aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-05-04 10:00:16 -0400
committerTakashi Iwai <tiwai@suse.de>2009-05-04 10:00:16 -0400
commit3a20ac2c52b1317f5a5f0bd9cd3cbe8495ddd026 (patch)
tree9a912f2609cefb9698b5cce09cd240bd6dbd09fb /sound
parent18cc8d8d9b74c446832336d8f6e1afb145f9431b (diff)
parent3e5b50165fd0be080044586f43fcdd460ed27610 (diff)
Merge branch 'fix/pcm-jiffies-check' into fix/asoc
Diffstat (limited to 'sound')
-rw-r--r--sound/Kconfig2
-rw-r--r--sound/Makefile2
-rw-r--r--sound/aoa/aoa-gpio.h2
-rw-r--r--sound/aoa/codecs/onyx.c76
-rw-r--r--sound/aoa/codecs/tas.c66
-rw-r--r--sound/aoa/core/gpio-feature.c17
-rw-r--r--sound/aoa/fabrics/layout.c81
-rw-r--r--sound/aoa/soundbus/i2sbus/core.c22
-rw-r--r--sound/arm/Kconfig11
-rw-r--r--sound/arm/Makefile3
-rw-r--r--sound/arm/aaci.c6
-rw-r--r--sound/arm/pxa2xx-ac97-lib.c3
-rw-r--r--sound/arm/pxa2xx-ac97.c2
-rw-r--r--sound/arm/pxa2xx-pcm-lib.c3
-rw-r--r--sound/arm/sa11xx-uda1341.c984
-rw-r--r--sound/atmel/Kconfig19
-rw-r--r--sound/atmel/Makefile5
-rw-r--r--sound/atmel/abdac.c602
-rw-r--r--sound/atmel/ac97c.c1022
-rw-r--r--sound/atmel/ac97c.h73
-rw-r--r--sound/core/control.c42
-rw-r--r--sound/core/hwdep.c9
-rw-r--r--sound/core/info.c31
-rw-r--r--sound/core/init.c42
-rw-r--r--sound/core/jack.c50
-rw-r--r--sound/core/misc.c10
-rw-r--r--sound/core/oss/mixer_oss.c11
-rw-r--r--sound/core/oss/pcm_oss.c57
-rw-r--r--sound/core/oss/pcm_plugin.h4
-rw-r--r--sound/core/oss/rate.c2
-rw-r--r--sound/core/pcm.c3
-rw-r--r--sound/core/pcm_compat.c11
-rw-r--r--sound/core/pcm_lib.c195
-rw-r--r--sound/core/pcm_native.c103
-rw-r--r--sound/core/pcm_timer.c6
-rw-r--r--sound/core/rawmidi.c379
-rw-r--r--sound/core/seq/oss/seq_oss_device.h2
-rw-r--r--sound/core/seq/seq_compat.c9
-rw-r--r--sound/core/seq/seq_prioq.c3
-rw-r--r--sound/core/sgbuf.c7
-rw-r--r--sound/core/timer.c17
-rw-r--r--sound/core/vmaster.c62
-rw-r--r--sound/drivers/Kconfig2
-rw-r--r--sound/drivers/mtpav.c15
-rw-r--r--sound/drivers/mts64.c2
-rw-r--r--sound/drivers/opl3/opl3_lib.c2
-rw-r--r--sound/drivers/opl3/opl3_midi.c30
-rw-r--r--sound/drivers/opl3/opl3_oss.c8
-rw-r--r--sound/drivers/opl3/opl3_synth.c2
-rw-r--r--sound/drivers/pcsp/pcsp.c2
-rw-r--r--sound/drivers/serial-u16550.c18
-rw-r--r--sound/drivers/virmidi.c4
-rw-r--r--sound/drivers/vx/vx_core.c3
-rw-r--r--sound/drivers/vx/vx_hwdep.c12
-rw-r--r--sound/drivers/vx/vx_uer.c2
-rw-r--r--sound/i2c/Makefile2
-rw-r--r--sound/i2c/l3/Makefile8
-rw-r--r--sound/i2c/l3/uda1341.c935
-rw-r--r--sound/i2c/other/tea575x-tuner.c302
-rw-r--r--sound/isa/Kconfig69
-rw-r--r--sound/isa/Makefile2
-rw-r--r--sound/isa/ad1816a/ad1816a.c14
-rw-r--r--sound/isa/ad1816a/ad1816a_lib.c11
-rw-r--r--sound/isa/cmi8330.c68
-rw-r--r--sound/isa/cs423x/Makefile8
-rw-r--r--sound/isa/cs423x/cs4232.c2
-rw-r--r--sound/isa/cs423x/cs4236.c153
-rw-r--r--sound/isa/cs423x/cs4236_lib.c45
-rw-r--r--sound/isa/es1688/es1688.c23
-rw-r--r--sound/isa/es1688/es1688_lib.c23
-rw-r--r--sound/isa/gus/gus_dma.c27
-rw-r--r--sound/isa/gus/gus_irq.c6
-rw-r--r--sound/isa/gus/gus_pcm.c26
-rw-r--r--sound/isa/gus/gus_uart.c10
-rw-r--r--sound/isa/gus/interwave.c16
-rw-r--r--sound/isa/msnd/Makefile9
-rw-r--r--sound/isa/msnd/msnd.c707
-rw-r--r--sound/isa/msnd/msnd.h308
-rw-r--r--sound/isa/msnd/msnd_classic.c3
-rw-r--r--sound/isa/msnd/msnd_classic.h129
-rw-r--r--sound/isa/msnd/msnd_midi.c180
-rw-r--r--sound/isa/msnd/msnd_pinnacle.c1238
-rw-r--r--sound/isa/msnd/msnd_pinnacle.h181
-rw-r--r--sound/isa/msnd/msnd_pinnacle_mixer.c343
-rw-r--r--sound/isa/opl3sa2.c33
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c40
-rw-r--r--sound/isa/sb/sb16_csp.c19
-rw-r--r--sound/isa/sb/sb_mixer.c156
-rw-r--r--sound/isa/sc6000.c4
-rw-r--r--sound/isa/sscape.c189
-rw-r--r--sound/isa/wavefront/wavefront.c4
-rw-r--r--sound/isa/wavefront/wavefront_fx.c30
-rw-r--r--sound/isa/wavefront/wavefront_synth.c13
-rw-r--r--sound/isa/wavefront/yss225.c2739
-rw-r--r--sound/isa/wss/wss_lib.c160
-rw-r--r--sound/mips/au1x00.c2
-rw-r--r--sound/oss/ad1848.c4
-rw-r--r--sound/oss/au1550_ac97.c2
-rw-r--r--sound/oss/audio.c2
-rw-r--r--sound/oss/dmabuf.c2
-rw-r--r--sound/oss/dmasound/dmasound_atari.c20
-rw-r--r--sound/oss/pas2_card.c4
-rw-r--r--sound/oss/pss.c14
-rw-r--r--sound/oss/sequencer.c3
-rw-r--r--sound/oss/sh_dac_audio.c2
-rw-r--r--sound/oss/swarm_cs4297a.c2
-rw-r--r--sound/oss/vwsnd.c2
-rw-r--r--sound/pci/Kconfig27
-rw-r--r--sound/pci/ac97/ac97_codec.c10
-rw-r--r--sound/pci/ac97/ac97_proc.c2
-rw-r--r--sound/pci/ad1889.c4
-rw-r--r--sound/pci/ak4531_codec.c3
-rw-r--r--sound/pci/ali5451/ali5451.c8
-rw-r--r--sound/pci/als300.c6
-rw-r--r--sound/pci/als4000.c4
-rw-r--r--sound/pci/atiixp.c6
-rw-r--r--sound/pci/au88x0/au88x0.c4
-rw-r--r--sound/pci/au88x0/au88x0_a3d.c7
-rw-r--r--sound/pci/au88x0/au88x0_core.c21
-rw-r--r--sound/pci/au88x0/au88x0_synth.c39
-rw-r--r--sound/pci/aw2/aw2-alsa.c6
-rw-r--r--sound/pci/azt3328.c12
-rw-r--r--sound/pci/bt87x.c6
-rw-r--r--sound/pci/ca0106/ca0106_main.c103
-rw-r--r--sound/pci/cmipci.c2
-rw-r--r--sound/pci/cs4281.c6
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c6
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.h6
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c6
-rw-r--r--sound/pci/echoaudio/Makefile4
-rw-r--r--sound/pci/echoaudio/echo3g_dsp.c2
-rw-r--r--sound/pci/echoaudio/echoaudio.c17
-rw-r--r--sound/pci/echoaudio/echoaudio.h3
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c3
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.c6
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.h9
-rw-r--r--sound/pci/echoaudio/gina20_dsp.c4
-rw-r--r--sound/pci/echoaudio/indigo_dsp.c12
-rw-r--r--sound/pci/echoaudio/indigo_express_dsp.c119
-rw-r--r--sound/pci/echoaudio/indigodj_dsp.c12
-rw-r--r--sound/pci/echoaudio/indigodjx.c107
-rw-r--r--sound/pci/echoaudio/indigodjx_dsp.c68
-rw-r--r--sound/pci/echoaudio/indigoio_dsp.c12
-rw-r--r--sound/pci/echoaudio/indigoiox.c109
-rw-r--r--sound/pci/echoaudio/indigoiox_dsp.c68
-rw-r--r--sound/pci/echoaudio/layla20_dsp.c4
-rw-r--r--sound/pci/echoaudio/mia_dsp.c16
-rw-r--r--sound/pci/echoaudio/midi.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_callback.c7
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c12
-rw-r--r--sound/pci/emu10k1/emu10k1x.c4
-rw-r--r--sound/pci/emu10k1/emufx.c52
-rw-r--r--sound/pci/emu10k1/emupcm.c37
-rw-r--r--sound/pci/emu10k1/io.c6
-rw-r--r--sound/pci/emu10k1/p16v.c100
-rw-r--r--sound/pci/emu10k1/voice.c12
-rw-r--r--sound/pci/ens1370.c3
-rw-r--r--sound/pci/es1938.c27
-rw-r--r--sound/pci/es1968.c4
-rw-r--r--sound/pci/hda/hda_beep.c1
-rw-r--r--sound/pci/hda/hda_beep.h2
-rw-r--r--sound/pci/hda/hda_codec.c519
-rw-r--r--sound/pci/hda/hda_codec.h20
-rw-r--r--sound/pci/hda/hda_generic.c4
-rw-r--r--sound/pci/hda/hda_hwdep.c255
-rw-r--r--sound/pci/hda/hda_intel.c201
-rw-r--r--sound/pci/hda/hda_local.h38
-rw-r--r--sound/pci/hda/hda_proc.c20
-rw-r--r--sound/pci/hda/patch_analog.c265
-rw-r--r--sound/pci/hda/patch_cmedia.c12
-rw-r--r--sound/pci/hda/patch_conexant.c401
-rw-r--r--sound/pci/hda/patch_intelhdmi.c61
-rw-r--r--sound/pci/hda/patch_nvhdmi.c2
-rw-r--r--sound/pci/hda/patch_realtek.c1320
-rw-r--r--sound/pci/hda/patch_sigmatel.c1581
-rw-r--r--sound/pci/hda/patch_via.c17
-rw-r--r--sound/pci/ice1712/ice1712.c6
-rw-r--r--sound/pci/ice1712/ice1724.c60
-rw-r--r--sound/pci/ice1712/juli.c5
-rw-r--r--sound/pci/ice1712/prodigy192.c13
-rw-r--r--sound/pci/intel8x0.c186
-rw-r--r--sound/pci/intel8x0m.c14
-rw-r--r--sound/pci/korg1212/korg1212.c6
-rw-r--r--sound/pci/maestro3.c4
-rw-r--r--sound/pci/mixart/mixart.c3
-rw-r--r--sound/pci/mixart/mixart_hwdep.c58
-rw-r--r--sound/pci/oxygen/hifier.c12
-rw-r--r--sound/pci/oxygen/oxygen.c114
-rw-r--r--sound/pci/oxygen/oxygen.h22
-rw-r--r--sound/pci/oxygen/oxygen_io.c31
-rw-r--r--sound/pci/oxygen/oxygen_lib.c100
-rw-r--r--sound/pci/oxygen/virtuoso.c342
-rw-r--r--sound/pci/pcxhr/pcxhr.c43
-rw-r--r--sound/pci/pcxhr/pcxhr.h17
-rw-r--r--sound/pci/pcxhr/pcxhr_core.h2
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c12
-rw-r--r--sound/pci/pcxhr/pcxhr_mix22.c40
-rw-r--r--sound/pci/pcxhr/pcxhr_mix22.h3
-rw-r--r--sound/pci/pcxhr/pcxhr_mixer.c8
-rw-r--r--sound/pci/rme9652/hdsp.c515
-rw-r--r--sound/pci/rme9652/hdspm.c9
-rw-r--r--sound/pci/sis7019.c2
-rw-r--r--sound/pci/sonicvibes.c113
-rw-r--r--sound/pci/trident/trident_main.c61
-rw-r--r--sound/pci/via82xx.c23
-rw-r--r--sound/pci/via82xx_modem.c5
-rw-r--r--sound/pci/vx222/vx222_ops.c8
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c14
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_core.c23
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_irq.c4
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c3
-rw-r--r--sound/ppc/Kconfig1
-rw-r--r--sound/ppc/awacs.c88
-rw-r--r--sound/ppc/burgundy.c2
-rw-r--r--sound/ppc/daca.c2
-rw-r--r--sound/ppc/keywest.c82
-rw-r--r--sound/ppc/pmac.c11
-rw-r--r--sound/ppc/powermac.c4
-rw-r--r--sound/ppc/snd_ps3.c4
-rw-r--r--sound/ppc/tumbler.c13
-rw-r--r--sound/sh/Kconfig1
-rw-r--r--sound/sh/aica.c2
-rw-r--r--sound/soc/au1x/dbdma2.c2
-rw-r--r--sound/soc/blackfin/Kconfig2
-rw-r--r--sound/soc/blackfin/bf5xx-ac97-pcm.c4
-rw-r--r--sound/soc/blackfin/bf5xx-i2s-pcm.c4
-rw-r--r--sound/soc/fsl/mpc5200_psc_i2s.c3
-rw-r--r--sound/soc/omap/omap-pcm.c2
-rw-r--r--sound/soc/pxa/corgi.c2
-rw-r--r--sound/soc/pxa/em-x270.c2
-rw-r--r--sound/soc/pxa/palm27x.c27
-rw-r--r--sound/soc/pxa/poodle.c2
-rw-r--r--sound/soc/pxa/pxa-ssp.c2
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c2
-rw-r--r--sound/soc/pxa/pxa2xx-i2s.c2
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c4
-rw-r--r--sound/soc/pxa/spitz.c2
-rw-r--r--sound/soc/pxa/tosa.c2
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c2
-rw-r--r--sound/soc/sh/dma-sh7760.c3
-rw-r--r--sound/sparc/amd7930.c5
-rw-r--r--sound/sparc/cs4231.c28
-rw-r--r--sound/sparc/dbri.c3
-rw-r--r--sound/synth/emux/emux_hwdep.c21
-rw-r--r--sound/synth/emux/emux_oss.c2
-rw-r--r--sound/synth/emux/emux_seq.c16
-rw-r--r--sound/synth/emux/emux_synth.c6
-rw-r--r--sound/synth/emux/soundfont.c28
-rw-r--r--sound/usb/Kconfig3
-rw-r--r--sound/usb/caiaq/Makefile4
-rw-r--r--sound/usb/caiaq/audio.c (renamed from sound/usb/caiaq/caiaq-audio.c)39
-rw-r--r--sound/usb/caiaq/audio.h (renamed from sound/usb/caiaq/caiaq-audio.h)0
-rw-r--r--sound/usb/caiaq/control.c (renamed from sound/usb/caiaq/caiaq-control.c)52
-rw-r--r--sound/usb/caiaq/control.h (renamed from sound/usb/caiaq/caiaq-control.h)0
-rw-r--r--sound/usb/caiaq/device.c (renamed from sound/usb/caiaq/caiaq-device.c)47
-rw-r--r--sound/usb/caiaq/device.h (renamed from sound/usb/caiaq/caiaq-device.h)6
-rw-r--r--sound/usb/caiaq/input.c (renamed from sound/usb/caiaq/caiaq-input.c)11
-rw-r--r--sound/usb/caiaq/input.h (renamed from sound/usb/caiaq/caiaq-input.h)0
-rw-r--r--sound/usb/caiaq/midi.c (renamed from sound/usb/caiaq/caiaq-midi.c)13
-rw-r--r--sound/usb/caiaq/midi.h (renamed from sound/usb/caiaq/caiaq-midi.h)0
-rw-r--r--sound/usb/usbaudio.c343
-rw-r--r--sound/usb/usbmidi.c1
-rw-r--r--sound/usb/usbmixer.c164
-rw-r--r--sound/usb/usbmixer_maps.c26
-rw-r--r--sound/usb/usbquirks.h18
-rw-r--r--sound/usb/usx2y/us122l.c22
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c28
-rw-r--r--sound/usb/usx2y/usb_stream.c69
-rw-r--r--sound/usb/usx2y/usbusx2y.c4
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c3
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.h2
271 files changed, 12461 insertions, 8971 deletions
diff --git a/sound/Kconfig b/sound/Kconfig
index 200aca1faa71..1eceb85287c5 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -60,6 +60,8 @@ source "sound/aoa/Kconfig"
60 60
61source "sound/arm/Kconfig" 61source "sound/arm/Kconfig"
62 62
63source "sound/atmel/Kconfig"
64
63source "sound/spi/Kconfig" 65source "sound/spi/Kconfig"
64 66
65source "sound/mips/Kconfig" 67source "sound/mips/Kconfig"
diff --git a/sound/Makefile b/sound/Makefile
index c76d70716fa5..ec467decfa79 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -6,7 +6,7 @@ obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o
6obj-$(CONFIG_SOUND_PRIME) += oss/ 6obj-$(CONFIG_SOUND_PRIME) += oss/
7obj-$(CONFIG_DMASOUND) += oss/ 7obj-$(CONFIG_DMASOUND) += oss/
8obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \ 8obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
9 sparc/ spi/ parisc/ pcmcia/ mips/ soc/ 9 sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/
10obj-$(CONFIG_SND_AOA) += aoa/ 10obj-$(CONFIG_SND_AOA) += aoa/
11 11
12# This one must be compilable even if sound is configured out 12# This one must be compilable even if sound is configured out
diff --git a/sound/aoa/aoa-gpio.h b/sound/aoa/aoa-gpio.h
index ee64f5de8966..6065b0344e23 100644
--- a/sound/aoa/aoa-gpio.h
+++ b/sound/aoa/aoa-gpio.h
@@ -34,10 +34,12 @@ struct gpio_methods {
34 void (*set_headphone)(struct gpio_runtime *rt, int on); 34 void (*set_headphone)(struct gpio_runtime *rt, int on);
35 void (*set_speakers)(struct gpio_runtime *rt, int on); 35 void (*set_speakers)(struct gpio_runtime *rt, int on);
36 void (*set_lineout)(struct gpio_runtime *rt, int on); 36 void (*set_lineout)(struct gpio_runtime *rt, int on);
37 void (*set_master)(struct gpio_runtime *rt, int on);
37 38
38 int (*get_headphone)(struct gpio_runtime *rt); 39 int (*get_headphone)(struct gpio_runtime *rt);
39 int (*get_speakers)(struct gpio_runtime *rt); 40 int (*get_speakers)(struct gpio_runtime *rt);
40 int (*get_lineout)(struct gpio_runtime *rt); 41 int (*get_lineout)(struct gpio_runtime *rt);
42 int (*get_master)(struct gpio_runtime *rt);
41 43
42 void (*set_hw_reset)(struct gpio_runtime *rt, int on); 44 void (*set_hw_reset)(struct gpio_runtime *rt, int on);
43 45
diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 15500b9d2da0..84bb07d39a7f 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -47,7 +47,7 @@ MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
47struct onyx { 47struct onyx {
48 /* cache registers 65 to 80, they are write-only! */ 48 /* cache registers 65 to 80, they are write-only! */
49 u8 cache[16]; 49 u8 cache[16];
50 struct i2c_client i2c; 50 struct i2c_client *i2c;
51 struct aoa_codec codec; 51 struct aoa_codec codec;
52 u32 initialised:1, 52 u32 initialised:1,
53 spdif_locked:1, 53 spdif_locked:1,
@@ -72,7 +72,7 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
72 *value = onyx->cache[reg-FIRSTREGISTER]; 72 *value = onyx->cache[reg-FIRSTREGISTER];
73 return 0; 73 return 0;
74 } 74 }
75 v = i2c_smbus_read_byte_data(&onyx->i2c, reg); 75 v = i2c_smbus_read_byte_data(onyx->i2c, reg);
76 if (v < 0) 76 if (v < 0)
77 return -1; 77 return -1;
78 *value = (u8)v; 78 *value = (u8)v;
@@ -84,7 +84,7 @@ static int onyx_write_register(struct onyx *onyx, u8 reg, u8 value)
84{ 84{
85 int result; 85 int result;
86 86
87 result = i2c_smbus_write_byte_data(&onyx->i2c, reg, value); 87 result = i2c_smbus_write_byte_data(onyx->i2c, reg, value);
88 if (!result) 88 if (!result)
89 onyx->cache[reg-FIRSTREGISTER] = value; 89 onyx->cache[reg-FIRSTREGISTER] = value;
90 return result; 90 return result;
@@ -996,12 +996,45 @@ static void onyx_exit_codec(struct aoa_codec *codec)
996 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx); 996 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
997} 997}
998 998
999static struct i2c_driver onyx_driver;
1000
1001static int onyx_create(struct i2c_adapter *adapter, 999static int onyx_create(struct i2c_adapter *adapter,
1002 struct device_node *node, 1000 struct device_node *node,
1003 int addr) 1001 int addr)
1004{ 1002{
1003 struct i2c_board_info info;
1004 struct i2c_client *client;
1005
1006 memset(&info, 0, sizeof(struct i2c_board_info));
1007 strlcpy(info.type, "aoa_codec_onyx", I2C_NAME_SIZE);
1008 info.addr = addr;
1009 info.platform_data = node;
1010 client = i2c_new_device(adapter, &info);
1011 if (!client)
1012 return -ENODEV;
1013
1014 /*
1015 * We know the driver is already loaded, so the device should be
1016 * already bound. If not it means binding failed, which suggests
1017 * the device doesn't really exist and should be deleted.
1018 * Ideally this would be replaced by better checks _before_
1019 * instantiating the device.
1020 */
1021 if (!client->driver) {
1022 i2c_unregister_device(client);
1023 return -ENODEV;
1024 }
1025
1026 /*
1027 * Let i2c-core delete that device on driver removal.
1028 * This is safe because i2c-core holds the core_lock mutex for us.
1029 */
1030 list_add_tail(&client->detected, &client->driver->clients);
1031 return 0;
1032}
1033
1034static int onyx_i2c_probe(struct i2c_client *client,
1035 const struct i2c_device_id *id)
1036{
1037 struct device_node *node = client->dev.platform_data;
1005 struct onyx *onyx; 1038 struct onyx *onyx;
1006 u8 dummy; 1039 u8 dummy;
1007 1040
@@ -1011,20 +1044,12 @@ static int onyx_create(struct i2c_adapter *adapter,
1011 return -ENOMEM; 1044 return -ENOMEM;
1012 1045
1013 mutex_init(&onyx->mutex); 1046 mutex_init(&onyx->mutex);
1014 onyx->i2c.driver = &onyx_driver; 1047 onyx->i2c = client;
1015 onyx->i2c.adapter = adapter; 1048 i2c_set_clientdata(client, onyx);
1016 onyx->i2c.addr = addr & 0x7f;
1017 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE);
1018
1019 if (i2c_attach_client(&onyx->i2c)) {
1020 printk(KERN_ERR PFX "failed to attach to i2c\n");
1021 goto fail;
1022 }
1023 1049
1024 /* we try to read from register ONYX_REG_CONTROL 1050 /* we try to read from register ONYX_REG_CONTROL
1025 * to check if the codec is present */ 1051 * to check if the codec is present */
1026 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &dummy) != 0) { 1052 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &dummy) != 0) {
1027 i2c_detach_client(&onyx->i2c);
1028 printk(KERN_ERR PFX "failed to read control register\n"); 1053 printk(KERN_ERR PFX "failed to read control register\n");
1029 goto fail; 1054 goto fail;
1030 } 1055 }
@@ -1036,14 +1061,14 @@ static int onyx_create(struct i2c_adapter *adapter,
1036 onyx->codec.node = of_node_get(node); 1061 onyx->codec.node = of_node_get(node);
1037 1062
1038 if (aoa_codec_register(&onyx->codec)) { 1063 if (aoa_codec_register(&onyx->codec)) {
1039 i2c_detach_client(&onyx->i2c);
1040 goto fail; 1064 goto fail;
1041 } 1065 }
1042 printk(KERN_DEBUG PFX "created and attached onyx instance\n"); 1066 printk(KERN_DEBUG PFX "created and attached onyx instance\n");
1043 return 0; 1067 return 0;
1044 fail: 1068 fail:
1069 i2c_set_clientdata(client, NULL);
1045 kfree(onyx); 1070 kfree(onyx);
1046 return -EINVAL; 1071 return -ENODEV;
1047} 1072}
1048 1073
1049static int onyx_i2c_attach(struct i2c_adapter *adapter) 1074static int onyx_i2c_attach(struct i2c_adapter *adapter)
@@ -1080,28 +1105,33 @@ static int onyx_i2c_attach(struct i2c_adapter *adapter)
1080 return onyx_create(adapter, NULL, 0x47); 1105 return onyx_create(adapter, NULL, 0x47);
1081} 1106}
1082 1107
1083static int onyx_i2c_detach(struct i2c_client *client) 1108static int onyx_i2c_remove(struct i2c_client *client)
1084{ 1109{
1085 struct onyx *onyx = container_of(client, struct onyx, i2c); 1110 struct onyx *onyx = i2c_get_clientdata(client);
1086 int err;
1087 1111
1088 if ((err = i2c_detach_client(client)))
1089 return err;
1090 aoa_codec_unregister(&onyx->codec); 1112 aoa_codec_unregister(&onyx->codec);
1091 of_node_put(onyx->codec.node); 1113 of_node_put(onyx->codec.node);
1092 if (onyx->codec_info) 1114 if (onyx->codec_info)
1093 kfree(onyx->codec_info); 1115 kfree(onyx->codec_info);
1116 i2c_set_clientdata(client, onyx);
1094 kfree(onyx); 1117 kfree(onyx);
1095 return 0; 1118 return 0;
1096} 1119}
1097 1120
1121static const struct i2c_device_id onyx_i2c_id[] = {
1122 { "aoa_codec_onyx", 0 },
1123 { }
1124};
1125
1098static struct i2c_driver onyx_driver = { 1126static struct i2c_driver onyx_driver = {
1099 .driver = { 1127 .driver = {
1100 .name = "aoa_codec_onyx", 1128 .name = "aoa_codec_onyx",
1101 .owner = THIS_MODULE, 1129 .owner = THIS_MODULE,
1102 }, 1130 },
1103 .attach_adapter = onyx_i2c_attach, 1131 .attach_adapter = onyx_i2c_attach,
1104 .detach_client = onyx_i2c_detach, 1132 .probe = onyx_i2c_probe,
1133 .remove = onyx_i2c_remove,
1134 .id_table = onyx_i2c_id,
1105}; 1135};
1106 1136
1107static int __init onyx_init(void) 1137static int __init onyx_init(void)
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index 008e0f85097d..f0ebc971c686 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -82,7 +82,7 @@ MODULE_DESCRIPTION("tas codec driver for snd-aoa");
82 82
83struct tas { 83struct tas {
84 struct aoa_codec codec; 84 struct aoa_codec codec;
85 struct i2c_client i2c; 85 struct i2c_client *i2c;
86 u32 mute_l:1, mute_r:1 , 86 u32 mute_l:1, mute_r:1 ,
87 controls_created:1 , 87 controls_created:1 ,
88 drc_enabled:1, 88 drc_enabled:1,
@@ -108,9 +108,9 @@ static struct tas *codec_to_tas(struct aoa_codec *codec)
108static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data) 108static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data)
109{ 109{
110 if (len == 1) 110 if (len == 1)
111 return i2c_smbus_write_byte_data(&tas->i2c, reg, *data); 111 return i2c_smbus_write_byte_data(tas->i2c, reg, *data);
112 else 112 else
113 return i2c_smbus_write_i2c_block_data(&tas->i2c, reg, len, data); 113 return i2c_smbus_write_i2c_block_data(tas->i2c, reg, len, data);
114} 114}
115 115
116static void tas3004_set_drc(struct tas *tas) 116static void tas3004_set_drc(struct tas *tas)
@@ -882,12 +882,34 @@ static void tas_exit_codec(struct aoa_codec *codec)
882} 882}
883 883
884 884
885static struct i2c_driver tas_driver;
886
887static int tas_create(struct i2c_adapter *adapter, 885static int tas_create(struct i2c_adapter *adapter,
888 struct device_node *node, 886 struct device_node *node,
889 int addr) 887 int addr)
890{ 888{
889 struct i2c_board_info info;
890 struct i2c_client *client;
891
892 memset(&info, 0, sizeof(struct i2c_board_info));
893 strlcpy(info.type, "aoa_codec_tas", I2C_NAME_SIZE);
894 info.addr = addr;
895 info.platform_data = node;
896
897 client = i2c_new_device(adapter, &info);
898 if (!client)
899 return -ENODEV;
900
901 /*
902 * Let i2c-core delete that device on driver removal.
903 * This is safe because i2c-core holds the core_lock mutex for us.
904 */
905 list_add_tail(&client->detected, &client->driver->clients);
906 return 0;
907}
908
909static int tas_i2c_probe(struct i2c_client *client,
910 const struct i2c_device_id *id)
911{
912 struct device_node *node = client->dev.platform_data;
891 struct tas *tas; 913 struct tas *tas;
892 914
893 tas = kzalloc(sizeof(struct tas), GFP_KERNEL); 915 tas = kzalloc(sizeof(struct tas), GFP_KERNEL);
@@ -896,17 +918,11 @@ static int tas_create(struct i2c_adapter *adapter,
896 return -ENOMEM; 918 return -ENOMEM;
897 919
898 mutex_init(&tas->mtx); 920 mutex_init(&tas->mtx);
899 tas->i2c.driver = &tas_driver; 921 tas->i2c = client;
900 tas->i2c.adapter = adapter; 922 i2c_set_clientdata(client, tas);
901 tas->i2c.addr = addr; 923
902 /* seems that half is a saner default */ 924 /* seems that half is a saner default */
903 tas->drc_range = TAS3004_DRC_MAX / 2; 925 tas->drc_range = TAS3004_DRC_MAX / 2;
904 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE);
905
906 if (i2c_attach_client(&tas->i2c)) {
907 printk(KERN_ERR PFX "failed to attach to i2c\n");
908 goto fail;
909 }
910 926
911 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN); 927 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
912 tas->codec.owner = THIS_MODULE; 928 tas->codec.owner = THIS_MODULE;
@@ -915,14 +931,12 @@ static int tas_create(struct i2c_adapter *adapter,
915 tas->codec.node = of_node_get(node); 931 tas->codec.node = of_node_get(node);
916 932
917 if (aoa_codec_register(&tas->codec)) { 933 if (aoa_codec_register(&tas->codec)) {
918 goto detach; 934 goto fail;
919 } 935 }
920 printk(KERN_DEBUG 936 printk(KERN_DEBUG
921 "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n", 937 "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n",
922 addr, node->full_name); 938 (unsigned int)client->addr, node->full_name);
923 return 0; 939 return 0;
924 detach:
925 i2c_detach_client(&tas->i2c);
926 fail: 940 fail:
927 mutex_destroy(&tas->mtx); 941 mutex_destroy(&tas->mtx);
928 kfree(tas); 942 kfree(tas);
@@ -970,14 +984,11 @@ static int tas_i2c_attach(struct i2c_adapter *adapter)
970 return -ENODEV; 984 return -ENODEV;
971} 985}
972 986
973static int tas_i2c_detach(struct i2c_client *client) 987static int tas_i2c_remove(struct i2c_client *client)
974{ 988{
975 struct tas *tas = container_of(client, struct tas, i2c); 989 struct tas *tas = i2c_get_clientdata(client);
976 int err;
977 u8 tmp = TAS_ACR_ANALOG_PDOWN; 990 u8 tmp = TAS_ACR_ANALOG_PDOWN;
978 991
979 if ((err = i2c_detach_client(client)))
980 return err;
981 aoa_codec_unregister(&tas->codec); 992 aoa_codec_unregister(&tas->codec);
982 of_node_put(tas->codec.node); 993 of_node_put(tas->codec.node);
983 994
@@ -989,13 +1000,20 @@ static int tas_i2c_detach(struct i2c_client *client)
989 return 0; 1000 return 0;
990} 1001}
991 1002
1003static const struct i2c_device_id tas_i2c_id[] = {
1004 { "aoa_codec_tas", 0 },
1005 { }
1006};
1007
992static struct i2c_driver tas_driver = { 1008static struct i2c_driver tas_driver = {
993 .driver = { 1009 .driver = {
994 .name = "aoa_codec_tas", 1010 .name = "aoa_codec_tas",
995 .owner = THIS_MODULE, 1011 .owner = THIS_MODULE,
996 }, 1012 },
997 .attach_adapter = tas_i2c_attach, 1013 .attach_adapter = tas_i2c_attach,
998 .detach_client = tas_i2c_detach, 1014 .probe = tas_i2c_probe,
1015 .remove = tas_i2c_remove,
1016 .id_table = tas_i2c_id,
999}; 1017};
1000 1018
1001static int __init tas_init(void) 1019static int __init tas_init(void)
diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c
index c93ad5dec66b..de8e03afa97b 100644
--- a/sound/aoa/core/gpio-feature.c
+++ b/sound/aoa/core/gpio-feature.c
@@ -14,7 +14,7 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include "../aoa.h" 15#include "../aoa.h"
16 16
17/* TODO: these are 20 global variables 17/* TODO: these are lots of global variables
18 * that aren't used on most machines... 18 * that aren't used on most machines...
19 * Move them into a dynamically allocated 19 * Move them into a dynamically allocated
20 * structure and use that. 20 * structure and use that.
@@ -23,6 +23,7 @@
23/* these are the GPIO numbers (register addresses as offsets into 23/* these are the GPIO numbers (register addresses as offsets into
24 * the GPIO space) */ 24 * the GPIO space) */
25static int headphone_mute_gpio; 25static int headphone_mute_gpio;
26static int master_mute_gpio;
26static int amp_mute_gpio; 27static int amp_mute_gpio;
27static int lineout_mute_gpio; 28static int lineout_mute_gpio;
28static int hw_reset_gpio; 29static int hw_reset_gpio;
@@ -32,6 +33,7 @@ static int linein_detect_gpio;
32 33
33/* see the SWITCH_GPIO macro */ 34/* see the SWITCH_GPIO macro */
34static int headphone_mute_gpio_activestate; 35static int headphone_mute_gpio_activestate;
36static int master_mute_gpio_activestate;
35static int amp_mute_gpio_activestate; 37static int amp_mute_gpio_activestate;
36static int lineout_mute_gpio_activestate; 38static int lineout_mute_gpio_activestate;
37static int hw_reset_gpio_activestate; 39static int hw_reset_gpio_activestate;
@@ -156,6 +158,7 @@ static int ftr_gpio_get_##name(struct gpio_runtime *rt) \
156FTR_GPIO(headphone, 0); 158FTR_GPIO(headphone, 0);
157FTR_GPIO(amp, 1); 159FTR_GPIO(amp, 1);
158FTR_GPIO(lineout, 2); 160FTR_GPIO(lineout, 2);
161FTR_GPIO(master, 3);
159 162
160static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on) 163static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
161{ 164{
@@ -172,6 +175,8 @@ static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
172 hw_reset_gpio, v); 175 hw_reset_gpio, v);
173} 176}
174 177
178static struct gpio_methods methods;
179
175static void ftr_gpio_all_amps_off(struct gpio_runtime *rt) 180static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)
176{ 181{
177 int saved; 182 int saved;
@@ -181,6 +186,8 @@ static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)
181 ftr_gpio_set_headphone(rt, 0); 186 ftr_gpio_set_headphone(rt, 0);
182 ftr_gpio_set_amp(rt, 0); 187 ftr_gpio_set_amp(rt, 0);
183 ftr_gpio_set_lineout(rt, 0); 188 ftr_gpio_set_lineout(rt, 0);
189 if (methods.set_master)
190 ftr_gpio_set_master(rt, 0);
184 rt->implementation_private = saved; 191 rt->implementation_private = saved;
185} 192}
186 193
@@ -193,6 +200,8 @@ static void ftr_gpio_all_amps_restore(struct gpio_runtime *rt)
193 ftr_gpio_set_headphone(rt, (s>>0)&1); 200 ftr_gpio_set_headphone(rt, (s>>0)&1);
194 ftr_gpio_set_amp(rt, (s>>1)&1); 201 ftr_gpio_set_amp(rt, (s>>1)&1);
195 ftr_gpio_set_lineout(rt, (s>>2)&1); 202 ftr_gpio_set_lineout(rt, (s>>2)&1);
203 if (methods.set_master)
204 ftr_gpio_set_master(rt, (s>>3)&1);
196} 205}
197 206
198static void ftr_handle_notify(struct work_struct *work) 207static void ftr_handle_notify(struct work_struct *work)
@@ -231,6 +240,12 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
231 get_gpio("hw-reset", "audio-hw-reset", 240 get_gpio("hw-reset", "audio-hw-reset",
232 &hw_reset_gpio, 241 &hw_reset_gpio,
233 &hw_reset_gpio_activestate); 242 &hw_reset_gpio_activestate);
243 if (get_gpio("master-mute", NULL,
244 &master_mute_gpio,
245 &master_mute_gpio_activestate)) {
246 methods.set_master = ftr_gpio_set_master;
247 methods.get_master = ftr_gpio_get_master;
248 }
234 249
235 headphone_detect_node = get_gpio("headphone-detect", NULL, 250 headphone_detect_node = get_gpio("headphone-detect", NULL,
236 &headphone_detect_gpio, 251 &headphone_detect_gpio,
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c
index ad60f5d10e82..fbf5c933baa4 100644
--- a/sound/aoa/fabrics/layout.c
+++ b/sound/aoa/fabrics/layout.c
@@ -1,16 +1,14 @@
1/* 1/*
2 * Apple Onboard Audio driver -- layout fabric 2 * Apple Onboard Audio driver -- layout/machine id fabric
3 * 3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
5 * 5 *
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 * 7 *
8 * 8 *
9 * This fabric module looks for sound codecs 9 * This fabric module looks for sound codecs based on the
10 * based on the layout-id property in the device tree. 10 * layout-id or device-id property in the device tree.
11 *
12 */ 11 */
13
14#include <asm/prom.h> 12#include <asm/prom.h>
15#include <linux/list.h> 13#include <linux/list.h>
16#include <linux/module.h> 14#include <linux/module.h>
@@ -63,7 +61,7 @@ struct codec_connect_info {
63#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0) 61#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
64 62
65struct layout { 63struct layout {
66 unsigned int layout_id; 64 unsigned int layout_id, device_id;
67 struct codec_connect_info codecs[MAX_CODECS_PER_BUS]; 65 struct codec_connect_info codecs[MAX_CODECS_PER_BUS];
68 int flags; 66 int flags;
69 67
@@ -111,6 +109,10 @@ MODULE_ALIAS("sound-layout-96");
111MODULE_ALIAS("sound-layout-98"); 109MODULE_ALIAS("sound-layout-98");
112MODULE_ALIAS("sound-layout-100"); 110MODULE_ALIAS("sound-layout-100");
113 111
112MODULE_ALIAS("aoa-device-id-14");
113MODULE_ALIAS("aoa-device-id-22");
114MODULE_ALIAS("aoa-device-id-35");
115
114/* onyx with all but microphone connected */ 116/* onyx with all but microphone connected */
115static struct codec_connection onyx_connections_nomic[] = { 117static struct codec_connection onyx_connections_nomic[] = {
116 { 118 {
@@ -518,6 +520,27 @@ static struct layout layouts[] = {
518 .connections = onyx_connections_noheadphones, 520 .connections = onyx_connections_noheadphones,
519 }, 521 },
520 }, 522 },
523 /* PowerMac3,4 */
524 { .device_id = 14,
525 .codecs[0] = {
526 .name = "tas",
527 .connections = tas_connections_noline,
528 },
529 },
530 /* PowerMac3,6 */
531 { .device_id = 22,
532 .codecs[0] = {
533 .name = "tas",
534 .connections = tas_connections_all,
535 },
536 },
537 /* PowerBook5,2 */
538 { .device_id = 35,
539 .codecs[0] = {
540 .name = "tas",
541 .connections = tas_connections_all,
542 },
543 },
521 {} 544 {}
522}; 545};
523 546
@@ -526,7 +549,7 @@ static struct layout *find_layout_by_id(unsigned int id)
526 struct layout *l; 549 struct layout *l;
527 550
528 l = layouts; 551 l = layouts;
529 while (l->layout_id) { 552 while (l->codecs[0].name) {
530 if (l->layout_id == id) 553 if (l->layout_id == id)
531 return l; 554 return l;
532 l++; 555 l++;
@@ -534,6 +557,19 @@ static struct layout *find_layout_by_id(unsigned int id)
534 return NULL; 557 return NULL;
535} 558}
536 559
560static struct layout *find_layout_by_device(unsigned int id)
561{
562 struct layout *l;
563
564 l = layouts;
565 while (l->codecs[0].name) {
566 if (l->device_id == id)
567 return l;
568 l++;
569 }
570 return NULL;
571}
572
537static void use_layout(struct layout *l) 573static void use_layout(struct layout *l)
538{ 574{
539 int i; 575 int i;
@@ -564,6 +600,7 @@ struct layout_dev {
564 struct snd_kcontrol *headphone_ctrl; 600 struct snd_kcontrol *headphone_ctrl;
565 struct snd_kcontrol *lineout_ctrl; 601 struct snd_kcontrol *lineout_ctrl;
566 struct snd_kcontrol *speaker_ctrl; 602 struct snd_kcontrol *speaker_ctrl;
603 struct snd_kcontrol *master_ctrl;
567 struct snd_kcontrol *headphone_detected_ctrl; 604 struct snd_kcontrol *headphone_detected_ctrl;
568 struct snd_kcontrol *lineout_detected_ctrl; 605 struct snd_kcontrol *lineout_detected_ctrl;
569 606
@@ -615,6 +652,7 @@ static struct snd_kcontrol_new n##_ctl = { \
615AMP_CONTROL(headphone, "Headphone Switch"); 652AMP_CONTROL(headphone, "Headphone Switch");
616AMP_CONTROL(speakers, "Speakers Switch"); 653AMP_CONTROL(speakers, "Speakers Switch");
617AMP_CONTROL(lineout, "Line-Out Switch"); 654AMP_CONTROL(lineout, "Line-Out Switch");
655AMP_CONTROL(master, "Master Switch");
618 656
619static int detect_choice_get(struct snd_kcontrol *kcontrol, 657static int detect_choice_get(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol) 658 struct snd_ctl_elem_value *ucontrol)
@@ -855,6 +893,11 @@ static void layout_attached_codec(struct aoa_codec *codec)
855 lineout = codec->gpio->methods->get_detect(codec->gpio, 893 lineout = codec->gpio->methods->get_detect(codec->gpio,
856 AOA_NOTIFY_LINE_OUT); 894 AOA_NOTIFY_LINE_OUT);
857 895
896 if (codec->gpio->methods->set_master) {
897 ctl = snd_ctl_new1(&master_ctl, codec->gpio);
898 ldev->master_ctrl = ctl;
899 aoa_snd_ctl_add(ctl);
900 }
858 while (cc->connected) { 901 while (cc->connected) {
859 if (cc->connected & CC_SPEAKERS) { 902 if (cc->connected & CC_SPEAKERS) {
860 if (headphones <= 0 && lineout <= 0) 903 if (headphones <= 0 && lineout <= 0)
@@ -938,8 +981,8 @@ static struct aoa_fabric layout_fabric = {
938static int aoa_fabric_layout_probe(struct soundbus_dev *sdev) 981static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
939{ 982{
940 struct device_node *sound = NULL; 983 struct device_node *sound = NULL;
941 const unsigned int *layout_id; 984 const unsigned int *id;
942 struct layout *layout; 985 struct layout *layout = NULL;
943 struct layout_dev *ldev = NULL; 986 struct layout_dev *ldev = NULL;
944 int err; 987 int err;
945 988
@@ -952,15 +995,18 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
952 if (sound->type && strcasecmp(sound->type, "soundchip") == 0) 995 if (sound->type && strcasecmp(sound->type, "soundchip") == 0)
953 break; 996 break;
954 } 997 }
955 if (!sound) return -ENODEV; 998 if (!sound)
999 return -ENODEV;
956 1000
957 layout_id = of_get_property(sound, "layout-id", NULL); 1001 id = of_get_property(sound, "layout-id", NULL);
958 if (!layout_id) 1002 if (id) {
959 goto outnodev; 1003 layout = find_layout_by_id(*id);
960 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n", 1004 } else {
961 *layout_id); 1005 id = of_get_property(sound, "device-id", NULL);
1006 if (id)
1007 layout = find_layout_by_device(*id);
1008 }
962 1009
963 layout = find_layout_by_id(*layout_id);
964 if (!layout) { 1010 if (!layout) {
965 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n"); 1011 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");
966 goto outnodev; 1012 goto outnodev;
@@ -976,6 +1022,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
976 ldev->layout = layout; 1022 ldev->layout = layout;
977 ldev->gpio.node = sound->parent; 1023 ldev->gpio.node = sound->parent;
978 switch (layout->layout_id) { 1024 switch (layout->layout_id) {
1025 case 0: /* anything with device_id, not layout_id */
979 case 41: /* that unknown machine no one seems to have */ 1026 case 41: /* that unknown machine no one seems to have */
980 case 51: /* PowerBook5,4 */ 1027 case 51: /* PowerBook5,4 */
981 case 58: /* Mac Mini */ 1028 case 58: /* Mac Mini */
diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
index be468edf3ecb..418c84c99d69 100644
--- a/sound/aoa/soundbus/i2sbus/core.c
+++ b/sound/aoa/soundbus/i2sbus/core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * i2sbus driver 2 * i2sbus driver
3 * 3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
5 * 5 *
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 */ 7 */
@@ -186,13 +186,25 @@ static int i2sbus_add_dev(struct macio_dev *macio,
186 } 186 }
187 } 187 }
188 if (i == 1) { 188 if (i == 1) {
189 const u32 *layout_id = 189 const u32 *id = of_get_property(sound, "layout-id", NULL);
190 of_get_property(sound, "layout-id", NULL); 190
191 if (layout_id) { 191 if (id) {
192 layout = *layout_id; 192 layout = *id;
193 snprintf(dev->sound.modalias, 32, 193 snprintf(dev->sound.modalias, 32,
194 "sound-layout-%d", layout); 194 "sound-layout-%d", layout);
195 ok = 1; 195 ok = 1;
196 } else {
197 id = of_get_property(sound, "device-id", NULL);
198 /*
199 * We probably cannot handle all device-id machines,
200 * so restrict to those we do handle for now.
201 */
202 if (id && (*id == 22 || *id == 14 || *id == 35)) {
203 snprintf(dev->sound.modalias, 32,
204 "aoa-device-id-%d", *id);
205 ok = 1;
206 layout = -1;
207 }
196 } 208 }
197 } 209 }
198 /* for the time being, until we can handle non-layout-id 210 /* for the time being, until we can handle non-layout-id
diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index f8e6de48d816..885683a3b0bd 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -11,17 +11,6 @@ menuconfig SND_ARM
11 11
12if SND_ARM 12if SND_ARM
13 13
14config SND_SA11XX_UDA1341
15 tristate "SA11xx UDA1341TS driver (iPaq H3600)"
16 depends on ARCH_SA1100 && L3
17 select SND_PCM
18 help
19 Say Y here if you have a Compaq iPaq H3x00 handheld computer
20 and want to use its Philips UDA 1341 audio chip.
21
22 To compile this driver as a module, choose M here: the module
23 will be called snd-sa11xx-uda1341.
24
25config SND_ARMAACI 14config SND_ARMAACI
26 tristate "ARM PrimeCell PL041 AC Link support" 15 tristate "ARM PrimeCell PL041 AC Link support"
27 depends on ARM_AMBA 16 depends on ARM_AMBA
diff --git a/sound/arm/Makefile b/sound/arm/Makefile
index 2054de11de8a..5a549ed6c8aa 100644
--- a/sound/arm/Makefile
+++ b/sound/arm/Makefile
@@ -2,9 +2,6 @@
2# Makefile for ALSA 2# Makefile for ALSA
3# 3#
4 4
5obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-sa11xx-uda1341.o
6snd-sa11xx-uda1341-objs := sa11xx-uda1341.o
7
8obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o 5obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o
9snd-aaci-objs := aaci.o devdma.o 6snd-aaci-objs := aaci.o devdma.o
10 7
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 7d39aac9ec14..7fbd68fab944 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -90,7 +90,7 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
90 */ 90 */
91 do { 91 do {
92 v = readl(aaci->base + AACI_SLFR); 92 v = readl(aaci->base + AACI_SLFR);
93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && timeout--); 93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && --timeout);
94 94
95 if (!timeout) 95 if (!timeout)
96 dev_err(&aaci->dev->dev, 96 dev_err(&aaci->dev->dev,
@@ -126,7 +126,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
126 */ 126 */
127 do { 127 do {
128 v = readl(aaci->base + AACI_SLFR); 128 v = readl(aaci->base + AACI_SLFR);
129 } while ((v & SLFR_1TXB) && timeout--); 129 } while ((v & SLFR_1TXB) && --timeout);
130 130
131 if (!timeout) { 131 if (!timeout) {
132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n"); 132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n");
@@ -147,7 +147,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
147 do { 147 do {
148 cond_resched(); 148 cond_resched();
149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV); 149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV);
150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && timeout--); 150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && --timeout);
151 151
152 if (!timeout) { 152 if (!timeout) {
153 dev_err(&aaci->dev->dev, "timeout on RX valid\n"); 153 dev_err(&aaci->dev->dev, "timeout on RX valid\n");
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 71bef45e9d31..a2c12d105c9a 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -21,7 +21,6 @@
21#include <sound/pxa2xx-lib.h> 21#include <sound/pxa2xx-lib.h>
22 22
23#include <asm/irq.h> 23#include <asm/irq.h>
24#include <mach/hardware.h>
25#include <mach/regs-ac97.h> 24#include <mach/regs-ac97.h>
26#include <mach/pxa2xx-gpio.h> 25#include <mach/pxa2xx-gpio.h>
27#include <mach/audio.h> 26#include <mach/audio.h>
@@ -365,7 +364,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_resume);
365int __devinit pxa2xx_ac97_hw_probe(struct platform_device *dev) 364int __devinit pxa2xx_ac97_hw_probe(struct platform_device *dev)
366{ 365{
367 int ret; 366 int ret;
368 struct pxa2xx_ac97_platform_data *pdata = dev->dev.platform_data; 367 pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
369 368
370 if (pdata) { 369 if (pdata) {
371 switch (pdata->reset_gpio) { 370 switch (pdata->reset_gpio) {
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 7ed100c80a5f..c570ebd9d177 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -20,8 +20,6 @@
20#include <sound/initval.h> 20#include <sound/initval.h>
21#include <sound/pxa2xx-lib.h> 21#include <sound/pxa2xx-lib.h>
22 22
23#include <mach/hardware.h>
24#include <mach/pxa-regs.h>
25#include <mach/regs-ac97.h> 23#include <mach/regs-ac97.h>
26#include <mach/audio.h> 24#include <mach/audio.h>
27 25
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index 75a0d746fb60..108b643229ba 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -12,8 +12,7 @@
12#include <sound/pcm_params.h> 12#include <sound/pcm_params.h>
13#include <sound/pxa2xx-lib.h> 13#include <sound/pxa2xx-lib.h>
14 14
15#include <asm/dma.h> 15#include <mach/dma.h>
16#include <mach/pxa-regs.h>
17 16
18#include "pxa2xx-pcm.h" 17#include "pxa2xx-pcm.h"
19 18
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
deleted file mode 100644
index 51d708c31e65..000000000000
--- a/sound/arm/sa11xx-uda1341.c
+++ /dev/null
@@ -1,984 +0,0 @@
1/*
2 * Driver for Philips UDA1341TS on Compaq iPAQ H3600 soundcard
3 * Copyright (C) 2002 Tomas Kasparek <tomas.kasparek@seznam.cz>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License.
7 *
8 * History:
9 *
10 * 2002-03-13 Tomas Kasparek initial release - based on h3600-uda1341.c from OSS
11 * 2002-03-20 Tomas Kasparek playback over ALSA is working
12 * 2002-03-28 Tomas Kasparek playback over OSS emulation is working
13 * 2002-03-29 Tomas Kasparek basic capture is working (native ALSA)
14 * 2002-03-29 Tomas Kasparek capture is working (OSS emulation)
15 * 2002-04-04 Tomas Kasparek better rates handling (allow non-standard rates)
16 * 2003-02-14 Brian Avery fixed full duplex mode, other updates
17 * 2003-02-20 Tomas Kasparek merged updates by Brian (except HAL)
18 * 2003-04-19 Jaroslav Kysela recoded DMA stuff to follow 2.4.18rmk3-hh24 kernel
19 * working suspend and resume
20 * 2003-04-28 Tomas Kasparek updated work by Jaroslav to compile it under 2.5.x again
21 * merged HAL layer (patches from Brian)
22 */
23
24/***************************************************************************************************
25*
26* To understand what Alsa Drivers should be doing look at "Writing an Alsa Driver" by Takashi Iwai
27* available in the Alsa doc section on the website
28*
29* A few notes to make things clearer. The UDA1341 is hooked up to Serial port 4 on the SA1100.
30* We are using SSP mode to talk to the UDA1341. The UDA1341 bit & wordselect clocks are generated
31* by this UART. Unfortunately, the clock only runs if the transmit buffer has something in it.
32* So, if we are just recording, we feed the transmit DMA stream a bunch of 0x0000 so that the
33* transmit buffer is full and the clock keeps going. The zeroes come from FLUSH_BASE_PHYS which
34* is a mem loc that always decodes to 0's w/ no off chip access.
35*
36* Some alsa terminology:
37* frame => num_channels * sample_size e.g stereo 16 bit is 2 * 16 = 32 bytes
38* period => the least number of bytes that will generate an interrupt e.g. we have a 1024 byte
39* buffer and 4 periods in the runtime structure this means we'll get an int every 256
40* bytes or 4 times per buffer.
41* A number of the sizes are in frames rather than bytes, use frames_to_bytes and
42* bytes_to_frames to convert. The easiest way to tell the units is to look at the
43* type i.e. runtime-> buffer_size is in frames and its type is snd_pcm_uframes_t
44*
45* Notes about the pointer fxn:
46* The pointer fxn needs to return the offset into the dma buffer in frames.
47* Interrupts must be blocked before calling the dma_get_pos fxn to avoid race with interrupts.
48*
49* Notes about pause/resume
50* Implementing this would be complicated so it's skipped. The problem case is:
51* A full duplex connection is going, then play is paused. At this point you need to start xmitting
52* 0's to keep the record active which means you cant just freeze the dma and resume it later you'd
53* need to save off the dma info, and restore it properly on a resume. Yeach!
54*
55* Notes about transfer methods:
56* The async write calls fail. I probably need to implement something else to support them?
57*
58***************************************************************************************************/
59
60#include <linux/module.h>
61#include <linux/moduleparam.h>
62#include <linux/init.h>
63#include <linux/err.h>
64#include <linux/platform_device.h>
65#include <linux/errno.h>
66#include <linux/ioctl.h>
67#include <linux/delay.h>
68#include <linux/slab.h>
69
70#ifdef CONFIG_PM
71#include <linux/pm.h>
72#endif
73
74#include <mach/hardware.h>
75#include <mach/h3600.h>
76#include <asm/mach-types.h>
77#include <asm/dma.h>
78
79#include <sound/core.h>
80#include <sound/pcm.h>
81#include <sound/initval.h>
82
83#include <linux/l3/l3.h>
84
85#undef DEBUG_MODE
86#undef DEBUG_FUNCTION_NAMES
87#include <sound/uda1341.h>
88
89/*
90 * FIXME: Is this enough as autodetection of 2.4.X-rmkY-hhZ kernels?
91 * We use DMA stuff from 2.4.18-rmk3-hh24 here to be able to compile this
92 * module for Familiar 0.6.1
93 */
94
95/* {{{ Type definitions */
96
97MODULE_AUTHOR("Tomas Kasparek <tomas.kasparek@seznam.cz>");
98MODULE_LICENSE("GPL");
99MODULE_DESCRIPTION("SA1100/SA1111 + UDA1341TS driver for ALSA");
100MODULE_SUPPORTED_DEVICE("{{UDA1341,iPAQ H3600 UDA1341TS}}");
101
102static char *id; /* ID for this card */
103
104module_param(id, charp, 0444);
105MODULE_PARM_DESC(id, "ID string for SA1100/SA1111 + UDA1341TS soundcard.");
106
107struct audio_stream {
108 char *id; /* identification string */
109 int stream_id; /* numeric identification */
110 dma_device_t dma_dev; /* device identifier for DMA */
111#ifdef HH_VERSION
112 dmach_t dmach; /* dma channel identification */
113#else
114 dma_regs_t *dma_regs; /* points to our DMA registers */
115#endif
116 unsigned int active:1; /* we are using this stream for transfer now */
117 int period; /* current transfer period */
118 int periods; /* current count of periods registerd in the DMA engine */
119 int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */
120 unsigned int old_offset;
121 spinlock_t dma_lock; /* for locking in DMA operations (see dma-sa1100.c in the kernel) */
122 struct snd_pcm_substream *stream;
123};
124
125struct sa11xx_uda1341 {
126 struct snd_card *card;
127 struct l3_client *uda1341;
128 struct snd_pcm *pcm;
129 long samplerate;
130 struct audio_stream s[2]; /* playback & capture */
131};
132
133static unsigned int rates[] = {
134 8000, 10666, 10985, 14647,
135 16000, 21970, 22050, 24000,
136 29400, 32000, 44100, 48000,
137};
138
139static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
140 .count = ARRAY_SIZE(rates),
141 .list = rates,
142 .mask = 0,
143};
144
145static struct platform_device *device;
146
147/* }}} */
148
149/* {{{ Clock and sample rate stuff */
150
151/*
152 * Stop-gap solution until rest of hh.org HAL stuff is merged.
153 */
154#define GPIO_H3600_CLK_SET0 GPIO_GPIO (12)
155#define GPIO_H3600_CLK_SET1 GPIO_GPIO (13)
156
157#ifdef CONFIG_SA1100_H3XXX
158#define clr_sa11xx_uda1341_egpio(x) clr_h3600_egpio(x)
159#define set_sa11xx_uda1341_egpio(x) set_h3600_egpio(x)
160#else
161#error This driver could serve H3x00 handhelds only!
162#endif
163
164static void sa11xx_uda1341_set_audio_clock(long val)
165{
166 switch (val) {
167 case 24000: case 32000: case 48000: /* 00: 12.288 MHz */
168 GPCR = GPIO_H3600_CLK_SET0 | GPIO_H3600_CLK_SET1;
169 break;
170
171 case 22050: case 29400: case 44100: /* 01: 11.2896 MHz */
172 GPSR = GPIO_H3600_CLK_SET0;
173 GPCR = GPIO_H3600_CLK_SET1;
174 break;
175
176 case 8000: case 10666: case 16000: /* 10: 4.096 MHz */
177 GPCR = GPIO_H3600_CLK_SET0;
178 GPSR = GPIO_H3600_CLK_SET1;
179 break;
180
181 case 10985: case 14647: case 21970: /* 11: 5.6245 MHz */
182 GPSR = GPIO_H3600_CLK_SET0 | GPIO_H3600_CLK_SET1;
183 break;
184 }
185}
186
187static void sa11xx_uda1341_set_samplerate(struct sa11xx_uda1341 *sa11xx_uda1341, long rate)
188{
189 int clk_div = 0;
190 int clk=0;
191
192 /* We don't want to mess with clocks when frames are in flight */
193 Ser4SSCR0 &= ~SSCR0_SSE;
194 /* wait for any frame to complete */
195 udelay(125);
196
197 /*
198 * We have the following clock sources:
199 * 4.096 MHz, 5.6245 MHz, 11.2896 MHz, 12.288 MHz
200 * Those can be divided either by 256, 384 or 512.
201 * This makes up 12 combinations for the following samplerates...
202 */
203 if (rate >= 48000)
204 rate = 48000;
205 else if (rate >= 44100)
206 rate = 44100;
207 else if (rate >= 32000)
208 rate = 32000;
209 else if (rate >= 29400)
210 rate = 29400;
211 else if (rate >= 24000)
212 rate = 24000;
213 else if (rate >= 22050)
214 rate = 22050;
215 else if (rate >= 21970)
216 rate = 21970;
217 else if (rate >= 16000)
218 rate = 16000;
219 else if (rate >= 14647)
220 rate = 14647;
221 else if (rate >= 10985)
222 rate = 10985;
223 else if (rate >= 10666)
224 rate = 10666;
225 else
226 rate = 8000;
227
228 /* Set the external clock generator */
229
230 sa11xx_uda1341_set_audio_clock(rate);
231
232 /* Select the clock divisor */
233 switch (rate) {
234 case 8000:
235 case 10985:
236 case 22050:
237 case 24000:
238 clk = F512;
239 clk_div = SSCR0_SerClkDiv(16);
240 break;
241 case 16000:
242 case 21970:
243 case 44100:
244 case 48000:
245 clk = F256;
246 clk_div = SSCR0_SerClkDiv(8);
247 break;
248 case 10666:
249 case 14647:
250 case 29400:
251 case 32000:
252 clk = F384;
253 clk_div = SSCR0_SerClkDiv(12);
254 break;
255 }
256
257 /* FMT setting should be moved away when other FMTs are added (FIXME) */
258 l3_command(sa11xx_uda1341->uda1341, CMD_FORMAT, (void *)LSB16);
259
260 l3_command(sa11xx_uda1341->uda1341, CMD_FS, (void *)clk);
261 Ser4SSCR0 = (Ser4SSCR0 & ~0xff00) + clk_div + SSCR0_SSE;
262 sa11xx_uda1341->samplerate = rate;
263}
264
265/* }}} */
266
267/* {{{ HW init and shutdown */
268
269static void sa11xx_uda1341_audio_init(struct sa11xx_uda1341 *sa11xx_uda1341)
270{
271 unsigned long flags;
272
273 /* Setup DMA stuff */
274 sa11xx_uda1341->s[SNDRV_PCM_STREAM_PLAYBACK].id = "UDA1341 out";
275 sa11xx_uda1341->s[SNDRV_PCM_STREAM_PLAYBACK].stream_id = SNDRV_PCM_STREAM_PLAYBACK;
276 sa11xx_uda1341->s[SNDRV_PCM_STREAM_PLAYBACK].dma_dev = DMA_Ser4SSPWr;
277
278 sa11xx_uda1341->s[SNDRV_PCM_STREAM_CAPTURE].id = "UDA1341 in";
279 sa11xx_uda1341->s[SNDRV_PCM_STREAM_CAPTURE].stream_id = SNDRV_PCM_STREAM_CAPTURE;
280 sa11xx_uda1341->s[SNDRV_PCM_STREAM_CAPTURE].dma_dev = DMA_Ser4SSPRd;
281
282 /* Initialize the UDA1341 internal state */
283
284 /* Setup the uarts */
285 local_irq_save(flags);
286 GAFR |= (GPIO_SSP_CLK);
287 GPDR &= ~(GPIO_SSP_CLK);
288 Ser4SSCR0 = 0;
289 Ser4SSCR0 = SSCR0_DataSize(16) + SSCR0_TI + SSCR0_SerClkDiv(8);
290 Ser4SSCR1 = SSCR1_SClkIactL + SSCR1_SClk1P + SSCR1_ExtClk;
291 Ser4SSCR0 |= SSCR0_SSE;
292 local_irq_restore(flags);
293
294 /* Enable the audio power */
295
296 clr_sa11xx_uda1341_egpio(IPAQ_EGPIO_CODEC_NRESET);
297 set_sa11xx_uda1341_egpio(IPAQ_EGPIO_AUDIO_ON);
298 set_sa11xx_uda1341_egpio(IPAQ_EGPIO_QMUTE);
299
300 /* Wait for the UDA1341 to wake up */
301 mdelay(1); //FIXME - was removed by Perex - Why?
302
303 /* Initialize the UDA1341 internal state */
304 l3_open(sa11xx_uda1341->uda1341);
305
306 /* external clock configuration (after l3_open - regs must be initialized */
307 sa11xx_uda1341_set_samplerate(sa11xx_uda1341, sa11xx_uda1341->samplerate);
308
309 /* Wait for the UDA1341 to wake up */
310 set_sa11xx_uda1341_egpio(IPAQ_EGPIO_CODEC_NRESET);
311 mdelay(1);
312
313 /* make the left and right channels unswapped (flip the WS latch) */
314 Ser4SSDR = 0;
315
316 clr_sa11xx_uda1341_egpio(IPAQ_EGPIO_QMUTE);
317}
318
319static void sa11xx_uda1341_audio_shutdown(struct sa11xx_uda1341 *sa11xx_uda1341)
320{
321 /* mute on */
322 set_sa11xx_uda1341_egpio(IPAQ_EGPIO_QMUTE);
323
324 /* disable the audio power and all signals leading to the audio chip */
325 l3_close(sa11xx_uda1341->uda1341);
326 Ser4SSCR0 = 0;
327 clr_sa11xx_uda1341_egpio(IPAQ_EGPIO_CODEC_NRESET);
328
329 /* power off and mute off */
330 /* FIXME - is muting off necesary??? */
331
332 clr_sa11xx_uda1341_egpio(IPAQ_EGPIO_AUDIO_ON);
333 clr_sa11xx_uda1341_egpio(IPAQ_EGPIO_QMUTE);
334}
335
336/* }}} */
337
338/* {{{ DMA staff */
339
340/*
341 * these are the address and sizes used to fill the xmit buffer
342 * so we can get a clock in record only mode
343 */
344#define FORCE_CLOCK_ADDR (dma_addr_t)FLUSH_BASE_PHYS
345#define FORCE_CLOCK_SIZE 4096 // was 2048
346
347// FIXME Why this value exactly - wrote comment
348#define DMA_BUF_SIZE 8176 /* <= MAX_DMA_SIZE from asm/arch-sa1100/dma.h */
349
350#ifdef HH_VERSION
351
352static int audio_dma_request(struct audio_stream *s, void (*callback)(void *, int))
353{
354 int ret;
355
356 ret = sa1100_request_dma(&s->dmach, s->id, s->dma_dev);
357 if (ret < 0) {
358 printk(KERN_ERR "unable to grab audio dma 0x%x\n", s->dma_dev);
359 return ret;
360 }
361 sa1100_dma_set_callback(s->dmach, callback);
362 return 0;
363}
364
365static inline void audio_dma_free(struct audio_stream *s)
366{
367 sa1100_free_dma(s->dmach);
368 s->dmach = -1;
369}
370
371#else
372
373static int audio_dma_request(struct audio_stream *s, void (*callback)(void *))
374{
375 int ret;
376
377 ret = sa1100_request_dma(s->dma_dev, s->id, callback, s, &s->dma_regs);
378 if (ret < 0)
379 printk(KERN_ERR "unable to grab audio dma 0x%x\n", s->dma_dev);
380 return ret;
381}
382
383static void audio_dma_free(struct audio_stream *s)
384{
385 sa1100_free_dma(s->dma_regs);
386 s->dma_regs = 0;
387}
388
389#endif
390
391static u_int audio_get_dma_pos(struct audio_stream *s)
392{
393 struct snd_pcm_substream *substream = s->stream;
394 struct snd_pcm_runtime *runtime = substream->runtime;
395 unsigned int offset;
396 unsigned long flags;
397 dma_addr_t addr;
398
399 // this must be called w/ interrupts locked out see dma-sa1100.c in the kernel
400 spin_lock_irqsave(&s->dma_lock, flags);
401#ifdef HH_VERSION
402 sa1100_dma_get_current(s->dmach, NULL, &addr);
403#else
404 addr = sa1100_get_dma_pos((s)->dma_regs);
405#endif
406 offset = addr - runtime->dma_addr;
407 spin_unlock_irqrestore(&s->dma_lock, flags);
408
409 offset = bytes_to_frames(runtime,offset);
410 if (offset >= runtime->buffer_size)
411 offset = 0;
412
413 return offset;
414}
415
416/*
417 * this stops the dma and clears the dma ptrs
418 */
419static void audio_stop_dma(struct audio_stream *s)
420{
421 unsigned long flags;
422
423 spin_lock_irqsave(&s->dma_lock, flags);
424 s->active = 0;
425 s->period = 0;
426 /* this stops the dma channel and clears the buffer ptrs */
427#ifdef HH_VERSION
428 sa1100_dma_flush_all(s->dmach);
429#else
430 sa1100_clear_dma(s->dma_regs);
431#endif
432 spin_unlock_irqrestore(&s->dma_lock, flags);
433}
434
435static void audio_process_dma(struct audio_stream *s)
436{
437 struct snd_pcm_substream *substream = s->stream;
438 struct snd_pcm_runtime *runtime;
439 unsigned int dma_size;
440 unsigned int offset;
441 int ret;
442
443 /* we are requested to process synchronization DMA transfer */
444 if (s->tx_spin) {
445 if (snd_BUG_ON(s->stream_id != SNDRV_PCM_STREAM_PLAYBACK))
446 return;
447 /* fill the xmit dma buffers and return */
448#ifdef HH_VERSION
449 sa1100_dma_set_spin(s->dmach, FORCE_CLOCK_ADDR, FORCE_CLOCK_SIZE);
450#else
451 while (1) {
452 ret = sa1100_start_dma(s->dma_regs, FORCE_CLOCK_ADDR, FORCE_CLOCK_SIZE);
453 if (ret)
454 return;
455 }
456#endif
457 return;
458 }
459
460 /* must be set here - only valid for running streams, not for forced_clock dma fills */
461 runtime = substream->runtime;
462 while (s->active && s->periods < runtime->periods) {
463 dma_size = frames_to_bytes(runtime, runtime->period_size);
464 if (s->old_offset) {
465 /* a little trick, we need resume from old position */
466 offset = frames_to_bytes(runtime, s->old_offset - 1);
467 s->old_offset = 0;
468 s->periods = 0;
469 s->period = offset / dma_size;
470 offset %= dma_size;
471 dma_size = dma_size - offset;
472 if (!dma_size)
473 continue; /* special case */
474 } else {
475 offset = dma_size * s->period;
476 snd_BUG_ON(dma_size > DMA_BUF_SIZE);
477 }
478#ifdef HH_VERSION
479 ret = sa1100_dma_queue_buffer(s->dmach, s, runtime->dma_addr + offset, dma_size);
480 if (ret)
481 return; //FIXME
482#else
483 ret = sa1100_start_dma((s)->dma_regs, runtime->dma_addr + offset, dma_size);
484 if (ret) {
485 printk(KERN_ERR "audio_process_dma: cannot queue DMA buffer (%i)\n", ret);
486 return;
487 }
488#endif
489
490 s->period++;
491 s->period %= runtime->periods;
492 s->periods++;
493 }
494}
495
496#ifdef HH_VERSION
497static void audio_dma_callback(void *data, int size)
498#else
499static void audio_dma_callback(void *data)
500#endif
501{
502 struct audio_stream *s = data;
503
504 /*
505 * If we are getting a callback for an active stream then we inform
506 * the PCM middle layer we've finished a period
507 */
508 if (s->active)
509 snd_pcm_period_elapsed(s->stream);
510
511 spin_lock(&s->dma_lock);
512 if (!s->tx_spin && s->periods > 0)
513 s->periods--;
514 audio_process_dma(s);
515 spin_unlock(&s->dma_lock);
516}
517
518/* }}} */
519
520/* {{{ PCM setting */
521
522/* {{{ trigger & timer */
523
524static int snd_sa11xx_uda1341_trigger(struct snd_pcm_substream *substream, int cmd)
525{
526 struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream);
527 int stream_id = substream->pstr->stream;
528 struct audio_stream *s = &chip->s[stream_id];
529 struct audio_stream *s1 = &chip->s[stream_id ^ 1];
530 int err = 0;
531
532 /* note local interrupts are already disabled in the midlevel code */
533 spin_lock(&s->dma_lock);
534 switch (cmd) {
535 case SNDRV_PCM_TRIGGER_START:
536 /* now we need to make sure a record only stream has a clock */
537 if (stream_id == SNDRV_PCM_STREAM_CAPTURE && !s1->active) {
538 /* we need to force fill the xmit DMA with zeros */
539 s1->tx_spin = 1;
540 audio_process_dma(s1);
541 }
542 /* this case is when you were recording then you turn on a
543 * playback stream so we stop (also clears it) the dma first,
544 * clear the sync flag and then we let it turned on
545 */
546 else {
547 s->tx_spin = 0;
548 }
549
550 /* requested stream startup */
551 s->active = 1;
552 audio_process_dma(s);
553 break;
554 case SNDRV_PCM_TRIGGER_STOP:
555 /* requested stream shutdown */
556 audio_stop_dma(s);
557
558 /*
559 * now we need to make sure a record only stream has a clock
560 * so if we're stopping a playback with an active capture
561 * we need to turn the 0 fill dma on for the xmit side
562 */
563 if (stream_id == SNDRV_PCM_STREAM_PLAYBACK && s1->active) {
564 /* we need to force fill the xmit DMA with zeros */
565 s->tx_spin = 1;
566 audio_process_dma(s);
567 }
568 /*
569 * we killed a capture only stream, so we should also kill
570 * the zero fill transmit
571 */
572 else {
573 if (s1->tx_spin) {
574 s1->tx_spin = 0;
575 audio_stop_dma(s1);
576 }
577 }
578
579 break;
580 case SNDRV_PCM_TRIGGER_SUSPEND:
581 s->active = 0;
582#ifdef HH_VERSION
583 sa1100_dma_stop(s->dmach);
584#else
585 //FIXME - DMA API
586#endif
587 s->old_offset = audio_get_dma_pos(s) + 1;
588#ifdef HH_VERSION
589 sa1100_dma_flush_all(s->dmach);
590#else
591 //FIXME - DMA API
592#endif
593 s->periods = 0;
594 break;
595 case SNDRV_PCM_TRIGGER_RESUME:
596 s->active = 1;
597 s->tx_spin = 0;
598 audio_process_dma(s);
599 if (stream_id == SNDRV_PCM_STREAM_CAPTURE && !s1->active) {
600 s1->tx_spin = 1;
601 audio_process_dma(s1);
602 }
603 break;
604 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
605#ifdef HH_VERSION
606 sa1100_dma_stop(s->dmach);
607#else
608 //FIXME - DMA API
609#endif
610 s->active = 0;
611 if (stream_id == SNDRV_PCM_STREAM_PLAYBACK) {
612 if (s1->active) {
613 s->tx_spin = 1;
614 s->old_offset = audio_get_dma_pos(s) + 1;
615#ifdef HH_VERSION
616 sa1100_dma_flush_all(s->dmach);
617#else
618 //FIXME - DMA API
619#endif
620 audio_process_dma(s);
621 }
622 } else {
623 if (s1->tx_spin) {
624 s1->tx_spin = 0;
625#ifdef HH_VERSION
626 sa1100_dma_flush_all(s1->dmach);
627#else
628 //FIXME - DMA API
629#endif
630 }
631 }
632 break;
633 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
634 s->active = 1;
635 if (s->old_offset) {
636 s->tx_spin = 0;
637 audio_process_dma(s);
638 break;
639 }
640 if (stream_id == SNDRV_PCM_STREAM_CAPTURE && !s1->active) {
641 s1->tx_spin = 1;
642 audio_process_dma(s1);
643 }
644#ifdef HH_VERSION
645 sa1100_dma_resume(s->dmach);
646#else
647 //FIXME - DMA API
648#endif
649 break;
650 default:
651 err = -EINVAL;
652 break;
653 }
654 spin_unlock(&s->dma_lock);
655 return err;
656}
657
658static int snd_sa11xx_uda1341_prepare(struct snd_pcm_substream *substream)
659{
660 struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream);
661 struct snd_pcm_runtime *runtime = substream->runtime;
662 struct audio_stream *s = &chip->s[substream->pstr->stream];
663
664 /* set requested samplerate */
665 sa11xx_uda1341_set_samplerate(chip, runtime->rate);
666
667 /* set requestd format when available */
668 /* set FMT here !!! FIXME */
669
670 s->period = 0;
671 s->periods = 0;
672
673 return 0;
674}
675
676static snd_pcm_uframes_t snd_sa11xx_uda1341_pointer(struct snd_pcm_substream *substream)
677{
678 struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream);
679 return audio_get_dma_pos(&chip->s[substream->pstr->stream]);
680}
681
682/* }}} */
683
684static struct snd_pcm_hardware snd_sa11xx_uda1341_capture =
685{
686 .info = (SNDRV_PCM_INFO_INTERLEAVED |
687 SNDRV_PCM_INFO_BLOCK_TRANSFER |
688 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
689 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
690 .formats = SNDRV_PCM_FMTBIT_S16_LE,
691 .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
692 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |\
693 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
694 SNDRV_PCM_RATE_KNOT),
695 .rate_min = 8000,
696 .rate_max = 48000,
697 .channels_min = 2,
698 .channels_max = 2,
699 .buffer_bytes_max = 64*1024,
700 .period_bytes_min = 64,
701 .period_bytes_max = DMA_BUF_SIZE,
702 .periods_min = 2,
703 .periods_max = 255,
704 .fifo_size = 0,
705};
706
707static struct snd_pcm_hardware snd_sa11xx_uda1341_playback =
708{
709 .info = (SNDRV_PCM_INFO_INTERLEAVED |
710 SNDRV_PCM_INFO_BLOCK_TRANSFER |
711 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
712 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
713 .formats = SNDRV_PCM_FMTBIT_S16_LE,
714 .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
715 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |\
716 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
717 SNDRV_PCM_RATE_KNOT),
718 .rate_min = 8000,
719 .rate_max = 48000,
720 .channels_min = 2,
721 .channels_max = 2,
722 .buffer_bytes_max = 64*1024,
723 .period_bytes_min = 64,
724 .period_bytes_max = DMA_BUF_SIZE,
725 .periods_min = 2,
726 .periods_max = 255,
727 .fifo_size = 0,
728};
729
730static int snd_card_sa11xx_uda1341_open(struct snd_pcm_substream *substream)
731{
732 struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream);
733 struct snd_pcm_runtime *runtime = substream->runtime;
734 int stream_id = substream->pstr->stream;
735 int err;
736
737 chip->s[stream_id].stream = substream;
738
739 if (stream_id == SNDRV_PCM_STREAM_PLAYBACK)
740 runtime->hw = snd_sa11xx_uda1341_playback;
741 else
742 runtime->hw = snd_sa11xx_uda1341_capture;
743 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
744 return err;
745 if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates)) < 0)
746 return err;
747
748 return 0;
749}
750
751static int snd_card_sa11xx_uda1341_close(struct snd_pcm_substream *substream)
752{
753 struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream);
754
755 chip->s[substream->pstr->stream].stream = NULL;
756 return 0;
757}
758
759/* {{{ HW params & free */
760
761static int snd_sa11xx_uda1341_hw_params(struct snd_pcm_substream *substream,
762 struct snd_pcm_hw_params *hw_params)
763{
764
765 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
766}
767
768static int snd_sa11xx_uda1341_hw_free(struct snd_pcm_substream *substream)
769{
770 return snd_pcm_lib_free_pages(substream);
771}
772
773/* }}} */
774
775static struct snd_pcm_ops snd_card_sa11xx_uda1341_playback_ops = {
776 .open = snd_card_sa11xx_uda1341_open,
777 .close = snd_card_sa11xx_uda1341_close,
778 .ioctl = snd_pcm_lib_ioctl,
779 .hw_params = snd_sa11xx_uda1341_hw_params,
780 .hw_free = snd_sa11xx_uda1341_hw_free,
781 .prepare = snd_sa11xx_uda1341_prepare,
782 .trigger = snd_sa11xx_uda1341_trigger,
783 .pointer = snd_sa11xx_uda1341_pointer,
784};
785
786static struct snd_pcm_ops snd_card_sa11xx_uda1341_capture_ops = {
787 .open = snd_card_sa11xx_uda1341_open,
788 .close = snd_card_sa11xx_uda1341_close,
789 .ioctl = snd_pcm_lib_ioctl,
790 .hw_params = snd_sa11xx_uda1341_hw_params,
791 .hw_free = snd_sa11xx_uda1341_hw_free,
792 .prepare = snd_sa11xx_uda1341_prepare,
793 .trigger = snd_sa11xx_uda1341_trigger,
794 .pointer = snd_sa11xx_uda1341_pointer,
795};
796
797static int __init snd_card_sa11xx_uda1341_pcm(struct sa11xx_uda1341 *sa11xx_uda1341, int device)
798{
799 struct snd_pcm *pcm;
800 int err;
801
802 if ((err = snd_pcm_new(sa11xx_uda1341->card, "UDA1341 PCM", device, 1, 1, &pcm)) < 0)
803 return err;
804
805 /*
806 * this sets up our initial buffers and sets the dma_type to isa.
807 * isa works but I'm not sure why (or if) it's the right choice
808 * this may be too large, trying it for now
809 */
810 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
811 snd_dma_isa_data(),
812 64*1024, 64*1024);
813
814 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_sa11xx_uda1341_playback_ops);
815 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_sa11xx_uda1341_capture_ops);
816 pcm->private_data = sa11xx_uda1341;
817 pcm->info_flags = 0;
818 strcpy(pcm->name, "UDA1341 PCM");
819
820 sa11xx_uda1341_audio_init(sa11xx_uda1341);
821
822 /* setup DMA controller */
823 audio_dma_request(&sa11xx_uda1341->s[SNDRV_PCM_STREAM_PLAYBACK], audio_dma_callback);
824 audio_dma_request(&sa11xx_uda1341->s[SNDRV_PCM_STREAM_CAPTURE], audio_dma_callback);
825
826 sa11xx_uda1341->pcm = pcm;
827
828 return 0;
829}
830
831/* }}} */
832
833/* {{{ module init & exit */
834
835#ifdef CONFIG_PM
836
837static int snd_sa11xx_uda1341_suspend(struct platform_device *devptr,
838 pm_message_t state)
839{
840 struct snd_card *card = platform_get_drvdata(devptr);
841 struct sa11xx_uda1341 *chip = card->private_data;
842
843 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
844 snd_pcm_suspend_all(chip->pcm);
845#ifdef HH_VERSION
846 sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach);
847 sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_CAPTURE].dmach);
848#else
849 //FIXME
850#endif
851 l3_command(chip->uda1341, CMD_SUSPEND, NULL);
852 sa11xx_uda1341_audio_shutdown(chip);
853
854 return 0;
855}
856
857static int snd_sa11xx_uda1341_resume(struct platform_device *devptr)
858{
859 struct snd_card *card = platform_get_drvdata(devptr);
860 struct sa11xx_uda1341 *chip = card->private_data;
861
862 sa11xx_uda1341_audio_init(chip);
863 l3_command(chip->uda1341, CMD_RESUME, NULL);
864#ifdef HH_VERSION
865 sa1100_dma_wakeup(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach);
866 sa1100_dma_wakeup(chip->s[SNDRV_PCM_STREAM_CAPTURE].dmach);
867#else
868 //FIXME
869#endif
870 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
871 return 0;
872}
873#endif /* COMFIG_PM */
874
875void snd_sa11xx_uda1341_free(struct snd_card *card)
876{
877 struct sa11xx_uda1341 *chip = card->private_data;
878
879 audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]);
880 audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]);
881}
882
883static int __devinit sa11xx_uda1341_probe(struct platform_device *devptr)
884{
885 int err;
886 struct snd_card *card;
887 struct sa11xx_uda1341 *chip;
888
889 /* register the soundcard */
890 err = snd_card_create(-1, id, THIS_MODULE,
891 sizeof(struct sa11xx_uda1341), &card);
892 if (err < 0)
893 return err;
894
895 chip = card->private_data;
896 spin_lock_init(&chip->s[0].dma_lock);
897 spin_lock_init(&chip->s[1].dma_lock);
898
899 card->private_free = snd_sa11xx_uda1341_free;
900 chip->card = card;
901 chip->samplerate = AUDIO_RATE_DEFAULT;
902
903 // mixer
904 if ((err = snd_chip_uda1341_mixer_new(card, &chip->uda1341)))
905 goto nodev;
906
907 // PCM
908 if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0)
909 goto nodev;
910
911 strcpy(card->driver, "UDA1341");
912 strcpy(card->shortname, "H3600 UDA1341TS");
913 sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS");
914
915 snd_card_set_dev(card, &devptr->dev);
916
917 if ((err = snd_card_register(card)) == 0) {
918 printk( KERN_INFO "iPAQ audio support initialized\n" );
919 platform_set_drvdata(devptr, card);
920 return 0;
921 }
922
923 nodev:
924 snd_card_free(card);
925 return err;
926}
927
928static int __devexit sa11xx_uda1341_remove(struct platform_device *devptr)
929{
930 snd_card_free(platform_get_drvdata(devptr));
931 platform_set_drvdata(devptr, NULL);
932 return 0;
933}
934
935#define SA11XX_UDA1341_DRIVER "sa11xx_uda1341"
936
937static struct platform_driver sa11xx_uda1341_driver = {
938 .probe = sa11xx_uda1341_probe,
939 .remove = __devexit_p(sa11xx_uda1341_remove),
940#ifdef CONFIG_PM
941 .suspend = snd_sa11xx_uda1341_suspend,
942 .resume = snd_sa11xx_uda1341_resume,
943#endif
944 .driver = {
945 .name = SA11XX_UDA1341_DRIVER,
946 },
947};
948
949static int __init sa11xx_uda1341_init(void)
950{
951 int err;
952
953 if (!machine_is_h3xxx())
954 return -ENODEV;
955 if ((err = platform_driver_register(&sa11xx_uda1341_driver)) < 0)
956 return err;
957 device = platform_device_register_simple(SA11XX_UDA1341_DRIVER, -1, NULL, 0);
958 if (!IS_ERR(device)) {
959 if (platform_get_drvdata(device))
960 return 0;
961 platform_device_unregister(device);
962 err = -ENODEV;
963 } else
964 err = PTR_ERR(device);
965 platform_driver_unregister(&sa11xx_uda1341_driver);
966 return err;
967}
968
969static void __exit sa11xx_uda1341_exit(void)
970{
971 platform_device_unregister(device);
972 platform_driver_unregister(&sa11xx_uda1341_driver);
973}
974
975module_init(sa11xx_uda1341_init);
976module_exit(sa11xx_uda1341_exit);
977
978/* }}} */
979
980/*
981 * Local variables:
982 * indent-tabs-mode: t
983 * End:
984 */
diff --git a/sound/atmel/Kconfig b/sound/atmel/Kconfig
new file mode 100644
index 000000000000..6c228a91940d
--- /dev/null
+++ b/sound/atmel/Kconfig
@@ -0,0 +1,19 @@
1menu "Atmel devices (AVR32 and AT91)"
2 depends on AVR32 || ARCH_AT91
3
4config SND_ATMEL_ABDAC
5 tristate "Atmel Audio Bitstream DAC (ABDAC) driver"
6 select SND_PCM
7 depends on DW_DMAC && AVR32
8 help
9 ALSA sound driver for the Atmel Audio Bitstream DAC (ABDAC).
10
11config SND_ATMEL_AC97C
12 tristate "Atmel AC97 Controller (AC97C) driver"
13 select SND_PCM
14 select SND_AC97_CODEC
15 depends on DW_DMAC && AVR32
16 help
17 ALSA sound driver for the Atmel AC97 controller.
18
19endmenu
diff --git a/sound/atmel/Makefile b/sound/atmel/Makefile
new file mode 100644
index 000000000000..219dcfac6086
--- /dev/null
+++ b/sound/atmel/Makefile
@@ -0,0 +1,5 @@
1snd-atmel-abdac-objs := abdac.o
2snd-atmel-ac97c-objs := ac97c.o
3
4obj-$(CONFIG_SND_ATMEL_ABDAC) += snd-atmel-abdac.o
5obj-$(CONFIG_SND_ATMEL_AC97C) += snd-atmel-ac97c.o
diff --git a/sound/atmel/abdac.c b/sound/atmel/abdac.c
new file mode 100644
index 000000000000..f2f41c854221
--- /dev/null
+++ b/sound/atmel/abdac.c
@@ -0,0 +1,602 @@
1/*
2 * Driver for the Atmel on-chip Audio Bitstream DAC (ABDAC)
3 *
4 * Copyright (C) 2006-2009 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10#include <linux/clk.h>
11#include <linux/bitmap.h>
12#include <linux/dw_dmac.h>
13#include <linux/dmaengine.h>
14#include <linux/dma-mapping.h>
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/module.h>
18#include <linux/platform_device.h>
19#include <linux/io.h>
20
21#include <sound/core.h>
22#include <sound/initval.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/atmel-abdac.h>
26
27/* DAC register offsets */
28#define DAC_DATA 0x0000
29#define DAC_CTRL 0x0008
30#define DAC_INT_MASK 0x000c
31#define DAC_INT_EN 0x0010
32#define DAC_INT_DIS 0x0014
33#define DAC_INT_CLR 0x0018
34#define DAC_INT_STATUS 0x001c
35
36/* Bitfields in CTRL */
37#define DAC_SWAP_OFFSET 30
38#define DAC_SWAP_SIZE 1
39#define DAC_EN_OFFSET 31
40#define DAC_EN_SIZE 1
41
42/* Bitfields in INT_MASK/INT_EN/INT_DIS/INT_STATUS/INT_CLR */
43#define DAC_UNDERRUN_OFFSET 28
44#define DAC_UNDERRUN_SIZE 1
45#define DAC_TX_READY_OFFSET 29
46#define DAC_TX_READY_SIZE 1
47
48/* Bit manipulation macros */
49#define DAC_BIT(name) \
50 (1 << DAC_##name##_OFFSET)
51#define DAC_BF(name, value) \
52 (((value) & ((1 << DAC_##name##_SIZE) - 1)) \
53 << DAC_##name##_OFFSET)
54#define DAC_BFEXT(name, value) \
55 (((value) >> DAC_##name##_OFFSET) \
56 & ((1 << DAC_##name##_SIZE) - 1))
57#define DAC_BFINS(name, value, old) \
58 (((old) & ~(((1 << DAC_##name##_SIZE) - 1) \
59 << DAC_##name##_OFFSET)) \
60 | DAC_BF(name, value))
61
62/* Register access macros */
63#define dac_readl(port, reg) \
64 __raw_readl((port)->regs + DAC_##reg)
65#define dac_writel(port, reg, value) \
66 __raw_writel((value), (port)->regs + DAC_##reg)
67
68/*
69 * ABDAC supports a maximum of 6 different rates from a generic clock. The
70 * generic clock has a power of two divider, which gives 6 steps from 192 kHz
71 * to 5112 Hz.
72 */
73#define MAX_NUM_RATES 6
74/* ALSA seems to use rates between 192000 Hz and 5112 Hz. */
75#define RATE_MAX 192000
76#define RATE_MIN 5112
77
78enum {
79 DMA_READY = 0,
80};
81
82struct atmel_abdac_dma {
83 struct dma_chan *chan;
84 struct dw_cyclic_desc *cdesc;
85};
86
87struct atmel_abdac {
88 struct clk *pclk;
89 struct clk *sample_clk;
90 struct platform_device *pdev;
91 struct atmel_abdac_dma dma;
92
93 struct snd_pcm_hw_constraint_list constraints_rates;
94 struct snd_pcm_substream *substream;
95 struct snd_card *card;
96 struct snd_pcm *pcm;
97
98 void __iomem *regs;
99 unsigned long flags;
100 unsigned int rates[MAX_NUM_RATES];
101 unsigned int rates_num;
102 int irq;
103};
104
105#define get_dac(card) ((struct atmel_abdac *)(card)->private_data)
106
107/* This function is called by the DMA driver. */
108static void atmel_abdac_dma_period_done(void *arg)
109{
110 struct atmel_abdac *dac = arg;
111 snd_pcm_period_elapsed(dac->substream);
112}
113
114static int atmel_abdac_prepare_dma(struct atmel_abdac *dac,
115 struct snd_pcm_substream *substream,
116 enum dma_data_direction direction)
117{
118 struct dma_chan *chan = dac->dma.chan;
119 struct dw_cyclic_desc *cdesc;
120 struct snd_pcm_runtime *runtime = substream->runtime;
121 unsigned long buffer_len, period_len;
122
123 /*
124 * We don't do DMA on "complex" transfers, i.e. with
125 * non-halfword-aligned buffers or lengths.
126 */
127 if (runtime->dma_addr & 1 || runtime->buffer_size & 1) {
128 dev_dbg(&dac->pdev->dev, "too complex transfer\n");
129 return -EINVAL;
130 }
131
132 buffer_len = frames_to_bytes(runtime, runtime->buffer_size);
133 period_len = frames_to_bytes(runtime, runtime->period_size);
134
135 cdesc = dw_dma_cyclic_prep(chan, runtime->dma_addr, buffer_len,
136 period_len, DMA_TO_DEVICE);
137 if (IS_ERR(cdesc)) {
138 dev_dbg(&dac->pdev->dev, "could not prepare cyclic DMA\n");
139 return PTR_ERR(cdesc);
140 }
141
142 cdesc->period_callback = atmel_abdac_dma_period_done;
143 cdesc->period_callback_param = dac;
144
145 dac->dma.cdesc = cdesc;
146
147 set_bit(DMA_READY, &dac->flags);
148
149 return 0;
150}
151
152static struct snd_pcm_hardware atmel_abdac_hw = {
153 .info = (SNDRV_PCM_INFO_MMAP
154 | SNDRV_PCM_INFO_MMAP_VALID
155 | SNDRV_PCM_INFO_INTERLEAVED
156 | SNDRV_PCM_INFO_BLOCK_TRANSFER
157 | SNDRV_PCM_INFO_RESUME
158 | SNDRV_PCM_INFO_PAUSE),
159 .formats = (SNDRV_PCM_FMTBIT_S16_BE),
160 .rates = (SNDRV_PCM_RATE_KNOT),
161 .rate_min = RATE_MIN,
162 .rate_max = RATE_MAX,
163 .channels_min = 2,
164 .channels_max = 2,
165 .buffer_bytes_max = 64 * 4096,
166 .period_bytes_min = 4096,
167 .period_bytes_max = 4096,
168 .periods_min = 6,
169 .periods_max = 64,
170};
171
172static int atmel_abdac_open(struct snd_pcm_substream *substream)
173{
174 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
175
176 dac->substream = substream;
177 atmel_abdac_hw.rate_max = dac->rates[dac->rates_num - 1];
178 atmel_abdac_hw.rate_min = dac->rates[0];
179 substream->runtime->hw = atmel_abdac_hw;
180
181 return snd_pcm_hw_constraint_list(substream->runtime, 0,
182 SNDRV_PCM_HW_PARAM_RATE, &dac->constraints_rates);
183}
184
185static int atmel_abdac_close(struct snd_pcm_substream *substream)
186{
187 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
188 dac->substream = NULL;
189 return 0;
190}
191
192static int atmel_abdac_hw_params(struct snd_pcm_substream *substream,
193 struct snd_pcm_hw_params *hw_params)
194{
195 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
196 int retval;
197
198 retval = snd_pcm_lib_malloc_pages(substream,
199 params_buffer_bytes(hw_params));
200 if (retval < 0)
201 return retval;
202 /* snd_pcm_lib_malloc_pages returns 1 if buffer is changed. */
203 if (retval == 1)
204 if (test_and_clear_bit(DMA_READY, &dac->flags))
205 dw_dma_cyclic_free(dac->dma.chan);
206
207 return retval;
208}
209
210static int atmel_abdac_hw_free(struct snd_pcm_substream *substream)
211{
212 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
213 if (test_and_clear_bit(DMA_READY, &dac->flags))
214 dw_dma_cyclic_free(dac->dma.chan);
215 return snd_pcm_lib_free_pages(substream);
216}
217
218static int atmel_abdac_prepare(struct snd_pcm_substream *substream)
219{
220 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
221 int retval;
222
223 retval = clk_set_rate(dac->sample_clk, 256 * substream->runtime->rate);
224 if (retval)
225 return retval;
226
227 if (!test_bit(DMA_READY, &dac->flags))
228 retval = atmel_abdac_prepare_dma(dac, substream, DMA_TO_DEVICE);
229
230 return retval;
231}
232
233static int atmel_abdac_trigger(struct snd_pcm_substream *substream, int cmd)
234{
235 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
236 int retval = 0;
237
238 switch (cmd) {
239 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */
240 case SNDRV_PCM_TRIGGER_RESUME: /* fall through */
241 case SNDRV_PCM_TRIGGER_START:
242 clk_enable(dac->sample_clk);
243 retval = dw_dma_cyclic_start(dac->dma.chan);
244 if (retval)
245 goto out;
246 dac_writel(dac, CTRL, DAC_BIT(EN));
247 break;
248 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* fall through */
249 case SNDRV_PCM_TRIGGER_SUSPEND: /* fall through */
250 case SNDRV_PCM_TRIGGER_STOP:
251 dw_dma_cyclic_stop(dac->dma.chan);
252 dac_writel(dac, DATA, 0);
253 dac_writel(dac, CTRL, 0);
254 clk_disable(dac->sample_clk);
255 break;
256 default:
257 retval = -EINVAL;
258 break;
259 }
260out:
261 return retval;
262}
263
264static snd_pcm_uframes_t
265atmel_abdac_pointer(struct snd_pcm_substream *substream)
266{
267 struct atmel_abdac *dac = snd_pcm_substream_chip(substream);
268 struct snd_pcm_runtime *runtime = substream->runtime;
269 snd_pcm_uframes_t frames;
270 unsigned long bytes;
271
272 bytes = dw_dma_get_src_addr(dac->dma.chan);
273 bytes -= runtime->dma_addr;
274
275 frames = bytes_to_frames(runtime, bytes);
276 if (frames >= runtime->buffer_size)
277 frames -= runtime->buffer_size;
278
279 return frames;
280}
281
282static irqreturn_t abdac_interrupt(int irq, void *dev_id)
283{
284 struct atmel_abdac *dac = dev_id;
285 u32 status;
286
287 status = dac_readl(dac, INT_STATUS);
288 if (status & DAC_BIT(UNDERRUN)) {
289 dev_err(&dac->pdev->dev, "underrun detected\n");
290 dac_writel(dac, INT_CLR, DAC_BIT(UNDERRUN));
291 } else {
292 dev_err(&dac->pdev->dev, "spurious interrupt (status=0x%x)\n",
293 status);
294 dac_writel(dac, INT_CLR, status);
295 }
296
297 return IRQ_HANDLED;
298}
299
300static struct snd_pcm_ops atmel_abdac_ops = {
301 .open = atmel_abdac_open,
302 .close = atmel_abdac_close,
303 .ioctl = snd_pcm_lib_ioctl,
304 .hw_params = atmel_abdac_hw_params,
305 .hw_free = atmel_abdac_hw_free,
306 .prepare = atmel_abdac_prepare,
307 .trigger = atmel_abdac_trigger,
308 .pointer = atmel_abdac_pointer,
309};
310
311static int __devinit atmel_abdac_pcm_new(struct atmel_abdac *dac)
312{
313 struct snd_pcm_hardware hw = atmel_abdac_hw;
314 struct snd_pcm *pcm;
315 int retval;
316
317 retval = snd_pcm_new(dac->card, dac->card->shortname,
318 dac->pdev->id, 1, 0, &pcm);
319 if (retval)
320 return retval;
321
322 strcpy(pcm->name, dac->card->shortname);
323 pcm->private_data = dac;
324 pcm->info_flags = 0;
325 dac->pcm = pcm;
326
327 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_abdac_ops);
328
329 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
330 &dac->pdev->dev, hw.periods_min * hw.period_bytes_min,
331 hw.buffer_bytes_max);
332
333 return retval;
334}
335
336static bool filter(struct dma_chan *chan, void *slave)
337{
338 struct dw_dma_slave *dws = slave;
339
340 if (dws->dma_dev == chan->device->dev) {
341 chan->private = dws;
342 return true;
343 } else
344 return false;
345}
346
347static int set_sample_rates(struct atmel_abdac *dac)
348{
349 long new_rate = RATE_MAX;
350 int retval = -EINVAL;
351 int index = 0;
352
353 /* we start at 192 kHz and work our way down to 5112 Hz */
354 while (new_rate >= RATE_MIN && index < (MAX_NUM_RATES + 1)) {
355 new_rate = clk_round_rate(dac->sample_clk, 256 * new_rate);
356 if (new_rate < 0)
357 break;
358 /* make sure we are below the ABDAC clock */
359 if (new_rate <= clk_get_rate(dac->pclk)) {
360 dac->rates[index] = new_rate / 256;
361 index++;
362 }
363 /* divide by 256 and then by two to get next rate */
364 new_rate /= 256 * 2;
365 }
366
367 if (index) {
368 int i;
369
370 /* reverse array, smallest go first */
371 for (i = 0; i < (index / 2); i++) {
372 unsigned int tmp = dac->rates[index - 1 - i];
373 dac->rates[index - 1 - i] = dac->rates[i];
374 dac->rates[i] = tmp;
375 }
376
377 dac->constraints_rates.count = index;
378 dac->constraints_rates.list = dac->rates;
379 dac->constraints_rates.mask = 0;
380 dac->rates_num = index;
381
382 retval = 0;
383 }
384
385 return retval;
386}
387
388static int __devinit atmel_abdac_probe(struct platform_device *pdev)
389{
390 struct snd_card *card;
391 struct atmel_abdac *dac;
392 struct resource *regs;
393 struct atmel_abdac_pdata *pdata;
394 struct clk *pclk;
395 struct clk *sample_clk;
396 int retval;
397 int irq;
398
399 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
400 if (!regs) {
401 dev_dbg(&pdev->dev, "no memory resource\n");
402 return -ENXIO;
403 }
404
405 irq = platform_get_irq(pdev, 0);
406 if (irq < 0) {
407 dev_dbg(&pdev->dev, "could not get IRQ number\n");
408 return irq;
409 }
410
411 pdata = pdev->dev.platform_data;
412 if (!pdata) {
413 dev_dbg(&pdev->dev, "no platform data\n");
414 return -ENXIO;
415 }
416
417 pclk = clk_get(&pdev->dev, "pclk");
418 if (IS_ERR(pclk)) {
419 dev_dbg(&pdev->dev, "no peripheral clock\n");
420 return PTR_ERR(pclk);
421 }
422 sample_clk = clk_get(&pdev->dev, "sample_clk");
423 if (IS_ERR(pclk)) {
424 dev_dbg(&pdev->dev, "no sample clock\n");
425 retval = PTR_ERR(pclk);
426 goto out_put_pclk;
427 }
428 clk_enable(pclk);
429
430 retval = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
431 THIS_MODULE, sizeof(struct atmel_abdac), &card);
432 if (retval) {
433 dev_dbg(&pdev->dev, "could not create sound card device\n");
434 goto out_put_sample_clk;
435 }
436
437 dac = get_dac(card);
438
439 dac->irq = irq;
440 dac->card = card;
441 dac->pclk = pclk;
442 dac->sample_clk = sample_clk;
443 dac->pdev = pdev;
444
445 retval = set_sample_rates(dac);
446 if (retval < 0) {
447 dev_dbg(&pdev->dev, "could not set supported rates\n");
448 goto out_free_card;
449 }
450
451 dac->regs = ioremap(regs->start, regs->end - regs->start + 1);
452 if (!dac->regs) {
453 dev_dbg(&pdev->dev, "could not remap register memory\n");
454 goto out_free_card;
455 }
456
457 /* make sure the DAC is silent and disabled */
458 dac_writel(dac, DATA, 0);
459 dac_writel(dac, CTRL, 0);
460
461 retval = request_irq(irq, abdac_interrupt, 0, "abdac", dac);
462 if (retval) {
463 dev_dbg(&pdev->dev, "could not request irq\n");
464 goto out_unmap_regs;
465 }
466
467 snd_card_set_dev(card, &pdev->dev);
468
469 if (pdata->dws.dma_dev) {
470 struct dw_dma_slave *dws = &pdata->dws;
471 dma_cap_mask_t mask;
472
473 dws->tx_reg = regs->start + DAC_DATA;
474
475 dma_cap_zero(mask);
476 dma_cap_set(DMA_SLAVE, mask);
477
478 dac->dma.chan = dma_request_channel(mask, filter, dws);
479 }
480 if (!pdata->dws.dma_dev || !dac->dma.chan) {
481 dev_dbg(&pdev->dev, "DMA not available\n");
482 retval = -ENODEV;
483 goto out_unset_card_dev;
484 }
485
486 strcpy(card->driver, "Atmel ABDAC");
487 strcpy(card->shortname, "Atmel ABDAC");
488 sprintf(card->longname, "Atmel Audio Bitstream DAC");
489
490 retval = atmel_abdac_pcm_new(dac);
491 if (retval) {
492 dev_dbg(&pdev->dev, "could not register ABDAC pcm device\n");
493 goto out_release_dma;
494 }
495
496 retval = snd_card_register(card);
497 if (retval) {
498 dev_dbg(&pdev->dev, "could not register sound card\n");
499 goto out_release_dma;
500 }
501
502 platform_set_drvdata(pdev, card);
503
504 dev_info(&pdev->dev, "Atmel ABDAC at 0x%p using %s\n",
505 dac->regs, dev_name(&dac->dma.chan->dev->device));
506
507 return retval;
508
509out_release_dma:
510 dma_release_channel(dac->dma.chan);
511 dac->dma.chan = NULL;
512out_unset_card_dev:
513 snd_card_set_dev(card, NULL);
514 free_irq(irq, dac);
515out_unmap_regs:
516 iounmap(dac->regs);
517out_free_card:
518 snd_card_free(card);
519out_put_sample_clk:
520 clk_put(sample_clk);
521 clk_disable(pclk);
522out_put_pclk:
523 clk_put(pclk);
524 return retval;
525}
526
527#ifdef CONFIG_PM
528static int atmel_abdac_suspend(struct platform_device *pdev, pm_message_t msg)
529{
530 struct snd_card *card = platform_get_drvdata(pdev);
531 struct atmel_abdac *dac = card->private_data;
532
533 dw_dma_cyclic_stop(dac->dma.chan);
534 clk_disable(dac->sample_clk);
535 clk_disable(dac->pclk);
536
537 return 0;
538}
539
540static int atmel_abdac_resume(struct platform_device *pdev)
541{
542 struct snd_card *card = platform_get_drvdata(pdev);
543 struct atmel_abdac *dac = card->private_data;
544
545 clk_enable(dac->pclk);
546 clk_enable(dac->sample_clk);
547 if (test_bit(DMA_READY, &dac->flags))
548 dw_dma_cyclic_start(dac->dma.chan);
549
550 return 0;
551}
552#else
553#define atmel_abdac_suspend NULL
554#define atmel_abdac_resume NULL
555#endif
556
557static int __devexit atmel_abdac_remove(struct platform_device *pdev)
558{
559 struct snd_card *card = platform_get_drvdata(pdev);
560 struct atmel_abdac *dac = get_dac(card);
561
562 clk_put(dac->sample_clk);
563 clk_disable(dac->pclk);
564 clk_put(dac->pclk);
565
566 dma_release_channel(dac->dma.chan);
567 dac->dma.chan = NULL;
568 snd_card_set_dev(card, NULL);
569 iounmap(dac->regs);
570 free_irq(dac->irq, dac);
571 snd_card_free(card);
572
573 platform_set_drvdata(pdev, NULL);
574
575 return 0;
576}
577
578static struct platform_driver atmel_abdac_driver = {
579 .remove = __devexit_p(atmel_abdac_remove),
580 .driver = {
581 .name = "atmel_abdac",
582 },
583 .suspend = atmel_abdac_suspend,
584 .resume = atmel_abdac_resume,
585};
586
587static int __init atmel_abdac_init(void)
588{
589 return platform_driver_probe(&atmel_abdac_driver,
590 atmel_abdac_probe);
591}
592module_init(atmel_abdac_init);
593
594static void __exit atmel_abdac_exit(void)
595{
596 platform_driver_unregister(&atmel_abdac_driver);
597}
598module_exit(atmel_abdac_exit);
599
600MODULE_LICENSE("GPL");
601MODULE_DESCRIPTION("Driver for Atmel Audio Bitstream DAC (ABDAC)");
602MODULE_AUTHOR("Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>");
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
new file mode 100644
index 000000000000..0c0f8771656a
--- /dev/null
+++ b/sound/atmel/ac97c.c
@@ -0,0 +1,1022 @@
1/*
2 * Driver for Atmel AC97C
3 *
4 * Copyright (C) 2005-2009 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10#include <linux/clk.h>
11#include <linux/delay.h>
12#include <linux/bitmap.h>
13#include <linux/device.h>
14#include <linux/dmaengine.h>
15#include <linux/dma-mapping.h>
16#include <linux/init.h>
17#include <linux/interrupt.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/mutex.h>
21#include <linux/gpio.h>
22#include <linux/io.h>
23
24#include <sound/core.h>
25#include <sound/initval.h>
26#include <sound/pcm.h>
27#include <sound/pcm_params.h>
28#include <sound/ac97_codec.h>
29#include <sound/atmel-ac97c.h>
30#include <sound/memalloc.h>
31
32#include <linux/dw_dmac.h>
33
34#include "ac97c.h"
35
36enum {
37 DMA_TX_READY = 0,
38 DMA_RX_READY,
39 DMA_TX_CHAN_PRESENT,
40 DMA_RX_CHAN_PRESENT,
41};
42
43/* Serialize access to opened variable */
44static DEFINE_MUTEX(opened_mutex);
45
46struct atmel_ac97c_dma {
47 struct dma_chan *rx_chan;
48 struct dma_chan *tx_chan;
49};
50
51struct atmel_ac97c {
52 struct clk *pclk;
53 struct platform_device *pdev;
54 struct atmel_ac97c_dma dma;
55
56 struct snd_pcm_substream *playback_substream;
57 struct snd_pcm_substream *capture_substream;
58 struct snd_card *card;
59 struct snd_pcm *pcm;
60 struct snd_ac97 *ac97;
61 struct snd_ac97_bus *ac97_bus;
62
63 u64 cur_format;
64 unsigned int cur_rate;
65 unsigned long flags;
66 /* Serialize access to opened variable */
67 spinlock_t lock;
68 void __iomem *regs;
69 int irq;
70 int opened;
71 int reset_pin;
72};
73
74#define get_chip(card) ((struct atmel_ac97c *)(card)->private_data)
75
76#define ac97c_writel(chip, reg, val) \
77 __raw_writel((val), (chip)->regs + AC97C_##reg)
78#define ac97c_readl(chip, reg) \
79 __raw_readl((chip)->regs + AC97C_##reg)
80
81/* This function is called by the DMA driver. */
82static void atmel_ac97c_dma_playback_period_done(void *arg)
83{
84 struct atmel_ac97c *chip = arg;
85 snd_pcm_period_elapsed(chip->playback_substream);
86}
87
88static void atmel_ac97c_dma_capture_period_done(void *arg)
89{
90 struct atmel_ac97c *chip = arg;
91 snd_pcm_period_elapsed(chip->capture_substream);
92}
93
94static int atmel_ac97c_prepare_dma(struct atmel_ac97c *chip,
95 struct snd_pcm_substream *substream,
96 enum dma_data_direction direction)
97{
98 struct dma_chan *chan;
99 struct dw_cyclic_desc *cdesc;
100 struct snd_pcm_runtime *runtime = substream->runtime;
101 unsigned long buffer_len, period_len;
102
103 /*
104 * We don't do DMA on "complex" transfers, i.e. with
105 * non-halfword-aligned buffers or lengths.
106 */
107 if (runtime->dma_addr & 1 || runtime->buffer_size & 1) {
108 dev_dbg(&chip->pdev->dev, "too complex transfer\n");
109 return -EINVAL;
110 }
111
112 if (direction == DMA_TO_DEVICE)
113 chan = chip->dma.tx_chan;
114 else
115 chan = chip->dma.rx_chan;
116
117 buffer_len = frames_to_bytes(runtime, runtime->buffer_size);
118 period_len = frames_to_bytes(runtime, runtime->period_size);
119
120 cdesc = dw_dma_cyclic_prep(chan, runtime->dma_addr, buffer_len,
121 period_len, direction);
122 if (IS_ERR(cdesc)) {
123 dev_dbg(&chip->pdev->dev, "could not prepare cyclic DMA\n");
124 return PTR_ERR(cdesc);
125 }
126
127 if (direction == DMA_TO_DEVICE) {
128 cdesc->period_callback = atmel_ac97c_dma_playback_period_done;
129 set_bit(DMA_TX_READY, &chip->flags);
130 } else {
131 cdesc->period_callback = atmel_ac97c_dma_capture_period_done;
132 set_bit(DMA_RX_READY, &chip->flags);
133 }
134
135 cdesc->period_callback_param = chip;
136
137 return 0;
138}
139
140static struct snd_pcm_hardware atmel_ac97c_hw = {
141 .info = (SNDRV_PCM_INFO_MMAP
142 | SNDRV_PCM_INFO_MMAP_VALID
143 | SNDRV_PCM_INFO_INTERLEAVED
144 | SNDRV_PCM_INFO_BLOCK_TRANSFER
145 | SNDRV_PCM_INFO_JOINT_DUPLEX
146 | SNDRV_PCM_INFO_RESUME
147 | SNDRV_PCM_INFO_PAUSE),
148 .formats = (SNDRV_PCM_FMTBIT_S16_BE
149 | SNDRV_PCM_FMTBIT_S16_LE),
150 .rates = (SNDRV_PCM_RATE_CONTINUOUS),
151 .rate_min = 4000,
152 .rate_max = 48000,
153 .channels_min = 1,
154 .channels_max = 2,
155 .buffer_bytes_max = 2 * 2 * 64 * 2048,
156 .period_bytes_min = 4096,
157 .period_bytes_max = 4096,
158 .periods_min = 6,
159 .periods_max = 64,
160};
161
162static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
163{
164 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
165 struct snd_pcm_runtime *runtime = substream->runtime;
166
167 mutex_lock(&opened_mutex);
168 chip->opened++;
169 runtime->hw = atmel_ac97c_hw;
170 if (chip->cur_rate) {
171 runtime->hw.rate_min = chip->cur_rate;
172 runtime->hw.rate_max = chip->cur_rate;
173 }
174 if (chip->cur_format)
175 runtime->hw.formats = (1ULL << chip->cur_format);
176 mutex_unlock(&opened_mutex);
177 chip->playback_substream = substream;
178 return 0;
179}
180
181static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
182{
183 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
184 struct snd_pcm_runtime *runtime = substream->runtime;
185
186 mutex_lock(&opened_mutex);
187 chip->opened++;
188 runtime->hw = atmel_ac97c_hw;
189 if (chip->cur_rate) {
190 runtime->hw.rate_min = chip->cur_rate;
191 runtime->hw.rate_max = chip->cur_rate;
192 }
193 if (chip->cur_format)
194 runtime->hw.formats = (1ULL << chip->cur_format);
195 mutex_unlock(&opened_mutex);
196 chip->capture_substream = substream;
197 return 0;
198}
199
200static int atmel_ac97c_playback_close(struct snd_pcm_substream *substream)
201{
202 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
203
204 mutex_lock(&opened_mutex);
205 chip->opened--;
206 if (!chip->opened) {
207 chip->cur_rate = 0;
208 chip->cur_format = 0;
209 }
210 mutex_unlock(&opened_mutex);
211
212 chip->playback_substream = NULL;
213
214 return 0;
215}
216
217static int atmel_ac97c_capture_close(struct snd_pcm_substream *substream)
218{
219 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
220
221 mutex_lock(&opened_mutex);
222 chip->opened--;
223 if (!chip->opened) {
224 chip->cur_rate = 0;
225 chip->cur_format = 0;
226 }
227 mutex_unlock(&opened_mutex);
228
229 chip->capture_substream = NULL;
230
231 return 0;
232}
233
234static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream,
235 struct snd_pcm_hw_params *hw_params)
236{
237 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
238 int retval;
239
240 retval = snd_pcm_lib_malloc_pages(substream,
241 params_buffer_bytes(hw_params));
242 if (retval < 0)
243 return retval;
244 /* snd_pcm_lib_malloc_pages returns 1 if buffer is changed. */
245 if (retval == 1)
246 if (test_and_clear_bit(DMA_TX_READY, &chip->flags))
247 dw_dma_cyclic_free(chip->dma.tx_chan);
248
249 /* Set restrictions to params. */
250 mutex_lock(&opened_mutex);
251 chip->cur_rate = params_rate(hw_params);
252 chip->cur_format = params_format(hw_params);
253 mutex_unlock(&opened_mutex);
254
255 return retval;
256}
257
258static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream,
259 struct snd_pcm_hw_params *hw_params)
260{
261 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
262 int retval;
263
264 retval = snd_pcm_lib_malloc_pages(substream,
265 params_buffer_bytes(hw_params));
266 if (retval < 0)
267 return retval;
268 /* snd_pcm_lib_malloc_pages returns 1 if buffer is changed. */
269 if (retval == 1)
270 if (test_and_clear_bit(DMA_RX_READY, &chip->flags))
271 dw_dma_cyclic_free(chip->dma.rx_chan);
272
273 /* Set restrictions to params. */
274 mutex_lock(&opened_mutex);
275 chip->cur_rate = params_rate(hw_params);
276 chip->cur_format = params_format(hw_params);
277 mutex_unlock(&opened_mutex);
278
279 return retval;
280}
281
282static int atmel_ac97c_playback_hw_free(struct snd_pcm_substream *substream)
283{
284 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
285 if (test_and_clear_bit(DMA_TX_READY, &chip->flags))
286 dw_dma_cyclic_free(chip->dma.tx_chan);
287 return snd_pcm_lib_free_pages(substream);
288}
289
290static int atmel_ac97c_capture_hw_free(struct snd_pcm_substream *substream)
291{
292 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
293 if (test_and_clear_bit(DMA_RX_READY, &chip->flags))
294 dw_dma_cyclic_free(chip->dma.rx_chan);
295 return snd_pcm_lib_free_pages(substream);
296}
297
298static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream)
299{
300 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
301 struct snd_pcm_runtime *runtime = substream->runtime;
302 unsigned long word = ac97c_readl(chip, OCA);
303 int retval;
304
305 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
306
307 /* assign channels to AC97C channel A */
308 switch (runtime->channels) {
309 case 1:
310 word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
311 break;
312 case 2:
313 word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
314 | AC97C_CH_ASSIGN(PCM_RIGHT, A);
315 break;
316 default:
317 /* TODO: support more than two channels */
318 return -EINVAL;
319 }
320 ac97c_writel(chip, OCA, word);
321
322 /* configure sample format and size */
323 word = AC97C_CMR_DMAEN | AC97C_CMR_SIZE_16;
324
325 switch (runtime->format) {
326 case SNDRV_PCM_FORMAT_S16_LE:
327 word |= AC97C_CMR_CEM_LITTLE;
328 break;
329 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
330 word &= ~(AC97C_CMR_CEM_LITTLE);
331 break;
332 default:
333 word = ac97c_readl(chip, OCA);
334 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
335 ac97c_writel(chip, OCA, word);
336 return -EINVAL;
337 }
338
339 /* Enable underrun interrupt on channel A */
340 word |= AC97C_CSR_UNRUN;
341
342 ac97c_writel(chip, CAMR, word);
343
344 /* Enable channel A event interrupt */
345 word = ac97c_readl(chip, IMR);
346 word |= AC97C_SR_CAEVT;
347 ac97c_writel(chip, IER, word);
348
349 /* set variable rate if needed */
350 if (runtime->rate != 48000) {
351 word = ac97c_readl(chip, MR);
352 word |= AC97C_MR_VRA;
353 ac97c_writel(chip, MR, word);
354 } else {
355 word = ac97c_readl(chip, MR);
356 word &= ~(AC97C_MR_VRA);
357 ac97c_writel(chip, MR, word);
358 }
359
360 retval = snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE,
361 runtime->rate);
362 if (retval)
363 dev_dbg(&chip->pdev->dev, "could not set rate %d Hz\n",
364 runtime->rate);
365
366 if (!test_bit(DMA_TX_READY, &chip->flags))
367 retval = atmel_ac97c_prepare_dma(chip, substream,
368 DMA_TO_DEVICE);
369
370 return retval;
371}
372
373static int atmel_ac97c_capture_prepare(struct snd_pcm_substream *substream)
374{
375 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
376 struct snd_pcm_runtime *runtime = substream->runtime;
377 unsigned long word = ac97c_readl(chip, ICA);
378 int retval;
379
380 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
381
382 /* assign channels to AC97C channel A */
383 switch (runtime->channels) {
384 case 1:
385 word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
386 break;
387 case 2:
388 word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
389 | AC97C_CH_ASSIGN(PCM_RIGHT, A);
390 break;
391 default:
392 /* TODO: support more than two channels */
393 return -EINVAL;
394 }
395 ac97c_writel(chip, ICA, word);
396
397 /* configure sample format and size */
398 word = AC97C_CMR_DMAEN | AC97C_CMR_SIZE_16;
399
400 switch (runtime->format) {
401 case SNDRV_PCM_FORMAT_S16_LE:
402 word |= AC97C_CMR_CEM_LITTLE;
403 break;
404 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
405 word &= ~(AC97C_CMR_CEM_LITTLE);
406 break;
407 default:
408 word = ac97c_readl(chip, ICA);
409 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
410 ac97c_writel(chip, ICA, word);
411 return -EINVAL;
412 }
413
414 /* Enable overrun interrupt on channel A */
415 word |= AC97C_CSR_OVRUN;
416
417 ac97c_writel(chip, CAMR, word);
418
419 /* Enable channel A event interrupt */
420 word = ac97c_readl(chip, IMR);
421 word |= AC97C_SR_CAEVT;
422 ac97c_writel(chip, IER, word);
423
424 /* set variable rate if needed */
425 if (runtime->rate != 48000) {
426 word = ac97c_readl(chip, MR);
427 word |= AC97C_MR_VRA;
428 ac97c_writel(chip, MR, word);
429 } else {
430 word = ac97c_readl(chip, MR);
431 word &= ~(AC97C_MR_VRA);
432 ac97c_writel(chip, MR, word);
433 }
434
435 retval = snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE,
436 runtime->rate);
437 if (retval)
438 dev_dbg(&chip->pdev->dev, "could not set rate %d Hz\n",
439 runtime->rate);
440
441 if (!test_bit(DMA_RX_READY, &chip->flags))
442 retval = atmel_ac97c_prepare_dma(chip, substream,
443 DMA_FROM_DEVICE);
444
445 return retval;
446}
447
448static int
449atmel_ac97c_playback_trigger(struct snd_pcm_substream *substream, int cmd)
450{
451 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
452 unsigned long camr;
453 int retval = 0;
454
455 camr = ac97c_readl(chip, CAMR);
456
457 switch (cmd) {
458 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */
459 case SNDRV_PCM_TRIGGER_RESUME: /* fall through */
460 case SNDRV_PCM_TRIGGER_START:
461 retval = dw_dma_cyclic_start(chip->dma.tx_chan);
462 if (retval)
463 goto out;
464 camr |= AC97C_CMR_CENA;
465 break;
466 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* fall through */
467 case SNDRV_PCM_TRIGGER_SUSPEND: /* fall through */
468 case SNDRV_PCM_TRIGGER_STOP:
469 dw_dma_cyclic_stop(chip->dma.tx_chan);
470 if (chip->opened <= 1)
471 camr &= ~AC97C_CMR_CENA;
472 break;
473 default:
474 retval = -EINVAL;
475 goto out;
476 }
477
478 ac97c_writel(chip, CAMR, camr);
479out:
480 return retval;
481}
482
483static int
484atmel_ac97c_capture_trigger(struct snd_pcm_substream *substream, int cmd)
485{
486 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
487 unsigned long camr;
488 int retval = 0;
489
490 camr = ac97c_readl(chip, CAMR);
491
492 switch (cmd) {
493 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */
494 case SNDRV_PCM_TRIGGER_RESUME: /* fall through */
495 case SNDRV_PCM_TRIGGER_START:
496 retval = dw_dma_cyclic_start(chip->dma.rx_chan);
497 if (retval)
498 goto out;
499 camr |= AC97C_CMR_CENA;
500 break;
501 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* fall through */
502 case SNDRV_PCM_TRIGGER_SUSPEND: /* fall through */
503 case SNDRV_PCM_TRIGGER_STOP:
504 dw_dma_cyclic_stop(chip->dma.rx_chan);
505 if (chip->opened <= 1)
506 camr &= ~AC97C_CMR_CENA;
507 break;
508 default:
509 retval = -EINVAL;
510 break;
511 }
512
513 ac97c_writel(chip, CAMR, camr);
514out:
515 return retval;
516}
517
518static snd_pcm_uframes_t
519atmel_ac97c_playback_pointer(struct snd_pcm_substream *substream)
520{
521 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
522 struct snd_pcm_runtime *runtime = substream->runtime;
523 snd_pcm_uframes_t frames;
524 unsigned long bytes;
525
526 bytes = dw_dma_get_src_addr(chip->dma.tx_chan);
527 bytes -= runtime->dma_addr;
528
529 frames = bytes_to_frames(runtime, bytes);
530 if (frames >= runtime->buffer_size)
531 frames -= runtime->buffer_size;
532 return frames;
533}
534
535static snd_pcm_uframes_t
536atmel_ac97c_capture_pointer(struct snd_pcm_substream *substream)
537{
538 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
539 struct snd_pcm_runtime *runtime = substream->runtime;
540 snd_pcm_uframes_t frames;
541 unsigned long bytes;
542
543 bytes = dw_dma_get_dst_addr(chip->dma.rx_chan);
544 bytes -= runtime->dma_addr;
545
546 frames = bytes_to_frames(runtime, bytes);
547 if (frames >= runtime->buffer_size)
548 frames -= runtime->buffer_size;
549 return frames;
550}
551
552static struct snd_pcm_ops atmel_ac97_playback_ops = {
553 .open = atmel_ac97c_playback_open,
554 .close = atmel_ac97c_playback_close,
555 .ioctl = snd_pcm_lib_ioctl,
556 .hw_params = atmel_ac97c_playback_hw_params,
557 .hw_free = atmel_ac97c_playback_hw_free,
558 .prepare = atmel_ac97c_playback_prepare,
559 .trigger = atmel_ac97c_playback_trigger,
560 .pointer = atmel_ac97c_playback_pointer,
561};
562
563static struct snd_pcm_ops atmel_ac97_capture_ops = {
564 .open = atmel_ac97c_capture_open,
565 .close = atmel_ac97c_capture_close,
566 .ioctl = snd_pcm_lib_ioctl,
567 .hw_params = atmel_ac97c_capture_hw_params,
568 .hw_free = atmel_ac97c_capture_hw_free,
569 .prepare = atmel_ac97c_capture_prepare,
570 .trigger = atmel_ac97c_capture_trigger,
571 .pointer = atmel_ac97c_capture_pointer,
572};
573
574static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev)
575{
576 struct atmel_ac97c *chip = (struct atmel_ac97c *)dev;
577 irqreturn_t retval = IRQ_NONE;
578 u32 sr = ac97c_readl(chip, SR);
579 u32 casr = ac97c_readl(chip, CASR);
580 u32 cosr = ac97c_readl(chip, COSR);
581
582 if (sr & AC97C_SR_CAEVT) {
583 dev_info(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n",
584 casr & AC97C_CSR_OVRUN ? " OVRUN" : "",
585 casr & AC97C_CSR_RXRDY ? " RXRDY" : "",
586 casr & AC97C_CSR_UNRUN ? " UNRUN" : "",
587 casr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
588 casr & AC97C_CSR_TXRDY ? " TXRDY" : "",
589 !casr ? " NONE" : "");
590 retval = IRQ_HANDLED;
591 }
592
593 if (sr & AC97C_SR_COEVT) {
594 dev_info(&chip->pdev->dev, "codec channel event%s%s%s%s%s\n",
595 cosr & AC97C_CSR_OVRUN ? " OVRUN" : "",
596 cosr & AC97C_CSR_RXRDY ? " RXRDY" : "",
597 cosr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
598 cosr & AC97C_CSR_TXRDY ? " TXRDY" : "",
599 !cosr ? " NONE" : "");
600 retval = IRQ_HANDLED;
601 }
602
603 if (retval == IRQ_NONE) {
604 dev_err(&chip->pdev->dev, "spurious interrupt sr 0x%08x "
605 "casr 0x%08x cosr 0x%08x\n", sr, casr, cosr);
606 }
607
608 return retval;
609}
610
611static int __devinit atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
612{
613 struct snd_pcm *pcm;
614 struct snd_pcm_hardware hw = atmel_ac97c_hw;
615 int capture, playback, retval;
616
617 capture = test_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
618 playback = test_bit(DMA_TX_CHAN_PRESENT, &chip->flags);
619
620 retval = snd_pcm_new(chip->card, chip->card->shortname,
621 chip->pdev->id, playback, capture, &pcm);
622 if (retval)
623 return retval;
624
625 if (capture)
626 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
627 &atmel_ac97_capture_ops);
628 if (playback)
629 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
630 &atmel_ac97_playback_ops);
631
632 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
633 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
634 hw.buffer_bytes_max);
635 if (retval)
636 return retval;
637
638 pcm->private_data = chip;
639 pcm->info_flags = 0;
640 strcpy(pcm->name, chip->card->shortname);
641 chip->pcm = pcm;
642
643 return 0;
644}
645
646static int atmel_ac97c_mixer_new(struct atmel_ac97c *chip)
647{
648 struct snd_ac97_template template;
649 memset(&template, 0, sizeof(template));
650 template.private_data = chip;
651 return snd_ac97_mixer(chip->ac97_bus, &template, &chip->ac97);
652}
653
654static void atmel_ac97c_write(struct snd_ac97 *ac97, unsigned short reg,
655 unsigned short val)
656{
657 struct atmel_ac97c *chip = get_chip(ac97);
658 unsigned long word;
659 int timeout = 40;
660
661 word = (reg & 0x7f) << 16 | val;
662
663 do {
664 if (ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) {
665 ac97c_writel(chip, COTHR, word);
666 return;
667 }
668 udelay(1);
669 } while (--timeout);
670
671 dev_dbg(&chip->pdev->dev, "codec write timeout\n");
672}
673
674static unsigned short atmel_ac97c_read(struct snd_ac97 *ac97,
675 unsigned short reg)
676{
677 struct atmel_ac97c *chip = get_chip(ac97);
678 unsigned long word;
679 int timeout = 40;
680 int write = 10;
681
682 word = (0x80 | (reg & 0x7f)) << 16;
683
684 if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0)
685 ac97c_readl(chip, CORHR);
686
687retry_write:
688 timeout = 40;
689
690 do {
691 if ((ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) != 0) {
692 ac97c_writel(chip, COTHR, word);
693 goto read_reg;
694 }
695 udelay(10);
696 } while (--timeout);
697
698 if (!--write)
699 goto timed_out;
700 goto retry_write;
701
702read_reg:
703 do {
704 if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0) {
705 unsigned short val = ac97c_readl(chip, CORHR);
706 return val;
707 }
708 udelay(10);
709 } while (--timeout);
710
711 if (!--write)
712 goto timed_out;
713 goto retry_write;
714
715timed_out:
716 dev_dbg(&chip->pdev->dev, "codec read timeout\n");
717 return 0xffff;
718}
719
720static bool filter(struct dma_chan *chan, void *slave)
721{
722 struct dw_dma_slave *dws = slave;
723
724 if (dws->dma_dev == chan->device->dev) {
725 chan->private = dws;
726 return true;
727 } else
728 return false;
729}
730
731static void atmel_ac97c_reset(struct atmel_ac97c *chip)
732{
733 ac97c_writel(chip, MR, 0);
734 ac97c_writel(chip, MR, AC97C_MR_ENA);
735 ac97c_writel(chip, CAMR, 0);
736 ac97c_writel(chip, COMR, 0);
737
738 if (gpio_is_valid(chip->reset_pin)) {
739 gpio_set_value(chip->reset_pin, 0);
740 /* AC97 v2.2 specifications says minimum 1 us. */
741 udelay(2);
742 gpio_set_value(chip->reset_pin, 1);
743 }
744}
745
746static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
747{
748 struct snd_card *card;
749 struct atmel_ac97c *chip;
750 struct resource *regs;
751 struct ac97c_platform_data *pdata;
752 struct clk *pclk;
753 static struct snd_ac97_bus_ops ops = {
754 .write = atmel_ac97c_write,
755 .read = atmel_ac97c_read,
756 };
757 int retval;
758 int irq;
759
760 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
761 if (!regs) {
762 dev_dbg(&pdev->dev, "no memory resource\n");
763 return -ENXIO;
764 }
765
766 pdata = pdev->dev.platform_data;
767 if (!pdata) {
768 dev_dbg(&pdev->dev, "no platform data\n");
769 return -ENXIO;
770 }
771
772 irq = platform_get_irq(pdev, 0);
773 if (irq < 0) {
774 dev_dbg(&pdev->dev, "could not get irq\n");
775 return -ENXIO;
776 }
777
778 pclk = clk_get(&pdev->dev, "pclk");
779 if (IS_ERR(pclk)) {
780 dev_dbg(&pdev->dev, "no peripheral clock\n");
781 return PTR_ERR(pclk);
782 }
783 clk_enable(pclk);
784
785 retval = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
786 THIS_MODULE, sizeof(struct atmel_ac97c), &card);
787 if (retval) {
788 dev_dbg(&pdev->dev, "could not create sound card device\n");
789 goto err_snd_card_new;
790 }
791
792 chip = get_chip(card);
793
794 retval = request_irq(irq, atmel_ac97c_interrupt, 0, "AC97C", chip);
795 if (retval) {
796 dev_dbg(&pdev->dev, "unable to request irq %d\n", irq);
797 goto err_request_irq;
798 }
799 chip->irq = irq;
800
801 spin_lock_init(&chip->lock);
802
803 strcpy(card->driver, "Atmel AC97C");
804 strcpy(card->shortname, "Atmel AC97C");
805 sprintf(card->longname, "Atmel AC97 controller");
806
807 chip->card = card;
808 chip->pclk = pclk;
809 chip->pdev = pdev;
810 chip->regs = ioremap(regs->start, regs->end - regs->start + 1);
811
812 if (!chip->regs) {
813 dev_dbg(&pdev->dev, "could not remap register memory\n");
814 goto err_ioremap;
815 }
816
817 if (gpio_is_valid(pdata->reset_pin)) {
818 if (gpio_request(pdata->reset_pin, "reset_pin")) {
819 dev_dbg(&pdev->dev, "reset pin not available\n");
820 chip->reset_pin = -ENODEV;
821 } else {
822 gpio_direction_output(pdata->reset_pin, 1);
823 chip->reset_pin = pdata->reset_pin;
824 }
825 }
826
827 snd_card_set_dev(card, &pdev->dev);
828
829 atmel_ac97c_reset(chip);
830
831 /* Enable overrun interrupt from codec channel */
832 ac97c_writel(chip, COMR, AC97C_CSR_OVRUN);
833 ac97c_writel(chip, IER, ac97c_readl(chip, IMR) | AC97C_SR_COEVT);
834
835 retval = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
836 if (retval) {
837 dev_dbg(&pdev->dev, "could not register on ac97 bus\n");
838 goto err_ac97_bus;
839 }
840
841 retval = atmel_ac97c_mixer_new(chip);
842 if (retval) {
843 dev_dbg(&pdev->dev, "could not register ac97 mixer\n");
844 goto err_ac97_bus;
845 }
846
847 if (pdata->rx_dws.dma_dev) {
848 struct dw_dma_slave *dws = &pdata->rx_dws;
849 dma_cap_mask_t mask;
850
851 dws->rx_reg = regs->start + AC97C_CARHR + 2;
852
853 dma_cap_zero(mask);
854 dma_cap_set(DMA_SLAVE, mask);
855
856 chip->dma.rx_chan = dma_request_channel(mask, filter, dws);
857
858 dev_info(&chip->pdev->dev, "using %s for DMA RX\n",
859 dev_name(&chip->dma.rx_chan->dev->device));
860 set_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
861 }
862
863 if (pdata->tx_dws.dma_dev) {
864 struct dw_dma_slave *dws = &pdata->tx_dws;
865 dma_cap_mask_t mask;
866
867 dws->tx_reg = regs->start + AC97C_CATHR + 2;
868
869 dma_cap_zero(mask);
870 dma_cap_set(DMA_SLAVE, mask);
871
872 chip->dma.tx_chan = dma_request_channel(mask, filter, dws);
873
874 dev_info(&chip->pdev->dev, "using %s for DMA TX\n",
875 dev_name(&chip->dma.tx_chan->dev->device));
876 set_bit(DMA_TX_CHAN_PRESENT, &chip->flags);
877 }
878
879 if (!test_bit(DMA_RX_CHAN_PRESENT, &chip->flags) &&
880 !test_bit(DMA_TX_CHAN_PRESENT, &chip->flags)) {
881 dev_dbg(&pdev->dev, "DMA not available\n");
882 retval = -ENODEV;
883 goto err_dma;
884 }
885
886 retval = atmel_ac97c_pcm_new(chip);
887 if (retval) {
888 dev_dbg(&pdev->dev, "could not register ac97 pcm device\n");
889 goto err_dma;
890 }
891
892 retval = snd_card_register(card);
893 if (retval) {
894 dev_dbg(&pdev->dev, "could not register sound card\n");
895 goto err_dma;
896 }
897
898 platform_set_drvdata(pdev, card);
899
900 dev_info(&pdev->dev, "Atmel AC97 controller at 0x%p\n",
901 chip->regs);
902
903 return 0;
904
905err_dma:
906 if (test_bit(DMA_RX_CHAN_PRESENT, &chip->flags))
907 dma_release_channel(chip->dma.rx_chan);
908 if (test_bit(DMA_TX_CHAN_PRESENT, &chip->flags))
909 dma_release_channel(chip->dma.tx_chan);
910 clear_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
911 clear_bit(DMA_TX_CHAN_PRESENT, &chip->flags);
912 chip->dma.rx_chan = NULL;
913 chip->dma.tx_chan = NULL;
914err_ac97_bus:
915 snd_card_set_dev(card, NULL);
916
917 if (gpio_is_valid(chip->reset_pin))
918 gpio_free(chip->reset_pin);
919
920 iounmap(chip->regs);
921err_ioremap:
922 free_irq(irq, chip);
923err_request_irq:
924 snd_card_free(card);
925err_snd_card_new:
926 clk_disable(pclk);
927 clk_put(pclk);
928 return retval;
929}
930
931#ifdef CONFIG_PM
932static int atmel_ac97c_suspend(struct platform_device *pdev, pm_message_t msg)
933{
934 struct snd_card *card = platform_get_drvdata(pdev);
935 struct atmel_ac97c *chip = card->private_data;
936
937 if (test_bit(DMA_RX_READY, &chip->flags))
938 dw_dma_cyclic_stop(chip->dma.rx_chan);
939 if (test_bit(DMA_TX_READY, &chip->flags))
940 dw_dma_cyclic_stop(chip->dma.tx_chan);
941 clk_disable(chip->pclk);
942
943 return 0;
944}
945
946static int atmel_ac97c_resume(struct platform_device *pdev)
947{
948 struct snd_card *card = platform_get_drvdata(pdev);
949 struct atmel_ac97c *chip = card->private_data;
950
951 clk_enable(chip->pclk);
952 if (test_bit(DMA_RX_READY, &chip->flags))
953 dw_dma_cyclic_start(chip->dma.rx_chan);
954 if (test_bit(DMA_TX_READY, &chip->flags))
955 dw_dma_cyclic_start(chip->dma.tx_chan);
956
957 return 0;
958}
959#else
960#define atmel_ac97c_suspend NULL
961#define atmel_ac97c_resume NULL
962#endif
963
964static int __devexit atmel_ac97c_remove(struct platform_device *pdev)
965{
966 struct snd_card *card = platform_get_drvdata(pdev);
967 struct atmel_ac97c *chip = get_chip(card);
968
969 if (gpio_is_valid(chip->reset_pin))
970 gpio_free(chip->reset_pin);
971
972 ac97c_writel(chip, CAMR, 0);
973 ac97c_writel(chip, COMR, 0);
974 ac97c_writel(chip, MR, 0);
975
976 clk_disable(chip->pclk);
977 clk_put(chip->pclk);
978 iounmap(chip->regs);
979 free_irq(chip->irq, chip);
980
981 if (test_bit(DMA_RX_CHAN_PRESENT, &chip->flags))
982 dma_release_channel(chip->dma.rx_chan);
983 if (test_bit(DMA_TX_CHAN_PRESENT, &chip->flags))
984 dma_release_channel(chip->dma.tx_chan);
985 clear_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
986 clear_bit(DMA_TX_CHAN_PRESENT, &chip->flags);
987 chip->dma.rx_chan = NULL;
988 chip->dma.tx_chan = NULL;
989
990 snd_card_set_dev(card, NULL);
991 snd_card_free(card);
992
993 platform_set_drvdata(pdev, NULL);
994
995 return 0;
996}
997
998static struct platform_driver atmel_ac97c_driver = {
999 .remove = __devexit_p(atmel_ac97c_remove),
1000 .driver = {
1001 .name = "atmel_ac97c",
1002 },
1003 .suspend = atmel_ac97c_suspend,
1004 .resume = atmel_ac97c_resume,
1005};
1006
1007static int __init atmel_ac97c_init(void)
1008{
1009 return platform_driver_probe(&atmel_ac97c_driver,
1010 atmel_ac97c_probe);
1011}
1012module_init(atmel_ac97c_init);
1013
1014static void __exit atmel_ac97c_exit(void)
1015{
1016 platform_driver_unregister(&atmel_ac97c_driver);
1017}
1018module_exit(atmel_ac97c_exit);
1019
1020MODULE_LICENSE("GPL");
1021MODULE_DESCRIPTION("Driver for Atmel AC97 controller");
1022MODULE_AUTHOR("Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>");
diff --git a/sound/atmel/ac97c.h b/sound/atmel/ac97c.h
new file mode 100644
index 000000000000..ecbba5021c80
--- /dev/null
+++ b/sound/atmel/ac97c.h
@@ -0,0 +1,73 @@
1/*
2 * Register definitions for Atmel AC97C
3 *
4 * Copyright (C) 2005-2009 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10#ifndef __SOUND_ATMEL_AC97C_H
11#define __SOUND_ATMEL_AC97C_H
12
13#define AC97C_MR 0x08
14#define AC97C_ICA 0x10
15#define AC97C_OCA 0x14
16#define AC97C_CARHR 0x20
17#define AC97C_CATHR 0x24
18#define AC97C_CASR 0x28
19#define AC97C_CAMR 0x2c
20#define AC97C_CORHR 0x40
21#define AC97C_COTHR 0x44
22#define AC97C_COSR 0x48
23#define AC97C_COMR 0x4c
24#define AC97C_SR 0x50
25#define AC97C_IER 0x54
26#define AC97C_IDR 0x58
27#define AC97C_IMR 0x5c
28#define AC97C_VERSION 0xfc
29
30#define AC97C_CATPR PDC_TPR
31#define AC97C_CATCR PDC_TCR
32#define AC97C_CATNPR PDC_TNPR
33#define AC97C_CATNCR PDC_TNCR
34#define AC97C_CARPR PDC_RPR
35#define AC97C_CARCR PDC_RCR
36#define AC97C_CARNPR PDC_RNPR
37#define AC97C_CARNCR PDC_RNCR
38#define AC97C_PTCR PDC_PTCR
39
40#define AC97C_MR_ENA (1 << 0)
41#define AC97C_MR_WRST (1 << 1)
42#define AC97C_MR_VRA (1 << 2)
43
44#define AC97C_CSR_TXRDY (1 << 0)
45#define AC97C_CSR_TXEMPTY (1 << 1)
46#define AC97C_CSR_UNRUN (1 << 2)
47#define AC97C_CSR_RXRDY (1 << 4)
48#define AC97C_CSR_OVRUN (1 << 5)
49#define AC97C_CSR_ENDTX (1 << 10)
50#define AC97C_CSR_ENDRX (1 << 14)
51
52#define AC97C_CMR_SIZE_20 (0 << 16)
53#define AC97C_CMR_SIZE_18 (1 << 16)
54#define AC97C_CMR_SIZE_16 (2 << 16)
55#define AC97C_CMR_SIZE_10 (3 << 16)
56#define AC97C_CMR_CEM_LITTLE (1 << 18)
57#define AC97C_CMR_CEM_BIG (0 << 18)
58#define AC97C_CMR_CENA (1 << 21)
59#define AC97C_CMR_DMAEN (1 << 22)
60
61#define AC97C_SR_CAEVT (1 << 3)
62#define AC97C_SR_COEVT (1 << 2)
63#define AC97C_SR_WKUP (1 << 1)
64#define AC97C_SR_SOF (1 << 0)
65
66#define AC97C_CH_MASK(slot) \
67 (0x7 << (3 * (AC97_SLOT_##slot - 3)))
68#define AC97C_CH_ASSIGN(slot, channel) \
69 (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3)))
70#define AC97C_CHANNEL_NONE 0x0
71#define AC97C_CHANNEL_A 0x1
72
73#endif /* __SOUND_ATMEL_AC97C_H */
diff --git a/sound/core/control.c b/sound/core/control.c
index 636b3b52ef8b..17b8d47a5cd0 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -723,14 +723,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
723{ 723{
724 struct snd_ctl_elem_value *control; 724 struct snd_ctl_elem_value *control;
725 int result; 725 int result;
726 726
727 control = kmalloc(sizeof(*control), GFP_KERNEL); 727 control = memdup_user(_control, sizeof(*control));
728 if (control == NULL) 728 if (IS_ERR(control))
729 return -ENOMEM; 729 return PTR_ERR(control);
730 if (copy_from_user(control, _control, sizeof(*control))) { 730
731 kfree(control);
732 return -EFAULT;
733 }
734 snd_power_lock(card); 731 snd_power_lock(card);
735 result = snd_power_wait(card, SNDRV_CTL_POWER_D0); 732 result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
736 if (result >= 0) 733 if (result >= 0)
@@ -784,13 +781,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
784 struct snd_card *card; 781 struct snd_card *card;
785 int result; 782 int result;
786 783
787 control = kmalloc(sizeof(*control), GFP_KERNEL); 784 control = memdup_user(_control, sizeof(*control));
788 if (control == NULL) 785 if (IS_ERR(control))
789 return -ENOMEM; 786 return PTR_ERR(control);
790 if (copy_from_user(control, _control, sizeof(*control))) { 787
791 kfree(control);
792 return -EFAULT;
793 }
794 card = file->card; 788 card = file->card;
795 snd_power_lock(card); 789 snd_power_lock(card);
796 result = snd_power_wait(card, SNDRV_CTL_POWER_D0); 790 result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
@@ -916,13 +910,10 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
916 if (op_flag > 0) { 910 if (op_flag > 0) {
917 if (size > 1024 * 128) /* sane value */ 911 if (size > 1024 * 128) /* sane value */
918 return -EINVAL; 912 return -EINVAL;
919 new_data = kmalloc(size, GFP_KERNEL); 913
920 if (new_data == NULL) 914 new_data = memdup_user(tlv, size);
921 return -ENOMEM; 915 if (IS_ERR(new_data))
922 if (copy_from_user(new_data, tlv, size)) { 916 return PTR_ERR(new_data);
923 kfree(new_data);
924 return -EFAULT;
925 }
926 change = ue->tlv_data_size != size; 917 change = ue->tlv_data_size != size;
927 if (!change) 918 if (!change)
928 change = memcmp(ue->tlv_data, new_data, size); 919 change = memcmp(ue->tlv_data, new_data, size);
@@ -1373,12 +1364,9 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat);
1373static int snd_ctl_fasync(int fd, struct file * file, int on) 1364static int snd_ctl_fasync(int fd, struct file * file, int on)
1374{ 1365{
1375 struct snd_ctl_file *ctl; 1366 struct snd_ctl_file *ctl;
1376 int err; 1367
1377 ctl = file->private_data; 1368 ctl = file->private_data;
1378 err = fasync_helper(fd, file, on, &ctl->fasync); 1369 return fasync_helper(fd, file, on, &ctl->fasync);
1379 if (err < 0)
1380 return err;
1381 return 0;
1382} 1370}
1383 1371
1384/* 1372/*
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 195cafc5a553..a70ee7f1ed98 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -99,9 +99,6 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
99 if (hw == NULL) 99 if (hw == NULL)
100 return -ENODEV; 100 return -ENODEV;
101 101
102 if (!hw->ops.open)
103 return -ENXIO;
104
105 if (!try_module_get(hw->card->module)) 102 if (!try_module_get(hw->card->module))
106 return -EFAULT; 103 return -EFAULT;
107 104
@@ -113,6 +110,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
113 err = -EBUSY; 110 err = -EBUSY;
114 break; 111 break;
115 } 112 }
113 if (!hw->ops.open) {
114 err = 0;
115 break;
116 }
116 err = hw->ops.open(hw, file); 117 err = hw->ops.open(hw, file);
117 if (err >= 0) 118 if (err >= 0)
118 break; 119 break;
@@ -151,7 +152,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
151 152
152static int snd_hwdep_release(struct inode *inode, struct file * file) 153static int snd_hwdep_release(struct inode *inode, struct file * file)
153{ 154{
154 int err = -ENXIO; 155 int err = 0;
155 struct snd_hwdep *hw = file->private_data; 156 struct snd_hwdep *hw = file->private_data;
156 struct module *mod = hw->card->module; 157 struct module *mod = hw->card->module;
157 158
diff --git a/sound/core/info.c b/sound/core/info.c
index 70fa87189f36..35df614f6c55 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -154,11 +154,6 @@ EXPORT_SYMBOL(snd_seq_root);
154struct snd_info_entry *snd_oss_root; 154struct snd_info_entry *snd_oss_root;
155#endif 155#endif
156 156
157static inline void snd_info_entry_prepare(struct proc_dir_entry *de)
158{
159 de->owner = THIS_MODULE;
160}
161
162static void snd_remove_proc_entry(struct proc_dir_entry *parent, 157static void snd_remove_proc_entry(struct proc_dir_entry *parent,
163 struct proc_dir_entry *de) 158 struct proc_dir_entry *de)
164{ 159{
@@ -522,32 +517,11 @@ static const struct file_operations snd_info_entry_operations =
522 .release = snd_info_entry_release, 517 .release = snd_info_entry_release,
523}; 518};
524 519
525/**
526 * snd_create_proc_entry - create a procfs entry
527 * @name: the name of the proc file
528 * @mode: the file permission bits, S_Ixxx
529 * @parent: the parent proc-directory entry
530 *
531 * Creates a new proc file entry with the given name and permission
532 * on the given directory.
533 *
534 * Returns the pointer of new instance or NULL on failure.
535 */
536static struct proc_dir_entry *snd_create_proc_entry(const char *name, mode_t mode,
537 struct proc_dir_entry *parent)
538{
539 struct proc_dir_entry *p;
540 p = create_proc_entry(name, mode, parent);
541 if (p)
542 snd_info_entry_prepare(p);
543 return p;
544}
545
546int __init snd_info_init(void) 520int __init snd_info_init(void)
547{ 521{
548 struct proc_dir_entry *p; 522 struct proc_dir_entry *p;
549 523
550 p = snd_create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, NULL); 524 p = create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, NULL);
551 if (p == NULL) 525 if (p == NULL)
552 return -ENOMEM; 526 return -ENOMEM;
553 snd_proc_root = p; 527 snd_proc_root = p;
@@ -974,12 +948,11 @@ int snd_info_register(struct snd_info_entry * entry)
974 return -ENXIO; 948 return -ENXIO;
975 root = entry->parent == NULL ? snd_proc_root : entry->parent->p; 949 root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
976 mutex_lock(&info_mutex); 950 mutex_lock(&info_mutex);
977 p = snd_create_proc_entry(entry->name, entry->mode, root); 951 p = create_proc_entry(entry->name, entry->mode, root);
978 if (!p) { 952 if (!p) {
979 mutex_unlock(&info_mutex); 953 mutex_unlock(&info_mutex);
980 return -ENOMEM; 954 return -ENOMEM;
981 } 955 }
982 p->owner = entry->module;
983 if (!S_ISDIR(entry->mode)) 956 if (!S_ISDIR(entry->mode))
984 p->proc_fops = &snd_info_entry_operations; 957 p->proc_fops = &snd_info_entry_operations;
985 p->size = entry->size; 958 p->size = entry->size;
diff --git a/sound/core/init.c b/sound/core/init.c
index dc4b80c7f311..fd56afe846ed 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -208,6 +208,7 @@ int snd_card_create(int idx, const char *xid,
208 INIT_LIST_HEAD(&card->controls); 208 INIT_LIST_HEAD(&card->controls);
209 INIT_LIST_HEAD(&card->ctl_files); 209 INIT_LIST_HEAD(&card->ctl_files);
210 spin_lock_init(&card->files_lock); 210 spin_lock_init(&card->files_lock);
211 INIT_LIST_HEAD(&card->files_list);
211 init_waitqueue_head(&card->shutdown_sleep); 212 init_waitqueue_head(&card->shutdown_sleep);
212#ifdef CONFIG_PM 213#ifdef CONFIG_PM
213 mutex_init(&card->power_lock); 214 mutex_init(&card->power_lock);
@@ -274,6 +275,7 @@ static int snd_disconnect_release(struct inode *inode, struct file *file)
274 list_for_each_entry(_df, &shutdown_files, shutdown_list) { 275 list_for_each_entry(_df, &shutdown_files, shutdown_list) {
275 if (_df->file == file) { 276 if (_df->file == file) {
276 df = _df; 277 df = _df;
278 list_del_init(&df->shutdown_list);
277 break; 279 break;
278 } 280 }
279 } 281 }
@@ -362,8 +364,7 @@ int snd_card_disconnect(struct snd_card *card)
362 /* phase 2: replace file->f_op with special dummy operations */ 364 /* phase 2: replace file->f_op with special dummy operations */
363 365
364 spin_lock(&card->files_lock); 366 spin_lock(&card->files_lock);
365 mfile = card->files; 367 list_for_each_entry(mfile, &card->files_list, list) {
366 while (mfile) {
367 file = mfile->file; 368 file = mfile->file;
368 369
369 /* it's critical part, use endless loop */ 370 /* it's critical part, use endless loop */
@@ -376,8 +377,6 @@ int snd_card_disconnect(struct snd_card *card)
376 377
377 mfile->file->f_op = &snd_shutdown_f_ops; 378 mfile->file->f_op = &snd_shutdown_f_ops;
378 fops_get(mfile->file->f_op); 379 fops_get(mfile->file->f_op);
379
380 mfile = mfile->next;
381 } 380 }
382 spin_unlock(&card->files_lock); 381 spin_unlock(&card->files_lock);
383 382
@@ -457,7 +456,7 @@ int snd_card_free_when_closed(struct snd_card *card)
457 return ret; 456 return ret;
458 457
459 spin_lock(&card->files_lock); 458 spin_lock(&card->files_lock);
460 if (card->files == NULL) 459 if (list_empty(&card->files_list))
461 free_now = 1; 460 free_now = 1;
462 else 461 else
463 card->free_on_last_close = 1; 462 card->free_on_last_close = 1;
@@ -477,7 +476,7 @@ int snd_card_free(struct snd_card *card)
477 return ret; 476 return ret;
478 477
479 /* wait, until all devices are ready for the free operation */ 478 /* wait, until all devices are ready for the free operation */
480 wait_event(card->shutdown_sleep, card->files == NULL); 479 wait_event(card->shutdown_sleep, list_empty(&card->files_list));
481 snd_card_do_free(card); 480 snd_card_do_free(card);
482 return 0; 481 return 0;
483} 482}
@@ -824,15 +823,13 @@ int snd_card_file_add(struct snd_card *card, struct file *file)
824 return -ENOMEM; 823 return -ENOMEM;
825 mfile->file = file; 824 mfile->file = file;
826 mfile->disconnected_f_op = NULL; 825 mfile->disconnected_f_op = NULL;
827 mfile->next = NULL;
828 spin_lock(&card->files_lock); 826 spin_lock(&card->files_lock);
829 if (card->shutdown) { 827 if (card->shutdown) {
830 spin_unlock(&card->files_lock); 828 spin_unlock(&card->files_lock);
831 kfree(mfile); 829 kfree(mfile);
832 return -ENODEV; 830 return -ENODEV;
833 } 831 }
834 mfile->next = card->files; 832 list_add(&mfile->list, &card->files_list);
835 card->files = mfile;
836 spin_unlock(&card->files_lock); 833 spin_unlock(&card->files_lock);
837 return 0; 834 return 0;
838} 835}
@@ -854,29 +851,20 @@ EXPORT_SYMBOL(snd_card_file_add);
854 */ 851 */
855int snd_card_file_remove(struct snd_card *card, struct file *file) 852int snd_card_file_remove(struct snd_card *card, struct file *file)
856{ 853{
857 struct snd_monitor_file *mfile, *pfile = NULL; 854 struct snd_monitor_file *mfile, *found = NULL;
858 int last_close = 0; 855 int last_close = 0;
859 856
860 spin_lock(&card->files_lock); 857 spin_lock(&card->files_lock);
861 mfile = card->files; 858 list_for_each_entry(mfile, &card->files_list, list) {
862 while (mfile) {
863 if (mfile->file == file) { 859 if (mfile->file == file) {
864 if (pfile) 860 list_del(&mfile->list);
865 pfile->next = mfile->next; 861 if (mfile->disconnected_f_op)
866 else 862 fops_put(mfile->disconnected_f_op);
867 card->files = mfile->next; 863 found = mfile;
868 break; 864 break;
869 } 865 }
870 pfile = mfile;
871 mfile = mfile->next;
872 }
873 if (mfile && mfile->disconnected_f_op) {
874 fops_put(mfile->disconnected_f_op);
875 spin_lock(&shutdown_lock);
876 list_del(&mfile->shutdown_list);
877 spin_unlock(&shutdown_lock);
878 } 866 }
879 if (card->files == NULL) 867 if (list_empty(&card->files_list))
880 last_close = 1; 868 last_close = 1;
881 spin_unlock(&card->files_lock); 869 spin_unlock(&card->files_lock);
882 if (last_close) { 870 if (last_close) {
@@ -884,11 +872,11 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
884 if (card->free_on_last_close) 872 if (card->free_on_last_close)
885 snd_card_do_free(card); 873 snd_card_do_free(card);
886 } 874 }
887 if (!mfile) { 875 if (!found) {
888 snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file); 876 snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file);
889 return -ENOENT; 877 return -ENOENT;
890 } 878 }
891 kfree(mfile); 879 kfree(found);
892 return 0; 880 return 0;
893} 881}
894 882
diff --git a/sound/core/jack.c b/sound/core/jack.c
index dd4a12dc09aa..d54d1a05fe65 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -23,10 +23,21 @@
23#include <sound/jack.h> 23#include <sound/jack.h>
24#include <sound/core.h> 24#include <sound/core.h>
25 25
26static int jack_types[] = {
27 SW_HEADPHONE_INSERT,
28 SW_MICROPHONE_INSERT,
29 SW_LINEOUT_INSERT,
30 SW_JACK_PHYSICAL_INSERT,
31 SW_VIDEOOUT_INSERT,
32};
33
26static int snd_jack_dev_free(struct snd_device *device) 34static int snd_jack_dev_free(struct snd_device *device)
27{ 35{
28 struct snd_jack *jack = device->device_data; 36 struct snd_jack *jack = device->device_data;
29 37
38 if (jack->private_free)
39 jack->private_free(jack);
40
30 /* If the input device is registered with the input subsystem 41 /* If the input device is registered with the input subsystem
31 * then we need to use a different deallocator. */ 42 * then we need to use a different deallocator. */
32 if (jack->registered) 43 if (jack->registered)
@@ -47,7 +58,7 @@ static int snd_jack_dev_register(struct snd_device *device)
47 int err; 58 int err;
48 59
49 snprintf(jack->name, sizeof(jack->name), "%s %s", 60 snprintf(jack->name, sizeof(jack->name), "%s %s",
50 card->longname, jack->id); 61 card->shortname, jack->id);
51 jack->input_dev->name = jack->name; 62 jack->input_dev->name = jack->name;
52 63
53 /* Default to the sound card device. */ 64 /* Default to the sound card device. */
@@ -79,6 +90,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
79{ 90{
80 struct snd_jack *jack; 91 struct snd_jack *jack;
81 int err; 92 int err;
93 int i;
82 static struct snd_device_ops ops = { 94 static struct snd_device_ops ops = {
83 .dev_free = snd_jack_dev_free, 95 .dev_free = snd_jack_dev_free,
84 .dev_register = snd_jack_dev_register, 96 .dev_register = snd_jack_dev_register,
@@ -100,18 +112,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
100 112
101 jack->type = type; 113 jack->type = type;
102 114
103 if (type & SND_JACK_HEADPHONE) 115 for (i = 0; i < ARRAY_SIZE(jack_types); i++)
104 input_set_capability(jack->input_dev, EV_SW, 116 if (type & (1 << i))
105 SW_HEADPHONE_INSERT); 117 input_set_capability(jack->input_dev, EV_SW,
106 if (type & SND_JACK_LINEOUT) 118 jack_types[i]);
107 input_set_capability(jack->input_dev, EV_SW,
108 SW_LINEOUT_INSERT);
109 if (type & SND_JACK_MICROPHONE)
110 input_set_capability(jack->input_dev, EV_SW,
111 SW_MICROPHONE_INSERT);
112 if (type & SND_JACK_MECHANICAL)
113 input_set_capability(jack->input_dev, EV_SW,
114 SW_JACK_PHYSICAL_INSERT);
115 119
116 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); 120 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
117 if (err < 0) 121 if (err < 0)
@@ -154,21 +158,17 @@ EXPORT_SYMBOL(snd_jack_set_parent);
154 */ 158 */
155void snd_jack_report(struct snd_jack *jack, int status) 159void snd_jack_report(struct snd_jack *jack, int status)
156{ 160{
161 int i;
162
157 if (!jack) 163 if (!jack)
158 return; 164 return;
159 165
160 if (jack->type & SND_JACK_HEADPHONE) 166 for (i = 0; i < ARRAY_SIZE(jack_types); i++) {
161 input_report_switch(jack->input_dev, SW_HEADPHONE_INSERT, 167 int testbit = 1 << i;
162 status & SND_JACK_HEADPHONE); 168 if (jack->type & testbit)
163 if (jack->type & SND_JACK_LINEOUT) 169 input_report_switch(jack->input_dev, jack_types[i],
164 input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, 170 status & testbit);
165 status & SND_JACK_LINEOUT); 171 }
166 if (jack->type & SND_JACK_MICROPHONE)
167 input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT,
168 status & SND_JACK_MICROPHONE);
169 if (jack->type & SND_JACK_MECHANICAL)
170 input_report_switch(jack->input_dev, SW_JACK_PHYSICAL_INSERT,
171 status & SND_JACK_MECHANICAL);
172 172
173 input_sync(jack->input_dev); 173 input_sync(jack->input_dev);
174} 174}
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 38524f615d94..a9710e0c97af 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -95,12 +95,14 @@ snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
95{ 95{
96 const struct snd_pci_quirk *q; 96 const struct snd_pci_quirk *q;
97 97
98 for (q = list; q->subvendor; q++) 98 for (q = list; q->subvendor; q++) {
99 if (q->subvendor == pci->subsystem_vendor && 99 if (q->subvendor != pci->subsystem_vendor)
100 (!q->subdevice || q->subdevice == pci->subsystem_device)) 100 continue;
101 if (!q->subdevice ||
102 (pci->subsystem_device & q->subdevice_mask) == q->subdevice)
101 return q; 103 return q;
104 }
102 return NULL; 105 return NULL;
103} 106}
104
105EXPORT_SYMBOL(snd_pci_quirk_lookup); 107EXPORT_SYMBOL(snd_pci_quirk_lookup);
106#endif 108#endif
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 4690b8b5681f..5dcd8a526970 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -692,6 +692,9 @@ static int snd_mixer_oss_put_volume1(struct snd_mixer_oss_file *fmixer,
692 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right); 692 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right);
693 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CVOLUME) 693 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CVOLUME)
694 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CVOLUME], left, right); 694 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CVOLUME], left, right);
695 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_CVOLUME) {
696 snd_mixer_oss_put_volume1_vol(fmixer, pslot,
697 slot->numid[SNDRV_MIXER_OSS_ITEM_CVOLUME], left, right);
695 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GVOLUME) { 698 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GVOLUME) {
696 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GVOLUME], left, right); 699 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GVOLUME], left, right);
697 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GLOBAL) { 700 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GLOBAL) {
@@ -700,19 +703,27 @@ static int snd_mixer_oss_put_volume1(struct snd_mixer_oss_file *fmixer,
700 if (left || right) { 703 if (left || right) {
701 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) 704 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH)
702 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0); 705 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
706 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CSWITCH)
707 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], left, right, 0);
703 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) 708 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH)
704 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0); 709 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
705 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) 710 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE)
706 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1); 711 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
712 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CROUTE)
713 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], left, right, 1);
707 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) 714 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE)
708 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1); 715 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
709 } else { 716 } else {
710 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) { 717 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) {
711 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0); 718 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
719 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_CSWITCH) {
720 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], left, right, 0);
712 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) { 721 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) {
713 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0); 722 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
714 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) { 723 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) {
715 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1); 724 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
725 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_CROUTE) {
726 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], left, right, 1);
716 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) { 727 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) {
717 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1); 728 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
718 } 729 }
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index e17836680f49..dda000b9684c 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1160,9 +1160,11 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
1160 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1160 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1161#ifdef OSS_DEBUG 1161#ifdef OSS_DEBUG
1162 if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1162 if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1163 printk("pcm_oss: write: recovering from XRUN\n"); 1163 printk(KERN_DEBUG "pcm_oss: write: "
1164 "recovering from XRUN\n");
1164 else 1165 else
1165 printk("pcm_oss: write: recovering from SUSPEND\n"); 1166 printk(KERN_DEBUG "pcm_oss: write: "
1167 "recovering from SUSPEND\n");
1166#endif 1168#endif
1167 ret = snd_pcm_oss_prepare(substream); 1169 ret = snd_pcm_oss_prepare(substream);
1168 if (ret < 0) 1170 if (ret < 0)
@@ -1196,9 +1198,11 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
1196 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1198 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1197#ifdef OSS_DEBUG 1199#ifdef OSS_DEBUG
1198 if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1200 if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1199 printk("pcm_oss: read: recovering from XRUN\n"); 1201 printk(KERN_DEBUG "pcm_oss: read: "
1202 "recovering from XRUN\n");
1200 else 1203 else
1201 printk("pcm_oss: read: recovering from SUSPEND\n"); 1204 printk(KERN_DEBUG "pcm_oss: read: "
1205 "recovering from SUSPEND\n");
1202#endif 1206#endif
1203 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); 1207 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1204 if (ret < 0) 1208 if (ret < 0)
@@ -1242,9 +1246,11 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void
1242 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1246 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1243#ifdef OSS_DEBUG 1247#ifdef OSS_DEBUG
1244 if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1248 if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1245 printk("pcm_oss: writev: recovering from XRUN\n"); 1249 printk(KERN_DEBUG "pcm_oss: writev: "
1250 "recovering from XRUN\n");
1246 else 1251 else
1247 printk("pcm_oss: writev: recovering from SUSPEND\n"); 1252 printk(KERN_DEBUG "pcm_oss: writev: "
1253 "recovering from SUSPEND\n");
1248#endif 1254#endif
1249 ret = snd_pcm_oss_prepare(substream); 1255 ret = snd_pcm_oss_prepare(substream);
1250 if (ret < 0) 1256 if (ret < 0)
@@ -1278,9 +1284,11 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void *
1278 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1284 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1279#ifdef OSS_DEBUG 1285#ifdef OSS_DEBUG
1280 if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1286 if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1281 printk("pcm_oss: readv: recovering from XRUN\n"); 1287 printk(KERN_DEBUG "pcm_oss: readv: "
1288 "recovering from XRUN\n");
1282 else 1289 else
1283 printk("pcm_oss: readv: recovering from SUSPEND\n"); 1290 printk(KERN_DEBUG "pcm_oss: readv: "
1291 "recovering from SUSPEND\n");
1284#endif 1292#endif
1285 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); 1293 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1286 if (ret < 0) 1294 if (ret < 0)
@@ -1533,7 +1541,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1533 init_waitqueue_entry(&wait, current); 1541 init_waitqueue_entry(&wait, current);
1534 add_wait_queue(&runtime->sleep, &wait); 1542 add_wait_queue(&runtime->sleep, &wait);
1535#ifdef OSS_DEBUG 1543#ifdef OSS_DEBUG
1536 printk("sync1: size = %li\n", size); 1544 printk(KERN_DEBUG "sync1: size = %li\n", size);
1537#endif 1545#endif
1538 while (1) { 1546 while (1) {
1539 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1); 1547 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1);
@@ -1590,7 +1598,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
1590 mutex_lock(&runtime->oss.params_lock); 1598 mutex_lock(&runtime->oss.params_lock);
1591 if (runtime->oss.buffer_used > 0) { 1599 if (runtime->oss.buffer_used > 0) {
1592#ifdef OSS_DEBUG 1600#ifdef OSS_DEBUG
1593 printk("sync: buffer_used\n"); 1601 printk(KERN_DEBUG "sync: buffer_used\n");
1594#endif 1602#endif
1595 size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width; 1603 size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width;
1596 snd_pcm_format_set_silence(format, 1604 snd_pcm_format_set_silence(format,
@@ -1603,7 +1611,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
1603 } 1611 }
1604 } else if (runtime->oss.period_ptr > 0) { 1612 } else if (runtime->oss.period_ptr > 0) {
1605#ifdef OSS_DEBUG 1613#ifdef OSS_DEBUG
1606 printk("sync: period_ptr\n"); 1614 printk(KERN_DEBUG "sync: period_ptr\n");
1607#endif 1615#endif
1608 size = runtime->oss.period_bytes - runtime->oss.period_ptr; 1616 size = runtime->oss.period_bytes - runtime->oss.period_ptr;
1609 snd_pcm_format_set_silence(format, 1617 snd_pcm_format_set_silence(format,
@@ -1767,7 +1775,7 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1767 AFMT_S8 | AFMT_U16_LE | 1775 AFMT_S8 | AFMT_U16_LE |
1768 AFMT_U16_BE | 1776 AFMT_U16_BE |
1769 AFMT_S32_LE | AFMT_S32_BE | 1777 AFMT_S32_LE | AFMT_S32_BE |
1770 AFMT_S24_LE | AFMT_S24_LE | 1778 AFMT_S24_LE | AFMT_S24_BE |
1771 AFMT_S24_PACKED; 1779 AFMT_S24_PACKED;
1772 params = kmalloc(sizeof(*params), GFP_KERNEL); 1780 params = kmalloc(sizeof(*params), GFP_KERNEL);
1773 if (!params) 1781 if (!params)
@@ -1895,7 +1903,9 @@ static int snd_pcm_oss_set_fragment(struct snd_pcm_oss_file *pcm_oss_file, unsig
1895 1903
1896static int snd_pcm_oss_nonblock(struct file * file) 1904static int snd_pcm_oss_nonblock(struct file * file)
1897{ 1905{
1906 spin_lock(&file->f_lock);
1898 file->f_flags |= O_NONBLOCK; 1907 file->f_flags |= O_NONBLOCK;
1908 spin_unlock(&file->f_lock);
1899 return 0; 1909 return 0;
1900} 1910}
1901 1911
@@ -1952,7 +1962,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
1952 int err, cmd; 1962 int err, cmd;
1953 1963
1954#ifdef OSS_DEBUG 1964#ifdef OSS_DEBUG
1955 printk("pcm_oss: trigger = 0x%x\n", trigger); 1965 printk(KERN_DEBUG "pcm_oss: trigger = 0x%x\n", trigger);
1956#endif 1966#endif
1957 1967
1958 psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 1968 psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
@@ -2170,7 +2180,9 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
2170 } 2180 }
2171 2181
2172#ifdef OSS_DEBUG 2182#ifdef OSS_DEBUG
2173 printk("pcm_oss: space: bytes = %i, fragments = %i, fragstotal = %i, fragsize = %i\n", info.bytes, info.fragments, info.fragstotal, info.fragsize); 2183 printk(KERN_DEBUG "pcm_oss: space: bytes = %i, fragments = %i, "
2184 "fragstotal = %i, fragsize = %i\n",
2185 info.bytes, info.fragments, info.fragstotal, info.fragsize);
2174#endif 2186#endif
2175 if (copy_to_user(_info, &info, sizeof(info))) 2187 if (copy_to_user(_info, &info, sizeof(info)))
2176 return -EFAULT; 2188 return -EFAULT;
@@ -2473,7 +2485,7 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
2473 if (((cmd >> 8) & 0xff) != 'P') 2485 if (((cmd >> 8) & 0xff) != 'P')
2474 return -EINVAL; 2486 return -EINVAL;
2475#ifdef OSS_DEBUG 2487#ifdef OSS_DEBUG
2476 printk("pcm_oss: ioctl = 0x%x\n", cmd); 2488 printk(KERN_DEBUG "pcm_oss: ioctl = 0x%x\n", cmd);
2477#endif 2489#endif
2478 switch (cmd) { 2490 switch (cmd) {
2479 case SNDCTL_DSP_RESET: 2491 case SNDCTL_DSP_RESET:
@@ -2627,7 +2639,8 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t coun
2627#else 2639#else
2628 { 2640 {
2629 ssize_t res = snd_pcm_oss_read1(substream, buf, count); 2641 ssize_t res = snd_pcm_oss_read1(substream, buf, count);
2630 printk("pcm_oss: read %li bytes (returned %li bytes)\n", (long)count, (long)res); 2642 printk(KERN_DEBUG "pcm_oss: read %li bytes "
2643 "(returned %li bytes)\n", (long)count, (long)res);
2631 return res; 2644 return res;
2632 } 2645 }
2633#endif 2646#endif
@@ -2646,7 +2659,8 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size
2646 substream->f_flags = file->f_flags & O_NONBLOCK; 2659 substream->f_flags = file->f_flags & O_NONBLOCK;
2647 result = snd_pcm_oss_write1(substream, buf, count); 2660 result = snd_pcm_oss_write1(substream, buf, count);
2648#ifdef OSS_DEBUG 2661#ifdef OSS_DEBUG
2649 printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result); 2662 printk(KERN_DEBUG "pcm_oss: write %li bytes (wrote %li bytes)\n",
2663 (long)count, (long)result);
2650#endif 2664#endif
2651 return result; 2665 return result;
2652} 2666}
@@ -2720,7 +2734,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
2720 int err; 2734 int err;
2721 2735
2722#ifdef OSS_DEBUG 2736#ifdef OSS_DEBUG
2723 printk("pcm_oss: mmap begin\n"); 2737 printk(KERN_DEBUG "pcm_oss: mmap begin\n");
2724#endif 2738#endif
2725 pcm_oss_file = file->private_data; 2739 pcm_oss_file = file->private_data;
2726 switch ((area->vm_flags & (VM_READ | VM_WRITE))) { 2740 switch ((area->vm_flags & (VM_READ | VM_WRITE))) {
@@ -2770,7 +2784,8 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
2770 runtime->silence_threshold = 0; 2784 runtime->silence_threshold = 0;
2771 runtime->silence_size = 0; 2785 runtime->silence_size = 0;
2772#ifdef OSS_DEBUG 2786#ifdef OSS_DEBUG
2773 printk("pcm_oss: mmap ok, bytes = 0x%x\n", runtime->oss.mmap_bytes); 2787 printk(KERN_DEBUG "pcm_oss: mmap ok, bytes = 0x%x\n",
2788 runtime->oss.mmap_bytes);
2774#endif 2789#endif
2775 /* In mmap mode we never stop */ 2790 /* In mmap mode we never stop */
2776 runtime->stop_threshold = runtime->boundary; 2791 runtime->stop_threshold = runtime->boundary;
@@ -2872,7 +2887,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
2872 setup = kmalloc(sizeof(*setup), GFP_KERNEL); 2887 setup = kmalloc(sizeof(*setup), GFP_KERNEL);
2873 if (! setup) { 2888 if (! setup) {
2874 buffer->error = -ENOMEM; 2889 buffer->error = -ENOMEM;
2875 mutex_lock(&pstr->oss.setup_mutex); 2890 mutex_unlock(&pstr->oss.setup_mutex);
2876 return; 2891 return;
2877 } 2892 }
2878 if (pstr->oss.setup_list == NULL) 2893 if (pstr->oss.setup_list == NULL)
@@ -2886,7 +2901,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
2886 if (! template.task_name) { 2901 if (! template.task_name) {
2887 kfree(setup); 2902 kfree(setup);
2888 buffer->error = -ENOMEM; 2903 buffer->error = -ENOMEM;
2889 mutex_lock(&pstr->oss.setup_mutex); 2904 mutex_unlock(&pstr->oss.setup_mutex);
2890 return; 2905 return;
2891 } 2906 }
2892 } 2907 }
diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
index ca2f4c39be46..b9afab603711 100644
--- a/sound/core/oss/pcm_plugin.h
+++ b/sound/core/oss/pcm_plugin.h
@@ -176,9 +176,9 @@ static inline int snd_pcm_plug_slave_format(int format, struct snd_mask *format_
176#endif 176#endif
177 177
178#ifdef PLUGIN_DEBUG 178#ifdef PLUGIN_DEBUG
179#define pdprintf( fmt, args... ) printk( "plugin: " fmt, ##args) 179#define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args)
180#else 180#else
181#define pdprintf( fmt, args... ) 181#define pdprintf(fmt, args...)
182#endif 182#endif
183 183
184#endif /* __PCM_PLUGIN_H */ 184#endif /* __PCM_PLUGIN_H */
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c
index a466443c4a26..2fa9299a440d 100644
--- a/sound/core/oss/rate.c
+++ b/sound/core/oss/rate.c
@@ -157,7 +157,7 @@ static void resample_shrink(struct snd_pcm_plugin *plugin,
157 while (dst_frames1 > 0) { 157 while (dst_frames1 > 0) {
158 S1 = S2; 158 S1 = S2;
159 if (src_frames1-- > 0) { 159 if (src_frames1-- > 0) {
160 S1 = *src; 160 S2 = *src;
161 src += src_step; 161 src += src_step;
162 } 162 }
163 if (pos & ~R_MASK) { 163 if (pos & ~R_MASK) {
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 192a433a2403..145931a9ff30 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -667,7 +667,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
667 spin_lock_init(&substream->self_group.lock); 667 spin_lock_init(&substream->self_group.lock);
668 INIT_LIST_HEAD(&substream->self_group.substreams); 668 INIT_LIST_HEAD(&substream->self_group.substreams);
669 list_add_tail(&substream->link_list, &substream->self_group.substreams); 669 list_add_tail(&substream->link_list, &substream->self_group.substreams);
670 spin_lock_init(&substream->timer_lock);
671 atomic_set(&substream->mmap_count, 0); 670 atomic_set(&substream->mmap_count, 0);
672 prev = substream; 671 prev = substream;
673 } 672 }
@@ -692,7 +691,7 @@ EXPORT_SYMBOL(snd_pcm_new_stream);
692 * 691 *
693 * Returns zero if successful, or a negative error code on failure. 692 * Returns zero if successful, or a negative error code on failure.
694 */ 693 */
695int snd_pcm_new(struct snd_card *card, char *id, int device, 694int snd_pcm_new(struct snd_card *card, const char *id, int device,
696 int playback_count, int capture_count, 695 int playback_count, int capture_count,
697 struct snd_pcm ** rpcm) 696 struct snd_pcm ** rpcm)
698{ 697{
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 36d7a5998234..08bfed594a83 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -232,14 +232,11 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,
232 if (! (runtime = substream->runtime)) 232 if (! (runtime = substream->runtime))
233 return -ENOTTY; 233 return -ENOTTY;
234 234
235 data = kmalloc(sizeof(*data), GFP_KERNEL);
236 if (data == NULL)
237 return -ENOMEM;
238 /* only fifo_size is different, so just copy all */ 235 /* only fifo_size is different, so just copy all */
239 if (copy_from_user(data, data32, sizeof(*data32))) { 236 data = memdup_user(data32, sizeof(*data32));
240 err = -EFAULT; 237 if (IS_ERR(data))
241 goto error; 238 return PTR_ERR(data);
242 } 239
243 if (refine) 240 if (refine)
244 err = snd_pcm_hw_refine(substream, data); 241 err = snd_pcm_hw_refine(substream, data);
245 else 242 else
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 921691080f35..a2a792c18c40 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -125,23 +125,32 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
125 } 125 }
126} 126}
127 127
128#ifdef CONFIG_SND_PCM_XRUN_DEBUG
129#define xrun_debug(substream) ((substream)->pstr->xrun_debug)
130#else
131#define xrun_debug(substream) 0
132#endif
133
134#define dump_stack_on_xrun(substream) do { \
135 if (xrun_debug(substream) > 1) \
136 dump_stack(); \
137 } while (0)
138
128static void xrun(struct snd_pcm_substream *substream) 139static void xrun(struct snd_pcm_substream *substream)
129{ 140{
130 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 141 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
131#ifdef CONFIG_SND_PCM_XRUN_DEBUG 142 if (xrun_debug(substream)) {
132 if (substream->pstr->xrun_debug) {
133 snd_printd(KERN_DEBUG "XRUN: pcmC%dD%d%c\n", 143 snd_printd(KERN_DEBUG "XRUN: pcmC%dD%d%c\n",
134 substream->pcm->card->number, 144 substream->pcm->card->number,
135 substream->pcm->device, 145 substream->pcm->device,
136 substream->stream ? 'c' : 'p'); 146 substream->stream ? 'c' : 'p');
137 if (substream->pstr->xrun_debug > 1) 147 dump_stack_on_xrun(substream);
138 dump_stack();
139 } 148 }
140#endif
141} 149}
142 150
143static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream, 151static snd_pcm_uframes_t
144 struct snd_pcm_runtime *runtime) 152snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream,
153 struct snd_pcm_runtime *runtime)
145{ 154{
146 snd_pcm_uframes_t pos; 155 snd_pcm_uframes_t pos;
147 156
@@ -150,17 +159,21 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(struct snd_pcm_substre
150 pos = substream->ops->pointer(substream); 159 pos = substream->ops->pointer(substream);
151 if (pos == SNDRV_PCM_POS_XRUN) 160 if (pos == SNDRV_PCM_POS_XRUN)
152 return pos; /* XRUN */ 161 return pos; /* XRUN */
153#ifdef CONFIG_SND_DEBUG
154 if (pos >= runtime->buffer_size) { 162 if (pos >= runtime->buffer_size) {
155 snd_printk(KERN_ERR "BUG: stream = %i, pos = 0x%lx, buffer size = 0x%lx, period size = 0x%lx\n", substream->stream, pos, runtime->buffer_size, runtime->period_size); 163 if (printk_ratelimit()) {
164 snd_printd(KERN_ERR "BUG: stream = %i, pos = 0x%lx, "
165 "buffer size = 0x%lx, period size = 0x%lx\n",
166 substream->stream, pos, runtime->buffer_size,
167 runtime->period_size);
168 }
169 pos = 0;
156 } 170 }
157#endif
158 pos -= pos % runtime->min_align; 171 pos -= pos % runtime->min_align;
159 return pos; 172 return pos;
160} 173}
161 174
162static inline int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, 175static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream,
163 struct snd_pcm_runtime *runtime) 176 struct snd_pcm_runtime *runtime)
164{ 177{
165 snd_pcm_uframes_t avail; 178 snd_pcm_uframes_t avail;
166 179
@@ -182,48 +195,108 @@ static inline int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream
182 return 0; 195 return 0;
183} 196}
184 197
185static inline int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) 198#define hw_ptr_error(substream, fmt, args...) \
199 do { \
200 if (xrun_debug(substream)) { \
201 if (printk_ratelimit()) { \
202 snd_printd("PCM: " fmt, ##args); \
203 } \
204 dump_stack_on_xrun(substream); \
205 } \
206 } while (0)
207
208static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
186{ 209{
187 struct snd_pcm_runtime *runtime = substream->runtime; 210 struct snd_pcm_runtime *runtime = substream->runtime;
188 snd_pcm_uframes_t pos; 211 snd_pcm_uframes_t pos;
189 snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt; 212 snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_ptr_interrupt, hw_base;
190 snd_pcm_sframes_t delta; 213 snd_pcm_sframes_t hdelta, delta;
214 unsigned long jdelta;
191 215
216 old_hw_ptr = runtime->status->hw_ptr;
192 pos = snd_pcm_update_hw_ptr_pos(substream, runtime); 217 pos = snd_pcm_update_hw_ptr_pos(substream, runtime);
193 if (pos == SNDRV_PCM_POS_XRUN) { 218 if (pos == SNDRV_PCM_POS_XRUN) {
194 xrun(substream); 219 xrun(substream);
195 return -EPIPE; 220 return -EPIPE;
196 } 221 }
197 if (runtime->period_size == runtime->buffer_size) 222 hw_base = runtime->hw_ptr_base;
198 goto __next_buf; 223 new_hw_ptr = hw_base + pos;
199 new_hw_ptr = runtime->hw_ptr_base + pos;
200 hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; 224 hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size;
201 225 delta = new_hw_ptr - hw_ptr_interrupt;
202 delta = hw_ptr_interrupt - new_hw_ptr; 226 if (hw_ptr_interrupt >= runtime->boundary) {
203 if (delta > 0) { 227 hw_ptr_interrupt -= runtime->boundary;
204 if ((snd_pcm_uframes_t)delta < runtime->buffer_size / 2) { 228 if (hw_base < runtime->boundary / 2)
205#ifdef CONFIG_SND_PCM_XRUN_DEBUG 229 /* hw_base was already lapped; recalc delta */
206 if (runtime->periods > 1 && substream->pstr->xrun_debug) { 230 delta = new_hw_ptr - hw_ptr_interrupt;
207 snd_printd(KERN_ERR "Unexpected hw_pointer value [1] (stream = %i, delta: -%ld, max jitter = %ld): wrong interrupt acknowledge?\n", substream->stream, (long) delta, runtime->buffer_size / 2); 231 }
208 if (substream->pstr->xrun_debug > 1) 232 if (delta < 0) {
209 dump_stack(); 233 delta += runtime->buffer_size;
210 } 234 if (delta < 0) {
211#endif 235 hw_ptr_error(substream,
212 return 0; 236 "Unexpected hw_pointer value "
237 "(stream=%i, pos=%ld, intr_ptr=%ld)\n",
238 substream->stream, (long)pos,
239 (long)hw_ptr_interrupt);
240 /* rebase to interrupt position */
241 hw_base = new_hw_ptr = hw_ptr_interrupt;
242 /* align hw_base to buffer_size */
243 hw_base -= hw_base % runtime->buffer_size;
244 delta = 0;
245 } else {
246 hw_base += runtime->buffer_size;
247 if (hw_base >= runtime->boundary)
248 hw_base = 0;
249 new_hw_ptr = hw_base + pos;
213 } 250 }
214 __next_buf:
215 runtime->hw_ptr_base += runtime->buffer_size;
216 if (runtime->hw_ptr_base == runtime->boundary)
217 runtime->hw_ptr_base = 0;
218 new_hw_ptr = runtime->hw_ptr_base + pos;
219 } 251 }
220 252 /* Skip the jiffies check for hardwares with BATCH flag.
253 * Such hardware usually just increases the position at each IRQ,
254 * thus it can't give any strange position.
255 */
256 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH)
257 goto no_jiffies_check;
258 hdelta = new_hw_ptr - old_hw_ptr;
259 jdelta = jiffies - runtime->hw_ptr_jiffies;
260 if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) {
261 delta = jdelta /
262 (((runtime->period_size * HZ) / runtime->rate)
263 + HZ/100);
264 hw_ptr_error(substream,
265 "hw_ptr skipping! [Q] "
266 "(pos=%ld, delta=%ld, period=%ld, "
267 "jdelta=%lu/%lu/%lu)\n",
268 (long)pos, (long)hdelta,
269 (long)runtime->period_size, jdelta,
270 ((hdelta * HZ) / runtime->rate), delta);
271 hw_ptr_interrupt = runtime->hw_ptr_interrupt +
272 runtime->period_size * delta;
273 if (hw_ptr_interrupt >= runtime->boundary)
274 hw_ptr_interrupt -= runtime->boundary;
275 /* rebase to interrupt position */
276 hw_base = new_hw_ptr = hw_ptr_interrupt;
277 /* align hw_base to buffer_size */
278 hw_base -= hw_base % runtime->buffer_size;
279 delta = 0;
280 }
281 no_jiffies_check:
282 if (delta > runtime->period_size + runtime->period_size / 2) {
283 hw_ptr_error(substream,
284 "Lost interrupts? "
285 "(stream=%i, delta=%ld, intr_ptr=%ld)\n",
286 substream->stream, (long)delta,
287 (long)hw_ptr_interrupt);
288 /* rebase hw_ptr_interrupt */
289 hw_ptr_interrupt =
290 new_hw_ptr - new_hw_ptr % runtime->period_size;
291 }
221 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 292 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
222 runtime->silence_size > 0) 293 runtime->silence_size > 0)
223 snd_pcm_playback_silence(substream, new_hw_ptr); 294 snd_pcm_playback_silence(substream, new_hw_ptr);
224 295
296 runtime->hw_ptr_base = hw_base;
225 runtime->status->hw_ptr = new_hw_ptr; 297 runtime->status->hw_ptr = new_hw_ptr;
226 runtime->hw_ptr_interrupt = new_hw_ptr - new_hw_ptr % runtime->period_size; 298 runtime->hw_ptr_jiffies = jiffies;
299 runtime->hw_ptr_interrupt = hw_ptr_interrupt;
227 300
228 return snd_pcm_update_hw_ptr_post(substream, runtime); 301 return snd_pcm_update_hw_ptr_post(substream, runtime);
229} 302}
@@ -233,8 +306,9 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream)
233{ 306{
234 struct snd_pcm_runtime *runtime = substream->runtime; 307 struct snd_pcm_runtime *runtime = substream->runtime;
235 snd_pcm_uframes_t pos; 308 snd_pcm_uframes_t pos;
236 snd_pcm_uframes_t old_hw_ptr, new_hw_ptr; 309 snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base;
237 snd_pcm_sframes_t delta; 310 snd_pcm_sframes_t delta;
311 unsigned long jdelta;
238 312
239 old_hw_ptr = runtime->status->hw_ptr; 313 old_hw_ptr = runtime->status->hw_ptr;
240 pos = snd_pcm_update_hw_ptr_pos(substream, runtime); 314 pos = snd_pcm_update_hw_ptr_pos(substream, runtime);
@@ -242,30 +316,42 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream)
242 xrun(substream); 316 xrun(substream);
243 return -EPIPE; 317 return -EPIPE;
244 } 318 }
245 new_hw_ptr = runtime->hw_ptr_base + pos; 319 hw_base = runtime->hw_ptr_base;
246 320 new_hw_ptr = hw_base + pos;
247 delta = old_hw_ptr - new_hw_ptr; 321
248 if (delta > 0) { 322 delta = new_hw_ptr - old_hw_ptr;
249 if ((snd_pcm_uframes_t)delta < runtime->buffer_size / 2) { 323 jdelta = jiffies - runtime->hw_ptr_jiffies;
250#ifdef CONFIG_SND_PCM_XRUN_DEBUG 324 if (delta < 0) {
251 if (runtime->periods > 2 && substream->pstr->xrun_debug) { 325 delta += runtime->buffer_size;
252 snd_printd(KERN_ERR "Unexpected hw_pointer value [2] (stream = %i, delta: -%ld, max jitter = %ld): wrong interrupt acknowledge?\n", substream->stream, (long) delta, runtime->buffer_size / 2); 326 if (delta < 0) {
253 if (substream->pstr->xrun_debug > 1) 327 hw_ptr_error(substream,
254 dump_stack(); 328 "Unexpected hw_pointer value [2] "
255 } 329 "(stream=%i, pos=%ld, old_ptr=%ld, jdelta=%li)\n",
256#endif 330 substream->stream, (long)pos,
331 (long)old_hw_ptr, jdelta);
257 return 0; 332 return 0;
258 } 333 }
259 runtime->hw_ptr_base += runtime->buffer_size; 334 hw_base += runtime->buffer_size;
260 if (runtime->hw_ptr_base == runtime->boundary) 335 if (hw_base >= runtime->boundary)
261 runtime->hw_ptr_base = 0; 336 hw_base = 0;
262 new_hw_ptr = runtime->hw_ptr_base + pos; 337 new_hw_ptr = hw_base + pos;
338 }
339 if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) {
340 hw_ptr_error(substream,
341 "hw_ptr skipping! "
342 "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu)\n",
343 (long)pos, (long)delta,
344 (long)runtime->period_size, jdelta,
345 ((delta * HZ) / runtime->rate));
346 return 0;
263 } 347 }
264 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 348 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
265 runtime->silence_size > 0) 349 runtime->silence_size > 0)
266 snd_pcm_playback_silence(substream, new_hw_ptr); 350 snd_pcm_playback_silence(substream, new_hw_ptr);
267 351
352 runtime->hw_ptr_base = hw_base;
268 runtime->status->hw_ptr = new_hw_ptr; 353 runtime->status->hw_ptr = new_hw_ptr;
354 runtime->hw_ptr_jiffies = jiffies;
269 355
270 return snd_pcm_update_hw_ptr_post(substream, runtime); 356 return snd_pcm_update_hw_ptr_post(substream, runtime);
271} 357}
@@ -1392,6 +1478,7 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream,
1392 runtime->status->hw_ptr %= runtime->buffer_size; 1478 runtime->status->hw_ptr %= runtime->buffer_size;
1393 else 1479 else
1394 runtime->status->hw_ptr = 0; 1480 runtime->status->hw_ptr = 0;
1481 runtime->hw_ptr_jiffies = jiffies;
1395 snd_pcm_stream_unlock_irqrestore(substream, flags); 1482 snd_pcm_stream_unlock_irqrestore(substream, flags);
1396 return 0; 1483 return 0;
1397} 1484}
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index a789efc9df39..fc6f98e257df 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -186,7 +186,7 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
186 if (!(params->rmask & (1 << k))) 186 if (!(params->rmask & (1 << k)))
187 continue; 187 continue;
188#ifdef RULES_DEBUG 188#ifdef RULES_DEBUG
189 printk("%s = ", snd_pcm_hw_param_names[k]); 189 printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
190 printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); 190 printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
191#endif 191#endif
192 changed = snd_mask_refine(m, constrs_mask(constrs, k)); 192 changed = snd_mask_refine(m, constrs_mask(constrs, k));
@@ -206,7 +206,7 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
206 if (!(params->rmask & (1 << k))) 206 if (!(params->rmask & (1 << k)))
207 continue; 207 continue;
208#ifdef RULES_DEBUG 208#ifdef RULES_DEBUG
209 printk("%s = ", snd_pcm_hw_param_names[k]); 209 printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
210 if (i->empty) 210 if (i->empty)
211 printk("empty"); 211 printk("empty");
212 else 212 else
@@ -251,7 +251,7 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
251 if (!doit) 251 if (!doit)
252 continue; 252 continue;
253#ifdef RULES_DEBUG 253#ifdef RULES_DEBUG
254 printk("Rule %d [%p]: ", k, r->func); 254 printk(KERN_DEBUG "Rule %d [%p]: ", k, r->func);
255 if (r->var >= 0) { 255 if (r->var >= 0) {
256 printk("%s = ", snd_pcm_hw_param_names[r->var]); 256 printk("%s = ", snd_pcm_hw_param_names[r->var]);
257 if (hw_is_mask(r->var)) { 257 if (hw_is_mask(r->var)) {
@@ -327,21 +327,16 @@ static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream,
327 struct snd_pcm_hw_params *params; 327 struct snd_pcm_hw_params *params;
328 int err; 328 int err;
329 329
330 params = kmalloc(sizeof(*params), GFP_KERNEL); 330 params = memdup_user(_params, sizeof(*params));
331 if (!params) { 331 if (IS_ERR(params))
332 err = -ENOMEM; 332 return PTR_ERR(params);
333 goto out; 333
334 }
335 if (copy_from_user(params, _params, sizeof(*params))) {
336 err = -EFAULT;
337 goto out;
338 }
339 err = snd_pcm_hw_refine(substream, params); 334 err = snd_pcm_hw_refine(substream, params);
340 if (copy_to_user(_params, params, sizeof(*params))) { 335 if (copy_to_user(_params, params, sizeof(*params))) {
341 if (!err) 336 if (!err)
342 err = -EFAULT; 337 err = -EFAULT;
343 } 338 }
344out: 339
345 kfree(params); 340 kfree(params);
346 return err; 341 return err;
347} 342}
@@ -465,21 +460,16 @@ static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream,
465 struct snd_pcm_hw_params *params; 460 struct snd_pcm_hw_params *params;
466 int err; 461 int err;
467 462
468 params = kmalloc(sizeof(*params), GFP_KERNEL); 463 params = memdup_user(_params, sizeof(*params));
469 if (!params) { 464 if (IS_ERR(params))
470 err = -ENOMEM; 465 return PTR_ERR(params);
471 goto out; 466
472 }
473 if (copy_from_user(params, _params, sizeof(*params))) {
474 err = -EFAULT;
475 goto out;
476 }
477 err = snd_pcm_hw_params(substream, params); 467 err = snd_pcm_hw_params(substream, params);
478 if (copy_to_user(_params, params, sizeof(*params))) { 468 if (copy_to_user(_params, params, sizeof(*params))) {
479 if (!err) 469 if (!err)
480 err = -EFAULT; 470 err = -EFAULT;
481 } 471 }
482out: 472
483 kfree(params); 473 kfree(params);
484 return err; 474 return err;
485} 475}
@@ -2593,13 +2583,11 @@ static int snd_pcm_playback_ioctl1(struct file *file,
2593 return -EFAULT; 2583 return -EFAULT;
2594 if (copy_from_user(&xfern, _xfern, sizeof(xfern))) 2584 if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
2595 return -EFAULT; 2585 return -EFAULT;
2596 bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); 2586
2597 if (bufs == NULL) 2587 bufs = memdup_user(xfern.bufs,
2598 return -ENOMEM; 2588 sizeof(void *) * runtime->channels);
2599 if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { 2589 if (IS_ERR(bufs))
2600 kfree(bufs); 2590 return PTR_ERR(bufs);
2601 return -EFAULT;
2602 }
2603 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); 2591 result = snd_pcm_lib_writev(substream, bufs, xfern.frames);
2604 kfree(bufs); 2592 kfree(bufs);
2605 __put_user(result, &_xfern->result); 2593 __put_user(result, &_xfern->result);
@@ -2675,13 +2663,11 @@ static int snd_pcm_capture_ioctl1(struct file *file,
2675 return -EFAULT; 2663 return -EFAULT;
2676 if (copy_from_user(&xfern, _xfern, sizeof(xfern))) 2664 if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
2677 return -EFAULT; 2665 return -EFAULT;
2678 bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); 2666
2679 if (bufs == NULL) 2667 bufs = memdup_user(xfern.bufs,
2680 return -ENOMEM; 2668 sizeof(void *) * runtime->channels);
2681 if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { 2669 if (IS_ERR(bufs))
2682 kfree(bufs); 2670 return PTR_ERR(bufs);
2683 return -EFAULT;
2684 }
2685 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); 2671 result = snd_pcm_lib_readv(substream, bufs, xfern.frames);
2686 kfree(bufs); 2672 kfree(bufs);
2687 __put_user(result, &_xfern->result); 2673 __put_user(result, &_xfern->result);
@@ -3246,9 +3232,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
3246 err = fasync_helper(fd, file, on, &runtime->fasync); 3232 err = fasync_helper(fd, file, on, &runtime->fasync);
3247out: 3233out:
3248 unlock_kernel(); 3234 unlock_kernel();
3249 if (err < 0) 3235 return err;
3250 return err;
3251 return 0;
3252} 3236}
3253 3237
3254/* 3238/*
@@ -3314,18 +3298,12 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
3314 int err; 3298 int err;
3315 3299
3316 params = kmalloc(sizeof(*params), GFP_KERNEL); 3300 params = kmalloc(sizeof(*params), GFP_KERNEL);
3317 if (!params) { 3301 if (!params)
3318 err = -ENOMEM; 3302 return -ENOMEM;
3319 goto out;
3320 }
3321 oparams = kmalloc(sizeof(*oparams), GFP_KERNEL);
3322 if (!oparams) {
3323 err = -ENOMEM;
3324 goto out;
3325 }
3326 3303
3327 if (copy_from_user(oparams, _oparams, sizeof(*oparams))) { 3304 oparams = memdup_user(_oparams, sizeof(*oparams));
3328 err = -EFAULT; 3305 if (IS_ERR(oparams)) {
3306 err = PTR_ERR(oparams);
3329 goto out; 3307 goto out;
3330 } 3308 }
3331 snd_pcm_hw_convert_from_old_params(params, oparams); 3309 snd_pcm_hw_convert_from_old_params(params, oparams);
@@ -3335,9 +3313,10 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
3335 if (!err) 3313 if (!err)
3336 err = -EFAULT; 3314 err = -EFAULT;
3337 } 3315 }
3316
3317 kfree(oparams);
3338out: 3318out:
3339 kfree(params); 3319 kfree(params);
3340 kfree(oparams);
3341 return err; 3320 return err;
3342} 3321}
3343 3322
@@ -3349,17 +3328,12 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
3349 int err; 3328 int err;
3350 3329
3351 params = kmalloc(sizeof(*params), GFP_KERNEL); 3330 params = kmalloc(sizeof(*params), GFP_KERNEL);
3352 if (!params) { 3331 if (!params)
3353 err = -ENOMEM; 3332 return -ENOMEM;
3354 goto out; 3333
3355 } 3334 oparams = memdup_user(_oparams, sizeof(*oparams));
3356 oparams = kmalloc(sizeof(*oparams), GFP_KERNEL); 3335 if (IS_ERR(oparams)) {
3357 if (!oparams) { 3336 err = PTR_ERR(oparams);
3358 err = -ENOMEM;
3359 goto out;
3360 }
3361 if (copy_from_user(oparams, _oparams, sizeof(*oparams))) {
3362 err = -EFAULT;
3363 goto out; 3337 goto out;
3364 } 3338 }
3365 snd_pcm_hw_convert_from_old_params(params, oparams); 3339 snd_pcm_hw_convert_from_old_params(params, oparams);
@@ -3369,9 +3343,10 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
3369 if (!err) 3343 if (!err)
3370 err = -EFAULT; 3344 err = -EFAULT;
3371 } 3345 }
3346
3347 kfree(oparams);
3372out: 3348out:
3373 kfree(params); 3349 kfree(params);
3374 kfree(oparams);
3375 return err; 3350 return err;
3376} 3351}
3377#endif /* CONFIG_SND_SUPPORT_OLD_API */ 3352#endif /* CONFIG_SND_SUPPORT_OLD_API */
diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c
index 2c89c04f2916..ca8068b63d6c 100644
--- a/sound/core/pcm_timer.c
+++ b/sound/core/pcm_timer.c
@@ -85,25 +85,19 @@ static unsigned long snd_pcm_timer_resolution(struct snd_timer * timer)
85 85
86static int snd_pcm_timer_start(struct snd_timer * timer) 86static int snd_pcm_timer_start(struct snd_timer * timer)
87{ 87{
88 unsigned long flags;
89 struct snd_pcm_substream *substream; 88 struct snd_pcm_substream *substream;
90 89
91 substream = snd_timer_chip(timer); 90 substream = snd_timer_chip(timer);
92 spin_lock_irqsave(&substream->timer_lock, flags);
93 substream->timer_running = 1; 91 substream->timer_running = 1;
94 spin_unlock_irqrestore(&substream->timer_lock, flags);
95 return 0; 92 return 0;
96} 93}
97 94
98static int snd_pcm_timer_stop(struct snd_timer * timer) 95static int snd_pcm_timer_stop(struct snd_timer * timer)
99{ 96{
100 unsigned long flags;
101 struct snd_pcm_substream *substream; 97 struct snd_pcm_substream *substream;
102 98
103 substream = snd_timer_chip(timer); 99 substream = snd_timer_chip(timer);
104 spin_lock_irqsave(&substream->timer_lock, flags);
105 substream->timer_running = 0; 100 substream->timer_running = 0;
106 spin_unlock_irqrestore(&substream->timer_lock, flags);
107 return 0; 101 return 0;
108} 102}
109 103
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 002777ba336a..473247c8e6d3 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -224,156 +224,143 @@ int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream)
224 return 0; 224 return 0;
225} 225}
226 226
227int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, 227/* look for an available substream for the given stream direction;
228 int mode, struct snd_rawmidi_file * rfile) 228 * if a specific subdevice is given, try to assign it
229 */
230static int assign_substream(struct snd_rawmidi *rmidi, int subdevice,
231 int stream, int mode,
232 struct snd_rawmidi_substream **sub_ret)
233{
234 struct snd_rawmidi_substream *substream;
235 struct snd_rawmidi_str *s = &rmidi->streams[stream];
236 static unsigned int info_flags[2] = {
237 [SNDRV_RAWMIDI_STREAM_OUTPUT] = SNDRV_RAWMIDI_INFO_OUTPUT,
238 [SNDRV_RAWMIDI_STREAM_INPUT] = SNDRV_RAWMIDI_INFO_INPUT,
239 };
240
241 if (!(rmidi->info_flags & info_flags[stream]))
242 return -ENXIO;
243 if (subdevice >= 0 && subdevice >= s->substream_count)
244 return -ENODEV;
245 if (s->substream_opened >= s->substream_count)
246 return -EAGAIN;
247
248 list_for_each_entry(substream, &s->substreams, list) {
249 if (substream->opened) {
250 if (stream == SNDRV_RAWMIDI_STREAM_INPUT ||
251 !(mode & SNDRV_RAWMIDI_LFLG_APPEND))
252 continue;
253 }
254 if (subdevice < 0 || subdevice == substream->number) {
255 *sub_ret = substream;
256 return 0;
257 }
258 }
259 return -EAGAIN;
260}
261
262/* open and do ref-counting for the given substream */
263static int open_substream(struct snd_rawmidi *rmidi,
264 struct snd_rawmidi_substream *substream,
265 int mode)
266{
267 int err;
268
269 err = snd_rawmidi_runtime_create(substream);
270 if (err < 0)
271 return err;
272 err = substream->ops->open(substream);
273 if (err < 0)
274 return err;
275 substream->opened = 1;
276 if (substream->use_count++ == 0)
277 substream->active_sensing = 1;
278 if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
279 substream->append = 1;
280 rmidi->streams[substream->stream].substream_opened++;
281 return 0;
282}
283
284static void close_substream(struct snd_rawmidi *rmidi,
285 struct snd_rawmidi_substream *substream,
286 int cleanup);
287
288static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode,
289 struct snd_rawmidi_file *rfile)
229{ 290{
230 struct snd_rawmidi *rmidi;
231 struct list_head *list1, *list2;
232 struct snd_rawmidi_substream *sinput = NULL, *soutput = NULL; 291 struct snd_rawmidi_substream *sinput = NULL, *soutput = NULL;
233 struct snd_rawmidi_runtime *input = NULL, *output = NULL;
234 int err; 292 int err;
235 293
236 if (rfile) 294 rfile->input = rfile->output = NULL;
237 rfile->input = rfile->output = NULL;
238 mutex_lock(&register_mutex);
239 rmidi = snd_rawmidi_search(card, device);
240 mutex_unlock(&register_mutex);
241 if (rmidi == NULL) {
242 err = -ENODEV;
243 goto __error1;
244 }
245 if (!try_module_get(rmidi->card->module)) {
246 err = -EFAULT;
247 goto __error1;
248 }
249 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
250 mutex_lock(&rmidi->open_mutex);
251 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) { 295 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
252 if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) { 296 err = assign_substream(rmidi, subdevice,
253 err = -ENXIO; 297 SNDRV_RAWMIDI_STREAM_INPUT,
254 goto __error; 298 mode, &sinput);
255 } 299 if (err < 0)
256 if (subdevice >= 0 && (unsigned int)subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_count) {
257 err = -ENODEV;
258 goto __error;
259 }
260 if (rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_opened >=
261 rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_count) {
262 err = -EAGAIN;
263 goto __error; 300 goto __error;
264 }
265 } 301 }
266 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { 302 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) {
267 if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT)) { 303 err = assign_substream(rmidi, subdevice,
268 err = -ENXIO; 304 SNDRV_RAWMIDI_STREAM_OUTPUT,
269 goto __error; 305 mode, &soutput);
270 } 306 if (err < 0)
271 if (subdevice >= 0 && (unsigned int)subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_count) {
272 err = -ENODEV;
273 goto __error;
274 }
275 if (rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened >=
276 rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_count) {
277 err = -EAGAIN;
278 goto __error; 307 goto __error;
279 }
280 }
281 list1 = rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams.next;
282 while (1) {
283 if (list1 == &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) {
284 sinput = NULL;
285 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
286 err = -EAGAIN;
287 goto __error;
288 }
289 break;
290 }
291 sinput = list_entry(list1, struct snd_rawmidi_substream, list);
292 if ((mode & SNDRV_RAWMIDI_LFLG_INPUT) && sinput->opened)
293 goto __nexti;
294 if (subdevice < 0 || (subdevice >= 0 && subdevice == sinput->number))
295 break;
296 __nexti:
297 list1 = list1->next;
298 } 308 }
299 list2 = rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams.next; 309
300 while (1) { 310 if (sinput) {
301 if (list2 == &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { 311 err = open_substream(rmidi, sinput, mode);
302 soutput = NULL; 312 if (err < 0)
303 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) {
304 err = -EAGAIN;
305 goto __error;
306 }
307 break;
308 }
309 soutput = list_entry(list2, struct snd_rawmidi_substream, list);
310 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) {
311 if (mode & SNDRV_RAWMIDI_LFLG_APPEND) {
312 if (soutput->opened && !soutput->append)
313 goto __nexto;
314 } else {
315 if (soutput->opened)
316 goto __nexto;
317 }
318 }
319 if (subdevice < 0 || (subdevice >= 0 && subdevice == soutput->number))
320 break;
321 __nexto:
322 list2 = list2->next;
323 }
324 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
325 if ((err = snd_rawmidi_runtime_create(sinput)) < 0)
326 goto __error;
327 input = sinput->runtime;
328 if ((err = sinput->ops->open(sinput)) < 0)
329 goto __error; 313 goto __error;
330 sinput->opened = 1;
331 rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_opened++;
332 } else {
333 sinput = NULL;
334 } 314 }
335 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { 315 if (soutput) {
336 if (soutput->opened) 316 err = open_substream(rmidi, soutput, mode);
337 goto __skip_output; 317 if (err < 0) {
338 if ((err = snd_rawmidi_runtime_create(soutput)) < 0) { 318 if (sinput)
339 if (mode & SNDRV_RAWMIDI_LFLG_INPUT) 319 close_substream(rmidi, sinput, 0);
340 sinput->ops->close(sinput);
341 goto __error;
342 }
343 output = soutput->runtime;
344 if ((err = soutput->ops->open(soutput)) < 0) {
345 if (mode & SNDRV_RAWMIDI_LFLG_INPUT)
346 sinput->ops->close(sinput);
347 goto __error; 320 goto __error;
348 } 321 }
349 __skip_output:
350 soutput->opened = 1;
351 if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
352 soutput->append = 1;
353 if (soutput->use_count++ == 0)
354 soutput->active_sensing = 1;
355 rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened++;
356 } else {
357 soutput = NULL;
358 }
359 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
360 mutex_unlock(&rmidi->open_mutex);
361 if (rfile) {
362 rfile->rmidi = rmidi;
363 rfile->input = sinput;
364 rfile->output = soutput;
365 } 322 }
323
324 rfile->rmidi = rmidi;
325 rfile->input = sinput;
326 rfile->output = soutput;
366 return 0; 327 return 0;
367 328
368 __error: 329 __error:
369 if (input != NULL) 330 if (sinput && sinput->runtime)
370 snd_rawmidi_runtime_free(sinput); 331 snd_rawmidi_runtime_free(sinput);
371 if (output != NULL) 332 if (soutput && soutput->runtime)
372 snd_rawmidi_runtime_free(soutput); 333 snd_rawmidi_runtime_free(soutput);
373 module_put(rmidi->card->module); 334 return err;
374 if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK)) 335}
375 mutex_unlock(&rmidi->open_mutex); 336
376 __error1: 337/* called from sound/core/seq/seq_midi.c */
338int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
339 int mode, struct snd_rawmidi_file * rfile)
340{
341 struct snd_rawmidi *rmidi;
342 int err;
343
344 if (snd_BUG_ON(!rfile))
345 return -EINVAL;
346
347 mutex_lock(&register_mutex);
348 rmidi = snd_rawmidi_search(card, device);
349 if (rmidi == NULL) {
350 mutex_unlock(&register_mutex);
351 return -ENODEV;
352 }
353 if (!try_module_get(rmidi->card->module)) {
354 mutex_unlock(&register_mutex);
355 return -ENXIO;
356 }
357 mutex_unlock(&register_mutex);
358
359 mutex_lock(&rmidi->open_mutex);
360 err = rawmidi_open_priv(rmidi, subdevice, mode, rfile);
361 mutex_unlock(&rmidi->open_mutex);
362 if (err < 0)
363 module_put(rmidi->card->module);
377 return err; 364 return err;
378} 365}
379 366
@@ -385,10 +372,13 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
385 unsigned short fflags; 372 unsigned short fflags;
386 int err; 373 int err;
387 struct snd_rawmidi *rmidi; 374 struct snd_rawmidi *rmidi;
388 struct snd_rawmidi_file *rawmidi_file; 375 struct snd_rawmidi_file *rawmidi_file = NULL;
389 wait_queue_t wait; 376 wait_queue_t wait;
390 struct snd_ctl_file *kctl; 377 struct snd_ctl_file *kctl;
391 378
379 if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK))
380 return -EINVAL; /* invalid combination */
381
392 if (maj == snd_major) { 382 if (maj == snd_major) {
393 rmidi = snd_lookup_minor_data(iminor(inode), 383 rmidi = snd_lookup_minor_data(iminor(inode),
394 SNDRV_DEVICE_TYPE_RAWMIDI); 384 SNDRV_DEVICE_TYPE_RAWMIDI);
@@ -402,24 +392,25 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
402 392
403 if (rmidi == NULL) 393 if (rmidi == NULL)
404 return -ENODEV; 394 return -ENODEV;
405 if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) 395
406 return -EINVAL; /* invalid combination */ 396 if (!try_module_get(rmidi->card->module))
397 return -ENXIO;
398
399 mutex_lock(&rmidi->open_mutex);
407 card = rmidi->card; 400 card = rmidi->card;
408 err = snd_card_file_add(card, file); 401 err = snd_card_file_add(card, file);
409 if (err < 0) 402 if (err < 0)
410 return -ENODEV; 403 goto __error_card;
411 fflags = snd_rawmidi_file_flags(file); 404 fflags = snd_rawmidi_file_flags(file);
412 if ((file->f_flags & O_APPEND) || maj == SOUND_MAJOR) /* OSS emul? */ 405 if ((file->f_flags & O_APPEND) || maj == SOUND_MAJOR) /* OSS emul? */
413 fflags |= SNDRV_RAWMIDI_LFLG_APPEND; 406 fflags |= SNDRV_RAWMIDI_LFLG_APPEND;
414 fflags |= SNDRV_RAWMIDI_LFLG_NOOPENLOCK;
415 rawmidi_file = kmalloc(sizeof(*rawmidi_file), GFP_KERNEL); 407 rawmidi_file = kmalloc(sizeof(*rawmidi_file), GFP_KERNEL);
416 if (rawmidi_file == NULL) { 408 if (rawmidi_file == NULL) {
417 snd_card_file_remove(card, file); 409 err = -ENOMEM;
418 return -ENOMEM; 410 goto __error;
419 } 411 }
420 init_waitqueue_entry(&wait, current); 412 init_waitqueue_entry(&wait, current);
421 add_wait_queue(&rmidi->open_wait, &wait); 413 add_wait_queue(&rmidi->open_wait, &wait);
422 mutex_lock(&rmidi->open_mutex);
423 while (1) { 414 while (1) {
424 subdevice = -1; 415 subdevice = -1;
425 read_lock(&card->ctl_files_rwlock); 416 read_lock(&card->ctl_files_rwlock);
@@ -431,8 +422,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
431 } 422 }
432 } 423 }
433 read_unlock(&card->ctl_files_rwlock); 424 read_unlock(&card->ctl_files_rwlock);
434 err = snd_rawmidi_kernel_open(rmidi->card, rmidi->device, 425 err = rawmidi_open_priv(rmidi, subdevice, fflags, rawmidi_file);
435 subdevice, fflags, rawmidi_file);
436 if (err >= 0) 426 if (err >= 0)
437 break; 427 break;
438 if (err == -EAGAIN) { 428 if (err == -EAGAIN) {
@@ -451,67 +441,89 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
451 break; 441 break;
452 } 442 }
453 } 443 }
444 remove_wait_queue(&rmidi->open_wait, &wait);
445 if (err < 0) {
446 kfree(rawmidi_file);
447 goto __error;
448 }
454#ifdef CONFIG_SND_OSSEMUL 449#ifdef CONFIG_SND_OSSEMUL
455 if (rawmidi_file->input && rawmidi_file->input->runtime) 450 if (rawmidi_file->input && rawmidi_file->input->runtime)
456 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR); 451 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR);
457 if (rawmidi_file->output && rawmidi_file->output->runtime) 452 if (rawmidi_file->output && rawmidi_file->output->runtime)
458 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR); 453 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR);
459#endif 454#endif
460 remove_wait_queue(&rmidi->open_wait, &wait); 455 file->private_data = rawmidi_file;
461 if (err >= 0) { 456 mutex_unlock(&rmidi->open_mutex);
462 file->private_data = rawmidi_file; 457 return 0;
463 } else { 458
464 snd_card_file_remove(card, file); 459 __error:
465 kfree(rawmidi_file); 460 snd_card_file_remove(card, file);
466 } 461 __error_card:
467 mutex_unlock(&rmidi->open_mutex); 462 mutex_unlock(&rmidi->open_mutex);
463 module_put(rmidi->card->module);
468 return err; 464 return err;
469} 465}
470 466
471int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) 467static void close_substream(struct snd_rawmidi *rmidi,
468 struct snd_rawmidi_substream *substream,
469 int cleanup)
472{ 470{
473 struct snd_rawmidi *rmidi; 471 rmidi->streams[substream->stream].substream_opened--;
474 struct snd_rawmidi_substream *substream; 472 if (--substream->use_count)
475 struct snd_rawmidi_runtime *runtime; 473 return;
476 474
477 if (snd_BUG_ON(!rfile)) 475 if (cleanup) {
478 return -ENXIO; 476 if (substream->stream == SNDRV_RAWMIDI_STREAM_INPUT)
479 rmidi = rfile->rmidi; 477 snd_rawmidi_input_trigger(substream, 0);
480 mutex_lock(&rmidi->open_mutex); 478 else {
481 if (rfile->input != NULL) {
482 substream = rfile->input;
483 rfile->input = NULL;
484 runtime = substream->runtime;
485 snd_rawmidi_input_trigger(substream, 0);
486 substream->ops->close(substream);
487 if (runtime->private_free != NULL)
488 runtime->private_free(substream);
489 snd_rawmidi_runtime_free(substream);
490 substream->opened = 0;
491 rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_opened--;
492 }
493 if (rfile->output != NULL) {
494 substream = rfile->output;
495 rfile->output = NULL;
496 if (--substream->use_count == 0) {
497 runtime = substream->runtime;
498 if (substream->active_sensing) { 479 if (substream->active_sensing) {
499 unsigned char buf = 0xfe; 480 unsigned char buf = 0xfe;
500 /* sending single active sensing message to shut the device up */ 481 /* sending single active sensing message
482 * to shut the device up
483 */
501 snd_rawmidi_kernel_write(substream, &buf, 1); 484 snd_rawmidi_kernel_write(substream, &buf, 1);
502 } 485 }
503 if (snd_rawmidi_drain_output(substream) == -ERESTARTSYS) 486 if (snd_rawmidi_drain_output(substream) == -ERESTARTSYS)
504 snd_rawmidi_output_trigger(substream, 0); 487 snd_rawmidi_output_trigger(substream, 0);
505 substream->ops->close(substream);
506 if (runtime->private_free != NULL)
507 runtime->private_free(substream);
508 snd_rawmidi_runtime_free(substream);
509 substream->opened = 0;
510 substream->append = 0;
511 } 488 }
512 rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--;
513 } 489 }
490 substream->ops->close(substream);
491 if (substream->runtime->private_free)
492 substream->runtime->private_free(substream);
493 snd_rawmidi_runtime_free(substream);
494 substream->opened = 0;
495 substream->append = 0;
496}
497
498static void rawmidi_release_priv(struct snd_rawmidi_file *rfile)
499{
500 struct snd_rawmidi *rmidi;
501
502 rmidi = rfile->rmidi;
503 mutex_lock(&rmidi->open_mutex);
504 if (rfile->input) {
505 close_substream(rmidi, rfile->input, 1);
506 rfile->input = NULL;
507 }
508 if (rfile->output) {
509 close_substream(rmidi, rfile->output, 1);
510 rfile->output = NULL;
511 }
512 rfile->rmidi = NULL;
514 mutex_unlock(&rmidi->open_mutex); 513 mutex_unlock(&rmidi->open_mutex);
514 wake_up(&rmidi->open_wait);
515}
516
517/* called from sound/core/seq/seq_midi.c */
518int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile)
519{
520 struct snd_rawmidi *rmidi;
521
522 if (snd_BUG_ON(!rfile))
523 return -ENXIO;
524
525 rmidi = rfile->rmidi;
526 rawmidi_release_priv(rfile);
515 module_put(rmidi->card->module); 527 module_put(rmidi->card->module);
516 return 0; 528 return 0;
517} 529}
@@ -520,15 +532,14 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file)
520{ 532{
521 struct snd_rawmidi_file *rfile; 533 struct snd_rawmidi_file *rfile;
522 struct snd_rawmidi *rmidi; 534 struct snd_rawmidi *rmidi;
523 int err;
524 535
525 rfile = file->private_data; 536 rfile = file->private_data;
526 err = snd_rawmidi_kernel_release(rfile);
527 rmidi = rfile->rmidi; 537 rmidi = rfile->rmidi;
528 wake_up(&rmidi->open_wait); 538 rawmidi_release_priv(rfile);
529 kfree(rfile); 539 kfree(rfile);
530 snd_card_file_remove(rmidi->card, file); 540 snd_card_file_remove(rmidi->card, file);
531 return err; 541 module_put(rmidi->card->module);
542 return 0;
532} 543}
533 544
534static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, 545static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
diff --git a/sound/core/seq/oss/seq_oss_device.h b/sound/core/seq/oss/seq_oss_device.h
index bf8d2b4cb15e..c0154a959d55 100644
--- a/sound/core/seq/oss/seq_oss_device.h
+++ b/sound/core/seq/oss/seq_oss_device.h
@@ -181,7 +181,7 @@ char *enabled_str(int bool);
181/* for debug */ 181/* for debug */
182#ifdef SNDRV_SEQ_OSS_DEBUG 182#ifdef SNDRV_SEQ_OSS_DEBUG
183extern int seq_oss_debug; 183extern int seq_oss_debug;
184#define debug_printk(x) do { if (seq_oss_debug > 0) snd_printk x; } while (0) 184#define debug_printk(x) do { if (seq_oss_debug > 0) snd_printd x; } while (0)
185#else 185#else
186#define debug_printk(x) /**/ 186#define debug_printk(x) /**/
187#endif 187#endif
diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c
index 38693f47c262..c956fe462569 100644
--- a/sound/core/seq/seq_compat.c
+++ b/sound/core/seq/seq_compat.c
@@ -48,12 +48,11 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned
48 struct snd_seq_port_info *data; 48 struct snd_seq_port_info *data;
49 mm_segment_t fs; 49 mm_segment_t fs;
50 50
51 data = kmalloc(sizeof(*data), GFP_KERNEL); 51 data = memdup_user(data32, sizeof(*data32));
52 if (! data) 52 if (IS_ERR(data))
53 return -ENOMEM; 53 return PTR_ERR(data);
54 54
55 if (copy_from_user(data, data32, sizeof(*data32)) || 55 if (get_user(data->flags, &data32->flags) ||
56 get_user(data->flags, &data32->flags) ||
57 get_user(data->time_queue, &data32->time_queue)) 56 get_user(data->time_queue, &data32->time_queue))
58 goto error; 57 goto error;
59 data->kernel = NULL; 58 data->kernel = NULL;
diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c
index 0101a8b99b73..29896ab23403 100644
--- a/sound/core/seq/seq_prioq.c
+++ b/sound/core/seq/seq_prioq.c
@@ -321,7 +321,8 @@ void snd_seq_prioq_leave(struct snd_seq_prioq * f, int client, int timestamp)
321 freeprev = cell; 321 freeprev = cell;
322 } else { 322 } else {
323#if 0 323#if 0
324 printk("type = %i, source = %i, dest = %i, client = %i\n", 324 printk(KERN_DEBUG "type = %i, source = %i, dest = %i, "
325 "client = %i\n",
325 cell->event.type, 326 cell->event.type,
326 cell->event.source.client, 327 cell->event.source.client,
327 cell->event.dest.client, 328 cell->event.dest.client,
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index d4564edd61d7..4e7ec2b49873 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -38,6 +38,10 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
38 if (! sgbuf) 38 if (! sgbuf)
39 return -EINVAL; 39 return -EINVAL;
40 40
41 if (dmab->area)
42 vunmap(dmab->area);
43 dmab->area = NULL;
44
41 tmpb.dev.type = SNDRV_DMA_TYPE_DEV; 45 tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
42 tmpb.dev.dev = sgbuf->dev; 46 tmpb.dev.dev = sgbuf->dev;
43 for (i = 0; i < sgbuf->pages; i++) { 47 for (i = 0; i < sgbuf->pages; i++) {
@@ -48,9 +52,6 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
48 tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT; 52 tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT;
49 snd_dma_free_pages(&tmpb); 53 snd_dma_free_pages(&tmpb);
50 } 54 }
51 if (dmab->area)
52 vunmap(dmab->area);
53 dmab->area = NULL;
54 55
55 kfree(sgbuf->table); 56 kfree(sgbuf->table);
56 kfree(sgbuf->page_table); 57 kfree(sgbuf->page_table);
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 796532081e81..8f8b17ac074d 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1395,13 +1395,10 @@ static int snd_timer_user_ginfo(struct file *file,
1395 struct list_head *p; 1395 struct list_head *p;
1396 int err = 0; 1396 int err = 0;
1397 1397
1398 ginfo = kmalloc(sizeof(*ginfo), GFP_KERNEL); 1398 ginfo = memdup_user(_ginfo, sizeof(*ginfo));
1399 if (! ginfo) 1399 if (IS_ERR(ginfo))
1400 return -ENOMEM; 1400 return PTR_ERR(ginfo);
1401 if (copy_from_user(ginfo, _ginfo, sizeof(*ginfo))) { 1401
1402 kfree(ginfo);
1403 return -EFAULT;
1404 }
1405 tid = ginfo->tid; 1402 tid = ginfo->tid;
1406 memset(ginfo, 0, sizeof(*ginfo)); 1403 memset(ginfo, 0, sizeof(*ginfo));
1407 ginfo->tid = tid; 1404 ginfo->tid = tid;
@@ -1825,13 +1822,9 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
1825static int snd_timer_user_fasync(int fd, struct file * file, int on) 1822static int snd_timer_user_fasync(int fd, struct file * file, int on)
1826{ 1823{
1827 struct snd_timer_user *tu; 1824 struct snd_timer_user *tu;
1828 int err;
1829 1825
1830 tu = file->private_data; 1826 tu = file->private_data;
1831 err = fasync_helper(fd, file, on, &tu->fasync); 1827 return fasync_helper(fd, file, on, &tu->fasync);
1832 if (err < 0)
1833 return err;
1834 return 0;
1835} 1828}
1836 1829
1837static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, 1830static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 4cc57f902e2c..257624bd1997 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -50,18 +50,38 @@ struct link_slave {
50 struct link_master *master; 50 struct link_master *master;
51 struct link_ctl_info info; 51 struct link_ctl_info info;
52 int vals[2]; /* current values */ 52 int vals[2]; /* current values */
53 unsigned int flags;
53 struct snd_kcontrol slave; /* the copy of original control entry */ 54 struct snd_kcontrol slave; /* the copy of original control entry */
54}; 55};
55 56
57static int slave_update(struct link_slave *slave)
58{
59 struct snd_ctl_elem_value *uctl;
60 int err, ch;
61
62 uctl = kmalloc(sizeof(*uctl), GFP_KERNEL);
63 if (!uctl)
64 return -ENOMEM;
65 uctl->id = slave->slave.id;
66 err = slave->slave.get(&slave->slave, uctl);
67 for (ch = 0; ch < slave->info.count; ch++)
68 slave->vals[ch] = uctl->value.integer.value[ch];
69 kfree(uctl);
70 return 0;
71}
72
56/* get the slave ctl info and save the initial values */ 73/* get the slave ctl info and save the initial values */
57static int slave_init(struct link_slave *slave) 74static int slave_init(struct link_slave *slave)
58{ 75{
59 struct snd_ctl_elem_info *uinfo; 76 struct snd_ctl_elem_info *uinfo;
60 struct snd_ctl_elem_value *uctl; 77 int err;
61 int err, ch;
62 78
63 if (slave->info.count) 79 if (slave->info.count) {
64 return 0; /* already initialized */ 80 /* already initialized */
81 if (slave->flags & SND_CTL_SLAVE_NEED_UPDATE)
82 return slave_update(slave);
83 return 0;
84 }
65 85
66 uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL); 86 uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL);
67 if (!uinfo) 87 if (!uinfo)
@@ -85,15 +105,7 @@ static int slave_init(struct link_slave *slave)
85 slave->info.max_val = uinfo->value.integer.max; 105 slave->info.max_val = uinfo->value.integer.max;
86 kfree(uinfo); 106 kfree(uinfo);
87 107
88 uctl = kmalloc(sizeof(*uctl), GFP_KERNEL); 108 return slave_update(slave);
89 if (!uctl)
90 return -ENOMEM;
91 uctl->id = slave->slave.id;
92 err = slave->slave.get(&slave->slave, uctl);
93 for (ch = 0; ch < slave->info.count; ch++)
94 slave->vals[ch] = uctl->value.integer.value[ch];
95 kfree(uctl);
96 return 0;
97} 109}
98 110
99/* initialize master volume */ 111/* initialize master volume */
@@ -229,7 +241,8 @@ static void slave_free(struct snd_kcontrol *kcontrol)
229 * - logarithmic volume control (dB level), no linear volume 241 * - logarithmic volume control (dB level), no linear volume
230 * - master can only attenuate the volume, no gain 242 * - master can only attenuate the volume, no gain
231 */ 243 */
232int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave) 244int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
245 unsigned int flags)
233{ 246{
234 struct link_master *master_link = snd_kcontrol_chip(master); 247 struct link_master *master_link = snd_kcontrol_chip(master);
235 struct link_slave *srec; 248 struct link_slave *srec;
@@ -241,6 +254,7 @@ int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
241 srec->slave = *slave; 254 srec->slave = *slave;
242 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd)); 255 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
243 srec->master = master_link; 256 srec->master = master_link;
257 srec->flags = flags;
244 258
245 /* override callbacks */ 259 /* override callbacks */
246 slave->info = slave_info; 260 slave->info = slave_info;
@@ -254,8 +268,7 @@ int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
254 list_add_tail(&srec->list, &master_link->slaves); 268 list_add_tail(&srec->list, &master_link->slaves);
255 return 0; 269 return 0;
256} 270}
257 271EXPORT_SYMBOL(_snd_ctl_add_slave);
258EXPORT_SYMBOL(snd_ctl_add_slave);
259 272
260/* 273/*
261 * ctl callbacks for master controls 274 * ctl callbacks for master controls
@@ -327,8 +340,20 @@ static void master_free(struct snd_kcontrol *kcontrol)
327} 340}
328 341
329 342
330/* 343/**
331 * Create a virtual master control with the given name 344 * snd_ctl_make_virtual_master - Create a virtual master control
345 * @name: name string of the control element to create
346 * @tlv: optional TLV int array for dB information
347 *
348 * Creates a virtual matster control with the given name string.
349 * Returns the created control element, or NULL for errors (ENOMEM).
350 *
351 * After creating a vmaster element, you can add the slave controls
352 * via snd_ctl_add_slave() or snd_ctl_add_slave_uncached().
353 *
354 * The optional argument @tlv can be used to specify the TLV information
355 * for dB scale of the master control. It should be a single element
356 * with #SNDRV_CTL_TLVT_DB_SCALE type, and should be the max 0dB.
332 */ 357 */
333struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, 358struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
334 const unsigned int *tlv) 359 const unsigned int *tlv)
@@ -367,5 +392,4 @@ struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
367 392
368 return kctl; 393 return kctl;
369} 394}
370
371EXPORT_SYMBOL(snd_ctl_make_virtual_master); 395EXPORT_SYMBOL(snd_ctl_make_virtual_master);
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 0bcf14640fde..84714a65e5c8 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -33,7 +33,7 @@ if SND_DRIVERS
33 33
34config SND_PCSP 34config SND_PCSP
35 tristate "PC-Speaker support (READ HELP!)" 35 tristate "PC-Speaker support (READ HELP!)"
36 depends on PCSPKR_PLATFORM && X86_PC && HIGH_RES_TIMERS 36 depends on PCSPKR_PLATFORM && X86 && HIGH_RES_TIMERS
37 depends on INPUT 37 depends on INPUT
38 depends on EXPERIMENTAL 38 depends on EXPERIMENTAL
39 select SND_PCM 39 select SND_PCM
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index c3e9833dcfd9..2f8f295d6b0c 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -303,8 +303,10 @@ static void snd_mtpav_output_port_write(struct mtpav *mtp_card,
303 303
304 snd_mtpav_send_byte(mtp_card, 0xf5); 304 snd_mtpav_send_byte(mtp_card, 0xf5);
305 snd_mtpav_send_byte(mtp_card, portp->hwport); 305 snd_mtpav_send_byte(mtp_card, portp->hwport);
306 //snd_printk("new outport: 0x%x\n", (unsigned int) portp->hwport); 306 /*
307 307 snd_printk(KERN_DEBUG "new outport: 0x%x\n",
308 (unsigned int) portp->hwport);
309 */
308 if (!(outbyte & 0x80) && portp->running_status) 310 if (!(outbyte & 0x80) && portp->running_status)
309 snd_mtpav_send_byte(mtp_card, portp->running_status); 311 snd_mtpav_send_byte(mtp_card, portp->running_status);
310 } 312 }
@@ -540,7 +542,7 @@ static void snd_mtpav_read_bytes(struct mtpav *mcrd)
540 542
541 u8 sbyt = snd_mtpav_getreg(mcrd, SREG); 543 u8 sbyt = snd_mtpav_getreg(mcrd, SREG);
542 544
543 //printk("snd_mtpav_read_bytes() sbyt: 0x%x\n", sbyt); 545 /* printk(KERN_DEBUG "snd_mtpav_read_bytes() sbyt: 0x%x\n", sbyt); */
544 546
545 if (!(sbyt & SIGS_BYTE)) 547 if (!(sbyt & SIGS_BYTE))
546 return; 548 return;
@@ -585,12 +587,12 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id)
585static int __devinit snd_mtpav_get_ISA(struct mtpav * mcard) 587static int __devinit snd_mtpav_get_ISA(struct mtpav * mcard)
586{ 588{
587 if ((mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI")) == NULL) { 589 if ((mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI")) == NULL) {
588 snd_printk("MTVAP port 0x%lx is busy\n", port); 590 snd_printk(KERN_ERR "MTVAP port 0x%lx is busy\n", port);
589 return -EBUSY; 591 return -EBUSY;
590 } 592 }
591 mcard->port = port; 593 mcard->port = port;
592 if (request_irq(irq, snd_mtpav_irqh, IRQF_DISABLED, "MOTU MTPAV", mcard)) { 594 if (request_irq(irq, snd_mtpav_irqh, IRQF_DISABLED, "MOTU MTPAV", mcard)) {
593 snd_printk("MTVAP IRQ %d busy\n", irq); 595 snd_printk(KERN_ERR "MTVAP IRQ %d busy\n", irq);
594 return -EBUSY; 596 return -EBUSY;
595 } 597 }
596 mcard->irq = irq; 598 mcard->irq = irq;
@@ -706,7 +708,6 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev)
706 mtp_card->card = card; 708 mtp_card->card = card;
707 mtp_card->irq = -1; 709 mtp_card->irq = -1;
708 mtp_card->share_irq = 0; 710 mtp_card->share_irq = 0;
709 mtp_card->inmidiport = 0xffffffff;
710 mtp_card->inmidistate = 0; 711 mtp_card->inmidistate = 0;
711 mtp_card->outmidihwport = 0xffffffff; 712 mtp_card->outmidihwport = 0xffffffff;
712 init_timer(&mtp_card->timer); 713 init_timer(&mtp_card->timer);
@@ -719,6 +720,8 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev)
719 if (err < 0) 720 if (err < 0)
720 goto __error; 721 goto __error;
721 722
723 mtp_card->inmidiport = mtp_card->num_ports + MTPAV_PIDX_BROADCAST;
724
722 err = snd_mtpav_get_ISA(mtp_card); 725 err = snd_mtpav_get_ISA(mtp_card);
723 if (err < 0) 726 if (err < 0)
724 goto __error; 727 goto __error;
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index 33d9db782e07..9284829bf927 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -1015,7 +1015,7 @@ static int __devinit snd_mts64_probe(struct platform_device *pdev)
1015 goto __err; 1015 goto __err;
1016 } 1016 }
1017 1017
1018 snd_printk("ESI Miditerminal 4140 on 0x%lx\n", p->base); 1018 snd_printk(KERN_INFO "ESI Miditerminal 4140 on 0x%lx\n", p->base);
1019 return 0; 1019 return 0;
1020 1020
1021__err: 1021__err:
diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c
index 780582340fef..6e31e46ca393 100644
--- a/sound/drivers/opl3/opl3_lib.c
+++ b/sound/drivers/opl3/opl3_lib.c
@@ -302,7 +302,7 @@ void snd_opl3_interrupt(struct snd_hwdep * hw)
302 opl3 = hw->private_data; 302 opl3 = hw->private_data;
303 status = inb(opl3->l_port); 303 status = inb(opl3->l_port);
304#if 0 304#if 0
305 snd_printk("AdLib IRQ status = 0x%x\n", status); 305 snd_printk(KERN_DEBUG "AdLib IRQ status = 0x%x\n", status);
306#endif 306#endif
307 if (!(status & 0x80)) 307 if (!(status & 0x80))
308 return; 308 return;
diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c
index 16feafa2c51e..6e7d09ae0e82 100644
--- a/sound/drivers/opl3/opl3_midi.c
+++ b/sound/drivers/opl3/opl3_midi.c
@@ -125,7 +125,7 @@ static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) {
125 int i; 125 int i;
126 char *str = "x.24"; 126 char *str = "x.24";
127 127
128 printk("time %.5i: %s [%.2i]: ", opl3->use_time, s, voice); 128 printk(KERN_DEBUG "time %.5i: %s [%.2i]: ", opl3->use_time, s, voice);
129 for (i = 0; i < opl3->max_voices; i++) 129 for (i = 0; i < opl3->max_voices; i++)
130 printk("%c", *(str + opl3->voices[i].state + 1)); 130 printk("%c", *(str + opl3->voices[i].state + 1));
131 printk("\n"); 131 printk("\n");
@@ -218,7 +218,7 @@ static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op,
218 for (i = 0; i < END; i++) { 218 for (i = 0; i < END; i++) {
219 if (best[i].voice >= 0) { 219 if (best[i].voice >= 0) {
220#ifdef DEBUG_ALLOC 220#ifdef DEBUG_ALLOC
221 printk("%s %iop allocation on voice %i\n", 221 printk(KERN_DEBUG "%s %iop allocation on voice %i\n",
222 alloc_type[i], instr_4op ? 4 : 2, 222 alloc_type[i], instr_4op ? 4 : 2,
223 best[i].voice); 223 best[i].voice);
224#endif 224#endif
@@ -317,7 +317,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
317 opl3 = p; 317 opl3 = p;
318 318
319#ifdef DEBUG_MIDI 319#ifdef DEBUG_MIDI
320 snd_printk("Note on, ch %i, inst %i, note %i, vel %i\n", 320 snd_printk(KERN_DEBUG "Note on, ch %i, inst %i, note %i, vel %i\n",
321 chan->number, chan->midi_program, note, vel); 321 chan->number, chan->midi_program, note, vel);
322#endif 322#endif
323 323
@@ -372,7 +372,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
372 return; 372 return;
373 } 373 }
374#ifdef DEBUG_MIDI 374#ifdef DEBUG_MIDI
375 snd_printk(" --> OPL%i instrument: %s\n", 375 snd_printk(KERN_DEBUG " --> OPL%i instrument: %s\n",
376 instr_4op ? 3 : 2, patch->name); 376 instr_4op ? 3 : 2, patch->name);
377#endif 377#endif
378 /* in SYNTH mode, application takes care of voices */ 378 /* in SYNTH mode, application takes care of voices */
@@ -431,7 +431,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
431 } 431 }
432 432
433#ifdef DEBUG_MIDI 433#ifdef DEBUG_MIDI
434 snd_printk(" --> setting OPL3 connection: 0x%x\n", 434 snd_printk(KERN_DEBUG " --> setting OPL3 connection: 0x%x\n",
435 opl3->connection_reg); 435 opl3->connection_reg);
436#endif 436#endif
437 /* 437 /*
@@ -466,7 +466,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
466 /* Program the FM voice characteristics */ 466 /* Program the FM voice characteristics */
467 for (i = 0; i < (instr_4op ? 4 : 2); i++) { 467 for (i = 0; i < (instr_4op ? 4 : 2); i++) {
468#ifdef DEBUG_MIDI 468#ifdef DEBUG_MIDI
469 snd_printk(" --> programming operator %i\n", i); 469 snd_printk(KERN_DEBUG " --> programming operator %i\n", i);
470#endif 470#endif
471 op_offset = snd_opl3_regmap[voice_offset][i]; 471 op_offset = snd_opl3_regmap[voice_offset][i];
472 472
@@ -546,7 +546,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
546 blocknum |= OPL3_KEYON_BIT; 546 blocknum |= OPL3_KEYON_BIT;
547 547
548#ifdef DEBUG_MIDI 548#ifdef DEBUG_MIDI
549 snd_printk(" --> trigger voice %i\n", voice); 549 snd_printk(KERN_DEBUG " --> trigger voice %i\n", voice);
550#endif 550#endif
551 /* Set OPL3 KEYON_BLOCK register of requested voice */ 551 /* Set OPL3 KEYON_BLOCK register of requested voice */
552 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset); 552 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
@@ -602,7 +602,7 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
602 prg = extra_prg - 1; 602 prg = extra_prg - 1;
603 } 603 }
604#ifdef DEBUG_MIDI 604#ifdef DEBUG_MIDI
605 snd_printk(" *** allocating extra program\n"); 605 snd_printk(KERN_DEBUG " *** allocating extra program\n");
606#endif 606#endif
607 goto __extra_prg; 607 goto __extra_prg;
608 } 608 }
@@ -633,7 +633,7 @@ static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
633 633
634 /* kill voice */ 634 /* kill voice */
635#ifdef DEBUG_MIDI 635#ifdef DEBUG_MIDI
636 snd_printk(" --> kill voice %i\n", voice); 636 snd_printk(KERN_DEBUG " --> kill voice %i\n", voice);
637#endif 637#endif
638 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset); 638 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
639 /* clear Key ON bit */ 639 /* clear Key ON bit */
@@ -670,7 +670,7 @@ void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan
670 opl3 = p; 670 opl3 = p;
671 671
672#ifdef DEBUG_MIDI 672#ifdef DEBUG_MIDI
673 snd_printk("Note off, ch %i, inst %i, note %i\n", 673 snd_printk(KERN_DEBUG "Note off, ch %i, inst %i, note %i\n",
674 chan->number, chan->midi_program, note); 674 chan->number, chan->midi_program, note);
675#endif 675#endif
676 676
@@ -709,7 +709,7 @@ void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *cha
709 709
710 opl3 = p; 710 opl3 = p;
711#ifdef DEBUG_MIDI 711#ifdef DEBUG_MIDI
712 snd_printk("Key pressure, ch#: %i, inst#: %i\n", 712 snd_printk(KERN_DEBUG "Key pressure, ch#: %i, inst#: %i\n",
713 chan->number, chan->midi_program); 713 chan->number, chan->midi_program);
714#endif 714#endif
715} 715}
@@ -723,7 +723,7 @@ void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan)
723 723
724 opl3 = p; 724 opl3 = p;
725#ifdef DEBUG_MIDI 725#ifdef DEBUG_MIDI
726 snd_printk("Terminate note, ch#: %i, inst#: %i\n", 726 snd_printk(KERN_DEBUG "Terminate note, ch#: %i, inst#: %i\n",
727 chan->number, chan->midi_program); 727 chan->number, chan->midi_program);
728#endif 728#endif
729} 729}
@@ -812,7 +812,7 @@ void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan)
812 812
813 opl3 = p; 813 opl3 = p;
814#ifdef DEBUG_MIDI 814#ifdef DEBUG_MIDI
815 snd_printk("Controller, TYPE = %i, ch#: %i, inst#: %i\n", 815 snd_printk(KERN_DEBUG "Controller, TYPE = %i, ch#: %i, inst#: %i\n",
816 type, chan->number, chan->midi_program); 816 type, chan->number, chan->midi_program);
817#endif 817#endif
818 818
@@ -849,7 +849,7 @@ void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan,
849 849
850 opl3 = p; 850 opl3 = p;
851#ifdef DEBUG_MIDI 851#ifdef DEBUG_MIDI
852 snd_printk("NRPN, ch#: %i, inst#: %i\n", 852 snd_printk(KERN_DEBUG "NRPN, ch#: %i, inst#: %i\n",
853 chan->number, chan->midi_program); 853 chan->number, chan->midi_program);
854#endif 854#endif
855} 855}
@@ -864,6 +864,6 @@ void snd_opl3_sysex(void *p, unsigned char *buf, int len,
864 864
865 opl3 = p; 865 opl3 = p;
866#ifdef DEBUG_MIDI 866#ifdef DEBUG_MIDI
867 snd_printk("SYSEX\n"); 867 snd_printk(KERN_DEBUG "SYSEX\n");
868#endif 868#endif
869} 869}
diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c
index 9a2271dc046a..a54b1dc5cc78 100644
--- a/sound/drivers/opl3/opl3_oss.c
+++ b/sound/drivers/opl3/opl3_oss.c
@@ -220,14 +220,14 @@ static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
220 return -EINVAL; 220 return -EINVAL;
221 221
222 if (count < (int)sizeof(sbi)) { 222 if (count < (int)sizeof(sbi)) {
223 snd_printk("FM Error: Patch record too short\n"); 223 snd_printk(KERN_ERR "FM Error: Patch record too short\n");
224 return -EINVAL; 224 return -EINVAL;
225 } 225 }
226 if (copy_from_user(&sbi, buf, sizeof(sbi))) 226 if (copy_from_user(&sbi, buf, sizeof(sbi)))
227 return -EFAULT; 227 return -EFAULT;
228 228
229 if (sbi.channel < 0 || sbi.channel >= SBFM_MAXINSTR) { 229 if (sbi.channel < 0 || sbi.channel >= SBFM_MAXINSTR) {
230 snd_printk("FM Error: Invalid instrument number %d\n", 230 snd_printk(KERN_ERR "FM Error: Invalid instrument number %d\n",
231 sbi.channel); 231 sbi.channel);
232 return -EINVAL; 232 return -EINVAL;
233 } 233 }
@@ -254,7 +254,9 @@ static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd,
254 opl3 = arg->private_data; 254 opl3 = arg->private_data;
255 switch (cmd) { 255 switch (cmd) {
256 case SNDCTL_FM_LOAD_INSTR: 256 case SNDCTL_FM_LOAD_INSTR:
257 snd_printk("OPL3: Obsolete ioctl(SNDCTL_FM_LOAD_INSTR) used. Fix the program.\n"); 257 snd_printk(KERN_ERR "OPL3: "
258 "Obsolete ioctl(SNDCTL_FM_LOAD_INSTR) used. "
259 "Fix the program.\n");
258 return -EINVAL; 260 return -EINVAL;
259 261
260 case SNDCTL_SYNTH_MEMAVL: 262 case SNDCTL_SYNTH_MEMAVL:
diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
index 962bb9c8b9c8..6d57b6441dec 100644
--- a/sound/drivers/opl3/opl3_synth.c
+++ b/sound/drivers/opl3/opl3_synth.c
@@ -168,7 +168,7 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
168 168
169#ifdef CONFIG_SND_DEBUG 169#ifdef CONFIG_SND_DEBUG
170 default: 170 default:
171 snd_printk("unknown IOCTL: 0x%x\n", cmd); 171 snd_printk(KERN_WARNING "unknown IOCTL: 0x%x\n", cmd);
172#endif 172#endif
173 } 173 }
174 return -ENOTTY; 174 return -ENOTTY;
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index aa2ae07a76d5..b60cef257b58 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -57,7 +57,7 @@ static int __devinit snd_pcsp_create(struct snd_card *card)
57 else 57 else
58 min_div = MAX_DIV; 58 min_div = MAX_DIV;
59#if PCSP_DEBUG 59#if PCSP_DEBUG
60 printk("PCSP: lpj=%li, min_div=%i, res=%li\n", 60 printk(KERN_DEBUG "PCSP: lpj=%li, min_div=%i, res=%li\n",
61 loops_per_jiffy, min_div, tp.tv_nsec); 61 loops_per_jiffy, min_div, tp.tv_nsec);
62#endif 62#endif
63 63
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 891d081e4825..b2b6d50c9425 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -241,7 +241,8 @@ static void snd_uart16550_io_loop(struct snd_uart16550 * uart)
241 snd_rawmidi_receive(uart->midi_input[substream], &c, 1); 241 snd_rawmidi_receive(uart->midi_input[substream], &c, 1);
242 242
243 if (status & UART_LSR_OE) 243 if (status & UART_LSR_OE)
244 snd_printk("%s: Overrun on device at 0x%lx\n", 244 snd_printk(KERN_WARNING
245 "%s: Overrun on device at 0x%lx\n",
245 uart->rmidi->name, uart->base); 246 uart->rmidi->name, uart->base);
246 } 247 }
247 248
@@ -636,7 +637,8 @@ static int snd_uart16550_output_byte(struct snd_uart16550 *uart,
636 } 637 }
637 } else { 638 } else {
638 if (!snd_uart16550_write_buffer(uart, midi_byte)) { 639 if (!snd_uart16550_write_buffer(uart, midi_byte)) {
639 snd_printk("%s: Buffer overrun on device at 0x%lx\n", 640 snd_printk(KERN_WARNING
641 "%s: Buffer overrun on device at 0x%lx\n",
640 uart->rmidi->name, uart->base); 642 uart->rmidi->name, uart->base);
641 return 0; 643 return 0;
642 } 644 }
@@ -815,7 +817,8 @@ static int __devinit snd_uart16550_create(struct snd_card *card,
815 if (irq >= 0 && irq != SNDRV_AUTO_IRQ) { 817 if (irq >= 0 && irq != SNDRV_AUTO_IRQ) {
816 if (request_irq(irq, snd_uart16550_interrupt, 818 if (request_irq(irq, snd_uart16550_interrupt,
817 IRQF_DISABLED, "Serial MIDI", uart)) { 819 IRQF_DISABLED, "Serial MIDI", uart)) {
818 snd_printk("irq %d busy. Using Polling.\n", irq); 820 snd_printk(KERN_WARNING
821 "irq %d busy. Using Polling.\n", irq);
819 } else { 822 } else {
820 uart->irq = irq; 823 uart->irq = irq;
821 } 824 }
@@ -919,19 +922,22 @@ static int __devinit snd_serial_probe(struct platform_device *devptr)
919 case SNDRV_SERIAL_GENERIC: 922 case SNDRV_SERIAL_GENERIC:
920 break; 923 break;
921 default: 924 default:
922 snd_printk("Adaptor type is out of range 0-%d (%d)\n", 925 snd_printk(KERN_ERR
926 "Adaptor type is out of range 0-%d (%d)\n",
923 SNDRV_SERIAL_MAX_ADAPTOR, adaptor[dev]); 927 SNDRV_SERIAL_MAX_ADAPTOR, adaptor[dev]);
924 return -ENODEV; 928 return -ENODEV;
925 } 929 }
926 930
927 if (outs[dev] < 1 || outs[dev] > SNDRV_SERIAL_MAX_OUTS) { 931 if (outs[dev] < 1 || outs[dev] > SNDRV_SERIAL_MAX_OUTS) {
928 snd_printk("Count of outputs is out of range 1-%d (%d)\n", 932 snd_printk(KERN_ERR
933 "Count of outputs is out of range 1-%d (%d)\n",
929 SNDRV_SERIAL_MAX_OUTS, outs[dev]); 934 SNDRV_SERIAL_MAX_OUTS, outs[dev]);
930 return -ENODEV; 935 return -ENODEV;
931 } 936 }
932 937
933 if (ins[dev] < 1 || ins[dev] > SNDRV_SERIAL_MAX_INS) { 938 if (ins[dev] < 1 || ins[dev] > SNDRV_SERIAL_MAX_INS) {
934 snd_printk("Count of inputs is out of range 1-%d (%d)\n", 939 snd_printk(KERN_ERR
940 "Count of inputs is out of range 1-%d (%d)\n",
935 SNDRV_SERIAL_MAX_INS, ins[dev]); 941 SNDRV_SERIAL_MAX_INS, ins[dev]);
936 return -ENODEV; 942 return -ENODEV;
937 } 943 }
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
index 6f48711818f3..0e631c3221e3 100644
--- a/sound/drivers/virmidi.c
+++ b/sound/drivers/virmidi.c
@@ -98,7 +98,9 @@ static int __devinit snd_virmidi_probe(struct platform_device *devptr)
98 vmidi->card = card; 98 vmidi->card = card;
99 99
100 if (midi_devs[dev] > MAX_MIDI_DEVICES) { 100 if (midi_devs[dev] > MAX_MIDI_DEVICES) {
101 snd_printk("too much midi devices for virmidi %d: force to use %d\n", dev, MAX_MIDI_DEVICES); 101 snd_printk(KERN_WARNING
102 "too much midi devices for virmidi %d: "
103 "force to use %d\n", dev, MAX_MIDI_DEVICES);
102 midi_devs[dev] = MAX_MIDI_DEVICES; 104 midi_devs[dev] = MAX_MIDI_DEVICES;
103 } 105 }
104 for (idx = 0; idx < midi_devs[dev]; idx++) { 106 for (idx = 0; idx < midi_devs[dev]; idx++) {
diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c
index 14e3354be43a..19c6e376c7c7 100644
--- a/sound/drivers/vx/vx_core.c
+++ b/sound/drivers/vx/vx_core.c
@@ -688,7 +688,8 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
688 image = dsp->data + i; 688 image = dsp->data + i;
689 /* Wait DSP ready for a new read */ 689 /* Wait DSP ready for a new read */
690 if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) { 690 if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) {
691 printk("dsp loading error at position %d\n", i); 691 printk(KERN_ERR
692 "dsp loading error at position %d\n", i);
692 return err; 693 return err;
693 } 694 }
694 cptr = image; 695 cptr = image;
diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c
index 8d6362e2d4c9..46df8817c18f 100644
--- a/sound/drivers/vx/vx_hwdep.c
+++ b/sound/drivers/vx/vx_hwdep.c
@@ -119,16 +119,6 @@ void snd_vx_free_firmware(struct vx_core *chip)
119 119
120#else /* old style firmware loading */ 120#else /* old style firmware loading */
121 121
122static int vx_hwdep_open(struct snd_hwdep *hw, struct file *file)
123{
124 return 0;
125}
126
127static int vx_hwdep_release(struct snd_hwdep *hw, struct file *file)
128{
129 return 0;
130}
131
132static int vx_hwdep_dsp_status(struct snd_hwdep *hw, 122static int vx_hwdep_dsp_status(struct snd_hwdep *hw,
133 struct snd_hwdep_dsp_status *info) 123 struct snd_hwdep_dsp_status *info)
134{ 124{
@@ -243,8 +233,6 @@ int snd_vx_setup_firmware(struct vx_core *chip)
243 233
244 hw->iface = SNDRV_HWDEP_IFACE_VX; 234 hw->iface = SNDRV_HWDEP_IFACE_VX;
245 hw->private_data = chip; 235 hw->private_data = chip;
246 hw->ops.open = vx_hwdep_open;
247 hw->ops.release = vx_hwdep_release;
248 hw->ops.dsp_status = vx_hwdep_dsp_status; 236 hw->ops.dsp_status = vx_hwdep_dsp_status;
249 hw->ops.dsp_load = vx_hwdep_dsp_load; 237 hw->ops.dsp_load = vx_hwdep_dsp_load;
250 hw->exclusive = 1; 238 hw->exclusive = 1;
diff --git a/sound/drivers/vx/vx_uer.c b/sound/drivers/vx/vx_uer.c
index 0e1ba9b47904..b0560fec6bba 100644
--- a/sound/drivers/vx/vx_uer.c
+++ b/sound/drivers/vx/vx_uer.c
@@ -103,7 +103,7 @@ static void vx_write_one_cbit(struct vx_core *chip, int index, int val)
103 * returns the frequency of UER, or 0 if not sync, 103 * returns the frequency of UER, or 0 if not sync,
104 * or a negative error code. 104 * or a negative error code.
105 */ 105 */
106static int vx_read_uer_status(struct vx_core *chip, int *mode) 106static int vx_read_uer_status(struct vx_core *chip, unsigned int *mode)
107{ 107{
108 int val, freq; 108 int val, freq;
109 109
diff --git a/sound/i2c/Makefile b/sound/i2c/Makefile
index 37970666a453..36879bf88700 100644
--- a/sound/i2c/Makefile
+++ b/sound/i2c/Makefile
@@ -7,8 +7,6 @@ snd-i2c-objs := i2c.o
7snd-cs8427-objs := cs8427.o 7snd-cs8427-objs := cs8427.o
8snd-tea6330t-objs := tea6330t.o 8snd-tea6330t-objs := tea6330t.o
9 9
10obj-$(CONFIG_L3) += l3/
11
12obj-$(CONFIG_SND) += other/ 10obj-$(CONFIG_SND) += other/
13 11
14# Toplevel Module Dependency 12# Toplevel Module Dependency
diff --git a/sound/i2c/l3/Makefile b/sound/i2c/l3/Makefile
deleted file mode 100644
index 49455b8dcc04..000000000000
--- a/sound/i2c/l3/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for ALSA
3#
4
5snd-uda1341-objs := uda1341.o
6
7# Module Dependency
8obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-uda1341.o
diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c
deleted file mode 100644
index 9840eb43648d..000000000000
--- a/sound/i2c/l3/uda1341.c
+++ /dev/null
@@ -1,935 +0,0 @@
1/*
2 * Philips UDA1341 mixer device driver
3 * Copyright (c) 2002 Tomas Kasparek <tomas.kasparek@seznam.cz>
4 *
5 * Portions are Copyright (C) 2000 Lernout & Hauspie Speech Products, N.V.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License.
9 *
10 * History:
11 *
12 * 2002-03-13 Tomas Kasparek initial release - based on uda1341.c from OSS
13 * 2002-03-28 Tomas Kasparek basic mixer is working (volume, bass, treble)
14 * 2002-03-30 Tomas Kasparek proc filesystem support, complete mixer and DSP
15 * features support
16 * 2002-04-12 Tomas Kasparek proc interface update, code cleanup
17 * 2002-05-12 Tomas Kasparek another code cleanup
18 */
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/types.h>
23#include <linux/slab.h>
24#include <linux/errno.h>
25#include <linux/ioctl.h>
26
27#include <asm/uaccess.h>
28
29#include <sound/core.h>
30#include <sound/control.h>
31#include <sound/initval.h>
32#include <sound/info.h>
33
34#include <linux/l3/l3.h>
35
36#include <sound/uda1341.h>
37
38/* {{{ HW regs definition */
39
40#define STAT0 0x00
41#define STAT1 0x80
42#define STAT_MASK 0x80
43
44#define DATA0_0 0x00
45#define DATA0_1 0x40
46#define DATA0_2 0x80
47#define DATA_MASK 0xc0
48
49#define IS_DATA0(x) ((x) >= data0_0 && (x) <= data0_2)
50#define IS_DATA1(x) ((x) == data1)
51#define IS_STATUS(x) ((x) == stat0 || (x) == stat1)
52#define IS_EXTEND(x) ((x) >= ext0 && (x) <= ext6)
53
54/* }}} */
55
56
57static const char *peak_names[] = {
58 "before",
59 "after",
60};
61
62static const char *filter_names[] = {
63 "flat",
64 "min",
65 "min",
66 "max",
67};
68
69static const char *mixer_names[] = {
70 "double differential",
71 "input channel 1 (line in)",
72 "input channel 2 (microphone)",
73 "digital mixer",
74};
75
76static const char *deemp_names[] = {
77 "none",
78 "32 kHz",
79 "44.1 kHz",
80 "48 kHz",
81};
82
83enum uda1341_regs_names {
84 stat0,
85 stat1,
86 data0_0,
87 data0_1,
88 data0_2,
89 data1,
90 ext0,
91 ext1,
92 ext2,
93 empty,
94 ext4,
95 ext5,
96 ext6,
97 uda1341_reg_last,
98};
99
100static const char *uda1341_reg_names[] = {
101 "stat 0 ",
102 "stat 1 ",
103 "data 00",
104 "data 01",
105 "data 02",
106 "data 1 ",
107 "ext 0",
108 "ext 1",
109 "ext 2",
110 "empty",
111 "ext 4",
112 "ext 5",
113 "ext 6",
114};
115
116static const int uda1341_enum_items[] = {
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 2, //peak - before/after
119 4, //deemp - none/32/44.1/48
120 0,
121 4, //filter - flat/min/min/max
122 0, 0, 0,
123 4, //mixer - differ/line/mic/mixer
124 0, 0, 0, 0, 0,
125};
126
127static const char ** uda1341_enum_names[] = {
128 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
129 peak_names, //peak - before/after
130 deemp_names, //deemp - none/32/44.1/48
131 NULL,
132 filter_names, //filter - flat/min/min/max
133 NULL, NULL, NULL,
134 mixer_names, //mixer - differ/line/mic/mixer
135 NULL, NULL, NULL, NULL, NULL,
136};
137
138typedef int uda1341_cfg[CMD_LAST];
139
140struct uda1341 {
141 int (*write) (struct l3_client *uda1341, unsigned short reg, unsigned short val);
142 int (*read) (struct l3_client *uda1341, unsigned short reg);
143 unsigned char regs[uda1341_reg_last];
144 int active;
145 spinlock_t reg_lock;
146 struct snd_card *card;
147 uda1341_cfg cfg;
148#ifdef CONFIG_PM
149 unsigned char suspend_regs[uda1341_reg_last];
150 uda1341_cfg suspend_cfg;
151#endif
152};
153
154/* transfer 8bit integer into string with binary representation */
155static void int2str_bin8(uint8_t val, char *buf)
156{
157 const int size = sizeof(val) * 8;
158 int i;
159
160 for (i= 0; i < size; i++){
161 *(buf++) = (val >> (size - 1)) ? '1' : '0';
162 val <<= 1;
163 }
164 *buf = '\0'; //end the string with zero
165}
166
167/* {{{ HW manipulation routines */
168
169static int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned short val)
170{
171 struct uda1341 *uda = clnt->driver_data;
172 unsigned char buf[2] = { 0xc0, 0xe0 }; // for EXT addressing
173 int err = 0;
174
175 uda->regs[reg] = val;
176
177 if (uda->active) {
178 if (IS_DATA0(reg)) {
179 err = l3_write(clnt, UDA1341_DATA0, (const unsigned char *)&val, 1);
180 } else if (IS_DATA1(reg)) {
181 err = l3_write(clnt, UDA1341_DATA1, (const unsigned char *)&val, 1);
182 } else if (IS_STATUS(reg)) {
183 err = l3_write(clnt, UDA1341_STATUS, (const unsigned char *)&val, 1);
184 } else if (IS_EXTEND(reg)) {
185 buf[0] |= (reg - ext0) & 0x7; //EXT address
186 buf[1] |= val; //EXT data
187 err = l3_write(clnt, UDA1341_DATA0, (const unsigned char *)buf, 2);
188 }
189 } else
190 printk(KERN_ERR "UDA1341 codec not active!\n");
191 return err;
192}
193
194static int snd_uda1341_codec_read(struct l3_client *clnt, unsigned short reg)
195{
196 unsigned char val;
197 int err;
198
199 err = l3_read(clnt, reg, &val, 1);
200 if (err == 1)
201 // use just 6bits - the rest is address of the reg
202 return val & 63;
203 return err < 0 ? err : -EIO;
204}
205
206static inline int snd_uda1341_valid_reg(struct l3_client *clnt, unsigned short reg)
207{
208 return reg < uda1341_reg_last;
209}
210
211static int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg,
212 unsigned short mask, unsigned short shift,
213 unsigned short value, int flush)
214{
215 int change;
216 unsigned short old, new;
217 struct uda1341 *uda = clnt->driver_data;
218
219#if 0
220 printk(KERN_DEBUG "update_bits: reg: %s mask: %d shift: %d val: %d\n",
221 uda1341_reg_names[reg], mask, shift, value);
222#endif
223
224 if (!snd_uda1341_valid_reg(clnt, reg))
225 return -EINVAL;
226 spin_lock(&uda->reg_lock);
227 old = uda->regs[reg];
228 new = (old & ~(mask << shift)) | (value << shift);
229 change = old != new;
230 if (change) {
231 if (flush) uda->write(clnt, reg, new);
232 uda->regs[reg] = new;
233 }
234 spin_unlock(&uda->reg_lock);
235 return change;
236}
237
238static int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what,
239 unsigned short value, int flush)
240{
241 struct uda1341 *uda = clnt->driver_data;
242 int ret = 0;
243#ifdef CONFIG_PM
244 int reg;
245#endif
246
247#if 0
248 printk(KERN_DEBUG "cfg_write what: %d value: %d\n", what, value);
249#endif
250
251 uda->cfg[what] = value;
252
253 switch(what) {
254 case CMD_RESET:
255 ret = snd_uda1341_update_bits(clnt, data0_2, 1, 2, 1, flush); // MUTE
256 ret = snd_uda1341_update_bits(clnt, stat0, 1, 6, 1, flush); // RESET
257 ret = snd_uda1341_update_bits(clnt, stat0, 1, 6, 0, flush); // RESTORE
258 uda->cfg[CMD_RESET]=0;
259 break;
260 case CMD_FS:
261 ret = snd_uda1341_update_bits(clnt, stat0, 3, 4, value, flush);
262 break;
263 case CMD_FORMAT:
264 ret = snd_uda1341_update_bits(clnt, stat0, 7, 1, value, flush);
265 break;
266 case CMD_OGAIN:
267 ret = snd_uda1341_update_bits(clnt, stat1, 1, 6, value, flush);
268 break;
269 case CMD_IGAIN:
270 ret = snd_uda1341_update_bits(clnt, stat1, 1, 5, value, flush);
271 break;
272 case CMD_DAC:
273 ret = snd_uda1341_update_bits(clnt, stat1, 1, 0, value, flush);
274 break;
275 case CMD_ADC:
276 ret = snd_uda1341_update_bits(clnt, stat1, 1, 1, value, flush);
277 break;
278 case CMD_VOLUME:
279 ret = snd_uda1341_update_bits(clnt, data0_0, 63, 0, value, flush);
280 break;
281 case CMD_BASS:
282 ret = snd_uda1341_update_bits(clnt, data0_1, 15, 2, value, flush);
283 break;
284 case CMD_TREBBLE:
285 ret = snd_uda1341_update_bits(clnt, data0_1, 3, 0, value, flush);
286 break;
287 case CMD_PEAK:
288 ret = snd_uda1341_update_bits(clnt, data0_2, 1, 5, value, flush);
289 break;
290 case CMD_DEEMP:
291 ret = snd_uda1341_update_bits(clnt, data0_2, 3, 3, value, flush);
292 break;
293 case CMD_MUTE:
294 ret = snd_uda1341_update_bits(clnt, data0_2, 1, 2, value, flush);
295 break;
296 case CMD_FILTER:
297 ret = snd_uda1341_update_bits(clnt, data0_2, 3, 0, value, flush);
298 break;
299 case CMD_CH1:
300 ret = snd_uda1341_update_bits(clnt, ext0, 31, 0, value, flush);
301 break;
302 case CMD_CH2:
303 ret = snd_uda1341_update_bits(clnt, ext1, 31, 0, value, flush);
304 break;
305 case CMD_MIC:
306 ret = snd_uda1341_update_bits(clnt, ext2, 7, 2, value, flush);
307 break;
308 case CMD_MIXER:
309 ret = snd_uda1341_update_bits(clnt, ext2, 3, 0, value, flush);
310 break;
311 case CMD_AGC:
312 ret = snd_uda1341_update_bits(clnt, ext4, 1, 4, value, flush);
313 break;
314 case CMD_IG:
315 ret = snd_uda1341_update_bits(clnt, ext4, 3, 0, value & 0x3, flush);
316 ret = snd_uda1341_update_bits(clnt, ext5, 31, 0, value >> 2, flush);
317 break;
318 case CMD_AGC_TIME:
319 ret = snd_uda1341_update_bits(clnt, ext6, 7, 2, value, flush);
320 break;
321 case CMD_AGC_LEVEL:
322 ret = snd_uda1341_update_bits(clnt, ext6, 3, 0, value, flush);
323 break;
324#ifdef CONFIG_PM
325 case CMD_SUSPEND:
326 for (reg = stat0; reg < uda1341_reg_last; reg++)
327 uda->suspend_regs[reg] = uda->regs[reg];
328 for (reg = 0; reg < CMD_LAST; reg++)
329 uda->suspend_cfg[reg] = uda->cfg[reg];
330 break;
331 case CMD_RESUME:
332 for (reg = stat0; reg < uda1341_reg_last; reg++)
333 snd_uda1341_codec_write(clnt, reg, uda->suspend_regs[reg]);
334 for (reg = 0; reg < CMD_LAST; reg++)
335 uda->cfg[reg] = uda->suspend_cfg[reg];
336 break;
337#endif
338 default:
339 ret = -EINVAL;
340 break;
341 }
342
343 if (!uda->active)
344 printk(KERN_ERR "UDA1341 codec not active!\n");
345 return ret;
346}
347
348/* }}} */
349
350/* {{{ Proc interface */
351#ifdef CONFIG_PROC_FS
352
353static const char *format_names[] = {
354 "I2S-bus",
355 "LSB 16bits",
356 "LSB 18bits",
357 "LSB 20bits",
358 "MSB",
359 "in LSB 16bits/out MSB",
360 "in LSB 18bits/out MSB",
361 "in LSB 20bits/out MSB",
362};
363
364static const char *fs_names[] = {
365 "512*fs",
366 "384*fs",
367 "256*fs",
368 "Unused - bad value!",
369};
370
371static const char* bass_values[][16] = {
372 {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB",
373 "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat
374 {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB",
375 "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min
376 {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB",
377 "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min
378 {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB",
379 "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max
380};
381
382static const char *mic_sens_value[] = {
383 "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used",
384};
385
386static const unsigned short AGC_atime[] = {
387 11, 16, 11, 16, 21, 11, 16, 21,
388};
389
390static const unsigned short AGC_dtime[] = {
391 100, 100, 200, 200, 200, 400, 400, 400,
392};
393
394static const char *AGC_level[] = {
395 "-9.0", "-11.5", "-15.0", "-17.5",
396};
397
398static const char *ig_small_value[] = {
399 "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5",
400};
401
402/*
403 * this was computed as peak_value[i] = pow((63-i)*1.42,1.013)
404 *
405 * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2
406 * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29
407 * [61]=-2.78, [62] = -1.48, [63] = 0.0
408 * I tried to compute it, but using but even using logarithm with base either 10 or 2
409 * i was'n able to get values in the table from the formula. So I constructed another
410 * formula (see above) to interpolate the values as good as possible. If there is some
411 * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks.
412 * UDA1341TS datasheet is available at:
413 * http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf
414 */
415static const char *peak_value[] = {
416 "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB",
417 "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB",
418 "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB",
419 "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB",
420 "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB",
421 "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB",
422 "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB",
423 "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB",
424 "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB",
425};
426
427static void snd_uda1341_proc_read(struct snd_info_entry *entry,
428 struct snd_info_buffer *buffer)
429{
430 struct l3_client *clnt = entry->private_data;
431 struct uda1341 *uda = clnt->driver_data;
432 int peak;
433
434 peak = snd_uda1341_codec_read(clnt, UDA1341_DATA1);
435 if (peak < 0)
436 peak = 0;
437
438 snd_iprintf(buffer, "%s\n\n", uda->card->longname);
439
440 // for information about computed values see UDA1341TS datasheet pages 15 - 21
441 snd_iprintf(buffer, "DAC power : %s\n", uda->cfg[CMD_DAC] ? "on" : "off");
442 snd_iprintf(buffer, "ADC power : %s\n", uda->cfg[CMD_ADC] ? "on" : "off");
443 snd_iprintf(buffer, "Clock frequency : %s\n", fs_names[uda->cfg[CMD_FS]]);
444 snd_iprintf(buffer, "Data format : %s\n\n", format_names[uda->cfg[CMD_FORMAT]]);
445
446 snd_iprintf(buffer, "Filter mode : %s\n", filter_names[uda->cfg[CMD_FILTER]]);
447 snd_iprintf(buffer, "Mixer mode : %s\n", mixer_names[uda->cfg[CMD_MIXER]]);
448 snd_iprintf(buffer, "De-emphasis : %s\n", deemp_names[uda->cfg[CMD_DEEMP]]);
449 snd_iprintf(buffer, "Peak detection pos. : %s\n", uda->cfg[CMD_PEAK] ? "after" : "before");
450 snd_iprintf(buffer, "Peak value : %s\n\n", peak_value[peak]);
451
452 snd_iprintf(buffer, "Automatic Gain Ctrl : %s\n", uda->cfg[CMD_AGC] ? "on" : "off");
453 snd_iprintf(buffer, "AGC attack time : %d ms\n", AGC_atime[uda->cfg[CMD_AGC_TIME]]);
454 snd_iprintf(buffer, "AGC decay time : %d ms\n", AGC_dtime[uda->cfg[CMD_AGC_TIME]]);
455 snd_iprintf(buffer, "AGC output level : %s dB\n\n", AGC_level[uda->cfg[CMD_AGC_LEVEL]]);
456
457 snd_iprintf(buffer, "Mute : %s\n", uda->cfg[CMD_MUTE] ? "on" : "off");
458
459 if (uda->cfg[CMD_VOLUME] == 0)
460 snd_iprintf(buffer, "Volume : 0 dB\n");
461 else if (uda->cfg[CMD_VOLUME] < 62)
462 snd_iprintf(buffer, "Volume : %d dB\n", -1*uda->cfg[CMD_VOLUME] +1);
463 else
464 snd_iprintf(buffer, "Volume : -INF dB\n");
465 snd_iprintf(buffer, "Bass : %s\n", bass_values[uda->cfg[CMD_FILTER]][uda->cfg[CMD_BASS]]);
466 snd_iprintf(buffer, "Trebble : %d dB\n", uda->cfg[CMD_FILTER] ? 2*uda->cfg[CMD_TREBBLE] : 0);
467 snd_iprintf(buffer, "Input Gain (6dB) : %s\n", uda->cfg[CMD_IGAIN] ? "on" : "off");
468 snd_iprintf(buffer, "Output Gain (6dB) : %s\n", uda->cfg[CMD_OGAIN] ? "on" : "off");
469 snd_iprintf(buffer, "Mic sensitivity : %s\n", mic_sens_value[uda->cfg[CMD_MIC]]);
470
471
472 if(uda->cfg[CMD_CH1] < 31)
473 snd_iprintf(buffer, "Mixer gain channel 1: -%d.%c dB\n",
474 ((uda->cfg[CMD_CH1] >> 1) * 3) + (uda->cfg[CMD_CH1] & 1),
475 uda->cfg[CMD_CH1] & 1 ? '5' : '0');
476 else
477 snd_iprintf(buffer, "Mixer gain channel 1: -INF dB\n");
478 if(uda->cfg[CMD_CH2] < 31)
479 snd_iprintf(buffer, "Mixer gain channel 2: -%d.%c dB\n",
480 ((uda->cfg[CMD_CH2] >> 1) * 3) + (uda->cfg[CMD_CH2] & 1),
481 uda->cfg[CMD_CH2] & 1 ? '5' : '0');
482 else
483 snd_iprintf(buffer, "Mixer gain channel 2: -INF dB\n");
484
485 if(uda->cfg[CMD_IG] > 5)
486 snd_iprintf(buffer, "Input Amp. Gain ch 2: %d.%c dB\n",
487 (uda->cfg[CMD_IG] >> 1) -3, uda->cfg[CMD_IG] & 1 ? '5' : '0');
488 else
489 snd_iprintf(buffer, "Input Amp. Gain ch 2: %s dB\n", ig_small_value[uda->cfg[CMD_IG]]);
490}
491
492static void snd_uda1341_proc_regs_read(struct snd_info_entry *entry,
493 struct snd_info_buffer *buffer)
494{
495 struct l3_client *clnt = entry->private_data;
496 struct uda1341 *uda = clnt->driver_data;
497 int reg;
498 char buf[12];
499
500 for (reg = 0; reg < uda1341_reg_last; reg ++) {
501 if (reg == empty)
502 continue;
503 int2str_bin8(uda->regs[reg], buf);
504 snd_iprintf(buffer, "%s = %s\n", uda1341_reg_names[reg], buf);
505 }
506
507 int2str_bin8(snd_uda1341_codec_read(clnt, UDA1341_DATA1), buf);
508 snd_iprintf(buffer, "DATA1 = %s\n", buf);
509}
510#endif /* CONFIG_PROC_FS */
511
512static void __devinit snd_uda1341_proc_init(struct snd_card *card, struct l3_client *clnt)
513{
514 struct snd_info_entry *entry;
515
516 if (! snd_card_proc_new(card, "uda1341", &entry))
517 snd_info_set_text_ops(entry, clnt, snd_uda1341_proc_read);
518 if (! snd_card_proc_new(card, "uda1341-regs", &entry))
519 snd_info_set_text_ops(entry, clnt, snd_uda1341_proc_regs_read);
520}
521
522/* }}} */
523
524/* {{{ Mixer controls setting */
525
526/* {{{ UDA1341 single functions */
527
528#define UDA1341_SINGLE(xname, where, reg, shift, mask, invert) \
529{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_uda1341_info_single, \
530 .get = snd_uda1341_get_single, .put = snd_uda1341_put_single, \
531 .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \
532}
533
534static int snd_uda1341_info_single(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_info *uinfo)
536{
537 int mask = (kcontrol->private_value >> 12) & 63;
538
539 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
540 uinfo->count = 1;
541 uinfo->value.integer.min = 0;
542 uinfo->value.integer.max = mask;
543 return 0;
544}
545
546static int snd_uda1341_get_single(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
548{
549 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
550 struct uda1341 *uda = clnt->driver_data;
551 int where = kcontrol->private_value & 31;
552 int mask = (kcontrol->private_value >> 12) & 63;
553 int invert = (kcontrol->private_value >> 18) & 1;
554
555 ucontrol->value.integer.value[0] = uda->cfg[where];
556 if (invert)
557 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
558
559 return 0;
560}
561
562static int snd_uda1341_put_single(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_value *ucontrol)
564{
565 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
566 struct uda1341 *uda = clnt->driver_data;
567 int where = kcontrol->private_value & 31;
568 int reg = (kcontrol->private_value >> 5) & 15;
569 int shift = (kcontrol->private_value >> 9) & 7;
570 int mask = (kcontrol->private_value >> 12) & 63;
571 int invert = (kcontrol->private_value >> 18) & 1;
572 unsigned short val;
573
574 val = (ucontrol->value.integer.value[0] & mask);
575 if (invert)
576 val = mask - val;
577
578 uda->cfg[where] = val;
579 return snd_uda1341_update_bits(clnt, reg, mask, shift, val, FLUSH);
580}
581
582/* }}} */
583
584/* {{{ UDA1341 enum functions */
585
586#define UDA1341_ENUM(xname, where, reg, shift, mask, invert) \
587{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_uda1341_info_enum, \
588 .get = snd_uda1341_get_enum, .put = snd_uda1341_put_enum, \
589 .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \
590}
591
592static int snd_uda1341_info_enum(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_info *uinfo)
594{
595 int where = kcontrol->private_value & 31;
596 const char **texts;
597
598 // this register we don't handle this way
599 if (!uda1341_enum_items[where])
600 return -EINVAL;
601
602 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
603 uinfo->count = 1;
604 uinfo->value.enumerated.items = uda1341_enum_items[where];
605
606 if (uinfo->value.enumerated.item >= uda1341_enum_items[where])
607 uinfo->value.enumerated.item = uda1341_enum_items[where] - 1;
608
609 texts = uda1341_enum_names[where];
610 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
611 return 0;
612}
613
614static int snd_uda1341_get_enum(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
616{
617 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
618 struct uda1341 *uda = clnt->driver_data;
619 int where = kcontrol->private_value & 31;
620
621 ucontrol->value.enumerated.item[0] = uda->cfg[where];
622 return 0;
623}
624
625static int snd_uda1341_put_enum(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
627{
628 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
629 struct uda1341 *uda = clnt->driver_data;
630 int where = kcontrol->private_value & 31;
631 int reg = (kcontrol->private_value >> 5) & 15;
632 int shift = (kcontrol->private_value >> 9) & 7;
633 int mask = (kcontrol->private_value >> 12) & 63;
634
635 uda->cfg[where] = (ucontrol->value.enumerated.item[0] & mask);
636
637 return snd_uda1341_update_bits(clnt, reg, mask, shift, uda->cfg[where], FLUSH);
638}
639
640/* }}} */
641
642/* {{{ UDA1341 2regs functions */
643
644#define UDA1341_2REGS(xname, where, reg_1, reg_2, shift_1, shift_2, mask_1, mask_2, invert) \
645{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_uda1341_info_2regs, \
646 .get = snd_uda1341_get_2regs, .put = snd_uda1341_put_2regs, \
647 .private_value = where | (reg_1 << 5) | (reg_2 << 9) | (shift_1 << 13) | (shift_2 << 16) | \
648 (mask_1 << 19) | (mask_2 << 25) | (invert << 31) \
649}
650
651
652static int snd_uda1341_info_2regs(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_info *uinfo)
654{
655 int mask_1 = (kcontrol->private_value >> 19) & 63;
656 int mask_2 = (kcontrol->private_value >> 25) & 63;
657 int mask;
658
659 mask = (mask_2 + 1) * (mask_1 + 1) - 1;
660 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
661 uinfo->count = 1;
662 uinfo->value.integer.min = 0;
663 uinfo->value.integer.max = mask;
664 return 0;
665}
666
667static int snd_uda1341_get_2regs(struct snd_kcontrol *kcontrol,
668 struct snd_ctl_elem_value *ucontrol)
669{
670 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
671 struct uda1341 *uda = clnt->driver_data;
672 int where = kcontrol->private_value & 31;
673 int mask_1 = (kcontrol->private_value >> 19) & 63;
674 int mask_2 = (kcontrol->private_value >> 25) & 63;
675 int invert = (kcontrol->private_value >> 31) & 1;
676 int mask;
677
678 mask = (mask_2 + 1) * (mask_1 + 1) - 1;
679
680 ucontrol->value.integer.value[0] = uda->cfg[where];
681 if (invert)
682 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
683 return 0;
684}
685
686static int snd_uda1341_put_2regs(struct snd_kcontrol *kcontrol,
687 struct snd_ctl_elem_value *ucontrol)
688{
689 struct l3_client *clnt = snd_kcontrol_chip(kcontrol);
690 struct uda1341 *uda = clnt->driver_data;
691 int where = kcontrol->private_value & 31;
692 int reg_1 = (kcontrol->private_value >> 5) & 15;
693 int reg_2 = (kcontrol->private_value >> 9) & 15;
694 int shift_1 = (kcontrol->private_value >> 13) & 7;
695 int shift_2 = (kcontrol->private_value >> 16) & 7;
696 int mask_1 = (kcontrol->private_value >> 19) & 63;
697 int mask_2 = (kcontrol->private_value >> 25) & 63;
698 int invert = (kcontrol->private_value >> 31) & 1;
699 int mask;
700 unsigned short val1, val2, val;
701
702 val = ucontrol->value.integer.value[0];
703
704 mask = (mask_2 + 1) * (mask_1 + 1) - 1;
705
706 val1 = val & mask_1;
707 val2 = (val / (mask_1 + 1)) & mask_2;
708
709 if (invert) {
710 val1 = mask_1 - val1;
711 val2 = mask_2 - val2;
712 }
713
714 uda->cfg[where] = invert ? mask - val : val;
715
716 //FIXME - return value
717 snd_uda1341_update_bits(clnt, reg_1, mask_1, shift_1, val1, FLUSH);
718 return snd_uda1341_update_bits(clnt, reg_2, mask_2, shift_2, val2, FLUSH);
719}
720
721/* }}} */
722
723static struct snd_kcontrol_new snd_uda1341_controls[] = {
724 UDA1341_SINGLE("Master Playback Switch", CMD_MUTE, data0_2, 2, 1, 1),
725 UDA1341_SINGLE("Master Playback Volume", CMD_VOLUME, data0_0, 0, 63, 1),
726
727 UDA1341_SINGLE("Bass Playback Volume", CMD_BASS, data0_1, 2, 15, 0),
728 UDA1341_SINGLE("Treble Playback Volume", CMD_TREBBLE, data0_1, 0, 3, 0),
729
730 UDA1341_SINGLE("Input Gain Switch", CMD_IGAIN, stat1, 5, 1, 0),
731 UDA1341_SINGLE("Output Gain Switch", CMD_OGAIN, stat1, 6, 1, 0),
732
733 UDA1341_SINGLE("Mixer Gain Channel 1 Volume", CMD_CH1, ext0, 0, 31, 1),
734 UDA1341_SINGLE("Mixer Gain Channel 2 Volume", CMD_CH2, ext1, 0, 31, 1),
735
736 UDA1341_SINGLE("Mic Sensitivity Volume", CMD_MIC, ext2, 2, 7, 0),
737
738 UDA1341_SINGLE("AGC Output Level", CMD_AGC_LEVEL, ext6, 0, 3, 0),
739 UDA1341_SINGLE("AGC Time Constant", CMD_AGC_TIME, ext6, 2, 7, 0),
740 UDA1341_SINGLE("AGC Time Constant Switch", CMD_AGC, ext4, 4, 1, 0),
741
742 UDA1341_SINGLE("DAC Power", CMD_DAC, stat1, 0, 1, 0),
743 UDA1341_SINGLE("ADC Power", CMD_ADC, stat1, 1, 1, 0),
744
745 UDA1341_ENUM("Peak detection", CMD_PEAK, data0_2, 5, 1, 0),
746 UDA1341_ENUM("De-emphasis", CMD_DEEMP, data0_2, 3, 3, 0),
747 UDA1341_ENUM("Mixer mode", CMD_MIXER, ext2, 0, 3, 0),
748 UDA1341_ENUM("Filter mode", CMD_FILTER, data0_2, 0, 3, 0),
749
750 UDA1341_2REGS("Gain Input Amplifier Gain (channel 2)", CMD_IG, ext4, ext5, 0, 0, 3, 31, 0),
751};
752
753static void uda1341_free(struct l3_client *clnt)
754{
755 l3_detach_client(clnt); // calls kfree for driver_data (struct uda1341)
756 kfree(clnt);
757}
758
759static int uda1341_dev_free(struct snd_device *device)
760{
761 struct l3_client *clnt = device->device_data;
762 uda1341_free(clnt);
763 return 0;
764}
765
766int __init snd_chip_uda1341_mixer_new(struct snd_card *card, struct l3_client **clntp)
767{
768 static struct snd_device_ops ops = {
769 .dev_free = uda1341_dev_free,
770 };
771 struct l3_client *clnt;
772 int idx, err;
773
774 if (snd_BUG_ON(!card))
775 return -EINVAL;
776
777 clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
778 if (clnt == NULL)
779 return -ENOMEM;
780
781 if ((err = l3_attach_client(clnt, "l3-bit-sa1100-gpio", UDA1341_ALSA_NAME))) {
782 kfree(clnt);
783 return err;
784 }
785
786 for (idx = 0; idx < ARRAY_SIZE(snd_uda1341_controls); idx++) {
787 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_uda1341_controls[idx], clnt))) < 0) {
788 uda1341_free(clnt);
789 return err;
790 }
791 }
792
793 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, clnt, &ops)) < 0) {
794 uda1341_free(clnt);
795 return err;
796 }
797
798 *clntp = clnt;
799 strcpy(card->mixername, "UDA1341TS Mixer");
800 ((struct uda1341 *)clnt->driver_data)->card = card;
801
802 snd_uda1341_proc_init(card, clnt);
803
804 return 0;
805}
806
807/* }}} */
808
809/* {{{ L3 operations */
810
811static int uda1341_attach(struct l3_client *clnt)
812{
813 struct uda1341 *uda;
814
815 uda = kzalloc(sizeof(*uda), 0, GFP_KERNEL);
816 if (!uda)
817 return -ENOMEM;
818
819 /* init fixed parts of my copy of registers */
820 uda->regs[stat0] = STAT0;
821 uda->regs[stat1] = STAT1;
822
823 uda->regs[data0_0] = DATA0_0;
824 uda->regs[data0_1] = DATA0_1;
825 uda->regs[data0_2] = DATA0_2;
826
827 uda->write = snd_uda1341_codec_write;
828 uda->read = snd_uda1341_codec_read;
829
830 spin_lock_init(&uda->reg_lock);
831
832 clnt->driver_data = uda;
833 return 0;
834}
835
836static void uda1341_detach(struct l3_client *clnt)
837{
838 kfree(clnt->driver_data);
839}
840
841static int
842uda1341_command(struct l3_client *clnt, int cmd, void *arg)
843{
844 if (cmd != CMD_READ_REG)
845 return snd_uda1341_cfg_write(clnt, cmd, (int) arg, FLUSH);
846
847 return snd_uda1341_codec_read(clnt, (int) arg);
848}
849
850static int uda1341_open(struct l3_client *clnt)
851{
852 struct uda1341 *uda = clnt->driver_data;
853
854 uda->active = 1;
855
856 /* init default configuration */
857 snd_uda1341_cfg_write(clnt, CMD_RESET, 0, REGS_ONLY);
858 snd_uda1341_cfg_write(clnt, CMD_FS, F256, FLUSH); // unknown state after reset
859 snd_uda1341_cfg_write(clnt, CMD_FORMAT, LSB16, FLUSH); // unknown state after reset
860 snd_uda1341_cfg_write(clnt, CMD_OGAIN, ON, FLUSH); // default off after reset
861 snd_uda1341_cfg_write(clnt, CMD_IGAIN, ON, FLUSH); // default off after reset
862 snd_uda1341_cfg_write(clnt, CMD_DAC, ON, FLUSH); // ??? default value after reset
863 snd_uda1341_cfg_write(clnt, CMD_ADC, ON, FLUSH); // ??? default value after reset
864 snd_uda1341_cfg_write(clnt, CMD_VOLUME, 20, FLUSH); // default 0dB after reset
865 snd_uda1341_cfg_write(clnt, CMD_BASS, 0, REGS_ONLY); // default value after reset
866 snd_uda1341_cfg_write(clnt, CMD_TREBBLE, 0, REGS_ONLY); // default value after reset
867 snd_uda1341_cfg_write(clnt, CMD_PEAK, AFTER, REGS_ONLY);// default value after reset
868 snd_uda1341_cfg_write(clnt, CMD_DEEMP, NONE, REGS_ONLY);// default value after reset
869 //at this moment should be QMUTED by h3600_audio_init
870 snd_uda1341_cfg_write(clnt, CMD_MUTE, OFF, REGS_ONLY); // default value after reset
871 snd_uda1341_cfg_write(clnt, CMD_FILTER, MAX, FLUSH); // defaul flat after reset
872 snd_uda1341_cfg_write(clnt, CMD_CH1, 31, FLUSH); // default value after reset
873 snd_uda1341_cfg_write(clnt, CMD_CH2, 4, FLUSH); // default value after reset
874 snd_uda1341_cfg_write(clnt, CMD_MIC, 4, FLUSH); // default 0dB after reset
875 snd_uda1341_cfg_write(clnt, CMD_MIXER, MIXER, FLUSH); // default doub.dif.mode
876 snd_uda1341_cfg_write(clnt, CMD_AGC, OFF, FLUSH); // default value after reset
877 snd_uda1341_cfg_write(clnt, CMD_IG, 0, FLUSH); // unknown state after reset
878 snd_uda1341_cfg_write(clnt, CMD_AGC_TIME, 0, FLUSH); // default value after reset
879 snd_uda1341_cfg_write(clnt, CMD_AGC_LEVEL, 0, FLUSH); // default value after reset
880
881 return 0;
882}
883
884static void uda1341_close(struct l3_client *clnt)
885{
886 struct uda1341 *uda = clnt->driver_data;
887
888 uda->active = 0;
889}
890
891/* }}} */
892
893/* {{{ Module and L3 initialization */
894
895static struct l3_ops uda1341_ops = {
896 .open = uda1341_open,
897 .command = uda1341_command,
898 .close = uda1341_close,
899};
900
901static struct l3_driver uda1341_driver = {
902 .name = UDA1341_ALSA_NAME,
903 .attach_client = uda1341_attach,
904 .detach_client = uda1341_detach,
905 .ops = &uda1341_ops,
906 .owner = THIS_MODULE,
907};
908
909static int __init uda1341_init(void)
910{
911 return l3_add_driver(&uda1341_driver);
912}
913
914static void __exit uda1341_exit(void)
915{
916 l3_del_driver(&uda1341_driver);
917}
918
919module_init(uda1341_init);
920module_exit(uda1341_exit);
921
922MODULE_AUTHOR("Tomas Kasparek <tomas.kasparek@seznam.cz>");
923MODULE_LICENSE("GPL");
924MODULE_DESCRIPTION("Philips UDA1341 CODEC driver for ALSA");
925MODULE_SUPPORTED_DEVICE("{{UDA1341,UDA1341TS}}");
926
927EXPORT_SYMBOL(snd_chip_uda1341_mixer_new);
928
929/* }}} */
930
931/*
932 * Local variables:
933 * indent-tabs-mode: t
934 * End:
935 */
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 9d98a6658ac9..d31c373e076d 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/version.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/tea575x-tuner.h> 29#include <sound/tea575x-tuner.h>
29 30
@@ -31,6 +32,13 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
31MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); 32MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips");
32MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
33 34
35static int radio_nr = -1;
36module_param(radio_nr, int, 0);
37
38#define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
39#define FREQ_LO (87 * 16000)
40#define FREQ_HI (108 * 16000)
41
34/* 42/*
35 * definitions 43 * definitions
36 */ 44 */
@@ -53,6 +61,17 @@ MODULE_LICENSE("GPL");
53#define TEA575X_BIT_DUMMY (1<<15) /* buffer */ 61#define TEA575X_BIT_DUMMY (1<<15) /* buffer */
54#define TEA575X_BIT_FREQ_MASK 0x7fff 62#define TEA575X_BIT_FREQ_MASK 0x7fff
55 63
64static struct v4l2_queryctrl radio_qctrl[] = {
65 {
66 .id = V4L2_CID_AUDIO_MUTE,
67 .name = "Mute",
68 .minimum = 0,
69 .maximum = 1,
70 .default_value = 1,
71 .type = V4L2_CTRL_TYPE_BOOLEAN,
72 }
73};
74
56/* 75/*
57 * lowlevel part 76 * lowlevel part
58 */ 77 */
@@ -84,94 +103,146 @@ static void snd_tea575x_set_freq(struct snd_tea575x *tea)
84 * Linux Video interface 103 * Linux Video interface
85 */ 104 */
86 105
87static long snd_tea575x_ioctl(struct file *file, 106static int vidioc_querycap(struct file *file, void *priv,
88 unsigned int cmd, unsigned long data) 107 struct v4l2_capability *v)
89{ 108{
90 struct snd_tea575x *tea = video_drvdata(file); 109 struct snd_tea575x *tea = video_drvdata(file);
91 void __user *arg = (void __user *)data; 110
92 111 strcpy(v->card, tea->tea5759 ? "TEA5759" : "TEA5757");
93 switch(cmd) { 112 strlcpy(v->driver, "tea575x-tuner", sizeof(v->driver));
94 case VIDIOCGCAP: 113 strlcpy(v->card, "Maestro Radio", sizeof(v->card));
95 { 114 sprintf(v->bus_info, "PCI");
96 struct video_capability v; 115 v->version = RADIO_VERSION;
97 v.type = VID_TYPE_TUNER; 116 v->capabilities = V4L2_CAP_TUNER;
98 v.channels = 1; 117 return 0;
99 v.audios = 1; 118}
100 /* No we don't do pictures */ 119
101 v.maxwidth = 0; 120static int vidioc_g_tuner(struct file *file, void *priv,
102 v.maxheight = 0; 121 struct v4l2_tuner *v)
103 v.minwidth = 0; 122{
104 v.minheight = 0; 123 if (v->index > 0)
105 strcpy(v.name, tea->tea5759 ? "TEA5759" : "TEA5757"); 124 return -EINVAL;
106 if (copy_to_user(arg,&v,sizeof(v))) 125
107 return -EFAULT; 126 strcpy(v->name, "FM");
108 return 0; 127 v->type = V4L2_TUNER_RADIO;
109 } 128 v->rangelow = FREQ_LO;
110 case VIDIOCGTUNER: 129 v->rangehigh = FREQ_HI;
111 { 130 v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
112 struct video_tuner v; 131 v->capability = V4L2_TUNER_CAP_LOW;
113 if (copy_from_user(&v, arg,sizeof(v))!=0) 132 v->audmode = V4L2_TUNER_MODE_MONO;
114 return -EFAULT; 133 v->signal = 0xffff;
115 if (v.tuner) /* Only 1 tuner */ 134 return 0;
116 return -EINVAL; 135}
117 v.rangelow = (87*16000); 136
118 v.rangehigh = (108*16000); 137static int vidioc_s_tuner(struct file *file, void *priv,
119 v.flags = VIDEO_TUNER_LOW; 138 struct v4l2_tuner *v)
120 v.mode = VIDEO_MODE_AUTO; 139{
121 strcpy(v.name, "FM"); 140 if (v->index > 0)
122 v.signal = 0xFFFF; 141 return -EINVAL;
123 if (copy_to_user(arg, &v, sizeof(v))) 142 return 0;
124 return -EFAULT; 143}
125 return 0; 144
126 } 145static int vidioc_g_frequency(struct file *file, void *priv,
127 case VIDIOCSTUNER: 146 struct v4l2_frequency *f)
128 { 147{
129 struct video_tuner v; 148 struct snd_tea575x *tea = video_drvdata(file);
130 if(copy_from_user(&v, arg, sizeof(v))) 149
131 return -EFAULT; 150 f->type = V4L2_TUNER_RADIO;
132 if(v.tuner!=0) 151 f->frequency = tea->freq;
133 return -EINVAL; 152 return 0;
134 /* Only 1 tuner so no setting needed ! */ 153}
154
155static int vidioc_s_frequency(struct file *file, void *priv,
156 struct v4l2_frequency *f)
157{
158 struct snd_tea575x *tea = video_drvdata(file);
159
160 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
161 return -EINVAL;
162
163 tea->freq = f->frequency;
164
165 snd_tea575x_set_freq(tea);
166
167 return 0;
168}
169
170static int vidioc_g_audio(struct file *file, void *priv,
171 struct v4l2_audio *a)
172{
173 if (a->index > 1)
174 return -EINVAL;
175
176 strcpy(a->name, "Radio");
177 a->capability = V4L2_AUDCAP_STEREO;
178 return 0;
179}
180
181static int vidioc_s_audio(struct file *file, void *priv,
182 struct v4l2_audio *a)
183{
184 if (a->index != 0)
185 return -EINVAL;
186 return 0;
187}
188
189static int vidioc_queryctrl(struct file *file, void *priv,
190 struct v4l2_queryctrl *qc)
191{
192 int i;
193
194 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
195 if (qc->id && qc->id == radio_qctrl[i].id) {
196 memcpy(qc, &(radio_qctrl[i]),
197 sizeof(*qc));
135 return 0; 198 return 0;
136 } 199 }
137 case VIDIOCGFREQ: 200 }
138 if(copy_to_user(arg, &tea->freq, sizeof(tea->freq))) 201 return -EINVAL;
139 return -EFAULT; 202}
140 return 0; 203
141 case VIDIOCSFREQ: 204static int vidioc_g_ctrl(struct file *file, void *priv,
142 if(copy_from_user(&tea->freq, arg, sizeof(tea->freq))) 205 struct v4l2_control *ctrl)
143 return -EFAULT; 206{
144 snd_tea575x_set_freq(tea); 207 struct snd_tea575x *tea = video_drvdata(file);
145 return 0; 208
146 case VIDIOCGAUDIO: 209 switch (ctrl->id) {
147 { 210 case V4L2_CID_AUDIO_MUTE:
148 struct video_audio v; 211 if (tea->ops->mute) {
149 memset(&v, 0, sizeof(v)); 212 ctrl->value = tea->mute;
150 strcpy(v.name, "Radio");
151 if(copy_to_user(arg,&v, sizeof(v)))
152 return -EFAULT;
153 return 0; 213 return 0;
154 } 214 }
155 case VIDIOCSAUDIO: 215 }
156 { 216 return -EINVAL;
157 struct video_audio v; 217}
158 if(copy_from_user(&v, arg, sizeof(v))) 218
159 return -EFAULT; 219static int vidioc_s_ctrl(struct file *file, void *priv,
160 if (tea->ops->mute) 220 struct v4l2_control *ctrl)
161 tea->ops->mute(tea, 221{
162 (v.flags & 222 struct snd_tea575x *tea = video_drvdata(file);
163 VIDEO_AUDIO_MUTE) ? 1 : 0); 223
164 if(v.audio) 224 switch (ctrl->id) {
165 return -EINVAL; 225 case V4L2_CID_AUDIO_MUTE:
226 if (tea->ops->mute) {
227 tea->ops->mute(tea, ctrl->value);
228 tea->mute = 1;
166 return 0; 229 return 0;
167 } 230 }
168 default:
169 return -ENOIOCTLCMD;
170 } 231 }
232 return -EINVAL;
233}
234
235static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
236{
237 *i = 0;
238 return 0;
171} 239}
172 240
173static void snd_tea575x_release(struct video_device *vfd) 241static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
174{ 242{
243 if (i != 0)
244 return -EINVAL;
245 return 0;
175} 246}
176 247
177static int snd_tea575x_exclusive_open(struct file *file) 248static int snd_tea575x_exclusive_open(struct file *file)
@@ -189,50 +260,91 @@ static int snd_tea575x_exclusive_release(struct file *file)
189 return 0; 260 return 0;
190} 261}
191 262
263static const struct v4l2_file_operations tea575x_fops = {
264 .owner = THIS_MODULE,
265 .open = snd_tea575x_exclusive_open,
266 .release = snd_tea575x_exclusive_release,
267 .ioctl = video_ioctl2,
268};
269
270static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
271 .vidioc_querycap = vidioc_querycap,
272 .vidioc_g_tuner = vidioc_g_tuner,
273 .vidioc_s_tuner = vidioc_s_tuner,
274 .vidioc_g_audio = vidioc_g_audio,
275 .vidioc_s_audio = vidioc_s_audio,
276 .vidioc_g_input = vidioc_g_input,
277 .vidioc_s_input = vidioc_s_input,
278 .vidioc_g_frequency = vidioc_g_frequency,
279 .vidioc_s_frequency = vidioc_s_frequency,
280 .vidioc_queryctrl = vidioc_queryctrl,
281 .vidioc_g_ctrl = vidioc_g_ctrl,
282 .vidioc_s_ctrl = vidioc_s_ctrl,
283};
284
285static struct video_device tea575x_radio = {
286 .name = "tea575x-tuner",
287 .fops = &tea575x_fops,
288 .ioctl_ops = &tea575x_ioctl_ops,
289 .release = video_device_release,
290};
291
192/* 292/*
193 * initialize all the tea575x chips 293 * initialize all the tea575x chips
194 */ 294 */
195void snd_tea575x_init(struct snd_tea575x *tea) 295void snd_tea575x_init(struct snd_tea575x *tea)
196{ 296{
297 int retval;
197 unsigned int val; 298 unsigned int val;
299 struct video_device *tea575x_radio_inst;
198 300
199 val = tea->ops->read(tea); 301 val = tea->ops->read(tea);
200 if (val == 0x1ffffff || val == 0) { 302 if (val == 0x1ffffff || val == 0) {
201 snd_printk(KERN_ERR "Cannot find TEA575x chip\n"); 303 snd_printk(KERN_ERR
304 "tea575x-tuner: Cannot find TEA575x chip\n");
202 return; 305 return;
203 } 306 }
204 307
205 memset(&tea->vd, 0, sizeof(tea->vd));
206 strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio");
207 tea->vd.release = snd_tea575x_release;
208 video_set_drvdata(&tea->vd, tea);
209 tea->vd.fops = &tea->fops;
210 tea->in_use = 0; 308 tea->in_use = 0;
211 tea->fops.owner = tea->card->module; 309 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;
212 tea->fops.open = snd_tea575x_exclusive_open; 310 tea->freq = 90500 * 16; /* 90.5Mhz default */
213 tea->fops.release = snd_tea575x_exclusive_release; 311
214 tea->fops.ioctl = snd_tea575x_ioctl; 312 tea575x_radio_inst = video_device_alloc();
215 if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) { 313 if (tea575x_radio_inst == NULL) {
216 snd_printk(KERN_ERR "unable to register tea575x tuner\n"); 314 printk(KERN_ERR "tea575x-tuner: not enough memory\n");
217 return; 315 return;
218 } 316 }
219 tea->vd_registered = 1;
220 317
221 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; 318 memcpy(tea575x_radio_inst, &tea575x_radio, sizeof(tea575x_radio));
222 tea->freq = 90500 * 16; /* 90.5Mhz default */ 319
320 strcpy(tea575x_radio.name, tea->tea5759 ?
321 "TEA5759 radio" : "TEA5757 radio");
322
323 video_set_drvdata(tea575x_radio_inst, tea);
324
325 retval = video_register_device(tea575x_radio_inst,
326 VFL_TYPE_RADIO, radio_nr);
327 if (retval) {
328 printk(KERN_ERR "tea575x-tuner: can't register video device!\n");
329 kfree(tea575x_radio_inst);
330 return;
331 }
223 332
224 snd_tea575x_set_freq(tea); 333 snd_tea575x_set_freq(tea);
225 334
226 /* mute on init */ 335 /* mute on init */
227 if (tea->ops->mute) 336 if (tea->ops->mute) {
228 tea->ops->mute(tea, 1); 337 tea->ops->mute(tea, 1);
338 tea->mute = 1;
339 }
340 tea->vd = tea575x_radio_inst;
229} 341}
230 342
231void snd_tea575x_exit(struct snd_tea575x *tea) 343void snd_tea575x_exit(struct snd_tea575x *tea)
232{ 344{
233 if (tea->vd_registered) { 345 if (tea->vd) {
234 video_unregister_device(&tea->vd); 346 video_unregister_device(tea->vd);
235 tea->vd_registered = 0; 347 tea->vd = NULL;
236 } 348 }
237} 349}
238 350
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index ce0aa044e274..c6942a4de99b 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -56,8 +56,8 @@ config SND_AD1848
56 Say Y here to include support for AD1848 (Analog Devices) or 56 Say Y here to include support for AD1848 (Analog Devices) or
57 CS4248 (Cirrus Logic - Crystal Semiconductors) chips. 57 CS4248 (Cirrus Logic - Crystal Semiconductors) chips.
58 58
59 For newer chips from Cirrus Logic, use the CS4231, CS4232 or 59 For newer chips from Cirrus Logic, use the CS4231 or CS4232+
60 CS4236+ drivers. 60 drivers.
61 61
62 To compile this driver as a module, choose M here: the module 62 To compile this driver as a module, choose M here: the module
63 will be called snd-ad1848. 63 will be called snd-ad1848.
@@ -94,6 +94,8 @@ config SND_CMI8330
94 tristate "C-Media CMI8330" 94 tristate "C-Media CMI8330"
95 select SND_WSS_LIB 95 select SND_WSS_LIB
96 select SND_SB16_DSP 96 select SND_SB16_DSP
97 select SND_OPL3_LIB
98 select SND_MPU401_UART
97 help 99 help
98 Say Y here to include support for soundcards based on the 100 Say Y here to include support for soundcards based on the
99 C-Media CMI8330 chip. 101 C-Media CMI8330 chip.
@@ -112,26 +114,15 @@ config SND_CS4231
112 To compile this driver as a module, choose M here: the module 114 To compile this driver as a module, choose M here: the module
113 will be called snd-cs4231. 115 will be called snd-cs4231.
114 116
115config SND_CS4232
116 tristate "Generic Cirrus Logic CS4232 driver"
117 select SND_OPL3_LIB
118 select SND_MPU401_UART
119 select SND_WSS_LIB
120 help
121 Say Y here to include support for CS4232 chips from Cirrus
122 Logic - Crystal Semiconductors.
123
124 To compile this driver as a module, choose M here: the module
125 will be called snd-cs4232.
126
127config SND_CS4236 117config SND_CS4236
128 tristate "Generic Cirrus Logic CS4236+ driver" 118 tristate "Generic Cirrus Logic CS4232/CS4236+ driver"
129 select SND_OPL3_LIB 119 select SND_OPL3_LIB
130 select SND_MPU401_UART 120 select SND_MPU401_UART
131 select SND_WSS_LIB 121 select SND_WSS_LIB
132 help 122 help
133 Say Y to include support for CS4235,CS4236,CS4237B,CS4238B, 123 Say Y to include support for CS4232,CS4235,CS4236,CS4237B,
134 CS4239 chips from Cirrus Logic - Crystal Semiconductors. 124 CS4238B,CS4239 chips from Cirrus Logic - Crystal
125 Semiconductors.
135 126
136 To compile this driver as a module, choose M here: the module 127 To compile this driver as a module, choose M here: the module
137 will be called snd-cs4236. 128 will be called snd-cs4236.
@@ -377,14 +368,17 @@ config SND_SGALAXY
377 will be called snd-sgalaxy. 368 will be called snd-sgalaxy.
378 369
379config SND_SSCAPE 370config SND_SSCAPE
380 tristate "Ensoniq SoundScape PnP driver" 371 tristate "Ensoniq SoundScape driver"
381 select SND_HWDEP 372 select SND_HWDEP
382 select SND_MPU401_UART 373 select SND_MPU401_UART
383 select SND_WSS_LIB 374 select SND_WSS_LIB
384 help 375 help
385 Say Y here to include support for Ensoniq SoundScape PnP 376 Say Y here to include support for Ensoniq SoundScape
386 soundcards. 377 soundcards.
387 378
379 The PCM audio is supported on SoundScape Classic, Elite, PnP
380 and VIVO cards. The MIDI support is very experimental.
381
388 To compile this driver as a module, choose M here: the module 382 To compile this driver as a module, choose M here: the module
389 will be called snd-sscape. 383 will be called snd-sscape.
390 384
@@ -401,15 +395,36 @@ config SND_WAVEFRONT
401 To compile this driver as a module, choose M here: the module 395 To compile this driver as a module, choose M here: the module
402 will be called snd-wavefront. 396 will be called snd-wavefront.
403 397
404config SND_WAVEFRONT_FIRMWARE_IN_KERNEL 398config SND_MSND_PINNACLE
405 bool "In-kernel firmware for Wavefront" 399 tristate "Turtle Beach MultiSound Pinnacle/Fiji driver"
406 depends on SND_WAVEFRONT 400 depends on X86 && EXPERIMENTAL
407 default y 401 select FW_LOADER
402 select SND_MPU401_UART
403 select SND_PCM
404 help
405 Say Y to include support for Turtle Beach MultiSound Pinnacle/
406 Fiji soundcards.
407
408 To compile this driver as a module, choose M here: the module
409 will be called snd-msnd-pinnacle.
410
411config SND_MSND_CLASSIC
412 tristate "Support for Turtle Beach MultiSound Classic, Tahiti, Monterey"
413 depends on X86 && EXPERIMENTAL
414 select FW_LOADER
415 select SND_MPU401_UART
416 select SND_PCM
408 help 417 help
409 Say Y here to include the static firmware for FX DSP built in 418 Say M here if you have a Turtle Beach MultiSound Classic, Tahiti or
410 the kernel for the Wavefront driver. If you choose N here, 419 Monterey (not for the Pinnacle or Fiji).
411 you need to install the firmware files from the 420
412 alsa-firmware package. 421 See <file:Documentation/sound/oss/MultiSound> for important information
422 about this driver. Note that it has been discontinued, but the
423 Voyetra Turtle Beach knowledge base entry for it is still available
424 at <http://www.turtlebeach.com/site/kb_ftp/790.asp>.
425
426 To compile this driver as a module, choose M here: the module
427 will be called snd-msnd-classic.
413 428
414endif # SND_ISA 429endif # SND_ISA
415 430
diff --git a/sound/isa/Makefile b/sound/isa/Makefile
index 63af13d901a5..b906b9a1a81e 100644
--- a/sound/isa/Makefile
+++ b/sound/isa/Makefile
@@ -26,5 +26,5 @@ obj-$(CONFIG_SND_SC6000) += snd-sc6000.o
26obj-$(CONFIG_SND_SGALAXY) += snd-sgalaxy.o 26obj-$(CONFIG_SND_SGALAXY) += snd-sgalaxy.o
27obj-$(CONFIG_SND_SSCAPE) += snd-sscape.o 27obj-$(CONFIG_SND_SSCAPE) += snd-sscape.o
28 28
29obj-$(CONFIG_SND) += ad1816a/ ad1848/ cs423x/ es1688/ gus/ opti9xx/ \ 29obj-$(CONFIG_SND) += ad1816a/ ad1848/ cs423x/ es1688/ gus/ msnd/ opti9xx/ \
30 sb/ wavefront/ wss/ 30 sb/ wavefront/ wss/
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 9660e598232c..bbcbf92a8ebe 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -156,6 +156,7 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
156 struct snd_card_ad1816a *acard; 156 struct snd_card_ad1816a *acard;
157 struct snd_ad1816a *chip; 157 struct snd_ad1816a *chip;
158 struct snd_opl3 *opl3; 158 struct snd_opl3 *opl3;
159 struct snd_timer *timer;
159 160
160 error = snd_card_create(index[dev], id[dev], THIS_MODULE, 161 error = snd_card_create(index[dev], id[dev], THIS_MODULE,
161 sizeof(struct snd_card_ad1816a), &card); 162 sizeof(struct snd_card_ad1816a), &card);
@@ -195,6 +196,12 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
195 return error; 196 return error;
196 } 197 }
197 198
199 error = snd_ad1816a_timer(chip, 0, &timer);
200 if (error < 0) {
201 snd_card_free(card);
202 return error;
203 }
204
198 if (mpu_port[dev] > 0) { 205 if (mpu_port[dev] > 0) {
199 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, 206 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
200 mpu_port[dev], 0, mpu_irq[dev], IRQF_DISABLED, 207 mpu_port[dev], 0, mpu_irq[dev], IRQF_DISABLED,
@@ -208,11 +215,8 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
208 OPL3_HW_AUTO, 0, &opl3) < 0) { 215 OPL3_HW_AUTO, 0, &opl3) < 0) {
209 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx.\n", fm_port[dev], fm_port[dev] + 2); 216 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx.\n", fm_port[dev], fm_port[dev] + 2);
210 } else { 217 } else {
211 if ((error = snd_opl3_timer_new(opl3, 1, 2)) < 0) { 218 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
212 snd_card_free(card); 219 if (error < 0) {
213 return error;
214 }
215 if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
216 snd_card_free(card); 220 snd_card_free(card);
217 return error; 221 return error;
218 } 222 }
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index 3bfca7c59baf..05aef8b97e96 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -37,7 +37,7 @@ static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip)
37 if (inb(AD1816A_REG(AD1816A_CHIP_STATUS)) & AD1816A_READY) 37 if (inb(AD1816A_REG(AD1816A_CHIP_STATUS)) & AD1816A_READY)
38 return 0; 38 return 0;
39 39
40 snd_printk("chip busy.\n"); 40 snd_printk(KERN_WARNING "chip busy.\n");
41 return -EBUSY; 41 return -EBUSY;
42} 42}
43 43
@@ -196,7 +196,7 @@ static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what,
196 spin_unlock(&chip->lock); 196 spin_unlock(&chip->lock);
197 break; 197 break;
198 default: 198 default:
199 snd_printk("invalid trigger mode 0x%x.\n", what); 199 snd_printk(KERN_WARNING "invalid trigger mode 0x%x.\n", what);
200 error = -EINVAL; 200 error = -EINVAL;
201 } 201 }
202 202
@@ -377,7 +377,6 @@ static struct snd_pcm_hardware snd_ad1816a_capture = {
377 .fifo_size = 0, 377 .fifo_size = 0,
378}; 378};
379 379
380#if 0 /* not used now */
381static int snd_ad1816a_timer_close(struct snd_timer *timer) 380static int snd_ad1816a_timer_close(struct snd_timer *timer)
382{ 381{
383 struct snd_ad1816a *chip = snd_timer_chip(timer); 382 struct snd_ad1816a *chip = snd_timer_chip(timer);
@@ -442,8 +441,6 @@ static struct snd_timer_hardware snd_ad1816a_timer_table = {
442 .start = snd_ad1816a_timer_start, 441 .start = snd_ad1816a_timer_start,
443 .stop = snd_ad1816a_timer_stop, 442 .stop = snd_ad1816a_timer_stop,
444}; 443};
445#endif /* not used now */
446
447 444
448static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream) 445static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream)
449{ 446{
@@ -568,7 +565,7 @@ static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip)
568 case AD1816A_HW_AD1815: return "AD1815"; 565 case AD1816A_HW_AD1815: return "AD1815";
569 case AD1816A_HW_AD18MAX10: return "AD18max10"; 566 case AD1816A_HW_AD18MAX10: return "AD18max10";
570 default: 567 default:
571 snd_printk("Unknown chip version %d:%d.\n", 568 snd_printk(KERN_WARNING "Unknown chip version %d:%d.\n",
572 chip->version, chip->hardware); 569 chip->version, chip->hardware);
573 return "AD1816A - unknown"; 570 return "AD1816A - unknown";
574 } 571 }
@@ -687,7 +684,6 @@ int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_p
687 return 0; 684 return 0;
688} 685}
689 686
690#if 0 /* not used now */
691int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer) 687int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer)
692{ 688{
693 struct snd_timer *timer; 689 struct snd_timer *timer;
@@ -709,7 +705,6 @@ int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd
709 *rtimer = timer; 705 *rtimer = timer;
710 return 0; 706 return 0;
711} 707}
712#endif /* not used now */
713 708
714/* 709/*
715 * 710 *
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 24e60902f8ca..de83608719ea 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -31,11 +31,11 @@
31 * To quickly load the module, 31 * To quickly load the module,
32 * 32 *
33 * modprobe -a snd-cmi8330 sbport=0x220 sbirq=5 sbdma8=1 33 * modprobe -a snd-cmi8330 sbport=0x220 sbirq=5 sbdma8=1
34 * sbdma16=5 wssport=0x530 wssirq=11 wssdma=0 34 * sbdma16=5 wssport=0x530 wssirq=11 wssdma=0 fmport=0x388
35 * 35 *
36 * This card has two mixers and two PCM devices. I've cheesed it such 36 * This card has two mixers and two PCM devices. I've cheesed it such
37 * that recording and playback can be done through the same device. 37 * that recording and playback can be done through the same device.
38 * The driver "magically" routes the capturing to the AD1848 codec, 38 * The driver "magically" routes the capturing to the CMI8330 codec,
39 * and playback to the SB16 codec. This allows for full-duplex mode 39 * and playback to the SB16 codec. This allows for full-duplex mode
40 * to some extent. 40 * to some extent.
41 * The utilities in alsa-utils are aware of both devices, so passing 41 * The utilities in alsa-utils are aware of both devices, so passing
@@ -51,6 +51,8 @@
51#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
52#include <sound/core.h> 52#include <sound/core.h>
53#include <sound/wss.h> 53#include <sound/wss.h>
54#include <sound/opl3.h>
55#include <sound/mpu401.h>
54#include <sound/sb.h> 56#include <sound/sb.h>
55#include <sound/initval.h> 57#include <sound/initval.h>
56 58
@@ -79,6 +81,9 @@ static int sbdma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
79static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 81static long wssport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
80static int wssirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; 82static int wssirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
81static int wssdma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; 83static int wssdma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
84static long fmport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
85static long mpuport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
86static int mpuirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
82 87
83module_param_array(index, int, NULL, 0444); 88module_param_array(index, int, NULL, 0444);
84MODULE_PARM_DESC(index, "Index value for CMI8330 soundcard."); 89MODULE_PARM_DESC(index, "Index value for CMI8330 soundcard.");
@@ -107,6 +112,12 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver.");
107module_param_array(wssdma, int, NULL, 0444); 112module_param_array(wssdma, int, NULL, 0444);
108MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 113MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
109 114
115module_param_array(fmport, long, NULL, 0444);
116MODULE_PARM_DESC(fmport, "FM port # for CMI8330 driver.");
117module_param_array(mpuport, long, NULL, 0444);
118MODULE_PARM_DESC(mpuport, "MPU-401 port # for CMI8330 driver.");
119module_param_array(mpuirq, int, NULL, 0444);
120MODULE_PARM_DESC(mpuirq, "IRQ # for CMI8330 MPU-401 port.");
110#ifdef CONFIG_PNP 121#ifdef CONFIG_PNP
111static int isa_registered; 122static int isa_registered;
112static int pnp_registered; 123static int pnp_registered;
@@ -149,6 +160,7 @@ struct snd_cmi8330 {
149#ifdef CONFIG_PNP 160#ifdef CONFIG_PNP
150 struct pnp_dev *cap; 161 struct pnp_dev *cap;
151 struct pnp_dev *play; 162 struct pnp_dev *play;
163 struct pnp_dev *mpu;
152#endif 164#endif
153 struct snd_card *card; 165 struct snd_card *card;
154 struct snd_wss *wss; 166 struct snd_wss *wss;
@@ -165,7 +177,7 @@ struct snd_cmi8330 {
165#ifdef CONFIG_PNP 177#ifdef CONFIG_PNP
166 178
167static struct pnp_card_device_id snd_cmi8330_pnpids[] = { 179static struct pnp_card_device_id snd_cmi8330_pnpids[] = {
168 { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" } } }, 180 { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } },
169 { .id = "" } 181 { .id = "" }
170}; 182};
171 183
@@ -219,8 +231,10 @@ WSS_SINGLE("3D Control - Switch", 0,
219 CMI8330_RMUX3D, 5, 1, 1), 231 CMI8330_RMUX3D, 5, 1, 1),
220WSS_SINGLE("PC Speaker Playback Volume", 0, 232WSS_SINGLE("PC Speaker Playback Volume", 0,
221 CMI8330_OUTPUTVOL, 3, 3, 0), 233 CMI8330_OUTPUTVOL, 3, 3, 0),
222WSS_SINGLE("FM Playback Switch", 0, 234WSS_DOUBLE("FM Playback Switch", 0,
223 CMI8330_RECMUX, 3, 1, 1), 235 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
236WSS_DOUBLE("FM Playback Volume", 0,
237 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
224WSS_SINGLE(SNDRV_CTL_NAME_IEC958("Input ", CAPTURE, SWITCH), 0, 238WSS_SINGLE(SNDRV_CTL_NAME_IEC958("Input ", CAPTURE, SWITCH), 0,
225 CMI8330_RMUX3D, 7, 1, 1), 239 CMI8330_RMUX3D, 7, 1, 1),
226WSS_SINGLE(SNDRV_CTL_NAME_IEC958("Input ", PLAYBACK, SWITCH), 0, 240WSS_SINGLE(SNDRV_CTL_NAME_IEC958("Input ", PLAYBACK, SWITCH), 0,
@@ -323,16 +337,21 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
323 if (acard->play == NULL) 337 if (acard->play == NULL)
324 return -EBUSY; 338 return -EBUSY;
325 339
340 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL);
341 if (acard->play == NULL)
342 return -EBUSY;
343
326 pdev = acard->cap; 344 pdev = acard->cap;
327 345
328 err = pnp_activate_dev(pdev); 346 err = pnp_activate_dev(pdev);
329 if (err < 0) { 347 if (err < 0) {
330 snd_printk(KERN_ERR "CMI8330/C3D (AD1848) PnP configure failure\n"); 348 snd_printk(KERN_ERR "CMI8330/C3D PnP configure failure\n");
331 return -EBUSY; 349 return -EBUSY;
332 } 350 }
333 wssport[dev] = pnp_port_start(pdev, 0); 351 wssport[dev] = pnp_port_start(pdev, 0);
334 wssdma[dev] = pnp_dma(pdev, 0); 352 wssdma[dev] = pnp_dma(pdev, 0);
335 wssirq[dev] = pnp_irq(pdev, 0); 353 wssirq[dev] = pnp_irq(pdev, 0);
354 fmport[dev] = pnp_port_start(pdev, 1);
336 355
337 /* allocate SB16 resources */ 356 /* allocate SB16 resources */
338 pdev = acard->play; 357 pdev = acard->play;
@@ -347,6 +366,17 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
347 sbdma16[dev] = pnp_dma(pdev, 1); 366 sbdma16[dev] = pnp_dma(pdev, 1);
348 sbirq[dev] = pnp_irq(pdev, 0); 367 sbirq[dev] = pnp_irq(pdev, 0);
349 368
369 /* allocate MPU-401 resources */
370 pdev = acard->mpu;
371
372 err = pnp_activate_dev(pdev);
373 if (err < 0) {
374 snd_printk(KERN_ERR
375 "CMI8330/C3D (MPU-401) PnP configure failure\n");
376 return -EBUSY;
377 }
378 mpuport[dev] = pnp_port_start(pdev, 0);
379 mpuirq[dev] = pnp_irq(pdev, 0);
350 return 0; 380 return 0;
351} 381}
352#endif 382#endif
@@ -489,6 +519,7 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
489{ 519{
490 struct snd_cmi8330 *acard; 520 struct snd_cmi8330 *acard;
491 int i, err; 521 int i, err;
522 struct snd_opl3 *opl3;
492 523
493 acard = card->private_data; 524 acard = card->private_data;
494 err = snd_wss_create(card, wssport[dev] + 4, -1, 525 err = snd_wss_create(card, wssport[dev] + 4, -1,
@@ -496,11 +527,11 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
496 wssdma[dev], -1, 527 wssdma[dev], -1,
497 WSS_HW_DETECT, 0, &acard->wss); 528 WSS_HW_DETECT, 0, &acard->wss);
498 if (err < 0) { 529 if (err < 0) {
499 snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); 530 snd_printk(KERN_ERR PFX "(CMI8330) device busy??\n");
500 return err; 531 return err;
501 } 532 }
502 if (acard->wss->hardware != WSS_HW_CMI8330) { 533 if (acard->wss->hardware != WSS_HW_CMI8330) {
503 snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); 534 snd_printk(KERN_ERR PFX "(CMI8330) not found during probe\n");
504 return -ENODEV; 535 return -ENODEV;
505 } 536 }
506 537
@@ -532,6 +563,27 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
532 snd_printk(KERN_ERR PFX "failed to create pcms\n"); 563 snd_printk(KERN_ERR PFX "failed to create pcms\n");
533 return err; 564 return err;
534 } 565 }
566 if (fmport[dev] != SNDRV_AUTO_PORT) {
567 if (snd_opl3_create(card,
568 fmport[dev], fmport[dev] + 2,
569 OPL3_HW_AUTO, 0, &opl3) < 0) {
570 snd_printk(KERN_ERR PFX
571 "no OPL device at 0x%lx-0x%lx ?\n",
572 fmport[dev], fmport[dev] + 2);
573 } else {
574 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
575 if (err < 0)
576 return err;
577 }
578 }
579
580 if (mpuport[dev] != SNDRV_AUTO_PORT) {
581 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
582 mpuport[dev], 0, mpuirq[dev],
583 IRQF_DISABLED, NULL) < 0)
584 printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n",
585 mpuport[dev]);
586 }
535 587
536 strcpy(card->driver, "CMI8330/C3D"); 588 strcpy(card->driver, "CMI8330/C3D");
537 strcpy(card->shortname, "C-Media CMI8330/C3D"); 589 strcpy(card->shortname, "C-Media CMI8330/C3D");
diff --git a/sound/isa/cs423x/Makefile b/sound/isa/cs423x/Makefile
index 5870ca21ab59..6d397e8d54ac 100644
--- a/sound/isa/cs423x/Makefile
+++ b/sound/isa/cs423x/Makefile
@@ -3,13 +3,11 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@perex.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6snd-cs4236-lib-objs := cs4236_lib.o
7snd-cs4231-objs := cs4231.o 6snd-cs4231-objs := cs4231.o
8snd-cs4232-objs := cs4232.o 7snd-cs4236-objs := cs4236.o cs4236_lib.o
9snd-cs4236-objs := cs4236.o
10 8
11# Toplevel Module Dependency 9# Toplevel Module Dependency
12obj-$(CONFIG_SND_CS4231) += snd-cs4231.o 10obj-$(CONFIG_SND_CS4231) += snd-cs4231.o
13obj-$(CONFIG_SND_CS4232) += snd-cs4232.o 11obj-$(CONFIG_SND_CS4236) += snd-cs4236.o
14obj-$(CONFIG_SND_CS4236) += snd-cs4236.o snd-cs4236-lib.o 12
15 13
diff --git a/sound/isa/cs423x/cs4232.c b/sound/isa/cs423x/cs4232.c
deleted file mode 100644
index 9fad2e6c0c2c..000000000000
--- a/sound/isa/cs423x/cs4232.c
+++ /dev/null
@@ -1,2 +0,0 @@
1#define CS4232
2#include "cs4236.c"
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index f7845986f467..a076a6ce8071 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -33,17 +33,14 @@
33 33
34MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 34MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36#ifdef CS4232 36MODULE_DESCRIPTION("Cirrus Logic CS4232-9");
37MODULE_DESCRIPTION("Cirrus Logic CS4232");
38MODULE_SUPPORTED_DEVICE("{{Turtle Beach,TBS-2000}," 37MODULE_SUPPORTED_DEVICE("{{Turtle Beach,TBS-2000},"
39 "{Turtle Beach,Tropez Plus}," 38 "{Turtle Beach,Tropez Plus},"
40 "{SIC CrystalWave 32}," 39 "{SIC CrystalWave 32},"
41 "{Hewlett Packard,Omnibook 5500}," 40 "{Hewlett Packard,Omnibook 5500},"
42 "{TerraTec,Maestro 32/96}," 41 "{TerraTec,Maestro 32/96},"
43 "{Philips,PCA70PS}}"); 42 "{Philips,PCA70PS}},"
44#else 43 "{{Crystal Semiconductors,CS4235},"
45MODULE_DESCRIPTION("Cirrus Logic CS4235-9");
46MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
47 "{Crystal Semiconductors,CS4236}," 44 "{Crystal Semiconductors,CS4236},"
48 "{Crystal Semiconductors,CS4237}," 45 "{Crystal Semiconductors,CS4237},"
49 "{Crystal Semiconductors,CS4238}," 46 "{Crystal Semiconductors,CS4238},"
@@ -70,15 +67,11 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
70 "{Typhoon Soundsystem,CS4236B}," 67 "{Typhoon Soundsystem,CS4236B},"
71 "{Turtle Beach,Malibu}," 68 "{Turtle Beach,Malibu},"
72 "{Unknown,Digital PC 5000 Onboard}}"); 69 "{Unknown,Digital PC 5000 Onboard}}");
73#endif
74 70
75#ifdef CS4232 71MODULE_ALIAS("snd_cs4232");
76#define IDENT "CS4232" 72
77#define DEV_NAME "cs4232" 73#define IDENT "CS4232+"
78#else 74#define DEV_NAME "cs4232+"
79#define IDENT "CS4236+"
80#define DEV_NAME "cs4236"
81#endif
82 75
83static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 76static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
84static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 77static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -128,9 +121,7 @@ MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
128#ifdef CONFIG_PNP 121#ifdef CONFIG_PNP
129static int isa_registered; 122static int isa_registered;
130static int pnpc_registered; 123static int pnpc_registered;
131#ifdef CS4232
132static int pnp_registered; 124static int pnp_registered;
133#endif
134#endif /* CONFIG_PNP */ 125#endif /* CONFIG_PNP */
135 126
136struct snd_card_cs4236 { 127struct snd_card_cs4236 {
@@ -145,11 +136,10 @@ struct snd_card_cs4236 {
145 136
146#ifdef CONFIG_PNP 137#ifdef CONFIG_PNP
147 138
148#ifdef CS4232
149/* 139/*
150 * PNP BIOS 140 * PNP BIOS
151 */ 141 */
152static const struct pnp_device_id snd_cs4232_pnpbiosids[] = { 142static const struct pnp_device_id snd_cs423x_pnpbiosids[] = {
153 { .id = "CSC0100" }, 143 { .id = "CSC0100" },
154 { .id = "CSC0000" }, 144 { .id = "CSC0000" },
155 /* Guillemot Turtlebeach something appears to be cs4232 compatible 145 /* Guillemot Turtlebeach something appears to be cs4232 compatible
@@ -157,10 +147,8 @@ static const struct pnp_device_id snd_cs4232_pnpbiosids[] = {
157 { .id = "GIM0100" }, 147 { .id = "GIM0100" },
158 { .id = "" } 148 { .id = "" }
159}; 149};
160MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids); 150MODULE_DEVICE_TABLE(pnp, snd_cs423x_pnpbiosids);
161#endif /* CS4232 */
162 151
163#ifdef CS4232
164#define CS423X_ISAPNP_DRIVER "cs4232_isapnp" 152#define CS423X_ISAPNP_DRIVER "cs4232_isapnp"
165static struct pnp_card_device_id snd_cs423x_pnpids[] = { 153static struct pnp_card_device_id snd_cs423x_pnpids[] = {
166 /* Philips PCA70PS */ 154 /* Philips PCA70PS */
@@ -179,12 +167,6 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = {
179 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 167 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
180 /* Netfinity 3000 on-board soundcard */ 168 /* Netfinity 3000 on-board soundcard */
181 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } }, 169 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } },
182 /* --- */
183 { .id = "" } /* end */
184};
185#else /* CS4236 */
186#define CS423X_ISAPNP_DRIVER "cs4236_isapnp"
187static struct pnp_card_device_id snd_cs423x_pnpids[] = {
188 /* Intel Marlin Spike Motherboard - CS4235 */ 170 /* Intel Marlin Spike Motherboard - CS4235 */
189 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 171 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
190 /* Intel Marlin Spike Motherboard (#2) - CS4235 */ 172 /* Intel Marlin Spike Motherboard (#2) - CS4235 */
@@ -266,7 +248,6 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = {
266 /* --- */ 248 /* --- */
267 { .id = "" } /* end */ 249 { .id = "" } /* end */
268}; 250};
269#endif
270 251
271MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); 252MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids);
272 253
@@ -323,17 +304,19 @@ static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
323 return 0; 304 return 0;
324} 305}
325 306
326#ifdef CS4232 307static int __devinit snd_card_cs423x_pnp(int dev, struct snd_card_cs4236 *acard,
327static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard, 308 struct pnp_dev *pdev,
328 struct pnp_dev *pdev) 309 struct pnp_dev *cdev)
329{ 310{
330 acard->wss = pdev; 311 acard->wss = pdev;
331 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0) 312 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
332 return -EBUSY; 313 return -EBUSY;
333 cport[dev] = -1; 314 if (cdev)
315 cport[dev] = pnp_port_start(cdev, 0);
316 else
317 cport[dev] = -1;
334 return 0; 318 return 0;
335} 319}
336#endif
337 320
338static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard, 321static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard,
339 struct pnp_card_link *card, 322 struct pnp_card_link *card,
@@ -411,40 +394,39 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
411 return -EBUSY; 394 return -EBUSY;
412 } 395 }
413 396
414#ifdef CS4232
415 err = snd_wss_create(card, port[dev], cport[dev], 397 err = snd_wss_create(card, port[dev], cport[dev],
416 irq[dev], 398 irq[dev],
417 dma1[dev], dma2[dev], 399 dma1[dev], dma2[dev],
418 WSS_HW_DETECT, 0, &chip); 400 WSS_HW_DETECT3, 0, &chip);
419 if (err < 0)
420 return err;
421 acard->chip = chip;
422
423 err = snd_wss_pcm(chip, 0, &pcm);
424 if (err < 0)
425 return err;
426
427 err = snd_wss_mixer(chip);
428 if (err < 0) 401 if (err < 0)
429 return err; 402 return err;
430 403 if (chip->hardware & WSS_HW_CS4236B_MASK) {
431#else /* CS4236 */ 404 snd_wss_free(chip);
432 err = snd_cs4236_create(card, 405 err = snd_cs4236_create(card,
433 port[dev], cport[dev], 406 port[dev], cport[dev],
434 irq[dev], dma1[dev], dma2[dev], 407 irq[dev], dma1[dev], dma2[dev],
435 WSS_HW_DETECT, 0, &chip); 408 WSS_HW_DETECT, 0, &chip);
436 if (err < 0) 409 if (err < 0)
437 return err; 410 return err;
438 acard->chip = chip; 411 acard->chip = chip;
439 412
440 err = snd_cs4236_pcm(chip, 0, &pcm); 413 err = snd_cs4236_pcm(chip, 0, &pcm);
441 if (err < 0) 414 if (err < 0)
442 return err; 415 return err;
443 416
444 err = snd_cs4236_mixer(chip); 417 err = snd_cs4236_mixer(chip);
445 if (err < 0) 418 if (err < 0)
446 return err; 419 return err;
447#endif 420 } else {
421 acard->chip = chip;
422 err = snd_wss_pcm(chip, 0, &pcm);
423 if (err < 0)
424 return err;
425
426 err = snd_wss_mixer(chip);
427 if (err < 0)
428 return err;
429 }
448 strcpy(card->driver, pcm->name); 430 strcpy(card->driver, pcm->name);
449 strcpy(card->shortname, pcm->name); 431 strcpy(card->shortname, pcm->name);
450 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", 432 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
@@ -579,13 +561,14 @@ static struct isa_driver cs423x_isa_driver = {
579 561
580 562
581#ifdef CONFIG_PNP 563#ifdef CONFIG_PNP
582#ifdef CS4232 564static int __devinit snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
583static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
584 const struct pnp_device_id *id) 565 const struct pnp_device_id *id)
585{ 566{
586 static int dev; 567 static int dev;
587 int err; 568 int err;
588 struct snd_card *card; 569 struct snd_card *card;
570 struct pnp_dev *cdev;
571 char cid[PNP_ID_LEN];
589 572
590 if (pnp_device_is_isapnp(pdev)) 573 if (pnp_device_is_isapnp(pdev))
591 return -ENOENT; /* we have another procedure - card */ 574 return -ENOENT; /* we have another procedure - card */
@@ -596,10 +579,19 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
596 if (dev >= SNDRV_CARDS) 579 if (dev >= SNDRV_CARDS)
597 return -ENODEV; 580 return -ENODEV;
598 581
582 /* prepare second id */
583 strcpy(cid, pdev->id[0].id);
584 cid[5] = '1';
585 cdev = NULL;
586 list_for_each_entry(cdev, &(pdev->protocol->devices), protocol_list) {
587 if (!strcmp(cdev->id[0].id, cid))
588 break;
589 }
599 err = snd_cs423x_card_new(dev, &card); 590 err = snd_cs423x_card_new(dev, &card);
600 if (err < 0) 591 if (err < 0)
601 return err; 592 return err;
602 if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) { 593 err = snd_card_cs423x_pnp(dev, card->private_data, pdev, cdev);
594 if (err < 0) {
603 printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n"); 595 printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n");
604 snd_card_free(card); 596 snd_card_free(card);
605 return err; 597 return err;
@@ -614,35 +606,34 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
614 return 0; 606 return 0;
615} 607}
616 608
617static void __devexit snd_cs4232_pnp_remove(struct pnp_dev * pdev) 609static void __devexit snd_cs423x_pnp_remove(struct pnp_dev *pdev)
618{ 610{
619 snd_card_free(pnp_get_drvdata(pdev)); 611 snd_card_free(pnp_get_drvdata(pdev));
620 pnp_set_drvdata(pdev, NULL); 612 pnp_set_drvdata(pdev, NULL);
621} 613}
622 614
623#ifdef CONFIG_PM 615#ifdef CONFIG_PM
624static int snd_cs4232_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) 616static int snd_cs423x_pnp_suspend(struct pnp_dev *pdev, pm_message_t state)
625{ 617{
626 return snd_cs423x_suspend(pnp_get_drvdata(pdev)); 618 return snd_cs423x_suspend(pnp_get_drvdata(pdev));
627} 619}
628 620
629static int snd_cs4232_pnp_resume(struct pnp_dev *pdev) 621static int snd_cs423x_pnp_resume(struct pnp_dev *pdev)
630{ 622{
631 return snd_cs423x_resume(pnp_get_drvdata(pdev)); 623 return snd_cs423x_resume(pnp_get_drvdata(pdev));
632} 624}
633#endif 625#endif
634 626
635static struct pnp_driver cs4232_pnp_driver = { 627static struct pnp_driver cs423x_pnp_driver = {
636 .name = "cs4232-pnpbios", 628 .name = "cs423x-pnpbios",
637 .id_table = snd_cs4232_pnpbiosids, 629 .id_table = snd_cs423x_pnpbiosids,
638 .probe = snd_cs4232_pnpbios_detect, 630 .probe = snd_cs423x_pnpbios_detect,
639 .remove = __devexit_p(snd_cs4232_pnp_remove), 631 .remove = __devexit_p(snd_cs423x_pnp_remove),
640#ifdef CONFIG_PM 632#ifdef CONFIG_PM
641 .suspend = snd_cs4232_pnp_suspend, 633 .suspend = snd_cs423x_pnp_suspend,
642 .resume = snd_cs4232_pnp_resume, 634 .resume = snd_cs423x_pnp_resume,
643#endif 635#endif
644}; 636};
645#endif /* CS4232 */
646 637
647static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard, 638static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
648 const struct pnp_card_device_id *pid) 639 const struct pnp_card_device_id *pid)
@@ -716,18 +707,14 @@ static int __init alsa_card_cs423x_init(void)
716#ifdef CONFIG_PNP 707#ifdef CONFIG_PNP
717 if (!err) 708 if (!err)
718 isa_registered = 1; 709 isa_registered = 1;
719#ifdef CS4232 710 err = pnp_register_driver(&cs423x_pnp_driver);
720 err = pnp_register_driver(&cs4232_pnp_driver);
721 if (!err) 711 if (!err)
722 pnp_registered = 1; 712 pnp_registered = 1;
723#endif
724 err = pnp_register_card_driver(&cs423x_pnpc_driver); 713 err = pnp_register_card_driver(&cs423x_pnpc_driver);
725 if (!err) 714 if (!err)
726 pnpc_registered = 1; 715 pnpc_registered = 1;
727#ifdef CS4232
728 if (pnp_registered) 716 if (pnp_registered)
729 err = 0; 717 err = 0;
730#endif
731 if (isa_registered) 718 if (isa_registered)
732 err = 0; 719 err = 0;
733#endif 720#endif
@@ -739,10 +726,8 @@ static void __exit alsa_card_cs423x_exit(void)
739#ifdef CONFIG_PNP 726#ifdef CONFIG_PNP
740 if (pnpc_registered) 727 if (pnpc_registered)
741 pnp_unregister_card_driver(&cs423x_pnpc_driver); 728 pnp_unregister_card_driver(&cs423x_pnpc_driver);
742#ifdef CS4232
743 if (pnp_registered) 729 if (pnp_registered)
744 pnp_unregister_driver(&cs4232_pnp_driver); 730 pnp_unregister_driver(&cs423x_pnp_driver);
745#endif
746 if (isa_registered) 731 if (isa_registered)
747#endif 732#endif
748 isa_unregister_driver(&cs423x_isa_driver); 733 isa_unregister_driver(&cs423x_isa_driver);
diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c
index 6a85fdc53b60..38835f31298b 100644
--- a/sound/isa/cs423x/cs4236_lib.c
+++ b/sound/isa/cs423x/cs4236_lib.c
@@ -88,10 +88,6 @@
88#include <sound/wss.h> 88#include <sound/wss.h>
89#include <sound/asoundef.h> 89#include <sound/asoundef.h>
90 90
91MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
92MODULE_DESCRIPTION("Routines for control of CS4235/4236B/4237B/4238B/4239 chips");
93MODULE_LICENSE("GPL");
94
95/* 91/*
96 * 92 *
97 */ 93 */
@@ -286,7 +282,8 @@ int snd_cs4236_create(struct snd_card *card,
286 if (hardware == WSS_HW_DETECT) 282 if (hardware == WSS_HW_DETECT)
287 hardware = WSS_HW_DETECT3; 283 hardware = WSS_HW_DETECT3;
288 if (cport < 0x100) { 284 if (cport < 0x100) {
289 snd_printk("please, specify control port for CS4236+ chips\n"); 285 snd_printk(KERN_ERR "please, specify control port "
286 "for CS4236+ chips\n");
290 return -ENODEV; 287 return -ENODEV;
291 } 288 }
292 err = snd_wss_create(card, port, cport, 289 err = snd_wss_create(card, port, cport,
@@ -295,7 +292,8 @@ int snd_cs4236_create(struct snd_card *card,
295 return err; 292 return err;
296 293
297 if (!(chip->hardware & WSS_HW_CS4236B_MASK)) { 294 if (!(chip->hardware & WSS_HW_CS4236B_MASK)) {
298 snd_printk("CS4236+: MODE3 and extended registers not available, hardware=0x%x\n",chip->hardware); 295 snd_printk(KERN_ERR "CS4236+: MODE3 and extended registers "
296 "not available, hardware=0x%x\n", chip->hardware);
299 snd_device_free(card, chip); 297 snd_device_free(card, chip);
300 return -ENODEV; 298 return -ENODEV;
301 } 299 }
@@ -303,16 +301,19 @@ int snd_cs4236_create(struct snd_card *card,
303 { 301 {
304 int idx; 302 int idx;
305 for (idx = 0; idx < 8; idx++) 303 for (idx = 0; idx < 8; idx++)
306 snd_printk("CD%i = 0x%x\n", idx, inb(chip->cport + idx)); 304 snd_printk(KERN_DEBUG "CD%i = 0x%x\n",
305 idx, inb(chip->cport + idx));
307 for (idx = 0; idx < 9; idx++) 306 for (idx = 0; idx < 9; idx++)
308 snd_printk("C%i = 0x%x\n", idx, snd_cs4236_ctrl_in(chip, idx)); 307 snd_printk(KERN_DEBUG "C%i = 0x%x\n",
308 idx, snd_cs4236_ctrl_in(chip, idx));
309 } 309 }
310#endif 310#endif
311 ver1 = snd_cs4236_ctrl_in(chip, 1); 311 ver1 = snd_cs4236_ctrl_in(chip, 1);
312 ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION); 312 ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION);
313 snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n", cport, ver1, ver2); 313 snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n", cport, ver1, ver2);
314 if (ver1 != ver2) { 314 if (ver1 != ver2) {
315 snd_printk("CS4236+ chip detected, but control port 0x%lx is not valid\n", cport); 315 snd_printk(KERN_ERR "CS4236+ chip detected, but "
316 "control port 0x%lx is not valid\n", cport);
316 snd_device_free(card, chip); 317 snd_device_free(card, chip);
317 return -ENODEV; 318 return -ENODEV;
318 } 319 }
@@ -883,7 +884,8 @@ static int snd_cs4236_get_iec958_switch(struct snd_kcontrol *kcontrol, struct sn
883 spin_lock_irqsave(&chip->reg_lock, flags); 884 spin_lock_irqsave(&chip->reg_lock, flags);
884 ucontrol->value.integer.value[0] = chip->image[CS4231_ALT_FEATURE_1] & 0x02 ? 1 : 0; 885 ucontrol->value.integer.value[0] = chip->image[CS4231_ALT_FEATURE_1] & 0x02 ? 1 : 0;
885#if 0 886#if 0
886 printk("get valid: ALT = 0x%x, C3 = 0x%x, C4 = 0x%x, C5 = 0x%x, C6 = 0x%x, C8 = 0x%x\n", 887 printk(KERN_DEBUG "get valid: ALT = 0x%x, C3 = 0x%x, C4 = 0x%x, "
888 "C5 = 0x%x, C6 = 0x%x, C8 = 0x%x\n",
887 snd_wss_in(chip, CS4231_ALT_FEATURE_1), 889 snd_wss_in(chip, CS4231_ALT_FEATURE_1),
888 snd_cs4236_ctrl_in(chip, 3), 890 snd_cs4236_ctrl_in(chip, 3),
889 snd_cs4236_ctrl_in(chip, 4), 891 snd_cs4236_ctrl_in(chip, 4),
@@ -920,7 +922,8 @@ static int snd_cs4236_put_iec958_switch(struct snd_kcontrol *kcontrol, struct sn
920 mutex_unlock(&chip->mce_mutex); 922 mutex_unlock(&chip->mce_mutex);
921 923
922#if 0 924#if 0
923 printk("set valid: ALT = 0x%x, C3 = 0x%x, C4 = 0x%x, C5 = 0x%x, C6 = 0x%x, C8 = 0x%x\n", 925 printk(KERN_DEBUG "set valid: ALT = 0x%x, C3 = 0x%x, C4 = 0x%x, "
926 "C5 = 0x%x, C6 = 0x%x, C8 = 0x%x\n",
924 snd_wss_in(chip, CS4231_ALT_FEATURE_1), 927 snd_wss_in(chip, CS4231_ALT_FEATURE_1),
925 snd_cs4236_ctrl_in(chip, 3), 928 snd_cs4236_ctrl_in(chip, 3),
926 snd_cs4236_ctrl_in(chip, 4), 929 snd_cs4236_ctrl_in(chip, 4),
@@ -1015,23 +1018,3 @@ int snd_cs4236_mixer(struct snd_wss *chip)
1015 } 1018 }
1016 return 0; 1019 return 0;
1017} 1020}
1018
1019EXPORT_SYMBOL(snd_cs4236_create);
1020EXPORT_SYMBOL(snd_cs4236_pcm);
1021EXPORT_SYMBOL(snd_cs4236_mixer);
1022
1023/*
1024 * INIT part
1025 */
1026
1027static int __init alsa_cs4236_init(void)
1028{
1029 return 0;
1030}
1031
1032static void __exit alsa_cs4236_exit(void)
1033{
1034}
1035
1036module_init(alsa_cs4236_init)
1037module_exit(alsa_cs4236_exit)
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index d746750410ea..442b081cafb7 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -49,6 +49,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
51static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 51static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
52static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* Usually 0x388 */
52static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 53static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
53static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */ 54static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
54static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */ 55static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
@@ -65,6 +66,8 @@ MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
65module_param_array(mpu_port, long, NULL, 0444); 66module_param_array(mpu_port, long, NULL, 0444);
66MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver."); 67MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
67module_param_array(irq, int, NULL, 0444); 68module_param_array(irq, int, NULL, 0444);
69module_param_array(fm_port, long, NULL, 0444);
70MODULE_PARM_DESC(fm_port, "FM port # for ES1688 driver.");
68MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); 71MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
69module_param_array(mpu_irq, int, NULL, 0444); 72module_param_array(mpu_irq, int, NULL, 0444);
70MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver."); 73MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
@@ -143,13 +146,19 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
143 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, 146 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
144 chip->port, chip->irq, chip->dma8); 147 chip->port, chip->irq, chip->dma8);
145 148
146 if (snd_opl3_create(card, chip->port, chip->port + 2, 149 if (fm_port[n] == SNDRV_AUTO_PORT)
147 OPL3_HW_OPL3, 0, &opl3) < 0) 150 fm_port[n] = port[n]; /* share the same port */
148 dev_warn(dev, "opl3 not detected at 0x%lx\n", chip->port); 151
149 else { 152 if (fm_port[n] > 0) {
150 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 153 if (snd_opl3_create(card, fm_port[n], fm_port[n] + 2,
151 if (error < 0) 154 OPL3_HW_OPL3, 0, &opl3) < 0)
152 goto out; 155 dev_warn(dev,
156 "opl3 not detected at 0x%lx\n", fm_port[n]);
157 else {
158 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
159 if (error < 0)
160 goto out;
161 }
153 } 162 }
154 163
155 if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ && 164 if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ &&
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 4fbb508a817f..4c6e14f87f2d 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -45,7 +45,7 @@ static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val)
45 return 1; 45 return 1;
46 } 46 }
47#ifdef CONFIG_SND_DEBUG 47#ifdef CONFIG_SND_DEBUG
48 printk("snd_es1688_dsp_command: timeout (0x%x)\n", val); 48 printk(KERN_DEBUG "snd_es1688_dsp_command: timeout (0x%x)\n", val);
49#endif 49#endif
50 return 0; 50 return 0;
51} 51}
@@ -167,13 +167,16 @@ static int snd_es1688_probe(struct snd_es1688 *chip)
167 hw = ES1688_HW_AUTO; 167 hw = ES1688_HW_AUTO;
168 switch (chip->version & 0xfff0) { 168 switch (chip->version & 0xfff0) {
169 case 0x4880: 169 case 0x4880:
170 snd_printk("[0x%lx] ESS: AudioDrive ES488 detected, but driver is in another place\n", chip->port); 170 snd_printk(KERN_ERR "[0x%lx] ESS: AudioDrive ES488 detected, "
171 "but driver is in another place\n", chip->port);
171 return -ENODEV; 172 return -ENODEV;
172 case 0x6880: 173 case 0x6880:
173 hw = (chip->version & 0x0f) >= 8 ? ES1688_HW_1688 : ES1688_HW_688; 174 hw = (chip->version & 0x0f) >= 8 ? ES1688_HW_1688 : ES1688_HW_688;
174 break; 175 break;
175 default: 176 default:
176 snd_printk("[0x%lx] ESS: unknown AudioDrive chip with version 0x%x (Jazz16 soundcard?)\n", chip->port, chip->version); 177 snd_printk(KERN_ERR "[0x%lx] ESS: unknown AudioDrive chip "
178 "with version 0x%x (Jazz16 soundcard?)\n",
179 chip->port, chip->version);
177 return -ENODEV; 180 return -ENODEV;
178 } 181 }
179 182
@@ -223,7 +226,7 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
223 } 226 }
224 } 227 }
225#if 0 228#if 0
226 snd_printk("mpu cfg = 0x%x\n", cfg); 229 snd_printk(KERN_DEBUG "mpu cfg = 0x%x\n", cfg);
227#endif 230#endif
228 spin_lock_irqsave(&chip->reg_lock, flags); 231 spin_lock_irqsave(&chip->reg_lock, flags);
229 snd_es1688_mixer_write(chip, 0x40, cfg); 232 snd_es1688_mixer_write(chip, 0x40, cfg);
@@ -237,7 +240,9 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
237 cfg = 0xf0; /* enable only DMA counter interrupt */ 240 cfg = 0xf0; /* enable only DMA counter interrupt */
238 irq_bits = irqs[chip->irq & 0x0f]; 241 irq_bits = irqs[chip->irq & 0x0f];
239 if (irq_bits < 0) { 242 if (irq_bits < 0) {
240 snd_printk("[0x%lx] ESS: bad IRQ %d for ES1688 chip!!\n", chip->port, chip->irq); 243 snd_printk(KERN_ERR "[0x%lx] ESS: bad IRQ %d "
244 "for ES1688 chip!!\n",
245 chip->port, chip->irq);
241#if 0 246#if 0
242 irq_bits = 0; 247 irq_bits = 0;
243 cfg = 0x10; 248 cfg = 0x10;
@@ -250,7 +255,8 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
250 cfg = 0xf0; /* extended mode DMA enable */ 255 cfg = 0xf0; /* extended mode DMA enable */
251 dma = chip->dma8; 256 dma = chip->dma8;
252 if (dma > 3 || dma == 2) { 257 if (dma > 3 || dma == 2) {
253 snd_printk("[0x%lx] ESS: bad DMA channel %d for ES1688 chip!!\n", chip->port, dma); 258 snd_printk(KERN_ERR "[0x%lx] ESS: bad DMA channel %d "
259 "for ES1688 chip!!\n", chip->port, dma);
254#if 0 260#if 0
255 dma_bits = 0; 261 dma_bits = 0;
256 cfg = 0x00; /* disable all DMA */ 262 cfg = 0x00; /* disable all DMA */
@@ -341,8 +347,9 @@ static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char va
341 return -EINVAL; /* something is wrong */ 347 return -EINVAL; /* something is wrong */
342 } 348 }
343#if 0 349#if 0
344 printk("trigger: val = 0x%x, value = 0x%x\n", val, value); 350 printk(KERN_DEBUG "trigger: val = 0x%x, value = 0x%x\n", val, value);
345 printk("trigger: pointer = 0x%x\n", snd_dma_pointer(chip->dma8, chip->dma_size)); 351 printk(KERN_DEBUG "trigger: pointer = 0x%x\n",
352 snd_dma_pointer(chip->dma8, chip->dma_size));
346#endif 353#endif
347 snd_es1688_write(chip, 0xb8, (val & 0xf0) | value); 354 snd_es1688_write(chip, 0xb8, (val & 0xf0) | value);
348 spin_unlock(&chip->reg_lock); 355 spin_unlock(&chip->reg_lock);
diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
index f45f6116c77a..36c27c832360 100644
--- a/sound/isa/gus/gus_dma.c
+++ b/sound/isa/gus/gus_dma.c
@@ -45,7 +45,8 @@ static void snd_gf1_dma_program(struct snd_gus_card * gus,
45 unsigned char dma_cmd; 45 unsigned char dma_cmd;
46 unsigned int address_high; 46 unsigned int address_high;
47 47
48 // snd_printk("dma_transfer: addr=0x%x, buf=0x%lx, count=0x%x\n", addr, (long) buf, count); 48 snd_printdd("dma_transfer: addr=0x%x, buf=0x%lx, count=0x%x\n",
49 addr, buf_addr, count);
49 50
50 if (gus->gf1.dma1 > 3) { 51 if (gus->gf1.dma1 > 3) {
51 if (gus->gf1.enh_mode) { 52 if (gus->gf1.enh_mode) {
@@ -77,7 +78,8 @@ static void snd_gf1_dma_program(struct snd_gus_card * gus,
77 snd_gf1_dma_ack(gus); 78 snd_gf1_dma_ack(gus);
78 snd_dma_program(gus->gf1.dma1, buf_addr, count, dma_cmd & SNDRV_GF1_DMA_READ ? DMA_MODE_READ : DMA_MODE_WRITE); 79 snd_dma_program(gus->gf1.dma1, buf_addr, count, dma_cmd & SNDRV_GF1_DMA_READ ? DMA_MODE_READ : DMA_MODE_WRITE);
79#if 0 80#if 0
80 snd_printk("address = 0x%x, count = 0x%x, dma_cmd = 0x%x\n", address << 1, count, dma_cmd); 81 snd_printk(KERN_DEBUG "address = 0x%x, count = 0x%x, dma_cmd = 0x%x\n",
82 address << 1, count, dma_cmd);
81#endif 83#endif
82 spin_lock_irqsave(&gus->reg_lock, flags); 84 spin_lock_irqsave(&gus->reg_lock, flags);
83 if (gus->gf1.enh_mode) { 85 if (gus->gf1.enh_mode) {
@@ -142,7 +144,9 @@ static void snd_gf1_dma_interrupt(struct snd_gus_card * gus)
142 snd_gf1_dma_program(gus, block->addr, block->buf_addr, block->count, (unsigned short) block->cmd); 144 snd_gf1_dma_program(gus, block->addr, block->buf_addr, block->count, (unsigned short) block->cmd);
143 kfree(block); 145 kfree(block);
144#if 0 146#if 0
145 printk("program dma (IRQ) - addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n", addr, (long) buffer, count, cmd); 147 snd_printd(KERN_DEBUG "program dma (IRQ) - "
148 "addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n",
149 block->addr, block->buf_addr, block->count, block->cmd);
146#endif 150#endif
147} 151}
148 152
@@ -203,13 +207,16 @@ int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
203 } 207 }
204 *block = *__block; 208 *block = *__block;
205 block->next = NULL; 209 block->next = NULL;
206#if 0 210
207 printk("addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n", block->addr, (long) block->buffer, block->count, block->cmd); 211 snd_printdd("addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n",
208#endif 212 block->addr, (long) block->buffer, block->count,
209#if 0 213 block->cmd);
210 printk("gus->gf1.dma_data_pcm_last = 0x%lx\n", (long)gus->gf1.dma_data_pcm_last); 214
211 printk("gus->gf1.dma_data_pcm = 0x%lx\n", (long)gus->gf1.dma_data_pcm); 215 snd_printdd("gus->gf1.dma_data_pcm_last = 0x%lx\n",
212#endif 216 (long)gus->gf1.dma_data_pcm_last);
217 snd_printdd("gus->gf1.dma_data_pcm = 0x%lx\n",
218 (long)gus->gf1.dma_data_pcm);
219
213 spin_lock_irqsave(&gus->dma_lock, flags); 220 spin_lock_irqsave(&gus->dma_lock, flags);
214 if (synth) { 221 if (synth) {
215 if (gus->gf1.dma_data_synth_last) { 222 if (gus->gf1.dma_data_synth_last) {
diff --git a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c
index 041894ddd014..2055aff71b50 100644
--- a/sound/isa/gus/gus_irq.c
+++ b/sound/isa/gus/gus_irq.c
@@ -41,7 +41,7 @@ __again:
41 if (status == 0) 41 if (status == 0)
42 return IRQ_RETVAL(handled); 42 return IRQ_RETVAL(handled);
43 handled = 1; 43 handled = 1;
44 // snd_printk("IRQ: status = 0x%x\n", status); 44 /* snd_printk(KERN_DEBUG "IRQ: status = 0x%x\n", status); */
45 if (status & 0x02) { 45 if (status & 0x02) {
46 STAT_ADD(gus->gf1.interrupt_stat_midi_in); 46 STAT_ADD(gus->gf1.interrupt_stat_midi_in);
47 if (gus->gf1.interrupt_handler_midi_in) 47 if (gus->gf1.interrupt_handler_midi_in)
@@ -65,7 +65,9 @@ __again:
65 continue; /* multi request */ 65 continue; /* multi request */
66 already |= _current_; /* mark request */ 66 already |= _current_; /* mark request */
67#if 0 67#if 0
68 printk("voice = %i, voice_status = 0x%x, voice_verify = %i\n", voice, voice_status, inb(GUSP(gus, GF1PAGE))); 68 printk(KERN_DEBUG "voice = %i, voice_status = 0x%x, "
69 "voice_verify = %i\n",
70 voice, voice_status, inb(GUSP(gus, GF1PAGE)));
69#endif 71#endif
70 pvoice = &gus->gf1.voices[voice]; 72 pvoice = &gus->gf1.voices[voice];
71 if (pvoice->use) { 73 if (pvoice->use) {
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index 38510aeb21c6..edb11eefdfe3 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -82,7 +82,10 @@ static int snd_gf1_pcm_block_change(struct snd_pcm_substream *substream,
82 82
83 count += offset & 31; 83 count += offset & 31;
84 offset &= ~31; 84 offset &= ~31;
85 // snd_printk("block change - offset = 0x%x, count = 0x%x\n", offset, count); 85 /*
86 snd_printk(KERN_DEBUG "block change - offset = 0x%x, count = 0x%x\n",
87 offset, count);
88 */
86 memset(&block, 0, sizeof(block)); 89 memset(&block, 0, sizeof(block));
87 block.cmd = SNDRV_GF1_DMA_IRQ; 90 block.cmd = SNDRV_GF1_DMA_IRQ;
88 if (snd_pcm_format_unsigned(runtime->format)) 91 if (snd_pcm_format_unsigned(runtime->format))
@@ -135,7 +138,11 @@ static void snd_gf1_pcm_trigger_up(struct snd_pcm_substream *substream)
135 curr = begin + (pcmp->bpos * pcmp->block_size) / runtime->channels; 138 curr = begin + (pcmp->bpos * pcmp->block_size) / runtime->channels;
136 end = curr + (pcmp->block_size / runtime->channels); 139 end = curr + (pcmp->block_size / runtime->channels);
137 end -= snd_pcm_format_width(runtime->format) == 16 ? 2 : 1; 140 end -= snd_pcm_format_width(runtime->format) == 16 ? 2 : 1;
138 // snd_printk("init: curr=0x%x, begin=0x%x, end=0x%x, ctrl=0x%x, ramp=0x%x, rate=0x%x\n", curr, begin, end, voice_ctrl, ramp_ctrl, rate); 141 /*
142 snd_printk(KERN_DEBUG "init: curr=0x%x, begin=0x%x, end=0x%x, "
143 "ctrl=0x%x, ramp=0x%x, rate=0x%x\n",
144 curr, begin, end, voice_ctrl, ramp_ctrl, rate);
145 */
139 pan = runtime->channels == 2 ? (!voice ? 1 : 14) : 8; 146 pan = runtime->channels == 2 ? (!voice ? 1 : 14) : 8;
140 vol = !voice ? gus->gf1.pcm_volume_level_left : gus->gf1.pcm_volume_level_right; 147 vol = !voice ? gus->gf1.pcm_volume_level_left : gus->gf1.pcm_volume_level_right;
141 spin_lock_irqsave(&gus->reg_lock, flags); 148 spin_lock_irqsave(&gus->reg_lock, flags);
@@ -205,9 +212,11 @@ static void snd_gf1_pcm_interrupt_wave(struct snd_gus_card * gus,
205 ramp_ctrl = (snd_gf1_read8(gus, SNDRV_GF1_VB_VOLUME_CONTROL) & ~0xa4) | 0x03; 212 ramp_ctrl = (snd_gf1_read8(gus, SNDRV_GF1_VB_VOLUME_CONTROL) & ~0xa4) | 0x03;
206#if 0 213#if 0
207 snd_gf1_select_voice(gus, pvoice->number); 214 snd_gf1_select_voice(gus, pvoice->number);
208 printk("position = 0x%x\n", (snd_gf1_read_addr(gus, SNDRV_GF1_VA_CURRENT, voice_ctrl & 4) >> 4)); 215 printk(KERN_DEBUG "position = 0x%x\n",
216 (snd_gf1_read_addr(gus, SNDRV_GF1_VA_CURRENT, voice_ctrl & 4) >> 4));
209 snd_gf1_select_voice(gus, pcmp->pvoices[1]->number); 217 snd_gf1_select_voice(gus, pcmp->pvoices[1]->number);
210 printk("position = 0x%x\n", (snd_gf1_read_addr(gus, SNDRV_GF1_VA_CURRENT, voice_ctrl & 4) >> 4)); 218 printk(KERN_DEBUG "position = 0x%x\n",
219 (snd_gf1_read_addr(gus, SNDRV_GF1_VA_CURRENT, voice_ctrl & 4) >> 4));
211 snd_gf1_select_voice(gus, pvoice->number); 220 snd_gf1_select_voice(gus, pvoice->number);
212#endif 221#endif
213 pcmp->bpos++; 222 pcmp->bpos++;
@@ -299,7 +308,11 @@ static int snd_gf1_pcm_poke_block(struct snd_gus_card *gus, unsigned char *buf,
299 unsigned int len; 308 unsigned int len;
300 unsigned long flags; 309 unsigned long flags;
301 310
302 // printk("poke block; buf = 0x%x, pos = %i, count = %i, port = 0x%x\n", (int)buf, pos, count, gus->gf1.port); 311 /*
312 printk(KERN_DEBUG
313 "poke block; buf = 0x%x, pos = %i, count = %i, port = 0x%x\n",
314 (int)buf, pos, count, gus->gf1.port);
315 */
303 while (count > 0) { 316 while (count > 0) {
304 len = count; 317 len = count;
305 if (len > 512) /* limit, to allow IRQ */ 318 if (len > 512) /* limit, to allow IRQ */
@@ -680,7 +693,8 @@ static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream)
680 runtime->private_free = snd_gf1_pcm_playback_free; 693 runtime->private_free = snd_gf1_pcm_playback_free;
681 694
682#if 0 695#if 0
683 printk("playback.buffer = 0x%lx, gf1.pcm_buffer = 0x%lx\n", (long) pcm->playback.buffer, (long) gus->gf1.pcm_buffer); 696 printk(KERN_DEBUG "playback.buffer = 0x%lx, gf1.pcm_buffer = 0x%lx\n",
697 (long) pcm->playback.buffer, (long) gus->gf1.pcm_buffer);
684#endif 698#endif
685 if ((err = snd_gf1_dma_init(gus)) < 0) 699 if ((err = snd_gf1_dma_init(gus)) < 0)
686 return err; 700 return err;
diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c
index f0af3f79b08b..21cc42e4c4be 100644
--- a/sound/isa/gus/gus_uart.c
+++ b/sound/isa/gus/gus_uart.c
@@ -129,8 +129,14 @@ static int snd_gf1_uart_input_open(struct snd_rawmidi_substream *substream)
129 } 129 }
130 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); 130 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags);
131#if 0 131#if 0
132 snd_printk("read init - enable = %i, cmd = 0x%x, stat = 0x%x\n", gus->uart_enable, gus->gf1.uart_cmd, snd_gf1_uart_stat(gus)); 132 snd_printk(KERN_DEBUG
133 snd_printk("[0x%x] reg (ctrl/status) = 0x%x, reg (data) = 0x%x (page = 0x%x)\n", gus->gf1.port + 0x100, inb(gus->gf1.port + 0x100), inb(gus->gf1.port + 0x101), inb(gus->gf1.port + 0x102)); 133 "read init - enable = %i, cmd = 0x%x, stat = 0x%x\n",
134 gus->uart_enable, gus->gf1.uart_cmd, snd_gf1_uart_stat(gus));
135 snd_printk(KERN_DEBUG
136 "[0x%x] reg (ctrl/status) = 0x%x, reg (data) = 0x%x "
137 "(page = 0x%x)\n",
138 gus->gf1.port + 0x100, inb(gus->gf1.port + 0x100),
139 inb(gus->gf1.port + 0x101), inb(gus->gf1.port + 0x102));
134#endif 140#endif
135 return 0; 141 return 0;
136} 142}
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 50e429a120da..534a6eced2b8 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -170,7 +170,7 @@ static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int da
170 unsigned long port = bus->private_value; 170 unsigned long port = bus->private_value;
171 171
172#if 0 172#if 0
173 printk("i2c_setlines - 0x%lx <- %i,%i\n", port, ctrl, data); 173 printk(KERN_DEBUG "i2c_setlines - 0x%lx <- %i,%i\n", port, ctrl, data);
174#endif 174#endif
175 outb((data << 1) | ctrl, port); 175 outb((data << 1) | ctrl, port);
176 udelay(10); 176 udelay(10);
@@ -183,7 +183,7 @@ static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus)
183 183
184 res = inb(port) & 1; 184 res = inb(port) & 1;
185#if 0 185#if 0
186 printk("i2c_getclockline - 0x%lx -> %i\n", port, res); 186 printk(KERN_DEBUG "i2c_getclockline - 0x%lx -> %i\n", port, res);
187#endif 187#endif
188 return res; 188 return res;
189} 189}
@@ -197,7 +197,7 @@ static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack)
197 udelay(10); 197 udelay(10);
198 res = (inb(port) & 2) >> 1; 198 res = (inb(port) & 2) >> 1;
199#if 0 199#if 0
200 printk("i2c_getdataline - 0x%lx -> %i\n", port, res); 200 printk(KERN_DEBUG "i2c_getdataline - 0x%lx -> %i\n", port, res);
201#endif 201#endif
202 return res; 202 return res;
203} 203}
@@ -342,7 +342,8 @@ static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *s
342 snd_gf1_poke(gus, local, d); 342 snd_gf1_poke(gus, local, d);
343 snd_gf1_poke(gus, local + 1, d + 1); 343 snd_gf1_poke(gus, local + 1, d + 1);
344#if 0 344#if 0
345 printk("d = 0x%x, local = 0x%x, local + 1 = 0x%x, idx << 22 = 0x%x\n", 345 printk(KERN_DEBUG "d = 0x%x, local = 0x%x, "
346 "local + 1 = 0x%x, idx << 22 = 0x%x\n",
346 d, 347 d,
347 snd_gf1_peek(gus, local), 348 snd_gf1_peek(gus, local),
348 snd_gf1_peek(gus, local + 1), 349 snd_gf1_peek(gus, local + 1),
@@ -356,7 +357,8 @@ static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *s
356 } 357 }
357 } 358 }
358#if 0 359#if 0
359 printk("sizes: %i %i %i %i\n", sizes[0], sizes[1], sizes[2], sizes[3]); 360 printk(KERN_DEBUG "sizes: %i %i %i %i\n",
361 sizes[0], sizes[1], sizes[2], sizes[3]);
360#endif 362#endif
361} 363}
362 364
@@ -410,12 +412,12 @@ static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus)
410 lmct = (psizes[3] << 24) | (psizes[2] << 16) | 412 lmct = (psizes[3] << 24) | (psizes[2] << 16) |
411 (psizes[1] << 8) | psizes[0]; 413 (psizes[1] << 8) | psizes[0];
412#if 0 414#if 0
413 printk("lmct = 0x%08x\n", lmct); 415 printk(KERN_DEBUG "lmct = 0x%08x\n", lmct);
414#endif 416#endif
415 for (i = 0; i < ARRAY_SIZE(lmc); i++) 417 for (i = 0; i < ARRAY_SIZE(lmc); i++)
416 if (lmct == lmc[i]) { 418 if (lmct == lmc[i]) {
417#if 0 419#if 0
418 printk("found !!! %i\n", i); 420 printk(KERN_DEBUG "found !!! %i\n", i);
419#endif 421#endif
420 snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | i); 422 snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | i);
421 snd_interwave_bank_sizes(gus, psizes); 423 snd_interwave_bank_sizes(gus, psizes);
diff --git a/sound/isa/msnd/Makefile b/sound/isa/msnd/Makefile
new file mode 100644
index 000000000000..2171c0aa2f62
--- /dev/null
+++ b/sound/isa/msnd/Makefile
@@ -0,0 +1,9 @@
1
2snd-msnd-lib-objs := msnd.o msnd_midi.o msnd_pinnacle_mixer.o
3snd-msnd-pinnacle-objs := msnd_pinnacle.o
4snd-msnd-classic-objs := msnd_classic.o
5
6# Toplevel Module Dependency
7obj-$(CONFIG_SND_MSND_PINNACLE) += snd-msnd-pinnacle.o snd-msnd-lib.o
8obj-$(CONFIG_SND_MSND_CLASSIC) += snd-msnd-classic.o snd-msnd-lib.o
9
diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c
new file mode 100644
index 000000000000..3a1526ae1729
--- /dev/null
+++ b/sound/isa/msnd/msnd.c
@@ -0,0 +1,707 @@
1/*********************************************************************
2 *
3 * 2002/06/30 Karsten Wiese:
4 * removed kernel-version dependencies.
5 * ripped from linux kernel 2.4.18 (OSS Implementation) by me.
6 * In the OSS Version, this file is compiled to a separate MODULE,
7 * that is used by the pinnacle and the classic driver.
8 * since there is no classic driver for alsa yet (i dont have a classic
9 * & writing one blindfold is difficult) this file's object is statically
10 * linked into the pinnacle-driver-module for now. look for the string
11 * "uncomment this to make this a module again"
12 * to do guess what.
13 *
14 * the following is a copy of the 2.4.18 OSS FREE file-heading comment:
15 *
16 * msnd.c - Driver Base
17 *
18 * Turtle Beach MultiSound Sound Card Driver for Linux
19 *
20 * Copyright (C) 1998 Andrew Veliath
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *
36 ********************************************************************/
37
38#include <linux/kernel.h>
39#include <linux/types.h>
40#include <linux/interrupt.h>
41#include <linux/io.h>
42#include <linux/fs.h>
43#include <linux/delay.h>
44
45#include <sound/core.h>
46#include <sound/initval.h>
47#include <sound/pcm.h>
48#include <sound/pcm_params.h>
49
50#include "msnd.h"
51
52#define LOGNAME "msnd"
53
54
55void snd_msnd_init_queue(void *base, int start, int size)
56{
57 writew(PCTODSP_BASED(start), base + JQS_wStart);
58 writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize);
59 writew(0, base + JQS_wHead);
60 writew(0, base + JQS_wTail);
61}
62EXPORT_SYMBOL(snd_msnd_init_queue);
63
64static int snd_msnd_wait_TXDE(struct snd_msnd *dev)
65{
66 unsigned int io = dev->io;
67 int timeout = 1000;
68
69 while (timeout-- > 0)
70 if (inb(io + HP_ISR) & HPISR_TXDE)
71 return 0;
72
73 return -EIO;
74}
75
76static int snd_msnd_wait_HC0(struct snd_msnd *dev)
77{
78 unsigned int io = dev->io;
79 int timeout = 1000;
80
81 while (timeout-- > 0)
82 if (!(inb(io + HP_CVR) & HPCVR_HC))
83 return 0;
84
85 return -EIO;
86}
87
88int snd_msnd_send_dsp_cmd(struct snd_msnd *dev, u8 cmd)
89{
90 unsigned long flags;
91
92 spin_lock_irqsave(&dev->lock, flags);
93 if (snd_msnd_wait_HC0(dev) == 0) {
94 outb(cmd, dev->io + HP_CVR);
95 spin_unlock_irqrestore(&dev->lock, flags);
96 return 0;
97 }
98 spin_unlock_irqrestore(&dev->lock, flags);
99
100 snd_printd(KERN_ERR LOGNAME ": Send DSP command timeout\n");
101
102 return -EIO;
103}
104EXPORT_SYMBOL(snd_msnd_send_dsp_cmd);
105
106int snd_msnd_send_word(struct snd_msnd *dev, unsigned char high,
107 unsigned char mid, unsigned char low)
108{
109 unsigned int io = dev->io;
110
111 if (snd_msnd_wait_TXDE(dev) == 0) {
112 outb(high, io + HP_TXH);
113 outb(mid, io + HP_TXM);
114 outb(low, io + HP_TXL);
115 return 0;
116 }
117
118 snd_printd(KERN_ERR LOGNAME ": Send host word timeout\n");
119
120 return -EIO;
121}
122EXPORT_SYMBOL(snd_msnd_send_word);
123
124int snd_msnd_upload_host(struct snd_msnd *dev, const u8 *bin, int len)
125{
126 int i;
127
128 if (len % 3 != 0) {
129 snd_printk(KERN_ERR LOGNAME
130 ": Upload host data not multiple of 3!\n");
131 return -EINVAL;
132 }
133
134 for (i = 0; i < len; i += 3)
135 if (snd_msnd_send_word(dev, bin[i], bin[i + 1], bin[i + 2]))
136 return -EIO;
137
138 inb(dev->io + HP_RXL);
139 inb(dev->io + HP_CVR);
140
141 return 0;
142}
143EXPORT_SYMBOL(snd_msnd_upload_host);
144
145int snd_msnd_enable_irq(struct snd_msnd *dev)
146{
147 unsigned long flags;
148
149 if (dev->irq_ref++)
150 return 0;
151
152 snd_printdd(LOGNAME ": Enabling IRQ\n");
153
154 spin_lock_irqsave(&dev->lock, flags);
155 if (snd_msnd_wait_TXDE(dev) == 0) {
156 outb(inb(dev->io + HP_ICR) | HPICR_TREQ, dev->io + HP_ICR);
157 if (dev->type == msndClassic)
158 outb(dev->irqid, dev->io + HP_IRQM);
159
160 outb(inb(dev->io + HP_ICR) & ~HPICR_TREQ, dev->io + HP_ICR);
161 outb(inb(dev->io + HP_ICR) | HPICR_RREQ, dev->io + HP_ICR);
162 enable_irq(dev->irq);
163 snd_msnd_init_queue(dev->DSPQ, dev->dspq_data_buff,
164 dev->dspq_buff_size);
165 spin_unlock_irqrestore(&dev->lock, flags);
166 return 0;
167 }
168 spin_unlock_irqrestore(&dev->lock, flags);
169
170 snd_printd(KERN_ERR LOGNAME ": Enable IRQ failed\n");
171
172 return -EIO;
173}
174EXPORT_SYMBOL(snd_msnd_enable_irq);
175
176int snd_msnd_disable_irq(struct snd_msnd *dev)
177{
178 unsigned long flags;
179
180 if (--dev->irq_ref > 0)
181 return 0;
182
183 if (dev->irq_ref < 0)
184 snd_printd(KERN_WARNING LOGNAME ": IRQ ref count is %d\n",
185 dev->irq_ref);
186
187 snd_printdd(LOGNAME ": Disabling IRQ\n");
188
189 spin_lock_irqsave(&dev->lock, flags);
190 if (snd_msnd_wait_TXDE(dev) == 0) {
191 outb(inb(dev->io + HP_ICR) & ~HPICR_RREQ, dev->io + HP_ICR);
192 if (dev->type == msndClassic)
193 outb(HPIRQ_NONE, dev->io + HP_IRQM);
194 disable_irq(dev->irq);
195 spin_unlock_irqrestore(&dev->lock, flags);
196 return 0;
197 }
198 spin_unlock_irqrestore(&dev->lock, flags);
199
200 snd_printd(KERN_ERR LOGNAME ": Disable IRQ failed\n");
201
202 return -EIO;
203}
204EXPORT_SYMBOL(snd_msnd_disable_irq);
205
206static inline long get_play_delay_jiffies(struct snd_msnd *chip, long size)
207{
208 long tmp = (size * HZ * chip->play_sample_size) / 8;
209 return tmp / (chip->play_sample_rate * chip->play_channels);
210}
211
212static void snd_msnd_dsp_write_flush(struct snd_msnd *chip)
213{
214 if (!(chip->mode & FMODE_WRITE) || !test_bit(F_WRITING, &chip->flags))
215 return;
216 set_bit(F_WRITEFLUSH, &chip->flags);
217/* interruptible_sleep_on_timeout(
218 &chip->writeflush,
219 get_play_delay_jiffies(&chip, chip->DAPF.len));*/
220 clear_bit(F_WRITEFLUSH, &chip->flags);
221 if (!signal_pending(current))
222 schedule_timeout_interruptible(
223 get_play_delay_jiffies(chip, chip->play_period_bytes));
224 clear_bit(F_WRITING, &chip->flags);
225}
226
227void snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file)
228{
229 if ((file ? file->f_mode : chip->mode) & FMODE_READ) {
230 clear_bit(F_READING, &chip->flags);
231 snd_msnd_send_dsp_cmd(chip, HDEX_RECORD_STOP);
232 snd_msnd_disable_irq(chip);
233 if (file) {
234 snd_printd(KERN_INFO LOGNAME
235 ": Stopping read for %p\n", file);
236 chip->mode &= ~FMODE_READ;
237 }
238 clear_bit(F_AUDIO_READ_INUSE, &chip->flags);
239 }
240 if ((file ? file->f_mode : chip->mode) & FMODE_WRITE) {
241 if (test_bit(F_WRITING, &chip->flags)) {
242 snd_msnd_dsp_write_flush(chip);
243 snd_msnd_send_dsp_cmd(chip, HDEX_PLAY_STOP);
244 }
245 snd_msnd_disable_irq(chip);
246 if (file) {
247 snd_printd(KERN_INFO
248 LOGNAME ": Stopping write for %p\n", file);
249 chip->mode &= ~FMODE_WRITE;
250 }
251 clear_bit(F_AUDIO_WRITE_INUSE, &chip->flags);
252 }
253}
254EXPORT_SYMBOL(snd_msnd_dsp_halt);
255
256
257int snd_msnd_DARQ(struct snd_msnd *chip, int bank)
258{
259 int /*size, n,*/ timeout = 3;
260 u16 wTmp;
261 /* void *DAQD; */
262
263 /* Increment the tail and check for queue wrap */
264 wTmp = readw(chip->DARQ + JQS_wTail) + PCTODSP_OFFSET(DAQDS__size);
265 if (wTmp > readw(chip->DARQ + JQS_wSize))
266 wTmp = 0;
267 while (wTmp == readw(chip->DARQ + JQS_wHead) && timeout--)
268 udelay(1);
269
270 if (chip->capturePeriods == 2) {
271 void *pDAQ = chip->mappedbase + DARQ_DATA_BUFF +
272 bank * DAQDS__size + DAQDS_wStart;
273 unsigned short offset = 0x3000 + chip->capturePeriodBytes;
274
275 if (readw(pDAQ) != PCTODSP_BASED(0x3000))
276 offset = 0x3000;
277 writew(PCTODSP_BASED(offset), pDAQ);
278 }
279
280 writew(wTmp, chip->DARQ + JQS_wTail);
281
282#if 0
283 /* Get our digital audio queue struct */
284 DAQD = bank * DAQDS__size + chip->mappedbase + DARQ_DATA_BUFF;
285
286 /* Get length of data */
287 size = readw(DAQD + DAQDS_wSize);
288
289 /* Read data from the head (unprotected bank 1 access okay
290 since this is only called inside an interrupt) */
291 outb(HPBLKSEL_1, chip->io + HP_BLKS);
292 n = msnd_fifo_write(&chip->DARF,
293 (char *)(chip->base + bank * DAR_BUFF_SIZE),
294 size, 0);
295 if (n <= 0) {
296 outb(HPBLKSEL_0, chip->io + HP_BLKS);
297 return n;
298 }
299 outb(HPBLKSEL_0, chip->io + HP_BLKS);
300#endif
301
302 return 1;
303}
304EXPORT_SYMBOL(snd_msnd_DARQ);
305
306int snd_msnd_DAPQ(struct snd_msnd *chip, int start)
307{
308 u16 DAPQ_tail;
309 int protect = start, nbanks = 0;
310 void *DAQD;
311 static int play_banks_submitted;
312 /* unsigned long flags;
313 spin_lock_irqsave(&chip->lock, flags); not necessary */
314
315 DAPQ_tail = readw(chip->DAPQ + JQS_wTail);
316 while (DAPQ_tail != readw(chip->DAPQ + JQS_wHead) || start) {
317 int bank_num = DAPQ_tail / PCTODSP_OFFSET(DAQDS__size);
318
319 if (start) {
320 start = 0;
321 play_banks_submitted = 0;
322 }
323
324 /* Get our digital audio queue struct */
325 DAQD = bank_num * DAQDS__size + chip->mappedbase +
326 DAPQ_DATA_BUFF;
327
328 /* Write size of this bank */
329 writew(chip->play_period_bytes, DAQD + DAQDS_wSize);
330 if (play_banks_submitted < 3)
331 ++play_banks_submitted;
332 else if (chip->playPeriods == 2) {
333 unsigned short offset = chip->play_period_bytes;
334
335 if (readw(DAQD + DAQDS_wStart) != PCTODSP_BASED(0x0))
336 offset = 0;
337
338 writew(PCTODSP_BASED(offset), DAQD + DAQDS_wStart);
339 }
340 ++nbanks;
341
342 /* Then advance the tail */
343 /*
344 if (protect)
345 snd_printd(KERN_INFO "B %X %lX\n",
346 bank_num, xtime.tv_usec);
347 */
348
349 DAPQ_tail = (++bank_num % 3) * PCTODSP_OFFSET(DAQDS__size);
350 writew(DAPQ_tail, chip->DAPQ + JQS_wTail);
351 /* Tell the DSP to play the bank */
352 snd_msnd_send_dsp_cmd(chip, HDEX_PLAY_START);
353 if (protect)
354 if (2 == bank_num)
355 break;
356 }
357 /*
358 if (protect)
359 snd_printd(KERN_INFO "%lX\n", xtime.tv_usec);
360 */
361 /* spin_unlock_irqrestore(&chip->lock, flags); not necessary */
362 return nbanks;
363}
364EXPORT_SYMBOL(snd_msnd_DAPQ);
365
366static void snd_msnd_play_reset_queue(struct snd_msnd *chip,
367 unsigned int pcm_periods,
368 unsigned int pcm_count)
369{
370 int n;
371 void *pDAQ = chip->mappedbase + DAPQ_DATA_BUFF;
372
373 chip->last_playbank = -1;
374 chip->playLimit = pcm_count * (pcm_periods - 1);
375 chip->playPeriods = pcm_periods;
376 writew(PCTODSP_OFFSET(0 * DAQDS__size), chip->DAPQ + JQS_wHead);
377 writew(PCTODSP_OFFSET(0 * DAQDS__size), chip->DAPQ + JQS_wTail);
378
379 chip->play_period_bytes = pcm_count;
380
381 for (n = 0; n < pcm_periods; ++n, pDAQ += DAQDS__size) {
382 writew(PCTODSP_BASED((u32)(pcm_count * n)),
383 pDAQ + DAQDS_wStart);
384 writew(0, pDAQ + DAQDS_wSize);
385 writew(1, pDAQ + DAQDS_wFormat);
386 writew(chip->play_sample_size, pDAQ + DAQDS_wSampleSize);
387 writew(chip->play_channels, pDAQ + DAQDS_wChannels);
388 writew(chip->play_sample_rate, pDAQ + DAQDS_wSampleRate);
389 writew(HIMT_PLAY_DONE * 0x100 + n, pDAQ + DAQDS_wIntMsg);
390 writew(n, pDAQ + DAQDS_wFlags);
391 }
392}
393
394static void snd_msnd_capture_reset_queue(struct snd_msnd *chip,
395 unsigned int pcm_periods,
396 unsigned int pcm_count)
397{
398 int n;
399 void *pDAQ;
400 /* unsigned long flags; */
401
402 /* snd_msnd_init_queue(chip->DARQ, DARQ_DATA_BUFF, DARQ_BUFF_SIZE); */
403
404 chip->last_recbank = 2;
405 chip->captureLimit = pcm_count * (pcm_periods - 1);
406 chip->capturePeriods = pcm_periods;
407 writew(PCTODSP_OFFSET(0 * DAQDS__size), chip->DARQ + JQS_wHead);
408 writew(PCTODSP_OFFSET(chip->last_recbank * DAQDS__size),
409 chip->DARQ + JQS_wTail);
410
411#if 0 /* Critical section: bank 1 access. this is how the OSS driver does it:*/
412 spin_lock_irqsave(&chip->lock, flags);
413 outb(HPBLKSEL_1, chip->io + HP_BLKS);
414 memset_io(chip->mappedbase, 0, DAR_BUFF_SIZE * 3);
415 outb(HPBLKSEL_0, chip->io + HP_BLKS);
416 spin_unlock_irqrestore(&chip->lock, flags);
417#endif
418
419 chip->capturePeriodBytes = pcm_count;
420 snd_printdd("snd_msnd_capture_reset_queue() %i\n", pcm_count);
421
422 pDAQ = chip->mappedbase + DARQ_DATA_BUFF;
423
424 for (n = 0; n < pcm_periods; ++n, pDAQ += DAQDS__size) {
425 u32 tmp = pcm_count * n;
426
427 writew(PCTODSP_BASED(tmp + 0x3000), pDAQ + DAQDS_wStart);
428 writew(pcm_count, pDAQ + DAQDS_wSize);
429 writew(1, pDAQ + DAQDS_wFormat);
430 writew(chip->capture_sample_size, pDAQ + DAQDS_wSampleSize);
431 writew(chip->capture_channels, pDAQ + DAQDS_wChannels);
432 writew(chip->capture_sample_rate, pDAQ + DAQDS_wSampleRate);
433 writew(HIMT_RECORD_DONE * 0x100 + n, pDAQ + DAQDS_wIntMsg);
434 writew(n, pDAQ + DAQDS_wFlags);
435 }
436}
437
438static struct snd_pcm_hardware snd_msnd_playback = {
439 .info = SNDRV_PCM_INFO_MMAP |
440 SNDRV_PCM_INFO_INTERLEAVED |
441 SNDRV_PCM_INFO_MMAP_VALID |
442 SNDRV_PCM_INFO_BATCH,
443 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
444 .rates = SNDRV_PCM_RATE_8000_48000,
445 .rate_min = 8000,
446 .rate_max = 48000,
447 .channels_min = 1,
448 .channels_max = 2,
449 .buffer_bytes_max = 0x3000,
450 .period_bytes_min = 0x40,
451 .period_bytes_max = 0x1800,
452 .periods_min = 2,
453 .periods_max = 3,
454 .fifo_size = 0,
455};
456
457static struct snd_pcm_hardware snd_msnd_capture = {
458 .info = SNDRV_PCM_INFO_MMAP |
459 SNDRV_PCM_INFO_INTERLEAVED |
460 SNDRV_PCM_INFO_MMAP_VALID |
461 SNDRV_PCM_INFO_BATCH,
462 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
463 .rates = SNDRV_PCM_RATE_8000_48000,
464 .rate_min = 8000,
465 .rate_max = 48000,
466 .channels_min = 1,
467 .channels_max = 2,
468 .buffer_bytes_max = 0x3000,
469 .period_bytes_min = 0x40,
470 .period_bytes_max = 0x1800,
471 .periods_min = 2,
472 .periods_max = 3,
473 .fifo_size = 0,
474};
475
476
477static int snd_msnd_playback_open(struct snd_pcm_substream *substream)
478{
479 struct snd_pcm_runtime *runtime = substream->runtime;
480 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
481
482 set_bit(F_AUDIO_WRITE_INUSE, &chip->flags);
483 clear_bit(F_WRITING, &chip->flags);
484 snd_msnd_enable_irq(chip);
485
486 runtime->dma_area = chip->mappedbase;
487 runtime->dma_bytes = 0x3000;
488
489 chip->playback_substream = substream;
490 runtime->hw = snd_msnd_playback;
491 return 0;
492}
493
494static int snd_msnd_playback_close(struct snd_pcm_substream *substream)
495{
496 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
497
498 snd_msnd_disable_irq(chip);
499 clear_bit(F_AUDIO_WRITE_INUSE, &chip->flags);
500 return 0;
501}
502
503
504static int snd_msnd_playback_hw_params(struct snd_pcm_substream *substream,
505 struct snd_pcm_hw_params *params)
506{
507 int i;
508 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
509 void *pDAQ = chip->mappedbase + DAPQ_DATA_BUFF;
510
511 chip->play_sample_size = snd_pcm_format_width(params_format(params));
512 chip->play_channels = params_channels(params);
513 chip->play_sample_rate = params_rate(params);
514
515 for (i = 0; i < 3; ++i, pDAQ += DAQDS__size) {
516 writew(chip->play_sample_size, pDAQ + DAQDS_wSampleSize);
517 writew(chip->play_channels, pDAQ + DAQDS_wChannels);
518 writew(chip->play_sample_rate, pDAQ + DAQDS_wSampleRate);
519 }
520 /* dont do this here:
521 * snd_msnd_calibrate_adc(chip->play_sample_rate);
522 */
523
524 return 0;
525}
526
527static int snd_msnd_playback_prepare(struct snd_pcm_substream *substream)
528{
529 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
530 unsigned int pcm_size = snd_pcm_lib_buffer_bytes(substream);
531 unsigned int pcm_count = snd_pcm_lib_period_bytes(substream);
532 unsigned int pcm_periods = pcm_size / pcm_count;
533
534 snd_msnd_play_reset_queue(chip, pcm_periods, pcm_count);
535 chip->playDMAPos = 0;
536 return 0;
537}
538
539static int snd_msnd_playback_trigger(struct snd_pcm_substream *substream,
540 int cmd)
541{
542 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
543 int result = 0;
544
545 if (cmd == SNDRV_PCM_TRIGGER_START) {
546 snd_printdd("snd_msnd_playback_trigger(START)\n");
547 chip->banksPlayed = 0;
548 set_bit(F_WRITING, &chip->flags);
549 snd_msnd_DAPQ(chip, 1);
550 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
551 snd_printdd("snd_msnd_playback_trigger(STop)\n");
552 /* interrupt diagnostic, comment this out later */
553 clear_bit(F_WRITING, &chip->flags);
554 snd_msnd_send_dsp_cmd(chip, HDEX_PLAY_STOP);
555 } else {
556 snd_printd(KERN_ERR "snd_msnd_playback_trigger(?????)\n");
557 result = -EINVAL;
558 }
559
560 snd_printdd("snd_msnd_playback_trigger() ENDE\n");
561 return result;
562}
563
564static snd_pcm_uframes_t
565snd_msnd_playback_pointer(struct snd_pcm_substream *substream)
566{
567 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
568
569 return bytes_to_frames(substream->runtime, chip->playDMAPos);
570}
571
572
573static struct snd_pcm_ops snd_msnd_playback_ops = {
574 .open = snd_msnd_playback_open,
575 .close = snd_msnd_playback_close,
576 .ioctl = snd_pcm_lib_ioctl,
577 .hw_params = snd_msnd_playback_hw_params,
578 .prepare = snd_msnd_playback_prepare,
579 .trigger = snd_msnd_playback_trigger,
580 .pointer = snd_msnd_playback_pointer,
581};
582
583static int snd_msnd_capture_open(struct snd_pcm_substream *substream)
584{
585 struct snd_pcm_runtime *runtime = substream->runtime;
586 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
587
588 set_bit(F_AUDIO_READ_INUSE, &chip->flags);
589 snd_msnd_enable_irq(chip);
590 runtime->dma_area = chip->mappedbase + 0x3000;
591 runtime->dma_bytes = 0x3000;
592 memset(runtime->dma_area, 0, runtime->dma_bytes);
593 chip->capture_substream = substream;
594 runtime->hw = snd_msnd_capture;
595 return 0;
596}
597
598static int snd_msnd_capture_close(struct snd_pcm_substream *substream)
599{
600 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
601
602 snd_msnd_disable_irq(chip);
603 clear_bit(F_AUDIO_READ_INUSE, &chip->flags);
604 return 0;
605}
606
607static int snd_msnd_capture_prepare(struct snd_pcm_substream *substream)
608{
609 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
610 unsigned int pcm_size = snd_pcm_lib_buffer_bytes(substream);
611 unsigned int pcm_count = snd_pcm_lib_period_bytes(substream);
612 unsigned int pcm_periods = pcm_size / pcm_count;
613
614 snd_msnd_capture_reset_queue(chip, pcm_periods, pcm_count);
615 chip->captureDMAPos = 0;
616 return 0;
617}
618
619static int snd_msnd_capture_trigger(struct snd_pcm_substream *substream,
620 int cmd)
621{
622 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
623
624 if (cmd == SNDRV_PCM_TRIGGER_START) {
625 chip->last_recbank = -1;
626 set_bit(F_READING, &chip->flags);
627 if (snd_msnd_send_dsp_cmd(chip, HDEX_RECORD_START) == 0)
628 return 0;
629
630 clear_bit(F_READING, &chip->flags);
631 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
632 clear_bit(F_READING, &chip->flags);
633 snd_msnd_send_dsp_cmd(chip, HDEX_RECORD_STOP);
634 return 0;
635 }
636 return -EINVAL;
637}
638
639
640static snd_pcm_uframes_t
641snd_msnd_capture_pointer(struct snd_pcm_substream *substream)
642{
643 struct snd_pcm_runtime *runtime = substream->runtime;
644 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
645
646 return bytes_to_frames(runtime, chip->captureDMAPos);
647}
648
649
650static int snd_msnd_capture_hw_params(struct snd_pcm_substream *substream,
651 struct snd_pcm_hw_params *params)
652{
653 int i;
654 struct snd_msnd *chip = snd_pcm_substream_chip(substream);
655 void *pDAQ = chip->mappedbase + DARQ_DATA_BUFF;
656
657 chip->capture_sample_size = snd_pcm_format_width(params_format(params));
658 chip->capture_channels = params_channels(params);
659 chip->capture_sample_rate = params_rate(params);
660
661 for (i = 0; i < 3; ++i, pDAQ += DAQDS__size) {
662 writew(chip->capture_sample_size, pDAQ + DAQDS_wSampleSize);
663 writew(chip->capture_channels, pDAQ + DAQDS_wChannels);
664 writew(chip->capture_sample_rate, pDAQ + DAQDS_wSampleRate);
665 }
666 return 0;
667}
668
669
670static struct snd_pcm_ops snd_msnd_capture_ops = {
671 .open = snd_msnd_capture_open,
672 .close = snd_msnd_capture_close,
673 .ioctl = snd_pcm_lib_ioctl,
674 .hw_params = snd_msnd_capture_hw_params,
675 .prepare = snd_msnd_capture_prepare,
676 .trigger = snd_msnd_capture_trigger,
677 .pointer = snd_msnd_capture_pointer,
678};
679
680
681int snd_msnd_pcm(struct snd_card *card, int device,
682 struct snd_pcm **rpcm)
683{
684 struct snd_msnd *chip = card->private_data;
685 struct snd_pcm *pcm;
686 int err;
687
688 err = snd_pcm_new(card, "MSNDPINNACLE", device, 1, 1, &pcm);
689 if (err < 0)
690 return err;
691
692 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_msnd_playback_ops);
693 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_msnd_capture_ops);
694
695 pcm->private_data = chip;
696 strcpy(pcm->name, "Hurricane");
697
698
699 if (rpcm)
700 *rpcm = pcm;
701 return 0;
702}
703EXPORT_SYMBOL(snd_msnd_pcm);
704
705MODULE_DESCRIPTION("Common routines for Turtle Beach Multisound drivers");
706MODULE_LICENSE("GPL");
707
diff --git a/sound/isa/msnd/msnd.h b/sound/isa/msnd/msnd.h
new file mode 100644
index 000000000000..3773e242b58e
--- /dev/null
+++ b/sound/isa/msnd/msnd.h
@@ -0,0 +1,308 @@
1/*********************************************************************
2 *
3 * msnd.h
4 *
5 * Turtle Beach MultiSound Sound Card Driver for Linux
6 *
7 * Some parts of this header file were derived from the Turtle Beach
8 * MultiSound Driver Development Kit.
9 *
10 * Copyright (C) 1998 Andrew Veliath
11 * Copyright (C) 1993 Turtle Beach Systems, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 ********************************************************************/
28#ifndef __MSND_H
29#define __MSND_H
30
31#define DEFSAMPLERATE 44100
32#define DEFSAMPLESIZE SNDRV_PCM_FORMAT_S16
33#define DEFCHANNELS 1
34
35#define SRAM_BANK_SIZE 0x8000
36#define SRAM_CNTL_START 0x7F00
37#define SMA_STRUCT_START 0x7F40
38
39#define DSP_BASE_ADDR 0x4000
40#define DSP_BANK_BASE 0x4000
41
42#define AGND 0x01
43#define SIGNAL 0x02
44
45#define EXT_DSP_BIT_DCAL 0x0001
46#define EXT_DSP_BIT_MIDI_CON 0x0002
47
48#define BUFFSIZE 0x8000
49#define HOSTQ_SIZE 0x40
50
51#define DAP_BUFF_SIZE 0x2400
52
53#define DAPQ_STRUCT_SIZE 0x10
54#define DARQ_STRUCT_SIZE 0x10
55#define DAPQ_BUFF_SIZE (3 * 0x10)
56#define DARQ_BUFF_SIZE (3 * 0x10)
57#define MODQ_BUFF_SIZE 0x400
58
59#define DAPQ_DATA_BUFF 0x6C00
60#define DARQ_DATA_BUFF 0x6C30
61#define MODQ_DATA_BUFF 0x6C60
62#define MIDQ_DATA_BUFF 0x7060
63
64#define DAPQ_OFFSET SRAM_CNTL_START
65#define DARQ_OFFSET (SRAM_CNTL_START + 0x08)
66#define MODQ_OFFSET (SRAM_CNTL_START + 0x10)
67#define MIDQ_OFFSET (SRAM_CNTL_START + 0x18)
68#define DSPQ_OFFSET (SRAM_CNTL_START + 0x20)
69
70#define HP_ICR 0x00
71#define HP_CVR 0x01
72#define HP_ISR 0x02
73#define HP_IVR 0x03
74#define HP_NU 0x04
75#define HP_INFO 0x04
76#define HP_TXH 0x05
77#define HP_RXH 0x05
78#define HP_TXM 0x06
79#define HP_RXM 0x06
80#define HP_TXL 0x07
81#define HP_RXL 0x07
82
83#define HP_ICR_DEF 0x00
84#define HP_CVR_DEF 0x12
85#define HP_ISR_DEF 0x06
86#define HP_IVR_DEF 0x0f
87#define HP_NU_DEF 0x00
88
89#define HP_IRQM 0x09
90
91#define HPR_BLRC 0x08
92#define HPR_SPR1 0x09
93#define HPR_SPR2 0x0A
94#define HPR_TCL0 0x0B
95#define HPR_TCL1 0x0C
96#define HPR_TCL2 0x0D
97#define HPR_TCL3 0x0E
98#define HPR_TCL4 0x0F
99
100#define HPICR_INIT 0x80
101#define HPICR_HM1 0x40
102#define HPICR_HM0 0x20
103#define HPICR_HF1 0x10
104#define HPICR_HF0 0x08
105#define HPICR_TREQ 0x02
106#define HPICR_RREQ 0x01
107
108#define HPCVR_HC 0x80
109
110#define HPISR_HREQ 0x80
111#define HPISR_DMA 0x40
112#define HPISR_HF3 0x10
113#define HPISR_HF2 0x08
114#define HPISR_TRDY 0x04
115#define HPISR_TXDE 0x02
116#define HPISR_RXDF 0x01
117
118#define HPIO_290 0
119#define HPIO_260 1
120#define HPIO_250 2
121#define HPIO_240 3
122#define HPIO_230 4
123#define HPIO_220 5
124#define HPIO_210 6
125#define HPIO_3E0 7
126
127#define HPMEM_NONE 0
128#define HPMEM_B000 1
129#define HPMEM_C800 2
130#define HPMEM_D000 3
131#define HPMEM_D400 4
132#define HPMEM_D800 5
133#define HPMEM_E000 6
134#define HPMEM_E800 7
135
136#define HPIRQ_NONE 0
137#define HPIRQ_5 1
138#define HPIRQ_7 2
139#define HPIRQ_9 3
140#define HPIRQ_10 4
141#define HPIRQ_11 5
142#define HPIRQ_12 6
143#define HPIRQ_15 7
144
145#define HIMT_PLAY_DONE 0x00
146#define HIMT_RECORD_DONE 0x01
147#define HIMT_MIDI_EOS 0x02
148#define HIMT_MIDI_OUT 0x03
149
150#define HIMT_MIDI_IN_UCHAR 0x0E
151#define HIMT_DSP 0x0F
152
153#define HDEX_BASE 0x92
154#define HDEX_PLAY_START (0 + HDEX_BASE)
155#define HDEX_PLAY_STOP (1 + HDEX_BASE)
156#define HDEX_PLAY_PAUSE (2 + HDEX_BASE)
157#define HDEX_PLAY_RESUME (3 + HDEX_BASE)
158#define HDEX_RECORD_START (4 + HDEX_BASE)
159#define HDEX_RECORD_STOP (5 + HDEX_BASE)
160#define HDEX_MIDI_IN_START (6 + HDEX_BASE)
161#define HDEX_MIDI_IN_STOP (7 + HDEX_BASE)
162#define HDEX_MIDI_OUT_START (8 + HDEX_BASE)
163#define HDEX_MIDI_OUT_STOP (9 + HDEX_BASE)
164#define HDEX_AUX_REQ (10 + HDEX_BASE)
165
166#define HDEXAR_CLEAR_PEAKS 1
167#define HDEXAR_IN_SET_POTS 2
168#define HDEXAR_AUX_SET_POTS 3
169#define HDEXAR_CAL_A_TO_D 4
170#define HDEXAR_RD_EXT_DSP_BITS 5
171
172/* Pinnacle only HDEXAR defs */
173#define HDEXAR_SET_ANA_IN 0
174#define HDEXAR_SET_SYNTH_IN 4
175#define HDEXAR_READ_DAT_IN 5
176#define HDEXAR_MIC_SET_POTS 6
177#define HDEXAR_SET_DAT_IN 7
178
179#define HDEXAR_SET_SYNTH_48 8
180#define HDEXAR_SET_SYNTH_44 9
181
182#define HIWORD(l) ((u16)((((u32)(l)) >> 16) & 0xFFFF))
183#define LOWORD(l) ((u16)(u32)(l))
184#define HIBYTE(w) ((u8)(((u16)(w) >> 8) & 0xFF))
185#define LOBYTE(w) ((u8)(w))
186#define MAKELONG(low, hi) ((long)(((u16)(low))|(((u32)((u16)(hi)))<<16)))
187#define MAKEWORD(low, hi) ((u16)(((u8)(low))|(((u16)((u8)(hi)))<<8)))
188
189#define PCTODSP_OFFSET(w) (u16)((w)/2)
190#define PCTODSP_BASED(w) (u16)(((w)/2) + DSP_BASE_ADDR)
191#define DSPTOPC_BASED(w) (((w) - DSP_BASE_ADDR) * 2)
192
193#ifdef SLOWIO
194# undef outb
195# undef inb
196# define outb outb_p
197# define inb inb_p
198#endif
199
200/* JobQueueStruct */
201#define JQS_wStart 0x00
202#define JQS_wSize 0x02
203#define JQS_wHead 0x04
204#define JQS_wTail 0x06
205#define JQS__size 0x08
206
207/* DAQueueDataStruct */
208#define DAQDS_wStart 0x00
209#define DAQDS_wSize 0x02
210#define DAQDS_wFormat 0x04
211#define DAQDS_wSampleSize 0x06
212#define DAQDS_wChannels 0x08
213#define DAQDS_wSampleRate 0x0A
214#define DAQDS_wIntMsg 0x0C
215#define DAQDS_wFlags 0x0E
216#define DAQDS__size 0x10
217
218#include <sound/pcm.h>
219
220struct snd_msnd {
221 void __iomem *mappedbase;
222 int play_period_bytes;
223 int playLimit;
224 int playPeriods;
225 int playDMAPos;
226 int banksPlayed;
227 int captureDMAPos;
228 int capturePeriodBytes;
229 int captureLimit;
230 int capturePeriods;
231 struct snd_card *card;
232 void *msndmidi_mpu;
233 struct snd_rawmidi *rmidi;
234
235 /* Hardware resources */
236 long io;
237 int memid, irqid;
238 int irq, irq_ref;
239 unsigned long base;
240
241 /* Motorola 56k DSP SMA */
242 void __iomem *SMA;
243 void __iomem *DAPQ;
244 void __iomem *DARQ;
245 void __iomem *MODQ;
246 void __iomem *MIDQ;
247 void __iomem *DSPQ;
248 int dspq_data_buff, dspq_buff_size;
249
250 /* State variables */
251 enum { msndClassic, msndPinnacle } type;
252 mode_t mode;
253 unsigned long flags;
254#define F_RESETTING 0
255#define F_HAVEDIGITAL 1
256#define F_AUDIO_WRITE_INUSE 2
257#define F_WRITING 3
258#define F_WRITEBLOCK 4
259#define F_WRITEFLUSH 5
260#define F_AUDIO_READ_INUSE 6
261#define F_READING 7
262#define F_READBLOCK 8
263#define F_EXT_MIDI_INUSE 9
264#define F_HDR_MIDI_INUSE 10
265#define F_DISABLE_WRITE_NDELAY 11
266 spinlock_t lock;
267 spinlock_t mixer_lock;
268 int nresets;
269 unsigned recsrc;
270#define LEVEL_ENTRIES 32
271 int left_levels[LEVEL_ENTRIES];
272 int right_levels[LEVEL_ENTRIES];
273 int calibrate_signal;
274 int play_sample_size, play_sample_rate, play_channels;
275 int play_ndelay;
276 int capture_sample_size, capture_sample_rate, capture_channels;
277 int capture_ndelay;
278 u8 bCurrentMidiPatch;
279
280 int last_playbank, last_recbank;
281 struct snd_pcm_substream *playback_substream;
282 struct snd_pcm_substream *capture_substream;
283
284};
285
286void snd_msnd_init_queue(void *base, int start, int size);
287
288int snd_msnd_send_dsp_cmd(struct snd_msnd *chip, u8 cmd);
289int snd_msnd_send_word(struct snd_msnd *chip,
290 unsigned char high,
291 unsigned char mid,
292 unsigned char low);
293int snd_msnd_upload_host(struct snd_msnd *chip,
294 const u8 *bin, int len);
295int snd_msnd_enable_irq(struct snd_msnd *chip);
296int snd_msnd_disable_irq(struct snd_msnd *chip);
297void snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file);
298int snd_msnd_DAPQ(struct snd_msnd *chip, int start);
299int snd_msnd_DARQ(struct snd_msnd *chip, int start);
300int snd_msnd_pcm(struct snd_card *card, int device, struct snd_pcm **rpcm);
301
302int snd_msndmidi_new(struct snd_card *card, int device);
303void snd_msndmidi_input_read(void *mpu);
304
305void snd_msndmix_setup(struct snd_msnd *chip);
306int __devinit snd_msndmix_new(struct snd_card *card);
307int snd_msndmix_force_recsrc(struct snd_msnd *chip, int recsrc);
308#endif /* __MSND_H */
diff --git a/sound/isa/msnd/msnd_classic.c b/sound/isa/msnd/msnd_classic.c
new file mode 100644
index 000000000000..3b23a096fa4e
--- /dev/null
+++ b/sound/isa/msnd/msnd_classic.c
@@ -0,0 +1,3 @@
1/* The work is in msnd_pinnacle.c, just define MSND_CLASSIC before it. */
2#define MSND_CLASSIC
3#include "msnd_pinnacle.c"
diff --git a/sound/isa/msnd/msnd_classic.h b/sound/isa/msnd/msnd_classic.h
new file mode 100644
index 000000000000..f18d5fa5baf4
--- /dev/null
+++ b/sound/isa/msnd/msnd_classic.h
@@ -0,0 +1,129 @@
1/*********************************************************************
2 *
3 * msnd_classic.h
4 *
5 * Turtle Beach MultiSound Sound Card Driver for Linux
6 *
7 * Some parts of this header file were derived from the Turtle Beach
8 * MultiSound Driver Development Kit.
9 *
10 * Copyright (C) 1998 Andrew Veliath
11 * Copyright (C) 1993 Turtle Beach Systems, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 ********************************************************************/
28#ifndef __MSND_CLASSIC_H
29#define __MSND_CLASSIC_H
30
31#define DSP_NUMIO 0x10
32
33#define HP_MEMM 0x08
34
35#define HP_BITM 0x0E
36#define HP_WAIT 0x0D
37#define HP_DSPR 0x0A
38#define HP_PROR 0x0B
39#define HP_BLKS 0x0C
40
41#define HPPRORESET_OFF 0
42#define HPPRORESET_ON 1
43
44#define HPDSPRESET_OFF 0
45#define HPDSPRESET_ON 1
46
47#define HPBLKSEL_0 0
48#define HPBLKSEL_1 1
49
50#define HPWAITSTATE_0 0
51#define HPWAITSTATE_1 1
52
53#define HPBITMODE_16 0
54#define HPBITMODE_8 1
55
56#define HIDSP_INT_PLAY_UNDER 0x00
57#define HIDSP_INT_RECORD_OVER 0x01
58#define HIDSP_INPUT_CLIPPING 0x02
59#define HIDSP_MIDI_IN_OVER 0x10
60#define HIDSP_MIDI_OVERRUN_ERR 0x13
61
62#define TIME_PRO_RESET_DONE 0x028A
63#define TIME_PRO_SYSEX 0x0040
64#define TIME_PRO_RESET 0x0032
65
66#define DAR_BUFF_SIZE 0x2000
67
68#define MIDQ_BUFF_SIZE 0x200
69#define DSPQ_BUFF_SIZE 0x40
70
71#define DSPQ_DATA_BUFF 0x7260
72
73#define MOP_SYNTH 0x10
74#define MOP_EXTOUT 0x32
75#define MOP_EXTTHRU 0x02
76#define MOP_OUTMASK 0x01
77
78#define MIP_EXTIN 0x01
79#define MIP_SYNTH 0x00
80#define MIP_INMASK 0x32
81
82/* Classic SMA Common Data */
83#define SMA_wCurrPlayBytes 0x0000
84#define SMA_wCurrRecordBytes 0x0002
85#define SMA_wCurrPlayVolLeft 0x0004
86#define SMA_wCurrPlayVolRight 0x0006
87#define SMA_wCurrInVolLeft 0x0008
88#define SMA_wCurrInVolRight 0x000a
89#define SMA_wUser_3 0x000c
90#define SMA_wUser_4 0x000e
91#define SMA_dwUser_5 0x0010
92#define SMA_dwUser_6 0x0014
93#define SMA_wUser_7 0x0018
94#define SMA_wReserved_A 0x001a
95#define SMA_wReserved_B 0x001c
96#define SMA_wReserved_C 0x001e
97#define SMA_wReserved_D 0x0020
98#define SMA_wReserved_E 0x0022
99#define SMA_wReserved_F 0x0024
100#define SMA_wReserved_G 0x0026
101#define SMA_wReserved_H 0x0028
102#define SMA_wCurrDSPStatusFlags 0x002a
103#define SMA_wCurrHostStatusFlags 0x002c
104#define SMA_wCurrInputTagBits 0x002e
105#define SMA_wCurrLeftPeak 0x0030
106#define SMA_wCurrRightPeak 0x0032
107#define SMA_wExtDSPbits 0x0034
108#define SMA_bExtHostbits 0x0036
109#define SMA_bBoardLevel 0x0037
110#define SMA_bInPotPosRight 0x0038
111#define SMA_bInPotPosLeft 0x0039
112#define SMA_bAuxPotPosRight 0x003a
113#define SMA_bAuxPotPosLeft 0x003b
114#define SMA_wCurrMastVolLeft 0x003c
115#define SMA_wCurrMastVolRight 0x003e
116#define SMA_bUser_12 0x0040
117#define SMA_bUser_13 0x0041
118#define SMA_wUser_14 0x0042
119#define SMA_wUser_15 0x0044
120#define SMA_wCalFreqAtoD 0x0046
121#define SMA_wUser_16 0x0048
122#define SMA_wUser_17 0x004a
123#define SMA__size 0x004c
124
125#define INITCODEFILE "turtlebeach/msndinit.bin"
126#define PERMCODEFILE "turtlebeach/msndperm.bin"
127#define LONGNAME "MultiSound (Classic/Monterey/Tahiti)"
128
129#endif /* __MSND_CLASSIC_H */
diff --git a/sound/isa/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c
new file mode 100644
index 000000000000..cb9aa4c4edd0
--- /dev/null
+++ b/sound/isa/msnd/msnd_midi.c
@@ -0,0 +1,180 @@
1/*
2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
3 * Copyright (c) 2009 by Krzysztof Helt
4 * Routines for control of MPU-401 in UART mode
5 *
6 * MPU-401 supports UART mode which is not capable generate transmit
7 * interrupts thus output is done via polling. Also, if irq < 0, then
8 * input is done also via polling. Do not expect good performance.
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#include <linux/io.h>
28#include <linux/delay.h>
29#include <linux/ioport.h>
30#include <linux/errno.h>
31#include <sound/core.h>
32#include <sound/rawmidi.h>
33
34#include "msnd.h"
35
36#define MSNDMIDI_MODE_BIT_INPUT 0
37#define MSNDMIDI_MODE_BIT_OUTPUT 1
38#define MSNDMIDI_MODE_BIT_INPUT_TRIGGER 2
39#define MSNDMIDI_MODE_BIT_OUTPUT_TRIGGER 3
40
41struct snd_msndmidi {
42 struct snd_msnd *dev;
43
44 unsigned long mode; /* MSNDMIDI_MODE_XXXX */
45
46 struct snd_rawmidi_substream *substream_input;
47
48 spinlock_t input_lock;
49};
50
51/*
52 * input/output open/close - protected by open_mutex in rawmidi.c
53 */
54static int snd_msndmidi_input_open(struct snd_rawmidi_substream *substream)
55{
56 struct snd_msndmidi *mpu;
57
58 snd_printdd("snd_msndmidi_input_open()\n");
59
60 mpu = substream->rmidi->private_data;
61
62 mpu->substream_input = substream;
63
64 snd_msnd_enable_irq(mpu->dev);
65
66 snd_msnd_send_dsp_cmd(mpu->dev, HDEX_MIDI_IN_START);
67 set_bit(MSNDMIDI_MODE_BIT_INPUT, &mpu->mode);
68 return 0;
69}
70
71static int snd_msndmidi_input_close(struct snd_rawmidi_substream *substream)
72{
73 struct snd_msndmidi *mpu;
74
75 mpu = substream->rmidi->private_data;
76 snd_msnd_send_dsp_cmd(mpu->dev, HDEX_MIDI_IN_STOP);
77 clear_bit(MSNDMIDI_MODE_BIT_INPUT, &mpu->mode);
78 mpu->substream_input = NULL;
79 snd_msnd_disable_irq(mpu->dev);
80 return 0;
81}
82
83static void snd_msndmidi_input_drop(struct snd_msndmidi *mpu)
84{
85 u16 tail;
86
87 tail = readw(mpu->dev->MIDQ + JQS_wTail);
88 writew(tail, mpu->dev->MIDQ + JQS_wHead);
89}
90
91/*
92 * trigger input
93 */
94static void snd_msndmidi_input_trigger(struct snd_rawmidi_substream *substream,
95 int up)
96{
97 unsigned long flags;
98 struct snd_msndmidi *mpu;
99
100 snd_printdd("snd_msndmidi_input_trigger(, %i)\n", up);
101
102 mpu = substream->rmidi->private_data;
103 spin_lock_irqsave(&mpu->input_lock, flags);
104 if (up) {
105 if (!test_and_set_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER,
106 &mpu->mode))
107 snd_msndmidi_input_drop(mpu);
108 } else {
109 clear_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode);
110 }
111 spin_unlock_irqrestore(&mpu->input_lock, flags);
112 if (up)
113 snd_msndmidi_input_read(mpu);
114}
115
116void snd_msndmidi_input_read(void *mpuv)
117{
118 unsigned long flags;
119 struct snd_msndmidi *mpu = mpuv;
120 void *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF;
121
122 spin_lock_irqsave(&mpu->input_lock, flags);
123 while (readw(mpu->dev->MIDQ + JQS_wTail) !=
124 readw(mpu->dev->MIDQ + JQS_wHead)) {
125 u16 wTmp, val;
126 val = readw(pwMIDQData + 2 * readw(mpu->dev->MIDQ + JQS_wHead));
127
128 if (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER,
129 &mpu->mode))
130 snd_rawmidi_receive(mpu->substream_input,
131 (unsigned char *)&val, 1);
132
133 wTmp = readw(mpu->dev->MIDQ + JQS_wHead) + 1;
134 if (wTmp > readw(mpu->dev->MIDQ + JQS_wSize))
135 writew(0, mpu->dev->MIDQ + JQS_wHead);
136 else
137 writew(wTmp, mpu->dev->MIDQ + JQS_wHead);
138 }
139 spin_unlock_irqrestore(&mpu->input_lock, flags);
140}
141EXPORT_SYMBOL(snd_msndmidi_input_read);
142
143static struct snd_rawmidi_ops snd_msndmidi_input = {
144 .open = snd_msndmidi_input_open,
145 .close = snd_msndmidi_input_close,
146 .trigger = snd_msndmidi_input_trigger,
147};
148
149static void snd_msndmidi_free(struct snd_rawmidi *rmidi)
150{
151 struct snd_msndmidi *mpu = rmidi->private_data;
152 kfree(mpu);
153}
154
155int snd_msndmidi_new(struct snd_card *card, int device)
156{
157 struct snd_msnd *chip = card->private_data;
158 struct snd_msndmidi *mpu;
159 struct snd_rawmidi *rmidi;
160 int err;
161
162 err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi);
163 if (err < 0)
164 return err;
165 mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL);
166 if (mpu == NULL) {
167 snd_device_free(card, rmidi);
168 return -ENOMEM;
169 }
170 mpu->dev = chip;
171 chip->msndmidi_mpu = mpu;
172 rmidi->private_data = mpu;
173 rmidi->private_free = snd_msndmidi_free;
174 spin_lock_init(&mpu->input_lock);
175 strcpy(rmidi->name, "MSND MIDI");
176 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
177 &snd_msndmidi_input);
178 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
179 return 0;
180}
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
new file mode 100644
index 000000000000..60b6abd71612
--- /dev/null
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -0,0 +1,1238 @@
1/*********************************************************************
2 *
3 * Linux multisound pinnacle/fiji driver for ALSA.
4 *
5 * 2002/06/30 Karsten Wiese:
6 * for now this is only used to build a pinnacle / fiji driver.
7 * the OSS parent of this code is designed to also support
8 * the multisound classic via the file msnd_classic.c.
9 * to make it easier for some brave heart to implemt classic
10 * support in alsa, i left all the MSND_CLASSIC tokens in this file.
11 * but for now this untested & undone.
12 *
13 *
14 * ripped from linux kernel 2.4.18 by Karsten Wiese.
15 *
16 * the following is a copy of the 2.4.18 OSS FREE file-heading comment:
17 *
18 * Turtle Beach MultiSound Sound Card Driver for Linux
19 * msnd_pinnacle.c / msnd_classic.c
20 *
21 * -- If MSND_CLASSIC is defined:
22 *
23 * -> driver for Turtle Beach Classic/Monterey/Tahiti
24 *
25 * -- Else
26 *
27 * -> driver for Turtle Beach Pinnacle/Fiji
28 *
29 * 12-3-2000 Modified IO port validation Steve Sycamore
30 *
31 * Copyright (C) 1998 Andrew Veliath
32 *
33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or
36 * (at your option) any later version.
37 *
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
42 *
43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
46 *
47 ********************************************************************/
48
49#include <linux/kernel.h>
50#include <linux/module.h>
51#include <linux/interrupt.h>
52#include <linux/types.h>
53#include <linux/delay.h>
54#include <linux/ioport.h>
55#include <linux/firmware.h>
56#include <linux/isa.h>
57#include <linux/isapnp.h>
58#include <linux/irq.h>
59#include <linux/io.h>
60
61#include <sound/core.h>
62#include <sound/initval.h>
63#include <sound/asound.h>
64#include <sound/pcm.h>
65#include <sound/mpu401.h>
66
67#ifdef MSND_CLASSIC
68# ifndef __alpha__
69# define SLOWIO
70# endif
71#endif
72#include "msnd.h"
73#ifdef MSND_CLASSIC
74# include "msnd_classic.h"
75# define LOGNAME "msnd_classic"
76#else
77# include "msnd_pinnacle.h"
78# define LOGNAME "snd_msnd_pinnacle"
79#endif
80
81static void __devinit set_default_audio_parameters(struct snd_msnd *chip)
82{
83 chip->play_sample_size = DEFSAMPLESIZE;
84 chip->play_sample_rate = DEFSAMPLERATE;
85 chip->play_channels = DEFCHANNELS;
86 chip->capture_sample_size = DEFSAMPLESIZE;
87 chip->capture_sample_rate = DEFSAMPLERATE;
88 chip->capture_channels = DEFCHANNELS;
89}
90
91static void snd_msnd_eval_dsp_msg(struct snd_msnd *chip, u16 wMessage)
92{
93 switch (HIBYTE(wMessage)) {
94 case HIMT_PLAY_DONE: {
95 if (chip->banksPlayed < 3)
96 snd_printdd("%08X: HIMT_PLAY_DONE: %i\n",
97 (unsigned)jiffies, LOBYTE(wMessage));
98
99 if (chip->last_playbank == LOBYTE(wMessage)) {
100 snd_printdd("chip.last_playbank == LOBYTE(wMessage)\n");
101 break;
102 }
103 chip->banksPlayed++;
104
105 if (test_bit(F_WRITING, &chip->flags))
106 snd_msnd_DAPQ(chip, 0);
107
108 chip->last_playbank = LOBYTE(wMessage);
109 chip->playDMAPos += chip->play_period_bytes;
110 if (chip->playDMAPos > chip->playLimit)
111 chip->playDMAPos = 0;
112 snd_pcm_period_elapsed(chip->playback_substream);
113
114 break;
115 }
116 case HIMT_RECORD_DONE:
117 if (chip->last_recbank == LOBYTE(wMessage))
118 break;
119 chip->last_recbank = LOBYTE(wMessage);
120 chip->captureDMAPos += chip->capturePeriodBytes;
121 if (chip->captureDMAPos > (chip->captureLimit))
122 chip->captureDMAPos = 0;
123
124 if (test_bit(F_READING, &chip->flags))
125 snd_msnd_DARQ(chip, chip->last_recbank);
126
127 snd_pcm_period_elapsed(chip->capture_substream);
128 break;
129
130 case HIMT_DSP:
131 switch (LOBYTE(wMessage)) {
132#ifndef MSND_CLASSIC
133 case HIDSP_PLAY_UNDER:
134#endif
135 case HIDSP_INT_PLAY_UNDER:
136 snd_printd(KERN_WARNING LOGNAME ": Play underflow %i\n",
137 chip->banksPlayed);
138 if (chip->banksPlayed > 2)
139 clear_bit(F_WRITING, &chip->flags);
140 break;
141
142 case HIDSP_INT_RECORD_OVER:
143 snd_printd(KERN_WARNING LOGNAME ": Record overflow\n");
144 clear_bit(F_READING, &chip->flags);
145 break;
146
147 default:
148 snd_printd(KERN_WARNING LOGNAME
149 ": DSP message %d 0x%02x\n",
150 LOBYTE(wMessage), LOBYTE(wMessage));
151 break;
152 }
153 break;
154
155 case HIMT_MIDI_IN_UCHAR:
156 if (chip->msndmidi_mpu)
157 snd_msndmidi_input_read(chip->msndmidi_mpu);
158 break;
159
160 default:
161 snd_printd(KERN_WARNING LOGNAME ": HIMT message %d 0x%02x\n",
162 HIBYTE(wMessage), HIBYTE(wMessage));
163 break;
164 }
165}
166
167static irqreturn_t snd_msnd_interrupt(int irq, void *dev_id)
168{
169 struct snd_msnd *chip = dev_id;
170 void *pwDSPQData = chip->mappedbase + DSPQ_DATA_BUFF;
171
172 /* Send ack to DSP */
173 /* inb(chip->io + HP_RXL); */
174
175 /* Evaluate queued DSP messages */
176 while (readw(chip->DSPQ + JQS_wTail) != readw(chip->DSPQ + JQS_wHead)) {
177 u16 wTmp;
178
179 snd_msnd_eval_dsp_msg(chip,
180 readw(pwDSPQData + 2 * readw(chip->DSPQ + JQS_wHead)));
181
182 wTmp = readw(chip->DSPQ + JQS_wHead) + 1;
183 if (wTmp > readw(chip->DSPQ + JQS_wSize))
184 writew(0, chip->DSPQ + JQS_wHead);
185 else
186 writew(wTmp, chip->DSPQ + JQS_wHead);
187 }
188 /* Send ack to DSP */
189 inb(chip->io + HP_RXL);
190 return IRQ_HANDLED;
191}
192
193
194static int snd_msnd_reset_dsp(long io, unsigned char *info)
195{
196 int timeout = 100;
197
198 outb(HPDSPRESET_ON, io + HP_DSPR);
199 msleep(1);
200#ifndef MSND_CLASSIC
201 if (info)
202 *info = inb(io + HP_INFO);
203#endif
204 outb(HPDSPRESET_OFF, io + HP_DSPR);
205 msleep(1);
206 while (timeout-- > 0) {
207 if (inb(io + HP_CVR) == HP_CVR_DEF)
208 return 0;
209 msleep(1);
210 }
211 snd_printk(KERN_ERR LOGNAME ": Cannot reset DSP\n");
212
213 return -EIO;
214}
215
216static int __devinit snd_msnd_probe(struct snd_card *card)
217{
218 struct snd_msnd *chip = card->private_data;
219 unsigned char info;
220#ifndef MSND_CLASSIC
221 char *xv, *rev = NULL;
222 char *pin = "TB Pinnacle", *fiji = "TB Fiji";
223 char *pinfiji = "TB Pinnacle/Fiji";
224#endif
225
226 if (!request_region(chip->io, DSP_NUMIO, "probing")) {
227 snd_printk(KERN_ERR LOGNAME ": I/O port conflict\n");
228 return -ENODEV;
229 }
230
231 if (snd_msnd_reset_dsp(chip->io, &info) < 0) {
232 release_region(chip->io, DSP_NUMIO);
233 return -ENODEV;
234 }
235
236#ifdef MSND_CLASSIC
237 strcpy(card->shortname, "Classic/Tahiti/Monterey");
238 strcpy(card->longname, "Turtle Beach Multisound");
239 printk(KERN_INFO LOGNAME ": %s, "
240 "I/O 0x%lx-0x%lx, IRQ %d, memory mapped to 0x%lX-0x%lX\n",
241 card->shortname,
242 chip->io, chip->io + DSP_NUMIO - 1,
243 chip->irq,
244 chip->base, chip->base + 0x7fff);
245#else
246 switch (info >> 4) {
247 case 0xf:
248 xv = "<= 1.15";
249 break;
250 case 0x1:
251 xv = "1.18/1.2";
252 break;
253 case 0x2:
254 xv = "1.3";
255 break;
256 case 0x3:
257 xv = "1.4";
258 break;
259 default:
260 xv = "unknown";
261 break;
262 }
263
264 switch (info & 0x7) {
265 case 0x0:
266 rev = "I";
267 strcpy(card->shortname, pin);
268 break;
269 case 0x1:
270 rev = "F";
271 strcpy(card->shortname, pin);
272 break;
273 case 0x2:
274 rev = "G";
275 strcpy(card->shortname, pin);
276 break;
277 case 0x3:
278 rev = "H";
279 strcpy(card->shortname, pin);
280 break;
281 case 0x4:
282 rev = "E";
283 strcpy(card->shortname, fiji);
284 break;
285 case 0x5:
286 rev = "C";
287 strcpy(card->shortname, fiji);
288 break;
289 case 0x6:
290 rev = "D";
291 strcpy(card->shortname, fiji);
292 break;
293 case 0x7:
294 rev = "A-B (Fiji) or A-E (Pinnacle)";
295 strcpy(card->shortname, pinfiji);
296 break;
297 }
298 strcpy(card->longname, "Turtle Beach Multisound Pinnacle");
299 printk(KERN_INFO LOGNAME ": %s revision %s, Xilinx version %s, "
300 "I/O 0x%lx-0x%lx, IRQ %d, memory mapped to 0x%lX-0x%lX\n",
301 card->shortname,
302 rev, xv,
303 chip->io, chip->io + DSP_NUMIO - 1,
304 chip->irq,
305 chip->base, chip->base + 0x7fff);
306#endif
307
308 release_region(chip->io, DSP_NUMIO);
309 return 0;
310}
311
312static int snd_msnd_init_sma(struct snd_msnd *chip)
313{
314 static int initted;
315 u16 mastVolLeft, mastVolRight;
316 unsigned long flags;
317
318#ifdef MSND_CLASSIC
319 outb(chip->memid, chip->io + HP_MEMM);
320#endif
321 outb(HPBLKSEL_0, chip->io + HP_BLKS);
322 /* Motorola 56k shared memory base */
323 chip->SMA = chip->mappedbase + SMA_STRUCT_START;
324
325 if (initted) {
326 mastVolLeft = readw(chip->SMA + SMA_wCurrMastVolLeft);
327 mastVolRight = readw(chip->SMA + SMA_wCurrMastVolRight);
328 } else
329 mastVolLeft = mastVolRight = 0;
330 memset_io(chip->mappedbase, 0, 0x8000);
331
332 /* Critical section: bank 1 access */
333 spin_lock_irqsave(&chip->lock, flags);
334 outb(HPBLKSEL_1, chip->io + HP_BLKS);
335 memset_io(chip->mappedbase, 0, 0x8000);
336 outb(HPBLKSEL_0, chip->io + HP_BLKS);
337 spin_unlock_irqrestore(&chip->lock, flags);
338
339 /* Digital audio play queue */
340 chip->DAPQ = chip->mappedbase + DAPQ_OFFSET;
341 snd_msnd_init_queue(chip->DAPQ, DAPQ_DATA_BUFF, DAPQ_BUFF_SIZE);
342
343 /* Digital audio record queue */
344 chip->DARQ = chip->mappedbase + DARQ_OFFSET;
345 snd_msnd_init_queue(chip->DARQ, DARQ_DATA_BUFF, DARQ_BUFF_SIZE);
346
347 /* MIDI out queue */
348 chip->MODQ = chip->mappedbase + MODQ_OFFSET;
349 snd_msnd_init_queue(chip->MODQ, MODQ_DATA_BUFF, MODQ_BUFF_SIZE);
350
351 /* MIDI in queue */
352 chip->MIDQ = chip->mappedbase + MIDQ_OFFSET;
353 snd_msnd_init_queue(chip->MIDQ, MIDQ_DATA_BUFF, MIDQ_BUFF_SIZE);
354
355 /* DSP -> host message queue */
356 chip->DSPQ = chip->mappedbase + DSPQ_OFFSET;
357 snd_msnd_init_queue(chip->DSPQ, DSPQ_DATA_BUFF, DSPQ_BUFF_SIZE);
358
359 /* Setup some DSP values */
360#ifndef MSND_CLASSIC
361 writew(1, chip->SMA + SMA_wCurrPlayFormat);
362 writew(chip->play_sample_size, chip->SMA + SMA_wCurrPlaySampleSize);
363 writew(chip->play_channels, chip->SMA + SMA_wCurrPlayChannels);
364 writew(chip->play_sample_rate, chip->SMA + SMA_wCurrPlaySampleRate);
365#endif
366 writew(chip->play_sample_rate, chip->SMA + SMA_wCalFreqAtoD);
367 writew(mastVolLeft, chip->SMA + SMA_wCurrMastVolLeft);
368 writew(mastVolRight, chip->SMA + SMA_wCurrMastVolRight);
369#ifndef MSND_CLASSIC
370 writel(0x00010000, chip->SMA + SMA_dwCurrPlayPitch);
371 writel(0x00000001, chip->SMA + SMA_dwCurrPlayRate);
372#endif
373 writew(0x303, chip->SMA + SMA_wCurrInputTagBits);
374
375 initted = 1;
376
377 return 0;
378}
379
380
381static int upload_dsp_code(struct snd_card *card)
382{
383 struct snd_msnd *chip = card->private_data;
384 const struct firmware *init_fw = NULL, *perm_fw = NULL;
385 int err;
386
387 outb(HPBLKSEL_0, chip->io + HP_BLKS);
388
389 err = request_firmware(&init_fw, INITCODEFILE, card->dev);
390 if (err < 0) {
391 printk(KERN_ERR LOGNAME ": Error loading " INITCODEFILE);
392 goto cleanup1;
393 }
394 err = request_firmware(&perm_fw, PERMCODEFILE, card->dev);
395 if (err < 0) {
396 printk(KERN_ERR LOGNAME ": Error loading " PERMCODEFILE);
397 goto cleanup;
398 }
399
400 memcpy_toio(chip->mappedbase, perm_fw->data, perm_fw->size);
401 if (snd_msnd_upload_host(chip, init_fw->data, init_fw->size) < 0) {
402 printk(KERN_WARNING LOGNAME ": Error uploading to DSP\n");
403 err = -ENODEV;
404 goto cleanup;
405 }
406 printk(KERN_INFO LOGNAME ": DSP firmware uploaded\n");
407 err = 0;
408
409cleanup:
410 release_firmware(perm_fw);
411cleanup1:
412 release_firmware(init_fw);
413 return err;
414}
415
416#ifdef MSND_CLASSIC
417static void reset_proteus(struct snd_msnd *chip)
418{
419 outb(HPPRORESET_ON, chip->io + HP_PROR);
420 msleep(TIME_PRO_RESET);
421 outb(HPPRORESET_OFF, chip->io + HP_PROR);
422 msleep(TIME_PRO_RESET_DONE);
423}
424#endif
425
426static int snd_msnd_initialize(struct snd_card *card)
427{
428 struct snd_msnd *chip = card->private_data;
429 int err, timeout;
430
431#ifdef MSND_CLASSIC
432 outb(HPWAITSTATE_0, chip->io + HP_WAIT);
433 outb(HPBITMODE_16, chip->io + HP_BITM);
434
435 reset_proteus(chip);
436#endif
437 err = snd_msnd_init_sma(chip);
438 if (err < 0) {
439 printk(KERN_WARNING LOGNAME ": Cannot initialize SMA\n");
440 return err;
441 }
442
443 err = snd_msnd_reset_dsp(chip->io, NULL);
444 if (err < 0)
445 return err;
446
447 err = upload_dsp_code(card);
448 if (err < 0) {
449 printk(KERN_WARNING LOGNAME ": Cannot upload DSP code\n");
450 return err;
451 }
452
453 timeout = 200;
454
455 while (readw(chip->mappedbase)) {
456 msleep(1);
457 if (!timeout--) {
458 snd_printd(KERN_ERR LOGNAME ": DSP reset timeout\n");
459 return -EIO;
460 }
461 }
462
463 snd_msndmix_setup(chip);
464 return 0;
465}
466
467static int snd_msnd_dsp_full_reset(struct snd_card *card)
468{
469 struct snd_msnd *chip = card->private_data;
470 int rv;
471
472 if (test_bit(F_RESETTING, &chip->flags) || ++chip->nresets > 10)
473 return 0;
474
475 set_bit(F_RESETTING, &chip->flags);
476 snd_msnd_dsp_halt(chip, NULL); /* Unconditionally halt */
477
478 rv = snd_msnd_initialize(card);
479 if (rv)
480 printk(KERN_WARNING LOGNAME ": DSP reset failed\n");
481 snd_msndmix_force_recsrc(chip, 0);
482 clear_bit(F_RESETTING, &chip->flags);
483 return rv;
484}
485
486static int snd_msnd_dev_free(struct snd_device *device)
487{
488 snd_printdd("snd_msnd_chip_free()\n");
489 return 0;
490}
491
492static int snd_msnd_send_dsp_cmd_chk(struct snd_msnd *chip, u8 cmd)
493{
494 if (snd_msnd_send_dsp_cmd(chip, cmd) == 0)
495 return 0;
496 snd_msnd_dsp_full_reset(chip->card);
497 return snd_msnd_send_dsp_cmd(chip, cmd);
498}
499
500static int __devinit snd_msnd_calibrate_adc(struct snd_msnd *chip, u16 srate)
501{
502 snd_printdd("snd_msnd_calibrate_adc(%i)\n", srate);
503 writew(srate, chip->SMA + SMA_wCalFreqAtoD);
504 if (chip->calibrate_signal == 0)
505 writew(readw(chip->SMA + SMA_wCurrHostStatusFlags)
506 | 0x0001, chip->SMA + SMA_wCurrHostStatusFlags);
507 else
508 writew(readw(chip->SMA + SMA_wCurrHostStatusFlags)
509 & ~0x0001, chip->SMA + SMA_wCurrHostStatusFlags);
510 if (snd_msnd_send_word(chip, 0, 0, HDEXAR_CAL_A_TO_D) == 0 &&
511 snd_msnd_send_dsp_cmd_chk(chip, HDEX_AUX_REQ) == 0) {
512 schedule_timeout_interruptible(msecs_to_jiffies(333));
513 return 0;
514 }
515 printk(KERN_WARNING LOGNAME ": ADC calibration failed\n");
516 return -EIO;
517}
518
519/*
520 * ALSA callback function, called when attempting to open the MIDI device.
521 */
522static int snd_msnd_mpu401_open(struct snd_mpu401 *mpu)
523{
524 snd_msnd_enable_irq(mpu->private_data);
525 snd_msnd_send_dsp_cmd(mpu->private_data, HDEX_MIDI_IN_START);
526 return 0;
527}
528
529static void snd_msnd_mpu401_close(struct snd_mpu401 *mpu)
530{
531 snd_msnd_send_dsp_cmd(mpu->private_data, HDEX_MIDI_IN_STOP);
532 snd_msnd_disable_irq(mpu->private_data);
533}
534
535static long mpu_io[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
536static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
537
538static int __devinit snd_msnd_attach(struct snd_card *card)
539{
540 struct snd_msnd *chip = card->private_data;
541 int err;
542 static struct snd_device_ops ops = {
543 .dev_free = snd_msnd_dev_free,
544 };
545
546 err = request_irq(chip->irq, snd_msnd_interrupt, 0, card->shortname,
547 chip);
548 if (err < 0) {
549 printk(KERN_ERR LOGNAME ": Couldn't grab IRQ %d\n", chip->irq);
550 return err;
551 }
552 request_region(chip->io, DSP_NUMIO, card->shortname);
553
554 if (!request_mem_region(chip->base, BUFFSIZE, card->shortname)) {
555 printk(KERN_ERR LOGNAME
556 ": unable to grab memory region 0x%lx-0x%lx\n",
557 chip->base, chip->base + BUFFSIZE - 1);
558 release_region(chip->io, DSP_NUMIO);
559 free_irq(chip->irq, chip);
560 return -EBUSY;
561 }
562 chip->mappedbase = ioremap_nocache(chip->base, 0x8000);
563 if (!chip->mappedbase) {
564 printk(KERN_ERR LOGNAME
565 ": unable to map memory region 0x%lx-0x%lx\n",
566 chip->base, chip->base + BUFFSIZE - 1);
567 err = -EIO;
568 goto err_release_region;
569 }
570
571 err = snd_msnd_dsp_full_reset(card);
572 if (err < 0)
573 goto err_release_region;
574
575 /* Register device */
576 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
577 if (err < 0)
578 goto err_release_region;
579
580 err = snd_msnd_pcm(card, 0, NULL);
581 if (err < 0) {
582 printk(KERN_ERR LOGNAME ": error creating new PCM device\n");
583 goto err_release_region;
584 }
585
586 err = snd_msndmix_new(card);
587 if (err < 0) {
588 printk(KERN_ERR LOGNAME ": error creating new Mixer device\n");
589 goto err_release_region;
590 }
591
592
593 if (mpu_io[0] != SNDRV_AUTO_PORT) {
594 struct snd_mpu401 *mpu;
595
596 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
597 mpu_io[0],
598 MPU401_MODE_INPUT |
599 MPU401_MODE_OUTPUT,
600 mpu_irq[0], IRQF_DISABLED,
601 &chip->rmidi);
602 if (err < 0) {
603 printk(KERN_ERR LOGNAME
604 ": error creating new Midi device\n");
605 goto err_release_region;
606 }
607 mpu = chip->rmidi->private_data;
608
609 mpu->open_input = snd_msnd_mpu401_open;
610 mpu->close_input = snd_msnd_mpu401_close;
611 mpu->private_data = chip;
612 }
613
614 disable_irq(chip->irq);
615 snd_msnd_calibrate_adc(chip, chip->play_sample_rate);
616 snd_msndmix_force_recsrc(chip, 0);
617
618 err = snd_card_register(card);
619 if (err < 0)
620 goto err_release_region;
621
622 return 0;
623
624err_release_region:
625 if (chip->mappedbase)
626 iounmap(chip->mappedbase);
627 release_mem_region(chip->base, BUFFSIZE);
628 release_region(chip->io, DSP_NUMIO);
629 free_irq(chip->irq, chip);
630 return err;
631}
632
633
634static void __devexit snd_msnd_unload(struct snd_card *card)
635{
636 struct snd_msnd *chip = card->private_data;
637
638 iounmap(chip->mappedbase);
639 release_mem_region(chip->base, BUFFSIZE);
640 release_region(chip->io, DSP_NUMIO);
641 free_irq(chip->irq, chip);
642 snd_card_free(card);
643}
644
645#ifndef MSND_CLASSIC
646
647/* Pinnacle/Fiji Logical Device Configuration */
648
649static int __devinit snd_msnd_write_cfg(int cfg, int reg, int value)
650{
651 outb(reg, cfg);
652 outb(value, cfg + 1);
653 if (value != inb(cfg + 1)) {
654 printk(KERN_ERR LOGNAME ": snd_msnd_write_cfg: I/O error\n");
655 return -EIO;
656 }
657 return 0;
658}
659
660static int __devinit snd_msnd_write_cfg_io0(int cfg, int num, u16 io)
661{
662 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
663 return -EIO;
664 if (snd_msnd_write_cfg(cfg, IREG_IO0_BASEHI, HIBYTE(io)))
665 return -EIO;
666 if (snd_msnd_write_cfg(cfg, IREG_IO0_BASELO, LOBYTE(io)))
667 return -EIO;
668 return 0;
669}
670
671static int __devinit snd_msnd_write_cfg_io1(int cfg, int num, u16 io)
672{
673 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
674 return -EIO;
675 if (snd_msnd_write_cfg(cfg, IREG_IO1_BASEHI, HIBYTE(io)))
676 return -EIO;
677 if (snd_msnd_write_cfg(cfg, IREG_IO1_BASELO, LOBYTE(io)))
678 return -EIO;
679 return 0;
680}
681
682static int __devinit snd_msnd_write_cfg_irq(int cfg, int num, u16 irq)
683{
684 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
685 return -EIO;
686 if (snd_msnd_write_cfg(cfg, IREG_IRQ_NUMBER, LOBYTE(irq)))
687 return -EIO;
688 if (snd_msnd_write_cfg(cfg, IREG_IRQ_TYPE, IRQTYPE_EDGE))
689 return -EIO;
690 return 0;
691}
692
693static int __devinit snd_msnd_write_cfg_mem(int cfg, int num, int mem)
694{
695 u16 wmem;
696
697 mem >>= 8;
698 wmem = (u16)(mem & 0xfff);
699 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
700 return -EIO;
701 if (snd_msnd_write_cfg(cfg, IREG_MEMBASEHI, HIBYTE(wmem)))
702 return -EIO;
703 if (snd_msnd_write_cfg(cfg, IREG_MEMBASELO, LOBYTE(wmem)))
704 return -EIO;
705 if (wmem && snd_msnd_write_cfg(cfg, IREG_MEMCONTROL,
706 MEMTYPE_HIADDR | MEMTYPE_16BIT))
707 return -EIO;
708 return 0;
709}
710
711static int __devinit snd_msnd_activate_logical(int cfg, int num)
712{
713 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
714 return -EIO;
715 if (snd_msnd_write_cfg(cfg, IREG_ACTIVATE, LD_ACTIVATE))
716 return -EIO;
717 return 0;
718}
719
720static int __devinit snd_msnd_write_cfg_logical(int cfg, int num, u16 io0,
721 u16 io1, u16 irq, int mem)
722{
723 if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
724 return -EIO;
725 if (snd_msnd_write_cfg_io0(cfg, num, io0))
726 return -EIO;
727 if (snd_msnd_write_cfg_io1(cfg, num, io1))
728 return -EIO;
729 if (snd_msnd_write_cfg_irq(cfg, num, irq))
730 return -EIO;
731 if (snd_msnd_write_cfg_mem(cfg, num, mem))
732 return -EIO;
733 if (snd_msnd_activate_logical(cfg, num))
734 return -EIO;
735 return 0;
736}
737
738static int __devinit snd_msnd_pinnacle_cfg_reset(int cfg)
739{
740 int i;
741
742 /* Reset devices if told to */
743 printk(KERN_INFO LOGNAME ": Resetting all devices\n");
744 for (i = 0; i < 4; ++i)
745 if (snd_msnd_write_cfg_logical(cfg, i, 0, 0, 0, 0))
746 return -EIO;
747
748 return 0;
749}
750#endif
751
752static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
753static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
754
755module_param_array(index, int, NULL, S_IRUGO);
756MODULE_PARM_DESC(index, "Index value for msnd_pinnacle soundcard.");
757module_param_array(id, charp, NULL, S_IRUGO);
758MODULE_PARM_DESC(id, "ID string for msnd_pinnacle soundcard.");
759
760static long io[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
761static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
762static long mem[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
763
764static long cfg[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
765
766#ifndef MSND_CLASSIC
767/* Extra Peripheral Configuration (Default: Disable) */
768static long ide_io0[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
769static long ide_io1[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
770static int ide_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
771
772static long joystick_io[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
773/* If we have the digital daugherboard... */
774static int digital[SNDRV_CARDS];
775
776/* Extra Peripheral Configuration */
777static int reset[SNDRV_CARDS];
778#endif
779
780static int write_ndelay[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 1 };
781
782static int calibrate_signal;
783
784#ifdef CONFIG_PNP
785static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
786module_param_array(isapnp, bool, NULL, 0444);
787MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
788#define has_isapnp(x) isapnp[x]
789#else
790#define has_isapnp(x) 0
791#endif
792
793MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>");
794MODULE_DESCRIPTION("Turtle Beach " LONGNAME " Linux Driver");
795MODULE_LICENSE("GPL");
796MODULE_FIRMWARE(INITCODEFILE);
797MODULE_FIRMWARE(PERMCODEFILE);
798
799module_param_array(io, long, NULL, S_IRUGO);
800MODULE_PARM_DESC(io, "IO port #");
801module_param_array(irq, int, NULL, S_IRUGO);
802module_param_array(mem, long, NULL, S_IRUGO);
803module_param_array(write_ndelay, int, NULL, S_IRUGO);
804module_param(calibrate_signal, int, S_IRUGO);
805#ifndef MSND_CLASSIC
806module_param_array(digital, int, NULL, S_IRUGO);
807module_param_array(cfg, long, NULL, S_IRUGO);
808module_param_array(reset, int, 0, S_IRUGO);
809module_param_array(mpu_io, long, NULL, S_IRUGO);
810module_param_array(mpu_irq, int, NULL, S_IRUGO);
811module_param_array(ide_io0, long, NULL, S_IRUGO);
812module_param_array(ide_io1, long, NULL, S_IRUGO);
813module_param_array(ide_irq, int, NULL, S_IRUGO);
814module_param_array(joystick_io, long, NULL, S_IRUGO);
815#endif
816
817
818static int __devinit snd_msnd_isa_match(struct device *pdev, unsigned int i)
819{
820 if (io[i] == SNDRV_AUTO_PORT)
821 return 0;
822
823 if (irq[i] == SNDRV_AUTO_PORT || mem[i] == SNDRV_AUTO_PORT) {
824 printk(KERN_WARNING LOGNAME ": io, irq and mem must be set\n");
825 return 0;
826 }
827
828#ifdef MSND_CLASSIC
829 if (!(io[i] == 0x290 ||
830 io[i] == 0x260 ||
831 io[i] == 0x250 ||
832 io[i] == 0x240 ||
833 io[i] == 0x230 ||
834 io[i] == 0x220 ||
835 io[i] == 0x210 ||
836 io[i] == 0x3e0)) {
837 printk(KERN_ERR LOGNAME ": \"io\" - DSP I/O base must be set "
838 " to 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x290, "
839 "or 0x3E0\n");
840 return 0;
841 }
842#else
843 if (io[i] < 0x100 || io[i] > 0x3e0 || (io[i] % 0x10) != 0) {
844 printk(KERN_ERR LOGNAME
845 ": \"io\" - DSP I/O base must within the range 0x100 "
846 "to 0x3E0 and must be evenly divisible by 0x10\n");
847 return 0;
848 }
849#endif /* MSND_CLASSIC */
850
851 if (!(irq[i] == 5 ||
852 irq[i] == 7 ||
853 irq[i] == 9 ||
854 irq[i] == 10 ||
855 irq[i] == 11 ||
856 irq[i] == 12)) {
857 printk(KERN_ERR LOGNAME
858 ": \"irq\" - must be set to 5, 7, 9, 10, 11 or 12\n");
859 return 0;
860 }
861
862 if (!(mem[i] == 0xb0000 ||
863 mem[i] == 0xc8000 ||
864 mem[i] == 0xd0000 ||
865 mem[i] == 0xd8000 ||
866 mem[i] == 0xe0000 ||
867 mem[i] == 0xe8000)) {
868 printk(KERN_ERR LOGNAME ": \"mem\" - must be set to "
869 "0xb0000, 0xc8000, 0xd0000, 0xd8000, 0xe0000 or "
870 "0xe8000\n");
871 return 0;
872 }
873
874#ifndef MSND_CLASSIC
875 if (cfg[i] == SNDRV_AUTO_PORT) {
876 printk(KERN_INFO LOGNAME ": Assuming PnP mode\n");
877 } else if (cfg[i] != 0x250 && cfg[i] != 0x260 && cfg[i] != 0x270) {
878 printk(KERN_INFO LOGNAME
879 ": Config port must be 0x250, 0x260 or 0x270 "
880 "(or unspecified for PnP mode)\n");
881 return 0;
882 }
883#endif /* MSND_CLASSIC */
884
885 return 1;
886}
887
888static int __devinit snd_msnd_isa_probe(struct device *pdev, unsigned int idx)
889{
890 int err;
891 struct snd_card *card;
892 struct snd_msnd *chip;
893
894 if (has_isapnp(idx) || cfg[idx] == SNDRV_AUTO_PORT) {
895 printk(KERN_INFO LOGNAME ": Assuming PnP mode\n");
896 return -ENODEV;
897 }
898
899 err = snd_card_create(index[idx], id[idx], THIS_MODULE,
900 sizeof(struct snd_msnd), &card);
901 if (err < 0)
902 return err;
903
904 snd_card_set_dev(card, pdev);
905 chip = card->private_data;
906 chip->card = card;
907
908#ifdef MSND_CLASSIC
909 switch (irq[idx]) {
910 case 5:
911 chip->irqid = HPIRQ_5; break;
912 case 7:
913 chip->irqid = HPIRQ_7; break;
914 case 9:
915 chip->irqid = HPIRQ_9; break;
916 case 10:
917 chip->irqid = HPIRQ_10; break;
918 case 11:
919 chip->irqid = HPIRQ_11; break;
920 case 12:
921 chip->irqid = HPIRQ_12; break;
922 }
923
924 switch (mem[idx]) {
925 case 0xb0000:
926 chip->memid = HPMEM_B000; break;
927 case 0xc8000:
928 chip->memid = HPMEM_C800; break;
929 case 0xd0000:
930 chip->memid = HPMEM_D000; break;
931 case 0xd8000:
932 chip->memid = HPMEM_D800; break;
933 case 0xe0000:
934 chip->memid = HPMEM_E000; break;
935 case 0xe8000:
936 chip->memid = HPMEM_E800; break;
937 }
938#else
939 printk(KERN_INFO LOGNAME ": Non-PnP mode: configuring at port 0x%lx\n",
940 cfg[idx]);
941
942 if (!request_region(cfg[idx], 2, "Pinnacle/Fiji Config")) {
943 printk(KERN_ERR LOGNAME ": Config port 0x%lx conflict\n",
944 cfg[idx]);
945 snd_card_free(card);
946 return -EIO;
947 }
948 if (reset[idx])
949 if (snd_msnd_pinnacle_cfg_reset(cfg[idx])) {
950 err = -EIO;
951 goto cfg_error;
952 }
953
954 /* DSP */
955 err = snd_msnd_write_cfg_logical(cfg[idx], 0,
956 io[idx], 0,
957 irq[idx], mem[idx]);
958
959 if (err)
960 goto cfg_error;
961
962 /* The following are Pinnacle specific */
963
964 /* MPU */
965 if (mpu_io[idx] != SNDRV_AUTO_PORT
966 && mpu_irq[idx] != SNDRV_AUTO_IRQ) {
967 printk(KERN_INFO LOGNAME
968 ": Configuring MPU to I/O 0x%lx IRQ %d\n",
969 mpu_io[idx], mpu_irq[idx]);
970 err = snd_msnd_write_cfg_logical(cfg[idx], 1,
971 mpu_io[idx], 0,
972 mpu_irq[idx], 0);
973
974 if (err)
975 goto cfg_error;
976 }
977
978 /* IDE */
979 if (ide_io0[idx] != SNDRV_AUTO_PORT
980 && ide_io1[idx] != SNDRV_AUTO_PORT
981 && ide_irq[idx] != SNDRV_AUTO_IRQ) {
982 printk(KERN_INFO LOGNAME
983 ": Configuring IDE to I/O 0x%lx, 0x%lx IRQ %d\n",
984 ide_io0[idx], ide_io1[idx], ide_irq[idx]);
985 err = snd_msnd_write_cfg_logical(cfg[idx], 2,
986 ide_io0[idx], ide_io1[idx],
987 ide_irq[idx], 0);
988
989 if (err)
990 goto cfg_error;
991 }
992
993 /* Joystick */
994 if (joystick_io[idx] != SNDRV_AUTO_PORT) {
995 printk(KERN_INFO LOGNAME
996 ": Configuring joystick to I/O 0x%lx\n",
997 joystick_io[idx]);
998 err = snd_msnd_write_cfg_logical(cfg[idx], 3,
999 joystick_io[idx], 0,
1000 0, 0);
1001
1002 if (err)
1003 goto cfg_error;
1004 }
1005 release_region(cfg[idx], 2);
1006
1007#endif /* MSND_CLASSIC */
1008
1009 set_default_audio_parameters(chip);
1010#ifdef MSND_CLASSIC
1011 chip->type = msndClassic;
1012#else
1013 chip->type = msndPinnacle;
1014#endif
1015 chip->io = io[idx];
1016 chip->irq = irq[idx];
1017 chip->base = mem[idx];
1018
1019 chip->calibrate_signal = calibrate_signal ? 1 : 0;
1020 chip->recsrc = 0;
1021 chip->dspq_data_buff = DSPQ_DATA_BUFF;
1022 chip->dspq_buff_size = DSPQ_BUFF_SIZE;
1023 if (write_ndelay[idx])
1024 clear_bit(F_DISABLE_WRITE_NDELAY, &chip->flags);
1025 else
1026 set_bit(F_DISABLE_WRITE_NDELAY, &chip->flags);
1027#ifndef MSND_CLASSIC
1028 if (digital[idx])
1029 set_bit(F_HAVEDIGITAL, &chip->flags);
1030#endif
1031 spin_lock_init(&chip->lock);
1032 err = snd_msnd_probe(card);
1033 if (err < 0) {
1034 printk(KERN_ERR LOGNAME ": Probe failed\n");
1035 snd_card_free(card);
1036 return err;
1037 }
1038
1039 err = snd_msnd_attach(card);
1040 if (err < 0) {
1041 printk(KERN_ERR LOGNAME ": Attach failed\n");
1042 snd_card_free(card);
1043 return err;
1044 }
1045 dev_set_drvdata(pdev, card);
1046
1047 return 0;
1048
1049#ifndef MSND_CLASSIC
1050cfg_error:
1051 release_region(cfg[idx], 2);
1052 snd_card_free(card);
1053 return err;
1054#endif
1055}
1056
1057static int __devexit snd_msnd_isa_remove(struct device *pdev, unsigned int dev)
1058{
1059 snd_msnd_unload(dev_get_drvdata(pdev));
1060 dev_set_drvdata(pdev, NULL);
1061 return 0;
1062}
1063
1064#define DEV_NAME "msnd-pinnacle"
1065
1066static struct isa_driver snd_msnd_driver = {
1067 .match = snd_msnd_isa_match,
1068 .probe = snd_msnd_isa_probe,
1069 .remove = __devexit_p(snd_msnd_isa_remove),
1070 /* FIXME: suspend, resume */
1071 .driver = {
1072 .name = DEV_NAME
1073 },
1074};
1075
1076#ifdef CONFIG_PNP
1077static int __devinit snd_msnd_pnp_detect(struct pnp_card_link *pcard,
1078 const struct pnp_card_device_id *pid)
1079{
1080 static int idx;
1081 struct pnp_dev *pnp_dev;
1082 struct pnp_dev *mpu_dev;
1083 struct snd_card *card;
1084 struct snd_msnd *chip;
1085 int ret;
1086
1087 for ( ; idx < SNDRV_CARDS; idx++) {
1088 if (has_isapnp(idx))
1089 break;
1090 }
1091 if (idx >= SNDRV_CARDS)
1092 return -ENODEV;
1093
1094 /*
1095 * Check that we still have room for another sound card ...
1096 */
1097 pnp_dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL);
1098 if (!pnp_dev)
1099 return -ENODEV;
1100
1101 mpu_dev = pnp_request_card_device(pcard, pid->devs[1].id, NULL);
1102 if (!mpu_dev)
1103 return -ENODEV;
1104
1105 if (!pnp_is_active(pnp_dev) && pnp_activate_dev(pnp_dev) < 0) {
1106 printk(KERN_INFO "msnd_pinnacle: device is inactive\n");
1107 return -EBUSY;
1108 }
1109
1110 if (!pnp_is_active(mpu_dev) && pnp_activate_dev(mpu_dev) < 0) {
1111 printk(KERN_INFO "msnd_pinnacle: MPU device is inactive\n");
1112 return -EBUSY;
1113 }
1114
1115 /*
1116 * Create a new ALSA sound card entry, in anticipation
1117 * of detecting our hardware ...
1118 */
1119 ret = snd_card_create(index[idx], id[idx], THIS_MODULE,
1120 sizeof(struct snd_msnd), &card);
1121 if (ret < 0)
1122 return ret;
1123
1124 chip = card->private_data;
1125 chip->card = card;
1126 snd_card_set_dev(card, &pcard->card->dev);
1127
1128 /*
1129 * Read the correct parameters off the ISA PnP bus ...
1130 */
1131 io[idx] = pnp_port_start(pnp_dev, 0);
1132 irq[idx] = pnp_irq(pnp_dev, 0);
1133 mem[idx] = pnp_mem_start(pnp_dev, 0);
1134 mpu_io[idx] = pnp_port_start(mpu_dev, 0);
1135 mpu_irq[idx] = pnp_irq(mpu_dev, 0);
1136
1137 set_default_audio_parameters(chip);
1138#ifdef MSND_CLASSIC
1139 chip->type = msndClassic;
1140#else
1141 chip->type = msndPinnacle;
1142#endif
1143 chip->io = io[idx];
1144 chip->irq = irq[idx];
1145 chip->base = mem[idx];
1146
1147 chip->calibrate_signal = calibrate_signal ? 1 : 0;
1148 chip->recsrc = 0;
1149 chip->dspq_data_buff = DSPQ_DATA_BUFF;
1150 chip->dspq_buff_size = DSPQ_BUFF_SIZE;
1151 if (write_ndelay[idx])
1152 clear_bit(F_DISABLE_WRITE_NDELAY, &chip->flags);
1153 else
1154 set_bit(F_DISABLE_WRITE_NDELAY, &chip->flags);
1155#ifndef MSND_CLASSIC
1156 if (digital[idx])
1157 set_bit(F_HAVEDIGITAL, &chip->flags);
1158#endif
1159 spin_lock_init(&chip->lock);
1160 ret = snd_msnd_probe(card);
1161 if (ret < 0) {
1162 printk(KERN_ERR LOGNAME ": Probe failed\n");
1163 goto _release_card;
1164 }
1165
1166 ret = snd_msnd_attach(card);
1167 if (ret < 0) {
1168 printk(KERN_ERR LOGNAME ": Attach failed\n");
1169 goto _release_card;
1170 }
1171
1172 pnp_set_card_drvdata(pcard, card);
1173 ++idx;
1174 return 0;
1175
1176_release_card:
1177 snd_card_free(card);
1178 return ret;
1179}
1180
1181static void __devexit snd_msnd_pnp_remove(struct pnp_card_link *pcard)
1182{
1183 snd_msnd_unload(pnp_get_card_drvdata(pcard));
1184 pnp_set_card_drvdata(pcard, NULL);
1185}
1186
1187static int isa_registered;
1188static int pnp_registered;
1189
1190static struct pnp_card_device_id msnd_pnpids[] = {
1191 /* Pinnacle PnP */
1192 { .id = "BVJ0440", .devs = { { "TBS0000" }, { "TBS0001" } } },
1193 { .id = "" } /* end */
1194};
1195
1196MODULE_DEVICE_TABLE(pnp_card, msnd_pnpids);
1197
1198static struct pnp_card_driver msnd_pnpc_driver = {
1199 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
1200 .name = "msnd_pinnacle",
1201 .id_table = msnd_pnpids,
1202 .probe = snd_msnd_pnp_detect,
1203 .remove = __devexit_p(snd_msnd_pnp_remove),
1204};
1205#endif /* CONFIG_PNP */
1206
1207static int __init snd_msnd_init(void)
1208{
1209 int err;
1210
1211 err = isa_register_driver(&snd_msnd_driver, SNDRV_CARDS);
1212#ifdef CONFIG_PNP
1213 if (!err)
1214 isa_registered = 1;
1215
1216 err = pnp_register_card_driver(&msnd_pnpc_driver);
1217 if (!err)
1218 pnp_registered = 1;
1219
1220 if (isa_registered)
1221 err = 0;
1222#endif
1223 return err;
1224}
1225
1226static void __exit snd_msnd_exit(void)
1227{
1228#ifdef CONFIG_PNP
1229 if (pnp_registered)
1230 pnp_unregister_card_driver(&msnd_pnpc_driver);
1231 if (isa_registered)
1232#endif
1233 isa_unregister_driver(&snd_msnd_driver);
1234}
1235
1236module_init(snd_msnd_init);
1237module_exit(snd_msnd_exit);
1238
diff --git a/sound/isa/msnd/msnd_pinnacle.h b/sound/isa/msnd/msnd_pinnacle.h
new file mode 100644
index 000000000000..48318d1ee340
--- /dev/null
+++ b/sound/isa/msnd/msnd_pinnacle.h
@@ -0,0 +1,181 @@
1/*********************************************************************
2 *
3 * msnd_pinnacle.h
4 *
5 * Turtle Beach MultiSound Sound Card Driver for Linux
6 *
7 * Some parts of this header file were derived from the Turtle Beach
8 * MultiSound Driver Development Kit.
9 *
10 * Copyright (C) 1998 Andrew Veliath
11 * Copyright (C) 1993 Turtle Beach Systems, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 ********************************************************************/
28#ifndef __MSND_PINNACLE_H
29#define __MSND_PINNACLE_H
30
31#define DSP_NUMIO 0x08
32
33#define IREG_LOGDEVICE 0x07
34#define IREG_ACTIVATE 0x30
35#define LD_ACTIVATE 0x01
36#define LD_DISACTIVATE 0x00
37#define IREG_EECONTROL 0x3F
38#define IREG_MEMBASEHI 0x40
39#define IREG_MEMBASELO 0x41
40#define IREG_MEMCONTROL 0x42
41#define IREG_MEMRANGEHI 0x43
42#define IREG_MEMRANGELO 0x44
43#define MEMTYPE_8BIT 0x00
44#define MEMTYPE_16BIT 0x02
45#define MEMTYPE_RANGE 0x00
46#define MEMTYPE_HIADDR 0x01
47#define IREG_IO0_BASEHI 0x60
48#define IREG_IO0_BASELO 0x61
49#define IREG_IO1_BASEHI 0x62
50#define IREG_IO1_BASELO 0x63
51#define IREG_IRQ_NUMBER 0x70
52#define IREG_IRQ_TYPE 0x71
53#define IRQTYPE_HIGH 0x02
54#define IRQTYPE_LOW 0x00
55#define IRQTYPE_LEVEL 0x01
56#define IRQTYPE_EDGE 0x00
57
58#define HP_DSPR 0x04
59#define HP_BLKS 0x04
60
61#define HPDSPRESET_OFF 2
62#define HPDSPRESET_ON 0
63
64#define HPBLKSEL_0 2
65#define HPBLKSEL_1 3
66
67#define HIMT_DAT_OFF 0x03
68
69#define HIDSP_PLAY_UNDER 0x00
70#define HIDSP_INT_PLAY_UNDER 0x01
71#define HIDSP_SSI_TX_UNDER 0x02
72#define HIDSP_RECQ_OVERFLOW 0x08
73#define HIDSP_INT_RECORD_OVER 0x09
74#define HIDSP_SSI_RX_OVERFLOW 0x0a
75
76#define HIDSP_MIDI_IN_OVER 0x10
77
78#define HIDSP_MIDI_FRAME_ERR 0x11
79#define HIDSP_MIDI_PARITY_ERR 0x12
80#define HIDSP_MIDI_OVERRUN_ERR 0x13
81
82#define HIDSP_INPUT_CLIPPING 0x20
83#define HIDSP_MIX_CLIPPING 0x30
84#define HIDSP_DAT_IN_OFF 0x21
85
86#define TIME_PRO_RESET_DONE 0x028A
87#define TIME_PRO_SYSEX 0x001E
88#define TIME_PRO_RESET 0x0032
89
90#define DAR_BUFF_SIZE 0x1000
91
92#define MIDQ_BUFF_SIZE 0x800
93#define DSPQ_BUFF_SIZE 0x5A0
94
95#define DSPQ_DATA_BUFF 0x7860
96
97#define MOP_WAVEHDR 0
98#define MOP_EXTOUT 1
99#define MOP_HWINIT 0xfe
100#define MOP_NONE 0xff
101#define MOP_MAX 1
102
103#define MIP_EXTIN 0
104#define MIP_WAVEHDR 1
105#define MIP_HWINIT 0xfe
106#define MIP_MAX 1
107
108/* Pinnacle/Fiji SMA Common Data */
109#define SMA_wCurrPlayBytes 0x0000
110#define SMA_wCurrRecordBytes 0x0002
111#define SMA_wCurrPlayVolLeft 0x0004
112#define SMA_wCurrPlayVolRight 0x0006
113#define SMA_wCurrInVolLeft 0x0008
114#define SMA_wCurrInVolRight 0x000a
115#define SMA_wCurrMHdrVolLeft 0x000c
116#define SMA_wCurrMHdrVolRight 0x000e
117#define SMA_dwCurrPlayPitch 0x0010
118#define SMA_dwCurrPlayRate 0x0014
119#define SMA_wCurrMIDIIOPatch 0x0018
120#define SMA_wCurrPlayFormat 0x001a
121#define SMA_wCurrPlaySampleSize 0x001c
122#define SMA_wCurrPlayChannels 0x001e
123#define SMA_wCurrPlaySampleRate 0x0020
124#define SMA_wCurrRecordFormat 0x0022
125#define SMA_wCurrRecordSampleSize 0x0024
126#define SMA_wCurrRecordChannels 0x0026
127#define SMA_wCurrRecordSampleRate 0x0028
128#define SMA_wCurrDSPStatusFlags 0x002a
129#define SMA_wCurrHostStatusFlags 0x002c
130#define SMA_wCurrInputTagBits 0x002e
131#define SMA_wCurrLeftPeak 0x0030
132#define SMA_wCurrRightPeak 0x0032
133#define SMA_bMicPotPosLeft 0x0034
134#define SMA_bMicPotPosRight 0x0035
135#define SMA_bMicPotMaxLeft 0x0036
136#define SMA_bMicPotMaxRight 0x0037
137#define SMA_bInPotPosLeft 0x0038
138#define SMA_bInPotPosRight 0x0039
139#define SMA_bAuxPotPosLeft 0x003a
140#define SMA_bAuxPotPosRight 0x003b
141#define SMA_bInPotMaxLeft 0x003c
142#define SMA_bInPotMaxRight 0x003d
143#define SMA_bAuxPotMaxLeft 0x003e
144#define SMA_bAuxPotMaxRight 0x003f
145#define SMA_bInPotMaxMethod 0x0040
146#define SMA_bAuxPotMaxMethod 0x0041
147#define SMA_wCurrMastVolLeft 0x0042
148#define SMA_wCurrMastVolRight 0x0044
149#define SMA_wCalFreqAtoD 0x0046
150#define SMA_wCurrAuxVolLeft 0x0048
151#define SMA_wCurrAuxVolRight 0x004a
152#define SMA_wCurrPlay1VolLeft 0x004c
153#define SMA_wCurrPlay1VolRight 0x004e
154#define SMA_wCurrPlay2VolLeft 0x0050
155#define SMA_wCurrPlay2VolRight 0x0052
156#define SMA_wCurrPlay3VolLeft 0x0054
157#define SMA_wCurrPlay3VolRight 0x0056
158#define SMA_wCurrPlay4VolLeft 0x0058
159#define SMA_wCurrPlay4VolRight 0x005a
160#define SMA_wCurrPlay1PeakLeft 0x005c
161#define SMA_wCurrPlay1PeakRight 0x005e
162#define SMA_wCurrPlay2PeakLeft 0x0060
163#define SMA_wCurrPlay2PeakRight 0x0062
164#define SMA_wCurrPlay3PeakLeft 0x0064
165#define SMA_wCurrPlay3PeakRight 0x0066
166#define SMA_wCurrPlay4PeakLeft 0x0068
167#define SMA_wCurrPlay4PeakRight 0x006a
168#define SMA_wCurrPlayPeakLeft 0x006c
169#define SMA_wCurrPlayPeakRight 0x006e
170#define SMA_wCurrDATSR 0x0070
171#define SMA_wCurrDATRXCHNL 0x0072
172#define SMA_wCurrDATTXCHNL 0x0074
173#define SMA_wCurrDATRXRate 0x0076
174#define SMA_dwDSPPlayCount 0x0078
175#define SMA__size 0x007c
176
177#define INITCODEFILE "turtlebeach/pndspini.bin"
178#define PERMCODEFILE "turtlebeach/pndsperm.bin"
179#define LONGNAME "MultiSound (Pinnacle/Fiji)"
180
181#endif /* __MSND_PINNACLE_H */
diff --git a/sound/isa/msnd/msnd_pinnacle_mixer.c b/sound/isa/msnd/msnd_pinnacle_mixer.c
new file mode 100644
index 000000000000..494058a1a502
--- /dev/null
+++ b/sound/isa/msnd/msnd_pinnacle_mixer.c
@@ -0,0 +1,343 @@
1/***************************************************************************
2 msnd_pinnacle_mixer.c - description
3 -------------------
4 begin : Fre Jun 7 2002
5 copyright : (C) 2002 by karsten wiese
6 email : annabellesgarden@yahoo.de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <linux/io.h>
19
20#include <sound/core.h>
21#include <sound/control.h>
22#include "msnd.h"
23#include "msnd_pinnacle.h"
24
25
26#define MSND_MIXER_VOLUME 0
27#define MSND_MIXER_PCM 1
28#define MSND_MIXER_AUX 2 /* Input source 1 (aux1) */
29#define MSND_MIXER_IMIX 3 /* Recording monitor */
30#define MSND_MIXER_SYNTH 4
31#define MSND_MIXER_SPEAKER 5
32#define MSND_MIXER_LINE 6
33#define MSND_MIXER_MIC 7
34#define MSND_MIXER_RECLEV 11 /* Recording level */
35#define MSND_MIXER_IGAIN 12 /* Input gain */
36#define MSND_MIXER_OGAIN 13 /* Output gain */
37#define MSND_MIXER_DIGITAL 17 /* Digital (input) 1 */
38
39/* Device mask bits */
40
41#define MSND_MASK_VOLUME (1 << MSND_MIXER_VOLUME)
42#define MSND_MASK_SYNTH (1 << MSND_MIXER_SYNTH)
43#define MSND_MASK_PCM (1 << MSND_MIXER_PCM)
44#define MSND_MASK_SPEAKER (1 << MSND_MIXER_SPEAKER)
45#define MSND_MASK_LINE (1 << MSND_MIXER_LINE)
46#define MSND_MASK_MIC (1 << MSND_MIXER_MIC)
47#define MSND_MASK_IMIX (1 << MSND_MIXER_IMIX)
48#define MSND_MASK_RECLEV (1 << MSND_MIXER_RECLEV)
49#define MSND_MASK_IGAIN (1 << MSND_MIXER_IGAIN)
50#define MSND_MASK_OGAIN (1 << MSND_MIXER_OGAIN)
51#define MSND_MASK_AUX (1 << MSND_MIXER_AUX)
52#define MSND_MASK_DIGITAL (1 << MSND_MIXER_DIGITAL)
53
54static int snd_msndmix_info_mux(struct snd_kcontrol *kcontrol,
55 struct snd_ctl_elem_info *uinfo)
56{
57 static char *texts[3] = {
58 "Analog", "MASS", "SPDIF",
59 };
60 struct snd_msnd *chip = snd_kcontrol_chip(kcontrol);
61 unsigned items = test_bit(F_HAVEDIGITAL, &chip->flags) ? 3 : 2;
62
63 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
64 uinfo->count = 1;
65 uinfo->value.enumerated.items = items;
66 if (uinfo->value.enumerated.item >= items)
67 uinfo->value.enumerated.item = items - 1;
68 strcpy(uinfo->value.enumerated.name,
69 texts[uinfo->value.enumerated.item]);
70 return 0;
71}
72
73static int snd_msndmix_get_mux(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_elem_value *ucontrol)
75{
76 struct snd_msnd *chip = snd_kcontrol_chip(kcontrol);
77 /* MSND_MASK_IMIX is the default */
78 ucontrol->value.enumerated.item[0] = 0;
79
80 if (chip->recsrc & MSND_MASK_SYNTH) {
81 ucontrol->value.enumerated.item[0] = 1;
82 } else if ((chip->recsrc & MSND_MASK_DIGITAL) &&
83 test_bit(F_HAVEDIGITAL, &chip->flags)) {
84 ucontrol->value.enumerated.item[0] = 2;
85 }
86
87
88 return 0;
89}
90
91static int snd_msndmix_set_mux(struct snd_msnd *chip, int val)
92{
93 unsigned newrecsrc;
94 int change;
95 unsigned char msndbyte;
96
97 switch (val) {
98 case 0:
99 newrecsrc = MSND_MASK_IMIX;
100 msndbyte = HDEXAR_SET_ANA_IN;
101 break;
102 case 1:
103 newrecsrc = MSND_MASK_SYNTH;
104 msndbyte = HDEXAR_SET_SYNTH_IN;
105 break;
106 case 2:
107 newrecsrc = MSND_MASK_DIGITAL;
108 msndbyte = HDEXAR_SET_DAT_IN;
109 break;
110 default:
111 return -EINVAL;
112 }
113 change = newrecsrc != chip->recsrc;
114 if (change) {
115 change = 0;
116 if (!snd_msnd_send_word(chip, 0, 0, msndbyte))
117 if (!snd_msnd_send_dsp_cmd(chip, HDEX_AUX_REQ)) {
118 chip->recsrc = newrecsrc;
119 change = 1;
120 }
121 }
122 return change;
123}
124
125static int snd_msndmix_put_mux(struct snd_kcontrol *kcontrol,
126 struct snd_ctl_elem_value *ucontrol)
127{
128 struct snd_msnd *msnd = snd_kcontrol_chip(kcontrol);
129 return snd_msndmix_set_mux(msnd, ucontrol->value.enumerated.item[0]);
130}
131
132
133static int snd_msndmix_volume_info(struct snd_kcontrol *kcontrol,
134 struct snd_ctl_elem_info *uinfo)
135{
136 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
137 uinfo->count = 2;
138 uinfo->value.integer.min = 0;
139 uinfo->value.integer.max = 100;
140 return 0;
141}
142
143static int snd_msndmix_volume_get(struct snd_kcontrol *kcontrol,
144 struct snd_ctl_elem_value *ucontrol)
145{
146 struct snd_msnd *msnd = snd_kcontrol_chip(kcontrol);
147 int addr = kcontrol->private_value;
148 unsigned long flags;
149
150 spin_lock_irqsave(&msnd->mixer_lock, flags);
151 ucontrol->value.integer.value[0] = msnd->left_levels[addr] * 100;
152 ucontrol->value.integer.value[0] /= 0xFFFF;
153 ucontrol->value.integer.value[1] = msnd->right_levels[addr] * 100;
154 ucontrol->value.integer.value[1] /= 0xFFFF;
155 spin_unlock_irqrestore(&msnd->mixer_lock, flags);
156 return 0;
157}
158
159#define update_volm(a, b) \
160 do { \
161 writew((dev->left_levels[a] >> 1) * \
162 readw(dev->SMA + SMA_wCurrMastVolLeft) / 0xffff, \
163 dev->SMA + SMA_##b##Left); \
164 writew((dev->right_levels[a] >> 1) * \
165 readw(dev->SMA + SMA_wCurrMastVolRight) / 0xffff, \
166 dev->SMA + SMA_##b##Right); \
167 } while (0);
168
169#define update_potm(d, s, ar) \
170 do { \
171 writeb((dev->left_levels[d] >> 8) * \
172 readw(dev->SMA + SMA_wCurrMastVolLeft) / 0xffff, \
173 dev->SMA + SMA_##s##Left); \
174 writeb((dev->right_levels[d] >> 8) * \
175 readw(dev->SMA + SMA_wCurrMastVolRight) / 0xffff, \
176 dev->SMA + SMA_##s##Right); \
177 if (snd_msnd_send_word(dev, 0, 0, ar) == 0) \
178 snd_msnd_send_dsp_cmd(dev, HDEX_AUX_REQ); \
179 } while (0);
180
181#define update_pot(d, s, ar) \
182 do { \
183 writeb(dev->left_levels[d] >> 8, \
184 dev->SMA + SMA_##s##Left); \
185 writeb(dev->right_levels[d] >> 8, \
186 dev->SMA + SMA_##s##Right); \
187 if (snd_msnd_send_word(dev, 0, 0, ar) == 0) \
188 snd_msnd_send_dsp_cmd(dev, HDEX_AUX_REQ); \
189 } while (0);
190
191
192static int snd_msndmix_set(struct snd_msnd *dev, int d, int left, int right)
193{
194 int bLeft, bRight;
195 int wLeft, wRight;
196 int updatemaster = 0;
197
198 if (d >= LEVEL_ENTRIES)
199 return -EINVAL;
200
201 bLeft = left * 0xff / 100;
202 wLeft = left * 0xffff / 100;
203
204 bRight = right * 0xff / 100;
205 wRight = right * 0xffff / 100;
206
207 dev->left_levels[d] = wLeft;
208 dev->right_levels[d] = wRight;
209
210 switch (d) {
211 /* master volume unscaled controls */
212 case MSND_MIXER_LINE: /* line pot control */
213 /* scaled by IMIX in digital mix */
214 writeb(bLeft, dev->SMA + SMA_bInPotPosLeft);
215 writeb(bRight, dev->SMA + SMA_bInPotPosRight);
216 if (snd_msnd_send_word(dev, 0, 0, HDEXAR_IN_SET_POTS) == 0)
217 snd_msnd_send_dsp_cmd(dev, HDEX_AUX_REQ);
218 break;
219 case MSND_MIXER_MIC: /* mic pot control */
220 if (dev->type == msndClassic)
221 return -EINVAL;
222 /* scaled by IMIX in digital mix */
223 writeb(bLeft, dev->SMA + SMA_bMicPotPosLeft);
224 writeb(bRight, dev->SMA + SMA_bMicPotPosRight);
225 if (snd_msnd_send_word(dev, 0, 0, HDEXAR_MIC_SET_POTS) == 0)
226 snd_msnd_send_dsp_cmd(dev, HDEX_AUX_REQ);
227 break;
228 case MSND_MIXER_VOLUME: /* master volume */
229 writew(wLeft, dev->SMA + SMA_wCurrMastVolLeft);
230 writew(wRight, dev->SMA + SMA_wCurrMastVolRight);
231 /* fall through */
232
233 case MSND_MIXER_AUX: /* aux pot control */
234 /* scaled by master volume */
235 /* fall through */
236
237 /* digital controls */
238 case MSND_MIXER_SYNTH: /* synth vol (dsp mix) */
239 case MSND_MIXER_PCM: /* pcm vol (dsp mix) */
240 case MSND_MIXER_IMIX: /* input monitor (dsp mix) */
241 /* scaled by master volume */
242 updatemaster = 1;
243 break;
244
245 default:
246 return -EINVAL;
247 }
248
249 if (updatemaster) {
250 /* update master volume scaled controls */
251 update_volm(MSND_MIXER_PCM, wCurrPlayVol);
252 update_volm(MSND_MIXER_IMIX, wCurrInVol);
253 if (dev->type == msndPinnacle)
254 update_volm(MSND_MIXER_SYNTH, wCurrMHdrVol);
255 update_potm(MSND_MIXER_AUX, bAuxPotPos, HDEXAR_AUX_SET_POTS);
256 }
257
258 return 0;
259}
260
261static int snd_msndmix_volume_put(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_value *ucontrol)
263{
264 struct snd_msnd *msnd = snd_kcontrol_chip(kcontrol);
265 int change, addr = kcontrol->private_value;
266 int left, right;
267 unsigned long flags;
268
269 left = ucontrol->value.integer.value[0] % 101;
270 right = ucontrol->value.integer.value[1] % 101;
271 spin_lock_irqsave(&msnd->mixer_lock, flags);
272 change = msnd->left_levels[addr] != left
273 || msnd->right_levels[addr] != right;
274 snd_msndmix_set(msnd, addr, left, right);
275 spin_unlock_irqrestore(&msnd->mixer_lock, flags);
276 return change;
277}
278
279
280#define DUMMY_VOLUME(xname, xindex, addr) \
281{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
282 .info = snd_msndmix_volume_info, \
283 .get = snd_msndmix_volume_get, .put = snd_msndmix_volume_put, \
284 .private_value = addr }
285
286
287static struct snd_kcontrol_new snd_msnd_controls[] = {
288DUMMY_VOLUME("Master Volume", 0, MSND_MIXER_VOLUME),
289DUMMY_VOLUME("PCM Volume", 0, MSND_MIXER_PCM),
290DUMMY_VOLUME("Aux Volume", 0, MSND_MIXER_AUX),
291DUMMY_VOLUME("Line Volume", 0, MSND_MIXER_LINE),
292DUMMY_VOLUME("Mic Volume", 0, MSND_MIXER_MIC),
293DUMMY_VOLUME("Monitor", 0, MSND_MIXER_IMIX),
294{
295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
296 .name = "Capture Source",
297 .info = snd_msndmix_info_mux,
298 .get = snd_msndmix_get_mux,
299 .put = snd_msndmix_put_mux,
300}
301};
302
303
304int __devinit snd_msndmix_new(struct snd_card *card)
305{
306 struct snd_msnd *chip = card->private_data;
307 unsigned int idx;
308 int err;
309
310 if (snd_BUG_ON(!chip))
311 return -EINVAL;
312 spin_lock_init(&chip->mixer_lock);
313 strcpy(card->mixername, "MSND Pinnacle Mixer");
314
315 for (idx = 0; idx < ARRAY_SIZE(snd_msnd_controls); idx++)
316 err = snd_ctl_add(card,
317 snd_ctl_new1(snd_msnd_controls + idx, chip));
318 if (err < 0)
319 return err;
320
321 return 0;
322}
323EXPORT_SYMBOL(snd_msndmix_new);
324
325void snd_msndmix_setup(struct snd_msnd *dev)
326{
327 update_pot(MSND_MIXER_LINE, bInPotPos, HDEXAR_IN_SET_POTS);
328 update_potm(MSND_MIXER_AUX, bAuxPotPos, HDEXAR_AUX_SET_POTS);
329 update_volm(MSND_MIXER_PCM, wCurrPlayVol);
330 update_volm(MSND_MIXER_IMIX, wCurrInVol);
331 if (dev->type == msndPinnacle) {
332 update_pot(MSND_MIXER_MIC, bMicPotPos, HDEXAR_MIC_SET_POTS);
333 update_volm(MSND_MIXER_SYNTH, wCurrMHdrVol);
334 }
335}
336EXPORT_SYMBOL(snd_msndmix_setup);
337
338int snd_msndmix_force_recsrc(struct snd_msnd *dev, int recsrc)
339{
340 dev->recsrc = -1;
341 return snd_msndmix_set_mux(dev, recsrc);
342}
343EXPORT_SYMBOL(snd_msndmix_force_recsrc);
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 645491a53023..0481a55334b9 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -179,12 +179,13 @@ static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char
179 unsigned char result; 179 unsigned char result;
180#if 0 180#if 0
181 outb(0x1d, port); /* password */ 181 outb(0x1d, port); /* password */
182 printk("read [0x%lx] = 0x%x\n", port, inb(port)); 182 printk(KERN_DEBUG "read [0x%lx] = 0x%x\n", port, inb(port));
183#endif 183#endif
184 outb(reg, chip->port); /* register */ 184 outb(reg, chip->port); /* register */
185 result = inb(chip->port + 1); 185 result = inb(chip->port + 1);
186#if 0 186#if 0
187 printk("read [0x%lx] = 0x%x [0x%x]\n", port, result, inb(port)); 187 printk(KERN_DEBUG "read [0x%lx] = 0x%x [0x%x]\n",
188 port, result, inb(port));
188#endif 189#endif
189 return result; 190 return result;
190} 191}
@@ -233,7 +234,10 @@ static int __devinit snd_opl3sa2_detect(struct snd_card *card)
233 snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port); 234 snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port);
234 return -EBUSY; 235 return -EBUSY;
235 } 236 }
236 // snd_printk("REG 0A = 0x%x\n", snd_opl3sa2_read(chip, 0x0a)); 237 /*
238 snd_printk(KERN_DEBUG "REG 0A = 0x%x\n",
239 snd_opl3sa2_read(chip, 0x0a));
240 */
237 chip->version = 0; 241 chip->version = 0;
238 tmp = snd_opl3sa2_read(chip, OPL3SA2_MISC); 242 tmp = snd_opl3sa2_read(chip, OPL3SA2_MISC);
239 if (tmp == 0xff) { 243 if (tmp == 0xff) {
@@ -477,6 +481,7 @@ OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1,
477OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), 481OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
478OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1, 482OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1,
479 db_scale_5bit_12db_max), 483 db_scale_5bit_12db_max),
484OPL3SA2_SINGLE("ZV Port Switch", 0, 0x02, 0, 1, 0),
480}; 485};
481 486
482static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { 487static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
@@ -550,21 +555,27 @@ static int __devinit snd_opl3sa2_mixer(struct snd_card *card)
550#ifdef CONFIG_PM 555#ifdef CONFIG_PM
551static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) 556static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state)
552{ 557{
553 struct snd_opl3sa2 *chip = card->private_data; 558 if (card) {
559 struct snd_opl3sa2 *chip = card->private_data;
554 560
555 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 561 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
556 chip->wss->suspend(chip->wss); 562 chip->wss->suspend(chip->wss);
557 /* power down */ 563 /* power down */
558 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3); 564 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
565 }
559 566
560 return 0; 567 return 0;
561} 568}
562 569
563static int snd_opl3sa2_resume(struct snd_card *card) 570static int snd_opl3sa2_resume(struct snd_card *card)
564{ 571{
565 struct snd_opl3sa2 *chip = card->private_data; 572 struct snd_opl3sa2 *chip;
566 int i; 573 int i;
567 574
575 if (!card)
576 return 0;
577
578 chip = card->private_data;
568 /* power up */ 579 /* power up */
569 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0); 580 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
570 581
@@ -613,7 +624,7 @@ static void snd_opl3sa2_free(struct snd_card *card)
613{ 624{
614 struct snd_opl3sa2 *chip = card->private_data; 625 struct snd_opl3sa2 *chip = card->private_data;
615 if (chip->irq >= 0) 626 if (chip->irq >= 0)
616 free_irq(chip->irq, (void *)chip); 627 free_irq(chip->irq, card);
617 release_and_free_resource(chip->res_port); 628 release_and_free_resource(chip->res_port);
618} 629}
619 630
@@ -628,7 +639,7 @@ static int snd_opl3sa2_card_new(int dev, struct snd_card **cardp)
628 if (err < 0) 639 if (err < 0)
629 return err; 640 return err;
630 strcpy(card->driver, "OPL3SA2"); 641 strcpy(card->driver, "OPL3SA2");
631 strcpy(card->shortname, "Yamaha OPL3-SA2"); 642 strcpy(card->shortname, "Yamaha OPL3-SA");
632 chip = card->private_data; 643 chip = card->private_data;
633 spin_lock_init(&chip->reg_lock); 644 spin_lock_init(&chip->reg_lock);
634 chip->irq = -1; 645 chip->irq = -1;
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index cd6e60a6a4ea..5cd555325b9d 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -252,7 +252,7 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
252#endif /* OPTi93X */ 252#endif /* OPTi93X */
253 253
254 default: 254 default:
255 snd_printk("chip %d not supported\n", hardware); 255 snd_printk(KERN_ERR "chip %d not supported\n", hardware);
256 return -ENODEV; 256 return -ENODEV;
257 } 257 }
258 return 0; 258 return 0;
@@ -294,7 +294,7 @@ static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip,
294#endif /* OPTi93X */ 294#endif /* OPTi93X */
295 295
296 default: 296 default:
297 snd_printk("chip %d not supported\n", chip->hardware); 297 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
298 } 298 }
299 299
300 spin_unlock_irqrestore(&chip->lock, flags); 300 spin_unlock_irqrestore(&chip->lock, flags);
@@ -336,7 +336,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
336#endif /* OPTi93X */ 336#endif /* OPTi93X */
337 337
338 default: 338 default:
339 snd_printk("chip %d not supported\n", chip->hardware); 339 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
340 } 340 }
341 341
342 spin_unlock_irqrestore(&chip->lock, flags); 342 spin_unlock_irqrestore(&chip->lock, flags);
@@ -412,7 +412,7 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
412#endif /* OPTi93X */ 412#endif /* OPTi93X */
413 413
414 default: 414 default:
415 snd_printk("chip %d not supported\n", chip->hardware); 415 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
416 return -EINVAL; 416 return -EINVAL;
417 } 417 }
418 418
@@ -430,7 +430,8 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
430 wss_base_bits = 0x02; 430 wss_base_bits = 0x02;
431 break; 431 break;
432 default: 432 default:
433 snd_printk("WSS port 0x%lx not valid\n", chip->wss_base); 433 snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n",
434 chip->wss_base);
434 goto __skip_base; 435 goto __skip_base;
435 } 436 }
436 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); 437 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30);
@@ -455,7 +456,7 @@ __skip_base:
455 irq_bits = 0x04; 456 irq_bits = 0x04;
456 break; 457 break;
457 default: 458 default:
458 snd_printk("WSS irq # %d not valid\n", chip->irq); 459 snd_printk(KERN_WARNING "WSS irq # %d not valid\n", chip->irq);
459 goto __skip_resources; 460 goto __skip_resources;
460 } 461 }
461 462
@@ -470,13 +471,14 @@ __skip_base:
470 dma_bits = 0x03; 471 dma_bits = 0x03;
471 break; 472 break;
472 default: 473 default:
473 snd_printk("WSS dma1 # %d not valid\n", chip->dma1); 474 snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n",
475 chip->dma1);
474 goto __skip_resources; 476 goto __skip_resources;
475 } 477 }
476 478
477#if defined(CS4231) || defined(OPTi93X) 479#if defined(CS4231) || defined(OPTi93X)
478 if (chip->dma1 == chip->dma2) { 480 if (chip->dma1 == chip->dma2) {
479 snd_printk("don't want to share dmas\n"); 481 snd_printk(KERN_ERR "don't want to share dmas\n");
480 return -EBUSY; 482 return -EBUSY;
481 } 483 }
482 484
@@ -485,7 +487,8 @@ __skip_base:
485 case 1: 487 case 1:
486 break; 488 break;
487 default: 489 default:
488 snd_printk("WSS dma2 # %d not valid\n", chip->dma2); 490 snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n",
491 chip->dma2);
489 goto __skip_resources; 492 goto __skip_resources;
490 } 493 }
491 dma_bits |= 0x04; 494 dma_bits |= 0x04;
@@ -516,7 +519,8 @@ __skip_resources:
516 mpu_port_bits = 0x00; 519 mpu_port_bits = 0x00;
517 break; 520 break;
518 default: 521 default:
519 snd_printk("MPU-401 port 0x%lx not valid\n", 522 snd_printk(KERN_WARNING
523 "MPU-401 port 0x%lx not valid\n",
520 chip->mpu_port); 524 chip->mpu_port);
521 goto __skip_mpu; 525 goto __skip_mpu;
522 } 526 }
@@ -535,7 +539,7 @@ __skip_resources:
535 mpu_irq_bits = 0x01; 539 mpu_irq_bits = 0x01;
536 break; 540 break;
537 default: 541 default:
538 snd_printk("MPU-401 irq # %d not valid\n", 542 snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n",
539 chip->mpu_irq); 543 chip->mpu_irq);
540 goto __skip_mpu; 544 goto __skip_mpu;
541 } 545 }
@@ -726,7 +730,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
726 if (chip->wss_base == SNDRV_AUTO_PORT) { 730 if (chip->wss_base == SNDRV_AUTO_PORT) {
727 chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4); 731 chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4);
728 if (chip->wss_base < 0) { 732 if (chip->wss_base < 0) {
729 snd_printk("unable to find a free WSS port\n"); 733 snd_printk(KERN_ERR "unable to find a free WSS port\n");
730 return -EBUSY; 734 return -EBUSY;
731 } 735 }
732 } 736 }
@@ -815,14 +819,8 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
815 chip->fm_port, chip->fm_port + 4 - 1); 819 chip->fm_port, chip->fm_port + 4 - 1);
816 } 820 }
817 if (opl3) { 821 if (opl3) {
818#ifdef CS4231 822 error = snd_opl3_hwdep_new(opl3, 0, 1, &synth);
819 const int t1dev = 1; 823 if (error < 0)
820#else
821 const int t1dev = 0;
822#endif
823 if ((error = snd_opl3_timer_new(opl3, t1dev, t1dev+1)) < 0)
824 return error;
825 if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0)
826 return error; 824 return error;
827 } 825 }
828 } 826 }
@@ -900,7 +898,7 @@ static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
900#if defined(CS4231) || defined(OPTi93X) 898#if defined(CS4231) || defined(OPTi93X)
901 if (dma2 == SNDRV_AUTO_DMA) { 899 if (dma2 == SNDRV_AUTO_DMA) {
902 if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) { 900 if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) {
903 snd_printk("unable to find a free DMA2\n"); 901 snd_printk(KERN_ERR "unable to find a free DMA2\n");
904 return -EBUSY; 902 return -EBUSY;
905 } 903 }
906 } 904 }
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index 49037d074c71..bdc8dde4e4a2 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -684,15 +684,16 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
684 684
685static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) 685static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags)
686{ 686{
687 int err = -ENOMEM; 687 int err;
688 unsigned char *kbuf = kmalloc(size, GFP_KERNEL); 688 unsigned char *kbuf;
689 if (kbuf) { 689
690 if (copy_from_user(kbuf, buf, size)) 690 kbuf = memdup_user(buf, size);
691 err = -EFAULT; 691 if (IS_ERR(kbuf))
692 else 692 return PTR_ERR(kbuf);
693 err = snd_sb_csp_load(p, kbuf, size, load_flags); 693
694 kfree(kbuf); 694 err = snd_sb_csp_load(p, kbuf, size, load_flags);
695 } 695
696 kfree(kbuf);
696 return err; 697 return err;
697} 698}
698 699
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c
index 406a431af91e..475220bbcc96 100644
--- a/sound/isa/sb/sb_mixer.c
+++ b/sound/isa/sb/sb_mixer.c
@@ -182,7 +182,7 @@ static int snd_sbmixer_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
182 182
183static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 183static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
184{ 184{
185 static char *texts[5] = { 185 static const char *texts[5] = {
186 "CD", "Mic", "Line", "Synth", "Master" 186 "CD", "Mic", "Line", "Synth", "Master"
187 }; 187 };
188 188
@@ -269,12 +269,73 @@ static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl
269} 269}
270 270
271/* 271/*
272 * ALS4000 mono recording control switch
273 */
274
275static int snd_als4k_mono_capture_route_info(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_info *uinfo)
277{
278 static const char *texts[3] = {
279 "L chan only", "R chan only", "L ch/2 + R ch/2"
280 };
281
282 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
283 uinfo->count = 1;
284 uinfo->value.enumerated.items = 3;
285 if (uinfo->value.enumerated.item > 2)
286 uinfo->value.enumerated.item = 2;
287 strcpy(uinfo->value.enumerated.name,
288 texts[uinfo->value.enumerated.item]);
289 return 0;
290}
291
292static int snd_als4k_mono_capture_route_get(struct snd_kcontrol *kcontrol,
293 struct snd_ctl_elem_value *ucontrol)
294{
295 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
296 unsigned long flags;
297 unsigned char oval;
298
299 spin_lock_irqsave(&sb->mixer_lock, flags);
300 oval = snd_sbmixer_read(sb, SB_ALS4000_MONO_IO_CTRL);
301 spin_unlock_irqrestore(&sb->mixer_lock, flags);
302 oval >>= 6;
303 if (oval > 2)
304 oval = 2;
305
306 ucontrol->value.enumerated.item[0] = oval;
307 return 0;
308}
309
310static int snd_als4k_mono_capture_route_put(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_value *ucontrol)
312{
313 struct snd_sb *sb = snd_kcontrol_chip(kcontrol);
314 unsigned long flags;
315 int change;
316 unsigned char nval, oval;
317
318 if (ucontrol->value.enumerated.item[0] > 2)
319 return -EINVAL;
320 spin_lock_irqsave(&sb->mixer_lock, flags);
321 oval = snd_sbmixer_read(sb, SB_ALS4000_MONO_IO_CTRL);
322
323 nval = (oval & ~(3 << 6))
324 | (ucontrol->value.enumerated.item[0] << 6);
325 change = nval != oval;
326 if (change)
327 snd_sbmixer_write(sb, SB_ALS4000_MONO_IO_CTRL, nval);
328 spin_unlock_irqrestore(&sb->mixer_lock, flags);
329 return change;
330}
331
332/*
272 * SBPRO input multiplexer 333 * SBPRO input multiplexer
273 */ 334 */
274 335
275static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 336static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
276{ 337{
277 static char *texts[3] = { 338 static const char *texts[3] = {
278 "Mic", "CD", "Line" 339 "Mic", "CD", "Line"
279 }; 340 };
280 341
@@ -442,6 +503,12 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty
442 .get = snd_dt019x_input_sw_get, 503 .get = snd_dt019x_input_sw_get,
443 .put = snd_dt019x_input_sw_put, 504 .put = snd_dt019x_input_sw_put,
444 }, 505 },
506 [SB_MIX_MONO_CAPTURE_ALS4K] = {
507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
508 .info = snd_als4k_mono_capture_route_info,
509 .get = snd_als4k_mono_capture_route_get,
510 .put = snd_als4k_mono_capture_route_put,
511 },
445 }; 512 };
446 struct snd_kcontrol *ctl; 513 struct snd_kcontrol *ctl;
447 int err; 514 int err;
@@ -636,6 +703,8 @@ static struct sbmix_elem snd_dt019x_ctl_capture_source =
636 }; 703 };
637 704
638static struct sbmix_elem *snd_dt019x_controls[] = { 705static struct sbmix_elem *snd_dt019x_controls[] = {
706 /* ALS4000 below has some parts which we might be lacking,
707 * e.g. snd_als4000_ctl_mono_playback_switch - check it! */
639 &snd_dt019x_ctl_master_play_vol, 708 &snd_dt019x_ctl_master_play_vol,
640 &snd_dt019x_ctl_pcm_play_vol, 709 &snd_dt019x_ctl_pcm_play_vol,
641 &snd_dt019x_ctl_synth_play_vol, 710 &snd_dt019x_ctl_synth_play_vol,
@@ -666,18 +735,21 @@ static unsigned char snd_dt019x_init_values[][2] = {
666/* 735/*
667 * ALS4000 specific mixer elements 736 * ALS4000 specific mixer elements
668 */ 737 */
669/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl! */
670static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = 738static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch =
671 SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); 739 SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1);
672static struct sbmix_elem snd_als4000_ctl_master_mono_capture_route = 740static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = {
673 SB_SINGLE("Master Mono Capture Route", SB_ALS4000_MONO_IO_CTRL, 6, 0x03); 741 .name = "Master Mono Capture Route",
674/* FIXME: mono playback switch also available on DT019X? */ 742 .type = SB_MIX_MONO_CAPTURE_ALS4K
743 };
675static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = 744static struct sbmix_elem snd_als4000_ctl_mono_playback_switch =
676 SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); 745 SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1);
677static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = 746static struct sbmix_elem snd_als4000_ctl_mic_20db_boost =
678 SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); 747 SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03);
679static struct sbmix_elem snd_als4000_ctl_mixer_loopback = 748static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback =
680 SB_SINGLE("Analog Loopback", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); 749 SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01);
750static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback =
751 SB_SINGLE("Digital Loopback Switch",
752 SB_ALS4000_CR3_CONFIGURATION, 7, 0x01);
681/* FIXME: functionality of 3D controls might be swapped, I didn't find 753/* FIXME: functionality of 3D controls might be swapped, I didn't find
682 * a description of how to identify what is supposed to be what */ 754 * a description of how to identify what is supposed to be what */
683static struct sbmix_elem snd_als4000_3d_control_switch = 755static struct sbmix_elem snd_als4000_3d_control_switch =
@@ -694,6 +766,9 @@ static struct sbmix_elem snd_als4000_3d_control_delay =
694 SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); 766 SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f);
695static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = 767static struct sbmix_elem snd_als4000_3d_control_poweroff_switch =
696 SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); 768 SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01);
769static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch =
770 SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch",
771 SB_ALS4000_FMDAC, 5, 0x01);
697#ifdef NOT_AVAILABLE 772#ifdef NOT_AVAILABLE
698static struct sbmix_elem snd_als4000_ctl_fmdac = 773static struct sbmix_elem snd_als4000_ctl_fmdac =
699 SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); 774 SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01);
@@ -702,35 +777,37 @@ static struct sbmix_elem snd_als4000_ctl_qsound =
702#endif 777#endif
703 778
704static struct sbmix_elem *snd_als4000_controls[] = { 779static struct sbmix_elem *snd_als4000_controls[] = {
705 &snd_sb16_ctl_master_play_vol, 780 /* ALS4000a.PDF regs page */
706 &snd_dt019x_ctl_pcm_play_switch, 781 &snd_sb16_ctl_master_play_vol, /* MX30/31 12 */
707 &snd_sb16_ctl_pcm_play_vol, 782 &snd_dt019x_ctl_pcm_play_switch, /* MX4C 16 */
708 &snd_sb16_ctl_synth_capture_route, 783 &snd_sb16_ctl_pcm_play_vol, /* MX32/33 12 */
709 &snd_dt019x_ctl_synth_play_switch, 784 &snd_sb16_ctl_synth_capture_route, /* MX3D/3E 14 */
710 &snd_sb16_ctl_synth_play_vol, 785 &snd_dt019x_ctl_synth_play_switch, /* MX4C 16 */
711 &snd_sb16_ctl_cd_capture_route, 786 &snd_sb16_ctl_synth_play_vol, /* MX34/35 12/13 */
712 &snd_sb16_ctl_cd_play_switch, 787 &snd_sb16_ctl_cd_capture_route, /* MX3D/3E 14 */
713 &snd_sb16_ctl_cd_play_vol, 788 &snd_sb16_ctl_cd_play_switch, /* MX3C 14 */
714 &snd_sb16_ctl_line_capture_route, 789 &snd_sb16_ctl_cd_play_vol, /* MX36/37 13 */
715 &snd_sb16_ctl_line_play_switch, 790 &snd_sb16_ctl_line_capture_route, /* MX3D/3E 14 */
716 &snd_sb16_ctl_line_play_vol, 791 &snd_sb16_ctl_line_play_switch, /* MX3C 14 */
717 &snd_sb16_ctl_mic_capture_route, 792 &snd_sb16_ctl_line_play_vol, /* MX38/39 13 */
718 &snd_als4000_ctl_mic_20db_boost, 793 &snd_sb16_ctl_mic_capture_route, /* MX3D/3E 14 */
719 &snd_sb16_ctl_auto_mic_gain, 794 &snd_als4000_ctl_mic_20db_boost, /* MX4D 16 */
720 &snd_sb16_ctl_mic_play_switch, 795 &snd_sb16_ctl_mic_play_switch, /* MX3C 14 */
721 &snd_sb16_ctl_mic_play_vol, 796 &snd_sb16_ctl_mic_play_vol, /* MX3A 13 */
722 &snd_sb16_ctl_pc_speaker_vol, 797 &snd_sb16_ctl_pc_speaker_vol, /* MX3B 14 */
723 &snd_sb16_ctl_capture_vol, 798 &snd_sb16_ctl_capture_vol, /* MX3F/40 15 */
724 &snd_sb16_ctl_play_vol, 799 &snd_sb16_ctl_play_vol, /* MX41/42 15 */
725 &snd_als4000_ctl_master_mono_playback_switch, 800 &snd_als4000_ctl_master_mono_playback_switch, /* MX4C 16 */
726 &snd_als4000_ctl_master_mono_capture_route, 801 &snd_als4k_ctl_master_mono_capture_route, /* MX4B 16 */
727 &snd_als4000_ctl_mono_playback_switch, 802 &snd_als4000_ctl_mono_playback_switch, /* MX4C 16 */
728 &snd_als4000_ctl_mixer_loopback, 803 &snd_als4000_ctl_mixer_analog_loopback, /* MX4D 16 */
729 &snd_als4000_3d_control_switch, 804 &snd_als4000_ctl_mixer_digital_loopback, /* CR3 21 */
730 &snd_als4000_3d_control_ratio, 805 &snd_als4000_3d_control_switch, /* MX50 17 */
731 &snd_als4000_3d_control_freq, 806 &snd_als4000_3d_control_ratio, /* MX50 17 */
732 &snd_als4000_3d_control_delay, 807 &snd_als4000_3d_control_freq, /* MX50 17 */
733 &snd_als4000_3d_control_poweroff_switch, 808 &snd_als4000_3d_control_delay, /* MX51 18 */
809 &snd_als4000_3d_control_poweroff_switch, /* MX51 18 */
810 &snd_als4000_ctl_3db_freq_control_switch, /* MX4F 17 */
734#ifdef NOT_AVAILABLE 811#ifdef NOT_AVAILABLE
735 &snd_als4000_ctl_fmdac, 812 &snd_als4000_ctl_fmdac,
736 &snd_als4000_ctl_qsound, 813 &snd_als4000_ctl_qsound,
@@ -905,13 +982,14 @@ static unsigned char dt019x_saved_regs[] = {
905}; 982};
906 983
907static unsigned char als4000_saved_regs[] = { 984static unsigned char als4000_saved_regs[] = {
985 /* please verify in dsheet whether regs to be added
986 are actually real H/W or just dummy */
908 SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, 987 SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1,
909 SB_DSP4_OUTPUT_SW, 988 SB_DSP4_OUTPUT_SW,
910 SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, 989 SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1,
911 SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 990 SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT,
912 SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, 991 SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1,
913 SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, 992 SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1,
914 SB_DSP4_MIC_AGC,
915 SB_DSP4_MIC_DEV, 993 SB_DSP4_MIC_DEV,
916 SB_DSP4_SPEAKER_DEV, 994 SB_DSP4_SPEAKER_DEV,
917 SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1, 995 SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1,
@@ -919,8 +997,10 @@ static unsigned char als4000_saved_regs[] = {
919 SB_DT019X_OUTPUT_SW2, 997 SB_DT019X_OUTPUT_SW2,
920 SB_ALS4000_MONO_IO_CTRL, 998 SB_ALS4000_MONO_IO_CTRL,
921 SB_ALS4000_MIC_IN_GAIN, 999 SB_ALS4000_MIC_IN_GAIN,
1000 SB_ALS4000_FMDAC,
922 SB_ALS4000_3D_SND_FX, 1001 SB_ALS4000_3D_SND_FX,
923 SB_ALS4000_3D_TIME_DELAY, 1002 SB_ALS4000_3D_TIME_DELAY,
1003 SB_ALS4000_CR3_CONFIGURATION,
924}; 1004};
925 1005
926static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) 1006static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs)
diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c
index 7a1470376c6d..782010608ef4 100644
--- a/sound/isa/sc6000.c
+++ b/sound/isa/sc6000.c
@@ -576,10 +576,6 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev)
576 snd_printk(KERN_ERR PFX "no OPL device at 0x%x-0x%x ?\n", 576 snd_printk(KERN_ERR PFX "no OPL device at 0x%x-0x%x ?\n",
577 0x388, 0x388 + 2); 577 0x388, 0x388 + 2);
578 } else { 578 } else {
579 err = snd_opl3_timer_new(opl3, 0, 1);
580 if (err < 0)
581 goto err_unmap2;
582
583 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 579 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
584 if (err < 0) 580 if (err < 0)
585 goto err_unmap2; 581 goto err_unmap2;
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 4025fb558c50..66187122377c 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -89,9 +89,6 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
89#endif 89#endif
90 90
91 91
92#define MPU401_IO(i) ((i) + 0)
93#define MIDI_DATA_IO(i) ((i) + 0)
94#define MIDI_CTRL_IO(i) ((i) + 1)
95#define HOST_CTRL_IO(i) ((i) + 2) 92#define HOST_CTRL_IO(i) ((i) + 2)
96#define HOST_DATA_IO(i) ((i) + 3) 93#define HOST_DATA_IO(i) ((i) + 3)
97#define ODIE_ADDR_IO(i) ((i) + 4) 94#define ODIE_ADDR_IO(i) ((i) + 4)
@@ -129,9 +126,6 @@ enum GA_REG {
129#define DMA_8BIT 0x80 126#define DMA_8BIT 0x80
130 127
131 128
132#define AD1845_FREQ_SEL_MSB 0x16
133#define AD1845_FREQ_SEL_LSB 0x17
134
135enum card_type { 129enum card_type {
136 SSCAPE, 130 SSCAPE,
137 SSCAPE_PNP, 131 SSCAPE_PNP,
@@ -141,8 +135,6 @@ enum card_type {
141struct soundscape { 135struct soundscape {
142 spinlock_t lock; 136 spinlock_t lock;
143 unsigned io_base; 137 unsigned io_base;
144 unsigned wss_base;
145 int codec_type;
146 int ic_type; 138 int ic_type;
147 enum card_type type; 139 enum card_type type;
148 struct resource *io_res; 140 struct resource *io_res;
@@ -330,7 +322,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
330 */ 322 */
331static inline int verify_mpu401(const struct snd_mpu401 * mpu) 323static inline int verify_mpu401(const struct snd_mpu401 * mpu)
332{ 324{
333 return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80); 325 return ((inb(MPU401C(mpu)) & 0xc0) == 0x80);
334} 326}
335 327
336/* 328/*
@@ -338,7 +330,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu)
338 */ 330 */
339static inline void initialise_mpu401(const struct snd_mpu401 * mpu) 331static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
340{ 332{
341 outb(0, MIDI_DATA_IO(mpu->port)); 333 outb(0, MPU401D(mpu));
342} 334}
343 335
344/* 336/*
@@ -396,20 +388,20 @@ static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned ti
396 */ 388 */
397static int obp_startup_ack(struct soundscape *s, unsigned timeout) 389static int obp_startup_ack(struct soundscape *s, unsigned timeout)
398{ 390{
399 while (timeout != 0) { 391 unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
392
393 do {
400 unsigned long flags; 394 unsigned long flags;
401 unsigned char x; 395 unsigned char x;
402 396
403 schedule_timeout_uninterruptible(1);
404
405 spin_lock_irqsave(&s->lock, flags); 397 spin_lock_irqsave(&s->lock, flags);
406 x = inb(HOST_DATA_IO(s->io_base)); 398 x = inb(HOST_DATA_IO(s->io_base));
407 spin_unlock_irqrestore(&s->lock, flags); 399 spin_unlock_irqrestore(&s->lock, flags);
408 if ((x & 0xfe) == 0xfe) 400 if ((x & 0xfe) == 0xfe)
409 return 1; 401 return 1;
410 402
411 --timeout; 403 msleep(10);
412 } /* while */ 404 } while (time_before(jiffies, end_time));
413 405
414 return 0; 406 return 0;
415} 407}
@@ -423,20 +415,20 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout)
423 */ 415 */
424static int host_startup_ack(struct soundscape *s, unsigned timeout) 416static int host_startup_ack(struct soundscape *s, unsigned timeout)
425{ 417{
426 while (timeout != 0) { 418 unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
419
420 do {
427 unsigned long flags; 421 unsigned long flags;
428 unsigned char x; 422 unsigned char x;
429 423
430 schedule_timeout_uninterruptible(1);
431
432 spin_lock_irqsave(&s->lock, flags); 424 spin_lock_irqsave(&s->lock, flags);
433 x = inb(HOST_DATA_IO(s->io_base)); 425 x = inb(HOST_DATA_IO(s->io_base));
434 spin_unlock_irqrestore(&s->lock, flags); 426 spin_unlock_irqrestore(&s->lock, flags);
435 if (x == 0xfe) 427 if (x == 0xfe)
436 return 1; 428 return 1;
437 429
438 --timeout; 430 msleep(10);
439 } /* while */ 431 } while (time_before(jiffies, end_time));
440 432
441 return 0; 433 return 0;
442} 434}
@@ -532,10 +524,10 @@ static int upload_dma_data(struct soundscape *s,
532 * give it 5 seconds (max) ... 524 * give it 5 seconds (max) ...
533 */ 525 */
534 ret = 0; 526 ret = 0;
535 if (!obp_startup_ack(s, 5)) { 527 if (!obp_startup_ack(s, 5000)) {
536 snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); 528 snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n");
537 ret = -EAGAIN; 529 ret = -EAGAIN;
538 } else if (!host_startup_ack(s, 5)) { 530 } else if (!host_startup_ack(s, 5000)) {
539 snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); 531 snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n");
540 ret = -EAGAIN; 532 ret = -EAGAIN;
541 } 533 }
@@ -732,13 +724,7 @@ static int sscape_midi_get(struct snd_kcontrol *kctl,
732 unsigned long flags; 724 unsigned long flags;
733 725
734 spin_lock_irqsave(&s->lock, flags); 726 spin_lock_irqsave(&s->lock, flags);
735 set_host_mode_unsafe(s->io_base); 727 uctl->value.integer.value[0] = s->midi_vol;
736
737 if (host_write_ctrl_unsafe(s->io_base, CMD_GET_MIDI_VOL, 100)) {
738 uctl->value.integer.value[0] = host_read_ctrl_unsafe(s->io_base, 100);
739 }
740
741 set_midi_mode_unsafe(s->io_base);
742 spin_unlock_irqrestore(&s->lock, flags); 728 spin_unlock_irqrestore(&s->lock, flags);
743 return 0; 729 return 0;
744} 730}
@@ -773,6 +759,7 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
773 change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) 759 change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
774 && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) 760 && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100)
775 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); 761 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100));
762 s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127;
776 __skip_change: 763 __skip_change:
777 764
778 /* 765 /*
@@ -815,12 +802,11 @@ static unsigned __devinit get_irq_config(int irq)
815 * Perform certain arcane port-checks to see whether there 802 * Perform certain arcane port-checks to see whether there
816 * is a SoundScape board lurking behind the given ports. 803 * is a SoundScape board lurking behind the given ports.
817 */ 804 */
818static int __devinit detect_sscape(struct soundscape *s) 805static int __devinit detect_sscape(struct soundscape *s, long wss_io)
819{ 806{
820 unsigned long flags; 807 unsigned long flags;
821 unsigned d; 808 unsigned d;
822 int retval = 0; 809 int retval = 0;
823 int codec = s->wss_base;
824 810
825 spin_lock_irqsave(&s->lock, flags); 811 spin_lock_irqsave(&s->lock, flags);
826 812
@@ -836,13 +822,11 @@ static int __devinit detect_sscape(struct soundscape *s)
836 if ((d & 0x80) != 0) 822 if ((d & 0x80) != 0)
837 goto _done; 823 goto _done;
838 824
839 if (d == 0) { 825 if (d == 0)
840 s->codec_type = 1;
841 s->ic_type = IC_ODIE; 826 s->ic_type = IC_ODIE;
842 } else if ((d & 0x60) != 0) { 827 else if ((d & 0x60) != 0)
843 s->codec_type = 2;
844 s->ic_type = IC_OPUS; 828 s->ic_type = IC_OPUS;
845 } else 829 else
846 goto _done; 830 goto _done;
847 831
848 outb(0xfa, ODIE_ADDR_IO(s->io_base)); 832 outb(0xfa, ODIE_ADDR_IO(s->io_base));
@@ -862,10 +846,10 @@ static int __devinit detect_sscape(struct soundscape *s)
862 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); 846 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
863 847
864 if (s->type == SSCAPE_VIVO) 848 if (s->type == SSCAPE_VIVO)
865 codec += 4; 849 wss_io += 4;
866 /* wait for WSS codec */ 850 /* wait for WSS codec */
867 for (d = 0; d < 500; d++) { 851 for (d = 0; d < 500; d++) {
868 if ((inb(codec) & 0x80) == 0) 852 if ((inb(wss_io) & 0x80) == 0)
869 break; 853 break;
870 spin_unlock_irqrestore(&s->lock, flags); 854 spin_unlock_irqrestore(&s->lock, flags);
871 msleep(1); 855 msleep(1);
@@ -955,82 +939,6 @@ static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned l
955 939
956 940
957/* 941/*
958 * Override for the CS4231 playback format function.
959 * The AD1845 has much simpler format and rate selection.
960 */
961static void ad1845_playback_format(struct snd_wss *chip,
962 struct snd_pcm_hw_params *params,
963 unsigned char format)
964{
965 unsigned long flags;
966 unsigned rate = params_rate(params);
967
968 /*
969 * The AD1845 can't handle sample frequencies
970 * outside of 4 kHZ to 50 kHZ
971 */
972 if (rate > 50000)
973 rate = 50000;
974 else if (rate < 4000)
975 rate = 4000;
976
977 spin_lock_irqsave(&chip->reg_lock, flags);
978
979 /*
980 * Program the AD1845 correctly for the playback stream.
981 * Note that we do NOT need to toggle the MCE bit because
982 * the PLAYBACK_ENABLE bit of the Interface Configuration
983 * register is set.
984 *
985 * NOTE: We seem to need to write to the MSB before the LSB
986 * to get the correct sample frequency.
987 */
988 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (format & 0xf0));
989 snd_wss_out(chip, AD1845_FREQ_SEL_MSB, (unsigned char) (rate >> 8));
990 snd_wss_out(chip, AD1845_FREQ_SEL_LSB, (unsigned char) rate);
991
992 spin_unlock_irqrestore(&chip->reg_lock, flags);
993}
994
995/*
996 * Override for the CS4231 capture format function.
997 * The AD1845 has much simpler format and rate selection.
998 */
999static void ad1845_capture_format(struct snd_wss *chip,
1000 struct snd_pcm_hw_params *params,
1001 unsigned char format)
1002{
1003 unsigned long flags;
1004 unsigned rate = params_rate(params);
1005
1006 /*
1007 * The AD1845 can't handle sample frequencies
1008 * outside of 4 kHZ to 50 kHZ
1009 */
1010 if (rate > 50000)
1011 rate = 50000;
1012 else if (rate < 4000)
1013 rate = 4000;
1014
1015 spin_lock_irqsave(&chip->reg_lock, flags);
1016
1017 /*
1018 * Program the AD1845 correctly for the playback stream.
1019 * Note that we do NOT need to toggle the MCE bit because
1020 * the CAPTURE_ENABLE bit of the Interface Configuration
1021 * register is set.
1022 *
1023 * NOTE: We seem to need to write to the MSB before the LSB
1024 * to get the correct sample frequency.
1025 */
1026 snd_wss_out(chip, CS4231_REC_FORMAT, (format & 0xf0));
1027 snd_wss_out(chip, AD1845_FREQ_SEL_MSB, (unsigned char) (rate >> 8));
1028 snd_wss_out(chip, AD1845_FREQ_SEL_LSB, (unsigned char) rate);
1029
1030 spin_unlock_irqrestore(&chip->reg_lock, flags);
1031}
1032
1033/*
1034 * Create an AD1845 PCM subdevice on the SoundScape. The AD1845 942 * Create an AD1845 PCM subdevice on the SoundScape. The AD1845
1035 * is very much like a CS4231, with a few extra bits. We will 943 * is very much like a CS4231, with a few extra bits. We will
1036 * try to support at least some of the extra bits by overriding 944 * try to support at least some of the extra bits by overriding
@@ -1055,11 +963,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1055 unsigned long flags; 963 unsigned long flags;
1056 struct snd_pcm *pcm; 964 struct snd_pcm *pcm;
1057 965
1058#define AD1845_FREQ_SEL_ENABLE 0x08
1059
1060#define AD1845_PWR_DOWN_CTRL 0x1b
1061#define AD1845_CRYS_CLOCK_SEL 0x1d
1062
1063/* 966/*
1064 * It turns out that the PLAYBACK_ENABLE bit is set 967 * It turns out that the PLAYBACK_ENABLE bit is set
1065 * by the lowlevel driver ... 968 * by the lowlevel driver ...
@@ -1074,7 +977,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1074 */ 977 */
1075 978
1076 if (sscape->type != SSCAPE_VIVO) { 979 if (sscape->type != SSCAPE_VIVO) {
1077 int val;
1078 /* 980 /*
1079 * The input clock frequency on the SoundScape must 981 * The input clock frequency on the SoundScape must
1080 * be 14.31818 MHz, because we must set this register 982 * be 14.31818 MHz, because we must set this register
@@ -1082,22 +984,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1082 */ 984 */
1083 snd_wss_mce_up(chip); 985 snd_wss_mce_up(chip);
1084 spin_lock_irqsave(&chip->reg_lock, flags); 986 spin_lock_irqsave(&chip->reg_lock, flags);
1085 snd_wss_out(chip, AD1845_CRYS_CLOCK_SEL, 0x20); 987 snd_wss_out(chip, AD1845_CLOCK, 0x20);
1086 spin_unlock_irqrestore(&chip->reg_lock, flags); 988 spin_unlock_irqrestore(&chip->reg_lock, flags);
1087 snd_wss_mce_down(chip); 989 snd_wss_mce_down(chip);
1088 990
1089 /*
1090 * More custom configuration:
1091 * a) select "mode 2" and provide a current drive of 8mA
1092 * b) enable frequency selection (for capture/playback)
1093 */
1094 spin_lock_irqsave(&chip->reg_lock, flags);
1095 snd_wss_out(chip, CS4231_MISC_INFO,
1096 CS4231_MODE2 | 0x10);
1097 val = snd_wss_in(chip, AD1845_PWR_DOWN_CTRL);
1098 snd_wss_out(chip, AD1845_PWR_DOWN_CTRL,
1099 val | AD1845_FREQ_SEL_ENABLE);
1100 spin_unlock_irqrestore(&chip->reg_lock, flags);
1101 } 991 }
1102 992
1103 err = snd_wss_pcm(chip, 0, &pcm); 993 err = snd_wss_pcm(chip, 0, &pcm);
@@ -1113,11 +1003,13 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1113 "for AD1845 chip\n"); 1003 "for AD1845 chip\n");
1114 goto _error; 1004 goto _error;
1115 } 1005 }
1116 err = snd_wss_timer(chip, 0, NULL); 1006 if (chip->hardware != WSS_HW_AD1848) {
1117 if (err < 0) { 1007 err = snd_wss_timer(chip, 0, NULL);
1118 snd_printk(KERN_ERR "sscape: No timer device " 1008 if (err < 0) {
1119 "for AD1845 chip\n"); 1009 snd_printk(KERN_ERR "sscape: No timer device "
1120 goto _error; 1010 "for AD1845 chip\n");
1011 goto _error;
1012 }
1121 } 1013 }
1122 1014
1123 if (sscape->type != SSCAPE_VIVO) { 1015 if (sscape->type != SSCAPE_VIVO) {
@@ -1128,8 +1020,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1128 "MIDI mixer control\n"); 1020 "MIDI mixer control\n");
1129 goto _error; 1021 goto _error;
1130 } 1022 }
1131 chip->set_playback_format = ad1845_playback_format;
1132 chip->set_capture_format = ad1845_capture_format;
1133 } 1023 }
1134 1024
1135 strcpy(card->driver, "SoundScape"); 1025 strcpy(card->driver, "SoundScape");
@@ -1157,7 +1047,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1157 unsigned dma_cfg; 1047 unsigned dma_cfg;
1158 unsigned irq_cfg; 1048 unsigned irq_cfg;
1159 unsigned mpu_irq_cfg; 1049 unsigned mpu_irq_cfg;
1160 unsigned xport;
1161 struct resource *io_res; 1050 struct resource *io_res;
1162 struct resource *wss_res; 1051 struct resource *wss_res;
1163 unsigned long flags; 1052 unsigned long flags;
@@ -1177,15 +1066,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1177 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); 1066 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1178 return -ENXIO; 1067 return -ENXIO;
1179 } 1068 }
1180 xport = port[dev];
1181 1069
1182 /* 1070 /*
1183 * Grab IO ports that we will need to probe so that we 1071 * Grab IO ports that we will need to probe so that we
1184 * can detect and control this hardware ... 1072 * can detect and control this hardware ...
1185 */ 1073 */
1186 io_res = request_region(xport, 8, "SoundScape"); 1074 io_res = request_region(port[dev], 8, "SoundScape");
1187 if (!io_res) { 1075 if (!io_res) {
1188 snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport); 1076 snd_printk(KERN_ERR
1077 "sscape: can't grab port 0x%lx\n", port[dev]);
1189 return -EBUSY; 1078 return -EBUSY;
1190 } 1079 }
1191 wss_res = NULL; 1080 wss_res = NULL;
@@ -1212,10 +1101,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1212 spin_lock_init(&sscape->fwlock); 1101 spin_lock_init(&sscape->fwlock);
1213 sscape->io_res = io_res; 1102 sscape->io_res = io_res;
1214 sscape->wss_res = wss_res; 1103 sscape->wss_res = wss_res;
1215 sscape->io_base = xport; 1104 sscape->io_base = port[dev];
1216 sscape->wss_base = wss_port[dev];
1217 1105
1218 if (!detect_sscape(sscape)) { 1106 if (!detect_sscape(sscape, wss_port[dev])) {
1219 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); 1107 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base);
1220 err = -ENODEV; 1108 err = -ENODEV;
1221 goto _release_dma; 1109 goto _release_dma;
@@ -1288,12 +1176,11 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1288 } 1176 }
1289#define MIDI_DEVNUM 0 1177#define MIDI_DEVNUM 0
1290 if (sscape->type != SSCAPE_VIVO) { 1178 if (sscape->type != SSCAPE_VIVO) {
1291 err = create_mpu401(card, MIDI_DEVNUM, 1179 err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]);
1292 MPU401_IO(xport), mpu_irq[dev]);
1293 if (err < 0) { 1180 if (err < 0) {
1294 printk(KERN_ERR "sscape: Failed to create " 1181 printk(KERN_ERR "sscape: Failed to create "
1295 "MPU-401 device at 0x%x\n", 1182 "MPU-401 device at 0x%lx\n",
1296 MPU401_IO(xport)); 1183 port[dev]);
1297 goto _release_dma; 1184 goto _release_dma;
1298 } 1185 }
1299 1186
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 95898b2b7b58..a34ae7b1f7d0 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -553,11 +553,11 @@ static int __devinit snd_wavefront_isa_match(struct device *pdev,
553 return 0; 553 return 0;
554#endif 554#endif
555 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 555 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
556 snd_printk("specify CS4232 port\n"); 556 snd_printk(KERN_ERR "specify CS4232 port\n");
557 return 0; 557 return 0;
558 } 558 }
559 if (ics2115_port[dev] == SNDRV_AUTO_PORT) { 559 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
560 snd_printk("specify ICS2115 port\n"); 560 snd_printk(KERN_ERR "specify ICS2115 port\n");
561 return 0; 561 return 0;
562 } 562 }
563 return 1; 563 return 1;
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index dfc449a2194e..2bb1cee09255 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -34,14 +34,6 @@
34 34
35#define WAIT_IDLE 0xff 35#define WAIT_IDLE 0xff
36 36
37#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
38#include "yss225.c"
39static const struct firmware yss225_registers_firmware = {
40 .data = (u8 *)yss225_registers,
41 .size = sizeof yss225_registers
42};
43#endif
44
45static int 37static int
46wavefront_fx_idle (snd_wavefront_t *dev) 38wavefront_fx_idle (snd_wavefront_t *dev)
47 39
@@ -210,15 +202,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
210 "> 512 bytes to FX\n"); 202 "> 512 bytes to FX\n");
211 return -EIO; 203 return -EIO;
212 } 204 }
213 page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL); 205 page_data = memdup_user((unsigned char __user *)
214 if (!page_data) 206 r.data[3],
215 return -ENOMEM; 207 r.data[2] * sizeof(short));
216 if (copy_from_user (page_data, 208 if (IS_ERR(page_data))
217 (unsigned char __user *) r.data[3], 209 return PTR_ERR(page_data);
218 r.data[2] * sizeof(short))) {
219 kfree(page_data);
220 return -EFAULT;
221 }
222 pd = page_data; 210 pd = page_data;
223 } 211 }
224 212
@@ -260,16 +248,12 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
260 if (dev->fx_initialized) 248 if (dev->fx_initialized)
261 return 0; 249 return 0;
262 250
263#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
264 firmware = &yss225_registers_firmware;
265#else
266 err = request_firmware(&firmware, "yamaha/yss225_registers.bin", 251 err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
267 dev->card->dev); 252 dev->card->dev);
268 if (err < 0) { 253 if (err < 0) {
269 err = -1; 254 err = -1;
270 goto out; 255 goto out;
271 } 256 }
272#endif
273 257
274 for (i = 0; i + 1 < firmware->size; i += 2) { 258 for (i = 0; i + 1 < firmware->size; i += 2) {
275 if (firmware->data[i] >= 8 && firmware->data[i] < 16) { 259 if (firmware->data[i] >= 8 && firmware->data[i] < 16) {
@@ -292,12 +276,8 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
292 err = 0; 276 err = 0;
293 277
294out: 278out:
295#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
296 release_firmware(firmware); 279 release_firmware(firmware);
297#endif
298 return err; 280 return err;
299} 281}
300 282
301#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
302MODULE_FIRMWARE("yamaha/yss225_registers.bin"); 283MODULE_FIRMWARE("yamaha/yss225_registers.bin");
303#endif
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index 4c410820a994..5d4ff48c4345 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -633,7 +633,7 @@ wavefront_get_sample_status (snd_wavefront_t *dev, int assume_rom)
633 wbuf[1] = i >> 7; 633 wbuf[1] = i >> 7;
634 634
635 if (snd_wavefront_cmd (dev, WFC_IDENTIFY_SAMPLE_TYPE, rbuf, wbuf)) { 635 if (snd_wavefront_cmd (dev, WFC_IDENTIFY_SAMPLE_TYPE, rbuf, wbuf)) {
636 snd_printk("cannot identify sample " 636 snd_printk(KERN_WARNING "cannot identify sample "
637 "type of slot %d\n", i); 637 "type of slot %d\n", i);
638 dev->sample_status[i] = WF_ST_EMPTY; 638 dev->sample_status[i] = WF_ST_EMPTY;
639 continue; 639 continue;
@@ -1664,12 +1664,11 @@ snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file,
1664 break; 1664 break;
1665 1665
1666 case WFCTL_WFCMD: 1666 case WFCTL_WFCMD:
1667 wc = kmalloc(sizeof(*wc), GFP_KERNEL); 1667 wc = memdup_user(argp, sizeof(*wc));
1668 if (! wc) 1668 if (IS_ERR(wc))
1669 return -ENOMEM; 1669 return PTR_ERR(wc);
1670 if (copy_from_user (wc, argp, sizeof (*wc))) 1670
1671 err = -EFAULT; 1671 if (wavefront_synth_control (acard, wc) < 0)
1672 else if (wavefront_synth_control (acard, wc) < 0)
1673 err = -EIO; 1672 err = -EIO;
1674 else if (copy_to_user (argp, wc, sizeof (*wc))) 1673 else if (copy_to_user (argp, wc, sizeof (*wc)))
1675 err = -EFAULT; 1674 err = -EFAULT;
diff --git a/sound/isa/wavefront/yss225.c b/sound/isa/wavefront/yss225.c
deleted file mode 100644
index 9f6be3ff8ecf..000000000000
--- a/sound/isa/wavefront/yss225.c
+++ /dev/null
@@ -1,2739 +0,0 @@
1/*
2 * Copyright (c) 1998-2002 by Paul Davis <pbd@op.net>
3 *
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
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19/* weird stuff, derived from port I/O tracing with dosemu */
20
21static const struct {
22 unsigned char addr;
23 unsigned char data;
24} yss225_registers[] __devinitdata = {
25/* Set all bits for all channels on the MOD unit to zero */
26{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
27{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
28{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
29{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
30{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
31{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
32{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
33{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
34{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
35{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
36{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
37{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
38{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
39{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
40{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
41{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
42{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
43{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
44{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
45{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
46{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
47{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
48{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
49{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
50{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
51{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
52{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
53{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
54{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
55{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
56{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
57{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
58{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
59{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
60{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
61{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
62{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
63{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
64{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
65{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
66{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
67{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
68{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
69{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
70{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
71{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
72{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
73{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
74{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
75{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
76{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
77{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
78{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
79{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
80{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
81{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
82{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
83{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
84{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
85{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
86{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
87{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
88{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
89{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
90{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
91{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
92{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
93{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
94{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
95{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
96{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
97{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
98{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
99{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
100{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
101{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
102{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
103{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
104{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
105{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
106{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
107{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
108{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
109{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
110{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
111{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
112{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
113{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
114{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
115{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
116{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
117{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
118{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
119{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
120{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
121{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
122{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
123{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
124{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
125{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
126{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
127{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
128{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
129{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
130{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
131{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
132{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
133{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
134{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
135{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
136{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
137{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
138{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
139{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
140{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
141{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
142{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
143{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
144{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
145{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
146{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
147{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
148{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
149{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
150{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
151{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
152{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
153{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
154{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
155{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
156{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
157{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
158{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
159{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
160{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
161{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
162{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
163{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
164{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
165{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
166{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
167{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
168{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
169{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
170{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
171{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
172{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
173{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
174{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
175{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
176{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
177{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
178{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
179{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
180{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
181{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
182{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
183{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
184{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
185{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
186{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
187{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
188{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
189{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
190{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
191{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
192{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
193{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
194{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
195{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
196{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
197{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
198{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
199{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
200{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
201{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
202{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
203{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
204{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
205{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
206{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
207{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
208{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
209{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
210{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
211{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
212{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
213{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
214{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
215{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
216{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
217{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
218{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
219{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
220{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
221{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
222{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
223{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
224{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
225{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
226{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
227{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
228{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
229{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
230{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
231{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
232{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
233{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
234{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
235{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
236{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
237{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
238{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
239{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
240{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
241{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
242{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
243{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
244{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
245{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
246{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
247{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
248{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
249{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
250{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
251{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
252{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
253{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
254{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
255{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
256{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
257{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
258{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
259{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
260{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
261{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
262{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
263{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
264{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
265{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
266
267/* XXX But why do this twice? */
268{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
269{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
270{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
271{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
272{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
273{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
274{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
275{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
276{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
277{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
278{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
279{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
280{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
281{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
282{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
283{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
284{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
285{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
286{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
287{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
288{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
289{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
290{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
291{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
292{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
293{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
294{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
295{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
296{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
297{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
298{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
299{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
300{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
301{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
302{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
303{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
304{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
305{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
306{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
307{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
308{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
309{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
310{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
311{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
312{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
313{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
314{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
315{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
316{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
317{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
318{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
319{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
320{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
321{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
322{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
323{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
324{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
325{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
326{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
327{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
328{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
329{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
330{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
331{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
332{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
333{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
334{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
335{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
336{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
337{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
338{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
339{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
340{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
341{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
342{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
343{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
344{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
345{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
346{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
347{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
348{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
349{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
350{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
351{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
352{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
353{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
354{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
355{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
356{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
357{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
358{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
359{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
360{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
361{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
362{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
363{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
364{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
365{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
366{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
367{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
368{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
369{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
370{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
371{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
372{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
373{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
374{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
375{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
376{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
377{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
378{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
379{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
380{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
381{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
382{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
383{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
384{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
385{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
386{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
387{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
388{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
389{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
390{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
391{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
392{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
393{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
394{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
395{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
396{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
397{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
398{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
399{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
400{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
401{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
402{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
403{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
404{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
405{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
406{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
407{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
408{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
409{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
410{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
411{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
412{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
413{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
414{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
415{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
416{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
417{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
418{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
419{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
420{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
421{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
422{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
423{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
424{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
425{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
426{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
427{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
428{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
429{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
430{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
431{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
432{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
433{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
434{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
435{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
436{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
437{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
438{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
439{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
440{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
441{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
442{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
443{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
444{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
445{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
446{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
447{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
448{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
449{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
450{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
451{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
452{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
453{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
454{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
455{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
456{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
457{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
458{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
459{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
460{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
461{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
462{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
463{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
464{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
465{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
466{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
467{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
468{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
469{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
470{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
471{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
472{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
473{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
474{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
475{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
476{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
477{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
478{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
479{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
480{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
481{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
482{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
483{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
484{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
485{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
486{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
487{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
488{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
489{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
490{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
491{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
492{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
493{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
494{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
495{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
496{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
497{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
498{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
499{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
500{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
501{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
502{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
503{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
504{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
505{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
506{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
507{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
508
509/* mute on */
510{ WAIT_IDLE }, { 0x8, 0x02 },
511
512{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 },
513{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 },
514{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 },
515{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 },
516{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 },
517{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 },
518{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 },
519{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 },
520{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 },
521
522/* either because of stupidity by TB's programmers, or because it
523 actually does something, rezero the MOD page. */
524{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 },
525{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 },
526{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 },
527{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 },
528{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 },
529{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 },
530{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 },
531{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 },
532{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 },
533{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 },
534{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 },
535{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 },
536{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 },
537{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 },
538{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 },
539{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 },
540{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 },
541{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 },
542{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 },
543{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 },
544{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 },
545{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 },
546{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 },
547{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 },
548{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 },
549{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 },
550{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 },
551{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 },
552{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 },
553{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 },
554{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 },
555{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 },
556{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 },
557{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 },
558{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 },
559{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 },
560{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 },
561{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 },
562{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 },
563{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 },
564{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 },
565{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 },
566{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 },
567{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 },
568{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 },
569{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 },
570{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 },
571{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 },
572{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 },
573{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 },
574{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 },
575{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 },
576{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 },
577{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 },
578{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 },
579{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 },
580{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 },
581{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 },
582{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 },
583{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 },
584{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 },
585{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 },
586{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 },
587{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 },
588{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 },
589{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 },
590{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 },
591{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 },
592{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 },
593{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 },
594{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 },
595{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 },
596{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 },
597{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 },
598{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 },
599{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 },
600{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 },
601{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 },
602{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 },
603{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 },
604{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 },
605{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 },
606{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 },
607{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 },
608{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 },
609{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 },
610{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 },
611{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 },
612{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 },
613{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 },
614{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 },
615{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 },
616{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 },
617{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 },
618{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 },
619{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 },
620{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 },
621{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 },
622{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 },
623{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 },
624{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 },
625{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 },
626{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 },
627{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 },
628{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 },
629{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 },
630{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 },
631{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 },
632{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 },
633{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 },
634{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 },
635{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 },
636{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 },
637{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 },
638{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 },
639{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 },
640{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 },
641{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 },
642{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 },
643{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 },
644{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 },
645{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 },
646{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 },
647{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 },
648{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 },
649{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 },
650{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 },
651{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 },
652{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 },
653{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 },
654{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 },
655{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 },
656{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 },
657{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 },
658{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 },
659{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 },
660{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 },
661{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 },
662{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 },
663{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 },
664{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 },
665{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 },
666{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 },
667{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 },
668{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 },
669{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 },
670{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 },
671{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 },
672{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 },
673{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 },
674{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 },
675{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 },
676{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 },
677{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 },
678{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 },
679{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 },
680{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 },
681{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 },
682{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 },
683{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 },
684{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 },
685{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 },
686{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 },
687{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 },
688{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 },
689{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 },
690{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 },
691{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 },
692{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 },
693{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 },
694{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 },
695{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 },
696{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 },
697{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 },
698{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 },
699{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 },
700{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 },
701{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 },
702{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 },
703{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 },
704{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 },
705{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 },
706{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 },
707{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 },
708{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 },
709{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 },
710{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 },
711{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 },
712{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 },
713{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 },
714{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 },
715{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 },
716{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 },
717{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 },
718{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 },
719{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 },
720{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 },
721{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 },
722{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 },
723{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 },
724{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 },
725{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 },
726{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 },
727{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 },
728{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 },
729{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 },
730{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 },
731{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 },
732{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 },
733{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 },
734{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 },
735{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 },
736{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 },
737{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 },
738{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 },
739{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 },
740{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 },
741{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 },
742{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 },
743{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 },
744{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 },
745{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 },
746{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 },
747{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 },
748{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 },
749{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 },
750{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 },
751{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 },
752{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 },
753{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 },
754{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 },
755{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 },
756{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 },
757{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 },
758{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 },
759{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 },
760{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 },
761{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 },
762{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 },
763{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 },
764
765/* load page zero */
766{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x00 },
767
768{ 0xd, 0x01 }, { 0xc, 0x7c }, { WAIT_IDLE },
769{ 0xd, 0x00 }, { 0xc, 0x1e }, { WAIT_IDLE },
770{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
771{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
772{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE },
773{ 0xd, 0x00 }, { 0xc, 0x11 }, { WAIT_IDLE },
774{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
775{ 0xd, 0x00 }, { 0xc, 0x32 }, { WAIT_IDLE },
776{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
777{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE },
778{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
779{ 0xd, 0x00 }, { 0xc, 0x14 }, { WAIT_IDLE },
780{ 0xd, 0x02 }, { 0xc, 0x76 }, { WAIT_IDLE },
781{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE },
782{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
783{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
784{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
785{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
786{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
787{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
788{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
789{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
790{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
791{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
792{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
793{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
794{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
795{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
796{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
797{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
798{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
799{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
800{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
801{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
802{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
803{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
804{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
805{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
806{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
807{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
808{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
809{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
810{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
811{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
812{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
813{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
814{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
815{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
816{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
817{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
818{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
819{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
820{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
821{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
822{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
823{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
824{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
825{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
826{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
827{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
828{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
829{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
830{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
831{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
832{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE },
833{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
834{ 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE },
835{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
836{ 0xd, 0x01 }, { 0xc, 0x40 }, { WAIT_IDLE },
837{ 0xd, 0x01 }, { 0xc, 0x17 }, { WAIT_IDLE },
838{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
839{ 0xd, 0x01 }, { 0xc, 0x80 }, { WAIT_IDLE },
840{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
841{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE },
842{ 0xd, 0x01 }, { 0xc, 0xa0 }, { WAIT_IDLE },
843{ 0xd, 0x03 }, { 0xc, 0xd1 }, { WAIT_IDLE },
844{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
845{ 0xd, 0x01 }, { 0xc, 0xf2 }, { WAIT_IDLE },
846{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
847{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE },
848{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
849{ 0xd, 0x00 }, { 0xc, 0xf4 }, { WAIT_IDLE },
850{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE },
851{ 0xd, 0x00 }, { 0xc, 0x15 }, { WAIT_IDLE },
852{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
853{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE },
854{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
855{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE },
856{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
857{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
858{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
859{ 0xd, 0x00 }, { 0xc, 0x50 }, { WAIT_IDLE },
860{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
861{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
862{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
863{ 0xd, 0x00 }, { 0xc, 0x71 }, { WAIT_IDLE },
864{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
865{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE },
866{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
867{ 0xd, 0x00 }, { 0xc, 0x92 }, { WAIT_IDLE },
868{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
869{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
870{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
871{ 0xd, 0x00 }, { 0xc, 0xb3 }, { WAIT_IDLE },
872{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
873{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE },
874{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
875{ 0xd, 0x00 }, { 0xc, 0xd4 }, { WAIT_IDLE },
876{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
877{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE },
878{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
879{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE },
880{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
881{ 0xd, 0x00 }, { 0xc, 0x70 }, { WAIT_IDLE },
882{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE },
883{ 0xd, 0x02 }, { 0xc, 0x11 }, { WAIT_IDLE },
884{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE },
885{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
886{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
887{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
888{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
889{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
890{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE },
891{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE },
892{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE },
893{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
894{ 0xd, 0x00 }, { 0xc, 0x1d }, { WAIT_IDLE },
895{ 0xd, 0x02 }, { 0xc, 0xdf }, { WAIT_IDLE },
896
897/* Now load page one */
898{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x00 },
899
900{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
901{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
902{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
903{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
904{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
905{ 0xd, 0x00 }, { 0xc, 0x1f }, { WAIT_IDLE },
906{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
907{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
908{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
909{ 0xd, 0x03 }, { 0xc, 0xd8 }, { WAIT_IDLE },
910{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
911{ 0xd, 0x02 }, { 0xc, 0x20 }, { WAIT_IDLE },
912{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE },
913{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
914{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
915{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE },
916{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE },
917{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE },
918{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE },
919{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
920{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
921{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
922{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
923{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
924{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
925{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
926{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
927{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
928{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
929{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
930{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
931{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
932{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
933{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
934{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
935{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
936{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
937{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
938{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
939{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
940{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
941{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
942{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
943{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
944{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
945{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
946{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
947{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
948{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
949{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
950{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
951{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
952{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
953{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
954{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
955{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
956{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
957{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
958{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
959{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
960{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
961{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
962{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
963{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
964{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
965{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
966{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
967{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
968{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
969{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE },
970{ 0xd, 0x02 }, { 0xc, 0x80 }, { WAIT_IDLE },
971{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
972{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
973{ 0xd, 0x02 }, { 0xc, 0xa0 }, { WAIT_IDLE },
974{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
975{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
976{ 0xd, 0x02 }, { 0xc, 0xd7 }, { WAIT_IDLE },
977{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
978{ 0xd, 0x02 }, { 0xc, 0xf7 }, { WAIT_IDLE },
979{ 0xd, 0x03 }, { 0xc, 0x20 }, { WAIT_IDLE },
980{ 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE },
981{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
982{ 0xd, 0x00 }, { 0xc, 0x1c }, { WAIT_IDLE },
983{ 0xd, 0x03 }, { 0xc, 0x3c }, { WAIT_IDLE },
984{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
985{ 0xd, 0x03 }, { 0xc, 0x3f }, { WAIT_IDLE },
986{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
987{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
988{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
989{ 0xd, 0x03 }, { 0xc, 0xdf }, { WAIT_IDLE },
990{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
991{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
992{ 0xd, 0x03 }, { 0xc, 0x5d }, { WAIT_IDLE },
993{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
994{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
995{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
996{ 0xd, 0x03 }, { 0xc, 0x7d }, { WAIT_IDLE },
997{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
998{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
999{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1000{ 0xd, 0x03 }, { 0xc, 0x9e }, { WAIT_IDLE },
1001{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1002{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
1003{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1004{ 0xd, 0x03 }, { 0xc, 0xbe }, { WAIT_IDLE },
1005{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1006{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE },
1007{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1008{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1009{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1010{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1011{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
1012{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1013{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1014{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1015{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE },
1016{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1017{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE },
1018{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1019{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE },
1020{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1021{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
1022{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1023{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE },
1024{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
1025{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE },
1026{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
1027{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE },
1028
1029{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x00 },
1030
1031{ 0xc, 0xc4 }, { WAIT_IDLE },
1032{ 0xc, 0x00 }, { WAIT_IDLE },
1033{ 0xc, 0x44 }, { WAIT_IDLE },
1034{ 0xc, 0x07 }, { WAIT_IDLE },
1035{ 0xc, 0x44 }, { WAIT_IDLE },
1036{ 0xc, 0x00 }, { WAIT_IDLE },
1037{ 0xc, 0x40 }, { WAIT_IDLE },
1038{ 0xc, 0x25 }, { WAIT_IDLE },
1039{ 0xc, 0x01 }, { WAIT_IDLE },
1040{ 0xc, 0x06 }, { WAIT_IDLE },
1041{ 0xc, 0xc4 }, { WAIT_IDLE },
1042{ 0xc, 0x07 }, { WAIT_IDLE },
1043{ 0xc, 0x40 }, { WAIT_IDLE },
1044{ 0xc, 0x25 }, { WAIT_IDLE },
1045{ 0xc, 0x01 }, { WAIT_IDLE },
1046{ 0xc, 0x00 }, { WAIT_IDLE },
1047{ 0xc, 0x46 }, { WAIT_IDLE },
1048{ 0xc, 0x46 }, { WAIT_IDLE },
1049{ 0xc, 0x00 }, { WAIT_IDLE },
1050{ 0xc, 0x00 }, { WAIT_IDLE },
1051{ 0xc, 0x00 }, { WAIT_IDLE },
1052{ 0xc, 0x00 }, { WAIT_IDLE },
1053{ 0xc, 0x00 }, { WAIT_IDLE },
1054{ 0xc, 0x00 }, { WAIT_IDLE },
1055{ 0xc, 0x00 }, { WAIT_IDLE },
1056{ 0xc, 0x00 }, { WAIT_IDLE },
1057{ 0xc, 0x00 }, { WAIT_IDLE },
1058{ 0xc, 0x00 }, { WAIT_IDLE },
1059{ 0xc, 0x00 }, { WAIT_IDLE },
1060{ 0xc, 0x00 }, { WAIT_IDLE },
1061{ 0xc, 0x00 }, { WAIT_IDLE },
1062{ 0xc, 0x00 }, { WAIT_IDLE },
1063{ 0xc, 0x00 }, { WAIT_IDLE },
1064{ 0xc, 0x00 }, { WAIT_IDLE },
1065{ 0xc, 0x00 }, { WAIT_IDLE },
1066{ 0xc, 0x00 }, { WAIT_IDLE },
1067{ 0xc, 0x00 }, { WAIT_IDLE },
1068{ 0xc, 0x00 }, { WAIT_IDLE },
1069{ 0xc, 0x00 }, { WAIT_IDLE },
1070{ 0xc, 0x00 }, { WAIT_IDLE },
1071{ 0xc, 0x00 }, { WAIT_IDLE },
1072{ 0xc, 0x00 }, { WAIT_IDLE },
1073{ 0xc, 0x00 }, { WAIT_IDLE },
1074{ 0xc, 0x00 }, { WAIT_IDLE },
1075{ 0xc, 0x00 }, { WAIT_IDLE },
1076{ 0xc, 0x00 }, { WAIT_IDLE },
1077{ 0xc, 0x00 }, { WAIT_IDLE },
1078{ 0xc, 0x00 }, { WAIT_IDLE },
1079{ 0xc, 0x00 }, { WAIT_IDLE },
1080{ 0xc, 0x00 }, { WAIT_IDLE },
1081{ 0xc, 0x00 }, { WAIT_IDLE },
1082{ 0xc, 0x00 }, { WAIT_IDLE },
1083{ 0xc, 0x00 }, { WAIT_IDLE },
1084{ 0xc, 0x00 }, { WAIT_IDLE },
1085{ 0xc, 0x00 }, { WAIT_IDLE },
1086{ 0xc, 0x00 }, { WAIT_IDLE },
1087{ 0xc, 0x00 }, { WAIT_IDLE },
1088{ 0xc, 0x00 }, { WAIT_IDLE },
1089{ 0xc, 0x00 }, { WAIT_IDLE },
1090{ 0xc, 0x00 }, { WAIT_IDLE },
1091{ 0xc, 0x00 }, { WAIT_IDLE },
1092{ 0xc, 0x00 }, { WAIT_IDLE },
1093{ 0xc, 0x00 }, { WAIT_IDLE },
1094{ 0xc, 0x00 }, { WAIT_IDLE },
1095{ 0xc, 0x46 }, { WAIT_IDLE },
1096{ 0xc, 0x07 }, { WAIT_IDLE },
1097{ 0xc, 0x05 }, { WAIT_IDLE },
1098{ 0xc, 0x05 }, { WAIT_IDLE },
1099{ 0xc, 0x05 }, { WAIT_IDLE },
1100{ 0xc, 0x04 }, { WAIT_IDLE },
1101{ 0xc, 0x07 }, { WAIT_IDLE },
1102{ 0xc, 0x05 }, { WAIT_IDLE },
1103{ 0xc, 0x04 }, { WAIT_IDLE },
1104{ 0xc, 0x07 }, { WAIT_IDLE },
1105{ 0xc, 0x05 }, { WAIT_IDLE },
1106{ 0xc, 0x44 }, { WAIT_IDLE },
1107{ 0xc, 0x46 }, { WAIT_IDLE },
1108{ 0xc, 0x44 }, { WAIT_IDLE },
1109{ 0xc, 0x46 }, { WAIT_IDLE },
1110{ 0xc, 0x46 }, { WAIT_IDLE },
1111{ 0xc, 0x07 }, { WAIT_IDLE },
1112{ 0xc, 0x05 }, { WAIT_IDLE },
1113{ 0xc, 0x44 }, { WAIT_IDLE },
1114{ 0xc, 0x46 }, { WAIT_IDLE },
1115{ 0xc, 0x05 }, { WAIT_IDLE },
1116{ 0xc, 0x46 }, { WAIT_IDLE },
1117{ 0xc, 0x05 }, { WAIT_IDLE },
1118{ 0xc, 0x46 }, { WAIT_IDLE },
1119{ 0xc, 0x05 }, { WAIT_IDLE },
1120{ 0xc, 0x46 }, { WAIT_IDLE },
1121{ 0xc, 0x05 }, { WAIT_IDLE },
1122{ 0xc, 0x44 }, { WAIT_IDLE },
1123{ 0xc, 0x46 }, { WAIT_IDLE },
1124{ 0xc, 0x05 }, { WAIT_IDLE },
1125{ 0xc, 0x07 }, { WAIT_IDLE },
1126{ 0xc, 0x44 }, { WAIT_IDLE },
1127{ 0xc, 0x46 }, { WAIT_IDLE },
1128{ 0xc, 0x05 }, { WAIT_IDLE },
1129{ 0xc, 0x07 }, { WAIT_IDLE },
1130{ 0xc, 0x44 }, { WAIT_IDLE },
1131{ 0xc, 0x46 }, { WAIT_IDLE },
1132{ 0xc, 0x05 }, { WAIT_IDLE },
1133{ 0xc, 0x07 }, { WAIT_IDLE },
1134{ 0xc, 0x44 }, { WAIT_IDLE },
1135{ 0xc, 0x46 }, { WAIT_IDLE },
1136{ 0xc, 0x05 }, { WAIT_IDLE },
1137{ 0xc, 0x07 }, { WAIT_IDLE },
1138{ 0xc, 0x44 }, { WAIT_IDLE },
1139{ 0xc, 0x05 }, { WAIT_IDLE },
1140{ 0xc, 0x05 }, { WAIT_IDLE },
1141{ 0xc, 0x05 }, { WAIT_IDLE },
1142{ 0xc, 0x44 }, { WAIT_IDLE },
1143{ 0xc, 0x05 }, { WAIT_IDLE },
1144{ 0xc, 0x05 }, { WAIT_IDLE },
1145{ 0xc, 0x05 }, { WAIT_IDLE },
1146{ 0xc, 0x46 }, { WAIT_IDLE },
1147{ 0xc, 0x05 }, { WAIT_IDLE },
1148{ 0xc, 0x46 }, { WAIT_IDLE },
1149{ 0xc, 0x05 }, { WAIT_IDLE },
1150{ 0xc, 0x46 }, { WAIT_IDLE },
1151{ 0xc, 0x05 }, { WAIT_IDLE },
1152{ 0xc, 0x46 }, { WAIT_IDLE },
1153{ 0xc, 0x05 }, { WAIT_IDLE },
1154{ 0xc, 0x46 }, { WAIT_IDLE },
1155{ 0xc, 0x07 }, { WAIT_IDLE },
1156{ 0xc, 0x46 }, { WAIT_IDLE },
1157{ 0xc, 0x07 }, { WAIT_IDLE },
1158{ 0xc, 0x44 }, { WAIT_IDLE },
1159
1160{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x00 },
1161
1162{ 0xc, 0x07 }, { WAIT_IDLE },
1163{ 0xc, 0x40 }, { WAIT_IDLE },
1164{ 0xc, 0x00 }, { WAIT_IDLE },
1165{ 0xc, 0x00 }, { WAIT_IDLE },
1166{ 0xc, 0x00 }, { WAIT_IDLE },
1167{ 0xc, 0x47 }, { WAIT_IDLE },
1168{ 0xc, 0x00 }, { WAIT_IDLE },
1169{ 0xc, 0x40 }, { WAIT_IDLE },
1170{ 0xc, 0x00 }, { WAIT_IDLE },
1171{ 0xc, 0x40 }, { WAIT_IDLE },
1172{ 0xc, 0x06 }, { WAIT_IDLE },
1173{ 0xc, 0x40 }, { WAIT_IDLE },
1174{ 0xc, 0x00 }, { WAIT_IDLE },
1175{ 0xc, 0x00 }, { WAIT_IDLE },
1176{ 0xc, 0x00 }, { WAIT_IDLE },
1177{ 0xc, 0x00 }, { WAIT_IDLE },
1178{ 0xc, 0x00 }, { WAIT_IDLE },
1179{ 0xc, 0x00 }, { WAIT_IDLE },
1180{ 0xc, 0x00 }, { WAIT_IDLE },
1181{ 0xc, 0x00 }, { WAIT_IDLE },
1182{ 0xc, 0x00 }, { WAIT_IDLE },
1183{ 0xc, 0x00 }, { WAIT_IDLE },
1184{ 0xc, 0x00 }, { WAIT_IDLE },
1185{ 0xc, 0x00 }, { WAIT_IDLE },
1186{ 0xc, 0x00 }, { WAIT_IDLE },
1187{ 0xc, 0x00 }, { WAIT_IDLE },
1188{ 0xc, 0x00 }, { WAIT_IDLE },
1189{ 0xc, 0x00 }, { WAIT_IDLE },
1190{ 0xc, 0x00 }, { WAIT_IDLE },
1191{ 0xc, 0x00 }, { WAIT_IDLE },
1192{ 0xc, 0x00 }, { WAIT_IDLE },
1193{ 0xc, 0x00 }, { WAIT_IDLE },
1194{ 0xc, 0x00 }, { WAIT_IDLE },
1195{ 0xc, 0x00 }, { WAIT_IDLE },
1196{ 0xc, 0x00 }, { WAIT_IDLE },
1197{ 0xc, 0x00 }, { WAIT_IDLE },
1198{ 0xc, 0x00 }, { WAIT_IDLE },
1199{ 0xc, 0x00 }, { WAIT_IDLE },
1200{ 0xc, 0x00 }, { WAIT_IDLE },
1201{ 0xc, 0x00 }, { WAIT_IDLE },
1202{ 0xc, 0x00 }, { WAIT_IDLE },
1203{ 0xc, 0x00 }, { WAIT_IDLE },
1204{ 0xc, 0x00 }, { WAIT_IDLE },
1205{ 0xc, 0x00 }, { WAIT_IDLE },
1206{ 0xc, 0x00 }, { WAIT_IDLE },
1207{ 0xc, 0x00 }, { WAIT_IDLE },
1208{ 0xc, 0x00 }, { WAIT_IDLE },
1209{ 0xc, 0x00 }, { WAIT_IDLE },
1210{ 0xc, 0x00 }, { WAIT_IDLE },
1211{ 0xc, 0x00 }, { WAIT_IDLE },
1212{ 0xc, 0x00 }, { WAIT_IDLE },
1213{ 0xc, 0x00 }, { WAIT_IDLE },
1214{ 0xc, 0x00 }, { WAIT_IDLE },
1215{ 0xc, 0x00 }, { WAIT_IDLE },
1216{ 0xc, 0x00 }, { WAIT_IDLE },
1217{ 0xc, 0x00 }, { WAIT_IDLE },
1218{ 0xc, 0x00 }, { WAIT_IDLE },
1219{ 0xc, 0x00 }, { WAIT_IDLE },
1220{ 0xc, 0x00 }, { WAIT_IDLE },
1221{ 0xc, 0x00 }, { WAIT_IDLE },
1222{ 0xc, 0x00 }, { WAIT_IDLE },
1223{ 0xc, 0x00 }, { WAIT_IDLE },
1224{ 0xc, 0x00 }, { WAIT_IDLE },
1225{ 0xc, 0x00 }, { WAIT_IDLE },
1226{ 0xc, 0x80 }, { WAIT_IDLE },
1227{ 0xc, 0x80 }, { WAIT_IDLE },
1228{ 0xc, 0xc0 }, { WAIT_IDLE },
1229{ 0xc, 0x00 }, { WAIT_IDLE },
1230{ 0xc, 0x00 }, { WAIT_IDLE },
1231{ 0xc, 0x40 }, { WAIT_IDLE },
1232{ 0xc, 0x00 }, { WAIT_IDLE },
1233{ 0xc, 0x00 }, { WAIT_IDLE },
1234{ 0xc, 0x00 }, { WAIT_IDLE },
1235{ 0xc, 0x40 }, { WAIT_IDLE },
1236{ 0xc, 0x00 }, { WAIT_IDLE },
1237{ 0xc, 0x40 }, { WAIT_IDLE },
1238{ 0xc, 0x00 }, { WAIT_IDLE },
1239{ 0xc, 0x60 }, { WAIT_IDLE },
1240{ 0xc, 0x00 }, { WAIT_IDLE },
1241{ 0xc, 0x70 }, { WAIT_IDLE },
1242{ 0xc, 0x00 }, { WAIT_IDLE },
1243{ 0xc, 0x40 }, { WAIT_IDLE },
1244{ 0xc, 0x00 }, { WAIT_IDLE },
1245{ 0xc, 0x40 }, { WAIT_IDLE },
1246{ 0xc, 0x00 }, { WAIT_IDLE },
1247{ 0xc, 0x42 }, { WAIT_IDLE },
1248{ 0xc, 0x00 }, { WAIT_IDLE },
1249{ 0xc, 0x40 }, { WAIT_IDLE },
1250{ 0xc, 0x00 }, { WAIT_IDLE },
1251{ 0xc, 0x02 }, { WAIT_IDLE },
1252{ 0xc, 0x00 }, { WAIT_IDLE },
1253{ 0xc, 0x40 }, { WAIT_IDLE },
1254{ 0xc, 0x00 }, { WAIT_IDLE },
1255{ 0xc, 0x00 }, { WAIT_IDLE },
1256{ 0xc, 0x00 }, { WAIT_IDLE },
1257{ 0xc, 0x40 }, { WAIT_IDLE },
1258{ 0xc, 0x00 }, { WAIT_IDLE },
1259{ 0xc, 0x00 }, { WAIT_IDLE },
1260{ 0xc, 0x00 }, { WAIT_IDLE },
1261{ 0xc, 0x40 }, { WAIT_IDLE },
1262{ 0xc, 0x00 }, { WAIT_IDLE },
1263{ 0xc, 0x00 }, { WAIT_IDLE },
1264{ 0xc, 0x00 }, { WAIT_IDLE },
1265{ 0xc, 0x40 }, { WAIT_IDLE },
1266{ 0xc, 0x00 }, { WAIT_IDLE },
1267{ 0xc, 0x00 }, { WAIT_IDLE },
1268{ 0xc, 0x00 }, { WAIT_IDLE },
1269{ 0xc, 0x40 }, { WAIT_IDLE },
1270{ 0xc, 0x00 }, { WAIT_IDLE },
1271{ 0xc, 0x00 }, { WAIT_IDLE },
1272{ 0xc, 0x00 }, { WAIT_IDLE },
1273{ 0xc, 0x42 }, { WAIT_IDLE },
1274{ 0xc, 0x00 }, { WAIT_IDLE },
1275{ 0xc, 0x40 }, { WAIT_IDLE },
1276{ 0xc, 0x00 }, { WAIT_IDLE },
1277{ 0xc, 0x42 }, { WAIT_IDLE },
1278{ 0xc, 0x00 }, { WAIT_IDLE },
1279{ 0xc, 0x02 }, { WAIT_IDLE },
1280{ 0xc, 0x00 }, { WAIT_IDLE },
1281{ 0xc, 0x02 }, { WAIT_IDLE },
1282{ 0xc, 0x00 }, { WAIT_IDLE },
1283{ 0xc, 0x02 }, { WAIT_IDLE },
1284{ 0xc, 0x00 }, { WAIT_IDLE },
1285{ 0xc, 0x42 }, { WAIT_IDLE },
1286{ 0xc, 0x00 }, { WAIT_IDLE },
1287{ 0xc, 0xc0 }, { WAIT_IDLE },
1288{ 0xc, 0x00 }, { WAIT_IDLE },
1289{ 0xc, 0x40 }, { WAIT_IDLE },
1290
1291{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x00 },
1292
1293{ 0xc, 0x63 }, { WAIT_IDLE },
1294{ 0xc, 0x03 }, { WAIT_IDLE },
1295{ 0xc, 0x26 }, { WAIT_IDLE },
1296{ 0xc, 0x02 }, { WAIT_IDLE },
1297{ 0xc, 0x2c }, { WAIT_IDLE },
1298{ 0xc, 0x00 }, { WAIT_IDLE },
1299{ 0xc, 0x24 }, { WAIT_IDLE },
1300{ 0xc, 0x00 }, { WAIT_IDLE },
1301{ 0xc, 0x2e }, { WAIT_IDLE },
1302{ 0xc, 0x02 }, { WAIT_IDLE },
1303{ 0xc, 0x02 }, { WAIT_IDLE },
1304{ 0xc, 0x02 }, { WAIT_IDLE },
1305{ 0xc, 0x00 }, { WAIT_IDLE },
1306{ 0xc, 0x00 }, { WAIT_IDLE },
1307{ 0xc, 0x00 }, { WAIT_IDLE },
1308{ 0xc, 0x00 }, { WAIT_IDLE },
1309{ 0xc, 0x00 }, { WAIT_IDLE },
1310{ 0xc, 0x00 }, { WAIT_IDLE },
1311{ 0xc, 0x00 }, { WAIT_IDLE },
1312{ 0xc, 0x00 }, { WAIT_IDLE },
1313{ 0xc, 0x00 }, { WAIT_IDLE },
1314{ 0xc, 0x00 }, { WAIT_IDLE },
1315{ 0xc, 0x00 }, { WAIT_IDLE },
1316{ 0xc, 0x00 }, { WAIT_IDLE },
1317{ 0xc, 0x00 }, { WAIT_IDLE },
1318{ 0xc, 0x00 }, { WAIT_IDLE },
1319{ 0xc, 0x00 }, { WAIT_IDLE },
1320{ 0xc, 0x00 }, { WAIT_IDLE },
1321{ 0xc, 0x00 }, { WAIT_IDLE },
1322{ 0xc, 0x00 }, { WAIT_IDLE },
1323{ 0xc, 0x00 }, { WAIT_IDLE },
1324{ 0xc, 0x00 }, { WAIT_IDLE },
1325{ 0xc, 0x00 }, { WAIT_IDLE },
1326{ 0xc, 0x00 }, { WAIT_IDLE },
1327{ 0xc, 0x00 }, { WAIT_IDLE },
1328{ 0xc, 0x00 }, { WAIT_IDLE },
1329{ 0xc, 0x00 }, { WAIT_IDLE },
1330{ 0xc, 0x00 }, { WAIT_IDLE },
1331{ 0xc, 0x00 }, { WAIT_IDLE },
1332{ 0xc, 0x00 }, { WAIT_IDLE },
1333{ 0xc, 0x00 }, { WAIT_IDLE },
1334{ 0xc, 0x00 }, { WAIT_IDLE },
1335{ 0xc, 0x00 }, { WAIT_IDLE },
1336{ 0xc, 0x00 }, { WAIT_IDLE },
1337{ 0xc, 0x00 }, { WAIT_IDLE },
1338{ 0xc, 0x00 }, { WAIT_IDLE },
1339{ 0xc, 0x00 }, { WAIT_IDLE },
1340{ 0xc, 0x00 }, { WAIT_IDLE },
1341{ 0xc, 0x00 }, { WAIT_IDLE },
1342{ 0xc, 0x00 }, { WAIT_IDLE },
1343{ 0xc, 0x00 }, { WAIT_IDLE },
1344{ 0xc, 0x00 }, { WAIT_IDLE },
1345{ 0xc, 0x00 }, { WAIT_IDLE },
1346{ 0xc, 0x00 }, { WAIT_IDLE },
1347{ 0xc, 0x00 }, { WAIT_IDLE },
1348{ 0xc, 0x00 }, { WAIT_IDLE },
1349{ 0xc, 0x00 }, { WAIT_IDLE },
1350{ 0xc, 0x00 }, { WAIT_IDLE },
1351{ 0xc, 0x00 }, { WAIT_IDLE },
1352{ 0xc, 0x00 }, { WAIT_IDLE },
1353{ 0xc, 0x00 }, { WAIT_IDLE },
1354{ 0xc, 0x00 }, { WAIT_IDLE },
1355{ 0xc, 0x00 }, { WAIT_IDLE },
1356{ 0xc, 0x00 }, { WAIT_IDLE },
1357{ 0xc, 0x00 }, { WAIT_IDLE },
1358{ 0xc, 0x01 }, { WAIT_IDLE },
1359{ 0xc, 0x20 }, { WAIT_IDLE },
1360{ 0xc, 0x00 }, { WAIT_IDLE },
1361{ 0xc, 0x60 }, { WAIT_IDLE },
1362{ 0xc, 0x00 }, { WAIT_IDLE },
1363{ 0xc, 0x20 }, { WAIT_IDLE },
1364{ 0xc, 0x00 }, { WAIT_IDLE },
1365{ 0xc, 0x20 }, { WAIT_IDLE },
1366{ 0xc, 0x00 }, { WAIT_IDLE },
1367{ 0xc, 0x20 }, { WAIT_IDLE },
1368{ 0xc, 0x00 }, { WAIT_IDLE },
1369{ 0xc, 0x20 }, { WAIT_IDLE },
1370{ 0xc, 0x00 }, { WAIT_IDLE },
1371{ 0xc, 0x20 }, { WAIT_IDLE },
1372{ 0xc, 0x00 }, { WAIT_IDLE },
1373{ 0xc, 0x20 }, { WAIT_IDLE },
1374{ 0xc, 0x00 }, { WAIT_IDLE },
1375{ 0xc, 0x20 }, { WAIT_IDLE },
1376{ 0xc, 0x00 }, { WAIT_IDLE },
1377{ 0xc, 0x20 }, { WAIT_IDLE },
1378{ 0xc, 0x00 }, { WAIT_IDLE },
1379{ 0xc, 0x60 }, { WAIT_IDLE },
1380{ 0xc, 0x00 }, { WAIT_IDLE },
1381{ 0xc, 0x20 }, { WAIT_IDLE },
1382{ 0xc, 0x00 }, { WAIT_IDLE },
1383{ 0xc, 0x60 }, { WAIT_IDLE },
1384{ 0xc, 0x00 }, { WAIT_IDLE },
1385{ 0xc, 0x20 }, { WAIT_IDLE },
1386{ 0xc, 0x00 }, { WAIT_IDLE },
1387{ 0xc, 0x60 }, { WAIT_IDLE },
1388{ 0xc, 0x00 }, { WAIT_IDLE },
1389{ 0xc, 0x20 }, { WAIT_IDLE },
1390{ 0xc, 0x00 }, { WAIT_IDLE },
1391{ 0xc, 0x60 }, { WAIT_IDLE },
1392{ 0xc, 0x00 }, { WAIT_IDLE },
1393{ 0xc, 0x20 }, { WAIT_IDLE },
1394{ 0xc, 0x00 }, { WAIT_IDLE },
1395{ 0xc, 0x60 }, { WAIT_IDLE },
1396{ 0xc, 0x00 }, { WAIT_IDLE },
1397{ 0xc, 0x20 }, { WAIT_IDLE },
1398{ 0xc, 0x00 }, { WAIT_IDLE },
1399{ 0xc, 0x60 }, { WAIT_IDLE },
1400{ 0xc, 0x00 }, { WAIT_IDLE },
1401{ 0xc, 0x20 }, { WAIT_IDLE },
1402{ 0xc, 0x00 }, { WAIT_IDLE },
1403{ 0xc, 0x20 }, { WAIT_IDLE },
1404{ 0xc, 0x00 }, { WAIT_IDLE },
1405{ 0xc, 0x22 }, { WAIT_IDLE },
1406{ 0xc, 0x02 }, { WAIT_IDLE },
1407{ 0xc, 0x22 }, { WAIT_IDLE },
1408{ 0xc, 0x02 }, { WAIT_IDLE },
1409{ 0xc, 0x20 }, { WAIT_IDLE },
1410{ 0xc, 0x00 }, { WAIT_IDLE },
1411{ 0xc, 0x60 }, { WAIT_IDLE },
1412{ 0xc, 0x00 }, { WAIT_IDLE },
1413{ 0xc, 0x22 }, { WAIT_IDLE },
1414{ 0xc, 0x02 }, { WAIT_IDLE },
1415{ 0xc, 0x62 }, { WAIT_IDLE },
1416{ 0xc, 0x02 }, { WAIT_IDLE },
1417{ 0xc, 0x20 }, { WAIT_IDLE },
1418{ 0xc, 0x01 }, { WAIT_IDLE },
1419{ 0xc, 0x21 }, { WAIT_IDLE },
1420{ 0xc, 0x01 }, { WAIT_IDLE },
1421
1422/* Load memory area (page six) */
1423{ 0x9, 0x01 }, { 0xb, 0x06 },
1424
1425{ 0xa, 0x00 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1426{ 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1427{ 0xa, 0x04 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1428{ 0xa, 0x06 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1429{ 0xa, 0x08 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1430{ 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1431{ 0xa, 0x0c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1432{ 0xa, 0x0e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1433{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1434{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1435{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1436{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1437{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1438{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1439{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1440{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1441{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1442{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1443{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1444{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1445{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1446{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1447{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1448{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1449{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1450{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1451{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1452{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1453{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1454{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1455{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1456{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1457{ 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1458{ 0xa, 0x42 }, { 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE },
1459{ 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
1460{ 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x21 }, { WAIT_IDLE },
1461{ 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x23 }, { WAIT_IDLE },
1462{ 0xa, 0x4a }, { 0xd, 0x23 }, { 0xc, 0x1b }, { WAIT_IDLE },
1463{ 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x8f }, { WAIT_IDLE },
1464{ 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x77 }, { WAIT_IDLE },
1465{ 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE },
1466{ 0xa, 0x52 }, { 0xd, 0x1c }, { 0xc, 0x92 }, { WAIT_IDLE },
1467{ 0xa, 0x54 }, { 0xd, 0x1c }, { 0xc, 0x52 }, { WAIT_IDLE },
1468{ 0xa, 0x56 }, { 0xd, 0x07 }, { 0xc, 0x00 }, { WAIT_IDLE },
1469{ 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc6 }, { WAIT_IDLE },
1470{ 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x00 }, { WAIT_IDLE },
1471{ 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x06 }, { WAIT_IDLE },
1472{ 0xa, 0x5e }, { 0xd, 0x17 }, { 0xc, 0x00 }, { WAIT_IDLE },
1473{ 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xda }, { WAIT_IDLE },
1474{ 0xa, 0x62 }, { 0xd, 0x29 }, { 0xc, 0x00 }, { WAIT_IDLE },
1475{ 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x41 }, { WAIT_IDLE },
1476{ 0xa, 0x66 }, { 0xd, 0x39 }, { 0xc, 0x00 }, { WAIT_IDLE },
1477{ 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE },
1478{ 0xa, 0x6a }, { 0xd, 0x49 }, { 0xc, 0x00 }, { WAIT_IDLE },
1479{ 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE },
1480{ 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd2 }, { WAIT_IDLE },
1481{ 0xa, 0x70 }, { 0xd, 0x16 }, { 0xc, 0x0c }, { WAIT_IDLE },
1482{ 0xa, 0x72 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1483{ 0xa, 0x74 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
1484{ 0xa, 0x76 }, { 0xd, 0x0f }, { 0xc, 0x00 }, { WAIT_IDLE },
1485{ 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE },
1486{ 0xa, 0x7a }, { 0xd, 0x13 }, { 0xc, 0x00 }, { WAIT_IDLE },
1487{ 0xa, 0x7c }, { 0xd, 0x80 }, { 0xc, 0x00 }, { WAIT_IDLE },
1488{ 0xa, 0x7e }, { 0xd, 0x80 }, { 0xc, 0x80 }, { WAIT_IDLE },
1489
1490{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x00 },
1491
1492{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1493{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1494{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
1495{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
1496{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
1497{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1498{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1499{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1500{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1501{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1502{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
1503{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE },
1504{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1505{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1506{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1507{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1508{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1509{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1510{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1511{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1512{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1513{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1514{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1515{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1516{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1517{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1518{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1519{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1520{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1521{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1522{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1523{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1524{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1525{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1526{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1527{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1528{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1529{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1530{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1531{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1532{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1533{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1534{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1535{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1536{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1537{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1538{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1539{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1540{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1541{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1542{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1543{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1544{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1545{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1546{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1547{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1548{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1549{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1550{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1551{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1552{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1553{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1554{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1555{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1556{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1557{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1558{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1559{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1560{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1561{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1562{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1563{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1564{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1565{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1566{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1567{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1568{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1569{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1570{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1571{ 0xd, 0x02 }, { 0xc, 0xe9 }, { WAIT_IDLE },
1572{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE },
1573{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE },
1574{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1575{ 0xd, 0x1a }, { 0xc, 0x75 }, { WAIT_IDLE },
1576{ 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE },
1577{ 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE },
1578{ 0xd, 0x0b }, { 0xc, 0x16 }, { WAIT_IDLE },
1579{ 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE },
1580{ 0xd, 0x0d }, { 0xc, 0xc8 }, { WAIT_IDLE },
1581{ 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE },
1582{ 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE },
1583{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1584{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
1585{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
1586{ 0xd, 0x02 }, { 0xc, 0x8f }, { WAIT_IDLE },
1587{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1588{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE },
1589{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE },
1590{ 0xd, 0x02 }, { 0xc, 0x7b }, { WAIT_IDLE },
1591{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1592{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE },
1593{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE },
1594{ 0xd, 0x02 }, { 0xc, 0x52 }, { WAIT_IDLE },
1595{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1596{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE },
1597{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE },
1598{ 0xd, 0x02 }, { 0xc, 0x19 }, { WAIT_IDLE },
1599{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1600{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1601{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1602{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1603{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1604{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1605{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1606{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE },
1607{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
1608{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
1609{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
1610{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
1611{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
1612{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
1613{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
1614{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
1615{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1616{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1617{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1618{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1619{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
1620
1621/* Now setup the MOD area. */
1622{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
1623{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1624{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
1625{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1626{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
1627{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1628{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
1629{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1630{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
1631{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1632{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
1633{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1634{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
1635{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1636{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
1637{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1638{ 0xe, 0x01 }, { 0xf, 0x08 }, { WAIT_IDLE },
1639{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1640{ 0xe, 0x01 }, { 0xf, 0x09 }, { WAIT_IDLE },
1641{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1642{ 0xe, 0x01 }, { 0xf, 0x0a }, { WAIT_IDLE },
1643{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1644{ 0xe, 0x01 }, { 0xf, 0x0b }, { WAIT_IDLE },
1645{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1646{ 0xe, 0x01 }, { 0xf, 0x0c }, { WAIT_IDLE },
1647{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1648{ 0xe, 0x01 }, { 0xf, 0x0d }, { WAIT_IDLE },
1649{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1650{ 0xe, 0x01 }, { 0xf, 0x0e }, { WAIT_IDLE },
1651{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1652{ 0xe, 0x01 }, { 0xf, 0x0f }, { WAIT_IDLE },
1653{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
1654
1655{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE },
1656{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE },
1657{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE },
1658{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE },
1659{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE },
1660{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE },
1661{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE },
1662{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE },
1663{ 0xe, 0xb8 }, { 0xf, 0x20 }, { WAIT_IDLE },
1664{ 0xe, 0xb9 }, { 0xf, 0x20 }, { WAIT_IDLE },
1665{ 0xe, 0xba }, { 0xf, 0x20 }, { WAIT_IDLE },
1666{ 0xe, 0xbb }, { 0xf, 0x20 }, { WAIT_IDLE },
1667{ 0xe, 0xbc }, { 0xf, 0x20 }, { WAIT_IDLE },
1668{ 0xe, 0xbd }, { 0xf, 0x20 }, { WAIT_IDLE },
1669{ 0xe, 0xbe }, { 0xf, 0x20 }, { WAIT_IDLE },
1670{ 0xe, 0xbf }, { 0xf, 0x20 }, { WAIT_IDLE },
1671
1672{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE },
1673{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE },
1674{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE },
1675{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE },
1676{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE },
1677{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE },
1678{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE },
1679{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE },
1680{ 0xe, 0xf8 }, { 0xf, 0x20 }, { WAIT_IDLE },
1681{ 0xe, 0xf9 }, { 0xf, 0x20 }, { WAIT_IDLE },
1682{ 0xe, 0xfa }, { 0xf, 0x20 }, { WAIT_IDLE },
1683{ 0xe, 0xfb }, { 0xf, 0x20 }, { WAIT_IDLE },
1684{ 0xe, 0xfc }, { 0xf, 0x20 }, { WAIT_IDLE },
1685{ 0xe, 0xfd }, { 0xf, 0x20 }, { WAIT_IDLE },
1686{ 0xe, 0xfe }, { 0xf, 0x20 }, { WAIT_IDLE },
1687{ 0xe, 0xff }, { 0xf, 0x20 }, { WAIT_IDLE },
1688
1689{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE },
1690{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE },
1691{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE },
1692{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE },
1693{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE },
1694{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE },
1695{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE },
1696{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE },
1697{ 0xe, 0x18 }, { 0xf, 0xff }, { WAIT_IDLE },
1698{ 0xe, 0x19 }, { 0xf, 0xff }, { WAIT_IDLE },
1699{ 0xe, 0x1a }, { 0xf, 0xff }, { WAIT_IDLE },
1700{ 0xe, 0x1b }, { 0xf, 0xff }, { WAIT_IDLE },
1701{ 0xe, 0x1c }, { 0xf, 0xff }, { WAIT_IDLE },
1702{ 0xe, 0x1d }, { 0xf, 0xff }, { WAIT_IDLE },
1703{ 0xe, 0x1e }, { 0xf, 0x40 }, { WAIT_IDLE },
1704{ 0xe, 0x1f }, { 0xf, 0xff }, { WAIT_IDLE },
1705{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE },
1706{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE },
1707{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE },
1708{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE },
1709{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE },
1710{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE },
1711{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE },
1712{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE },
1713{ 0xe, 0x28 }, { 0xf, 0xff }, { WAIT_IDLE },
1714{ 0xe, 0x29 }, { 0xf, 0xff }, { WAIT_IDLE },
1715{ 0xe, 0x2a }, { 0xf, 0xff }, { WAIT_IDLE },
1716{ 0xe, 0x2b }, { 0xf, 0xff }, { WAIT_IDLE },
1717{ 0xe, 0x2c }, { 0xf, 0xff }, { WAIT_IDLE },
1718{ 0xe, 0x2d }, { 0xf, 0xff }, { WAIT_IDLE },
1719{ 0xe, 0x2e }, { 0xf, 0x00 }, { WAIT_IDLE },
1720{ 0xe, 0x2f }, { 0xf, 0x00 }, { WAIT_IDLE },
1721{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE },
1722{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE },
1723{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE },
1724{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE },
1725{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE },
1726{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE },
1727{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE },
1728{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE },
1729{ 0xe, 0x38 }, { 0xf, 0x00 }, { WAIT_IDLE },
1730{ 0xe, 0x39 }, { 0xf, 0x00 }, { WAIT_IDLE },
1731{ 0xe, 0x3a }, { 0xf, 0x00 }, { WAIT_IDLE },
1732{ 0xe, 0x3b }, { 0xf, 0x00 }, { WAIT_IDLE },
1733{ 0xe, 0x3c }, { 0xf, 0x00 }, { WAIT_IDLE },
1734{ 0xe, 0x3d }, { 0xf, 0x00 }, { WAIT_IDLE },
1735{ 0xe, 0x3e }, { 0xf, 0x00 }, { WAIT_IDLE },
1736{ 0xe, 0x3f }, { 0xf, 0x20 }, { WAIT_IDLE },
1737{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE },
1738{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE },
1739{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE },
1740{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE },
1741{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE },
1742{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE },
1743{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE },
1744{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE },
1745{ 0xe, 0x48 }, { 0xf, 0x00 }, { WAIT_IDLE },
1746{ 0xe, 0x49 }, { 0xf, 0x00 }, { WAIT_IDLE },
1747{ 0xe, 0x4a }, { 0xf, 0x00 }, { WAIT_IDLE },
1748{ 0xe, 0x4b }, { 0xf, 0x00 }, { WAIT_IDLE },
1749{ 0xe, 0x4c }, { 0xf, 0x00 }, { WAIT_IDLE },
1750{ 0xe, 0x4d }, { 0xf, 0x00 }, { WAIT_IDLE },
1751{ 0xe, 0x4e }, { 0xf, 0x0e }, { WAIT_IDLE },
1752{ 0xe, 0x4f }, { 0xf, 0x0e }, { WAIT_IDLE },
1753{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE },
1754{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE },
1755{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE },
1756{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE },
1757{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE },
1758{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE },
1759{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE },
1760{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE },
1761{ 0xe, 0x58 }, { 0xf, 0x00 }, { WAIT_IDLE },
1762{ 0xe, 0x59 }, { 0xf, 0x00 }, { WAIT_IDLE },
1763{ 0xe, 0x5a }, { 0xf, 0x00 }, { WAIT_IDLE },
1764{ 0xe, 0x5b }, { 0xf, 0x00 }, { WAIT_IDLE },
1765{ 0xe, 0x5c }, { 0xf, 0x00 }, { WAIT_IDLE },
1766{ 0xe, 0x5d }, { 0xf, 0x00 }, { WAIT_IDLE },
1767{ 0xe, 0x5e }, { 0xf, 0x00 }, { WAIT_IDLE },
1768{ 0xe, 0x5f }, { 0xf, 0x00 }, { WAIT_IDLE },
1769{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE },
1770{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE },
1771{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE },
1772{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE },
1773{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE },
1774{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE },
1775{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE },
1776{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE },
1777{ 0xe, 0x68 }, { 0xf, 0x00 }, { WAIT_IDLE },
1778{ 0xe, 0x69 }, { 0xf, 0x00 }, { WAIT_IDLE },
1779{ 0xe, 0x6a }, { 0xf, 0x00 }, { WAIT_IDLE },
1780{ 0xe, 0x6b }, { 0xf, 0x00 }, { WAIT_IDLE },
1781{ 0xe, 0x6c }, { 0xf, 0x40 }, { WAIT_IDLE },
1782{ 0xe, 0x6d }, { 0xf, 0x00 }, { WAIT_IDLE },
1783{ 0xe, 0x6e }, { 0xf, 0x40 }, { WAIT_IDLE },
1784{ 0xe, 0x6f }, { 0xf, 0x40 }, { WAIT_IDLE },
1785{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1786{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1787{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1788{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1789{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1790{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1791{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1792{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1793{ 0xe, 0x78 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1794{ 0xe, 0x79 }, { 0xf, 0xc0 }, { WAIT_IDLE },
1795{ 0xe, 0x7a }, { 0xf, 0xc0 }, { WAIT_IDLE },
1796{ 0xe, 0x7b }, { 0xf, 0xc0 }, { WAIT_IDLE },
1797{ 0xe, 0x7c }, { 0xf, 0xc0 }, { WAIT_IDLE },
1798{ 0xe, 0x7d }, { 0xf, 0xc0 }, { WAIT_IDLE },
1799{ 0xe, 0x7e }, { 0xf, 0xc0 }, { WAIT_IDLE },
1800{ 0xe, 0x7f }, { 0xf, 0xc0 }, { WAIT_IDLE },
1801{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE },
1802{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE },
1803{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE },
1804{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE },
1805{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE },
1806{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE },
1807{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE },
1808{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE },
1809{ 0xe, 0x88 }, { 0xf, 0x00 }, { WAIT_IDLE },
1810{ 0xe, 0x89 }, { 0xf, 0x00 }, { WAIT_IDLE },
1811{ 0xe, 0x8a }, { 0xf, 0x00 }, { WAIT_IDLE },
1812{ 0xe, 0x8b }, { 0xf, 0x00 }, { WAIT_IDLE },
1813{ 0xe, 0x8c }, { 0xf, 0x00 }, { WAIT_IDLE },
1814{ 0xe, 0x8d }, { 0xf, 0x00 }, { WAIT_IDLE },
1815{ 0xe, 0x8e }, { 0xf, 0x00 }, { WAIT_IDLE },
1816{ 0xe, 0x8f }, { 0xf, 0x00 }, { WAIT_IDLE },
1817{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE },
1818{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE },
1819{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE },
1820{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE },
1821{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE },
1822{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE },
1823{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE },
1824{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE },
1825{ 0xe, 0x98 }, { 0xf, 0x00 }, { WAIT_IDLE },
1826{ 0xe, 0x99 }, { 0xf, 0x00 }, { WAIT_IDLE },
1827{ 0xe, 0x9a }, { 0xf, 0x00 }, { WAIT_IDLE },
1828{ 0xe, 0x9b }, { 0xf, 0x00 }, { WAIT_IDLE },
1829{ 0xe, 0x9c }, { 0xf, 0x00 }, { WAIT_IDLE },
1830{ 0xe, 0x9d }, { 0xf, 0x00 }, { WAIT_IDLE },
1831{ 0xe, 0x9e }, { 0xf, 0x00 }, { WAIT_IDLE },
1832{ 0xe, 0x9f }, { 0xf, 0x00 }, { WAIT_IDLE },
1833{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE },
1834{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE },
1835{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE },
1836{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE },
1837{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE },
1838{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE },
1839{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE },
1840{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE },
1841{ 0xe, 0xa8 }, { 0xf, 0x00 }, { WAIT_IDLE },
1842{ 0xe, 0xa9 }, { 0xf, 0x00 }, { WAIT_IDLE },
1843{ 0xe, 0xaa }, { 0xf, 0x00 }, { WAIT_IDLE },
1844{ 0xe, 0xab }, { 0xf, 0x00 }, { WAIT_IDLE },
1845{ 0xe, 0xac }, { 0xf, 0x00 }, { WAIT_IDLE },
1846{ 0xe, 0xad }, { 0xf, 0x00 }, { WAIT_IDLE },
1847{ 0xe, 0xae }, { 0xf, 0x00 }, { WAIT_IDLE },
1848{ 0xe, 0xaf }, { 0xf, 0x00 }, { WAIT_IDLE },
1849
1850{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE },
1851{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE },
1852{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE },
1853{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE },
1854{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE },
1855{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE },
1856{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE },
1857{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE },
1858{ 0xe, 0xc8 }, { 0xf, 0x00 }, { WAIT_IDLE },
1859{ 0xe, 0xc9 }, { 0xf, 0x00 }, { WAIT_IDLE },
1860{ 0xe, 0xca }, { 0xf, 0x00 }, { WAIT_IDLE },
1861{ 0xe, 0xcb }, { 0xf, 0x00 }, { WAIT_IDLE },
1862{ 0xe, 0xcc }, { 0xf, 0x00 }, { WAIT_IDLE },
1863{ 0xe, 0xcd }, { 0xf, 0x00 }, { WAIT_IDLE },
1864{ 0xe, 0xce }, { 0xf, 0x00 }, { WAIT_IDLE },
1865{ 0xe, 0xcf }, { 0xf, 0x00 }, { WAIT_IDLE },
1866{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE },
1867{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE },
1868{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE },
1869{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE },
1870{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE },
1871{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE },
1872{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE },
1873{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE },
1874{ 0xe, 0xd8 }, { 0xf, 0x00 }, { WAIT_IDLE },
1875{ 0xe, 0xd9 }, { 0xf, 0x00 }, { WAIT_IDLE },
1876{ 0xe, 0xda }, { 0xf, 0x00 }, { WAIT_IDLE },
1877{ 0xe, 0xdb }, { 0xf, 0x00 }, { WAIT_IDLE },
1878{ 0xe, 0xdc }, { 0xf, 0x00 }, { WAIT_IDLE },
1879{ 0xe, 0xdd }, { 0xf, 0x00 }, { WAIT_IDLE },
1880{ 0xe, 0xde }, { 0xf, 0x10 }, { WAIT_IDLE },
1881{ 0xe, 0xdf }, { 0xf, 0x10 }, { WAIT_IDLE },
1882{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE },
1883{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE },
1884{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE },
1885{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE },
1886{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE },
1887{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE },
1888{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE },
1889{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE },
1890{ 0xe, 0xe8 }, { 0xf, 0x00 }, { WAIT_IDLE },
1891{ 0xe, 0xe9 }, { 0xf, 0x00 }, { WAIT_IDLE },
1892{ 0xe, 0xea }, { 0xf, 0x00 }, { WAIT_IDLE },
1893{ 0xe, 0xeb }, { 0xf, 0x00 }, { WAIT_IDLE },
1894{ 0xe, 0xec }, { 0xf, 0x00 }, { WAIT_IDLE },
1895{ 0xe, 0xed }, { 0xf, 0x00 }, { WAIT_IDLE },
1896{ 0xe, 0xee }, { 0xf, 0x00 }, { WAIT_IDLE },
1897{ 0xe, 0xef }, { 0xf, 0x00 }, { WAIT_IDLE },
1898
1899{ 0xe, 0x01 }, { 0xf, 0x00 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1900{ 0xe, 0x01 }, { 0xf, 0x01 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1901{ 0xe, 0x01 }, { 0xf, 0x02 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1902{ 0xe, 0x01 }, { 0xf, 0x03 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1903{ 0xe, 0x01 }, { 0xf, 0x04 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1904{ 0xe, 0x01 }, { 0xf, 0x05 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1905{ 0xe, 0x01 }, { 0xf, 0x06 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1906{ 0xe, 0x01 }, { 0xf, 0x07 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1907{ 0xe, 0x01 }, { 0xf, 0x08 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1908{ 0xe, 0x01 }, { 0xf, 0x09 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1909{ 0xe, 0x01 }, { 0xf, 0x0a }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1910{ 0xe, 0x01 }, { 0xf, 0x0b }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1911{ 0xe, 0x01 }, { 0xf, 0x0c }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1912{ 0xe, 0x01 }, { 0xf, 0x0d }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1913{ 0xe, 0x01 }, { 0xf, 0x0e }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1914{ 0xe, 0x01 }, { 0xf, 0x0f }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
1915
1916/* mute on */
1917{ 0x8, 0x02 },
1918
1919/* Now set the coefficients and so forth for the programs above */
1920{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1921{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1922{ 0xb, 0x00 }, { 0xa, 0x4b }, { 0xd, 0x03 }, { 0xc, 0x11 }, { WAIT_IDLE },
1923{ 0xb, 0x00 }, { 0xa, 0x4d }, { 0xd, 0x01 }, { 0xc, 0x32 }, { WAIT_IDLE },
1924{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1925{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1926{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1927{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1928{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
1929{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
1930{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1931{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1932{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1933{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1934{ 0xb, 0x00 }, { 0xa, 0x47 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
1935{ 0xb, 0x00 }, { 0xa, 0x4a }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
1936{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1937{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1938{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1939{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1940{ 0xb, 0x00 }, { 0xa, 0x00 }, { 0xd, 0x01 }, { 0xc, 0x1c }, { WAIT_IDLE },
1941{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1942{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1943{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1944{ 0xb, 0x00 }, { 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE },
1945{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1946{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1947{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1948{ 0xb, 0x00 }, { 0xa, 0x42 }, { 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE },
1949{ 0xb, 0x00 }, { 0xa, 0x43 }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE },
1950{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1951{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1952{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1953{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1954{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE },
1955{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE },
1956{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1957{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1958{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
1959{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1960{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1961{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1962{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
1963{ 0xb, 0x07 }, { 0xa, 0x51 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
1964{ 0xb, 0x07 }, { 0xa, 0x50 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE },
1965{ 0xb, 0x07 }, { 0xa, 0x4f }, { 0xd, 0x03 }, { 0xc, 0x81 }, { WAIT_IDLE },
1966{ 0xb, 0x07 }, { 0xa, 0x53 }, { 0xd, 0x1a }, { 0xc, 0x76 }, { WAIT_IDLE },
1967{ 0xb, 0x07 }, { 0xa, 0x54 }, { 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE },
1968{ 0xb, 0x07 }, { 0xa, 0x55 }, { 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE },
1969{ 0xb, 0x07 }, { 0xa, 0x56 }, { 0xd, 0x0b }, { 0xc, 0x17 }, { WAIT_IDLE },
1970{ 0xb, 0x07 }, { 0xa, 0x57 }, { 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE },
1971{ 0xb, 0x07 }, { 0xa, 0x58 }, { 0xd, 0x0d }, { 0xc, 0xc9 }, { WAIT_IDLE },
1972{ 0xb, 0x07 }, { 0xa, 0x59 }, { 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE },
1973{ 0xb, 0x07 }, { 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE },
1974{ 0xb, 0x07 }, { 0xa, 0x73 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
1975{ 0xb, 0x07 }, { 0xa, 0x74 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
1976{ 0xb, 0x07 }, { 0xa, 0x75 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE },
1977{ 0xb, 0x07 }, { 0xa, 0x76 }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
1978{ 0xb, 0x07 }, { 0xa, 0x77 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE },
1979{ 0xb, 0x07 }, { 0xa, 0x78 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE },
1980{ 0xb, 0x07 }, { 0xa, 0x79 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE },
1981{ 0xb, 0x07 }, { 0xa, 0x7a }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE },
1982{ 0xb, 0x07 }, { 0xa, 0x5e }, { 0xd, 0x03 }, { 0xc, 0x68 }, { WAIT_IDLE },
1983{ 0xb, 0x07 }, { 0xa, 0x5c }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE },
1984{ 0xb, 0x07 }, { 0xa, 0x5d }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE },
1985{ 0xb, 0x07 }, { 0xa, 0x62 }, { 0xd, 0x03 }, { 0xc, 0x52 }, { WAIT_IDLE },
1986{ 0xb, 0x07 }, { 0xa, 0x60 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE },
1987{ 0xb, 0x07 }, { 0xa, 0x61 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE },
1988{ 0xb, 0x07 }, { 0xa, 0x66 }, { 0xd, 0x03 }, { 0xc, 0x2e }, { WAIT_IDLE },
1989{ 0xb, 0x07 }, { 0xa, 0x64 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
1990{ 0xb, 0x07 }, { 0xa, 0x65 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE },
1991{ 0xb, 0x07 }, { 0xa, 0x6a }, { 0xd, 0x02 }, { 0xc, 0xf6 }, { WAIT_IDLE },
1992{ 0xb, 0x07 }, { 0xa, 0x68 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE },
1993{ 0xb, 0x07 }, { 0xa, 0x69 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE },
1994{ 0xb, 0x06 }, { 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x22 }, { WAIT_IDLE },
1995{ 0xb, 0x06 }, { 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x24 }, { WAIT_IDLE },
1996{ 0xb, 0x06 }, { 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd3 }, { WAIT_IDLE },
1997{ 0xb, 0x06 }, { 0xa, 0x70 }, { 0xd, 0x15 }, { 0xc, 0xcb }, { WAIT_IDLE },
1998{ 0xb, 0x06 }, { 0xa, 0x52 }, { 0xd, 0x20 }, { 0xc, 0x93 }, { WAIT_IDLE },
1999{ 0xb, 0x06 }, { 0xa, 0x54 }, { 0xd, 0x20 }, { 0xc, 0x54 }, { WAIT_IDLE },
2000{ 0xb, 0x06 }, { 0xa, 0x4a }, { 0xd, 0x27 }, { 0xc, 0x1d }, { WAIT_IDLE },
2001{ 0xb, 0x06 }, { 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc8 }, { WAIT_IDLE },
2002{ 0xb, 0x06 }, { 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x07 }, { WAIT_IDLE },
2003{ 0xb, 0x06 }, { 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x90 }, { WAIT_IDLE },
2004{ 0xb, 0x06 }, { 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xdb }, { WAIT_IDLE },
2005{ 0xb, 0x06 }, { 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x42 }, { WAIT_IDLE },
2006{ 0xb, 0x06 }, { 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x78 }, { WAIT_IDLE },
2007{ 0xb, 0x06 }, { 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE },
2008{ 0xb, 0x06 }, { 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE },
2009{ 0xb, 0x06 }, { 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE },
2010{ 0xb, 0x06 }, { 0xa, 0x42 }, { 0xd, 0x02 }, { 0xc, 0xba }, { WAIT_IDLE },
2011
2012/* Some settings (?) */
2013{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x14 },
2014{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x20 },
2015{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x20 },
2016
2017/* some more coefficients */
2018{ WAIT_IDLE }, { 0xb, 0x06 }, { 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x40 },
2019{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x03 }, { 0xd, 0x0f }, { 0xc, 0xff },
2020{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0b }, { 0xd, 0x0f }, { 0xc, 0xff },
2021{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 },
2022{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 },
2023{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 },
2024{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 },
2025
2026/* Now, for some strange reason, lets reload every page
2027 and all the coefficients over again. I have *NO* idea
2028 why this is done. I do know that no sound is produced
2029 is this phase is omitted. */
2030{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x10 },
2031
2032{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2033{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2034{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE },
2035{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2036{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2037{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2038{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2039{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2040{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2041{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2042{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2043{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2044{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2045{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2046{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2047{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2048{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2049{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2050{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2051{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2052{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2053{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2054{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2055{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2056{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2057{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2058{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2059{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2060{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2061{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2062{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2063{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2064{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2065{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2066{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2067{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2068{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2069{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2070{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2071{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2072{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2073{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2074{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2075{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2076{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2077{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2078{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2079{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2080
2081{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x10 },
2082
2083{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE },
2084{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE },
2085{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE },
2086{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2087{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2088{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2089{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2090{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2091{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2092{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2093{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2094{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2095{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2096{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2097{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2098{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2099{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2100{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2101{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2102{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2103{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2104{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2105{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2106{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2107{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2108{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2109{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2110{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2111{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2112{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2113{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2114{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2115{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2116{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2117{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2118{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2119{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2120{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2121{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2122{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2123{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2124{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2125{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2126{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2127{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2128{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2129{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2130{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2131
2132{ WAIT_IDLE }, { WAIT_IDLE },
2133
2134{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x10 },
2135
2136{ 0xc, 0x46 }, { WAIT_IDLE },
2137{ 0xc, 0x46 }, { WAIT_IDLE },
2138{ 0xc, 0x00 }, { WAIT_IDLE },
2139{ 0xc, 0x00 }, { WAIT_IDLE },
2140{ 0xc, 0x00 }, { WAIT_IDLE },
2141{ 0xc, 0x00 }, { WAIT_IDLE },
2142{ 0xc, 0x00 }, { WAIT_IDLE },
2143{ 0xc, 0x00 }, { WAIT_IDLE },
2144{ 0xc, 0x00 }, { WAIT_IDLE },
2145{ 0xc, 0x00 }, { WAIT_IDLE },
2146{ 0xc, 0x00 }, { WAIT_IDLE },
2147{ 0xc, 0x00 }, { WAIT_IDLE },
2148{ 0xc, 0x00 }, { WAIT_IDLE },
2149{ 0xc, 0x00 }, { WAIT_IDLE },
2150{ 0xc, 0x00 }, { WAIT_IDLE },
2151{ 0xc, 0x00 }, { WAIT_IDLE },
2152{ 0xc, 0x00 }, { WAIT_IDLE },
2153{ 0xc, 0x00 }, { WAIT_IDLE },
2154{ 0xc, 0x00 }, { WAIT_IDLE },
2155{ 0xc, 0x00 }, { WAIT_IDLE },
2156{ 0xc, 0x00 }, { WAIT_IDLE },
2157{ 0xc, 0x00 }, { WAIT_IDLE },
2158{ 0xc, 0x00 }, { WAIT_IDLE },
2159{ 0xc, 0x00 }, { WAIT_IDLE },
2160{ 0xc, 0x00 }, { WAIT_IDLE },
2161{ 0xc, 0x00 }, { WAIT_IDLE },
2162{ 0xc, 0x00 }, { WAIT_IDLE },
2163{ 0xc, 0x00 }, { WAIT_IDLE },
2164{ 0xc, 0x00 }, { WAIT_IDLE },
2165{ 0xc, 0x00 }, { WAIT_IDLE },
2166{ 0xc, 0x00 }, { WAIT_IDLE },
2167{ 0xc, 0x00 }, { WAIT_IDLE },
2168{ 0xc, 0x00 }, { WAIT_IDLE },
2169{ 0xc, 0x00 }, { WAIT_IDLE },
2170{ 0xc, 0x00 }, { WAIT_IDLE },
2171{ 0xc, 0x00 }, { WAIT_IDLE },
2172{ 0xc, 0x00 }, { WAIT_IDLE },
2173{ 0xc, 0x00 }, { WAIT_IDLE },
2174{ 0xc, 0x00 }, { WAIT_IDLE },
2175{ 0xc, 0x00 }, { WAIT_IDLE },
2176{ 0xc, 0x00 }, { WAIT_IDLE },
2177{ 0xc, 0x00 }, { WAIT_IDLE },
2178{ 0xc, 0x00 }, { WAIT_IDLE },
2179{ 0xc, 0x00 }, { WAIT_IDLE },
2180{ 0xc, 0x00 }, { WAIT_IDLE },
2181{ 0xc, 0x00 }, { WAIT_IDLE },
2182{ 0xc, 0x00 }, { WAIT_IDLE },
2183{ 0xc, 0x00 }, { WAIT_IDLE },
2184
2185{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x10 },
2186
2187{ 0xc, 0x00 }, { WAIT_IDLE },
2188{ 0xc, 0x00 }, { WAIT_IDLE },
2189{ 0xc, 0x00 }, { WAIT_IDLE },
2190{ 0xc, 0x00 }, { WAIT_IDLE },
2191{ 0xc, 0x00 }, { WAIT_IDLE },
2192{ 0xc, 0x00 }, { WAIT_IDLE },
2193{ 0xc, 0x00 }, { WAIT_IDLE },
2194{ 0xc, 0x00 }, { WAIT_IDLE },
2195{ 0xc, 0x00 }, { WAIT_IDLE },
2196{ 0xc, 0x00 }, { WAIT_IDLE },
2197{ 0xc, 0x00 }, { WAIT_IDLE },
2198{ 0xc, 0x00 }, { WAIT_IDLE },
2199{ 0xc, 0x00 }, { WAIT_IDLE },
2200{ 0xc, 0x00 }, { WAIT_IDLE },
2201{ 0xc, 0x00 }, { WAIT_IDLE },
2202{ 0xc, 0x00 }, { WAIT_IDLE },
2203{ 0xc, 0x00 }, { WAIT_IDLE },
2204{ 0xc, 0x00 }, { WAIT_IDLE },
2205{ 0xc, 0x00 }, { WAIT_IDLE },
2206{ 0xc, 0x00 }, { WAIT_IDLE },
2207{ 0xc, 0x00 }, { WAIT_IDLE },
2208{ 0xc, 0x00 }, { WAIT_IDLE },
2209{ 0xc, 0x00 }, { WAIT_IDLE },
2210{ 0xc, 0x00 }, { WAIT_IDLE },
2211{ 0xc, 0x00 }, { WAIT_IDLE },
2212{ 0xc, 0x00 }, { WAIT_IDLE },
2213{ 0xc, 0x00 }, { WAIT_IDLE },
2214{ 0xc, 0x00 }, { WAIT_IDLE },
2215{ 0xc, 0x00 }, { WAIT_IDLE },
2216{ 0xc, 0x00 }, { WAIT_IDLE },
2217{ 0xc, 0x00 }, { WAIT_IDLE },
2218{ 0xc, 0x00 }, { WAIT_IDLE },
2219{ 0xc, 0x00 }, { WAIT_IDLE },
2220{ 0xc, 0x00 }, { WAIT_IDLE },
2221{ 0xc, 0x00 }, { WAIT_IDLE },
2222{ 0xc, 0x00 }, { WAIT_IDLE },
2223{ 0xc, 0x00 }, { WAIT_IDLE },
2224{ 0xc, 0x00 }, { WAIT_IDLE },
2225{ 0xc, 0x00 }, { WAIT_IDLE },
2226{ 0xc, 0x00 }, { WAIT_IDLE },
2227{ 0xc, 0x00 }, { WAIT_IDLE },
2228{ 0xc, 0x00 }, { WAIT_IDLE },
2229{ 0xc, 0x00 }, { WAIT_IDLE },
2230{ 0xc, 0x00 }, { WAIT_IDLE },
2231{ 0xc, 0x00 }, { WAIT_IDLE },
2232{ 0xc, 0x00 }, { WAIT_IDLE },
2233{ 0xc, 0x00 }, { WAIT_IDLE },
2234{ 0xc, 0x00 }, { WAIT_IDLE },
2235
2236{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x10 },
2237
2238{ 0xc, 0x00 }, { WAIT_IDLE },
2239{ 0xc, 0x00 }, { WAIT_IDLE },
2240{ 0xc, 0x00 }, { WAIT_IDLE },
2241{ 0xc, 0x00 }, { WAIT_IDLE },
2242{ 0xc, 0x00 }, { WAIT_IDLE },
2243{ 0xc, 0x00 }, { WAIT_IDLE },
2244{ 0xc, 0x00 }, { WAIT_IDLE },
2245{ 0xc, 0x00 }, { WAIT_IDLE },
2246{ 0xc, 0x00 }, { WAIT_IDLE },
2247{ 0xc, 0x00 }, { WAIT_IDLE },
2248{ 0xc, 0x00 }, { WAIT_IDLE },
2249{ 0xc, 0x00 }, { WAIT_IDLE },
2250{ 0xc, 0x00 }, { WAIT_IDLE },
2251{ 0xc, 0x00 }, { WAIT_IDLE },
2252{ 0xc, 0x00 }, { WAIT_IDLE },
2253{ 0xc, 0x00 }, { WAIT_IDLE },
2254{ 0xc, 0x00 }, { WAIT_IDLE },
2255{ 0xc, 0x00 }, { WAIT_IDLE },
2256{ 0xc, 0x00 }, { WAIT_IDLE },
2257{ 0xc, 0x00 }, { WAIT_IDLE },
2258{ 0xc, 0x00 }, { WAIT_IDLE },
2259{ 0xc, 0x00 }, { WAIT_IDLE },
2260{ 0xc, 0x00 }, { WAIT_IDLE },
2261{ 0xc, 0x00 }, { WAIT_IDLE },
2262{ 0xc, 0x00 }, { WAIT_IDLE },
2263{ 0xc, 0x00 }, { WAIT_IDLE },
2264{ 0xc, 0x00 }, { WAIT_IDLE },
2265{ 0xc, 0x00 }, { WAIT_IDLE },
2266{ 0xc, 0x00 }, { WAIT_IDLE },
2267{ 0xc, 0x00 }, { WAIT_IDLE },
2268{ 0xc, 0x00 }, { WAIT_IDLE },
2269{ 0xc, 0x00 }, { WAIT_IDLE },
2270{ 0xc, 0x00 }, { WAIT_IDLE },
2271{ 0xc, 0x00 }, { WAIT_IDLE },
2272{ 0xc, 0x00 }, { WAIT_IDLE },
2273{ 0xc, 0x00 }, { WAIT_IDLE },
2274{ 0xc, 0x00 }, { WAIT_IDLE },
2275{ 0xc, 0x00 }, { WAIT_IDLE },
2276{ 0xc, 0x00 }, { WAIT_IDLE },
2277{ 0xc, 0x00 }, { WAIT_IDLE },
2278{ 0xc, 0x00 }, { WAIT_IDLE },
2279{ 0xc, 0x00 }, { WAIT_IDLE },
2280{ 0xc, 0x00 }, { WAIT_IDLE },
2281{ 0xc, 0x00 }, { WAIT_IDLE },
2282{ 0xc, 0x00 }, { WAIT_IDLE },
2283{ 0xc, 0x00 }, { WAIT_IDLE },
2284{ 0xc, 0x00 }, { WAIT_IDLE },
2285{ 0xc, 0x00 }, { WAIT_IDLE },
2286
2287/* Page six v.2 */
2288{ 0x9, 0x01 }, { 0xb, 0x06 },
2289
2290{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2291{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2292{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2293{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2294{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2295{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2296{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2297{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2298{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2299{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2300{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2301{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2302{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2303{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2304{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2305{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2306{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2307{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2308{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2309{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2310{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2311{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2312{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2313{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2314
2315{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x10 },
2316
2317{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
2318{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
2319{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2320{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2321{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2322{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2323{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2324{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2325{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2326{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2327{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2328{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2329{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2330{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2331{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2332{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2333{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2334{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2335{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2336{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2337{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2338{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2339{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2340{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2341{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2342{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2343{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2344{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2345{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2346{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2347{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2348{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2349{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2350{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2351{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2352{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2353{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2354{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2355{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2356{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2357{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2358{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2359{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2360{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2361{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2362{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2363{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2364{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2365
2366{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
2367{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2368{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
2369{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2370{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
2371{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2372{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
2373{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2374{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
2375{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2376{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
2377{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2378{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
2379{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2380{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
2381{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE },
2382{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE },
2383{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE },
2384{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE },
2385{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE },
2386{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE },
2387{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE },
2388{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE },
2389{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE },
2390{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE },
2391{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE },
2392{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE },
2393{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE },
2394{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE },
2395{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE },
2396{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE },
2397{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE },
2398{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE },
2399{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE },
2400{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE },
2401{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE },
2402{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE },
2403{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE },
2404{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE },
2405{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE },
2406{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE },
2407{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE },
2408{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE },
2409{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE },
2410{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE },
2411{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE },
2412{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE },
2413{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE },
2414{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE },
2415{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE },
2416{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE },
2417{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE },
2418{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE },
2419{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE },
2420{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE },
2421{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE },
2422{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE },
2423{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE },
2424{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE },
2425{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE },
2426{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE },
2427{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE },
2428{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE },
2429{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE },
2430{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE },
2431{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE },
2432{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE },
2433{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE },
2434{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE },
2435{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE },
2436{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE },
2437{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE },
2438{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE },
2439{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE },
2440{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE },
2441{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE },
2442{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE },
2443{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE },
2444{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE },
2445{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE },
2446{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2447{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2448{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2449{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2450{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2451{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2452{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2453{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE },
2454{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE },
2455{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE },
2456{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE },
2457{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE },
2458{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE },
2459{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE },
2460{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE },
2461{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE },
2462{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE },
2463{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE },
2464{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE },
2465{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE },
2466{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE },
2467{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE },
2468{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE },
2469{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE },
2470{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE },
2471{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE },
2472{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE },
2473{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE },
2474{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE },
2475{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE },
2476{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE },
2477{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE },
2478{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE },
2479{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE },
2480{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE },
2481{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE },
2482{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE },
2483{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE },
2484{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE },
2485{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE },
2486{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE },
2487{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE },
2488{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE },
2489{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE },
2490{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE },
2491{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE },
2492{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE },
2493{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE },
2494{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE },
2495{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE },
2496{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE },
2497{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE },
2498{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE },
2499{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE },
2500{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE },
2501{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE },
2502{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE },
2503{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2504{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE },
2505{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2506{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE },
2507{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2508{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE },
2509{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2510{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE },
2511{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2512{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE },
2513{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2514{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE },
2515{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2516{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE },
2517{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE },
2518
2519{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2520{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2521{ 0xb, 0x07 }, { 0xa, 0x45 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
2522{ 0xb, 0x07 }, { 0xa, 0x48 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE },
2523{ 0xb, 0x07 }, { 0xa, 0x7b }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE },
2524{ 0xb, 0x07 }, { 0xa, 0x7d }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE },
2525{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2526{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2527{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2528{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2529{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2530{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2531{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2532{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE },
2533
2534{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 },
2535{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 },
2536{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x28 },
2537{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x28 },
2538{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x51 },
2539{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x51 },
2540{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x7a },
2541{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x7a },
2542{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xa3 },
2543{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xa3 },
2544{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xcc },
2545{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xcc },
2546{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xf5 },
2547{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xf5 },
2548{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x1e },
2549{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x1e },
2550{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x47 },
2551{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x47 },
2552{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x70 },
2553{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x70 },
2554{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x99 },
2555{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x99 },
2556{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xc2 },
2557{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xc2 },
2558{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xeb },
2559{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xeb },
2560{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x14 },
2561{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x14 },
2562{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x3d },
2563{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x3d },
2564{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x66 },
2565{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x66 },
2566{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x8f },
2567{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x8f },
2568{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xb8 },
2569{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xb8 },
2570{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xe1 },
2571{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xe1 },
2572{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x0a },
2573{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x0a },
2574{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x33 },
2575{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x33 },
2576{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x5c },
2577{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x5c },
2578{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x85 },
2579{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x85 },
2580{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xae },
2581{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xae },
2582{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xd7 },
2583{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xd7 },
2584{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x00 },
2585{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x00 },
2586{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x28 },
2587{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x28 },
2588{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x51 },
2589{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x51 },
2590{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x7a },
2591{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x7a },
2592{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xa3 },
2593{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xa3 },
2594{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xcc },
2595{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xcc },
2596{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xf5 },
2597{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xf5 },
2598{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x1e },
2599{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x1e },
2600{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x47 },
2601{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x47 },
2602{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x70 },
2603{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x70 },
2604{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x99 },
2605{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x99 },
2606{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xc2 },
2607{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xc2 },
2608{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xeb },
2609{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xeb },
2610{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x14 },
2611{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x14 },
2612{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x3d },
2613{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x3d },
2614{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x66 },
2615{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x66 },
2616{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x8f },
2617{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x8f },
2618{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xb8 },
2619{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xb8 },
2620{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xe1 },
2621{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xe1 },
2622{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x0a },
2623{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x0a },
2624{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x33 },
2625{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x33 },
2626{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x5c },
2627{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x5c },
2628{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x85 },
2629{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x85 },
2630{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xae },
2631{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xae },
2632{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xd7 },
2633{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xd7 },
2634{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x00 },
2635{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x00 },
2636{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x28 },
2637{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x28 },
2638{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x51 },
2639{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x51 },
2640{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x7a },
2641{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x7a },
2642{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xa3 },
2643{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xa3 },
2644{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xcc },
2645{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xcc },
2646{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xf5 },
2647{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xf5 },
2648{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x1e },
2649{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x1e },
2650{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x47 },
2651{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x47 },
2652{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x70 },
2653{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x70 },
2654{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x99 },
2655{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x99 },
2656{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xc2 },
2657{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xc2 },
2658{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xeb },
2659{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xeb },
2660{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x14 },
2661{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x14 },
2662{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x3d },
2663{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x3d },
2664{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x66 },
2665{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x66 },
2666{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x8f },
2667{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x8f },
2668{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xb8 },
2669{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xb8 },
2670{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xe1 },
2671{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xe1 },
2672{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x0a },
2673{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x0a },
2674{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x33 },
2675{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x33 },
2676{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x5c },
2677{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x5c },
2678{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x85 },
2679{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x85 },
2680{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xae },
2681{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xae },
2682{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xd7 },
2683{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xd7 },
2684{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x00 },
2685{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x00 },
2686{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x28 },
2687{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x28 },
2688{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x51 },
2689{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x51 },
2690{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x7a },
2691{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x7a },
2692{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xa3 },
2693{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xa3 },
2694{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xcc },
2695{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xcc },
2696{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xf5 },
2697{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xf5 },
2698{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x1e },
2699{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x1e },
2700{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x47 },
2701{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x47 },
2702{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x70 },
2703{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x70 },
2704{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x99 },
2705{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x99 },
2706{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xc2 },
2707{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xc2 },
2708{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xeb },
2709{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xeb },
2710{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x14 },
2711{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x14 },
2712{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x3d },
2713{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x3d },
2714{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x66 },
2715{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x66 },
2716{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x8f },
2717{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x8f },
2718{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xb8 },
2719{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xb8 },
2720{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xe1 },
2721{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xe1 },
2722{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x0a },
2723{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x0a },
2724{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x33 },
2725{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x33 },
2726{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x5c },
2727{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x5c },
2728{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x85 },
2729{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x85 },
2730{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xae },
2731{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xae },
2732{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xd7 },
2733{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xd7 },
2734{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xff },
2735{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xff },
2736
2737/* mute off */
2738{ 0x8, 0x00 }, { WAIT_IDLE }
2739};
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 3d6c5f2838af..5d2ba1b749ab 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -181,25 +181,6 @@ static void snd_wss_wait(struct snd_wss *chip)
181 udelay(100); 181 udelay(100);
182} 182}
183 183
184static void snd_wss_outm(struct snd_wss *chip, unsigned char reg,
185 unsigned char mask, unsigned char value)
186{
187 unsigned char tmp = (chip->image[reg] & mask) | value;
188
189 snd_wss_wait(chip);
190#ifdef CONFIG_SND_DEBUG
191 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
192 snd_printk("outm: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
193#endif
194 chip->image[reg] = tmp;
195 if (!chip->calibrate_mute) {
196 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg);
197 wmb();
198 wss_outb(chip, CS4231P(REG), tmp);
199 mb();
200 }
201}
202
203static void snd_wss_dout(struct snd_wss *chip, unsigned char reg, 184static void snd_wss_dout(struct snd_wss *chip, unsigned char reg,
204 unsigned char value) 185 unsigned char value)
205{ 186{
@@ -219,7 +200,8 @@ void snd_wss_out(struct snd_wss *chip, unsigned char reg, unsigned char value)
219 snd_wss_wait(chip); 200 snd_wss_wait(chip);
220#ifdef CONFIG_SND_DEBUG 201#ifdef CONFIG_SND_DEBUG
221 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) 202 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
222 snd_printk("out: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value); 203 snd_printk(KERN_DEBUG "out: auto calibration time out "
204 "- reg = 0x%x, value = 0x%x\n", reg, value);
223#endif 205#endif
224 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); 206 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg);
225 wss_outb(chip, CS4231P(REG), value); 207 wss_outb(chip, CS4231P(REG), value);
@@ -235,7 +217,8 @@ unsigned char snd_wss_in(struct snd_wss *chip, unsigned char reg)
235 snd_wss_wait(chip); 217 snd_wss_wait(chip);
236#ifdef CONFIG_SND_DEBUG 218#ifdef CONFIG_SND_DEBUG
237 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) 219 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
238 snd_printk("in: auto calibration time out - reg = 0x%x\n", reg); 220 snd_printk(KERN_DEBUG "in: auto calibration time out "
221 "- reg = 0x%x\n", reg);
239#endif 222#endif
240 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); 223 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg);
241 mb(); 224 mb();
@@ -252,7 +235,7 @@ void snd_cs4236_ext_out(struct snd_wss *chip, unsigned char reg,
252 wss_outb(chip, CS4231P(REG), val); 235 wss_outb(chip, CS4231P(REG), val);
253 chip->eimage[CS4236_REG(reg)] = val; 236 chip->eimage[CS4236_REG(reg)] = val;
254#if 0 237#if 0
255 printk("ext out : reg = 0x%x, val = 0x%x\n", reg, val); 238 printk(KERN_DEBUG "ext out : reg = 0x%x, val = 0x%x\n", reg, val);
256#endif 239#endif
257} 240}
258EXPORT_SYMBOL(snd_cs4236_ext_out); 241EXPORT_SYMBOL(snd_cs4236_ext_out);
@@ -268,7 +251,8 @@ unsigned char snd_cs4236_ext_in(struct snd_wss *chip, unsigned char reg)
268 { 251 {
269 unsigned char res; 252 unsigned char res;
270 res = wss_inb(chip, CS4231P(REG)); 253 res = wss_inb(chip, CS4231P(REG));
271 printk("ext in : reg = 0x%x, val = 0x%x\n", reg, res); 254 printk(KERN_DEBUG "ext in : reg = 0x%x, val = 0x%x\n",
255 reg, res);
272 return res; 256 return res;
273 } 257 }
274#endif 258#endif
@@ -394,13 +378,16 @@ void snd_wss_mce_up(struct snd_wss *chip)
394 snd_wss_wait(chip); 378 snd_wss_wait(chip);
395#ifdef CONFIG_SND_DEBUG 379#ifdef CONFIG_SND_DEBUG
396 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) 380 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
397 snd_printk("mce_up - auto calibration time out (0)\n"); 381 snd_printk(KERN_DEBUG
382 "mce_up - auto calibration time out (0)\n");
398#endif 383#endif
399 spin_lock_irqsave(&chip->reg_lock, flags); 384 spin_lock_irqsave(&chip->reg_lock, flags);
400 chip->mce_bit |= CS4231_MCE; 385 chip->mce_bit |= CS4231_MCE;
401 timeout = wss_inb(chip, CS4231P(REGSEL)); 386 timeout = wss_inb(chip, CS4231P(REGSEL));
402 if (timeout == 0x80) 387 if (timeout == 0x80)
403 snd_printk("mce_up [0x%lx]: serious init problem - codec still busy\n", chip->port); 388 snd_printk(KERN_DEBUG "mce_up [0x%lx]: "
389 "serious init problem - codec still busy\n",
390 chip->port);
404 if (!(timeout & CS4231_MCE)) 391 if (!(timeout & CS4231_MCE))
405 wss_outb(chip, CS4231P(REGSEL), 392 wss_outb(chip, CS4231P(REGSEL),
406 chip->mce_bit | (timeout & 0x1f)); 393 chip->mce_bit | (timeout & 0x1f));
@@ -419,7 +406,9 @@ void snd_wss_mce_down(struct snd_wss *chip)
419 406
420#ifdef CONFIG_SND_DEBUG 407#ifdef CONFIG_SND_DEBUG
421 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) 408 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT)
422 snd_printk("mce_down [0x%lx] - auto calibration time out (0)\n", (long)CS4231P(REGSEL)); 409 snd_printk(KERN_DEBUG "mce_down [0x%lx] - "
410 "auto calibration time out (0)\n",
411 (long)CS4231P(REGSEL));
423#endif 412#endif
424 spin_lock_irqsave(&chip->reg_lock, flags); 413 spin_lock_irqsave(&chip->reg_lock, flags);
425 chip->mce_bit &= ~CS4231_MCE; 414 chip->mce_bit &= ~CS4231_MCE;
@@ -427,7 +416,9 @@ void snd_wss_mce_down(struct snd_wss *chip)
427 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); 416 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f));
428 spin_unlock_irqrestore(&chip->reg_lock, flags); 417 spin_unlock_irqrestore(&chip->reg_lock, flags);
429 if (timeout == 0x80) 418 if (timeout == 0x80)
430 snd_printk("mce_down [0x%lx]: serious init problem - codec still busy\n", chip->port); 419 snd_printk(KERN_DEBUG "mce_down [0x%lx]: "
420 "serious init problem - codec still busy\n",
421 chip->port);
431 if ((timeout & CS4231_MCE) == 0 || !(chip->hardware & hw_mask)) 422 if ((timeout & CS4231_MCE) == 0 || !(chip->hardware & hw_mask))
432 return; 423 return;
433 424
@@ -565,7 +556,7 @@ static unsigned char snd_wss_get_format(struct snd_wss *chip,
565 if (channels > 1) 556 if (channels > 1)
566 rformat |= CS4231_STEREO; 557 rformat |= CS4231_STEREO;
567#if 0 558#if 0
568 snd_printk("get_format: 0x%x (mode=0x%x)\n", format, mode); 559 snd_printk(KERN_DEBUG "get_format: 0x%x (mode=0x%x)\n", format, mode);
569#endif 560#endif
570 return rformat; 561 return rformat;
571} 562}
@@ -587,7 +578,15 @@ static void snd_wss_calibrate_mute(struct snd_wss *chip, int mute)
587 chip->image[CS4231_RIGHT_INPUT]); 578 chip->image[CS4231_RIGHT_INPUT]);
588 snd_wss_dout(chip, CS4231_LOOPBACK, 579 snd_wss_dout(chip, CS4231_LOOPBACK,
589 chip->image[CS4231_LOOPBACK]); 580 chip->image[CS4231_LOOPBACK]);
581 } else {
582 snd_wss_dout(chip, CS4231_LEFT_INPUT,
583 0);
584 snd_wss_dout(chip, CS4231_RIGHT_INPUT,
585 0);
586 snd_wss_dout(chip, CS4231_LOOPBACK,
587 0xfd);
590 } 588 }
589
591 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT, 590 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT,
592 mute | chip->image[CS4231_AUX1_LEFT_INPUT]); 591 mute | chip->image[CS4231_AUX1_LEFT_INPUT]);
593 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT, 592 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT,
@@ -630,7 +629,6 @@ static void snd_wss_playback_format(struct snd_wss *chip,
630 int full_calib = 1; 629 int full_calib = 1;
631 630
632 mutex_lock(&chip->mce_mutex); 631 mutex_lock(&chip->mce_mutex);
633 snd_wss_calibrate_mute(chip, 1);
634 if (chip->hardware == WSS_HW_CS4231A || 632 if (chip->hardware == WSS_HW_CS4231A ||
635 (chip->hardware & WSS_HW_CS4232_MASK)) { 633 (chip->hardware & WSS_HW_CS4232_MASK)) {
636 spin_lock_irqsave(&chip->reg_lock, flags); 634 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -646,6 +644,24 @@ static void snd_wss_playback_format(struct snd_wss *chip,
646 full_calib = 0; 644 full_calib = 0;
647 } 645 }
648 spin_unlock_irqrestore(&chip->reg_lock, flags); 646 spin_unlock_irqrestore(&chip->reg_lock, flags);
647 } else if (chip->hardware == WSS_HW_AD1845) {
648 unsigned rate = params_rate(params);
649
650 /*
651 * Program the AD1845 correctly for the playback stream.
652 * Note that we do NOT need to toggle the MCE bit because
653 * the PLAYBACK_ENABLE bit of the Interface Configuration
654 * register is set.
655 *
656 * NOTE: We seem to need to write to the MSB before the LSB
657 * to get the correct sample frequency.
658 */
659 spin_lock_irqsave(&chip->reg_lock, flags);
660 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (pdfr & 0xf0));
661 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff);
662 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff);
663 full_calib = 0;
664 spin_unlock_irqrestore(&chip->reg_lock, flags);
649 } 665 }
650 if (full_calib) { 666 if (full_calib) {
651 snd_wss_mce_up(chip); 667 snd_wss_mce_up(chip);
@@ -663,7 +679,6 @@ static void snd_wss_playback_format(struct snd_wss *chip,
663 udelay(100); /* this seems to help */ 679 udelay(100); /* this seems to help */
664 snd_wss_mce_down(chip); 680 snd_wss_mce_down(chip);
665 } 681 }
666 snd_wss_calibrate_mute(chip, 0);
667 mutex_unlock(&chip->mce_mutex); 682 mutex_unlock(&chip->mce_mutex);
668} 683}
669 684
@@ -675,7 +690,6 @@ static void snd_wss_capture_format(struct snd_wss *chip,
675 int full_calib = 1; 690 int full_calib = 1;
676 691
677 mutex_lock(&chip->mce_mutex); 692 mutex_lock(&chip->mce_mutex);
678 snd_wss_calibrate_mute(chip, 1);
679 if (chip->hardware == WSS_HW_CS4231A || 693 if (chip->hardware == WSS_HW_CS4231A ||
680 (chip->hardware & WSS_HW_CS4232_MASK)) { 694 (chip->hardware & WSS_HW_CS4232_MASK)) {
681 spin_lock_irqsave(&chip->reg_lock, flags); 695 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -690,6 +704,24 @@ static void snd_wss_capture_format(struct snd_wss *chip,
690 full_calib = 0; 704 full_calib = 0;
691 } 705 }
692 spin_unlock_irqrestore(&chip->reg_lock, flags); 706 spin_unlock_irqrestore(&chip->reg_lock, flags);
707 } else if (chip->hardware == WSS_HW_AD1845) {
708 unsigned rate = params_rate(params);
709
710 /*
711 * Program the AD1845 correctly for the capture stream.
712 * Note that we do NOT need to toggle the MCE bit because
713 * the PLAYBACK_ENABLE bit of the Interface Configuration
714 * register is set.
715 *
716 * NOTE: We seem to need to write to the MSB before the LSB
717 * to get the correct sample frequency.
718 */
719 spin_lock_irqsave(&chip->reg_lock, flags);
720 snd_wss_out(chip, CS4231_REC_FORMAT, (cdfr & 0xf0));
721 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff);
722 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff);
723 full_calib = 0;
724 spin_unlock_irqrestore(&chip->reg_lock, flags);
693 } 725 }
694 if (full_calib) { 726 if (full_calib) {
695 snd_wss_mce_up(chip); 727 snd_wss_mce_up(chip);
@@ -714,7 +746,6 @@ static void snd_wss_capture_format(struct snd_wss *chip,
714 spin_unlock_irqrestore(&chip->reg_lock, flags); 746 spin_unlock_irqrestore(&chip->reg_lock, flags);
715 snd_wss_mce_down(chip); 747 snd_wss_mce_down(chip);
716 } 748 }
717 snd_wss_calibrate_mute(chip, 0);
718 mutex_unlock(&chip->mce_mutex); 749 mutex_unlock(&chip->mce_mutex);
719} 750}
720 751
@@ -771,10 +802,11 @@ static void snd_wss_init(struct snd_wss *chip)
771{ 802{
772 unsigned long flags; 803 unsigned long flags;
773 804
805 snd_wss_calibrate_mute(chip, 1);
774 snd_wss_mce_down(chip); 806 snd_wss_mce_down(chip);
775 807
776#ifdef SNDRV_DEBUG_MCE 808#ifdef SNDRV_DEBUG_MCE
777 snd_printk("init: (1)\n"); 809 snd_printk(KERN_DEBUG "init: (1)\n");
778#endif 810#endif
779 snd_wss_mce_up(chip); 811 snd_wss_mce_up(chip);
780 spin_lock_irqsave(&chip->reg_lock, flags); 812 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -789,18 +821,20 @@ static void snd_wss_init(struct snd_wss *chip)
789 snd_wss_mce_down(chip); 821 snd_wss_mce_down(chip);
790 822
791#ifdef SNDRV_DEBUG_MCE 823#ifdef SNDRV_DEBUG_MCE
792 snd_printk("init: (2)\n"); 824 snd_printk(KERN_DEBUG "init: (2)\n");
793#endif 825#endif
794 826
795 snd_wss_mce_up(chip); 827 snd_wss_mce_up(chip);
796 spin_lock_irqsave(&chip->reg_lock, flags); 828 spin_lock_irqsave(&chip->reg_lock, flags);
829 chip->image[CS4231_IFACE_CTRL] &= ~CS4231_AUTOCALIB;
830 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]);
797 snd_wss_out(chip, 831 snd_wss_out(chip,
798 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); 832 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]);
799 spin_unlock_irqrestore(&chip->reg_lock, flags); 833 spin_unlock_irqrestore(&chip->reg_lock, flags);
800 snd_wss_mce_down(chip); 834 snd_wss_mce_down(chip);
801 835
802#ifdef SNDRV_DEBUG_MCE 836#ifdef SNDRV_DEBUG_MCE
803 snd_printk("init: (3) - afei = 0x%x\n", 837 snd_printk(KERN_DEBUG "init: (3) - afei = 0x%x\n",
804 chip->image[CS4231_ALT_FEATURE_1]); 838 chip->image[CS4231_ALT_FEATURE_1]);
805#endif 839#endif
806 840
@@ -817,7 +851,7 @@ static void snd_wss_init(struct snd_wss *chip)
817 snd_wss_mce_down(chip); 851 snd_wss_mce_down(chip);
818 852
819#ifdef SNDRV_DEBUG_MCE 853#ifdef SNDRV_DEBUG_MCE
820 snd_printk("init: (4)\n"); 854 snd_printk(KERN_DEBUG "init: (4)\n");
821#endif 855#endif
822 856
823 snd_wss_mce_up(chip); 857 snd_wss_mce_up(chip);
@@ -827,9 +861,10 @@ static void snd_wss_init(struct snd_wss *chip)
827 chip->image[CS4231_REC_FORMAT]); 861 chip->image[CS4231_REC_FORMAT]);
828 spin_unlock_irqrestore(&chip->reg_lock, flags); 862 spin_unlock_irqrestore(&chip->reg_lock, flags);
829 snd_wss_mce_down(chip); 863 snd_wss_mce_down(chip);
864 snd_wss_calibrate_mute(chip, 0);
830 865
831#ifdef SNDRV_DEBUG_MCE 866#ifdef SNDRV_DEBUG_MCE
832 snd_printk("init: (5)\n"); 867 snd_printk(KERN_DEBUG "init: (5)\n");
833#endif 868#endif
834} 869}
835 870
@@ -885,8 +920,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode)
885 mutex_unlock(&chip->open_mutex); 920 mutex_unlock(&chip->open_mutex);
886 return; 921 return;
887 } 922 }
888 snd_wss_calibrate_mute(chip, 1);
889
890 /* disable IRQ */ 923 /* disable IRQ */
891 spin_lock_irqsave(&chip->reg_lock, flags); 924 spin_lock_irqsave(&chip->reg_lock, flags);
892 if (!(chip->hardware & WSS_HW_AD1848_MASK)) 925 if (!(chip->hardware & WSS_HW_AD1848_MASK))
@@ -919,8 +952,6 @@ static void snd_wss_close(struct snd_wss *chip, unsigned int mode)
919 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ 952 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */
920 spin_unlock_irqrestore(&chip->reg_lock, flags); 953 spin_unlock_irqrestore(&chip->reg_lock, flags);
921 954
922 snd_wss_calibrate_mute(chip, 0);
923
924 chip->mode = 0; 955 chip->mode = 0;
925 mutex_unlock(&chip->open_mutex); 956 mutex_unlock(&chip->open_mutex);
926} 957}
@@ -1113,7 +1144,7 @@ irqreturn_t snd_wss_interrupt(int irq, void *dev_id)
1113 if (chip->hardware & WSS_HW_AD1848_MASK) 1144 if (chip->hardware & WSS_HW_AD1848_MASK)
1114 wss_outb(chip, CS4231P(STATUS), 0); 1145 wss_outb(chip, CS4231P(STATUS), 0);
1115 else 1146 else
1116 snd_wss_outm(chip, CS4231_IRQ_STATUS, status, 0); 1147 snd_wss_out(chip, CS4231_IRQ_STATUS, status);
1117 spin_unlock(&chip->reg_lock); 1148 spin_unlock(&chip->reg_lock);
1118 return IRQ_HANDLED; 1149 return IRQ_HANDLED;
1119} 1150}
@@ -1278,7 +1309,8 @@ static int snd_wss_probe(struct snd_wss *chip)
1278 } else if (rev == 0x03) { 1309 } else if (rev == 0x03) {
1279 chip->hardware = WSS_HW_CS4236B; 1310 chip->hardware = WSS_HW_CS4236B;
1280 } else { 1311 } else {
1281 snd_printk("unknown CS chip with version 0x%x\n", rev); 1312 snd_printk(KERN_ERR
1313 "unknown CS chip with version 0x%x\n", rev);
1282 return -ENODEV; /* unknown CS4231 chip? */ 1314 return -ENODEV; /* unknown CS4231 chip? */
1283 } 1315 }
1284 } 1316 }
@@ -1314,6 +1346,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1314 chip->image[CS4231_ALT_FEATURE_2] = 1346 chip->image[CS4231_ALT_FEATURE_2] =
1315 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01; 1347 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01;
1316 } 1348 }
1349 /* enable fine grained frequency selection */
1350 if (chip->hardware == WSS_HW_AD1845)
1351 chip->image[AD1845_PWR_DOWN] = 8;
1352
1317 ptr = (unsigned char *) &chip->image; 1353 ptr = (unsigned char *) &chip->image;
1318 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32; 1354 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32;
1319 snd_wss_mce_down(chip); 1355 snd_wss_mce_down(chip);
@@ -1342,7 +1378,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1342 case 6: 1378 case 6:
1343 break; 1379 break;
1344 default: 1380 default:
1345 snd_printk("unknown CS4235 chip (enhanced version = 0x%x)\n", id); 1381 snd_printk(KERN_WARNING
1382 "unknown CS4235 chip "
1383 "(enhanced version = 0x%x)\n",
1384 id);
1346 } 1385 }
1347 } else if ((id & 0x1f) == 0x0b) { /* CS4236/B */ 1386 } else if ((id & 0x1f) == 0x0b) { /* CS4236/B */
1348 switch (id >> 5) { 1387 switch (id >> 5) {
@@ -1353,7 +1392,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1353 chip->hardware = WSS_HW_CS4236B; 1392 chip->hardware = WSS_HW_CS4236B;
1354 break; 1393 break;
1355 default: 1394 default:
1356 snd_printk("unknown CS4236 chip (enhanced version = 0x%x)\n", id); 1395 snd_printk(KERN_WARNING
1396 "unknown CS4236 chip "
1397 "(enhanced version = 0x%x)\n",
1398 id);
1357 } 1399 }
1358 } else if ((id & 0x1f) == 0x08) { /* CS4237B */ 1400 } else if ((id & 0x1f) == 0x08) { /* CS4237B */
1359 chip->hardware = WSS_HW_CS4237B; 1401 chip->hardware = WSS_HW_CS4237B;
@@ -1364,7 +1406,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1364 case 7: 1406 case 7:
1365 break; 1407 break;
1366 default: 1408 default:
1367 snd_printk("unknown CS4237B chip (enhanced version = 0x%x)\n", id); 1409 snd_printk(KERN_WARNING
1410 "unknown CS4237B chip "
1411 "(enhanced version = 0x%x)\n",
1412 id);
1368 } 1413 }
1369 } else if ((id & 0x1f) == 0x09) { /* CS4238B */ 1414 } else if ((id & 0x1f) == 0x09) { /* CS4238B */
1370 chip->hardware = WSS_HW_CS4238B; 1415 chip->hardware = WSS_HW_CS4238B;
@@ -1374,7 +1419,10 @@ static int snd_wss_probe(struct snd_wss *chip)
1374 case 7: 1419 case 7:
1375 break; 1420 break;
1376 default: 1421 default:
1377 snd_printk("unknown CS4238B chip (enhanced version = 0x%x)\n", id); 1422 snd_printk(KERN_WARNING
1423 "unknown CS4238B chip "
1424 "(enhanced version = 0x%x)\n",
1425 id);
1378 } 1426 }
1379 } else if ((id & 0x1f) == 0x1e) { /* CS4239 */ 1427 } else if ((id & 0x1f) == 0x1e) { /* CS4239 */
1380 chip->hardware = WSS_HW_CS4239; 1428 chip->hardware = WSS_HW_CS4239;
@@ -1384,10 +1432,15 @@ static int snd_wss_probe(struct snd_wss *chip)
1384 case 6: 1432 case 6:
1385 break; 1433 break;
1386 default: 1434 default:
1387 snd_printk("unknown CS4239 chip (enhanced version = 0x%x)\n", id); 1435 snd_printk(KERN_WARNING
1436 "unknown CS4239 chip "
1437 "(enhanced version = 0x%x)\n",
1438 id);
1388 } 1439 }
1389 } else { 1440 } else {
1390 snd_printk("unknown CS4236/CS423xB chip (enhanced version = 0x%x)\n", id); 1441 snd_printk(KERN_WARNING
1442 "unknown CS4236/CS423xB chip "
1443 "(enhanced version = 0x%x)\n", id);
1391 } 1444 }
1392 } 1445 }
1393 } 1446 }
@@ -1618,7 +1671,8 @@ static void snd_wss_resume(struct snd_wss *chip)
1618 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); 1671 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f));
1619 spin_unlock_irqrestore(&chip->reg_lock, flags); 1672 spin_unlock_irqrestore(&chip->reg_lock, flags);
1620 if (timeout == 0x80) 1673 if (timeout == 0x80)
1621 snd_printk("down [0x%lx]: serious init problem - codec still busy\n", chip->port); 1674 snd_printk(KERN_ERR "down [0x%lx]: serious init problem "
1675 "- codec still busy\n", chip->port);
1622 if ((timeout & CS4231_MCE) == 0 || 1676 if ((timeout & CS4231_MCE) == 0 ||
1623 !(chip->hardware & (WSS_HW_CS4231_MASK | WSS_HW_CS4232_MASK))) { 1677 !(chip->hardware & (WSS_HW_CS4231_MASK | WSS_HW_CS4232_MASK))) {
1624 return; 1678 return;
@@ -1628,7 +1682,7 @@ static void snd_wss_resume(struct snd_wss *chip)
1628} 1682}
1629#endif /* CONFIG_PM */ 1683#endif /* CONFIG_PM */
1630 1684
1631static int snd_wss_free(struct snd_wss *chip) 1685int snd_wss_free(struct snd_wss *chip)
1632{ 1686{
1633 release_and_free_resource(chip->res_port); 1687 release_and_free_resource(chip->res_port);
1634 release_and_free_resource(chip->res_cport); 1688 release_and_free_resource(chip->res_cport);
@@ -1651,6 +1705,7 @@ static int snd_wss_free(struct snd_wss *chip)
1651 kfree(chip); 1705 kfree(chip);
1652 return 0; 1706 return 0;
1653} 1707}
1708EXPORT_SYMBOL(snd_wss_free);
1654 1709
1655static int snd_wss_dev_free(struct snd_device *device) 1710static int snd_wss_dev_free(struct snd_device *device)
1656{ 1711{
@@ -1820,7 +1875,8 @@ int snd_wss_create(struct snd_card *card,
1820#if 0 1875#if 0
1821 if (chip->hardware & WSS_HW_CS4232_MASK) { 1876 if (chip->hardware & WSS_HW_CS4232_MASK) {
1822 if (chip->res_cport == NULL) 1877 if (chip->res_cport == NULL)
1823 snd_printk("CS4232 control port features are not accessible\n"); 1878 snd_printk(KERN_ERR "CS4232 control port features are "
1879 "not accessible\n");
1824 } 1880 }
1825#endif 1881#endif
1826 1882
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index 99e1391b2eb4..3e763d6a5d67 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -679,7 +679,7 @@ au1000_init(void)
679 return err; 679 return err;
680 } 680 }
681 681
682 printk( KERN_INFO "ALSA AC97: Driver Initialized\n" ); 682 printk(KERN_INFO "ALSA AC97: Driver Initialized\n");
683 au1000_card = card; 683 au1000_card = card;
684 return 0; 684 return 0;
685} 685}
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 7cf9913a47b2..d12bd98a37ba 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -280,7 +280,7 @@ static void wait_for_calibration(ad1848_info * devc)
280 while (timeout > 0 && (ad_read(devc, 11) & 0x20)) 280 while (timeout > 0 && (ad_read(devc, 11) & 0x20))
281 timeout--; 281 timeout--;
282 if (ad_read(devc, 11) & 0x20) 282 if (ad_read(devc, 11) & 0x20)
283 if ( (devc->model != MD_1845) || (devc->model != MD_1845_SSCAPE)) 283 if ((devc->model != MD_1845) && (devc->model != MD_1845_SSCAPE))
284 printk(KERN_WARNING "ad1848: Auto calibration timed out(3).\n"); 284 printk(KERN_WARNING "ad1848: Auto calibration timed out(3).\n");
285} 285}
286 286
@@ -2107,7 +2107,7 @@ int ad1848_control(int cmd, int arg)
2107 switch (cmd) 2107 switch (cmd)
2108 { 2108 {
2109 case AD1848_SET_XTAL: /* Change clock frequency of AD1845 (only ) */ 2109 case AD1848_SET_XTAL: /* Change clock frequency of AD1845 (only ) */
2110 if (devc->model != MD_1845 || devc->model != MD_1845_SSCAPE) 2110 if (devc->model != MD_1845 && devc->model != MD_1845_SSCAPE)
2111 return -EINVAL; 2111 return -EINVAL;
2112 spin_lock_irqsave(&devc->lock,flags); 2112 spin_lock_irqsave(&devc->lock,flags);
2113 ad_enter_MCE(devc); 2113 ad_enter_MCE(devc);
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 81e1f443d094..4191acccbcdb 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -1627,7 +1627,9 @@ au1550_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1627 sizeof(abinfo)) ? -EFAULT : 0; 1627 sizeof(abinfo)) ? -EFAULT : 0;
1628 1628
1629 case SNDCTL_DSP_NONBLOCK: 1629 case SNDCTL_DSP_NONBLOCK:
1630 spin_lock(&file->f_lock);
1630 file->f_flags |= O_NONBLOCK; 1631 file->f_flags |= O_NONBLOCK;
1632 spin_unlock(&file->f_lock);
1631 return 0; 1633 return 0;
1632 1634
1633 case SNDCTL_DSP_GETODELAY: 1635 case SNDCTL_DSP_GETODELAY:
diff --git a/sound/oss/audio.c b/sound/oss/audio.c
index 89bd27a5e865..b69c05b7ea7b 100644
--- a/sound/oss/audio.c
+++ b/sound/oss/audio.c
@@ -433,7 +433,9 @@ int audio_ioctl(int dev, struct file *file, unsigned int cmd, void __user *arg)
433 return dma_ioctl(dev, cmd, arg); 433 return dma_ioctl(dev, cmd, arg);
434 434
435 case SNDCTL_DSP_NONBLOCK: 435 case SNDCTL_DSP_NONBLOCK:
436 spin_lock(&file->f_lock);
436 file->f_flags |= O_NONBLOCK; 437 file->f_flags |= O_NONBLOCK;
438 spin_unlock(&file->f_lock);
437 return 0; 439 return 0;
438 440
439 case SNDCTL_DSP_GETCAPS: 441 case SNDCTL_DSP_GETCAPS:
diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c
index 1e90d769b62e..1bfcf7e88546 100644
--- a/sound/oss/dmabuf.c
+++ b/sound/oss/dmabuf.c
@@ -439,7 +439,7 @@ int DMAbuf_sync(int dev)
439 DMAbuf_launch_output(dev, dmap); 439 DMAbuf_launch_output(dev, dmap);
440 adev->dmap_out->flags |= DMA_SYNCING; 440 adev->dmap_out->flags |= DMA_SYNCING;
441 adev->dmap_out->underrun_count = 0; 441 adev->dmap_out->underrun_count = 0;
442 while (!signal_pending(current) && n++ <= adev->dmap_out->nbufs && 442 while (!signal_pending(current) && n++ < adev->dmap_out->nbufs &&
443 adev->dmap_out->qlen && adev->dmap_out->underrun_count == 0) { 443 adev->dmap_out->qlen && adev->dmap_out->underrun_count == 0) {
444 long t = dmabuf_timeout(dmap); 444 long t = dmabuf_timeout(dmap);
445 spin_unlock_irqrestore(&dmap->lock,flags); 445 spin_unlock_irqrestore(&dmap->lock,flags);
diff --git a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c
index 57d9f154c88b..1f4774123064 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -847,23 +847,23 @@ static int __init AtaIrqInit(void)
847 of events. So all we need to keep the music playing is 847 of events. So all we need to keep the music playing is
848 to provide the sound hardware with new data upon 848 to provide the sound hardware with new data upon
849 an interrupt from timer A. */ 849 an interrupt from timer A. */
850 mfp.tim_ct_a = 0; /* ++roman: Stop timer before programming! */ 850 st_mfp.tim_ct_a = 0; /* ++roman: Stop timer before programming! */
851 mfp.tim_dt_a = 1; /* Cause interrupt after first event. */ 851 st_mfp.tim_dt_a = 1; /* Cause interrupt after first event. */
852 mfp.tim_ct_a = 8; /* Turn on event counting. */ 852 st_mfp.tim_ct_a = 8; /* Turn on event counting. */
853 /* Register interrupt handler. */ 853 /* Register interrupt handler. */
854 if (request_irq(IRQ_MFP_TIMA, AtaInterrupt, IRQ_TYPE_SLOW, "DMA sound", 854 if (request_irq(IRQ_MFP_TIMA, AtaInterrupt, IRQ_TYPE_SLOW, "DMA sound",
855 AtaInterrupt)) 855 AtaInterrupt))
856 return 0; 856 return 0;
857 mfp.int_en_a |= 0x20; /* Turn interrupt on. */ 857 st_mfp.int_en_a |= 0x20; /* Turn interrupt on. */
858 mfp.int_mk_a |= 0x20; 858 st_mfp.int_mk_a |= 0x20;
859 return 1; 859 return 1;
860} 860}
861 861
862#ifdef MODULE 862#ifdef MODULE
863static void AtaIrqCleanUp(void) 863static void AtaIrqCleanUp(void)
864{ 864{
865 mfp.tim_ct_a = 0; /* stop timer */ 865 st_mfp.tim_ct_a = 0; /* stop timer */
866 mfp.int_en_a &= ~0x20; /* turn interrupt off */ 866 st_mfp.int_en_a &= ~0x20; /* turn interrupt off */
867 free_irq(IRQ_MFP_TIMA, AtaInterrupt); 867 free_irq(IRQ_MFP_TIMA, AtaInterrupt);
868} 868}
869#endif /* MODULE */ 869#endif /* MODULE */
@@ -1524,7 +1524,7 @@ static SETTINGS def_soft = {
1524 .speed = 8000 1524 .speed = 8000
1525} ; 1525} ;
1526 1526
1527static MACHINE machTT = { 1527static __initdata MACHINE machTT = {
1528 .name = "Atari", 1528 .name = "Atari",
1529 .name2 = "TT", 1529 .name2 = "TT",
1530 .owner = THIS_MODULE, 1530 .owner = THIS_MODULE,
@@ -1553,7 +1553,7 @@ static MACHINE machTT = {
1553 .capabilities = DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */ 1553 .capabilities = DSP_CAP_BATCH /* As per SNDCTL_DSP_GETCAPS */
1554}; 1554};
1555 1555
1556static MACHINE machFalcon = { 1556static __initdata MACHINE machFalcon = {
1557 .name = "Atari", 1557 .name = "Atari",
1558 .name2 = "FALCON", 1558 .name2 = "FALCON",
1559 .dma_alloc = AtaAlloc, 1559 .dma_alloc = AtaAlloc,
@@ -1599,7 +1599,7 @@ static int __init dmasound_atari_init(void)
1599 is_falcon = 0; 1599 is_falcon = 0;
1600 } else 1600 } else
1601 return -ENODEV; 1601 return -ENODEV;
1602 if ((mfp.int_en_a & mfp.int_mk_a & 0x20) == 0) 1602 if ((st_mfp.int_en_a & st_mfp.int_mk_a & 0x20) == 0)
1603 return dmasound_init(); 1603 return dmasound_init();
1604 else { 1604 else {
1605 printk("DMA sound driver: Timer A interrupt already in use\n"); 1605 printk("DMA sound driver: Timer A interrupt already in use\n");
diff --git a/sound/oss/pas2_card.c b/sound/oss/pas2_card.c
index 25f3a22c52ee..7f377ec3486d 100644
--- a/sound/oss/pas2_card.c
+++ b/sound/oss/pas2_card.c
@@ -156,9 +156,7 @@ static int __init config_pas_hw(struct address_info *hw_config)
156 * 0x80 156 * 0x80
157 */ , 0xB88); 157 */ , 0xB88);
158 158
159 pas_write(0x80 159 pas_write(0x80 | (joystick ? 0x40 : 0), 0xF388);
160 | joystick?0x40:0
161 ,0xF388);
162 160
163 if (pas_irq < 0 || pas_irq > 15) 161 if (pas_irq < 0 || pas_irq > 15)
164 { 162 {
diff --git a/sound/oss/pss.c b/sound/oss/pss.c
index 16ed06950dc1..83f5ee236b12 100644
--- a/sound/oss/pss.c
+++ b/sound/oss/pss.c
@@ -46,7 +46,7 @@
46 * load the driver as it did in previous versions. 46 * load the driver as it did in previous versions.
47 * 04-07-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu> 47 * 04-07-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu>
48 * Added module parameter pss_firmware to allow the user to tell 48 * Added module parameter pss_firmware to allow the user to tell
49 * the driver where the fireware file is located. The default 49 * the driver where the firmware file is located. The default
50 * setting is the previous hardcoded setting "/etc/sound/pss_synth". 50 * setting is the previous hardcoded setting "/etc/sound/pss_synth".
51 * 00-03-03: Christoph Hellwig <chhellwig@infradead.org> 51 * 00-03-03: Christoph Hellwig <chhellwig@infradead.org>
52 * Adapted to module_init/module_exit 52 * Adapted to module_init/module_exit
@@ -457,10 +457,9 @@ static void pss_mixer_reset(pss_confdata *devc)
457 } 457 }
458} 458}
459 459
460static int set_volume_mono(unsigned __user *p, int *aleft) 460static int set_volume_mono(unsigned __user *p, unsigned int *aleft)
461{ 461{
462 int left; 462 unsigned int left, volume;
463 unsigned volume;
464 if (get_user(volume, p)) 463 if (get_user(volume, p))
465 return -EFAULT; 464 return -EFAULT;
466 465
@@ -471,10 +470,11 @@ static int set_volume_mono(unsigned __user *p, int *aleft)
471 return 0; 470 return 0;
472} 471}
473 472
474static int set_volume_stereo(unsigned __user *p, int *aleft, int *aright) 473static int set_volume_stereo(unsigned __user *p,
474 unsigned int *aleft,
475 unsigned int *aright)
475{ 476{
476 int left, right; 477 unsigned int left, right, volume;
477 unsigned volume;
478 if (get_user(volume, p)) 478 if (get_user(volume, p))
479 return -EFAULT; 479 return -EFAULT;
480 480
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 5c215f787ca9..c79874696bec 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -212,7 +212,6 @@ int sequencer_write(int dev, struct file *file, const char __user *buf, int coun
212{ 212{
213 unsigned char event_rec[EV_SZ], ev_code; 213 unsigned char event_rec[EV_SZ], ev_code;
214 int p = 0, c, ev_size; 214 int p = 0, c, ev_size;
215 int err;
216 int mode = translate_mode(file); 215 int mode = translate_mode(file);
217 216
218 dev = dev >> 4; 217 dev = dev >> 4;
@@ -285,7 +284,7 @@ int sequencer_write(int dev, struct file *file, const char __user *buf, int coun
285 { 284 {
286 if (!midi_opened[event_rec[2]]) 285 if (!midi_opened[event_rec[2]])
287 { 286 {
288 int mode; 287 int err, mode;
289 int dev = event_rec[2]; 288 int dev = event_rec[2];
290 289
291 if (dev >= max_mididev || midi_devs[dev]==NULL) 290 if (dev >= max_mididev || midi_devs[dev]==NULL)
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index e5d423994918..78cfb66e4c59 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -135,7 +135,9 @@ static int dac_audio_ioctl(struct inode *inode, struct file *file,
135 return put_user(AFMT_U8, (int *)arg); 135 return put_user(AFMT_U8, (int *)arg);
136 136
137 case SNDCTL_DSP_NONBLOCK: 137 case SNDCTL_DSP_NONBLOCK:
138 spin_lock(&file->f_lock);
138 file->f_flags |= O_NONBLOCK; 139 file->f_flags |= O_NONBLOCK;
140 spin_unlock(&file->f_lock);
139 return 0; 141 return 0;
140 142
141 case SNDCTL_DSP_GETCAPS: 143 case SNDCTL_DSP_GETCAPS:
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 41562ecde5bb..1edab7b4ea83 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -2200,7 +2200,9 @@ static int cs4297a_ioctl(struct inode *inode, struct file *file,
2200 sizeof(abinfo)) ? -EFAULT : 0; 2200 sizeof(abinfo)) ? -EFAULT : 0;
2201 2201
2202 case SNDCTL_DSP_NONBLOCK: 2202 case SNDCTL_DSP_NONBLOCK:
2203 spin_lock(&file->f_lock);
2203 file->f_flags |= O_NONBLOCK; 2204 file->f_flags |= O_NONBLOCK;
2205 spin_unlock(&file->f_lock);
2204 return 0; 2206 return 0;
2205 2207
2206 case SNDCTL_DSP_GETODELAY: 2208 case SNDCTL_DSP_GETODELAY:
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 78b8acc7c3b9..187f72750e8f 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -2673,7 +2673,9 @@ static int vwsnd_audio_do_ioctl(struct inode *inode,
2673 2673
2674 case SNDCTL_DSP_NONBLOCK: /* _SIO ('P',14) */ 2674 case SNDCTL_DSP_NONBLOCK: /* _SIO ('P',14) */
2675 DBGX("SNDCTL_DSP_NONBLOCK\n"); 2675 DBGX("SNDCTL_DSP_NONBLOCK\n");
2676 spin_lock(&file->f_lock);
2676 file->f_flags |= O_NONBLOCK; 2677 file->f_flags |= O_NONBLOCK;
2678 spin_unlock(&file->f_lock);
2677 return 0; 2679 return 0;
2678 2680
2679 case SNDCTL_DSP_RESET: /* _SIO ('P', 0) */ 2681 case SNDCTL_DSP_RESET: /* _SIO ('P', 0) */
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 6e3a1848447c..93422e3a3f0c 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -400,6 +400,26 @@ config SND_INDIGODJ
400 To compile this driver as a module, choose M here: the module 400 To compile this driver as a module, choose M here: the module
401 will be called snd-indigodj 401 will be called snd-indigodj
402 402
403config SND_INDIGOIOX
404 tristate "(Echoaudio) Indigo IOx"
405 select FW_LOADER
406 select SND_PCM
407 help
408 Say 'Y' or 'M' to include support for Echoaudio Indigo IOx.
409
410 To compile this driver as a module, choose M here: the module
411 will be called snd-indigoiox
412
413config SND_INDIGODJX
414 tristate "(Echoaudio) Indigo DJx"
415 select FW_LOADER
416 select SND_PCM
417 help
418 Say 'Y' or 'M' to include support for Echoaudio Indigo DJx.
419
420 To compile this driver as a module, choose M here: the module
421 will be called snd-indigodjx
422
403config SND_EMU10K1 423config SND_EMU10K1
404 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)" 424 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)"
405 select FW_LOADER 425 select FW_LOADER
@@ -487,7 +507,7 @@ config SND_FM801
487config SND_FM801_TEA575X_BOOL 507config SND_FM801_TEA575X_BOOL
488 bool "ForteMedia FM801 + TEA5757 tuner" 508 bool "ForteMedia FM801 + TEA5757 tuner"
489 depends on SND_FM801 509 depends on SND_FM801
490 depends on VIDEO_V4L1=y || VIDEO_V4L1=SND_FM801 510 depends on VIDEO_V4L2=y || VIDEO_V4L2=SND_FM801
491 help 511 help
492 Say Y here to include support for soundcards based on the ForteMedia 512 Say Y here to include support for soundcards based on the ForteMedia
493 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media 513 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
@@ -744,8 +764,9 @@ config SND_VIRTUOSO
744 select SND_OXYGEN_LIB 764 select SND_OXYGEN_LIB
745 help 765 help
746 Say Y here to include support for sound cards based on the 766 Say Y here to include support for sound cards based on the
747 Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X and 767 Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, and
748 HDAV1.3 (Deluxe). 768 Essence STX.
769 Support for the HDAV1.3 (Deluxe) is very experimental.
749 770
750 To compile this driver as a module, choose M here: the module 771 To compile this driver as a module, choose M here: the module
751 will be called snd-virtuoso. 772 will be called snd-virtuoso.
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index e2b843b4f9d0..78288dbfc17a 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -143,6 +143,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
143{ 0x43525970, 0xfffffff8, "CS4202", NULL, NULL }, 143{ 0x43525970, 0xfffffff8, "CS4202", NULL, NULL },
144{ 0x43585421, 0xffffffff, "HSD11246", NULL, NULL }, // SmartMC II 144{ 0x43585421, 0xffffffff, "HSD11246", NULL, NULL }, // SmartMC II
145{ 0x43585428, 0xfffffff8, "Cx20468", patch_conexant, NULL }, // SmartAMC fixme: the mask might be different 145{ 0x43585428, 0xfffffff8, "Cx20468", patch_conexant, NULL }, // SmartAMC fixme: the mask might be different
146{ 0x43585430, 0xffffffff, "Cx20468-31", patch_conexant, NULL },
146{ 0x43585431, 0xffffffff, "Cx20551", patch_cx20551, NULL }, 147{ 0x43585431, 0xffffffff, "Cx20551", patch_cx20551, NULL },
147{ 0x44543031, 0xfffffff0, "DT0398", NULL, NULL }, 148{ 0x44543031, 0xfffffff0, "DT0398", NULL, NULL },
148{ 0x454d4328, 0xffffffff, "EM28028", NULL, NULL }, // same as TR28028? 149{ 0x454d4328, 0xffffffff, "EM28028", NULL, NULL }, // same as TR28028?
@@ -383,7 +384,7 @@ int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned sho
383 384
384EXPORT_SYMBOL(snd_ac97_update_bits); 385EXPORT_SYMBOL(snd_ac97_update_bits);
385 386
386/* no lock version - see snd_ac97_updat_bits() */ 387/* no lock version - see snd_ac97_update_bits() */
387int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, 388int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
388 unsigned short mask, unsigned short value) 389 unsigned short mask, unsigned short value)
389{ 390{
@@ -1643,7 +1644,10 @@ static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97)
1643{ 1644{
1644 int err, idx; 1645 int err, idx;
1645 1646
1646 //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG)); 1647 /*
1648 printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n",
1649 snd_ac97_read(ac97,AC97_GPIO_CFG));
1650 */
1647 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); 1651 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
1648 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); 1652 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH));
1649 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); 1653 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff);
@@ -2118,7 +2122,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2118 } 2122 }
2119 /* nothing should be in powerdown mode */ 2123 /* nothing should be in powerdown mode */
2120 snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0); 2124 snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0);
2121 end_time = jiffies + msecs_to_jiffies(100); 2125 end_time = jiffies + msecs_to_jiffies(120);
2122 do { 2126 do {
2123 if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f) 2127 if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f)
2124 goto __ready_ok; 2128 goto __ready_ok;
diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c
index 060ea59d5f02..73b17d526c8b 100644
--- a/sound/pci/ac97/ac97_proc.c
+++ b/sound/pci/ac97/ac97_proc.c
@@ -125,6 +125,8 @@ static void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffe
125 snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n", 125 snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n",
126 ac97->subsystem_device); 126 ac97->subsystem_device);
127 127
128 snd_iprintf(buffer, "Flags: %x\n", ac97->flags);
129
128 if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) { 130 if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
129 val = snd_ac97_read(ac97, AC97_INT_PAGING); 131 val = snd_ac97_read(ac97, AC97_INT_PAGING);
130 snd_ac97_update_bits(ac97, AC97_INT_PAGING, 132 snd_ac97_update_bits(ac97, AC97_INT_PAGING,
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index d1f242bd0ac5..8f5098f92c37 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -909,8 +909,8 @@ snd_ad1889_create(struct snd_card *card,
909 return err; 909 return err;
910 910
911 /* check PCI availability (32bit DMA) */ 911 /* check PCI availability (32bit DMA) */
912 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || 912 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
913 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { 913 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
914 printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n"); 914 printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n");
915 pci_disable_device(pci); 915 pci_disable_device(pci);
916 return -ENXIO; 916 return -ENXIO;
diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c
index 0f819ddb3ebf..fd135e3d8a84 100644
--- a/sound/pci/ak4531_codec.c
+++ b/sound/pci/ak4531_codec.c
@@ -51,7 +51,8 @@ static void snd_ak4531_dump(struct snd_ak4531 *ak4531)
51 int idx; 51 int idx;
52 52
53 for (idx = 0; idx < 0x19; idx++) 53 for (idx = 0; idx < 0x19; idx++)
54 printk("ak4531 0x%x: 0x%x\n", idx, ak4531->regs[idx]); 54 printk(KERN_DEBUG "ak4531 0x%x: 0x%x\n",
55 idx, ak4531->regs[idx]);
55} 56}
56 57
57#endif 58#endif
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index b36c551da566..c551006e2920 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2142,7 +2142,7 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2142{ 2142{
2143 int err; 2143 int err;
2144 2144
2145 snd_ali_printk("resouces allocation ...\n"); 2145 snd_ali_printk("resources allocation ...\n");
2146 err = pci_request_regions(codec->pci, "ALI 5451"); 2146 err = pci_request_regions(codec->pci, "ALI 5451");
2147 if (err < 0) 2147 if (err < 0)
2148 return err; 2148 return err;
@@ -2154,7 +2154,7 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2154 return -EBUSY; 2154 return -EBUSY;
2155 } 2155 }
2156 codec->irq = codec->pci->irq; 2156 codec->irq = codec->pci->irq;
2157 snd_ali_printk("resouces allocated.\n"); 2157 snd_ali_printk("resources allocated.\n");
2158 return 0; 2158 return 0;
2159} 2159}
2160static int snd_ali_dev_free(struct snd_device *device) 2160static int snd_ali_dev_free(struct snd_device *device)
@@ -2186,8 +2186,8 @@ static int __devinit snd_ali_create(struct snd_card *card,
2186 if (err < 0) 2186 if (err < 0)
2187 return err; 2187 return err;
2188 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2188 /* check, if we can restrict PCI DMA transfers to 31 bits */
2189 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 || 2189 if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
2190 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) { 2190 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
2191 snd_printk(KERN_ERR "architecture does not support " 2191 snd_printk(KERN_ERR "architecture does not support "
2192 "31bit PCI busmaster DMA\n"); 2192 "31bit PCI busmaster DMA\n");
2193 pci_disable_device(pci); 2193 pci_disable_device(pci);
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index f557c155db48..3aa35af7ca91 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -91,7 +91,7 @@
91#define DEBUG_PLAY_REC 0 91#define DEBUG_PLAY_REC 0
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(KERN_DEBUG format, ##args)
95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__) 95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__) 96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
97#else 97#else
@@ -689,8 +689,8 @@ static int __devinit snd_als300_create(struct snd_card *card,
689 if ((err = pci_enable_device(pci)) < 0) 689 if ((err = pci_enable_device(pci)) < 0)
690 return err; 690 return err;
691 691
692 if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || 692 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
693 pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { 693 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
694 printk(KERN_ERR "error setting 28bit DMA mask\n"); 694 printk(KERN_ERR "error setting 28bit DMA mask\n");
695 pci_disable_device(pci); 695 pci_disable_device(pci);
696 return -ENXIO; 696 return -ENXIO;
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 542a0c65a92c..3dbacde1a5af 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -872,8 +872,8 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci,
872 return err; 872 return err;
873 } 873 }
874 /* check, if we can restrict PCI DMA transfers to 24 bits */ 874 /* check, if we can restrict PCI DMA transfers to 24 bits */
875 if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 || 875 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
876 pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) { 876 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
877 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 877 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
878 pci_disable_device(pci); 878 pci_disable_device(pci);
879 return -ENXIO; 879 return -ENXIO;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 9ce8548c03e4..71515ddb4593 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1393,6 +1393,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1393 .name = "HP nx6125", 1393 .name = "HP nx6125",
1394 .type = AC97_TUNE_MUTE_LED 1394 .type = AC97_TUNE_MUTE_LED
1395 }, 1395 },
1396 {
1397 .subvendor = 0x103c,
1398 .subdevice = 0x3091,
1399 .name = "unknown HP",
1400 .type = AC97_TUNE_MUTE_LED
1401 },
1396 { } /* terminator */ 1402 { } /* terminator */
1397}; 1403};
1398 1404
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 9ec122383eef..7b72c88e449d 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -151,8 +151,8 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
151 // check PCI availability (DMA). 151 // check PCI availability (DMA).
152 if ((err = pci_enable_device(pci)) < 0) 152 if ((err = pci_enable_device(pci)) < 0)
153 return err; 153 return err;
154 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || 154 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
155 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { 155 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
156 printk(KERN_ERR "error to set DMA mask\n"); 156 printk(KERN_ERR "error to set DMA mask\n");
157 pci_disable_device(pci); 157 pci_disable_device(pci);
158 return -ENXIO; 158 return -ENXIO;
diff --git a/sound/pci/au88x0/au88x0_a3d.c b/sound/pci/au88x0/au88x0_a3d.c
index 649849e540d3..f4aa8ff6f5f9 100644
--- a/sound/pci/au88x0/au88x0_a3d.c
+++ b/sound/pci/au88x0/au88x0_a3d.c
@@ -462,9 +462,10 @@ static void a3dsrc_ZeroSliceIO(a3dsrc_t * a)
462/* Reset Single A3D source. */ 462/* Reset Single A3D source. */
463static void a3dsrc_ZeroState(a3dsrc_t * a) 463static void a3dsrc_ZeroState(a3dsrc_t * a)
464{ 464{
465 465 /*
466 //printk("vortex: ZeroState slice: %d, source %d\n", a->slice, a->source); 466 printk(KERN_DEBUG "vortex: ZeroState slice: %d, source %d\n",
467 467 a->slice, a->source);
468 */
468 a3dsrc_SetAtmosState(a, 0, 0, 0, 0); 469 a3dsrc_SetAtmosState(a, 0, 0, 0, 0);
469 a3dsrc_SetHrtfState(a, A3dHrirZeros, A3dHrirZeros); 470 a3dsrc_SetHrtfState(a, A3dHrirZeros, A3dHrirZeros);
470 a3dsrc_SetItdDline(a, A3dItdDlineZeros); 471 a3dsrc_SetItdDline(a, A3dItdDlineZeros);
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index b070e5714514..3906f5afe27a 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -1135,7 +1135,10 @@ vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
1135 snd_pcm_sgbuf_get_addr(dma->substream, 0)); 1135 snd_pcm_sgbuf_get_addr(dma->substream, 0));
1136 break; 1136 break;
1137 } 1137 }
1138 //printk("vortex: cfg0 = 0x%x\nvortex: cfg1=0x%x\n", dma->cfg0, dma->cfg1); 1138 /*
1139 printk(KERN_DEBUG "vortex: cfg0 = 0x%x\nvortex: cfg1=0x%x\n",
1140 dma->cfg0, dma->cfg1);
1141 */
1139 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0); 1142 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG0 + (adbdma << 3), dma->cfg0);
1140 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1); 1143 hwwrite(vortex->mmio, VORTEX_ADBDMA_BUFCFG1 + (adbdma << 3), dma->cfg1);
1141 1144
@@ -1959,7 +1962,7 @@ vortex_connect_codecplay(vortex_t * vortex, int en, unsigned char mixers[])
1959 ADB_CODECOUT(0 + 4)); 1962 ADB_CODECOUT(0 + 4));
1960 vortex_connection_mix_adb(vortex, en, 0x11, mixers[3], 1963 vortex_connection_mix_adb(vortex, en, 0x11, mixers[3],
1961 ADB_CODECOUT(1 + 4)); 1964 ADB_CODECOUT(1 + 4));
1962 //printk("SDAC detected "); 1965 /* printk(KERN_DEBUG "SDAC detected "); */
1963 } 1966 }
1964#else 1967#else
1965 // Use plain direct output to codec. 1968 // Use plain direct output to codec.
@@ -2013,7 +2016,11 @@ vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out, int restype)
2013 resmap[restype] |= (1 << i); 2016 resmap[restype] |= (1 << i);
2014 else 2017 else
2015 vortex->dma_adb[i].resources[restype] |= (1 << i); 2018 vortex->dma_adb[i].resources[restype] |= (1 << i);
2016 //printk("vortex: ResManager: type %d out %d\n", restype, i); 2019 /*
2020 printk(KERN_DEBUG
2021 "vortex: ResManager: type %d out %d\n",
2022 restype, i);
2023 */
2017 return i; 2024 return i;
2018 } 2025 }
2019 } 2026 }
@@ -2024,7 +2031,11 @@ vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out, int restype)
2024 for (i = 0; i < qty; i++) { 2031 for (i = 0; i < qty; i++) {
2025 if (resmap[restype] & (1 << i)) { 2032 if (resmap[restype] & (1 << i)) {
2026 resmap[restype] &= ~(1 << i); 2033 resmap[restype] &= ~(1 << i);
2027 //printk("vortex: ResManager: type %d in %d\n",restype, i); 2034 /*
2035 printk(KERN_DEBUG
2036 "vortex: ResManager: type %d in %d\n",
2037 restype, i);
2038 */
2028 return i; 2039 return i;
2029 } 2040 }
2030 } 2041 }
@@ -2789,7 +2800,7 @@ vortex_translateformat(vortex_t * vortex, char bits, char nch, int encod)
2789{ 2800{
2790 int a, this_194; 2801 int a, this_194;
2791 2802
2792 if ((bits != 8) || (bits != 16)) 2803 if ((bits != 8) && (bits != 16))
2793 return -1; 2804 return -1;
2794 2805
2795 switch (encod) { 2806 switch (encod) {
diff --git a/sound/pci/au88x0/au88x0_synth.c b/sound/pci/au88x0/au88x0_synth.c
index 978b856f5621..2805e34bd41d 100644
--- a/sound/pci/au88x0/au88x0_synth.c
+++ b/sound/pci/au88x0/au88x0_synth.c
@@ -213,38 +213,59 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
213 switch (reg) { 213 switch (reg) {
214 /* Voice specific parameters */ 214 /* Voice specific parameters */
215 case 0: /* running */ 215 case 0: /* running */
216 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_RUN(wt), (int)val); 216 /*
217 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
218 WT_RUN(wt), (int)val);
219 */
217 hwwrite(vortex->mmio, WT_RUN(wt), val); 220 hwwrite(vortex->mmio, WT_RUN(wt), val);
218 return 0xc; 221 return 0xc;
219 break; 222 break;
220 case 1: /* param 0 */ 223 case 1: /* param 0 */
221 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,0), (int)val); 224 /*
225 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
226 WT_PARM(wt,0), (int)val);
227 */
222 hwwrite(vortex->mmio, WT_PARM(wt, 0), val); 228 hwwrite(vortex->mmio, WT_PARM(wt, 0), val);
223 return 0xc; 229 return 0xc;
224 break; 230 break;
225 case 2: /* param 1 */ 231 case 2: /* param 1 */
226 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,1), (int)val); 232 /*
233 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
234 WT_PARM(wt,1), (int)val);
235 */
227 hwwrite(vortex->mmio, WT_PARM(wt, 1), val); 236 hwwrite(vortex->mmio, WT_PARM(wt, 1), val);
228 return 0xc; 237 return 0xc;
229 break; 238 break;
230 case 3: /* param 2 */ 239 case 3: /* param 2 */
231 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,2), (int)val); 240 /*
241 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
242 WT_PARM(wt,2), (int)val);
243 */
232 hwwrite(vortex->mmio, WT_PARM(wt, 2), val); 244 hwwrite(vortex->mmio, WT_PARM(wt, 2), val);
233 return 0xc; 245 return 0xc;
234 break; 246 break;
235 case 4: /* param 3 */ 247 case 4: /* param 3 */
236 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_PARM(wt,3), (int)val); 248 /*
249 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
250 WT_PARM(wt,3), (int)val);
251 */
237 hwwrite(vortex->mmio, WT_PARM(wt, 3), val); 252 hwwrite(vortex->mmio, WT_PARM(wt, 3), val);
238 return 0xc; 253 return 0xc;
239 break; 254 break;
240 case 6: /* mute */ 255 case 6: /* mute */
241 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_MUTE(wt), (int)val); 256 /*
257 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
258 WT_MUTE(wt), (int)val);
259 */
242 hwwrite(vortex->mmio, WT_MUTE(wt), val); 260 hwwrite(vortex->mmio, WT_MUTE(wt), val);
243 return 0xc; 261 return 0xc;
244 break; 262 break;
245 case 0xb: 263 case 0xb:
246 { /* delay */ 264 { /* delay */
247 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", WT_DELAY(wt,0), (int)val); 265 /*
266 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
267 WT_DELAY(wt,0), (int)val);
268 */
248 hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); 269 hwwrite(vortex->mmio, WT_DELAY(wt, 3), val);
249 hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); 270 hwwrite(vortex->mmio, WT_DELAY(wt, 2), val);
250 hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); 271 hwwrite(vortex->mmio, WT_DELAY(wt, 1), val);
@@ -272,7 +293,9 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt,
272 return 0; 293 return 0;
273 break; 294 break;
274 } 295 }
275 //printk("vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val); 296 /*
297 printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val);
298 */
276 hwwrite(vortex->mmio, ecx, val); 299 hwwrite(vortex->mmio, ecx, val);
277 return 1; 300 return 1;
278} 301}
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index eefcbf648ee1..4d34bb0d99d3 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -165,7 +165,7 @@ module_param_array(enable, bool, NULL, 0444);
165MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard."); 165MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard.");
166 166
167static struct pci_device_id snd_aw2_ids[] = { 167static struct pci_device_id snd_aw2_ids[] = {
168 {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, PCI_ANY_ID, PCI_ANY_ID, 168 {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, 0, 0,
169 0, 0, 0}, 169 0, 0, 0},
170 {0} 170 {0}
171}; 171};
@@ -279,8 +279,8 @@ static int __devinit snd_aw2_create(struct snd_card *card,
279 pci_set_master(pci); 279 pci_set_master(pci);
280 280
281 /* check PCI availability (32bit DMA) */ 281 /* check PCI availability (32bit DMA) */
282 if ((pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) || 282 if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) ||
283 (pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0)) { 283 (pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) {
284 printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n"); 284 printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n");
285 pci_disable_device(pci); 285 pci_disable_device(pci);
286 return -ENXIO; 286 return -ENXIO;
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 1df96e76c483..f290bc56178f 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -211,25 +211,25 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
211#endif 211#endif
212 212
213#if DEBUG_MIXER 213#if DEBUG_MIXER
214#define snd_azf3328_dbgmixer(format, args...) printk(format, ##args) 214#define snd_azf3328_dbgmixer(format, args...) printk(KERN_DEBUG format, ##args)
215#else 215#else
216#define snd_azf3328_dbgmixer(format, args...) 216#define snd_azf3328_dbgmixer(format, args...)
217#endif 217#endif
218 218
219#if DEBUG_PLAY_REC 219#if DEBUG_PLAY_REC
220#define snd_azf3328_dbgplay(format, args...) printk(KERN_ERR format, ##args) 220#define snd_azf3328_dbgplay(format, args...) printk(KERN_DEBUG format, ##args)
221#else 221#else
222#define snd_azf3328_dbgplay(format, args...) 222#define snd_azf3328_dbgplay(format, args...)
223#endif 223#endif
224 224
225#if DEBUG_MISC 225#if DEBUG_MISC
226#define snd_azf3328_dbgtimer(format, args...) printk(KERN_ERR format, ##args) 226#define snd_azf3328_dbgtimer(format, args...) printk(KERN_DEBUG format, ##args)
227#else 227#else
228#define snd_azf3328_dbgtimer(format, args...) 228#define snd_azf3328_dbgtimer(format, args...)
229#endif 229#endif
230 230
231#if DEBUG_GAME 231#if DEBUG_GAME
232#define snd_azf3328_dbggame(format, args...) printk(KERN_ERR format, ##args) 232#define snd_azf3328_dbggame(format, args...) printk(KERN_DEBUG format, ##args)
233#else 233#else
234#define snd_azf3328_dbggame(format, args...) 234#define snd_azf3328_dbggame(format, args...)
235#endif 235#endif
@@ -2125,8 +2125,8 @@ snd_azf3328_create(struct snd_card *card,
2125 chip->irq = -1; 2125 chip->irq = -1;
2126 2126
2127 /* check if we can restrict PCI DMA transfers to 24 bits */ 2127 /* check if we can restrict PCI DMA transfers to 24 bits */
2128 if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 || 2128 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
2129 pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) { 2129 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
2130 snd_printk(KERN_ERR "architecture does not support " 2130 snd_printk(KERN_ERR "architecture does not support "
2131 "24bit PCI busmaster DMA\n" 2131 "24bit PCI busmaster DMA\n"
2132 ); 2132 );
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index a299340519df..ce3f2e90f4d7 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -349,7 +349,8 @@ static struct snd_pcm_hardware snd_bt87x_digital_hw = {
349 .info = SNDRV_PCM_INFO_MMAP | 349 .info = SNDRV_PCM_INFO_MMAP |
350 SNDRV_PCM_INFO_INTERLEAVED | 350 SNDRV_PCM_INFO_INTERLEAVED |
351 SNDRV_PCM_INFO_BLOCK_TRANSFER | 351 SNDRV_PCM_INFO_BLOCK_TRANSFER |
352 SNDRV_PCM_INFO_MMAP_VALID, 352 SNDRV_PCM_INFO_MMAP_VALID |
353 SNDRV_PCM_INFO_BATCH,
353 .formats = SNDRV_PCM_FMTBIT_S16_LE, 354 .formats = SNDRV_PCM_FMTBIT_S16_LE,
354 .rates = 0, /* set at runtime */ 355 .rates = 0, /* set at runtime */
355 .channels_min = 2, 356 .channels_min = 2,
@@ -365,7 +366,8 @@ static struct snd_pcm_hardware snd_bt87x_analog_hw = {
365 .info = SNDRV_PCM_INFO_MMAP | 366 .info = SNDRV_PCM_INFO_MMAP |
366 SNDRV_PCM_INFO_INTERLEAVED | 367 SNDRV_PCM_INFO_INTERLEAVED |
367 SNDRV_PCM_INFO_BLOCK_TRANSFER | 368 SNDRV_PCM_INFO_BLOCK_TRANSFER |
368 SNDRV_PCM_INFO_MMAP_VALID, 369 SNDRV_PCM_INFO_MMAP_VALID |
370 SNDRV_PCM_INFO_BATCH,
369 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8, 371 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8,
370 .rates = SNDRV_PCM_RATE_KNOT, 372 .rates = SNDRV_PCM_RATE_KNOT,
371 .rate_min = ANALOG_CLOCK / CLOCK_DIV_MAX, 373 .rate_min = ANALOG_CLOCK / CLOCK_DIV_MAX,
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index b116456e7707..bfac30f7929f 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -255,6 +255,14 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
255 .gpio_type = 2, 255 .gpio_type = 2,
256 .i2c_adc = 1, 256 .i2c_adc = 1,
257 .spi_dac = 1 } , 257 .spi_dac = 1 } ,
258 /* Giga-byte GA-G1975X mobo
259 * Novell bnc#395807
260 */
261 /* FIXME: the GPIO and I2C setting aren't tested well */
262 { .serial = 0x1458a006,
263 .name = "Giga-byte GA-G1975X",
264 .gpio_type = 1,
265 .i2c_adc = 1 },
258 /* Shuttle XPC SD31P which has an onboard Creative Labs 266 /* Shuttle XPC SD31P which has an onboard Creative Labs
259 * Sound Blaster Live! 24-bit EAX 267 * Sound Blaster Live! 24-bit EAX
260 * high-definition 7.1 audio processor". 268 * high-definition 7.1 audio processor".
@@ -404,7 +412,9 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
404 } 412 }
405 413
406 tmp = reg << 25 | value << 16; 414 tmp = reg << 25 | value << 16;
407 // snd_printk("I2C-write:reg=0x%x, value=0x%x\n", reg, value); 415 /*
416 snd_printk(KERN_DEBUG "I2C-write:reg=0x%x, value=0x%x\n", reg, value);
417 */
408 /* Not sure what this I2C channel controls. */ 418 /* Not sure what this I2C channel controls. */
409 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ 419 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */
410 420
@@ -422,7 +432,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
422 /* Wait till the transaction ends */ 432 /* Wait till the transaction ends */
423 while (1) { 433 while (1) {
424 status = snd_ca0106_ptr_read(emu, I2C_A, 0); 434 status = snd_ca0106_ptr_read(emu, I2C_A, 0);
425 //snd_printk("I2C:status=0x%x\n", status); 435 /*snd_printk(KERN_DEBUG "I2C:status=0x%x\n", status);*/
426 timeout++; 436 timeout++;
427 if ((status & I2C_A_ADC_START) == 0) 437 if ((status & I2C_A_ADC_START) == 0)
428 break; 438 break;
@@ -521,7 +531,10 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
521 channel->number = channel_id; 531 channel->number = channel_id;
522 532
523 channel->use = 1; 533 channel->use = 1;
524 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 534 /*
535 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
536 channel_id, chip, channel);
537 */
525 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 538 //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
526 channel->epcm = epcm; 539 channel->epcm = epcm;
527 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 540 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
@@ -614,7 +627,10 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
614 channel->number = channel_id; 627 channel->number = channel_id;
615 628
616 channel->use = 1; 629 channel->use = 1;
617 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 630 /*
631 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
632 channel_id, chip, channel);
633 */
618 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 634 //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
619 channel->epcm = epcm; 635 channel->epcm = epcm;
620 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 636 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
@@ -705,9 +721,20 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream)
705 u32 reg71; 721 u32 reg71;
706 int i; 722 int i;
707 723
708 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); 724#if 0 /* debug */
709 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); 725 snd_printk(KERN_DEBUG
710 //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); 726 "prepare:channel_number=%d, rate=%d, format=0x%x, "
727 "channels=%d, buffer_size=%ld, period_size=%ld, "
728 "periods=%u, frames_to_bytes=%d\n",
729 channel, runtime->rate, runtime->format,
730 runtime->channels, runtime->buffer_size,
731 runtime->period_size, runtime->periods,
732 frames_to_bytes(runtime, 1));
733 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
734 runtime->dma_addr, runtime->dma_area, table_base);
735 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
736 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
737#endif /* debug */
711 /* Rate can be set per channel. */ 738 /* Rate can be set per channel. */
712 /* reg40 control host to fifo */ 739 /* reg40 control host to fifo */
713 /* reg71 controls DAC rate. */ 740 /* reg71 controls DAC rate. */
@@ -799,9 +826,20 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
799 u32 reg71_set = 0; 826 u32 reg71_set = 0;
800 u32 reg71; 827 u32 reg71;
801 828
802 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); 829#if 0 /* debug */
803 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); 830 snd_printk(KERN_DEBUG
804 //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); 831 "prepare:channel_number=%d, rate=%d, format=0x%x, "
832 "channels=%d, buffer_size=%ld, period_size=%ld, "
833 "periods=%u, frames_to_bytes=%d\n",
834 channel, runtime->rate, runtime->format,
835 runtime->channels, runtime->buffer_size,
836 runtime->period_size, runtime->periods,
837 frames_to_bytes(runtime, 1));
838 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
839 runtime->dma_addr, runtime->dma_area, table_base);
840 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
841 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
842#endif /* debug */
805 /* reg71 controls ADC rate. */ 843 /* reg71 controls ADC rate. */
806 switch (runtime->rate) { 844 switch (runtime->rate) {
807 case 44100: 845 case 44100:
@@ -846,7 +884,14 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
846 } 884 }
847 885
848 886
849 //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); 887 /*
888 printk(KERN_DEBUG
889 "prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, "
890 "buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",
891 channel, runtime->rate, runtime->format, runtime->channels,
892 runtime->buffer_size, runtime->period_size,
893 frames_to_bytes(runtime, 1));
894 */
850 snd_ca0106_ptr_write(emu, 0x13, channel, 0); 895 snd_ca0106_ptr_write(emu, 0x13, channel, 0);
851 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); 896 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
852 snd_ca0106_ptr_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes 897 snd_ca0106_ptr_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes
@@ -888,13 +933,13 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
888 runtime = s->runtime; 933 runtime = s->runtime;
889 epcm = runtime->private_data; 934 epcm = runtime->private_data;
890 channel = epcm->channel_id; 935 channel = epcm->channel_id;
891 /* snd_printk("channel=%d\n",channel); */ 936 /* snd_printk(KERN_DEBUG "channel=%d\n", channel); */
892 epcm->running = running; 937 epcm->running = running;
893 basic |= (0x1 << channel); 938 basic |= (0x1 << channel);
894 extended |= (0x10 << channel); 939 extended |= (0x10 << channel);
895 snd_pcm_trigger_done(s, substream); 940 snd_pcm_trigger_done(s, substream);
896 } 941 }
897 /* snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); */ 942 /* snd_printk(KERN_DEBUG "basic=0x%x, extended=0x%x\n",basic, extended); */
898 943
899 switch (cmd) { 944 switch (cmd) {
900 case SNDRV_PCM_TRIGGER_START: 945 case SNDRV_PCM_TRIGGER_START:
@@ -972,8 +1017,13 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream)
972 ptr=ptr2; 1017 ptr=ptr2;
973 if (ptr >= runtime->buffer_size) 1018 if (ptr >= runtime->buffer_size)
974 ptr -= runtime->buffer_size; 1019 ptr -= runtime->buffer_size;
975 //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); 1020 /*
976 1021 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
1022 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
1023 ptr1, ptr2, ptr, (int)runtime->buffer_size,
1024 (int)runtime->period_size, (int)runtime->frame_bits,
1025 (int)runtime->rate);
1026 */
977 return ptr; 1027 return ptr;
978} 1028}
979 1029
@@ -995,8 +1045,13 @@ snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream)
995 ptr=ptr2; 1045 ptr=ptr2;
996 if (ptr >= runtime->buffer_size) 1046 if (ptr >= runtime->buffer_size)
997 ptr -= runtime->buffer_size; 1047 ptr -= runtime->buffer_size;
998 //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); 1048 /*
999 1049 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
1050 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
1051 ptr1, ptr2, ptr, (int)runtime->buffer_size,
1052 (int)runtime->period_size, (int)runtime->frame_bits,
1053 (int)runtime->rate);
1054 */
1000 return ptr; 1055 return ptr;
1001} 1056}
1002 1057
@@ -1181,8 +1236,12 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
1181 return IRQ_NONE; 1236 return IRQ_NONE;
1182 1237
1183 stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0); 1238 stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0);
1184 //snd_printk("interrupt status = 0x%08x, stat76=0x%08x\n", status, stat76); 1239 /*
1185 //snd_printk("ptr=0x%08x\n",snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0)); 1240 snd_printk(KERN_DEBUG "interrupt status = 0x%08x, stat76=0x%08x\n",
1241 status, stat76);
1242 snd_printk(KERN_DEBUG "ptr=0x%08x\n",
1243 snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0));
1244 */
1186 mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */ 1245 mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */
1187 for(i = 0; i < 4; i++) { 1246 for(i = 0; i < 4; i++) {
1188 pchannel = &(chip->playback_channels[i]); 1247 pchannel = &(chip->playback_channels[i]);
@@ -1470,7 +1529,7 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
1470 int size, n; 1529 int size, n;
1471 1530
1472 size = ARRAY_SIZE(i2c_adc_init); 1531 size = ARRAY_SIZE(i2c_adc_init);
1473 /* snd_printk("I2C:array size=0x%x\n", size); */ 1532 /* snd_printk(KERN_DEBUG "I2C:array size=0x%x\n", size); */
1474 for (n = 0; n < size; n++) 1533 for (n = 0; n < size; n++)
1475 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], 1534 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
1476 i2c_adc_init[n][1]); 1535 i2c_adc_init[n][1]);
@@ -1530,8 +1589,8 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1530 err = pci_enable_device(pci); 1589 err = pci_enable_device(pci);
1531 if (err < 0) 1590 if (err < 0)
1532 return err; 1591 return err;
1533 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || 1592 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
1534 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { 1593 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1535 printk(KERN_ERR "error to set 32bit mask DMA\n"); 1594 printk(KERN_ERR "error to set 32bit mask DMA\n");
1536 pci_disable_device(pci); 1595 pci_disable_device(pci);
1537 return -ENXIO; 1596 return -ENXIO;
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index c7899c32aba1..449fe02f666e 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3014,7 +3014,7 @@ static int __devinit snd_cmipci_create(struct snd_card *card, struct pci_dev *pc
3014 .dev_free = snd_cmipci_dev_free, 3014 .dev_free = snd_cmipci_dev_free,
3015 }; 3015 };
3016 unsigned int val; 3016 unsigned int val;
3017 long iomidi; 3017 long iomidi = 0;
3018 int integrated_midi = 0; 3018 int integrated_midi = 0;
3019 char modelstr[16]; 3019 char modelstr[16];
3020 int pcm_index, pcm_spdif_index; 3020 int pcm_index, pcm_spdif_index;
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index b9b07f464631..f6286f84a221 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -834,7 +834,11 @@ static snd_pcm_uframes_t snd_cs4281_pointer(struct snd_pcm_substream *substream)
834 struct cs4281_dma *dma = runtime->private_data; 834 struct cs4281_dma *dma = runtime->private_data;
835 struct cs4281 *chip = snd_pcm_substream_chip(substream); 835 struct cs4281 *chip = snd_pcm_substream_chip(substream);
836 836
837 // printk("DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n", snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size, jiffies); 837 /*
838 printk(KERN_DEBUG "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n",
839 snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size,
840 jiffies);
841 */
838 return runtime->buffer_size - 842 return runtime->buffer_size -
839 snd_cs4281_peekBA0(chip, dma->regDCC) - 1; 843 snd_cs4281_peekBA0(chip, dma->regDCC) - 1;
840} 844}
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 8ab07aa63652..1be96ead4244 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -194,7 +194,7 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
194 * ACSDA = Status Data Register = 474h 194 * ACSDA = Status Data Register = 474h
195 */ 195 */
196#if 0 196#if 0
197 printk("e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg, 197 printk(KERN_DEBUG "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
198 snd_cs46xx_peekBA0(chip, BA0_ACSDA), 198 snd_cs46xx_peekBA0(chip, BA0_ACSDA),
199 snd_cs46xx_peekBA0(chip, BA0_ACCAD)); 199 snd_cs46xx_peekBA0(chip, BA0_ACCAD));
200#endif 200#endif
@@ -428,8 +428,8 @@ static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout)
428 } 428 }
429 429
430 if(status & SERBST_WBSY) { 430 if(status & SERBST_WBSY) {
431 snd_printk( KERN_ERR "cs46xx: failure waiting for FIFO command to complete\n"); 431 snd_printk(KERN_ERR "cs46xx: failure waiting for "
432 432 "FIFO command to complete\n");
433 return -EINVAL; 433 return -EINVAL;
434 } 434 }
435 435
diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h
index 018a7de56017..4eb55aa33612 100644
--- a/sound/pci/cs46xx/cs46xx_lib.h
+++ b/sound/pci/cs46xx/cs46xx_lib.h
@@ -62,7 +62,11 @@ static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, u
62 unsigned int bank = reg >> 16; 62 unsigned int bank = reg >> 16;
63 unsigned int offset = reg & 0xffff; 63 unsigned int offset = reg & 0xffff;
64 64
65 /*if (bank == 0) printk("snd_cs46xx_poke: %04X - %08X\n",reg >> 2,val); */ 65 /*
66 if (bank == 0)
67 printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
68 reg >> 2,val);
69 */
66 writel(val, chip->region.idx[bank+1].remap_addr + offset); 70 writel(val, chip->region.idx[bank+1].remap_addr + offset);
67} 71}
68 72
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index ac1d72e0a1e4..05f56e04849b 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -285,8 +285,8 @@ static int __devinit snd_cs5535audio_create(struct snd_card *card,
285 if ((err = pci_enable_device(pci)) < 0) 285 if ((err = pci_enable_device(pci)) < 0)
286 return err; 286 return err;
287 287
288 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || 288 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
289 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { 289 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
290 printk(KERN_WARNING "unable to get 32bit dma\n"); 290 printk(KERN_WARNING "unable to get 32bit dma\n");
291 err = -ENXIO; 291 err = -ENXIO;
292 goto pcifail; 292 goto pcifail;
@@ -312,7 +312,7 @@ static int __devinit snd_cs5535audio_create(struct snd_card *card,
312 312
313 if (request_irq(pci->irq, snd_cs5535audio_interrupt, 313 if (request_irq(pci->irq, snd_cs5535audio_interrupt,
314 IRQF_SHARED, "CS5535 Audio", cs5535au)) { 314 IRQF_SHARED, "CS5535 Audio", cs5535au)) {
315 snd_printk("unable to grab IRQ %d\n", pci->irq); 315 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
316 err = -EBUSY; 316 err = -EBUSY;
317 goto sndfail; 317 goto sndfail;
318 } 318 }
diff --git a/sound/pci/echoaudio/Makefile b/sound/pci/echoaudio/Makefile
index 7b576aeb3f8d..1361de77e0cd 100644
--- a/sound/pci/echoaudio/Makefile
+++ b/sound/pci/echoaudio/Makefile
@@ -15,6 +15,8 @@ snd-echo3g-objs := echo3g.o
15snd-indigo-objs := indigo.o 15snd-indigo-objs := indigo.o
16snd-indigoio-objs := indigoio.o 16snd-indigoio-objs := indigoio.o
17snd-indigodj-objs := indigodj.o 17snd-indigodj-objs := indigodj.o
18snd-indigoiox-objs := indigoiox.o
19snd-indigodjx-objs := indigodjx.o
18 20
19obj-$(CONFIG_SND_DARLA20) += snd-darla20.o 21obj-$(CONFIG_SND_DARLA20) += snd-darla20.o
20obj-$(CONFIG_SND_GINA20) += snd-gina20.o 22obj-$(CONFIG_SND_GINA20) += snd-gina20.o
@@ -28,3 +30,5 @@ obj-$(CONFIG_SND_ECHO3G) += snd-echo3g.o
28obj-$(CONFIG_SND_INDIGO) += snd-indigo.o 30obj-$(CONFIG_SND_INDIGO) += snd-indigo.o
29obj-$(CONFIG_SND_INDIGOIO) += snd-indigoio.o 31obj-$(CONFIG_SND_INDIGOIO) += snd-indigoio.o
30obj-$(CONFIG_SND_INDIGODJ) += snd-indigodj.o 32obj-$(CONFIG_SND_INDIGODJ) += snd-indigodj.o
33obj-$(CONFIG_SND_INDIGOIOX) += snd-indigoiox.o
34obj-$(CONFIG_SND_INDIGODJX) += snd-indigodjx.o
diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c
index 417e25add82b..57967e580571 100644
--- a/sound/pci/echoaudio/echo3g_dsp.c
+++ b/sound/pci/echoaudio/echo3g_dsp.c
@@ -56,7 +56,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
56 } 56 }
57 57
58 chip->comm_page->e3g_frq_register = 58 chip->comm_page->e3g_frq_register =
59 __constant_cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2); 59 cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2);
60 chip->device_id = device_id; 60 chip->device_id = device_id;
61 chip->subdevice_id = subdevice_id; 61 chip->subdevice_id = subdevice_id;
62 chip->bad_board = TRUE; 62 chip->bad_board = TRUE;
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 9d015a76eb69..da2065cd2c0d 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -950,6 +950,8 @@ static int __devinit snd_echo_new_pcm(struct echoaudio *chip)
950 Control interface 950 Control interface
951******************************************************************************/ 951******************************************************************************/
952 952
953#ifndef ECHOCARD_HAS_VMIXER
954
953/******************* PCM output volume *******************/ 955/******************* PCM output volume *******************/
954static int snd_echo_output_gain_info(struct snd_kcontrol *kcontrol, 956static int snd_echo_output_gain_info(struct snd_kcontrol *kcontrol,
955 struct snd_ctl_elem_info *uinfo) 957 struct snd_ctl_elem_info *uinfo)
@@ -1001,18 +1003,6 @@ static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
1001 return changed; 1003 return changed;
1002} 1004}
1003 1005
1004#ifdef ECHOCARD_HAS_VMIXER
1005/* On Vmixer cards this one controls the line-out volume */
1006static struct snd_kcontrol_new snd_echo_line_output_gain __devinitdata = {
1007 .name = "Line Playback Volume",
1008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1009 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1010 .info = snd_echo_output_gain_info,
1011 .get = snd_echo_output_gain_get,
1012 .put = snd_echo_output_gain_put,
1013 .tlv = {.p = db_scale_output_gain},
1014};
1015#else
1016static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = { 1006static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
1017 .name = "PCM Playback Volume", 1007 .name = "PCM Playback Volume",
1018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1022,6 +1012,7 @@ static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
1022 .put = snd_echo_output_gain_put, 1012 .put = snd_echo_output_gain_put,
1023 .tlv = {.p = db_scale_output_gain}, 1013 .tlv = {.p = db_scale_output_gain},
1024}; 1014};
1015
1025#endif 1016#endif
1026 1017
1027 1018
@@ -2037,8 +2028,6 @@ static int __devinit snd_echo_probe(struct pci_dev *pci,
2037 2028
2038#ifdef ECHOCARD_HAS_VMIXER 2029#ifdef ECHOCARD_HAS_VMIXER
2039 snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip); 2030 snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip);
2040 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_output_gain, chip))) < 0)
2041 goto ctl_error;
2042 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0) 2031 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0)
2043 goto ctl_error; 2032 goto ctl_error;
2044#else 2033#else
diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h
index 1c88e051abf2..f9490ae36c2e 100644
--- a/sound/pci/echoaudio/echoaudio.h
+++ b/sound/pci/echoaudio/echoaudio.h
@@ -189,6 +189,9 @@
189#define INDIGO 0x0090 189#define INDIGO 0x0090
190#define INDIGO_IO 0x00a0 190#define INDIGO_IO 0x00a0
191#define INDIGO_DJ 0x00b0 191#define INDIGO_DJ 0x00b0
192#define DC8 0x00c0
193#define INDIGO_IOX 0x00d0
194#define INDIGO_DJX 0x00e0
192#define ECHO3G 0x0100 195#define ECHO3G 0x0100
193 196
194 197
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
index c3736bbd819e..e32a74897921 100644
--- a/sound/pci/echoaudio/echoaudio_3g.c
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -40,8 +40,7 @@ static int check_asic_status(struct echoaudio *chip)
40 if (wait_handshake(chip)) 40 if (wait_handshake(chip))
41 return -EIO; 41 return -EIO;
42 42
43 chip->comm_page->ext_box_status = 43 chip->comm_page->ext_box_status = cpu_to_le32(E3G_ASIC_NOT_LOADED);
44 __constant_cpu_to_le32(E3G_ASIC_NOT_LOADED);
45 chip->asic_loaded = FALSE; 44 chip->asic_loaded = FALSE;
46 clear_handshake(chip); 45 clear_handshake(chip);
47 send_vector(chip, DSP_VC_TEST_ASIC); 46 send_vector(chip, DSP_VC_TEST_ASIC);
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
index be0e18192de3..4df51ef5e095 100644
--- a/sound/pci/echoaudio/echoaudio_dsp.c
+++ b/sound/pci/echoaudio/echoaudio_dsp.c
@@ -926,11 +926,11 @@ static int init_dsp_comm_page(struct echoaudio *chip)
926 926
927 /* Init the comm page */ 927 /* Init the comm page */
928 chip->comm_page->comm_size = 928 chip->comm_page->comm_size =
929 __constant_cpu_to_le32(sizeof(struct comm_page)); 929 cpu_to_le32(sizeof(struct comm_page));
930 chip->comm_page->handshake = 0xffffffff; 930 chip->comm_page->handshake = 0xffffffff;
931 chip->comm_page->midi_out_free_count = 931 chip->comm_page->midi_out_free_count =
932 __constant_cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); 932 cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE);
933 chip->comm_page->sample_rate = __constant_cpu_to_le32(44100); 933 chip->comm_page->sample_rate = cpu_to_le32(44100);
934 chip->sample_rate = 44100; 934 chip->sample_rate = 44100;
935 935
936 /* Set line levels so we don't blast any inputs on startup */ 936 /* Set line levels so we don't blast any inputs on startup */
diff --git a/sound/pci/echoaudio/echoaudio_dsp.h b/sound/pci/echoaudio/echoaudio_dsp.h
index e352f3ae292c..cb7d75a0a503 100644
--- a/sound/pci/echoaudio/echoaudio_dsp.h
+++ b/sound/pci/echoaudio/echoaudio_dsp.h
@@ -576,8 +576,13 @@ SET_LAYLA24_FREQUENCY_REG command.
576#define E3G_ASIC_NOT_LOADED 0xffff 576#define E3G_ASIC_NOT_LOADED 0xffff
577#define E3G_BOX_TYPE_MASK 0xf0 577#define E3G_BOX_TYPE_MASK 0xf0
578 578
579#define EXT_3GBOX_NC 0x01 579/* Indigo express control register values */
580#define EXT_3GBOX_NOT_SET 0x02 580#define INDIGO_EXPRESS_32000 0x02
581#define INDIGO_EXPRESS_44100 0x01
582#define INDIGO_EXPRESS_48000 0x00
583#define INDIGO_EXPRESS_DOUBLE_SPEED 0x10
584#define INDIGO_EXPRESS_QUAD_SPEED 0x04
585#define INDIGO_EXPRESS_CLOCK_MASK 0x17
581 586
582 587
583/* 588/*
diff --git a/sound/pci/echoaudio/gina20_dsp.c b/sound/pci/echoaudio/gina20_dsp.c
index db6c952e9d7f..3f1e7475faea 100644
--- a/sound/pci/echoaudio/gina20_dsp.c
+++ b/sound/pci/echoaudio/gina20_dsp.c
@@ -208,10 +208,10 @@ static int set_professional_spdif(struct echoaudio *chip, char prof)
208 DE_ACT(("set_professional_spdif %d\n", prof)); 208 DE_ACT(("set_professional_spdif %d\n", prof));
209 if (prof) 209 if (prof)
210 chip->comm_page->flags |= 210 chip->comm_page->flags |=
211 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 211 cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
212 else 212 else
213 chip->comm_page->flags &= 213 chip->comm_page->flags &=
214 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 214 ~cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
215 chip->professional_spdif = prof; 215 chip->professional_spdif = prof;
216 return update_flags(chip); 216 return update_flags(chip);
217} 217}
diff --git a/sound/pci/echoaudio/indigo_dsp.c b/sound/pci/echoaudio/indigo_dsp.c
index f05e39f7aad9..0b2cd9c86277 100644
--- a/sound/pci/echoaudio/indigo_dsp.c
+++ b/sound/pci/echoaudio/indigo_dsp.c
@@ -63,18 +63,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
63 if ((err = init_line_levels(chip)) < 0) 63 if ((err = init_line_levels(chip)) < 0)
64 return err; 64 return err;
65 65
66 /* Default routing of the virtual channels: all vchannels are routed
67 to the stereo output */
68 set_vmixer_gain(chip, 0, 0, 0);
69 set_vmixer_gain(chip, 1, 1, 0);
70 set_vmixer_gain(chip, 0, 2, 0);
71 set_vmixer_gain(chip, 1, 3, 0);
72 set_vmixer_gain(chip, 0, 4, 0);
73 set_vmixer_gain(chip, 1, 5, 0);
74 set_vmixer_gain(chip, 0, 6, 0);
75 set_vmixer_gain(chip, 1, 7, 0);
76 err = update_vmixer_level(chip);
77
78 DE_INIT(("init_hw done\n")); 66 DE_INIT(("init_hw done\n"));
79 return err; 67 return err;
80} 68}
diff --git a/sound/pci/echoaudio/indigo_express_dsp.c b/sound/pci/echoaudio/indigo_express_dsp.c
new file mode 100644
index 000000000000..9ab625e15652
--- /dev/null
+++ b/sound/pci/echoaudio/indigo_express_dsp.c
@@ -0,0 +1,119 @@
1/************************************************************************
2
3This file is part of Echo Digital Audio's generic driver library.
4Copyright Echo Digital Audio Corporation (c) 1998 - 2005
5All rights reserved
6www.echoaudio.com
7
8This library is free software; you can redistribute it and/or
9modify it under the terms of the GNU Lesser General Public
10License as published by the Free Software Foundation; either
11version 2.1 of the License, or (at your option) any later version.
12
13This library is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with this library; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22*************************************************************************
23
24 Translation from C++ and adaptation for use in ALSA-Driver
25 were made by Giuliano Pochini <pochini@shiny.it>
26
27*************************************************************************/
28
29static int set_sample_rate(struct echoaudio *chip, u32 rate)
30{
31 u32 clock, control_reg, old_control_reg;
32
33 if (wait_handshake(chip))
34 return -EIO;
35
36 old_control_reg = le32_to_cpu(chip->comm_page->control_register);
37 control_reg = old_control_reg & ~INDIGO_EXPRESS_CLOCK_MASK;
38
39 switch (rate) {
40 case 32000:
41 clock = INDIGO_EXPRESS_32000;
42 break;
43 case 44100:
44 clock = INDIGO_EXPRESS_44100;
45 break;
46 case 48000:
47 clock = INDIGO_EXPRESS_48000;
48 break;
49 case 64000:
50 clock = INDIGO_EXPRESS_32000|INDIGO_EXPRESS_DOUBLE_SPEED;
51 break;
52 case 88200:
53 clock = INDIGO_EXPRESS_44100|INDIGO_EXPRESS_DOUBLE_SPEED;
54 break;
55 case 96000:
56 clock = INDIGO_EXPRESS_48000|INDIGO_EXPRESS_DOUBLE_SPEED;
57 break;
58 default:
59 return -EINVAL;
60 }
61
62 control_reg |= clock;
63 if (control_reg != old_control_reg) {
64 chip->comm_page->control_register = cpu_to_le32(control_reg);
65 chip->sample_rate = rate;
66 clear_handshake(chip);
67 return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
68 }
69 return 0;
70}
71
72
73
74/* This function routes the sound from a virtual channel to a real output */
75static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
76 int gain)
77{
78 int index;
79
80 if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
81 output >= num_busses_out(chip)))
82 return -EINVAL;
83
84 if (wait_handshake(chip))
85 return -EIO;
86
87 chip->vmixer_gain[output][pipe] = gain;
88 index = output * num_pipes_out(chip) + pipe;
89 chip->comm_page->vmixer[index] = gain;
90
91 DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));
92 return 0;
93}
94
95
96
97/* Tell the DSP to read and update virtual mixer levels in comm page. */
98static int update_vmixer_level(struct echoaudio *chip)
99{
100 if (wait_handshake(chip))
101 return -EIO;
102 clear_handshake(chip);
103 return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
104}
105
106
107
108static u32 detect_input_clocks(const struct echoaudio *chip)
109{
110 return ECHO_CLOCK_BIT_INTERNAL;
111}
112
113
114
115/* The IndigoIO has no ASIC. Just do nothing */
116static int load_asic(struct echoaudio *chip)
117{
118 return 0;
119}
diff --git a/sound/pci/echoaudio/indigodj_dsp.c b/sound/pci/echoaudio/indigodj_dsp.c
index 90730a5ecb42..08392916691e 100644
--- a/sound/pci/echoaudio/indigodj_dsp.c
+++ b/sound/pci/echoaudio/indigodj_dsp.c
@@ -63,18 +63,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
63 if ((err = init_line_levels(chip)) < 0) 63 if ((err = init_line_levels(chip)) < 0)
64 return err; 64 return err;
65 65
66 /* Default routing of the virtual channels: vchannels 0-3 and
67 vchannels 4-7 are routed to real channels 0-4 */
68 set_vmixer_gain(chip, 0, 0, 0);
69 set_vmixer_gain(chip, 1, 1, 0);
70 set_vmixer_gain(chip, 2, 2, 0);
71 set_vmixer_gain(chip, 3, 3, 0);
72 set_vmixer_gain(chip, 0, 4, 0);
73 set_vmixer_gain(chip, 1, 5, 0);
74 set_vmixer_gain(chip, 2, 6, 0);
75 set_vmixer_gain(chip, 3, 7, 0);
76 err = update_vmixer_level(chip);
77
78 DE_INIT(("init_hw done\n")); 66 DE_INIT(("init_hw done\n"));
79 return err; 67 return err;
80} 68}
diff --git a/sound/pci/echoaudio/indigodjx.c b/sound/pci/echoaudio/indigodjx.c
new file mode 100644
index 000000000000..3482ef69f491
--- /dev/null
+++ b/sound/pci/echoaudio/indigodjx.c
@@ -0,0 +1,107 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2009 Giuliano Pochini <pochini@shiny.it>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define INDIGO_FAMILY
20#define ECHOCARD_INDIGO_DJX
21#define ECHOCARD_NAME "Indigo DJx"
22#define ECHOCARD_HAS_SUPER_INTERLEAVE
23#define ECHOCARD_HAS_VMIXER
24#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
25
26/* Pipe indexes */
27#define PX_ANALOG_OUT 0 /* 8 */
28#define PX_DIGITAL_OUT 8 /* 0 */
29#define PX_ANALOG_IN 8 /* 0 */
30#define PX_DIGITAL_IN 8 /* 0 */
31#define PX_NUM 8
32
33/* Bus indexes */
34#define BX_ANALOG_OUT 0 /* 4 */
35#define BX_DIGITAL_OUT 4 /* 0 */
36#define BX_ANALOG_IN 4 /* 0 */
37#define BX_DIGITAL_IN 4 /* 0 */
38#define BX_NUM 4
39
40
41#include <linux/delay.h>
42#include <linux/init.h>
43#include <linux/interrupt.h>
44#include <linux/pci.h>
45#include <linux/slab.h>
46#include <linux/moduleparam.h>
47#include <linux/firmware.h>
48#include <linux/io.h>
49#include <sound/core.h>
50#include <sound/info.h>
51#include <sound/control.h>
52#include <sound/tlv.h>
53#include <sound/pcm.h>
54#include <sound/pcm_params.h>
55#include <sound/asoundef.h>
56#include <sound/initval.h>
57#include <asm/atomic.h>
58#include "echoaudio.h"
59
60MODULE_FIRMWARE("ea/loader_dsp.fw");
61MODULE_FIRMWARE("ea/indigo_djx_dsp.fw");
62
63#define FW_361_LOADER 0
64#define FW_INDIGO_DJX_DSP 1
65
66static const struct firmware card_fw[] = {
67 {0, "loader_dsp.fw"},
68 {0, "indigo_djx_dsp.fw"}
69};
70
71static struct pci_device_id snd_echo_ids[] = {
72 {0x1057, 0x3410, 0xECC0, 0x00E0, 0, 0, 0}, /* Indigo DJx*/
73 {0,}
74};
75
76static struct snd_pcm_hardware pcm_hardware_skel = {
77 .info = SNDRV_PCM_INFO_MMAP |
78 SNDRV_PCM_INFO_INTERLEAVED |
79 SNDRV_PCM_INFO_BLOCK_TRANSFER |
80 SNDRV_PCM_INFO_MMAP_VALID |
81 SNDRV_PCM_INFO_PAUSE |
82 SNDRV_PCM_INFO_SYNC_START,
83 .formats = SNDRV_PCM_FMTBIT_U8 |
84 SNDRV_PCM_FMTBIT_S16_LE |
85 SNDRV_PCM_FMTBIT_S24_3LE |
86 SNDRV_PCM_FMTBIT_S32_LE |
87 SNDRV_PCM_FMTBIT_S32_BE,
88 .rates = SNDRV_PCM_RATE_32000 |
89 SNDRV_PCM_RATE_44100 |
90 SNDRV_PCM_RATE_48000 |
91 SNDRV_PCM_RATE_88200 |
92 SNDRV_PCM_RATE_96000,
93 .rate_min = 32000,
94 .rate_max = 96000,
95 .channels_min = 1,
96 .channels_max = 4,
97 .buffer_bytes_max = 262144,
98 .period_bytes_min = 32,
99 .period_bytes_max = 131072,
100 .periods_min = 2,
101 .periods_max = 220,
102};
103
104#include "indigodjx_dsp.c"
105#include "indigo_express_dsp.c"
106#include "echoaudio_dsp.c"
107#include "echoaudio.c"
diff --git a/sound/pci/echoaudio/indigodjx_dsp.c b/sound/pci/echoaudio/indigodjx_dsp.c
new file mode 100644
index 000000000000..f591fc2ed960
--- /dev/null
+++ b/sound/pci/echoaudio/indigodjx_dsp.c
@@ -0,0 +1,68 @@
1/************************************************************************
2
3This file is part of Echo Digital Audio's generic driver library.
4Copyright Echo Digital Audio Corporation (c) 1998 - 2005
5All rights reserved
6www.echoaudio.com
7
8This library is free software; you can redistribute it and/or
9modify it under the terms of the GNU Lesser General Public
10License as published by the Free Software Foundation; either
11version 2.1 of the License, or (at your option) any later version.
12
13This library is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with this library; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22*************************************************************************
23
24 Translation from C++ and adaptation for use in ALSA-Driver
25 were made by Giuliano Pochini <pochini@shiny.it>
26
27*************************************************************************/
28
29static int update_vmixer_level(struct echoaudio *chip);
30static int set_vmixer_gain(struct echoaudio *chip, u16 output,
31 u16 pipe, int gain);
32
33
34static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
35{
36 int err;
37
38 DE_INIT(("init_hw() - Indigo DJx\n"));
39 if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJX))
40 return -ENODEV;
41
42 err = init_dsp_comm_page(chip);
43 if (err < 0) {
44 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
45 return err;
46 }
47
48 chip->device_id = device_id;
49 chip->subdevice_id = subdevice_id;
50 chip->bad_board = TRUE;
51 chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJX_DSP];
52 /* Since this card has no ASIC, mark it as loaded so everything
53 works OK */
54 chip->asic_loaded = TRUE;
55 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
56
57 err = load_firmware(chip);
58 if (err < 0)
59 return err;
60 chip->bad_board = FALSE;
61
62 err = init_line_levels(chip);
63 if (err < 0)
64 return err;
65
66 DE_INIT(("init_hw done\n"));
67 return err;
68}
diff --git a/sound/pci/echoaudio/indigoio_dsp.c b/sound/pci/echoaudio/indigoio_dsp.c
index a7e09ec21079..0604c8a85223 100644
--- a/sound/pci/echoaudio/indigoio_dsp.c
+++ b/sound/pci/echoaudio/indigoio_dsp.c
@@ -63,18 +63,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
63 if ((err = init_line_levels(chip)) < 0) 63 if ((err = init_line_levels(chip)) < 0)
64 return err; 64 return err;
65 65
66 /* Default routing of the virtual channels: all vchannels are routed
67 to the stereo output */
68 set_vmixer_gain(chip, 0, 0, 0);
69 set_vmixer_gain(chip, 1, 1, 0);
70 set_vmixer_gain(chip, 0, 2, 0);
71 set_vmixer_gain(chip, 1, 3, 0);
72 set_vmixer_gain(chip, 0, 4, 0);
73 set_vmixer_gain(chip, 1, 5, 0);
74 set_vmixer_gain(chip, 0, 6, 0);
75 set_vmixer_gain(chip, 1, 7, 0);
76 err = update_vmixer_level(chip);
77
78 DE_INIT(("init_hw done\n")); 66 DE_INIT(("init_hw done\n"));
79 return err; 67 return err;
80} 68}
diff --git a/sound/pci/echoaudio/indigoiox.c b/sound/pci/echoaudio/indigoiox.c
new file mode 100644
index 000000000000..aebee27a40ff
--- /dev/null
+++ b/sound/pci/echoaudio/indigoiox.c
@@ -0,0 +1,109 @@
1/*
2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2009 Giuliano Pochini <pochini@shiny.it>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define INDIGO_FAMILY
20#define ECHOCARD_INDIGO_IOX
21#define ECHOCARD_NAME "Indigo IOx"
22#define ECHOCARD_HAS_MONITOR
23#define ECHOCARD_HAS_SUPER_INTERLEAVE
24#define ECHOCARD_HAS_VMIXER
25#define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
26
27/* Pipe indexes */
28#define PX_ANALOG_OUT 0 /* 8 */
29#define PX_DIGITAL_OUT 8 /* 0 */
30#define PX_ANALOG_IN 8 /* 2 */
31#define PX_DIGITAL_IN 10 /* 0 */
32#define PX_NUM 10
33
34/* Bus indexes */
35#define BX_ANALOG_OUT 0 /* 2 */
36#define BX_DIGITAL_OUT 2 /* 0 */
37#define BX_ANALOG_IN 2 /* 2 */
38#define BX_DIGITAL_IN 4 /* 0 */
39#define BX_NUM 4
40
41
42#include <linux/delay.h>
43#include <linux/init.h>
44#include <linux/interrupt.h>
45#include <linux/pci.h>
46#include <linux/slab.h>
47#include <linux/moduleparam.h>
48#include <linux/firmware.h>
49#include <linux/io.h>
50#include <sound/core.h>
51#include <sound/info.h>
52#include <sound/control.h>
53#include <sound/tlv.h>
54#include <sound/pcm.h>
55#include <sound/pcm_params.h>
56#include <sound/asoundef.h>
57#include <sound/initval.h>
58#include <asm/atomic.h>
59#include "echoaudio.h"
60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_iox_dsp.fw");
63
64#define FW_361_LOADER 0
65#define FW_INDIGO_IOX_DSP 1
66
67static const struct firmware card_fw[] = {
68 {0, "loader_dsp.fw"},
69 {0, "indigo_iox_dsp.fw"}
70};
71
72static struct pci_device_id snd_echo_ids[] = {
73 {0x1057, 0x3410, 0xECC0, 0x00D0, 0, 0, 0}, /* Indigo IOx */
74 {0,}
75};
76
77static struct snd_pcm_hardware pcm_hardware_skel = {
78 .info = SNDRV_PCM_INFO_MMAP |
79 SNDRV_PCM_INFO_INTERLEAVED |
80 SNDRV_PCM_INFO_BLOCK_TRANSFER |
81 SNDRV_PCM_INFO_MMAP_VALID |
82 SNDRV_PCM_INFO_PAUSE |
83 SNDRV_PCM_INFO_SYNC_START,
84 .formats = SNDRV_PCM_FMTBIT_U8 |
85 SNDRV_PCM_FMTBIT_S16_LE |
86 SNDRV_PCM_FMTBIT_S24_3LE |
87 SNDRV_PCM_FMTBIT_S32_LE |
88 SNDRV_PCM_FMTBIT_S32_BE,
89 .rates = SNDRV_PCM_RATE_32000 |
90 SNDRV_PCM_RATE_44100 |
91 SNDRV_PCM_RATE_48000 |
92 SNDRV_PCM_RATE_88200 |
93 SNDRV_PCM_RATE_96000,
94 .rate_min = 32000,
95 .rate_max = 96000,
96 .channels_min = 1,
97 .channels_max = 8,
98 .buffer_bytes_max = 262144,
99 .period_bytes_min = 32,
100 .period_bytes_max = 131072,
101 .periods_min = 2,
102 .periods_max = 220,
103};
104
105#include "indigoiox_dsp.c"
106#include "indigo_express_dsp.c"
107#include "echoaudio_dsp.c"
108#include "echoaudio.c"
109
diff --git a/sound/pci/echoaudio/indigoiox_dsp.c b/sound/pci/echoaudio/indigoiox_dsp.c
new file mode 100644
index 000000000000..f357521c79e6
--- /dev/null
+++ b/sound/pci/echoaudio/indigoiox_dsp.c
@@ -0,0 +1,68 @@
1/************************************************************************
2
3This file is part of Echo Digital Audio's generic driver library.
4Copyright Echo Digital Audio Corporation (c) 1998 - 2005
5All rights reserved
6www.echoaudio.com
7
8This library is free software; you can redistribute it and/or
9modify it under the terms of the GNU Lesser General Public
10License as published by the Free Software Foundation; either
11version 2.1 of the License, or (at your option) any later version.
12
13This library is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with this library; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22*************************************************************************
23
24 Translation from C++ and adaptation for use in ALSA-Driver
25 were made by Giuliano Pochini <pochini@shiny.it>
26
27*************************************************************************/
28
29static int update_vmixer_level(struct echoaudio *chip);
30static int set_vmixer_gain(struct echoaudio *chip, u16 output,
31 u16 pipe, int gain);
32
33
34static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
35{
36 int err;
37
38 DE_INIT(("init_hw() - Indigo IOx\n"));
39 if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IOX))
40 return -ENODEV;
41
42 err = init_dsp_comm_page(chip);
43 if (err < 0) {
44 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
45 return err;
46 }
47
48 chip->device_id = device_id;
49 chip->subdevice_id = subdevice_id;
50 chip->bad_board = TRUE;
51 chip->dsp_code_to_load = &card_fw[FW_INDIGO_IOX_DSP];
52 /* Since this card has no ASIC, mark it as loaded so everything
53 works OK */
54 chip->asic_loaded = TRUE;
55 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
56
57 err = load_firmware(chip);
58 if (err < 0)
59 return err;
60 chip->bad_board = FALSE;
61
62 err = init_line_levels(chip);
63 if (err < 0)
64 return err;
65
66 DE_INIT(("init_hw done\n"));
67 return err;
68}
diff --git a/sound/pci/echoaudio/layla20_dsp.c b/sound/pci/echoaudio/layla20_dsp.c
index ede75c6ca0fb..83750e9fd7b4 100644
--- a/sound/pci/echoaudio/layla20_dsp.c
+++ b/sound/pci/echoaudio/layla20_dsp.c
@@ -284,10 +284,10 @@ static int set_professional_spdif(struct echoaudio *chip, char prof)
284 DE_ACT(("set_professional_spdif %d\n", prof)); 284 DE_ACT(("set_professional_spdif %d\n", prof));
285 if (prof) 285 if (prof)
286 chip->comm_page->flags |= 286 chip->comm_page->flags |=
287 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 287 cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
288 else 288 else
289 chip->comm_page->flags &= 289 chip->comm_page->flags &=
290 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 290 ~cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
291 chip->professional_spdif = prof; 291 chip->professional_spdif = prof;
292 return update_flags(chip); 292 return update_flags(chip);
293} 293}
diff --git a/sound/pci/echoaudio/mia_dsp.c b/sound/pci/echoaudio/mia_dsp.c
index 227386602f9b..551405114cbc 100644
--- a/sound/pci/echoaudio/mia_dsp.c
+++ b/sound/pci/echoaudio/mia_dsp.c
@@ -69,18 +69,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
69 if ((err = init_line_levels(chip))) 69 if ((err = init_line_levels(chip)))
70 return err; 70 return err;
71 71
72 /* Default routing of the virtual channels: vchannels 0-3 go to analog
73 outputs and vchannels 4-7 go to S/PDIF outputs */
74 set_vmixer_gain(chip, 0, 0, 0);
75 set_vmixer_gain(chip, 1, 1, 0);
76 set_vmixer_gain(chip, 0, 2, 0);
77 set_vmixer_gain(chip, 1, 3, 0);
78 set_vmixer_gain(chip, 2, 4, 0);
79 set_vmixer_gain(chip, 3, 5, 0);
80 set_vmixer_gain(chip, 2, 6, 0);
81 set_vmixer_gain(chip, 3, 7, 0);
82 err = update_vmixer_level(chip);
83
84 DE_INIT(("init_hw done\n")); 72 DE_INIT(("init_hw done\n"));
85 return err; 73 return err;
86} 74}
@@ -222,10 +210,10 @@ static int set_professional_spdif(struct echoaudio *chip, char prof)
222 DE_ACT(("set_professional_spdif %d\n", prof)); 210 DE_ACT(("set_professional_spdif %d\n", prof));
223 if (prof) 211 if (prof)
224 chip->comm_page->flags |= 212 chip->comm_page->flags |=
225 __constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 213 cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
226 else 214 else
227 chip->comm_page->flags &= 215 chip->comm_page->flags &=
228 ~__constant_cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF); 216 ~cpu_to_le32(DSP_FLAG_PROFESSIONAL_SPDIF);
229 chip->professional_spdif = prof; 217 chip->professional_spdif = prof;
230 return update_flags(chip); 218 return update_flags(chip);
231} 219}
diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c
index 77bf2a83d997..a953d142cb4b 100644
--- a/sound/pci/echoaudio/midi.c
+++ b/sound/pci/echoaudio/midi.c
@@ -44,10 +44,10 @@ static int enable_midi_input(struct echoaudio *chip, char enable)
44 if (enable) { 44 if (enable) {
45 chip->mtc_state = MIDI_IN_STATE_NORMAL; 45 chip->mtc_state = MIDI_IN_STATE_NORMAL;
46 chip->comm_page->flags |= 46 chip->comm_page->flags |=
47 __constant_cpu_to_le32(DSP_FLAG_MIDI_INPUT); 47 cpu_to_le32(DSP_FLAG_MIDI_INPUT);
48 } else 48 } else
49 chip->comm_page->flags &= 49 chip->comm_page->flags &=
50 ~__constant_cpu_to_le32(DSP_FLAG_MIDI_INPUT); 50 ~cpu_to_le32(DSP_FLAG_MIDI_INPUT);
51 51
52 clear_handshake(chip); 52 clear_handshake(chip);
53 return send_vector(chip, DSP_VC_UPDATE_FLAGS); 53 return send_vector(chip, DSP_VC_UPDATE_FLAGS);
diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c
index 0e649dcdbf64..7ef949d99a50 100644
--- a/sound/pci/emu10k1/emu10k1_callback.c
+++ b/sound/pci/emu10k1/emu10k1_callback.c
@@ -103,7 +103,10 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
103 int ch; 103 int ch;
104 vp = &emu->voices[best[i].voice]; 104 vp = &emu->voices[best[i].voice];
105 if ((ch = vp->ch) < 0) { 105 if ((ch = vp->ch) < 0) {
106 //printk("synth_get_voice: ch < 0 (%d) ??", i); 106 /*
107 printk(KERN_WARNING
108 "synth_get_voice: ch < 0 (%d) ??", i);
109 */
107 continue; 110 continue;
108 } 111 }
109 vp->emu->num_voices--; 112 vp->emu->num_voices--;
@@ -335,7 +338,7 @@ start_voice(struct snd_emux_voice *vp)
335 return -EINVAL; 338 return -EINVAL;
336 emem->map_locked++; 339 emem->map_locked++;
337 if (snd_emu10k1_memblk_map(hw, emem) < 0) { 340 if (snd_emu10k1_memblk_map(hw, emem) < 0) {
338 // printk("emu: cannot map!\n"); 341 /* printk(KERN_ERR "emu: cannot map!\n"); */
339 return -ENOMEM; 342 return -ENOMEM;
340 } 343 }
341 mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1; 344 mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 7958006a1d66..f18bd6207c50 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -711,8 +711,7 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, const char *filena
711static int emu1010_firmware_thread(void *data) 711static int emu1010_firmware_thread(void *data)
712{ 712{
713 struct snd_emu10k1 *emu = data; 713 struct snd_emu10k1 *emu = data;
714 int tmp, tmp2; 714 u32 tmp, tmp2, reg;
715 int reg;
716 int err; 715 int err;
717 716
718 for (;;) { 717 for (;;) {
@@ -758,7 +757,8 @@ static int emu1010_firmware_thread(void *data)
758 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 757 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
759 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); 758 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
760 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); 759 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
761 snd_printk("Audio Dock ver:%d.%d\n", tmp, tmp2); 760 snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n",
761 tmp, tmp2);
762 /* Sync clocking between 1010 and Dock */ 762 /* Sync clocking between 1010 and Dock */
763 /* Allow DLL to settle */ 763 /* Allow DLL to settle */
764 msleep(10); 764 msleep(10);
@@ -804,8 +804,7 @@ static int emu1010_firmware_thread(void *data)
804static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) 804static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
805{ 805{
806 unsigned int i; 806 unsigned int i;
807 int tmp, tmp2; 807 u32 tmp, tmp2, reg;
808 int reg;
809 int err; 808 int err;
810 const char *filename = NULL; 809 const char *filename = NULL;
811 810
@@ -887,7 +886,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
887 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); 886 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
888 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp); 887 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
889 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2); 888 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
890 snd_printk("emu1010: Hana version: %d.%d\n", tmp, tmp2); 889 snd_printk(KERN_INFO "emu1010: Hana version: %u.%u\n", tmp, tmp2);
891 /* Enable 48Volt power to Audio Dock */ 890 /* Enable 48Volt power to Audio Dock */
892 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON); 891 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
893 892
@@ -1528,6 +1527,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1528 .ca0151_chip = 1, 1527 .ca0151_chip = 1,
1529 .spk71 = 1, 1528 .spk71 = 1,
1530 .spdif_bug = 1, 1529 .spdif_bug = 1,
1530 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1531 .ac97_chip = 1} , 1531 .ac97_chip = 1} ,
1532 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 1532 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
1533 .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]", 1533 .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]",
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 31542adc6b7e..1970f0e70f37 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -897,8 +897,8 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,
897 897
898 if ((err = pci_enable_device(pci)) < 0) 898 if ((err = pci_enable_device(pci)) < 0)
899 return err; 899 return err;
900 if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || 900 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
901 pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { 901 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
902 snd_printk(KERN_ERR "error to set 28bit mask DMA\n"); 902 snd_printk(KERN_ERR "error to set 28bit mask DMA\n");
903 pci_disable_device(pci); 903 pci_disable_device(pci);
904 return -ENXIO; 904 return -ENXIO;
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 7dba08f0ab8e..4b302d86f5f2 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1519,7 +1519,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1519 /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ 1519 /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */
1520 if (emu->card_capabilities->emu_model) { 1520 if (emu->card_capabilities->emu_model) {
1521 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ 1521 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
1522 snd_printk("EMU outputs on\n"); 1522 snd_printk(KERN_INFO "EMU outputs on\n");
1523 for (z = 0; z < 8; z++) { 1523 for (z = 0; z < 8; z++) {
1524 if (emu->card_capabilities->ca0108_chip) { 1524 if (emu->card_capabilities->ca0108_chip) {
1525 A_OP(icode, &ptr, iACC3, A3_EMU32OUT(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000); 1525 A_OP(icode, &ptr, iACC3, A3_EMU32OUT(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000);
@@ -1567,7 +1567,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1567 1567
1568 if (emu->card_capabilities->emu_model) { 1568 if (emu->card_capabilities->emu_model) {
1569 if (emu->card_capabilities->ca0108_chip) { 1569 if (emu->card_capabilities->ca0108_chip) {
1570 snd_printk("EMU2 inputs on\n"); 1570 snd_printk(KERN_INFO "EMU2 inputs on\n");
1571 for (z = 0; z < 0x10; z++) { 1571 for (z = 0; z < 0x10; z++) {
1572 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, 1572 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp,
1573 bit_shifter16, 1573 bit_shifter16,
@@ -1575,10 +1575,13 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1575 A_FXBUS2(z*2) ); 1575 A_FXBUS2(z*2) );
1576 } 1576 }
1577 } else { 1577 } else {
1578 snd_printk("EMU inputs on\n"); 1578 snd_printk(KERN_INFO "EMU inputs on\n");
1579 /* Capture 16 (originally 8) channels of S32_LE sound */ 1579 /* Capture 16 (originally 8) channels of S32_LE sound */
1580 1580
1581 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */ 1581 /*
1582 printk(KERN_DEBUG "emufx.c: gpr=0x%x, tmp=0x%x\n",
1583 gpr, tmp);
1584 */
1582 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ 1585 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
1583 /* A_P16VIN(0) is delayed by one sample, 1586 /* A_P16VIN(0) is delayed by one sample,
1584 * so all other A_P16VIN channels will need to also be delayed 1587 * so all other A_P16VIN channels will need to also be delayed
@@ -2490,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
2490 case SNDRV_EMU10K1_IOCTL_CODE_POKE: 2493 case SNDRV_EMU10K1_IOCTL_CODE_POKE:
2491 if (!capable(CAP_SYS_ADMIN)) 2494 if (!capable(CAP_SYS_ADMIN))
2492 return -EPERM; 2495 return -EPERM;
2493 icode = kmalloc(sizeof(*icode), GFP_KERNEL); 2496
2494 if (icode == NULL) 2497 icode = memdup_user(argp, sizeof(*icode));
2495 return -ENOMEM; 2498 if (IS_ERR(icode))
2496 if (copy_from_user(icode, argp, sizeof(*icode))) { 2499 return PTR_ERR(icode);
2497 kfree(icode);
2498 return -EFAULT;
2499 }
2500 res = snd_emu10k1_icode_poke(emu, icode); 2500 res = snd_emu10k1_icode_poke(emu, icode);
2501 kfree(icode); 2501 kfree(icode);
2502 return res; 2502 return res;
2503 case SNDRV_EMU10K1_IOCTL_CODE_PEEK: 2503 case SNDRV_EMU10K1_IOCTL_CODE_PEEK:
2504 icode = kmalloc(sizeof(*icode), GFP_KERNEL); 2504 icode = memdup_user(argp, sizeof(*icode));
2505 if (icode == NULL) 2505 if (IS_ERR(icode))
2506 return -ENOMEM; 2506 return PTR_ERR(icode);
2507 if (copy_from_user(icode, argp, sizeof(*icode))) {
2508 kfree(icode);
2509 return -EFAULT;
2510 }
2511 res = snd_emu10k1_icode_peek(emu, icode); 2507 res = snd_emu10k1_icode_peek(emu, icode);
2512 if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { 2508 if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) {
2513 kfree(icode); 2509 kfree(icode);
@@ -2516,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
2516 kfree(icode); 2512 kfree(icode);
2517 return res; 2513 return res;
2518 case SNDRV_EMU10K1_IOCTL_PCM_POKE: 2514 case SNDRV_EMU10K1_IOCTL_PCM_POKE:
2519 ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); 2515 ipcm = memdup_user(argp, sizeof(*ipcm));
2520 if (ipcm == NULL) 2516 if (IS_ERR(ipcm))
2521 return -ENOMEM; 2517 return PTR_ERR(ipcm);
2522 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
2523 kfree(ipcm);
2524 return -EFAULT;
2525 }
2526 res = snd_emu10k1_ipcm_poke(emu, ipcm); 2518 res = snd_emu10k1_ipcm_poke(emu, ipcm);
2527 kfree(ipcm); 2519 kfree(ipcm);
2528 return res; 2520 return res;
2529 case SNDRV_EMU10K1_IOCTL_PCM_PEEK: 2521 case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
2530 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); 2522 ipcm = memdup_user(argp, sizeof(*ipcm));
2531 if (ipcm == NULL) 2523 if (IS_ERR(ipcm))
2532 return -ENOMEM; 2524 return PTR_ERR(ipcm);
2533 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
2534 kfree(ipcm);
2535 return -EFAULT;
2536 }
2537 res = snd_emu10k1_ipcm_peek(emu, ipcm); 2525 res = snd_emu10k1_ipcm_peek(emu, ipcm);
2538 if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { 2526 if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) {
2539 kfree(ipcm); 2527 kfree(ipcm);
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index cf9276ddad42..78f62fd404c2 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -44,7 +44,7 @@ static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu,
44 if (epcm->substream == NULL) 44 if (epcm->substream == NULL)
45 return; 45 return;
46#if 0 46#if 0
47 printk("IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 47 printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
48 epcm->substream->runtime->hw->pointer(emu, epcm->substream), 48 epcm->substream->runtime->hw->pointer(emu, epcm->substream),
49 snd_pcm_lib_period_bytes(epcm->substream), 49 snd_pcm_lib_period_bytes(epcm->substream),
50 snd_pcm_lib_buffer_bytes(epcm->substream)); 50 snd_pcm_lib_buffer_bytes(epcm->substream));
@@ -146,7 +146,11 @@ static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voic
146 1, 146 1,
147 &epcm->extra); 147 &epcm->extra);
148 if (err < 0) { 148 if (err < 0) {
149 /* printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); */ 149 /*
150 printk(KERN_DEBUG "pcm_channel_alloc: "
151 "failed extra: voices=%d, frame=%d\n",
152 voices, frame);
153 */
150 for (i = 0; i < voices; i++) { 154 for (i = 0; i < voices; i++) {
151 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 155 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]);
152 epcm->voices[i] = NULL; 156 epcm->voices[i] = NULL;
@@ -737,7 +741,10 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream,
737 struct snd_emu10k1_pcm_mixer *mix; 741 struct snd_emu10k1_pcm_mixer *mix;
738 int result = 0; 742 int result = 0;
739 743
740 /* printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); */ 744 /*
745 printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
746 (int)emu, cmd, substream->ops->pointer(substream))
747 */
741 spin_lock(&emu->reg_lock); 748 spin_lock(&emu->reg_lock);
742 switch (cmd) { 749 switch (cmd) {
743 case SNDRV_PCM_TRIGGER_START: 750 case SNDRV_PCM_TRIGGER_START:
@@ -786,7 +793,10 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
786 /* hmm this should cause full and half full interrupt to be raised? */ 793 /* hmm this should cause full and half full interrupt to be raised? */
787 outl(epcm->capture_ipr, emu->port + IPR); 794 outl(epcm->capture_ipr, emu->port + IPR);
788 snd_emu10k1_intr_enable(emu, epcm->capture_inte); 795 snd_emu10k1_intr_enable(emu, epcm->capture_inte);
789 /* printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */ 796 /*
797 printk(KERN_DEBUG "adccr = 0x%x, adcbs = 0x%x\n",
798 epcm->adccr, epcm->adcbs);
799 */
790 switch (epcm->type) { 800 switch (epcm->type) {
791 case CAPTURE_AC97ADC: 801 case CAPTURE_AC97ADC:
792 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); 802 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val);
@@ -857,7 +867,11 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *
857 ptr -= runtime->buffer_size; 867 ptr -= runtime->buffer_size;
858 } 868 }
859#endif 869#endif
860 /* printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); */ 870 /*
871 printk(KERN_DEBUG
872 "ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n",
873 ptr, runtime->buffer_size, runtime->period_size);
874 */
861 return ptr; 875 return ptr;
862} 876}
863 877
@@ -1546,7 +1560,11 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left,
1546 unsigned int count, 1560 unsigned int count,
1547 unsigned int tram_shift) 1561 unsigned int tram_shift)
1548{ 1562{
1549 /* printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */ 1563 /*
1564 printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
1565 "src = 0x%p, count = 0x%x\n",
1566 dst_left, dst_right, src, count);
1567 */
1550 if ((tram_shift & 1) == 0) { 1568 if ((tram_shift & 1) == 0) {
1551 while (count--) { 1569 while (count--) {
1552 *dst_left-- = *src++; 1570 *dst_left-- = *src++;
@@ -1623,7 +1641,12 @@ static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substre
1623 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1641 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1624 unsigned int i; 1642 unsigned int i;
1625 1643
1626 /* printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */ 1644 /*
1645 printk(KERN_DEBUG "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
1646 "buffer_size = 0x%x (0x%x)\n",
1647 emu->fx8010.etram_pages, runtime->dma_area,
1648 runtime->buffer_size, runtime->buffer_size << 2);
1649 */
1627 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); 1650 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec));
1628 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ 1651 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */
1629 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); 1652 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream);
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c
index b5a802bdeb7c..c1a5aa15af8f 100644
--- a/sound/pci/emu10k1/io.c
+++ b/sound/pci/emu10k1/io.c
@@ -226,7 +226,9 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
226 break; 226 break;
227 227
228 if (timeout > 1000) { 228 if (timeout > 1000) {
229 snd_printk("emu10k1:I2C:timeout status=0x%x\n", status); 229 snd_printk(KERN_WARNING
230 "emu10k1:I2C:timeout status=0x%x\n",
231 status);
230 break; 232 break;
231 } 233 }
232 } 234 }
@@ -488,7 +490,7 @@ void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait)
488 if (newtime != curtime) 490 if (newtime != curtime)
489 break; 491 break;
490 } 492 }
491 if (count >= 16384) 493 if (count > 16384)
492 break; 494 break;
493 curtime = newtime; 495 curtime = newtime;
494 } 496 }
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 749a21b6bd06..e617acaf10e3 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -168,7 +168,7 @@ static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime)
168 struct snd_emu10k1_pcm *epcm = runtime->private_data; 168 struct snd_emu10k1_pcm *epcm = runtime->private_data;
169 169
170 if (epcm) { 170 if (epcm) {
171 //snd_printk("epcm free: %p\n", epcm); 171 /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */
172 kfree(epcm); 172 kfree(epcm);
173 } 173 }
174} 174}
@@ -183,14 +183,16 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
183 int err; 183 int err;
184 184
185 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 185 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
186 //snd_printk("epcm kcalloc: %p\n", epcm); 186 /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
187 187
188 if (epcm == NULL) 188 if (epcm == NULL)
189 return -ENOMEM; 189 return -ENOMEM;
190 epcm->emu = emu; 190 epcm->emu = emu;
191 epcm->substream = substream; 191 epcm->substream = substream;
192 //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id); 192 /*
193 193 snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
194 substream->pcm->device, channel_id);
195 */
194 runtime->private_data = epcm; 196 runtime->private_data = epcm;
195 runtime->private_free = snd_p16v_pcm_free_substream; 197 runtime->private_free = snd_p16v_pcm_free_substream;
196 198
@@ -200,10 +202,15 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
200 channel->number = channel_id; 202 channel->number = channel_id;
201 203
202 channel->use=1; 204 channel->use=1;
203 //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use); 205#if 0 /* debug */
204 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 206 snd_printk(KERN_DEBUG
205 //channel->interrupt = snd_p16v_pcm_channel_interrupt; 207 "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
206 channel->epcm=epcm; 208 channel_id, channel, channel->use);
209 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
210 channel_id, chip, channel);
211#endif /* debug */
212 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
213 channel->epcm = epcm;
207 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 214 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
208 return err; 215 return err;
209 216
@@ -224,14 +231,16 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
224 int err; 231 int err;
225 232
226 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 233 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
227 //snd_printk("epcm kcalloc: %p\n", epcm); 234 /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */
228 235
229 if (epcm == NULL) 236 if (epcm == NULL)
230 return -ENOMEM; 237 return -ENOMEM;
231 epcm->emu = emu; 238 epcm->emu = emu;
232 epcm->substream = substream; 239 epcm->substream = substream;
233 //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id); 240 /*
234 241 snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n",
242 substream->pcm->device, channel_id);
243 */
235 runtime->private_data = epcm; 244 runtime->private_data = epcm;
236 runtime->private_free = snd_p16v_pcm_free_substream; 245 runtime->private_free = snd_p16v_pcm_free_substream;
237 246
@@ -241,10 +250,15 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
241 channel->number = channel_id; 250 channel->number = channel_id;
242 251
243 channel->use=1; 252 channel->use=1;
244 //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use); 253#if 0 /* debug */
245 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 254 snd_printk(KERN_DEBUG
246 //channel->interrupt = snd_p16v_pcm_channel_interrupt; 255 "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
247 channel->epcm=epcm; 256 channel_id, channel, channel->use);
257 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n",
258 channel_id, chip, channel);
259#endif /* debug */
260 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
261 channel->epcm = epcm;
248 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 262 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
249 return err; 263 return err;
250 264
@@ -334,9 +348,19 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)
334 int i; 348 int i;
335 u32 tmp; 349 u32 tmp;
336 350
337 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); 351#if 0 /* debug */
338 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); 352 snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, "
339 //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->p16v_buffer.addr, emu->p16v_buffer.area, emu->p16v_buffer.bytes); 353 "format=0x%x, channels=%d, buffer_size=%ld, "
354 "period_size=%ld, periods=%u, frames_to_bytes=%d\n",
355 channel, runtime->rate, runtime->format, runtime->channels,
356 runtime->buffer_size, runtime->period_size,
357 runtime->periods, frames_to_bytes(runtime, 1));
358 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n",
359 runtime->dma_addr, runtime->dma_area, table_base);
360 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
361 emu->p16v_buffer.addr, emu->p16v_buffer.area,
362 emu->p16v_buffer.bytes);
363#endif /* debug */
340 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); 364 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
341 switch (runtime->rate) { 365 switch (runtime->rate) {
342 case 44100: 366 case 44100:
@@ -379,7 +403,15 @@ static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream)
379 struct snd_pcm_runtime *runtime = substream->runtime; 403 struct snd_pcm_runtime *runtime = substream->runtime;
380 int channel = substream->pcm->device - emu->p16v_device_offset; 404 int channel = substream->pcm->device - emu->p16v_device_offset;
381 u32 tmp; 405 u32 tmp;
382 //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); 406
407 /*
408 printk(KERN_DEBUG "prepare capture:channel_number=%d, rate=%d, "
409 "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, "
410 "frames_to_bytes=%d\n",
411 channel, runtime->rate, runtime->format, runtime->channels,
412 runtime->buffer_size, runtime->period_size,
413 frames_to_bytes(runtime, 1));
414 */
383 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); 415 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
384 switch (runtime->rate) { 416 switch (runtime->rate) {
385 case 44100: 417 case 44100:
@@ -459,13 +491,13 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
459 runtime = s->runtime; 491 runtime = s->runtime;
460 epcm = runtime->private_data; 492 epcm = runtime->private_data;
461 channel = substream->pcm->device-emu->p16v_device_offset; 493 channel = substream->pcm->device-emu->p16v_device_offset;
462 //snd_printk("p16v channel=%d\n",channel); 494 /* snd_printk(KERN_DEBUG "p16v channel=%d\n", channel); */
463 epcm->running = running; 495 epcm->running = running;
464 basic |= (0x1<<channel); 496 basic |= (0x1<<channel);
465 inte |= (INTE2_PLAYBACK_CH_0_LOOP<<channel); 497 inte |= (INTE2_PLAYBACK_CH_0_LOOP<<channel);
466 snd_pcm_trigger_done(s, substream); 498 snd_pcm_trigger_done(s, substream);
467 } 499 }
468 //snd_printk("basic=0x%x, inte=0x%x\n",basic, inte); 500 /* snd_printk(KERN_DEBUG "basic=0x%x, inte=0x%x\n", basic, inte); */
469 501
470 switch (cmd) { 502 switch (cmd) {
471 case SNDRV_PCM_TRIGGER_START: 503 case SNDRV_PCM_TRIGGER_START:
@@ -558,8 +590,13 @@ snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream)
558 ptr -= runtime->buffer_size; 590 ptr -= runtime->buffer_size;
559 printk(KERN_WARNING "buffer capture limited!\n"); 591 printk(KERN_WARNING "buffer capture limited!\n");
560 } 592 }
561 //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); 593 /*
562 594 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
595 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
596 ptr1, ptr2, ptr, (int)runtime->buffer_size,
597 (int)runtime->period_size, (int)runtime->frame_bits,
598 (int)runtime->rate);
599 */
563 return ptr; 600 return ptr;
564} 601}
565 602
@@ -592,7 +629,10 @@ int snd_p16v_free(struct snd_emu10k1 *chip)
592 // release the data 629 // release the data
593 if (chip->p16v_buffer.area) { 630 if (chip->p16v_buffer.area) {
594 snd_dma_free_pages(&chip->p16v_buffer); 631 snd_dma_free_pages(&chip->p16v_buffer);
595 //snd_printk("period lables free: %p\n", &chip->p16v_buffer); 632 /*
633 snd_printk(KERN_DEBUG "period lables free: %p\n",
634 &chip->p16v_buffer);
635 */
596 } 636 }
597 return 0; 637 return 0;
598} 638}
@@ -604,7 +644,7 @@ int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm *
604 int err; 644 int err;
605 int capture=1; 645 int capture=1;
606 646
607 //snd_printk("snd_p16v_pcm called. device=%d\n", device); 647 /* snd_printk("KERN_DEBUG snd_p16v_pcm called. device=%d\n", device); */
608 emu->p16v_device_offset = device; 648 emu->p16v_device_offset = device;
609 if (rpcm) 649 if (rpcm)
610 *rpcm = NULL; 650 *rpcm = NULL;
@@ -631,7 +671,10 @@ int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm *
631 snd_dma_pci_data(emu->pci), 671 snd_dma_pci_data(emu->pci),
632 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 672 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0)
633 return err; 673 return err;
634 //snd_printk("preallocate playback substream: err=%d\n", err); 674 /*
675 snd_printk(KERN_DEBUG
676 "preallocate playback substream: err=%d\n", err);
677 */
635 } 678 }
636 679
637 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 680 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
@@ -642,7 +685,10 @@ int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm *
642 snd_dma_pci_data(emu->pci), 685 snd_dma_pci_data(emu->pci),
643 65536 - 64, 65536 - 64)) < 0) 686 65536 - 64, 65536 - 64)) < 0)
644 return err; 687 return err;
645 //snd_printk("preallocate capture substream: err=%d\n", err); 688 /*
689 snd_printk(KERN_DEBUG
690 "preallocate capture substream: err=%d\n", err);
691 */
646 } 692 }
647 693
648 if (rpcm) 694 if (rpcm)
diff --git a/sound/pci/emu10k1/voice.c b/sound/pci/emu10k1/voice.c
index d7300a1aa262..20b8da250bd0 100644
--- a/sound/pci/emu10k1/voice.c
+++ b/sound/pci/emu10k1/voice.c
@@ -53,7 +53,10 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
53 *rvoice = NULL; 53 *rvoice = NULL;
54 first_voice = last_voice = 0; 54 first_voice = last_voice = 0;
55 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) { 55 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) {
56 // printk("i %d j %d next free %d!\n", i, j, emu->next_free_voice); 56 /*
57 printk(KERN_DEBUG "i %d j %d next free %d!\n",
58 i, j, emu->next_free_voice);
59 */
57 i %= NUM_G; 60 i %= NUM_G;
58 61
59 /* stereo voices must be even/odd */ 62 /* stereo voices must be even/odd */
@@ -71,7 +74,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
71 } 74 }
72 } 75 }
73 if (!skip) { 76 if (!skip) {
74 // printk("allocated voice %d\n", i); 77 /* printk(KERN_DEBUG "allocated voice %d\n", i); */
75 first_voice = i; 78 first_voice = i;
76 last_voice = (i + number) % NUM_G; 79 last_voice = (i + number) % NUM_G;
77 emu->next_free_voice = last_voice; 80 emu->next_free_voice = last_voice;
@@ -84,7 +87,10 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
84 87
85 for (i = 0; i < number; i++) { 88 for (i = 0; i < number; i++) {
86 voice = &emu->voices[(first_voice + i) % NUM_G]; 89 voice = &emu->voices[(first_voice + i) % NUM_G];
87 // printk("voice alloc - %i, %i of %i\n", voice->number, idx-first_voice+1, number); 90 /*
91 printk(kERN_DEBUG "voice alloc - %i, %i of %i\n",
92 voice->number, idx-first_voice+1, number);
93 */
88 voice->use = 1; 94 voice->use = 1;
89 switch (type) { 95 switch (type) {
90 case EMU10K1_PCM: 96 case EMU10K1_PCM:
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index e00614cbceff..18f4d1e98c46 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -584,7 +584,8 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
584 unsigned long end_time = jiffies + HZ / 10; 584 unsigned long end_time = jiffies + HZ / 10;
585 585
586#if 0 586#if 0
587 printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", 587 printk(KERN_DEBUG
588 "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n",
588 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); 589 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
589#endif 590#endif
590 do { 591 do {
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 34a78afc26d0..fbd2ac09aa34 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1608,8 +1608,8 @@ static int __devinit snd_es1938_create(struct snd_card *card,
1608 if ((err = pci_enable_device(pci)) < 0) 1608 if ((err = pci_enable_device(pci)) < 0)
1609 return err; 1609 return err;
1610 /* check, if we can restrict PCI DMA transfers to 24 bits */ 1610 /* check, if we can restrict PCI DMA transfers to 24 bits */
1611 if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 || 1611 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
1612 pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) { 1612 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
1613 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 1613 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
1614 pci_disable_device(pci); 1614 pci_disable_device(pci);
1615 return -ENXIO; 1615 return -ENXIO;
@@ -1673,18 +1673,22 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
1673 1673
1674 status = inb(SLIO_REG(chip, IRQCONTROL)); 1674 status = inb(SLIO_REG(chip, IRQCONTROL));
1675#if 0 1675#if 0
1676 printk("Es1938debug - interrupt status: =0x%x\n", status); 1676 printk(KERN_DEBUG "Es1938debug - interrupt status: =0x%x\n", status);
1677#endif 1677#endif
1678 1678
1679 /* AUDIO 1 */ 1679 /* AUDIO 1 */
1680 if (status & 0x10) { 1680 if (status & 0x10) {
1681#if 0 1681#if 0
1682 printk("Es1938debug - AUDIO channel 1 interrupt\n"); 1682 printk(KERN_DEBUG
1683 printk("Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", 1683 "Es1938debug - AUDIO channel 1 interrupt\n");
1684 printk(KERN_DEBUG
1685 "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n",
1684 inw(SLDM_REG(chip, DMACOUNT))); 1686 inw(SLDM_REG(chip, DMACOUNT)));
1685 printk("Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", 1687 printk(KERN_DEBUG
1688 "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n",
1686 inl(SLDM_REG(chip, DMAADDR))); 1689 inl(SLDM_REG(chip, DMAADDR)));
1687 printk("Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", 1690 printk(KERN_DEBUG
1691 "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n",
1688 inl(SLDM_REG(chip, DMASTATUS))); 1692 inl(SLDM_REG(chip, DMASTATUS)));
1689#endif 1693#endif
1690 /* clear irq */ 1694 /* clear irq */
@@ -1699,10 +1703,13 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
1699 /* AUDIO 2 */ 1703 /* AUDIO 2 */
1700 if (status & 0x20) { 1704 if (status & 0x20) {
1701#if 0 1705#if 0
1702 printk("Es1938debug - AUDIO channel 2 interrupt\n"); 1706 printk(KERN_DEBUG
1703 printk("Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", 1707 "Es1938debug - AUDIO channel 2 interrupt\n");
1708 printk(KERN_DEBUG
1709 "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n",
1704 inw(SLIO_REG(chip, AUDIO2DMACOUNT))); 1710 inw(SLIO_REG(chip, AUDIO2DMACOUNT)));
1705 printk("Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", 1711 printk(KERN_DEBUG
1712 "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n",
1706 inl(SLIO_REG(chip, AUDIO2DMAADDR))); 1713 inl(SLIO_REG(chip, AUDIO2DMAADDR)));
1707 1714
1708#endif 1715#endif
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index dc97e8116141..a11f453a6b6d 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2539,8 +2539,8 @@ static int __devinit snd_es1968_create(struct snd_card *card,
2539 if ((err = pci_enable_device(pci)) < 0) 2539 if ((err = pci_enable_device(pci)) < 0)
2540 return err; 2540 return err;
2541 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2541 /* check, if we can restrict PCI DMA transfers to 28 bits */
2542 if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || 2542 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2543 pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { 2543 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2544 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2544 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
2545 pci_disable_device(pci); 2545 pci_disable_device(pci);
2546 return -ENXIO; 2546 return -ENXIO;
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 960fd7970384..4de5bacd3929 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -138,6 +138,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
138 138
139 input_unregister_device(beep->dev); 139 input_unregister_device(beep->dev);
140 kfree(beep); 140 kfree(beep);
141 codec->beep = NULL;
141 } 142 }
142} 143}
143EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); 144EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index b9679f081cae..51bf6a5daf39 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -39,7 +39,7 @@ struct hda_beep {
39int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); 39int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
40void snd_hda_detach_beep_device(struct hda_codec *codec); 40void snd_hda_detach_beep_device(struct hda_codec *codec);
41#else 41#else
42#define snd_hda_attach_beep_device(...) 42#define snd_hda_attach_beep_device(...) 0
43#define snd_hda_detach_beep_device(...) 43#define snd_hda_detach_beep_device(...)
44#endif 44#endif
45#endif 45#endif
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 3c596da2b9b5..8820faf6c9d8 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -487,7 +487,6 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
487{ 487{
488 struct hda_bus *bus; 488 struct hda_bus *bus;
489 int err; 489 int err;
490 char qname[8];
491 static struct snd_device_ops dev_ops = { 490 static struct snd_device_ops dev_ops = {
492 .dev_register = snd_hda_bus_dev_register, 491 .dev_register = snd_hda_bus_dev_register,
493 .dev_free = snd_hda_bus_dev_free, 492 .dev_free = snd_hda_bus_dev_free,
@@ -517,10 +516,12 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
517 mutex_init(&bus->cmd_mutex); 516 mutex_init(&bus->cmd_mutex);
518 INIT_LIST_HEAD(&bus->codec_list); 517 INIT_LIST_HEAD(&bus->codec_list);
519 518
520 snprintf(qname, sizeof(qname), "hda%d", card->number); 519 snprintf(bus->workq_name, sizeof(bus->workq_name),
521 bus->workq = create_workqueue(qname); 520 "hd-audio%d", card->number);
521 bus->workq = create_singlethread_workqueue(bus->workq_name);
522 if (!bus->workq) { 522 if (!bus->workq) {
523 snd_printk(KERN_ERR "cannot create workqueue %s\n", qname); 523 snd_printk(KERN_ERR "cannot create workqueue %s\n",
524 bus->workq_name);
524 kfree(bus); 525 kfree(bus);
525 return -ENOMEM; 526 return -ENOMEM;
526 } 527 }
@@ -641,19 +642,21 @@ static int get_codec_name(struct hda_codec *codec)
641 */ 642 */
642static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) 643static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
643{ 644{
644 int i, total_nodes; 645 int i, total_nodes, function_id;
645 hda_nid_t nid; 646 hda_nid_t nid;
646 647
647 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 648 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
648 for (i = 0; i < total_nodes; i++, nid++) { 649 for (i = 0; i < total_nodes; i++, nid++) {
649 unsigned int func; 650 function_id = snd_hda_param_read(codec, nid,
650 func = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE); 651 AC_PAR_FUNCTION_TYPE) & 0xff;
651 switch (func & 0xff) { 652 switch (function_id) {
652 case AC_GRP_AUDIO_FUNCTION: 653 case AC_GRP_AUDIO_FUNCTION:
653 codec->afg = nid; 654 codec->afg = nid;
655 codec->function_id = function_id;
654 break; 656 break;
655 case AC_GRP_MODEM_FUNCTION: 657 case AC_GRP_MODEM_FUNCTION:
656 codec->mfg = nid; 658 codec->mfg = nid;
659 codec->function_id = function_id;
657 break; 660 break;
658 default: 661 default:
659 break; 662 break;
@@ -681,11 +684,140 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
681 return 0; 684 return 0;
682} 685}
683 686
687/* read all pin default configurations and save codec->init_pins */
688static int read_pin_defaults(struct hda_codec *codec)
689{
690 int i;
691 hda_nid_t nid = codec->start_nid;
692
693 for (i = 0; i < codec->num_nodes; i++, nid++) {
694 struct hda_pincfg *pin;
695 unsigned int wcaps = get_wcaps(codec, nid);
696 unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
697 AC_WCAP_TYPE_SHIFT;
698 if (wid_type != AC_WID_PIN)
699 continue;
700 pin = snd_array_new(&codec->init_pins);
701 if (!pin)
702 return -ENOMEM;
703 pin->nid = nid;
704 pin->cfg = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_CONFIG_DEFAULT, 0);
706 }
707 return 0;
708}
709
710/* look up the given pin config list and return the item matching with NID */
711static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec,
712 struct snd_array *array,
713 hda_nid_t nid)
714{
715 int i;
716 for (i = 0; i < array->used; i++) {
717 struct hda_pincfg *pin = snd_array_elem(array, i);
718 if (pin->nid == nid)
719 return pin;
720 }
721 return NULL;
722}
723
724/* write a config value for the given NID */
725static void set_pincfg(struct hda_codec *codec, hda_nid_t nid,
726 unsigned int cfg)
727{
728 int i;
729 for (i = 0; i < 4; i++) {
730 snd_hda_codec_write(codec, nid, 0,
731 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
732 cfg & 0xff);
733 cfg >>= 8;
734 }
735}
736
737/* set the current pin config value for the given NID.
738 * the value is cached, and read via snd_hda_codec_get_pincfg()
739 */
740int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
741 hda_nid_t nid, unsigned int cfg)
742{
743 struct hda_pincfg *pin;
744 unsigned int oldcfg;
745
746 oldcfg = snd_hda_codec_get_pincfg(codec, nid);
747 pin = look_up_pincfg(codec, list, nid);
748 if (!pin) {
749 pin = snd_array_new(list);
750 if (!pin)
751 return -ENOMEM;
752 pin->nid = nid;
753 }
754 pin->cfg = cfg;
755
756 /* change only when needed; e.g. if the pincfg is already present
757 * in user_pins[], don't write it
758 */
759 cfg = snd_hda_codec_get_pincfg(codec, nid);
760 if (oldcfg != cfg)
761 set_pincfg(codec, nid, cfg);
762 return 0;
763}
764
765int snd_hda_codec_set_pincfg(struct hda_codec *codec,
766 hda_nid_t nid, unsigned int cfg)
767{
768 return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg);
769}
770EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg);
771
772/* get the current pin config value of the given pin NID */
773unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
774{
775 struct hda_pincfg *pin;
776
777#ifdef CONFIG_SND_HDA_HWDEP
778 pin = look_up_pincfg(codec, &codec->user_pins, nid);
779 if (pin)
780 return pin->cfg;
781#endif
782 pin = look_up_pincfg(codec, &codec->driver_pins, nid);
783 if (pin)
784 return pin->cfg;
785 pin = look_up_pincfg(codec, &codec->init_pins, nid);
786 if (pin)
787 return pin->cfg;
788 return 0;
789}
790EXPORT_SYMBOL_HDA(snd_hda_codec_get_pincfg);
791
792/* restore all current pin configs */
793static void restore_pincfgs(struct hda_codec *codec)
794{
795 int i;
796 for (i = 0; i < codec->init_pins.used; i++) {
797 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
798 set_pincfg(codec, pin->nid,
799 snd_hda_codec_get_pincfg(codec, pin->nid));
800 }
801}
684 802
685static void init_hda_cache(struct hda_cache_rec *cache, 803static void init_hda_cache(struct hda_cache_rec *cache,
686 unsigned int record_size); 804 unsigned int record_size);
687static void free_hda_cache(struct hda_cache_rec *cache); 805static void free_hda_cache(struct hda_cache_rec *cache);
688 806
807/* restore the initial pin cfgs and release all pincfg lists */
808static void restore_init_pincfgs(struct hda_codec *codec)
809{
810 /* first free driver_pins and user_pins, then call restore_pincfg
811 * so that only the values in init_pins are restored
812 */
813 snd_array_free(&codec->driver_pins);
814#ifdef CONFIG_SND_HDA_HWDEP
815 snd_array_free(&codec->user_pins);
816#endif
817 restore_pincfgs(codec);
818 snd_array_free(&codec->init_pins);
819}
820
689/* 821/*
690 * codec destructor 822 * codec destructor
691 */ 823 */
@@ -693,6 +825,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
693{ 825{
694 if (!codec) 826 if (!codec)
695 return; 827 return;
828 restore_init_pincfgs(codec);
696#ifdef CONFIG_SND_HDA_POWER_SAVE 829#ifdef CONFIG_SND_HDA_POWER_SAVE
697 cancel_delayed_work(&codec->power_work); 830 cancel_delayed_work(&codec->power_work);
698 flush_workqueue(codec->bus->workq); 831 flush_workqueue(codec->bus->workq);
@@ -711,6 +844,9 @@ static void snd_hda_codec_free(struct hda_codec *codec)
711 kfree(codec); 844 kfree(codec);
712} 845}
713 846
847static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
848 unsigned int power_state);
849
714/** 850/**
715 * snd_hda_codec_new - create a HDA codec 851 * snd_hda_codec_new - create a HDA codec
716 * @bus: the bus to assign 852 * @bus: the bus to assign
@@ -750,6 +886,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
750 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 886 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
751 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 887 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
752 snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); 888 snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
889 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
890 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
753 if (codec->bus->modelname) { 891 if (codec->bus->modelname) {
754 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); 892 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
755 if (!codec->modelname) { 893 if (!codec->modelname) {
@@ -786,15 +924,18 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
786 setup_fg_nodes(codec); 924 setup_fg_nodes(codec);
787 if (!codec->afg && !codec->mfg) { 925 if (!codec->afg && !codec->mfg) {
788 snd_printdd("hda_codec: no AFG or MFG node found\n"); 926 snd_printdd("hda_codec: no AFG or MFG node found\n");
789 snd_hda_codec_free(codec); 927 err = -ENODEV;
790 return -ENODEV; 928 goto error;
791 } 929 }
792 930
793 if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) { 931 err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg);
932 if (err < 0) {
794 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 933 snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
795 snd_hda_codec_free(codec); 934 goto error;
796 return -ENOMEM;
797 } 935 }
936 err = read_pin_defaults(codec);
937 if (err < 0)
938 goto error;
798 939
799 if (!codec->subsystem_id) { 940 if (!codec->subsystem_id) {
800 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 941 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
@@ -805,12 +946,15 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
805 if (bus->modelname) 946 if (bus->modelname)
806 codec->modelname = kstrdup(bus->modelname, GFP_KERNEL); 947 codec->modelname = kstrdup(bus->modelname, GFP_KERNEL);
807 948
949 /* power-up all before initialization */
950 hda_set_power_state(codec,
951 codec->afg ? codec->afg : codec->mfg,
952 AC_PWRST_D0);
953
808 if (do_init) { 954 if (do_init) {
809 err = snd_hda_codec_configure(codec); 955 err = snd_hda_codec_configure(codec);
810 if (err < 0) { 956 if (err < 0)
811 snd_hda_codec_free(codec); 957 goto error;
812 return err;
813 }
814 } 958 }
815 snd_hda_codec_proc_new(codec); 959 snd_hda_codec_proc_new(codec);
816 960
@@ -823,6 +967,10 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
823 if (codecp) 967 if (codecp)
824 *codecp = codec; 968 *codecp = codec;
825 return 0; 969 return 0;
970
971 error:
972 snd_hda_codec_free(codec);
973 return err;
826} 974}
827EXPORT_SYMBOL_HDA(snd_hda_codec_new); 975EXPORT_SYMBOL_HDA(snd_hda_codec_new);
828 976
@@ -906,6 +1054,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
906 1054
907/* FIXME: more better hash key? */ 1055/* FIXME: more better hash key? */
908#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) 1056#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
1057#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))
909#define INFO_AMP_CAPS (1<<0) 1058#define INFO_AMP_CAPS (1<<0)
910#define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 1059#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
911 1060
@@ -996,6 +1145,21 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
996} 1145}
997EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); 1146EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps);
998 1147
1148u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid)
1149{
1150 struct hda_amp_info *info;
1151
1152 info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid));
1153 if (!info)
1154 return 0;
1155 if (!info->head.val) {
1156 info->amp_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
1157 info->head.val |= INFO_AMP_CAPS;
1158 }
1159 return info->amp_caps;
1160}
1161EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps);
1162
999/* 1163/*
1000 * read the current volume to info 1164 * read the current volume to info
1001 * if the cache exists, read the cache value. 1165 * if the cache exists, read the cache value.
@@ -1119,6 +1283,7 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1119 u16 nid = get_amp_nid(kcontrol); 1283 u16 nid = get_amp_nid(kcontrol);
1120 u8 chs = get_amp_channels(kcontrol); 1284 u8 chs = get_amp_channels(kcontrol);
1121 int dir = get_amp_direction(kcontrol); 1285 int dir = get_amp_direction(kcontrol);
1286 unsigned int ofs = get_amp_offset(kcontrol);
1122 u32 caps; 1287 u32 caps;
1123 1288
1124 caps = query_amp_caps(codec, nid, dir); 1289 caps = query_amp_caps(codec, nid, dir);
@@ -1130,6 +1295,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1130 kcontrol->id.name); 1295 kcontrol->id.name);
1131 return -EINVAL; 1296 return -EINVAL;
1132 } 1297 }
1298 if (ofs < caps)
1299 caps -= ofs;
1133 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1300 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1134 uinfo->count = chs == 3 ? 2 : 1; 1301 uinfo->count = chs == 3 ? 2 : 1;
1135 uinfo->value.integer.min = 0; 1302 uinfo->value.integer.min = 0;
@@ -1138,6 +1305,32 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1138} 1305}
1139EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info); 1306EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
1140 1307
1308
1309static inline unsigned int
1310read_amp_value(struct hda_codec *codec, hda_nid_t nid,
1311 int ch, int dir, int idx, unsigned int ofs)
1312{
1313 unsigned int val;
1314 val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx);
1315 val &= HDA_AMP_VOLMASK;
1316 if (val >= ofs)
1317 val -= ofs;
1318 else
1319 val = 0;
1320 return val;
1321}
1322
1323static inline int
1324update_amp_value(struct hda_codec *codec, hda_nid_t nid,
1325 int ch, int dir, int idx, unsigned int ofs,
1326 unsigned int val)
1327{
1328 if (val > 0)
1329 val += ofs;
1330 return snd_hda_codec_amp_update(codec, nid, ch, dir, idx,
1331 HDA_AMP_VOLMASK, val);
1332}
1333
1141int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, 1334int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
1142 struct snd_ctl_elem_value *ucontrol) 1335 struct snd_ctl_elem_value *ucontrol)
1143{ 1336{
@@ -1146,14 +1339,13 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
1146 int chs = get_amp_channels(kcontrol); 1339 int chs = get_amp_channels(kcontrol);
1147 int dir = get_amp_direction(kcontrol); 1340 int dir = get_amp_direction(kcontrol);
1148 int idx = get_amp_index(kcontrol); 1341 int idx = get_amp_index(kcontrol);
1342 unsigned int ofs = get_amp_offset(kcontrol);
1149 long *valp = ucontrol->value.integer.value; 1343 long *valp = ucontrol->value.integer.value;
1150 1344
1151 if (chs & 1) 1345 if (chs & 1)
1152 *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) 1346 *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs);
1153 & HDA_AMP_VOLMASK;
1154 if (chs & 2) 1347 if (chs & 2)
1155 *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) 1348 *valp = read_amp_value(codec, nid, 1, dir, idx, ofs);
1156 & HDA_AMP_VOLMASK;
1157 return 0; 1349 return 0;
1158} 1350}
1159EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get); 1351EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
@@ -1166,18 +1358,17 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
1166 int chs = get_amp_channels(kcontrol); 1358 int chs = get_amp_channels(kcontrol);
1167 int dir = get_amp_direction(kcontrol); 1359 int dir = get_amp_direction(kcontrol);
1168 int idx = get_amp_index(kcontrol); 1360 int idx = get_amp_index(kcontrol);
1361 unsigned int ofs = get_amp_offset(kcontrol);
1169 long *valp = ucontrol->value.integer.value; 1362 long *valp = ucontrol->value.integer.value;
1170 int change = 0; 1363 int change = 0;
1171 1364
1172 snd_hda_power_up(codec); 1365 snd_hda_power_up(codec);
1173 if (chs & 1) { 1366 if (chs & 1) {
1174 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 1367 change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp);
1175 0x7f, *valp);
1176 valp++; 1368 valp++;
1177 } 1369 }
1178 if (chs & 2) 1370 if (chs & 2)
1179 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 1371 change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp);
1180 0x7f, *valp);
1181 snd_hda_power_down(codec); 1372 snd_hda_power_down(codec);
1182 return change; 1373 return change;
1183} 1374}
@@ -1189,6 +1380,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1189 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1380 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1190 hda_nid_t nid = get_amp_nid(kcontrol); 1381 hda_nid_t nid = get_amp_nid(kcontrol);
1191 int dir = get_amp_direction(kcontrol); 1382 int dir = get_amp_direction(kcontrol);
1383 unsigned int ofs = get_amp_offset(kcontrol);
1192 u32 caps, val1, val2; 1384 u32 caps, val1, val2;
1193 1385
1194 if (size < 4 * sizeof(unsigned int)) 1386 if (size < 4 * sizeof(unsigned int))
@@ -1197,6 +1389,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1197 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT; 1389 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
1198 val2 = (val2 + 1) * 25; 1390 val2 = (val2 + 1) * 25;
1199 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 1391 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
1392 val1 += ofs;
1200 val1 = ((int)val1) * ((int)val2); 1393 val1 = ((int)val1) * ((int)val2);
1201 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 1394 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
1202 return -EFAULT; 1395 return -EFAULT;
@@ -1267,7 +1460,6 @@ int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl)
1267} 1460}
1268EXPORT_SYMBOL_HDA(snd_hda_ctl_add); 1461EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
1269 1462
1270#ifdef CONFIG_SND_HDA_RECONFIG
1271/* Clear all controls assigned to the given codec */ 1463/* Clear all controls assigned to the given codec */
1272void snd_hda_ctls_clear(struct hda_codec *codec) 1464void snd_hda_ctls_clear(struct hda_codec *codec)
1273{ 1465{
@@ -1278,9 +1470,52 @@ void snd_hda_ctls_clear(struct hda_codec *codec)
1278 snd_array_free(&codec->mixers); 1470 snd_array_free(&codec->mixers);
1279} 1471}
1280 1472
1281void snd_hda_codec_reset(struct hda_codec *codec) 1473/* pseudo device locking
1474 * toggle card->shutdown to allow/disallow the device access (as a hack)
1475 */
1476static int hda_lock_devices(struct snd_card *card)
1282{ 1477{
1283 int i; 1478 spin_lock(&card->files_lock);
1479 if (card->shutdown) {
1480 spin_unlock(&card->files_lock);
1481 return -EINVAL;
1482 }
1483 card->shutdown = 1;
1484 spin_unlock(&card->files_lock);
1485 return 0;
1486}
1487
1488static void hda_unlock_devices(struct snd_card *card)
1489{
1490 spin_lock(&card->files_lock);
1491 card->shutdown = 0;
1492 spin_unlock(&card->files_lock);
1493}
1494
1495int snd_hda_codec_reset(struct hda_codec *codec)
1496{
1497 struct snd_card *card = codec->bus->card;
1498 int i, pcm;
1499
1500 if (hda_lock_devices(card) < 0)
1501 return -EBUSY;
1502 /* check whether the codec isn't used by any mixer or PCM streams */
1503 if (!list_empty(&card->ctl_files)) {
1504 hda_unlock_devices(card);
1505 return -EBUSY;
1506 }
1507 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
1508 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
1509 if (!cpcm->pcm)
1510 continue;
1511 if (cpcm->pcm->streams[0].substream_opened ||
1512 cpcm->pcm->streams[1].substream_opened) {
1513 hda_unlock_devices(card);
1514 return -EBUSY;
1515 }
1516 }
1517
1518 /* OK, let it free */
1284 1519
1285#ifdef CONFIG_SND_HDA_POWER_SAVE 1520#ifdef CONFIG_SND_HDA_POWER_SAVE
1286 cancel_delayed_work(&codec->power_work); 1521 cancel_delayed_work(&codec->power_work);
@@ -1290,8 +1525,7 @@ void snd_hda_codec_reset(struct hda_codec *codec)
1290 /* relase PCMs */ 1525 /* relase PCMs */
1291 for (i = 0; i < codec->num_pcms; i++) { 1526 for (i = 0; i < codec->num_pcms; i++) {
1292 if (codec->pcm_info[i].pcm) { 1527 if (codec->pcm_info[i].pcm) {
1293 snd_device_free(codec->bus->card, 1528 snd_device_free(card, codec->pcm_info[i].pcm);
1294 codec->pcm_info[i].pcm);
1295 clear_bit(codec->pcm_info[i].device, 1529 clear_bit(codec->pcm_info[i].device,
1296 codec->bus->pcm_dev_bits); 1530 codec->bus->pcm_dev_bits);
1297 } 1531 }
@@ -1304,13 +1538,22 @@ void snd_hda_codec_reset(struct hda_codec *codec)
1304 free_hda_cache(&codec->cmd_cache); 1538 free_hda_cache(&codec->cmd_cache);
1305 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 1539 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
1306 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 1540 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
1541 /* free only driver_pins so that init_pins + user_pins are restored */
1542 snd_array_free(&codec->driver_pins);
1543 restore_pincfgs(codec);
1307 codec->num_pcms = 0; 1544 codec->num_pcms = 0;
1308 codec->pcm_info = NULL; 1545 codec->pcm_info = NULL;
1309 codec->preset = NULL; 1546 codec->preset = NULL;
1547 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
1548 codec->slave_dig_outs = NULL;
1549 codec->spdif_status_reset = 0;
1310 module_put(codec->owner); 1550 module_put(codec->owner);
1311 codec->owner = NULL; 1551 codec->owner = NULL;
1552
1553 /* allow device access again */
1554 hda_unlock_devices(card);
1555 return 0;
1312} 1556}
1313#endif /* CONFIG_SND_HDA_RECONFIG */
1314 1557
1315/* create a virtual master control and add slaves */ 1558/* create a virtual master control and add slaves */
1316int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1559int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
@@ -1335,15 +1578,20 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1335 1578
1336 for (s = slaves; *s; s++) { 1579 for (s = slaves; *s; s++) {
1337 struct snd_kcontrol *sctl; 1580 struct snd_kcontrol *sctl;
1338 1581 int i = 0;
1339 sctl = snd_hda_find_mixer_ctl(codec, *s); 1582 for (;;) {
1340 if (!sctl) { 1583 sctl = _snd_hda_find_mixer_ctl(codec, *s, i);
1341 snd_printdd("Cannot find slave %s, skipped\n", *s); 1584 if (!sctl) {
1342 continue; 1585 if (!i)
1586 snd_printdd("Cannot find slave %s, "
1587 "skipped\n", *s);
1588 break;
1589 }
1590 err = snd_ctl_add_slave(kctl, sctl);
1591 if (err < 0)
1592 return err;
1593 i++;
1343 } 1594 }
1344 err = snd_ctl_add_slave(kctl, sctl);
1345 if (err < 0)
1346 return err;
1347 } 1595 }
1348 return 0; 1596 return 0;
1349} 1597}
@@ -1954,6 +2202,8 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1954 } 2202 }
1955 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 2203 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1956 kctl = snd_ctl_new1(dig_mix, codec); 2204 kctl = snd_ctl_new1(dig_mix, codec);
2205 if (!kctl)
2206 return -ENOMEM;
1957 kctl->private_value = nid; 2207 kctl->private_value = nid;
1958 err = snd_hda_ctl_add(codec, kctl); 2208 err = snd_hda_ctl_add(codec, kctl);
1959 if (err < 0) 2209 if (err < 0)
@@ -2002,7 +2252,11 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
2002 err = bus->ops.command(bus, res); 2252 err = bus->ops.command(bus, res);
2003 if (!err) { 2253 if (!err) {
2004 struct hda_cache_head *c; 2254 struct hda_cache_head *c;
2005 u32 key = build_cmd_cache_key(nid, verb); 2255 u32 key;
2256 /* parm may contain the verb stuff for get/set amp */
2257 verb = verb | (parm >> 8);
2258 parm &= 0xff;
2259 key = build_cmd_cache_key(nid, verb);
2006 c = get_alloc_hash(&codec->cmd_cache, key); 2260 c = get_alloc_hash(&codec->cmd_cache, key);
2007 if (c) 2261 if (c)
2008 c->val = parm; 2262 c->val = parm;
@@ -2073,8 +2327,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
2073 * don't power down the widget if it controls 2327 * don't power down the widget if it controls
2074 * eapd and EAPD_BTLENABLE is set. 2328 * eapd and EAPD_BTLENABLE is set.
2075 */ 2329 */
2076 pincap = snd_hda_param_read(codec, nid, 2330 pincap = snd_hda_query_pin_caps(codec, nid);
2077 AC_PAR_PIN_CAP);
2078 if (pincap & AC_PINCAP_EAPD) { 2331 if (pincap & AC_PINCAP_EAPD) {
2079 int eapd = snd_hda_codec_read(codec, 2332 int eapd = snd_hda_codec_read(codec,
2080 nid, 0, 2333 nid, 0,
@@ -2143,6 +2396,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
2143 hda_set_power_state(codec, 2396 hda_set_power_state(codec,
2144 codec->afg ? codec->afg : codec->mfg, 2397 codec->afg ? codec->afg : codec->mfg,
2145 AC_PWRST_D0); 2398 AC_PWRST_D0);
2399 restore_pincfgs(codec); /* restore all current pin configs */
2146 hda_exec_init_verbs(codec); 2400 hda_exec_init_verbs(codec);
2147 if (codec->patch_ops.resume) 2401 if (codec->patch_ops.resume)
2148 codec->patch_ops.resume(codec); 2402 codec->patch_ops.resume(codec);
@@ -2170,8 +2424,16 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
2170 2424
2171 list_for_each_entry(codec, &bus->codec_list, list) { 2425 list_for_each_entry(codec, &bus->codec_list, list) {
2172 int err = snd_hda_codec_build_controls(codec); 2426 int err = snd_hda_codec_build_controls(codec);
2173 if (err < 0) 2427 if (err < 0) {
2174 return err; 2428 printk(KERN_ERR "hda_codec: cannot build controls"
2429 "for #%d (error %d)\n", codec->addr, err);
2430 err = snd_hda_codec_reset(codec);
2431 if (err < 0) {
2432 printk(KERN_ERR
2433 "hda_codec: cannot revert codec\n");
2434 return err;
2435 }
2436 }
2175 } 2437 }
2176 return 0; 2438 return 0;
2177} 2439}
@@ -2180,19 +2442,12 @@ EXPORT_SYMBOL_HDA(snd_hda_build_controls);
2180int snd_hda_codec_build_controls(struct hda_codec *codec) 2442int snd_hda_codec_build_controls(struct hda_codec *codec)
2181{ 2443{
2182 int err = 0; 2444 int err = 0;
2183 /* fake as if already powered-on */
2184 hda_keep_power_on(codec);
2185 /* then fire up */
2186 hda_set_power_state(codec,
2187 codec->afg ? codec->afg : codec->mfg,
2188 AC_PWRST_D0);
2189 hda_exec_init_verbs(codec); 2445 hda_exec_init_verbs(codec);
2190 /* continue to initialize... */ 2446 /* continue to initialize... */
2191 if (codec->patch_ops.init) 2447 if (codec->patch_ops.init)
2192 err = codec->patch_ops.init(codec); 2448 err = codec->patch_ops.init(codec);
2193 if (!err && codec->patch_ops.build_controls) 2449 if (!err && codec->patch_ops.build_controls)
2194 err = codec->patch_ops.build_controls(codec); 2450 err = codec->patch_ops.build_controls(codec);
2195 snd_hda_power_down(codec);
2196 if (err < 0) 2451 if (err < 0)
2197 return err; 2452 return err;
2198 return 0; 2453 return 0;
@@ -2305,12 +2560,11 @@ EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format);
2305static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, 2560static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2306 u32 *ratesp, u64 *formatsp, unsigned int *bpsp) 2561 u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
2307{ 2562{
2308 int i; 2563 unsigned int i, val, wcaps;
2309 unsigned int val, streams;
2310 2564
2311 val = 0; 2565 val = 0;
2312 if (nid != codec->afg && 2566 wcaps = get_wcaps(codec, nid);
2313 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { 2567 if (nid != codec->afg && (wcaps & AC_WCAP_FORMAT_OVRD)) {
2314 val = snd_hda_param_read(codec, nid, AC_PAR_PCM); 2568 val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
2315 if (val == -1) 2569 if (val == -1)
2316 return -EIO; 2570 return -EIO;
@@ -2324,15 +2578,20 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2324 if (val & (1 << i)) 2578 if (val & (1 << i))
2325 rates |= rate_bits[i].alsa_bits; 2579 rates |= rate_bits[i].alsa_bits;
2326 } 2580 }
2581 if (rates == 0) {
2582 snd_printk(KERN_ERR "hda_codec: rates == 0 "
2583 "(nid=0x%x, val=0x%x, ovrd=%i)\n",
2584 nid, val,
2585 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
2586 return -EIO;
2587 }
2327 *ratesp = rates; 2588 *ratesp = rates;
2328 } 2589 }
2329 2590
2330 if (formatsp || bpsp) { 2591 if (formatsp || bpsp) {
2331 u64 formats = 0; 2592 u64 formats = 0;
2332 unsigned int bps; 2593 unsigned int streams, bps;
2333 unsigned int wcaps;
2334 2594
2335 wcaps = get_wcaps(codec, nid);
2336 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 2595 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
2337 if (streams == -1) 2596 if (streams == -1)
2338 return -EIO; 2597 return -EIO;
@@ -2385,6 +2644,15 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2385 formats |= SNDRV_PCM_FMTBIT_U8; 2644 formats |= SNDRV_PCM_FMTBIT_U8;
2386 bps = 8; 2645 bps = 8;
2387 } 2646 }
2647 if (formats == 0) {
2648 snd_printk(KERN_ERR "hda_codec: formats == 0 "
2649 "(nid=0x%x, val=0x%x, ovrd=%i, "
2650 "streams=0x%x)\n",
2651 nid, val,
2652 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
2653 streams);
2654 return -EIO;
2655 }
2388 if (formatsp) 2656 if (formatsp)
2389 *formatsp = formats; 2657 *formatsp = formats;
2390 if (bpsp) 2658 if (bpsp)
@@ -2500,12 +2768,16 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
2500static int set_pcm_default_values(struct hda_codec *codec, 2768static int set_pcm_default_values(struct hda_codec *codec,
2501 struct hda_pcm_stream *info) 2769 struct hda_pcm_stream *info)
2502{ 2770{
2771 int err;
2772
2503 /* query support PCM information from the given NID */ 2773 /* query support PCM information from the given NID */
2504 if (info->nid && (!info->rates || !info->formats)) { 2774 if (info->nid && (!info->rates || !info->formats)) {
2505 snd_hda_query_supported_pcm(codec, info->nid, 2775 err = snd_hda_query_supported_pcm(codec, info->nid,
2506 info->rates ? NULL : &info->rates, 2776 info->rates ? NULL : &info->rates,
2507 info->formats ? NULL : &info->formats, 2777 info->formats ? NULL : &info->formats,
2508 info->maxbps ? NULL : &info->maxbps); 2778 info->maxbps ? NULL : &info->maxbps);
2779 if (err < 0)
2780 return err;
2509 } 2781 }
2510 if (info->ops.open == NULL) 2782 if (info->ops.open == NULL)
2511 info->ops.open = hda_pcm_default_open_close; 2783 info->ops.open = hda_pcm_default_open_close;
@@ -2548,13 +2820,10 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
2548 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) { 2820 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
2549 dev = audio_idx[i]; 2821 dev = audio_idx[i];
2550 if (!test_bit(dev, bus->pcm_dev_bits)) 2822 if (!test_bit(dev, bus->pcm_dev_bits))
2551 break; 2823 goto ok;
2552 } 2824 }
2553 if (i >= ARRAY_SIZE(audio_idx)) { 2825 snd_printk(KERN_WARNING "Too many audio devices\n");
2554 snd_printk(KERN_WARNING "Too many audio devices\n"); 2826 return -EAGAIN;
2555 return -EAGAIN;
2556 }
2557 break;
2558 case HDA_PCM_TYPE_SPDIF: 2827 case HDA_PCM_TYPE_SPDIF:
2559 case HDA_PCM_TYPE_HDMI: 2828 case HDA_PCM_TYPE_HDMI:
2560 case HDA_PCM_TYPE_MODEM: 2829 case HDA_PCM_TYPE_MODEM:
@@ -2569,6 +2838,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
2569 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type); 2838 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
2570 return -EINVAL; 2839 return -EINVAL;
2571 } 2840 }
2841 ok:
2572 set_bit(dev, bus->pcm_dev_bits); 2842 set_bit(dev, bus->pcm_dev_bits);
2573 return dev; 2843 return dev;
2574} 2844}
@@ -2605,24 +2875,36 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
2605 if (!codec->patch_ops.build_pcms) 2875 if (!codec->patch_ops.build_pcms)
2606 return 0; 2876 return 0;
2607 err = codec->patch_ops.build_pcms(codec); 2877 err = codec->patch_ops.build_pcms(codec);
2608 if (err < 0) 2878 if (err < 0) {
2609 return err; 2879 printk(KERN_ERR "hda_codec: cannot build PCMs"
2880 "for #%d (error %d)\n", codec->addr, err);
2881 err = snd_hda_codec_reset(codec);
2882 if (err < 0) {
2883 printk(KERN_ERR
2884 "hda_codec: cannot revert codec\n");
2885 return err;
2886 }
2887 }
2610 } 2888 }
2611 for (pcm = 0; pcm < codec->num_pcms; pcm++) { 2889 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
2612 struct hda_pcm *cpcm = &codec->pcm_info[pcm]; 2890 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
2613 int dev; 2891 int dev;
2614 2892
2615 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) 2893 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
2616 return 0; /* no substreams assigned */ 2894 continue; /* no substreams assigned */
2617 2895
2618 if (!cpcm->pcm) { 2896 if (!cpcm->pcm) {
2619 dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type); 2897 dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
2620 if (dev < 0) 2898 if (dev < 0)
2621 return 0; 2899 continue; /* no fatal error */
2622 cpcm->device = dev; 2900 cpcm->device = dev;
2623 err = snd_hda_attach_pcm(codec, cpcm); 2901 err = snd_hda_attach_pcm(codec, cpcm);
2624 if (err < 0) 2902 if (err < 0) {
2625 return err; 2903 printk(KERN_ERR "hda_codec: cannot attach "
2904 "PCM stream %d for codec #%d\n",
2905 dev, codec->addr);
2906 continue; /* no fatal error */
2907 }
2626 } 2908 }
2627 } 2909 }
2628 return 0; 2910 return 0;
@@ -2724,6 +3006,67 @@ int snd_hda_check_board_config(struct hda_codec *codec,
2724EXPORT_SYMBOL_HDA(snd_hda_check_board_config); 3006EXPORT_SYMBOL_HDA(snd_hda_check_board_config);
2725 3007
2726/** 3008/**
3009 * snd_hda_check_board_codec_sid_config - compare the current codec
3010 subsystem ID with the
3011 config table
3012
3013 This is important for Gateway notebooks with SB450 HDA Audio
3014 where the vendor ID of the PCI device is:
3015 ATI Technologies Inc SB450 HDA Audio [1002:437b]
3016 and the vendor/subvendor are found only at the codec.
3017
3018 * @codec: the HDA codec
3019 * @num_configs: number of config enums
3020 * @models: array of model name strings
3021 * @tbl: configuration table, terminated by null entries
3022 *
3023 * Compares the modelname or PCI subsystem id of the current codec with the
3024 * given configuration table. If a matching entry is found, returns its
3025 * config value (supposed to be 0 or positive).
3026 *
3027 * If no entries are matching, the function returns a negative value.
3028 */
3029int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
3030 int num_configs, const char **models,
3031 const struct snd_pci_quirk *tbl)
3032{
3033 const struct snd_pci_quirk *q;
3034
3035 /* Search for codec ID */
3036 for (q = tbl; q->subvendor; q++) {
3037 unsigned long vendorid = (q->subdevice) | (q->subvendor << 16);
3038
3039 if (vendorid == codec->subsystem_id)
3040 break;
3041 }
3042
3043 if (!q->subvendor)
3044 return -1;
3045
3046 tbl = q;
3047
3048 if (tbl->value >= 0 && tbl->value < num_configs) {
3049#ifdef CONFIG_SND_DEBUG_DETECT
3050 char tmp[10];
3051 const char *model = NULL;
3052 if (models)
3053 model = models[tbl->value];
3054 if (!model) {
3055 sprintf(tmp, "#%d", tbl->value);
3056 model = tmp;
3057 }
3058 snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
3059 "for config %x:%x (%s)\n",
3060 model, tbl->subvendor, tbl->subdevice,
3061 (tbl->name ? tbl->name : "Unknown device"));
3062#endif
3063 return tbl->value;
3064 }
3065 return -1;
3066}
3067EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config);
3068
3069/**
2727 * snd_hda_add_new_ctls - create controls from the array 3070 * snd_hda_add_new_ctls - create controls from the array
2728 * @codec: the HDA codec 3071 * @codec: the HDA codec
2729 * @knew: the array of struct snd_kcontrol_new 3072 * @knew: the array of struct snd_kcontrol_new
@@ -2815,7 +3158,7 @@ void snd_hda_power_down(struct hda_codec *codec)
2815 return; 3158 return;
2816 if (power_save(codec)) { 3159 if (power_save(codec)) {
2817 codec->power_transition = 1; /* avoid reentrance */ 3160 codec->power_transition = 1; /* avoid reentrance */
2818 schedule_delayed_work(&codec->power_work, 3161 queue_delayed_work(codec->bus->workq, &codec->power_work,
2819 msecs_to_jiffies(power_save(codec) * 1000)); 3162 msecs_to_jiffies(power_save(codec) * 1000));
2820 } 3163 }
2821} 3164}
@@ -3026,6 +3369,16 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
3026} 3369}
3027EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare); 3370EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
3028 3371
3372int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
3373 struct hda_multi_out *mout)
3374{
3375 mutex_lock(&codec->spdif_mutex);
3376 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3377 mutex_unlock(&codec->spdif_mutex);
3378 return 0;
3379}
3380EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup);
3381
3029/* 3382/*
3030 * release the digital out 3383 * release the digital out
3031 */ 3384 */
@@ -3252,8 +3605,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3252 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 3605 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
3253 continue; 3606 continue;
3254 3607
3255 def_conf = snd_hda_codec_read(codec, nid, 0, 3608 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3256 AC_VERB_GET_CONFIG_DEFAULT, 0);
3257 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3609 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3258 continue; 3610 continue;
3259 loc = get_defcfg_location(def_conf); 3611 loc = get_defcfg_location(def_conf);
@@ -3329,10 +3681,22 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3329 cfg->input_pins[AUTO_PIN_AUX] = nid; 3681 cfg->input_pins[AUTO_PIN_AUX] = nid;
3330 break; 3682 break;
3331 case AC_JACK_SPDIF_OUT: 3683 case AC_JACK_SPDIF_OUT:
3332 cfg->dig_out_pin = nid; 3684 case AC_JACK_DIG_OTHER_OUT:
3685 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
3686 continue;
3687 cfg->dig_out_pins[cfg->dig_outs] = nid;
3688 cfg->dig_out_type[cfg->dig_outs] =
3689 (loc == AC_JACK_LOC_HDMI) ?
3690 HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF;
3691 cfg->dig_outs++;
3333 break; 3692 break;
3334 case AC_JACK_SPDIF_IN: 3693 case AC_JACK_SPDIF_IN:
3694 case AC_JACK_DIG_OTHER_IN:
3335 cfg->dig_in_pin = nid; 3695 cfg->dig_in_pin = nid;
3696 if (loc == AC_JACK_LOC_HDMI)
3697 cfg->dig_in_type = HDA_PCM_TYPE_HDMI;
3698 else
3699 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
3336 break; 3700 break;
3337 } 3701 }
3338 } 3702 }
@@ -3438,6 +3802,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3438 cfg->hp_pins[1], cfg->hp_pins[2], 3802 cfg->hp_pins[1], cfg->hp_pins[2],
3439 cfg->hp_pins[3], cfg->hp_pins[4]); 3803 cfg->hp_pins[3], cfg->hp_pins[4]);
3440 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin); 3804 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin);
3805 if (cfg->dig_outs)
3806 snd_printd(" dig-out=0x%x/0x%x\n",
3807 cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
3441 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," 3808 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
3442 " cd=0x%x, aux=0x%x\n", 3809 " cd=0x%x, aux=0x%x\n",
3443 cfg->input_pins[AUTO_PIN_MIC], 3810 cfg->input_pins[AUTO_PIN_MIC],
@@ -3446,6 +3813,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3446 cfg->input_pins[AUTO_PIN_FRONT_LINE], 3813 cfg->input_pins[AUTO_PIN_FRONT_LINE],
3447 cfg->input_pins[AUTO_PIN_CD], 3814 cfg->input_pins[AUTO_PIN_CD],
3448 cfg->input_pins[AUTO_PIN_AUX]); 3815 cfg->input_pins[AUTO_PIN_AUX]);
3816 if (cfg->dig_in_pin)
3817 snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin);
3449 3818
3450 return 0; 3819 return 0;
3451} 3820}
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 5810ef588402..2fdecf4b0eb6 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -614,6 +614,7 @@ struct hda_bus {
614 614
615 /* unsolicited event queue */ 615 /* unsolicited event queue */
616 struct hda_bus_unsolicited *unsol; 616 struct hda_bus_unsolicited *unsol;
617 char workq_name[16];
617 struct workqueue_struct *workq; /* common workqueue for codecs */ 618 struct workqueue_struct *workq; /* common workqueue for codecs */
618 619
619 /* assigned PCMs */ 620 /* assigned PCMs */
@@ -738,6 +739,7 @@ struct hda_codec {
738 hda_nid_t mfg; /* MFG node id */ 739 hda_nid_t mfg; /* MFG node id */
739 740
740 /* ids */ 741 /* ids */
742 u32 function_id;
741 u32 vendor_id; 743 u32 vendor_id;
742 u32 subsystem_id; 744 u32 subsystem_id;
743 u32 revision_id; 745 u32 revision_id;
@@ -777,11 +779,14 @@ struct hda_codec {
777 unsigned short spdif_ctls; /* SPDIF control bits */ 779 unsigned short spdif_ctls; /* SPDIF control bits */
778 unsigned int spdif_in_enable; /* SPDIF input enable? */ 780 unsigned int spdif_in_enable; /* SPDIF input enable? */
779 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ 781 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
782 struct snd_array init_pins; /* initial (BIOS) pin configurations */
783 struct snd_array driver_pins; /* pin configs set by codec parser */
780 784
781#ifdef CONFIG_SND_HDA_HWDEP 785#ifdef CONFIG_SND_HDA_HWDEP
782 struct snd_hwdep *hwdep; /* assigned hwdep device */ 786 struct snd_hwdep *hwdep; /* assigned hwdep device */
783 struct snd_array init_verbs; /* additional init verbs */ 787 struct snd_array init_verbs; /* additional init verbs */
784 struct snd_array hints; /* additional hints */ 788 struct snd_array hints; /* additional hints */
789 struct snd_array user_pins; /* default pin configs to override */
785#endif 790#endif
786 791
787 /* misc flags */ 792 /* misc flags */
@@ -789,6 +794,9 @@ struct hda_codec {
789 * status change 794 * status change
790 * (e.g. Realtek codecs) 795 * (e.g. Realtek codecs)
791 */ 796 */
797 unsigned int pin_amp_workaround:1; /* pin out-amp takes index
798 * (e.g. Conexant codecs)
799 */
792#ifdef CONFIG_SND_HDA_POWER_SAVE 800#ifdef CONFIG_SND_HDA_POWER_SAVE
793 unsigned int power_on :1; /* current (global) power-state */ 801 unsigned int power_on :1; /* current (global) power-state */
794 unsigned int power_transition :1; /* power-state in transition */ 802 unsigned int power_transition :1; /* power-state in transition */
@@ -854,6 +862,18 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
854#define snd_hda_sequence_write_cache snd_hda_sequence_write 862#define snd_hda_sequence_write_cache snd_hda_sequence_write
855#endif 863#endif
856 864
865/* the struct for codec->pin_configs */
866struct hda_pincfg {
867 hda_nid_t nid;
868 unsigned int cfg;
869};
870
871unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
872int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
873 unsigned int cfg);
874int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
875 hda_nid_t nid, unsigned int cfg); /* for hwdep */
876
857/* 877/*
858 * Mixer 878 * Mixer
859 */ 879 */
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 65745e96dc70..1d5797a96682 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -144,9 +144,9 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
144 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 144 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
145 145
146 if (node->type == AC_WID_PIN) { 146 if (node->type == AC_WID_PIN) {
147 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); 147 node->pin_caps = snd_hda_query_pin_caps(codec, node->nid);
148 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 148 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
149 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 149 node->def_cfg = snd_hda_codec_get_pincfg(codec, node->nid);
150 } 150 }
151 151
152 if (node->wid_caps & AC_WCAP_OUT_AMP) { 152 if (node->wid_caps & AC_WCAP_OUT_AMP) {
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index 300ab407cf42..1c57505c2874 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -30,6 +30,12 @@
30#include <sound/hda_hwdep.h> 30#include <sound/hda_hwdep.h>
31#include <sound/minors.h> 31#include <sound/minors.h>
32 32
33/* hint string pair */
34struct hda_hint {
35 const char *key;
36 const char *val; /* contained in the same alloc as key */
37};
38
33/* 39/*
34 * write/read an out-of-bound verb 40 * write/read an out-of-bound verb
35 */ 41 */
@@ -99,16 +105,17 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
99 105
100static void clear_hwdep_elements(struct hda_codec *codec) 106static void clear_hwdep_elements(struct hda_codec *codec)
101{ 107{
102 char **head;
103 int i; 108 int i;
104 109
105 /* clear init verbs */ 110 /* clear init verbs */
106 snd_array_free(&codec->init_verbs); 111 snd_array_free(&codec->init_verbs);
107 /* clear hints */ 112 /* clear hints */
108 head = codec->hints.list; 113 for (i = 0; i < codec->hints.used; i++) {
109 for (i = 0; i < codec->hints.used; i++, head++) 114 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
110 kfree(*head); 115 kfree(hint->key); /* we don't need to free hint->val */
116 }
111 snd_array_free(&codec->hints); 117 snd_array_free(&codec->hints);
118 snd_array_free(&codec->user_pins);
112} 119}
113 120
114static void hwdep_free(struct snd_hwdep *hwdep) 121static void hwdep_free(struct snd_hwdep *hwdep)
@@ -140,7 +147,8 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
140#endif 147#endif
141 148
142 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); 149 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
143 snd_array_init(&codec->hints, sizeof(char *), 32); 150 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
151 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
144 152
145 return 0; 153 return 0;
146} 154}
@@ -153,7 +161,13 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
153 161
154static int clear_codec(struct hda_codec *codec) 162static int clear_codec(struct hda_codec *codec)
155{ 163{
156 snd_hda_codec_reset(codec); 164 int err;
165
166 err = snd_hda_codec_reset(codec);
167 if (err < 0) {
168 snd_printk(KERN_ERR "The codec is being used, can't free.\n");
169 return err;
170 }
157 clear_hwdep_elements(codec); 171 clear_hwdep_elements(codec);
158 return 0; 172 return 0;
159} 173}
@@ -162,20 +176,29 @@ static int reconfig_codec(struct hda_codec *codec)
162{ 176{
163 int err; 177 int err;
164 178
179 snd_hda_power_up(codec);
165 snd_printk(KERN_INFO "hda-codec: reconfiguring\n"); 180 snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
166 snd_hda_codec_reset(codec); 181 err = snd_hda_codec_reset(codec);
182 if (err < 0) {
183 snd_printk(KERN_ERR
184 "The codec is being used, can't reconfigure.\n");
185 goto error;
186 }
167 err = snd_hda_codec_configure(codec); 187 err = snd_hda_codec_configure(codec);
168 if (err < 0) 188 if (err < 0)
169 return err; 189 goto error;
170 /* rebuild PCMs */ 190 /* rebuild PCMs */
171 err = snd_hda_codec_build_pcms(codec); 191 err = snd_hda_codec_build_pcms(codec);
172 if (err < 0) 192 if (err < 0)
173 return err; 193 goto error;
174 /* rebuild mixers */ 194 /* rebuild mixers */
175 err = snd_hda_codec_build_controls(codec); 195 err = snd_hda_codec_build_controls(codec);
176 if (err < 0) 196 if (err < 0)
177 return err; 197 goto error;
178 return 0; 198 err = snd_card_register(codec->bus->card);
199 error:
200 snd_hda_power_down(codec);
201 return err;
179} 202}
180 203
181/* 204/*
@@ -271,47 +294,195 @@ static ssize_t type##_store(struct device *dev, \
271CODEC_ACTION_STORE(reconfig); 294CODEC_ACTION_STORE(reconfig);
272CODEC_ACTION_STORE(clear); 295CODEC_ACTION_STORE(clear);
273 296
297static ssize_t init_verbs_show(struct device *dev,
298 struct device_attribute *attr,
299 char *buf)
300{
301 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
302 struct hda_codec *codec = hwdep->private_data;
303 int i, len = 0;
304 for (i = 0; i < codec->init_verbs.used; i++) {
305 struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
306 len += snprintf(buf + len, PAGE_SIZE - len,
307 "0x%02x 0x%03x 0x%04x\n",
308 v->nid, v->verb, v->param);
309 }
310 return len;
311}
312
274static ssize_t init_verbs_store(struct device *dev, 313static ssize_t init_verbs_store(struct device *dev,
275 struct device_attribute *attr, 314 struct device_attribute *attr,
276 const char *buf, size_t count) 315 const char *buf, size_t count)
277{ 316{
278 struct snd_hwdep *hwdep = dev_get_drvdata(dev); 317 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
279 struct hda_codec *codec = hwdep->private_data; 318 struct hda_codec *codec = hwdep->private_data;
280 char *p; 319 struct hda_verb *v;
281 struct hda_verb verb, *v; 320 int nid, verb, param;
282 321
283 verb.nid = simple_strtoul(buf, &p, 0); 322 if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
284 verb.verb = simple_strtoul(p, &p, 0); 323 return -EINVAL;
285 verb.param = simple_strtoul(p, &p, 0); 324 if (!nid || !verb)
286 if (!verb.nid || !verb.verb || !verb.param)
287 return -EINVAL; 325 return -EINVAL;
288 v = snd_array_new(&codec->init_verbs); 326 v = snd_array_new(&codec->init_verbs);
289 if (!v) 327 if (!v)
290 return -ENOMEM; 328 return -ENOMEM;
291 *v = verb; 329 v->nid = nid;
330 v->verb = verb;
331 v->param = param;
292 return count; 332 return count;
293} 333}
294 334
335static ssize_t hints_show(struct device *dev,
336 struct device_attribute *attr,
337 char *buf)
338{
339 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
340 struct hda_codec *codec = hwdep->private_data;
341 int i, len = 0;
342 for (i = 0; i < codec->hints.used; i++) {
343 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
344 len += snprintf(buf + len, PAGE_SIZE - len,
345 "%s = %s\n", hint->key, hint->val);
346 }
347 return len;
348}
349
350static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
351{
352 int i;
353
354 for (i = 0; i < codec->hints.used; i++) {
355 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
356 if (!strcmp(hint->key, key))
357 return hint;
358 }
359 return NULL;
360}
361
362static void remove_trail_spaces(char *str)
363{
364 char *p;
365 if (!*str)
366 return;
367 p = str + strlen(str) - 1;
368 for (; isspace(*p); p--) {
369 *p = 0;
370 if (p == str)
371 return;
372 }
373}
374
375#define MAX_HINTS 1024
376
295static ssize_t hints_store(struct device *dev, 377static ssize_t hints_store(struct device *dev,
296 struct device_attribute *attr, 378 struct device_attribute *attr,
297 const char *buf, size_t count) 379 const char *buf, size_t count)
298{ 380{
299 struct snd_hwdep *hwdep = dev_get_drvdata(dev); 381 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
300 struct hda_codec *codec = hwdep->private_data; 382 struct hda_codec *codec = hwdep->private_data;
301 char *p; 383 char *key, *val;
302 char **hint; 384 struct hda_hint *hint;
303 385
304 if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n') 386 while (isspace(*buf))
387 buf++;
388 if (!*buf || *buf == '#' || *buf == '\n')
305 return count; 389 return count;
306 p = kstrndup_noeol(buf, 1024); 390 if (*buf == '=')
307 if (!p) 391 return -EINVAL;
392 key = kstrndup_noeol(buf, 1024);
393 if (!key)
308 return -ENOMEM; 394 return -ENOMEM;
309 hint = snd_array_new(&codec->hints); 395 /* extract key and val */
396 val = strchr(key, '=');
397 if (!val) {
398 kfree(key);
399 return -EINVAL;
400 }
401 *val++ = 0;
402 while (isspace(*val))
403 val++;
404 remove_trail_spaces(key);
405 remove_trail_spaces(val);
406 hint = get_hint(codec, key);
407 if (hint) {
408 /* replace */
409 kfree(hint->key);
410 hint->key = key;
411 hint->val = val;
412 return count;
413 }
414 /* allocate a new hint entry */
415 if (codec->hints.used >= MAX_HINTS)
416 hint = NULL;
417 else
418 hint = snd_array_new(&codec->hints);
310 if (!hint) { 419 if (!hint) {
311 kfree(p); 420 kfree(key);
312 return -ENOMEM; 421 return -ENOMEM;
313 } 422 }
314 *hint = p; 423 hint->key = key;
424 hint->val = val;
425 return count;
426}
427
428static ssize_t pin_configs_show(struct hda_codec *codec,
429 struct snd_array *list,
430 char *buf)
431{
432 int i, len = 0;
433 for (i = 0; i < list->used; i++) {
434 struct hda_pincfg *pin = snd_array_elem(list, i);
435 len += sprintf(buf + len, "0x%02x 0x%08x\n",
436 pin->nid, pin->cfg);
437 }
438 return len;
439}
440
441static ssize_t init_pin_configs_show(struct device *dev,
442 struct device_attribute *attr,
443 char *buf)
444{
445 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
446 struct hda_codec *codec = hwdep->private_data;
447 return pin_configs_show(codec, &codec->init_pins, buf);
448}
449
450static ssize_t user_pin_configs_show(struct device *dev,
451 struct device_attribute *attr,
452 char *buf)
453{
454 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
455 struct hda_codec *codec = hwdep->private_data;
456 return pin_configs_show(codec, &codec->user_pins, buf);
457}
458
459static ssize_t driver_pin_configs_show(struct device *dev,
460 struct device_attribute *attr,
461 char *buf)
462{
463 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
464 struct hda_codec *codec = hwdep->private_data;
465 return pin_configs_show(codec, &codec->driver_pins, buf);
466}
467
468#define MAX_PIN_CONFIGS 32
469
470static ssize_t user_pin_configs_store(struct device *dev,
471 struct device_attribute *attr,
472 const char *buf, size_t count)
473{
474 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
475 struct hda_codec *codec = hwdep->private_data;
476 int nid, cfg;
477 int err;
478
479 if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
480 return -EINVAL;
481 if (!nid)
482 return -EINVAL;
483 err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
484 if (err < 0)
485 return err;
315 return count; 486 return count;
316} 487}
317 488
@@ -330,8 +501,11 @@ static struct device_attribute codec_attrs[] = {
330 CODEC_ATTR_RO(mfg), 501 CODEC_ATTR_RO(mfg),
331 CODEC_ATTR_RW(name), 502 CODEC_ATTR_RW(name),
332 CODEC_ATTR_RW(modelname), 503 CODEC_ATTR_RW(modelname),
333 CODEC_ATTR_WO(init_verbs), 504 CODEC_ATTR_RW(init_verbs),
334 CODEC_ATTR_WO(hints), 505 CODEC_ATTR_RW(hints),
506 CODEC_ATTR_RO(init_pin_configs),
507 CODEC_ATTR_RW(user_pin_configs),
508 CODEC_ATTR_RO(driver_pin_configs),
335 CODEC_ATTR_WO(reconfig), 509 CODEC_ATTR_WO(reconfig),
336 CODEC_ATTR_WO(clear), 510 CODEC_ATTR_WO(clear),
337}; 511};
@@ -350,4 +524,29 @@ int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
350 return 0; 524 return 0;
351} 525}
352 526
527/*
528 * Look for hint string
529 */
530const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
531{
532 struct hda_hint *hint = get_hint(codec, key);
533 return hint ? hint->val : NULL;
534}
535EXPORT_SYMBOL_HDA(snd_hda_get_hint);
536
537int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
538{
539 const char *p = snd_hda_get_hint(codec, key);
540 if (!p || !*p)
541 return -ENOENT;
542 switch (toupper(*p)) {
543 case 'T': /* true */
544 case 'Y': /* yes */
545 case '1':
546 return 1;
547 }
548 return 0;
549}
550EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint);
551
353#endif /* CONFIG_SND_HDA_RECONFIG */ 552#endif /* CONFIG_SND_HDA_RECONFIG */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f9603443f086..21e99cfa8c49 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -312,6 +312,8 @@ struct azx_dev {
312 unsigned int period_bytes; /* size of the period in bytes */ 312 unsigned int period_bytes; /* size of the period in bytes */
313 unsigned int frags; /* number for period in the play buffer */ 313 unsigned int frags; /* number for period in the play buffer */
314 unsigned int fifo_size; /* FIFO size */ 314 unsigned int fifo_size; /* FIFO size */
315 unsigned long start_jiffies; /* start + minimum jiffies */
316 unsigned long min_jiffies; /* minimum jiffies before position is valid */
315 317
316 void __iomem *sd_addr; /* stream descriptor pointer */ 318 void __iomem *sd_addr; /* stream descriptor pointer */
317 319
@@ -330,7 +332,7 @@ struct azx_dev {
330 unsigned int opened :1; 332 unsigned int opened :1;
331 unsigned int running :1; 333 unsigned int running :1;
332 unsigned int irq_pending :1; 334 unsigned int irq_pending :1;
333 unsigned int irq_ignore :1; 335 unsigned int start_flag: 1; /* stream full start flag */
334 /* 336 /*
335 * For VIA: 337 * For VIA:
336 * A flag to ensure DMA position is 0 338 * A flag to ensure DMA position is 0
@@ -381,6 +383,7 @@ struct azx {
381 383
382 /* HD codec */ 384 /* HD codec */
383 unsigned short codec_mask; 385 unsigned short codec_mask;
386 int codec_probe_mask; /* copied from probe_mask option */
384 struct hda_bus *bus; 387 struct hda_bus *bus;
385 388
386 /* CORB/RIRB */ 389 /* CORB/RIRB */
@@ -858,13 +861,18 @@ static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
858 SD_CTL_DMA_START | SD_INT_MASK); 861 SD_CTL_DMA_START | SD_INT_MASK);
859} 862}
860 863
861/* stop a stream */ 864/* stop DMA */
862static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) 865static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
863{ 866{
864 /* stop DMA */
865 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & 867 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
866 ~(SD_CTL_DMA_START | SD_INT_MASK)); 868 ~(SD_CTL_DMA_START | SD_INT_MASK));
867 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ 869 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
870}
871
872/* stop a stream */
873static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
874{
875 azx_stream_clear(chip, azx_dev);
868 /* disable SIE */ 876 /* disable SIE */
869 azx_writeb(chip, INTCTL, 877 azx_writeb(chip, INTCTL,
870 azx_readb(chip, INTCTL) & ~(1 << azx_dev->index)); 878 azx_readb(chip, INTCTL) & ~(1 << azx_dev->index));
@@ -969,7 +977,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
969 struct azx *chip = dev_id; 977 struct azx *chip = dev_id;
970 struct azx_dev *azx_dev; 978 struct azx_dev *azx_dev;
971 u32 status; 979 u32 status;
972 int i; 980 int i, ok;
973 981
974 spin_lock(&chip->reg_lock); 982 spin_lock(&chip->reg_lock);
975 983
@@ -985,18 +993,14 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
985 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 993 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
986 if (!azx_dev->substream || !azx_dev->running) 994 if (!azx_dev->substream || !azx_dev->running)
987 continue; 995 continue;
988 /* ignore the first dummy IRQ (due to pos_adj) */
989 if (azx_dev->irq_ignore) {
990 azx_dev->irq_ignore = 0;
991 continue;
992 }
993 /* check whether this IRQ is really acceptable */ 996 /* check whether this IRQ is really acceptable */
994 if (azx_position_ok(chip, azx_dev)) { 997 ok = azx_position_ok(chip, azx_dev);
998 if (ok == 1) {
995 azx_dev->irq_pending = 0; 999 azx_dev->irq_pending = 0;
996 spin_unlock(&chip->reg_lock); 1000 spin_unlock(&chip->reg_lock);
997 snd_pcm_period_elapsed(azx_dev->substream); 1001 snd_pcm_period_elapsed(azx_dev->substream);
998 spin_lock(&chip->reg_lock); 1002 spin_lock(&chip->reg_lock);
999 } else if (chip->bus && chip->bus->workq) { 1003 } else if (ok == 0 && chip->bus && chip->bus->workq) {
1000 /* bogus IRQ, process it later */ 1004 /* bogus IRQ, process it later */
1001 azx_dev->irq_pending = 1; 1005 azx_dev->irq_pending = 1;
1002 queue_work(chip->bus->workq, 1006 queue_work(chip->bus->workq,
@@ -1075,15 +1079,13 @@ static int azx_setup_periods(struct azx *chip,
1075 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1079 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1076 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1080 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1077 1081
1078 period_bytes = snd_pcm_lib_period_bytes(substream); 1082 period_bytes = azx_dev->period_bytes;
1079 azx_dev->period_bytes = period_bytes;
1080 periods = azx_dev->bufsize / period_bytes; 1083 periods = azx_dev->bufsize / period_bytes;
1081 1084
1082 /* program the initial BDL entries */ 1085 /* program the initial BDL entries */
1083 bdl = (u32 *)azx_dev->bdl.area; 1086 bdl = (u32 *)azx_dev->bdl.area;
1084 ofs = 0; 1087 ofs = 0;
1085 azx_dev->frags = 0; 1088 azx_dev->frags = 0;
1086 azx_dev->irq_ignore = 0;
1087 pos_adj = bdl_pos_adj[chip->dev_index]; 1089 pos_adj = bdl_pos_adj[chip->dev_index];
1088 if (pos_adj > 0) { 1090 if (pos_adj > 0) {
1089 struct snd_pcm_runtime *runtime = substream->runtime; 1091 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1104,7 +1106,6 @@ static int azx_setup_periods(struct azx *chip,
1104 &bdl, ofs, pos_adj, 1); 1106 &bdl, ofs, pos_adj, 1);
1105 if (ofs < 0) 1107 if (ofs < 0)
1106 goto error; 1108 goto error;
1107 azx_dev->irq_ignore = 1;
1108 } 1109 }
1109 } else 1110 } else
1110 pos_adj = 0; 1111 pos_adj = 0;
@@ -1123,24 +1124,17 @@ static int azx_setup_periods(struct azx *chip,
1123 error: 1124 error:
1124 snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n", 1125 snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n",
1125 azx_dev->bufsize, period_bytes); 1126 azx_dev->bufsize, period_bytes);
1126 /* reset */
1127 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1128 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1129 return -EINVAL; 1127 return -EINVAL;
1130} 1128}
1131 1129
1132/* 1130/* reset stream */
1133 * set up the SD for streaming 1131static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
1134 */
1135static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1136{ 1132{
1137 unsigned char val; 1133 unsigned char val;
1138 int timeout; 1134 int timeout;
1139 1135
1140 /* make sure the run bit is zero for SD */ 1136 azx_stream_clear(chip, azx_dev);
1141 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & 1137
1142 ~SD_CTL_DMA_START);
1143 /* reset stream */
1144 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | 1138 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
1145 SD_CTL_STREAM_RESET); 1139 SD_CTL_STREAM_RESET);
1146 udelay(3); 1140 udelay(3);
@@ -1158,6 +1152,17 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1158 --timeout) 1152 --timeout)
1159 ; 1153 ;
1160 1154
1155 /* reset first position - may not be synced with hw at this time */
1156 *azx_dev->posbuf = 0;
1157}
1158
1159/*
1160 * set up the SD for streaming
1161 */
1162static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1163{
1164 /* make sure the run bit is zero for SD */
1165 azx_stream_clear(chip, azx_dev);
1161 /* program the stream_tag */ 1166 /* program the stream_tag */
1162 azx_sd_writel(azx_dev, SD_CTL, 1167 azx_sd_writel(azx_dev, SD_CTL,
1163 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)| 1168 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)|
@@ -1228,7 +1233,6 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1228}; 1233};
1229 1234
1230static int __devinit azx_codec_create(struct azx *chip, const char *model, 1235static int __devinit azx_codec_create(struct azx *chip, const char *model,
1231 unsigned int codec_probe_mask,
1232 int no_init) 1236 int no_init)
1233{ 1237{
1234 struct hda_bus_template bus_temp; 1238 struct hda_bus_template bus_temp;
@@ -1261,7 +1265,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1261 1265
1262 /* First try to probe all given codec slots */ 1266 /* First try to probe all given codec slots */
1263 for (c = 0; c < max_slots; c++) { 1267 for (c = 0; c < max_slots; c++) {
1264 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1268 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1265 if (probe_codec(chip, c) < 0) { 1269 if (probe_codec(chip, c) < 0) {
1266 /* Some BIOSen give you wrong codec addresses 1270 /* Some BIOSen give you wrong codec addresses
1267 * that don't exist 1271 * that don't exist
@@ -1285,7 +1289,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1285 1289
1286 /* Then create codec instances */ 1290 /* Then create codec instances */
1287 for (c = 0; c < max_slots; c++) { 1291 for (c = 0; c < max_slots; c++) {
1288 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1292 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1289 struct hda_codec *codec; 1293 struct hda_codec *codec;
1290 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); 1294 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec);
1291 if (err < 0) 1295 if (err < 0)
@@ -1403,6 +1407,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1403 runtime->private_data = azx_dev; 1407 runtime->private_data = azx_dev;
1404 snd_pcm_set_sync(substream); 1408 snd_pcm_set_sync(substream);
1405 mutex_unlock(&chip->open_mutex); 1409 mutex_unlock(&chip->open_mutex);
1410
1406 return 0; 1411 return 0;
1407} 1412}
1408 1413
@@ -1429,6 +1434,11 @@ static int azx_pcm_close(struct snd_pcm_substream *substream)
1429static int azx_pcm_hw_params(struct snd_pcm_substream *substream, 1434static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
1430 struct snd_pcm_hw_params *hw_params) 1435 struct snd_pcm_hw_params *hw_params)
1431{ 1436{
1437 struct azx_dev *azx_dev = get_azx_dev(substream);
1438
1439 azx_dev->bufsize = 0;
1440 azx_dev->period_bytes = 0;
1441 azx_dev->format_val = 0;
1432 return snd_pcm_lib_malloc_pages(substream, 1442 return snd_pcm_lib_malloc_pages(substream,
1433 params_buffer_bytes(hw_params)); 1443 params_buffer_bytes(hw_params));
1434} 1444}
@@ -1443,6 +1453,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
1443 azx_sd_writel(azx_dev, SD_BDLPL, 0); 1453 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1444 azx_sd_writel(azx_dev, SD_BDLPU, 0); 1454 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1445 azx_sd_writel(azx_dev, SD_CTL, 0); 1455 azx_sd_writel(azx_dev, SD_CTL, 0);
1456 azx_dev->bufsize = 0;
1457 azx_dev->period_bytes = 0;
1458 azx_dev->format_val = 0;
1446 1459
1447 hinfo->ops.cleanup(hinfo, apcm->codec, substream); 1460 hinfo->ops.cleanup(hinfo, apcm->codec, substream);
1448 1461
@@ -1456,23 +1469,40 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1456 struct azx_dev *azx_dev = get_azx_dev(substream); 1469 struct azx_dev *azx_dev = get_azx_dev(substream);
1457 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1470 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1458 struct snd_pcm_runtime *runtime = substream->runtime; 1471 struct snd_pcm_runtime *runtime = substream->runtime;
1472 unsigned int bufsize, period_bytes, format_val;
1473 int err;
1459 1474
1460 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); 1475 azx_stream_reset(chip, azx_dev);
1461 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate, 1476 format_val = snd_hda_calc_stream_format(runtime->rate,
1462 runtime->channels, 1477 runtime->channels,
1463 runtime->format, 1478 runtime->format,
1464 hinfo->maxbps); 1479 hinfo->maxbps);
1465 if (!azx_dev->format_val) { 1480 if (!format_val) {
1466 snd_printk(KERN_ERR SFX 1481 snd_printk(KERN_ERR SFX
1467 "invalid format_val, rate=%d, ch=%d, format=%d\n", 1482 "invalid format_val, rate=%d, ch=%d, format=%d\n",
1468 runtime->rate, runtime->channels, runtime->format); 1483 runtime->rate, runtime->channels, runtime->format);
1469 return -EINVAL; 1484 return -EINVAL;
1470 } 1485 }
1471 1486
1487 bufsize = snd_pcm_lib_buffer_bytes(substream);
1488 period_bytes = snd_pcm_lib_period_bytes(substream);
1489
1472 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", 1490 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1473 azx_dev->bufsize, azx_dev->format_val); 1491 bufsize, format_val);
1474 if (azx_setup_periods(chip, substream, azx_dev) < 0) 1492
1475 return -EINVAL; 1493 if (bufsize != azx_dev->bufsize ||
1494 period_bytes != azx_dev->period_bytes ||
1495 format_val != azx_dev->format_val) {
1496 azx_dev->bufsize = bufsize;
1497 azx_dev->period_bytes = period_bytes;
1498 azx_dev->format_val = format_val;
1499 err = azx_setup_periods(chip, substream, azx_dev);
1500 if (err < 0)
1501 return err;
1502 }
1503
1504 azx_dev->min_jiffies = (runtime->period_size * HZ) /
1505 (runtime->rate * 2);
1476 azx_setup_controller(chip, azx_dev); 1506 azx_setup_controller(chip, azx_dev);
1477 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1507 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1478 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1508 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
@@ -1489,13 +1519,14 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1489 struct azx *chip = apcm->chip; 1519 struct azx *chip = apcm->chip;
1490 struct azx_dev *azx_dev; 1520 struct azx_dev *azx_dev;
1491 struct snd_pcm_substream *s; 1521 struct snd_pcm_substream *s;
1492 int start, nsync = 0, sbits = 0; 1522 int rstart = 0, start, nsync = 0, sbits = 0;
1493 int nwait, timeout; 1523 int nwait, timeout;
1494 1524
1495 switch (cmd) { 1525 switch (cmd) {
1526 case SNDRV_PCM_TRIGGER_START:
1527 rstart = 1;
1496 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1528 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1497 case SNDRV_PCM_TRIGGER_RESUME: 1529 case SNDRV_PCM_TRIGGER_RESUME:
1498 case SNDRV_PCM_TRIGGER_START:
1499 start = 1; 1530 start = 1;
1500 break; 1531 break;
1501 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1532 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -1525,6 +1556,10 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1525 if (s->pcm->card != substream->pcm->card) 1556 if (s->pcm->card != substream->pcm->card)
1526 continue; 1557 continue;
1527 azx_dev = get_azx_dev(s); 1558 azx_dev = get_azx_dev(s);
1559 if (rstart) {
1560 azx_dev->start_flag = 1;
1561 azx_dev->start_jiffies = jiffies + azx_dev->min_jiffies;
1562 }
1528 if (start) 1563 if (start)
1529 azx_stream_start(chip, azx_dev); 1564 azx_stream_start(chip, azx_dev);
1530 else 1565 else
@@ -1674,6 +1709,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
1674{ 1709{
1675 unsigned int pos; 1710 unsigned int pos;
1676 1711
1712 if (azx_dev->start_flag &&
1713 time_before_eq(jiffies, azx_dev->start_jiffies))
1714 return -1; /* bogus (too early) interrupt */
1715 azx_dev->start_flag = 0;
1716
1677 pos = azx_get_position(chip, azx_dev); 1717 pos = azx_get_position(chip, azx_dev);
1678 if (chip->position_fix == POS_FIX_AUTO) { 1718 if (chip->position_fix == POS_FIX_AUTO) {
1679 if (!pos) { 1719 if (!pos) {
@@ -1947,16 +1987,13 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1947 return 0; 1987 return 0;
1948} 1988}
1949 1989
1950static int azx_resume_early(struct pci_dev *pci)
1951{
1952 return pci_restore_state(pci);
1953}
1954
1955static int azx_resume(struct pci_dev *pci) 1990static int azx_resume(struct pci_dev *pci)
1956{ 1991{
1957 struct snd_card *card = pci_get_drvdata(pci); 1992 struct snd_card *card = pci_get_drvdata(pci);
1958 struct azx *chip = card->private_data; 1993 struct azx *chip = card->private_data;
1959 1994
1995 pci_set_power_state(pci, PCI_D0);
1996 pci_restore_state(pci);
1960 if (pci_enable_device(pci) < 0) { 1997 if (pci_enable_device(pci) < 0) {
1961 printk(KERN_ERR "hda-intel: pci_enable_device failed, " 1998 printk(KERN_ERR "hda-intel: pci_enable_device failed, "
1962 "disabling device\n"); 1999 "disabling device\n");
@@ -2062,26 +2099,31 @@ static int __devinit check_position_fix(struct azx *chip, int fix)
2062{ 2099{
2063 const struct snd_pci_quirk *q; 2100 const struct snd_pci_quirk *q;
2064 2101
2065 /* Check VIA HD Audio Controller exist */ 2102 switch (fix) {
2066 if (chip->pci->vendor == PCI_VENDOR_ID_VIA && 2103 case POS_FIX_LPIB:
2067 chip->pci->device == VIA_HDAC_DEVICE_ID) { 2104 case POS_FIX_POSBUF:
2105 return fix;
2106 }
2107
2108 /* Check VIA/ATI HD Audio Controller exist */
2109 switch (chip->driver_type) {
2110 case AZX_DRIVER_VIA:
2111 case AZX_DRIVER_ATI:
2068 chip->via_dmapos_patch = 1; 2112 chip->via_dmapos_patch = 1;
2069 /* Use link position directly, avoid any transfer problem. */ 2113 /* Use link position directly, avoid any transfer problem. */
2070 return POS_FIX_LPIB; 2114 return POS_FIX_LPIB;
2071 } 2115 }
2072 chip->via_dmapos_patch = 0; 2116 chip->via_dmapos_patch = 0;
2073 2117
2074 if (fix == POS_FIX_AUTO) { 2118 q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
2075 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); 2119 if (q) {
2076 if (q) { 2120 printk(KERN_INFO
2077 printk(KERN_INFO 2121 "hda_intel: position_fix set to %d "
2078 "hda_intel: position_fix set to %d " 2122 "for device %04x:%04x\n",
2079 "for device %04x:%04x\n", 2123 q->value, q->subvendor, q->subdevice);
2080 q->value, q->subvendor, q->subdevice); 2124 return q->value;
2081 return q->value;
2082 }
2083 } 2125 }
2084 return fix; 2126 return POS_FIX_AUTO;
2085} 2127}
2086 2128
2087/* 2129/*
@@ -2098,23 +2140,36 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
2098 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01), 2140 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
2099 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ 2141 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
2100 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), 2142 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
2143 /* forced codec slots */
2144 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
2101 {} 2145 {}
2102}; 2146};
2103 2147
2148#define AZX_FORCE_CODEC_MASK 0x100
2149
2104static void __devinit check_probe_mask(struct azx *chip, int dev) 2150static void __devinit check_probe_mask(struct azx *chip, int dev)
2105{ 2151{
2106 const struct snd_pci_quirk *q; 2152 const struct snd_pci_quirk *q;
2107 2153
2108 if (probe_mask[dev] == -1) { 2154 chip->codec_probe_mask = probe_mask[dev];
2155 if (chip->codec_probe_mask == -1) {
2109 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 2156 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
2110 if (q) { 2157 if (q) {
2111 printk(KERN_INFO 2158 printk(KERN_INFO
2112 "hda_intel: probe_mask set to 0x%x " 2159 "hda_intel: probe_mask set to 0x%x "
2113 "for device %04x:%04x\n", 2160 "for device %04x:%04x\n",
2114 q->value, q->subvendor, q->subdevice); 2161 q->value, q->subvendor, q->subdevice);
2115 probe_mask[dev] = q->value; 2162 chip->codec_probe_mask = q->value;
2116 } 2163 }
2117 } 2164 }
2165
2166 /* check forced option */
2167 if (chip->codec_probe_mask != -1 &&
2168 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
2169 chip->codec_mask = chip->codec_probe_mask & 0xff;
2170 printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n",
2171 chip->codec_mask);
2172 }
2118} 2173}
2119 2174
2120 2175
@@ -2211,9 +2266,17 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2211 gcap = azx_readw(chip, GCAP); 2266 gcap = azx_readw(chip, GCAP);
2212 snd_printdd("chipset global capabilities = 0x%x\n", gcap); 2267 snd_printdd("chipset global capabilities = 0x%x\n", gcap);
2213 2268
2269 /* ATI chips seems buggy about 64bit DMA addresses */
2270 if (chip->driver_type == AZX_DRIVER_ATI)
2271 gcap &= ~0x01;
2272
2214 /* allow 64bit DMA address if supported by H/W */ 2273 /* allow 64bit DMA address if supported by H/W */
2215 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK)) 2274 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
2216 pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK); 2275 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
2276 else {
2277 pci_set_dma_mask(pci, DMA_BIT_MASK(32));
2278 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
2279 }
2217 2280
2218 /* read number of streams from GCAP register instead of using 2281 /* read number of streams from GCAP register instead of using
2219 * hardcoded value 2282 * hardcoded value
@@ -2347,8 +2410,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
2347 card->private_data = chip; 2410 card->private_data = chip;
2348 2411
2349 /* create codec instances */ 2412 /* create codec instances */
2350 err = azx_codec_create(chip, model[dev], probe_mask[dev], 2413 err = azx_codec_create(chip, model[dev], probe_only[dev]);
2351 probe_only[dev]);
2352 if (err < 0) 2414 if (err < 0)
2353 goto out_free; 2415 goto out_free;
2354 2416
@@ -2445,10 +2507,10 @@ static struct pci_device_id azx_ids[] = {
2445 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, 2507 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2446 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, 2508 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2447 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, 2509 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2448 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA }, 2510 { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
2449 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA }, 2511 { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
2450 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA }, 2512 { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
2451 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA }, 2513 { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
2452 /* Teradici */ 2514 /* Teradici */
2453 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2515 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
2454 /* AMD Generic, PCI class code and Vendor ID for HD Audio */ 2516 /* AMD Generic, PCI class code and Vendor ID for HD Audio */
@@ -2468,7 +2530,6 @@ static struct pci_driver driver = {
2468 .remove = __devexit_p(azx_remove), 2530 .remove = __devexit_p(azx_remove),
2469#ifdef CONFIG_PM 2531#ifdef CONFIG_PM
2470 .suspend = azx_suspend, 2532 .suspend = azx_suspend,
2471 .resume_early = azx_resume_early,
2472 .resume = azx_resume, 2533 .resume = azx_resume,
2473#endif 2534#endif
2474}; 2535};
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 6f2fe0f9fdd8..83349013b4df 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -26,8 +26,10 @@
26/* 26/*
27 * for mixer controls 27 * for mixer controls
28 */ 28 */
29#define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs) \
30 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
29#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \ 31#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
30 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19)) 32 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
31/* mono volume with index (index=0,1,...) (channel=1,2) */ 33/* mono volume with index (index=0,1,...) (channel=1,2) */
32#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 34#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
33 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 35 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
@@ -96,7 +98,7 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
96 const char *name); 98 const char *name);
97int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 99int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
98 unsigned int *tlv, const char **slaves); 100 unsigned int *tlv, const char **slaves);
99void snd_hda_codec_reset(struct hda_codec *codec); 101int snd_hda_codec_reset(struct hda_codec *codec);
100int snd_hda_codec_configure(struct hda_codec *codec); 102int snd_hda_codec_configure(struct hda_codec *codec);
101 103
102/* amp value bits */ 104/* amp value bits */
@@ -134,7 +136,7 @@ extern struct hda_ctl_ops snd_hda_bind_sw; /* for bind-switch */
134 136
135struct hda_bind_ctls { 137struct hda_bind_ctls {
136 struct hda_ctl_ops *ops; 138 struct hda_ctl_ops *ops;
137 long values[]; 139 unsigned long values[];
138}; 140};
139 141
140int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, 142int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
@@ -227,6 +229,7 @@ struct hda_multi_out {
227 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 229 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */
228 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */ 230 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */
229 hda_nid_t dig_out_nid; /* digital out audio widget */ 231 hda_nid_t dig_out_nid; /* digital out audio widget */
232 hda_nid_t *slave_dig_outs;
230 int max_channels; /* currently supported analog channels */ 233 int max_channels; /* currently supported analog channels */
231 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 234 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
232 int no_share_stream; /* don't share a stream with multiple pins */ 235 int no_share_stream; /* don't share a stream with multiple pins */
@@ -251,6 +254,8 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
251 unsigned int stream_tag, 254 unsigned int stream_tag,
252 unsigned int format, 255 unsigned int format,
253 struct snd_pcm_substream *substream); 256 struct snd_pcm_substream *substream);
257int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
258 struct hda_multi_out *mout);
254int snd_hda_multi_out_analog_open(struct hda_codec *codec, 259int snd_hda_multi_out_analog_open(struct hda_codec *codec,
255 struct hda_multi_out *mout, 260 struct hda_multi_out *mout,
256 struct snd_pcm_substream *substream, 261 struct snd_pcm_substream *substream,
@@ -296,6 +301,9 @@ void snd_print_pcm_bits(int pcm, char *buf, int buflen);
296int snd_hda_check_board_config(struct hda_codec *codec, int num_configs, 301int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
297 const char **modelnames, 302 const char **modelnames,
298 const struct snd_pci_quirk *pci_list); 303 const struct snd_pci_quirk *pci_list);
304int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
305 int num_configs, const char **models,
306 const struct snd_pci_quirk *tbl);
299int snd_hda_add_new_ctls(struct hda_codec *codec, 307int snd_hda_add_new_ctls(struct hda_codec *codec,
300 struct snd_kcontrol_new *knew); 308 struct snd_kcontrol_new *knew);
301 309
@@ -349,9 +357,12 @@ struct auto_pin_cfg {
349 int line_out_type; /* AUTO_PIN_XXX_OUT */ 357 int line_out_type; /* AUTO_PIN_XXX_OUT */
350 hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 358 hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
351 hda_nid_t input_pins[AUTO_PIN_LAST]; 359 hda_nid_t input_pins[AUTO_PIN_LAST];
352 hda_nid_t dig_out_pin; 360 int dig_outs;
361 hda_nid_t dig_out_pins[2];
353 hda_nid_t dig_in_pin; 362 hda_nid_t dig_in_pin;
354 hda_nid_t mono_out_pin; 363 hda_nid_t mono_out_pin;
364 int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
365 int dig_in_type; /* HDA_PCM_TYPE_XXX */
355}; 366};
356 367
357#define get_defcfg_connect(cfg) \ 368#define get_defcfg_connect(cfg) \
@@ -400,6 +411,7 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
400u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); 411u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
401int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 412int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
402 unsigned int caps); 413 unsigned int caps);
414u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
403 415
404int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl); 416int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl);
405void snd_hda_ctls_clear(struct hda_codec *codec); 417void snd_hda_ctls_clear(struct hda_codec *codec);
@@ -422,6 +434,23 @@ static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
422} 434}
423#endif 435#endif
424 436
437#ifdef CONFIG_SND_HDA_RECONFIG
438const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
439int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key);
440#else
441static inline
442const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
443{
444 return NULL;
445}
446
447static inline
448int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
449{
450 return -ENOENT;
451}
452#endif
453
425/* 454/*
426 * power-management 455 * power-management
427 */ 456 */
@@ -453,6 +482,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
453#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) 482#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
454#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 483#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
455#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 484#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
485#define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f)
456 486
457/* 487/*
458 * CEA Short Audio Descriptor data 488 * CEA Short Audio Descriptor data
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 7ca66d654148..93d7499350c6 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -399,7 +399,10 @@ static void print_conn_list(struct snd_info_buffer *buffer,
399{ 399{
400 int c, curr = -1; 400 int c, curr = -1;
401 401
402 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) 402 if (conn_len > 1 &&
403 wid_type != AC_WID_AUD_MIX &&
404 wid_type != AC_WID_VOL_KNB &&
405 wid_type != AC_WID_POWER)
403 curr = snd_hda_codec_read(codec, nid, 0, 406 curr = snd_hda_codec_read(codec, nid, 0,
404 AC_VERB_GET_CONNECT_SEL, 0); 407 AC_VERB_GET_CONNECT_SEL, 0);
405 snd_iprintf(buffer, " Connection: %d\n", conn_len); 408 snd_iprintf(buffer, " Connection: %d\n", conn_len);
@@ -466,8 +469,9 @@ static void print_codec_info(struct snd_info_entry *entry,
466 snd_iprintf(buffer, "Codec: %s\n", 469 snd_iprintf(buffer, "Codec: %s\n",
467 codec->name ? codec->name : "Not Set"); 470 codec->name ? codec->name : "Not Set");
468 snd_iprintf(buffer, "Address: %d\n", codec->addr); 471 snd_iprintf(buffer, "Address: %d\n", codec->addr);
469 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); 472 snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id);
470 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 473 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
474 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
471 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 475 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
472 476
473 if (codec->mfg) 477 if (codec->mfg)
@@ -553,8 +557,14 @@ static void print_codec_info(struct snd_info_entry *entry,
553 snd_iprintf(buffer, " Amp-Out caps: "); 557 snd_iprintf(buffer, " Amp-Out caps: ");
554 print_amp_caps(buffer, codec, nid, HDA_OUTPUT); 558 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
555 snd_iprintf(buffer, " Amp-Out vals: "); 559 snd_iprintf(buffer, " Amp-Out vals: ");
556 print_amp_vals(buffer, codec, nid, HDA_OUTPUT, 560 if (wid_type == AC_WID_PIN &&
557 wid_caps & AC_WCAP_STEREO, 1); 561 codec->pin_amp_workaround)
562 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
563 wid_caps & AC_WCAP_STEREO,
564 conn_len);
565 else
566 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
567 wid_caps & AC_WCAP_STEREO, 1);
558 } 568 }
559 569
560 switch (wid_type) { 570 switch (wid_type) {
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 2e7371ec2e23..84cc49ca9148 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -27,11 +27,12 @@
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_beep.h"
30 31
31struct ad198x_spec { 32struct ad198x_spec {
32 struct snd_kcontrol_new *mixers[5]; 33 struct snd_kcontrol_new *mixers[5];
33 int num_mixers; 34 int num_mixers;
34 35 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
35 const struct hda_verb *init_verbs[5]; /* initialization verbs 36 const struct hda_verb *init_verbs[5]; /* initialization verbs
36 * don't forget NULL termination! 37 * don't forget NULL termination!
37 */ 38 */
@@ -154,6 +155,16 @@ static const char *ad_slave_sws[] = {
154 155
155static void ad198x_free_kctls(struct hda_codec *codec); 156static void ad198x_free_kctls(struct hda_codec *codec);
156 157
158/* additional beep mixers; the actual parameters are overwritten at build */
159static struct snd_kcontrol_new ad_beep_mixer[] = {
160 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
161 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT),
162 { } /* end */
163};
164
165#define set_beep_amp(spec, nid, idx, dir) \
166 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
167
157static int ad198x_build_controls(struct hda_codec *codec) 168static int ad198x_build_controls(struct hda_codec *codec)
158{ 169{
159 struct ad198x_spec *spec = codec->spec; 170 struct ad198x_spec *spec = codec->spec;
@@ -181,6 +192,21 @@ static int ad198x_build_controls(struct hda_codec *codec)
181 return err; 192 return err;
182 } 193 }
183 194
195 /* create beep controls if needed */
196 if (spec->beep_amp) {
197 struct snd_kcontrol_new *knew;
198 for (knew = ad_beep_mixer; knew->name; knew++) {
199 struct snd_kcontrol *kctl;
200 kctl = snd_ctl_new1(knew, codec);
201 if (!kctl)
202 return -ENOMEM;
203 kctl->private_value = spec->beep_amp;
204 err = snd_hda_ctl_add(codec, kctl);
205 if (err < 0)
206 return err;
207 }
208 }
209
184 /* if we have no master control, let's create it */ 210 /* if we have no master control, let's create it */
185 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 211 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
186 unsigned int vmaster_tlv[4]; 212 unsigned int vmaster_tlv[4];
@@ -275,6 +301,14 @@ static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
275 format, substream); 301 format, substream);
276} 302}
277 303
304static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
305 struct hda_codec *codec,
306 struct snd_pcm_substream *substream)
307{
308 struct ad198x_spec *spec = codec->spec;
309 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
310}
311
278/* 312/*
279 * Analog capture 313 * Analog capture
280 */ 314 */
@@ -333,7 +367,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
333 .ops = { 367 .ops = {
334 .open = ad198x_dig_playback_pcm_open, 368 .open = ad198x_dig_playback_pcm_open,
335 .close = ad198x_dig_playback_pcm_close, 369 .close = ad198x_dig_playback_pcm_close,
336 .prepare = ad198x_dig_playback_pcm_prepare 370 .prepare = ad198x_dig_playback_pcm_prepare,
371 .cleanup = ad198x_dig_playback_pcm_cleanup
337 }, 372 },
338}; 373};
339 374
@@ -397,7 +432,8 @@ static void ad198x_free(struct hda_codec *codec)
397 return; 432 return;
398 433
399 ad198x_free_kctls(codec); 434 ad198x_free_kctls(codec);
400 kfree(codec->spec); 435 kfree(spec);
436 snd_hda_detach_beep_device(codec);
401} 437}
402 438
403static struct hda_codec_ops ad198x_patch_ops = { 439static struct hda_codec_ops ad198x_patch_ops = {
@@ -536,8 +572,6 @@ static struct snd_kcontrol_new ad1986a_mixers[] = {
536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
537 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 573 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
538 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 574 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
539 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
540 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
541 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 575 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
542 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), 576 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
543 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 577 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@ -601,8 +635,7 @@ static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
602 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 636 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
603 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 637 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
604 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), 638 /*
605 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
606 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 639 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
607 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ 640 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
608 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 641 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@ -800,8 +833,6 @@ static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = {
800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
801 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 834 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
802 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 835 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
803 HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT),
804 HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT),
805 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 836 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
806 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), 837 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
807 { 838 {
@@ -993,10 +1024,8 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
993 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), 1024 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
994 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), 1025 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
995 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), 1026 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
996 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_SAMSUNG),
997 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_SAMSUNG),
998 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_SAMSUNG),
999 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), 1027 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
1028 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
1000 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), 1029 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
1001 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), 1030 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
1002 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), 1031 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
@@ -1018,15 +1047,14 @@ static struct hda_amp_list ad1986a_loopbacks[] = {
1018 1047
1019static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) 1048static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
1020{ 1049{
1021 unsigned int conf = snd_hda_codec_read(codec, nid, 0, 1050 unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
1022 AC_VERB_GET_CONFIG_DEFAULT, 0);
1023 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; 1051 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
1024} 1052}
1025 1053
1026static int patch_ad1986a(struct hda_codec *codec) 1054static int patch_ad1986a(struct hda_codec *codec)
1027{ 1055{
1028 struct ad198x_spec *spec; 1056 struct ad198x_spec *spec;
1029 int board_config; 1057 int err, board_config;
1030 1058
1031 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1059 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1032 if (spec == NULL) 1060 if (spec == NULL)
@@ -1034,6 +1062,13 @@ static int patch_ad1986a(struct hda_codec *codec)
1034 1062
1035 codec->spec = spec; 1063 codec->spec = spec;
1036 1064
1065 err = snd_hda_attach_beep_device(codec, 0x19);
1066 if (err < 0) {
1067 ad198x_free(codec);
1068 return err;
1069 }
1070 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1071
1037 spec->multiout.max_channels = 6; 1072 spec->multiout.max_channels = 6;
1038 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); 1073 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
1039 spec->multiout.dac_nids = ad1986a_dac_nids; 1074 spec->multiout.dac_nids = ad1986a_dac_nids;
@@ -1213,8 +1248,6 @@ static struct snd_kcontrol_new ad1983_mixers[] = {
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), 1248 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1214 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1249 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1215 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), 1250 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1216 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
1217 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
1218 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), 1251 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
1219 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 1252 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1220 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), 1253 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
@@ -1285,6 +1318,7 @@ static struct hda_amp_list ad1983_loopbacks[] = {
1285static int patch_ad1983(struct hda_codec *codec) 1318static int patch_ad1983(struct hda_codec *codec)
1286{ 1319{
1287 struct ad198x_spec *spec; 1320 struct ad198x_spec *spec;
1321 int err;
1288 1322
1289 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1323 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1290 if (spec == NULL) 1324 if (spec == NULL)
@@ -1292,6 +1326,13 @@ static int patch_ad1983(struct hda_codec *codec)
1292 1326
1293 codec->spec = spec; 1327 codec->spec = spec;
1294 1328
1329 err = snd_hda_attach_beep_device(codec, 0x10);
1330 if (err < 0) {
1331 ad198x_free(codec);
1332 return err;
1333 }
1334 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1335
1295 spec->multiout.max_channels = 2; 1336 spec->multiout.max_channels = 2;
1296 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); 1337 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1297 spec->multiout.dac_nids = ad1983_dac_nids; 1338 spec->multiout.dac_nids = ad1983_dac_nids;
@@ -1361,8 +1402,6 @@ static struct snd_kcontrol_new ad1981_mixers[] = {
1361 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), 1402 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1362 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1403 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1363 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1404 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1364 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1365 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1366 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), 1405 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1367 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), 1406 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1368 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 1407 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
@@ -1407,8 +1446,8 @@ static struct hda_verb ad1981_init_verbs[] = {
1407 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1446 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1408 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1447 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1409 /* Mic boost: 0dB */ 1448 /* Mic boost: 0dB */
1410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1412 /* Record selector: Front mic */ 1451 /* Record selector: Front mic */
1413 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, 1452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
@@ -1673,10 +1712,10 @@ static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1673 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), 1712 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1674 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD), 1713 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
1675 /* All HP models */ 1714 /* All HP models */
1676 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), 1715 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
1677 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), 1716 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1678 /* Lenovo Thinkpad T60/X60/Z6xx */ 1717 /* Lenovo Thinkpad T60/X60/Z6xx */
1679 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), 1718 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
1680 /* HP nx6320 (reversed SSID, H/W bug) */ 1719 /* HP nx6320 (reversed SSID, H/W bug) */
1681 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), 1720 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1682 {} 1721 {}
@@ -1685,7 +1724,7 @@ static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1685static int patch_ad1981(struct hda_codec *codec) 1724static int patch_ad1981(struct hda_codec *codec)
1686{ 1725{
1687 struct ad198x_spec *spec; 1726 struct ad198x_spec *spec;
1688 int board_config; 1727 int err, board_config;
1689 1728
1690 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1691 if (spec == NULL) 1730 if (spec == NULL)
@@ -1693,6 +1732,13 @@ static int patch_ad1981(struct hda_codec *codec)
1693 1732
1694 codec->spec = spec; 1733 codec->spec = spec;
1695 1734
1735 err = snd_hda_attach_beep_device(codec, 0x10);
1736 if (err < 0) {
1737 ad198x_free(codec);
1738 return err;
1739 }
1740 set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
1741
1696 spec->multiout.max_channels = 2; 1742 spec->multiout.max_channels = 2;
1697 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); 1743 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1698 spec->multiout.dac_nids = ad1981_dac_nids; 1744 spec->multiout.dac_nids = ad1981_dac_nids;
@@ -1885,8 +1931,8 @@ static hda_nid_t ad1988_capsrc_nids[3] = {
1885#define AD1988_SPDIF_OUT_HDMI 0x0b 1931#define AD1988_SPDIF_OUT_HDMI 0x0b
1886#define AD1988_SPDIF_IN 0x07 1932#define AD1988_SPDIF_IN 0x07
1887 1933
1888static hda_nid_t ad1989b_slave_dig_outs[2] = { 1934static hda_nid_t ad1989b_slave_dig_outs[] = {
1889 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI 1935 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
1890}; 1936};
1891 1937
1892static struct hda_input_mux ad1988_6stack_capture_source = { 1938static struct hda_input_mux ad1988_6stack_capture_source = {
@@ -1979,9 +2025,6 @@ static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 2025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1980 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 2026 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1981 2027
1982 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1983 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1984
1985 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2028 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1986 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2029 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1987 2030
@@ -2025,9 +2068,6 @@ static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 2068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2026 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 2069 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2027 2070
2028 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2029 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2030
2031 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2071 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2032 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2072 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2033 2073
@@ -2057,9 +2097,6 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2057 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), 2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2058 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), 2098 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2059 2099
2060 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2061 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2062
2063 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2100 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2064 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2101 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2065 2102
@@ -2288,10 +2325,6 @@ static struct hda_verb ad1988_capture_init_verbs[] = {
2288 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2325 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2289 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2326 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2290 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2327 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2291 /* ADCs; muted */
2292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2295 2328
2296 { } 2329 { }
2297}; 2330};
@@ -2399,10 +2432,6 @@ static struct hda_verb ad1988_3stack_init_verbs[] = {
2399 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2432 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2400 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2433 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2401 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2434 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2402 /* ADCs; muted */
2403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2406 /* Analog Mix output amp */ 2435 /* Analog Mix output amp */
2407 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ 2436 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2408 { } 2437 { }
@@ -2474,10 +2503,6 @@ static struct hda_verb ad1988_laptop_init_verbs[] = {
2474 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2503 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2475 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2504 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2476 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2505 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2477 /* ADCs; muted */
2478 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2479 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2480 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2481 /* Analog Mix output amp */ 2506 /* Analog Mix output amp */
2482 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ 2507 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2483 { } 2508 { }
@@ -2881,7 +2906,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec)
2881 2906
2882 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2907 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2883 2908
2884 if (spec->autocfg.dig_out_pin) 2909 if (spec->autocfg.dig_outs)
2885 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 2910 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2886 if (spec->autocfg.dig_in_pin) 2911 if (spec->autocfg.dig_in_pin)
2887 spec->dig_in_nid = AD1988_SPDIF_IN; 2912 spec->dig_in_nid = AD1988_SPDIF_IN;
@@ -2931,7 +2956,7 @@ static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2931static int patch_ad1988(struct hda_codec *codec) 2956static int patch_ad1988(struct hda_codec *codec)
2932{ 2957{
2933 struct ad198x_spec *spec; 2958 struct ad198x_spec *spec;
2934 int board_config; 2959 int err, board_config;
2935 2960
2936 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2961 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2937 if (spec == NULL) 2962 if (spec == NULL)
@@ -2951,7 +2976,7 @@ static int patch_ad1988(struct hda_codec *codec)
2951 2976
2952 if (board_config == AD1988_AUTO) { 2977 if (board_config == AD1988_AUTO) {
2953 /* automatic parse from the BIOS config */ 2978 /* automatic parse from the BIOS config */
2954 int err = ad1988_parse_auto_config(codec); 2979 err = ad1988_parse_auto_config(codec);
2955 if (err < 0) { 2980 if (err < 0) {
2956 ad198x_free(codec); 2981 ad198x_free(codec);
2957 return err; 2982 return err;
@@ -2961,6 +2986,13 @@ static int patch_ad1988(struct hda_codec *codec)
2961 } 2986 }
2962 } 2987 }
2963 2988
2989 err = snd_hda_attach_beep_device(codec, 0x10);
2990 if (err < 0) {
2991 ad198x_free(codec);
2992 return err;
2993 }
2994 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
2995
2964 switch (board_config) { 2996 switch (board_config) {
2965 case AD1988_6STACK: 2997 case AD1988_6STACK:
2966 case AD1988_6STACK_DIG: 2998 case AD1988_6STACK_DIG:
@@ -3117,12 +3149,6 @@ static struct snd_kcontrol_new ad1884_base_mixers[] = {
3117 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), 3149 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3118 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), 3150 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3119 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), 3151 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3120 /*
3121 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3122 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3123 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
3124 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3125 */
3126 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT), 3152 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3153 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3128 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3154 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3195,10 +3221,10 @@ static struct hda_verb ad1884_init_verbs[] = {
3195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 3221 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
3196 /* Port-B (front mic) pin */ 3222 /* Port-B (front mic) pin */
3197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3199 /* Port-C (rear mic) pin */ 3225 /* Port-C (rear mic) pin */
3200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3227 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3202 /* Analog mixer; mute as default */ 3228 /* Analog mixer; mute as default */
3203 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3229 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3204 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3230 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
@@ -3230,8 +3256,8 @@ static const char *ad1884_slave_vols[] = {
3230 "Mic Playback Volume", 3256 "Mic Playback Volume",
3231 "CD Playback Volume", 3257 "CD Playback Volume",
3232 "Internal Mic Playback Volume", 3258 "Internal Mic Playback Volume",
3233 "Docking Mic Playback Volume" 3259 "Docking Mic Playback Volume",
3234 "Beep Playback Volume", 3260 /* "Beep Playback Volume", */
3235 "IEC958 Playback Volume", 3261 "IEC958 Playback Volume",
3236 NULL 3262 NULL
3237}; 3263};
@@ -3239,6 +3265,7 @@ static const char *ad1884_slave_vols[] = {
3239static int patch_ad1884(struct hda_codec *codec) 3265static int patch_ad1884(struct hda_codec *codec)
3240{ 3266{
3241 struct ad198x_spec *spec; 3267 struct ad198x_spec *spec;
3268 int err;
3242 3269
3243 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3270 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3244 if (spec == NULL) 3271 if (spec == NULL)
@@ -3246,6 +3273,13 @@ static int patch_ad1884(struct hda_codec *codec)
3246 3273
3247 codec->spec = spec; 3274 codec->spec = spec;
3248 3275
3276 err = snd_hda_attach_beep_device(codec, 0x10);
3277 if (err < 0) {
3278 ad198x_free(codec);
3279 return err;
3280 }
3281 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3282
3249 spec->multiout.max_channels = 2; 3283 spec->multiout.max_channels = 2;
3250 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids); 3284 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
3251 spec->multiout.dac_nids = ad1884_dac_nids; 3285 spec->multiout.dac_nids = ad1884_dac_nids;
@@ -3312,8 +3346,6 @@ static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3312 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3346 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3313 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), 3347 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3314 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3348 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3315 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3316 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3317 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3349 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3318 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), 3350 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3319 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), 3351 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
@@ -3349,7 +3381,7 @@ static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3349 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3350 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3382 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3351 /* docking mic boost */ 3383 /* docking mic boost */
3352 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3384 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3353 /* Analog mixer - docking mic; mute as default */ 3385 /* Analog mixer - docking mic; mute as default */
3354 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3386 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3355 /* enable EAPD bit */ 3387 /* enable EAPD bit */
@@ -3370,10 +3402,6 @@ static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), 3402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3371 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT), 3403 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3372 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT), 3404 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3373 /*
3374 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3375 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3376 */
3377 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT), 3405 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
3378 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3406 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3379 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3407 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3459,7 +3487,7 @@ static const char *ad1984_models[AD1984_MODELS] = {
3459 3487
3460static struct snd_pci_quirk ad1984_cfg_tbl[] = { 3488static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3461 /* Lenovo Thinkpad T61/X61 */ 3489 /* Lenovo Thinkpad T61/X61 */
3462 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD), 3490 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
3463 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP), 3491 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3464 {} 3492 {}
3465}; 3493};
@@ -3552,8 +3580,6 @@ static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3552 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT), 3580 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3553 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), 3581 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3554 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), 3582 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3555 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3556 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3557 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3583 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3558 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT), 3584 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3559 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3585 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@ -3613,10 +3639,10 @@ static struct hda_verb ad1884a_init_verbs[] = {
3613 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3639 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3614 /* Port-B (front mic) pin */ 3640 /* Port-B (front mic) pin */
3615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3617 /* Port-C (rear line-in) pin */ 3643 /* Port-C (rear line-in) pin */
3618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3620 /* Port-E (rear mic) pin */ 3646 /* Port-E (rear mic) pin */
3621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3647 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3622 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3648 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
@@ -3686,8 +3712,6 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3686 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), 3712 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3687 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT), 3713 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3688 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT), 3714 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3689 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3690 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3691 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3715 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3692 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), 3716 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3693 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3717 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@ -3715,8 +3739,6 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3715 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), 3739 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3716 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), 3740 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3717 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), 3741 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3718 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3719 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3720 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), 3742 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
3721 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT), 3743 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
3722 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3744 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3795,6 +3817,49 @@ static struct hda_verb ad1884a_laptop_verbs[] = {
3795 { } /* end */ 3817 { } /* end */
3796}; 3818};
3797 3819
3820static struct hda_verb ad1884a_mobile_verbs[] = {
3821 /* DACs; unmute as default */
3822 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3823 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3824 /* Port-A (HP) mixer - route only from analog mixer */
3825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3827 /* Port-A pin */
3828 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3829 /* Port-A (HP) pin - always unmuted */
3830 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3831 /* Port-B (mic jack) pin */
3832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3834 /* Port-C (int mic) pin */
3835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3837 /* Port-F (int speaker) mixer - route only from analog mixer */
3838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 /* Port-F pin */
3841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3843 /* Analog mixer; mute as default */
3844 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3845 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3846 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3847 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3848 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3849 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3850 /* Analog Mix output amp */
3851 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3852 /* capture sources */
3853 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
3854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3855 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3857 /* unsolicited event for pin-sense */
3858 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3860 { } /* end */
3861};
3862
3798/* 3863/*
3799 * Thinkpad X300 3864 * Thinkpad X300
3800 * 0x11 - HP 3865 * 0x11 - HP
@@ -3827,8 +3892,6 @@ static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
3827 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), 3892 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), 3893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3829 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), 3894 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3830 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3831 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3832 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3895 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3833 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT), 3896 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
3834 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3897 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3902,9 +3965,9 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3902 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), 3965 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3903 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), 3966 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
3904 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), 3967 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
3905 SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP), 3968 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
3906 SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP), 3969 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
3907 SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP), 3970 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
3908 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), 3971 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
3909 {} 3972 {}
3910}; 3973};
@@ -3912,7 +3975,7 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3912static int patch_ad1884a(struct hda_codec *codec) 3975static int patch_ad1884a(struct hda_codec *codec)
3913{ 3976{
3914 struct ad198x_spec *spec; 3977 struct ad198x_spec *spec;
3915 int board_config; 3978 int err, board_config;
3916 3979
3917 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3980 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3918 if (spec == NULL) 3981 if (spec == NULL)
@@ -3920,6 +3983,13 @@ static int patch_ad1884a(struct hda_codec *codec)
3920 3983
3921 codec->spec = spec; 3984 codec->spec = spec;
3922 3985
3986 err = snd_hda_attach_beep_device(codec, 0x10);
3987 if (err < 0) {
3988 ad198x_free(codec);
3989 return err;
3990 }
3991 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3992
3923 spec->multiout.max_channels = 2; 3993 spec->multiout.max_channels = 2;
3924 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids); 3994 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3925 spec->multiout.dac_nids = ad1884a_dac_nids; 3995 spec->multiout.dac_nids = ad1884a_dac_nids;
@@ -3950,13 +4020,29 @@ static int patch_ad1884a(struct hda_codec *codec)
3950 spec->input_mux = &ad1884a_laptop_capture_source; 4020 spec->input_mux = &ad1884a_laptop_capture_source;
3951 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; 4021 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3952 codec->patch_ops.init = ad1884a_hp_init; 4022 codec->patch_ops.init = ad1884a_hp_init;
4023 /* set the upper-limit for mixer amp to 0dB for avoiding the
4024 * possible damage by overloading
4025 */
4026 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4027 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4028 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4029 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4030 (1 << AC_AMPCAP_MUTE_SHIFT));
3953 break; 4031 break;
3954 case AD1884A_MOBILE: 4032 case AD1884A_MOBILE:
3955 spec->mixers[0] = ad1884a_mobile_mixers; 4033 spec->mixers[0] = ad1884a_mobile_mixers;
3956 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; 4034 spec->init_verbs[0] = ad1884a_mobile_verbs;
3957 spec->multiout.dig_out_nid = 0; 4035 spec->multiout.dig_out_nid = 0;
3958 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; 4036 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3959 codec->patch_ops.init = ad1884a_hp_init; 4037 codec->patch_ops.init = ad1884a_hp_init;
4038 /* set the upper-limit for mixer amp to 0dB for avoiding the
4039 * possible damage by overloading
4040 */
4041 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4042 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4043 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4044 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4045 (1 << AC_AMPCAP_MUTE_SHIFT));
3960 break; 4046 break;
3961 case AD1884A_THINKPAD: 4047 case AD1884A_THINKPAD:
3962 spec->mixers[0] = ad1984a_thinkpad_mixers; 4048 spec->mixers[0] = ad1984a_thinkpad_mixers;
@@ -4074,8 +4160,6 @@ static struct snd_kcontrol_new ad1882_loopback_mixers[] = {
4074 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT), 4160 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
4075 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), 4161 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4076 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), 4162 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4077 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4078 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4079 { } /* end */ 4163 { } /* end */
4080}; 4164};
4081 4165
@@ -4088,8 +4172,6 @@ static struct snd_kcontrol_new ad1882a_loopback_mixers[] = {
4088 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT), 4172 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
4089 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), 4173 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4090 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), 4174 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4091 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4092 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4093 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT), 4175 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
4094 { } /* end */ 4176 { } /* end */
4095}; 4177};
@@ -4248,7 +4330,7 @@ static const char *ad1882_models[AD1986A_MODELS] = {
4248static int patch_ad1882(struct hda_codec *codec) 4330static int patch_ad1882(struct hda_codec *codec)
4249{ 4331{
4250 struct ad198x_spec *spec; 4332 struct ad198x_spec *spec;
4251 int board_config; 4333 int err, board_config;
4252 4334
4253 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4335 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4254 if (spec == NULL) 4336 if (spec == NULL)
@@ -4256,6 +4338,13 @@ static int patch_ad1882(struct hda_codec *codec)
4256 4338
4257 codec->spec = spec; 4339 codec->spec = spec;
4258 4340
4341 err = snd_hda_attach_beep_device(codec, 0x10);
4342 if (err < 0) {
4343 ad198x_free(codec);
4344 return err;
4345 }
4346 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4347
4259 spec->multiout.max_channels = 6; 4348 spec->multiout.max_channels = 6;
4260 spec->multiout.num_dacs = 3; 4349 spec->multiout.num_dacs = 3;
4261 spec->multiout.dac_nids = ad1882_dac_nids; 4350 spec->multiout.dac_nids = ad1882_dac_nids;
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index f3ebe837f2d5..c921264bbd71 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -680,13 +680,13 @@ static int patch_cmi9880(struct hda_codec *codec)
680 struct auto_pin_cfg cfg; 680 struct auto_pin_cfg cfg;
681 681
682 /* collect pin default configuration */ 682 /* collect pin default configuration */
683 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 683 port_e = snd_hda_codec_get_pincfg(codec, 0x0f);
684 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 684 port_f = snd_hda_codec_get_pincfg(codec, 0x10);
685 spec->front_panel = 1; 685 spec->front_panel = 1;
686 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || 686 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
687 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { 687 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
688 port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 688 port_g = snd_hda_codec_get_pincfg(codec, 0x1f);
689 port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 689 port_h = snd_hda_codec_get_pincfg(codec, 0x20);
690 spec->channel_modes = cmi9880_channel_modes; 690 spec->channel_modes = cmi9880_channel_modes;
691 /* no front panel */ 691 /* no front panel */
692 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || 692 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
@@ -703,8 +703,8 @@ static int patch_cmi9880(struct hda_codec *codec)
703 spec->multiout.max_channels = cmi9880_channel_modes[0].channels; 703 spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
704 } else { 704 } else {
705 spec->input_mux = &cmi9880_basic_mux; 705 spec->input_mux = &cmi9880_basic_mux;
706 port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 706 port_spdifi = snd_hda_codec_get_pincfg(codec, 0x13);
707 port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 707 port_spdifo = snd_hda_codec_get_pincfg(codec, 0x12);
708 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) 708 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
709 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 709 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
710 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) 710 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 75de40aaab0a..56ce19e68cb5 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -58,6 +58,7 @@ struct conexant_spec {
58 58
59 struct snd_kcontrol_new *mixers[5]; 59 struct snd_kcontrol_new *mixers[5];
60 int num_mixers; 60 int num_mixers;
61 hda_nid_t vmaster_nid;
61 62
62 const struct hda_verb *init_verbs[5]; /* initialization verbs 63 const struct hda_verb *init_verbs[5]; /* initialization verbs
63 * don't forget NULL 64 * don't forget NULL
@@ -72,6 +73,7 @@ struct conexant_spec {
72 */ 73 */
73 unsigned int cur_eapd; 74 unsigned int cur_eapd;
74 unsigned int hp_present; 75 unsigned int hp_present;
76 unsigned int no_auto_mic;
75 unsigned int need_dac_fix; 77 unsigned int need_dac_fix;
76 78
77 /* capture */ 79 /* capture */
@@ -347,12 +349,21 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
347 &spec->cur_mux[adc_idx]); 349 &spec->cur_mux[adc_idx]);
348} 350}
349 351
352#ifdef CONFIG_SND_JACK
353static void conexant_free_jack_priv(struct snd_jack *jack)
354{
355 struct conexant_jack *jacks = jack->private_data;
356 jacks->nid = 0;
357 jacks->jack = NULL;
358}
359
350static int conexant_add_jack(struct hda_codec *codec, 360static int conexant_add_jack(struct hda_codec *codec,
351 hda_nid_t nid, int type) 361 hda_nid_t nid, int type)
352{ 362{
353 struct conexant_spec *spec; 363 struct conexant_spec *spec;
354 struct conexant_jack *jack; 364 struct conexant_jack *jack;
355 const char *name; 365 const char *name;
366 int err;
356 367
357 spec = codec->spec; 368 spec = codec->spec;
358 snd_array_init(&spec->jacks, sizeof(*jack), 32); 369 snd_array_init(&spec->jacks, sizeof(*jack), 32);
@@ -365,7 +376,12 @@ static int conexant_add_jack(struct hda_codec *codec,
365 jack->nid = nid; 376 jack->nid = nid;
366 jack->type = type; 377 jack->type = type;
367 378
368 return snd_jack_new(codec->bus->card, name, type, &jack->jack); 379 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
380 if (err < 0)
381 return err;
382 jack->jack->private_data = jack;
383 jack->jack->private_free = conexant_free_jack_priv;
384 return 0;
369} 385}
370 386
371static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) 387static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
@@ -394,7 +410,6 @@ static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
394 410
395static int conexant_init_jacks(struct hda_codec *codec) 411static int conexant_init_jacks(struct hda_codec *codec)
396{ 412{
397#ifdef CONFIG_SND_JACK
398 struct conexant_spec *spec = codec->spec; 413 struct conexant_spec *spec = codec->spec;
399 int i; 414 int i;
400 415
@@ -422,10 +437,19 @@ static int conexant_init_jacks(struct hda_codec *codec)
422 ++hv; 437 ++hv;
423 } 438 }
424 } 439 }
425#endif
426 return 0; 440 return 0;
427 441
428} 442}
443#else
444static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
445{
446}
447
448static inline int conexant_init_jacks(struct hda_codec *codec)
449{
450 return 0;
451}
452#endif
429 453
430static int conexant_init(struct hda_codec *codec) 454static int conexant_init(struct hda_codec *codec)
431{ 455{
@@ -444,14 +468,39 @@ static void conexant_free(struct hda_codec *codec)
444 if (spec->jacks.list) { 468 if (spec->jacks.list) {
445 struct conexant_jack *jacks = spec->jacks.list; 469 struct conexant_jack *jacks = spec->jacks.list;
446 int i; 470 int i;
447 for (i = 0; i < spec->jacks.used; i++) 471 for (i = 0; i < spec->jacks.used; i++, jacks++) {
448 snd_device_free(codec->bus->card, &jacks[i].jack); 472 if (jacks->jack)
473 snd_device_free(codec->bus->card, jacks->jack);
474 }
449 snd_array_free(&spec->jacks); 475 snd_array_free(&spec->jacks);
450 } 476 }
451#endif 477#endif
452 kfree(codec->spec); 478 kfree(codec->spec);
453} 479}
454 480
481static struct snd_kcontrol_new cxt_capture_mixers[] = {
482 {
483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
484 .name = "Capture Source",
485 .info = conexant_mux_enum_info,
486 .get = conexant_mux_enum_get,
487 .put = conexant_mux_enum_put
488 },
489 {}
490};
491
492static const char *slave_vols[] = {
493 "Headphone Playback Volume",
494 "Speaker Playback Volume",
495 NULL
496};
497
498static const char *slave_sws[] = {
499 "Headphone Playback Switch",
500 "Speaker Playback Switch",
501 NULL
502};
503
455static int conexant_build_controls(struct hda_codec *codec) 504static int conexant_build_controls(struct hda_codec *codec)
456{ 505{
457 struct conexant_spec *spec = codec->spec; 506 struct conexant_spec *spec = codec->spec;
@@ -479,6 +528,32 @@ static int conexant_build_controls(struct hda_codec *codec)
479 if (err < 0) 528 if (err < 0)
480 return err; 529 return err;
481 } 530 }
531
532 /* if we have no master control, let's create it */
533 if (spec->vmaster_nid &&
534 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
535 unsigned int vmaster_tlv[4];
536 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
537 HDA_OUTPUT, vmaster_tlv);
538 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
539 vmaster_tlv, slave_vols);
540 if (err < 0)
541 return err;
542 }
543 if (spec->vmaster_nid &&
544 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
545 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
546 NULL, slave_sws);
547 if (err < 0)
548 return err;
549 }
550
551 if (spec->input_mux) {
552 err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
553 if (err < 0)
554 return err;
555 }
556
482 return 0; 557 return 0;
483} 558}
484 559
@@ -710,13 +785,6 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
710} 785}
711 786
712static struct snd_kcontrol_new cxt5045_mixers[] = { 787static struct snd_kcontrol_new cxt5045_mixers[] = {
713 {
714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
715 .name = "Capture Source",
716 .info = conexant_mux_enum_info,
717 .get = conexant_mux_enum_get,
718 .put = conexant_mux_enum_put
719 },
720 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), 788 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
721 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), 789 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
722 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), 790 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
@@ -750,13 +818,6 @@ static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
750}; 818};
751 819
752static struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 820static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
753 {
754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
755 .name = "Capture Source",
756 .info = conexant_mux_enum_info,
757 .get = conexant_mux_enum_get,
758 .put = conexant_mux_enum_put
759 },
760 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), 821 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
761 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), 822 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
762 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), 823 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
@@ -993,15 +1054,9 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
993}; 1054};
994 1055
995static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 1056static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
996 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
997 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
998 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
999 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
1000 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
1001 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
1002 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
1003 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 1057 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1004 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE), 1058 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1059 CXT5045_LAPTOP_HPSENSE),
1005 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 1060 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1006 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 1061 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1007 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 1062 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
@@ -1011,8 +1066,8 @@ static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1011 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1066 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1012 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1067 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1013 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1068 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1014 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE), 1069 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1015 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE), 1070 CXT5045_LAPTOP_HPMICSENSE),
1016 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1071 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
1017 {} 1072 {}
1018}; 1073};
@@ -1026,6 +1081,7 @@ static int patch_cxt5045(struct hda_codec *codec)
1026 if (!spec) 1081 if (!spec)
1027 return -ENOMEM; 1082 return -ENOMEM;
1028 codec->spec = spec; 1083 codec->spec = spec;
1084 codec->pin_amp_workaround = 1;
1029 1085
1030 spec->multiout.max_channels = 2; 1086 spec->multiout.max_channels = 2;
1031 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1087 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
@@ -1125,7 +1181,7 @@ static int patch_cxt5045(struct hda_codec *codec)
1125/* Conexant 5047 specific */ 1181/* Conexant 5047 specific */
1126#define CXT5047_SPDIF_OUT 0x11 1182#define CXT5047_SPDIF_OUT 0x11
1127 1183
1128static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c }; 1184static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
1129static hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 1185static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1130static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1186static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1131 1187
@@ -1133,20 +1189,6 @@ static struct hda_channel_mode cxt5047_modes[1] = {
1133 { 2, NULL }, 1189 { 2, NULL },
1134}; 1190};
1135 1191
1136static struct hda_input_mux cxt5047_capture_source = {
1137 .num_items = 1,
1138 .items = {
1139 { "Mic", 0x2 },
1140 }
1141};
1142
1143static struct hda_input_mux cxt5047_hp_capture_source = {
1144 .num_items = 1,
1145 .items = {
1146 { "ExtMic", 0x2 },
1147 }
1148};
1149
1150static struct hda_input_mux cxt5047_toshiba_capture_source = { 1192static struct hda_input_mux cxt5047_toshiba_capture_source = {
1151 .num_items = 2, 1193 .num_items = 2,
1152 .items = { 1194 .items = {
@@ -1170,7 +1212,11 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1170 * the headphone jack 1212 * the headphone jack
1171 */ 1213 */
1172 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 1214 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1173 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0, 1215 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1216 * pin widgets unlike other codecs. In this case, we need to
1217 * set index 0x01 for the volume from the mixer amp 0x19.
1218 */
1219 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1174 HDA_AMP_MUTE, bits); 1220 HDA_AMP_MUTE, bits);
1175 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 1221 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1176 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 1222 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
@@ -1178,16 +1224,6 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1178 return 1; 1224 return 1;
1179} 1225}
1180 1226
1181/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1182static struct hda_bind_ctls cxt5047_bind_master_vol = {
1183 .ops = &snd_hda_bind_vol,
1184 .values = {
1185 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1186 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1187 0
1188 },
1189};
1190
1191/* mute internal speaker if HP is plugged */ 1227/* mute internal speaker if HP is plugged */
1192static void cxt5047_hp_automute(struct hda_codec *codec) 1228static void cxt5047_hp_automute(struct hda_codec *codec)
1193{ 1229{
@@ -1198,27 +1234,8 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
1198 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1199 1235
1200 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 1236 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1201 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0, 1237 /* See the note in cxt5047_hp_master_sw_put */
1202 HDA_AMP_MUTE, bits); 1238 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1203 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1204 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1205 HDA_AMP_MUTE, bits);
1206}
1207
1208/* mute internal speaker if HP is plugged */
1209static void cxt5047_hp2_automute(struct hda_codec *codec)
1210{
1211 struct conexant_spec *spec = codec->spec;
1212 unsigned int bits;
1213
1214 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1215 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1216
1217 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1218 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1219 HDA_AMP_MUTE, bits);
1220 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1221 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1222 HDA_AMP_MUTE, bits); 1239 HDA_AMP_MUTE, bits);
1223} 1240}
1224 1241
@@ -1259,55 +1276,14 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1259 } 1276 }
1260} 1277}
1261 1278
1262/* unsolicited event for HP jack sensing - non-EAPD systems */ 1279static struct snd_kcontrol_new cxt5047_base_mixers[] = {
1263static void cxt5047_hp2_unsol_event(struct hda_codec *codec, 1280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
1264 unsigned int res) 1281 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
1265{ 1282 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
1266 res >>= 26;
1267 switch (res) {
1268 case CONEXANT_HP_EVENT:
1269 cxt5047_hp2_automute(codec);
1270 break;
1271 case CONEXANT_MIC_EVENT:
1272 cxt5047_hp_automic(codec);
1273 break;
1274 }
1275}
1276
1277static struct snd_kcontrol_new cxt5047_mixers[] = {
1278 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1279 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1280 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1281 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1282 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1283 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1283 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1284 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1284 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1285 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1285 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 1286 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1286 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1287 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1288 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1289 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1290 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1292
1293 {}
1294};
1295
1296static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1297 {
1298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1299 .name = "Capture Source",
1300 .info = conexant_mux_enum_info,
1301 .get = conexant_mux_enum_get,
1302 .put = conexant_mux_enum_put
1303 },
1304 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1305 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1306 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1307 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1308 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1309 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1310 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1311 { 1287 {
1312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1313 .name = "Master Playback Switch", 1289 .name = "Master Playback Switch",
@@ -1320,29 +1296,15 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1320 {} 1296 {}
1321}; 1297};
1322 1298
1323static struct snd_kcontrol_new cxt5047_hp_mixers[] = { 1299static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
1324 { 1300 /* See the note in cxt5047_hp_master_sw_put */
1325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1301 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
1326 .name = "Capture Source", 1302 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1327 .info = conexant_mux_enum_info, 1303 {}
1328 .get = conexant_mux_enum_get, 1304};
1329 .put = conexant_mux_enum_put 1305
1330 }, 1306static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
1331 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1332 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1333 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1334 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1335 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1336 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1337 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1307 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1338 {
1339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1340 .name = "Master Playback Switch",
1341 .info = cxt_eapd_info,
1342 .get = cxt_eapd_get,
1343 .put = cxt5047_hp_master_sw_put,
1344 .private_value = 0x13,
1345 },
1346 { } /* end */ 1308 { } /* end */
1347}; 1309};
1348 1310
@@ -1353,8 +1315,8 @@ static struct hda_verb cxt5047_init_verbs[] = {
1353 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1315 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1354 /* HP, Speaker */ 1316 /* HP, Speaker */
1355 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 1317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1356 {0x13, AC_VERB_SET_CONNECT_SEL,0x1}, 1318 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
1357 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0}, 1319 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
1358 /* Record selector: Mic */ 1320 /* Record selector: Mic */
1359 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1321 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
@@ -1374,30 +1336,7 @@ static struct hda_verb cxt5047_init_verbs[] = {
1374 1336
1375/* configuration for Toshiba Laptops */ 1337/* configuration for Toshiba Laptops */
1376static struct hda_verb cxt5047_toshiba_init_verbs[] = { 1338static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1377 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */ 1339 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
1378 /* pin sensing on HP and Mic jacks */
1379 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1380 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1381 /* Speaker routing */
1382 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1383 {}
1384};
1385
1386/* configuration for HP Laptops */
1387static struct hda_verb cxt5047_hp_init_verbs[] = {
1388 /* pin sensing on HP jack */
1389 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1390 /* 0x13 is actually shared by both HP and speaker;
1391 * setting the connection to 0 (=0x19) makes the master volume control
1392 * working mysteriouslly...
1393 */
1394 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1395 /* Record selector: Ext Mic */
1396 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1398 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1399 /* Speaker routing */
1400 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1401 {} 1340 {}
1402}; 1341};
1403 1342
@@ -1562,10 +1501,9 @@ static const char *cxt5047_models[CXT5047_MODELS] = {
1562}; 1501};
1563 1502
1564static struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1503static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1565 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1566 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1504 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1567 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP), 1505 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1568 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP), 1506 CXT5047_LAPTOP),
1569 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1507 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1570 {} 1508 {}
1571}; 1509};
@@ -1579,6 +1517,7 @@ static int patch_cxt5047(struct hda_codec *codec)
1579 if (!spec) 1517 if (!spec)
1580 return -ENOMEM; 1518 return -ENOMEM;
1581 codec->spec = spec; 1519 codec->spec = spec;
1520 codec->pin_amp_workaround = 1;
1582 1521
1583 spec->multiout.max_channels = 2; 1522 spec->multiout.max_channels = 2;
1584 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1523 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
@@ -1587,9 +1526,8 @@ static int patch_cxt5047(struct hda_codec *codec)
1587 spec->num_adc_nids = 1; 1526 spec->num_adc_nids = 1;
1588 spec->adc_nids = cxt5047_adc_nids; 1527 spec->adc_nids = cxt5047_adc_nids;
1589 spec->capsrc_nids = cxt5047_capsrc_nids; 1528 spec->capsrc_nids = cxt5047_capsrc_nids;
1590 spec->input_mux = &cxt5047_capture_source;
1591 spec->num_mixers = 1; 1529 spec->num_mixers = 1;
1592 spec->mixers[0] = cxt5047_mixers; 1530 spec->mixers[0] = cxt5047_base_mixers;
1593 spec->num_init_verbs = 1; 1531 spec->num_init_verbs = 1;
1594 spec->init_verbs[0] = cxt5047_init_verbs; 1532 spec->init_verbs[0] = cxt5047_init_verbs;
1595 spec->spdif_route = 0; 1533 spec->spdif_route = 0;
@@ -1603,21 +1541,22 @@ static int patch_cxt5047(struct hda_codec *codec)
1603 cxt5047_cfg_tbl); 1541 cxt5047_cfg_tbl);
1604 switch (board_config) { 1542 switch (board_config) {
1605 case CXT5047_LAPTOP: 1543 case CXT5047_LAPTOP:
1606 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; 1544 spec->num_mixers = 2;
1545 spec->mixers[1] = cxt5047_hp_spk_mixers;
1546 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1607 break; 1547 break;
1608 case CXT5047_LAPTOP_HP: 1548 case CXT5047_LAPTOP_HP:
1609 spec->input_mux = &cxt5047_hp_capture_source; 1549 spec->num_mixers = 2;
1610 spec->num_init_verbs = 2; 1550 spec->mixers[1] = cxt5047_hp_only_mixers;
1611 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1612 spec->mixers[0] = cxt5047_hp_mixers;
1613 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1551 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1614 codec->patch_ops.init = cxt5047_hp_init; 1552 codec->patch_ops.init = cxt5047_hp_init;
1615 break; 1553 break;
1616 case CXT5047_LAPTOP_EAPD: 1554 case CXT5047_LAPTOP_EAPD:
1617 spec->input_mux = &cxt5047_toshiba_capture_source; 1555 spec->input_mux = &cxt5047_toshiba_capture_source;
1556 spec->num_mixers = 2;
1557 spec->mixers[1] = cxt5047_hp_spk_mixers;
1618 spec->num_init_verbs = 2; 1558 spec->num_init_verbs = 2;
1619 spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1559 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1620 spec->mixers[0] = cxt5047_toshiba_mixers;
1621 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1560 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1622 break; 1561 break;
1623#ifdef CONFIG_SND_DEBUG 1562#ifdef CONFIG_SND_DEBUG
@@ -1628,6 +1567,7 @@ static int patch_cxt5047(struct hda_codec *codec)
1628 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1567 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1629#endif 1568#endif
1630 } 1569 }
1570 spec->vmaster_nid = 0x13;
1631 return 0; 1571 return 0;
1632} 1572}
1633 1573
@@ -1663,8 +1603,11 @@ static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1663/* toggle input of built-in and mic jack appropriately */ 1603/* toggle input of built-in and mic jack appropriately */
1664static void cxt5051_portb_automic(struct hda_codec *codec) 1604static void cxt5051_portb_automic(struct hda_codec *codec)
1665{ 1605{
1606 struct conexant_spec *spec = codec->spec;
1666 unsigned int present; 1607 unsigned int present;
1667 1608
1609 if (spec->no_auto_mic)
1610 return;
1668 present = snd_hda_codec_read(codec, 0x17, 0, 1611 present = snd_hda_codec_read(codec, 0x17, 0,
1669 AC_VERB_GET_PIN_SENSE, 0) & 1612 AC_VERB_GET_PIN_SENSE, 0) &
1670 AC_PINSENSE_PRESENCE; 1613 AC_PINSENSE_PRESENCE;
@@ -1680,6 +1623,8 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
1680 unsigned int present; 1623 unsigned int present;
1681 hda_nid_t new_adc; 1624 hda_nid_t new_adc;
1682 1625
1626 if (spec->no_auto_mic)
1627 return;
1683 present = snd_hda_codec_read(codec, 0x18, 0, 1628 present = snd_hda_codec_read(codec, 0x18, 0,
1684 AC_VERB_GET_PIN_SENSE, 0) & 1629 AC_VERB_GET_PIN_SENSE, 0) &
1685 AC_PINSENSE_PRESENCE; 1630 AC_PINSENSE_PRESENCE;
@@ -1766,6 +1711,22 @@ static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1766 {} 1711 {}
1767}; 1712};
1768 1713
1714static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
1715 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT),
1716 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT),
1717 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1718 {
1719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1720 .name = "Master Playback Switch",
1721 .info = cxt_eapd_info,
1722 .get = cxt_eapd_get,
1723 .put = cxt5051_hp_master_sw_put,
1724 .private_value = 0x1a,
1725 },
1726
1727 {}
1728};
1729
1769static struct hda_verb cxt5051_init_verbs[] = { 1730static struct hda_verb cxt5051_init_verbs[] = {
1770 /* Line in, Mic */ 1731 /* Line in, Mic */
1771 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
@@ -1796,6 +1757,66 @@ static struct hda_verb cxt5051_init_verbs[] = {
1796 { } /* end */ 1757 { } /* end */
1797}; 1758};
1798 1759
1760static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
1761 /* Line in, Mic */
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1765 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1766 /* SPK */
1767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1768 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1769 /* HP, Amp */
1770 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1771 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1772 /* DAC1 */
1773 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774 /* Record selector: Int mic */
1775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1776 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1777 /* SPDIF route: PCM */
1778 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1779 /* EAPD */
1780 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1781 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1782 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1783 { } /* end */
1784};
1785
1786static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
1787 /* Line in, Mic */
1788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1792 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1793 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1794 /* SPK */
1795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1796 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1797 /* HP, Amp */
1798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1799 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1800 /* Docking HP */
1801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
1803 /* DAC1 */
1804 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1805 /* Record selector: Int mic */
1806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1809 /* SPDIF route: PCM */
1810 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1811 /* EAPD */
1812 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1813 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1814 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1815 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1816 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1817 { } /* end */
1818};
1819
1799/* initialize jack-sensing, too */ 1820/* initialize jack-sensing, too */
1800static int cxt5051_init(struct hda_codec *codec) 1821static int cxt5051_init(struct hda_codec *codec)
1801{ 1822{
@@ -1813,18 +1834,24 @@ static int cxt5051_init(struct hda_codec *codec)
1813enum { 1834enum {
1814 CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1835 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1815 CXT5051_HP, /* no docking */ 1836 CXT5051_HP, /* no docking */
1837 CXT5051_HP_DV6736, /* HP without mic switch */
1838 CXT5051_LENOVO_X200, /* Lenovo X200 laptop */
1816 CXT5051_MODELS 1839 CXT5051_MODELS
1817}; 1840};
1818 1841
1819static const char *cxt5051_models[CXT5051_MODELS] = { 1842static const char *cxt5051_models[CXT5051_MODELS] = {
1820 [CXT5051_LAPTOP] = "laptop", 1843 [CXT5051_LAPTOP] = "laptop",
1821 [CXT5051_HP] = "hp", 1844 [CXT5051_HP] = "hp",
1845 [CXT5051_HP_DV6736] = "hp-dv6736",
1846 [CXT5051_LENOVO_X200] = "lenovo-x200",
1822}; 1847};
1823 1848
1824static struct snd_pci_quirk cxt5051_cfg_tbl[] = { 1849static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1850 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
1825 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1851 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1826 CXT5051_LAPTOP), 1852 CXT5051_LAPTOP),
1827 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1853 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1854 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
1828 {} 1855 {}
1829}; 1856};
1830 1857
@@ -1837,6 +1864,7 @@ static int patch_cxt5051(struct hda_codec *codec)
1837 if (!spec) 1864 if (!spec)
1838 return -ENOMEM; 1865 return -ENOMEM;
1839 codec->spec = spec; 1866 codec->spec = spec;
1867 codec->pin_amp_workaround = 1;
1840 1868
1841 codec->patch_ops = conexant_patch_ops; 1869 codec->patch_ops = conexant_patch_ops;
1842 codec->patch_ops.init = cxt5051_init; 1870 codec->patch_ops.init = cxt5051_init;
@@ -1857,17 +1885,22 @@ static int patch_cxt5051(struct hda_codec *codec)
1857 spec->cur_adc = 0; 1885 spec->cur_adc = 0;
1858 spec->cur_adc_idx = 0; 1886 spec->cur_adc_idx = 0;
1859 1887
1888 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1889
1860 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 1890 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1861 cxt5051_models, 1891 cxt5051_models,
1862 cxt5051_cfg_tbl); 1892 cxt5051_cfg_tbl);
1863 switch (board_config) { 1893 switch (board_config) {
1864 case CXT5051_HP: 1894 case CXT5051_HP:
1865 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1866 spec->mixers[0] = cxt5051_hp_mixers; 1895 spec->mixers[0] = cxt5051_hp_mixers;
1867 break; 1896 break;
1868 default: 1897 case CXT5051_HP_DV6736:
1869 case CXT5051_LAPTOP: 1898 spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
1870 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 1899 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
1900 spec->no_auto_mic = 1;
1901 break;
1902 case CXT5051_LENOVO_X200:
1903 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
1871 break; 1904 break;
1872 } 1905 }
1873 1906
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c
index 3564f4e4b74c..fcc77fec4487 100644
--- a/sound/pci/hda/patch_intelhdmi.c
+++ b/sound/pci/hda/patch_intelhdmi.c
@@ -49,11 +49,6 @@ static struct hda_verb pinout_enable_verb[] = {
49 {} /* terminator */ 49 {} /* terminator */
50}; 50};
51 51
52static struct hda_verb pinout_disable_verb[] = {
53 {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00},
54 {}
55};
56
57static struct hda_verb unsolicited_response_verb[] = { 52static struct hda_verb unsolicited_response_verb[] = {
58 {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 53 {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN |
59 INTEL_HDMI_EVENT_TAG}, 54 INTEL_HDMI_EVENT_TAG},
@@ -248,10 +243,6 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid,
248 243
249static void hdmi_enable_output(struct hda_codec *codec) 244static void hdmi_enable_output(struct hda_codec *codec)
250{ 245{
251 /* Enable Audio InfoFrame Transmission */
252 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
253 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
254 AC_DIPXMIT_BEST);
255 /* Unmute */ 246 /* Unmute */
256 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) 247 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP)
257 snd_hda_codec_write(codec, PIN_NID, 0, 248 snd_hda_codec_write(codec, PIN_NID, 0,
@@ -260,17 +251,24 @@ static void hdmi_enable_output(struct hda_codec *codec)
260 snd_hda_sequence_write(codec, pinout_enable_verb); 251 snd_hda_sequence_write(codec, pinout_enable_verb);
261} 252}
262 253
263static void hdmi_disable_output(struct hda_codec *codec) 254/*
255 * Enable Audio InfoFrame Transmission
256 */
257static void hdmi_start_infoframe_trans(struct hda_codec *codec)
264{ 258{
265 snd_hda_sequence_write(codec, pinout_disable_verb); 259 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
266 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) 260 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
267 snd_hda_codec_write(codec, PIN_NID, 0, 261 AC_DIPXMIT_BEST);
268 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 262}
269 263
270 /* 264/*
271 * FIXME: noises may arise when playing music after reloading the 265 * Disable Audio InfoFrame Transmission
272 * kernel module, until the next X restart or monitor repower. 266 */
273 */ 267static void hdmi_stop_infoframe_trans(struct hda_codec *codec)
268{
269 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
270 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
271 AC_DIPXMIT_DISABLE);
274} 272}
275 273
276static int hdmi_get_channel_count(struct hda_codec *codec) 274static int hdmi_get_channel_count(struct hda_codec *codec)
@@ -368,11 +366,16 @@ static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
368 struct hdmi_audio_infoframe *ai) 366 struct hdmi_audio_infoframe *ai)
369{ 367{
370 u8 *params = (u8 *)ai; 368 u8 *params = (u8 *)ai;
369 u8 sum = 0;
371 int i; 370 int i;
372 371
373 hdmi_debug_dip_size(codec); 372 hdmi_debug_dip_size(codec);
374 hdmi_clear_dip_buffers(codec); /* be paranoid */ 373 hdmi_clear_dip_buffers(codec); /* be paranoid */
375 374
375 for (i = 0; i < sizeof(ai); i++)
376 sum += params[i];
377 ai->checksum = - sum;
378
376 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); 379 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
377 for (i = 0; i < sizeof(ai); i++) 380 for (i = 0; i < sizeof(ai); i++)
378 hdmi_write_dip_byte(codec, PIN_NID, params[i]); 381 hdmi_write_dip_byte(codec, PIN_NID, params[i]);
@@ -419,14 +422,18 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec,
419 /* 422 /*
420 * CA defaults to 0 for basic stereo audio 423 * CA defaults to 0 for basic stereo audio
421 */ 424 */
422 if (!eld->eld_ver)
423 return 0;
424 if (!eld->spk_alloc)
425 return 0;
426 if (channels <= 2) 425 if (channels <= 2)
427 return 0; 426 return 0;
428 427
429 /* 428 /*
429 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
430 * in console or for audio devices. Assume the highest speakers
431 * configuration, to _not_ prohibit multi-channel audio playback.
432 */
433 if (!eld->spk_alloc)
434 eld->spk_alloc = 0xffff;
435
436 /*
430 * expand ELD's speaker allocation mask 437 * expand ELD's speaker allocation mask
431 * 438 *
432 * ELD tells the speaker mask in a compact(paired) form, 439 * ELD tells the speaker mask in a compact(paired) form,
@@ -485,6 +492,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
485 hdmi_setup_channel_mapping(codec, &ai); 492 hdmi_setup_channel_mapping(codec, &ai);
486 493
487 hdmi_fill_audio_infoframe(codec, &ai); 494 hdmi_fill_audio_infoframe(codec, &ai);
495 hdmi_start_infoframe_trans(codec);
488} 496}
489 497
490 498
@@ -562,7 +570,7 @@ static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo,
562{ 570{
563 struct intel_hdmi_spec *spec = codec->spec; 571 struct intel_hdmi_spec *spec = codec->spec;
564 572
565 hdmi_disable_output(codec); 573 hdmi_stop_infoframe_trans(codec);
566 574
567 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 575 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
568} 576}
@@ -582,8 +590,6 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
582 590
583 hdmi_setup_audio_infoframe(codec, substream); 591 hdmi_setup_audio_infoframe(codec, substream);
584 592
585 hdmi_enable_output(codec);
586
587 return 0; 593 return 0;
588} 594}
589 595
@@ -628,8 +634,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec)
628 634
629static int intel_hdmi_init(struct hda_codec *codec) 635static int intel_hdmi_init(struct hda_codec *codec)
630{ 636{
631 /* disable audio output as early as possible */ 637 hdmi_enable_output(codec);
632 hdmi_disable_output(codec);
633 638
634 snd_hda_sequence_write(codec, unsolicited_response_verb); 639 snd_hda_sequence_write(codec, unsolicited_response_verb);
635 640
@@ -679,6 +684,7 @@ static struct hda_codec_preset snd_hda_preset_intelhdmi[] = {
679 { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, 684 { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi },
680 { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, 685 { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi },
681 { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, 686 { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi },
687 { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi },
682 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, 688 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi },
683 {} /* terminator */ 689 {} /* terminator */
684}; 690};
@@ -687,6 +693,7 @@ MODULE_ALIAS("snd-hda-codec-id:808629fb");
687MODULE_ALIAS("snd-hda-codec-id:80862801"); 693MODULE_ALIAS("snd-hda-codec-id:80862801");
688MODULE_ALIAS("snd-hda-codec-id:80862802"); 694MODULE_ALIAS("snd-hda-codec-id:80862802");
689MODULE_ALIAS("snd-hda-codec-id:80862803"); 695MODULE_ALIAS("snd-hda-codec-id:80862803");
696MODULE_ALIAS("snd-hda-codec-id:80862804");
690MODULE_ALIAS("snd-hda-codec-id:10951392"); 697MODULE_ALIAS("snd-hda-codec-id:10951392");
691 698
692MODULE_LICENSE("GPL"); 699MODULE_LICENSE("GPL");
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
index 96952a37d884..d57d8132a06e 100644
--- a/sound/pci/hda/patch_nvhdmi.c
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -160,6 +160,7 @@ static int patch_nvhdmi(struct hda_codec *codec)
160 */ 160 */
161static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { 161static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
162 { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi }, 162 { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi },
163 { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi },
163 { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi }, 164 { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi },
164 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi }, 165 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi },
165 { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi }, 166 { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi },
@@ -167,6 +168,7 @@ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
167}; 168};
168 169
169MODULE_ALIAS("snd-hda-codec-id:10de0002"); 170MODULE_ALIAS("snd-hda-codec-id:10de0002");
171MODULE_ALIAS("snd-hda-codec-id:10de0006");
170MODULE_ALIAS("snd-hda-codec-id:10de0007"); 172MODULE_ALIAS("snd-hda-codec-id:10de0007");
171MODULE_ALIAS("snd-hda-codec-id:10de0067"); 173MODULE_ALIAS("snd-hda-codec-id:10de0067");
172MODULE_ALIAS("snd-hda-codec-id:10de8001"); 174MODULE_ALIAS("snd-hda-codec-id:10de8001");
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ea4c88fe05c4..b8a0d3e79272 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_beep.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
@@ -77,6 +78,7 @@ enum {
77 ALC260_ACER, 78 ALC260_ACER,
78 ALC260_WILL, 79 ALC260_WILL,
79 ALC260_REPLACER_672V, 80 ALC260_REPLACER_672V,
81 ALC260_FAVORIT100,
80#ifdef CONFIG_SND_DEBUG 82#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST, 83 ALC260_TEST,
82#endif 84#endif
@@ -103,6 +105,7 @@ enum {
103 ALC262_NEC, 105 ALC262_NEC,
104 ALC262_TOSHIBA_S06, 106 ALC262_TOSHIBA_S06,
105 ALC262_TOSHIBA_RX1, 107 ALC262_TOSHIBA_RX1,
108 ALC262_TYAN,
106 ALC262_AUTO, 109 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */ 110 ALC262_MODEL_LAST /* last tag */
108}; 111};
@@ -185,6 +188,8 @@ enum {
185 ALC663_ASUS_MODE4, 188 ALC663_ASUS_MODE4,
186 ALC663_ASUS_MODE5, 189 ALC663_ASUS_MODE5,
187 ALC663_ASUS_MODE6, 190 ALC663_ASUS_MODE6,
191 ALC272_DELL,
192 ALC272_DELL_ZM1,
188 ALC662_AUTO, 193 ALC662_AUTO,
189 ALC662_MODEL_LAST, 194 ALC662_MODEL_LAST,
190}; 195};
@@ -238,6 +243,13 @@ enum {
238 ALC883_MODEL_LAST, 243 ALC883_MODEL_LAST,
239}; 244};
240 245
246/* styles of capture selection */
247enum {
248 CAPT_MUX = 0, /* only mux based */
249 CAPT_MIX, /* only mixer based */
250 CAPT_1MUX_MIX, /* first mux and other mixers */
251};
252
241/* for GPIO Poll */ 253/* for GPIO Poll */
242#define GPIO_MASK 0x03 254#define GPIO_MASK 0x03
243 255
@@ -246,6 +258,7 @@ struct alc_spec {
246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 258 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
247 unsigned int num_mixers; 259 unsigned int num_mixers;
248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */ 260 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
261 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
249 262
250 const struct hda_verb *init_verbs[5]; /* initialization verbs 263 const struct hda_verb *init_verbs[5]; /* initialization verbs
251 * don't forget NULL 264 * don't forget NULL
@@ -269,13 +282,15 @@ struct alc_spec {
269 * dig_out_nid and hp_nid are optional 282 * dig_out_nid and hp_nid are optional
270 */ 283 */
271 hda_nid_t alt_dac_nid; 284 hda_nid_t alt_dac_nid;
285 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
286 int dig_out_type;
272 287
273 /* capture */ 288 /* capture */
274 unsigned int num_adc_nids; 289 unsigned int num_adc_nids;
275 hda_nid_t *adc_nids; 290 hda_nid_t *adc_nids;
276 hda_nid_t *capsrc_nids; 291 hda_nid_t *capsrc_nids;
277 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 292 hda_nid_t dig_in_nid; /* digital-in NID; optional */
278 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */ 293 int capture_style; /* capture style (CAPT_*) */
279 294
280 /* capture source */ 295 /* capture source */
281 unsigned int num_mux_defs; 296 unsigned int num_mux_defs;
@@ -293,7 +308,7 @@ struct alc_spec {
293 /* dynamic controls, init_verbs and input_mux */ 308 /* dynamic controls, init_verbs and input_mux */
294 struct auto_pin_cfg autocfg; 309 struct auto_pin_cfg autocfg;
295 struct snd_array kctls; 310 struct snd_array kctls;
296 struct hda_input_mux private_imux; 311 struct hda_input_mux private_imux[3];
297 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 312 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
298 313
299 /* hooks */ 314 /* hooks */
@@ -305,6 +320,9 @@ struct alc_spec {
305 unsigned int jack_present: 1; 320 unsigned int jack_present: 1;
306 unsigned int master_sw: 1; 321 unsigned int master_sw: 1;
307 322
323 /* other flags */
324 unsigned int no_analog :1; /* digital I/O only */
325
308 /* for virtual master */ 326 /* for virtual master */
309 hda_nid_t vmaster_nid; 327 hda_nid_t vmaster_nid;
310#ifdef CONFIG_SND_HDA_POWER_SAVE 328#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -314,13 +332,6 @@ struct alc_spec {
314 /* for PLL fix */ 332 /* for PLL fix */
315 hda_nid_t pll_nid; 333 hda_nid_t pll_nid;
316 unsigned int pll_coef_idx, pll_coef_bit; 334 unsigned int pll_coef_idx, pll_coef_bit;
317
318#ifdef SND_HDA_NEEDS_RESUME
319#define ALC_MAX_PINS 16
320 unsigned int num_pins;
321 hda_nid_t pin_nids[ALC_MAX_PINS];
322 unsigned int pin_cfgs[ALC_MAX_PINS];
323#endif
324}; 335};
325 336
326/* 337/*
@@ -336,6 +347,7 @@ struct alc_config_preset {
336 hda_nid_t *dac_nids; 347 hda_nid_t *dac_nids;
337 hda_nid_t dig_out_nid; /* optional */ 348 hda_nid_t dig_out_nid; /* optional */
338 hda_nid_t hp_nid; /* optional */ 349 hda_nid_t hp_nid; /* optional */
350 hda_nid_t *slave_dig_outs;
339 unsigned int num_adc_nids; 351 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids; 352 hda_nid_t *adc_nids;
341 hda_nid_t *capsrc_nids; 353 hda_nid_t *capsrc_nids;
@@ -392,7 +404,8 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 404 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
393 imux = &spec->input_mux[mux_idx]; 405 imux = &spec->input_mux[mux_idx];
394 406
395 if (spec->is_mix_capture) { 407 if (spec->capture_style &&
408 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
396 /* Matrix-mixer style (e.g. ALC882) */ 409 /* Matrix-mixer style (e.g. ALC882) */
397 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 410 unsigned int *cur_val = &spec->cur_mux[adc_idx];
398 unsigned int i, idx; 411 unsigned int i, idx;
@@ -750,6 +763,24 @@ static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
750#endif /* CONFIG_SND_DEBUG */ 763#endif /* CONFIG_SND_DEBUG */
751 764
752/* 765/*
766 * set up the input pin config (depending on the given auto-pin type)
767 */
768static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
769 int auto_pin_type)
770{
771 unsigned int val = PIN_IN;
772
773 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
774 unsigned int pincap;
775 pincap = snd_hda_query_pin_caps(codec, nid);
776 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
777 if (pincap & AC_PINCAP_VREF_80)
778 val = PIN_VREF80;
779 }
780 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
781}
782
783/*
753 */ 784 */
754static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) 785static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
755{ 786{
@@ -810,6 +841,7 @@ static void setup_preset(struct alc_spec *spec,
810 spec->multiout.num_dacs = preset->num_dacs; 841 spec->multiout.num_dacs = preset->num_dacs;
811 spec->multiout.dac_nids = preset->dac_nids; 842 spec->multiout.dac_nids = preset->dac_nids;
812 spec->multiout.dig_out_nid = preset->dig_out_nid; 843 spec->multiout.dig_out_nid = preset->dig_out_nid;
844 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
813 spec->multiout.hp_nid = preset->hp_nid; 845 spec->multiout.hp_nid = preset->hp_nid;
814 846
815 spec->num_mux_defs = preset->num_mux_defs; 847 spec->num_mux_defs = preset->num_mux_defs;
@@ -921,7 +953,7 @@ static void alc_mic_automute(struct hda_codec *codec)
921 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
922} 954}
923#else 955#else
924#define alc_mic_automute(codec) /* NOP */ 956#define alc_mic_automute(codec) do {} while(0) /* NOP */
925#endif /* disabled */ 957#endif /* disabled */
926 958
927/* unsolicited event for HP jack sensing */ 959/* unsolicited event for HP jack sensing */
@@ -952,7 +984,7 @@ static void alc888_coef_init(struct hda_codec *codec)
952 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
953 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 985 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
954 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 986 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
955 if ((tmp & 0xf0) == 2) 987 if ((tmp & 0xf0) == 0x20)
956 /* alc888S-VC */ 988 /* alc888S-VC */
957 snd_hda_codec_read(codec, 0x20, 0, 989 snd_hda_codec_read(codec, 0x20, 0,
958 AC_VERB_SET_PROC_COEF, 0x830); 990 AC_VERB_SET_PROC_COEF, 0x830);
@@ -991,8 +1023,7 @@ static void alc_subsystem_id(struct hda_codec *codec,
991 nid = 0x1d; 1023 nid = 0x1d;
992 if (codec->vendor_id == 0x10ec0260) 1024 if (codec->vendor_id == 0x10ec0260)
993 nid = 0x17; 1025 nid = 0x17;
994 ass = snd_hda_codec_read(codec, nid, 0, 1026 ass = snd_hda_codec_get_pincfg(codec, nid);
995 AC_VERB_GET_CONFIG_DEFAULT, 0);
996 if (!(ass & 1) && !(ass & 0x100000)) 1027 if (!(ass & 1) && !(ass & 0x100000))
997 return; 1028 return;
998 if ((ass >> 30) != 1) /* no physical connection */ 1029 if ((ass >> 30) != 1) /* no physical connection */
@@ -1037,6 +1068,7 @@ do_sku:
1037 case 0x10ec0267: 1068 case 0x10ec0267:
1038 case 0x10ec0268: 1069 case 0x10ec0268:
1039 case 0x10ec0269: 1070 case 0x10ec0269:
1071 case 0x10ec0272:
1040 case 0x10ec0660: 1072 case 0x10ec0660:
1041 case 0x10ec0662: 1073 case 0x10ec0662:
1042 case 0x10ec0663: 1074 case 0x10ec0663:
@@ -1065,6 +1097,7 @@ do_sku:
1065 case 0x10ec0882: 1097 case 0x10ec0882:
1066 case 0x10ec0883: 1098 case 0x10ec0883:
1067 case 0x10ec0885: 1099 case 0x10ec0885:
1100 case 0x10ec0887:
1068 case 0x10ec0889: 1101 case 0x10ec0889:
1069 snd_hda_codec_write(codec, 0x20, 0, 1102 snd_hda_codec_write(codec, 0x20, 0,
1070 AC_VERB_SET_COEF_INDEX, 7); 1103 AC_VERB_SET_COEF_INDEX, 7);
@@ -1164,16 +1197,8 @@ static void alc_fix_pincfg(struct hda_codec *codec,
1164 return; 1197 return;
1165 1198
1166 cfg = pinfix[quirk->value]; 1199 cfg = pinfix[quirk->value];
1167 for (; cfg->nid; cfg++) { 1200 for (; cfg->nid; cfg++)
1168 int i; 1201 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1169 u32 val = cfg->val;
1170 for (i = 0; i < 4; i++) {
1171 snd_hda_codec_write(codec, cfg->nid, 0,
1172 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1173 val & 0xff);
1174 val >>= 8;
1175 }
1176 }
1177} 1202}
1178 1203
1179/* 1204/*
@@ -1373,8 +1398,6 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 1399 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1377 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1378 { } /* end */ 1401 { } /* end */
1379}; 1402};
1380 1403
@@ -1481,8 +1504,6 @@ static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1481 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1482 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 1505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 1506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1484 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1485 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 1507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1487 { 1508 {
1488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1576,8 +1597,7 @@ static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1576 snd_hda_mixer_amp_switch_put); 1597 snd_hda_mixer_amp_switch_put);
1577} 1598}
1578 1599
1579#define DEFINE_CAPMIX(num) \ 1600#define _DEFINE_CAPMIX(num) \
1580static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1581 { \ 1601 { \
1582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1602 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1583 .name = "Capture Switch", \ 1603 .name = "Capture Switch", \
@@ -1598,7 +1618,9 @@ static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1598 .get = alc_cap_vol_get, \ 1618 .get = alc_cap_vol_get, \
1599 .put = alc_cap_vol_put, \ 1619 .put = alc_cap_vol_put, \
1600 .tlv = { .c = alc_cap_vol_tlv }, \ 1620 .tlv = { .c = alc_cap_vol_tlv }, \
1601 }, \ 1621 }
1622
1623#define _DEFINE_CAPSRC(num) \
1602 { \ 1624 { \
1603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1604 /* .name = "Capture Source", */ \ 1626 /* .name = "Capture Source", */ \
@@ -1607,15 +1629,28 @@ static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1607 .info = alc_mux_enum_info, \ 1629 .info = alc_mux_enum_info, \
1608 .get = alc_mux_enum_get, \ 1630 .get = alc_mux_enum_get, \
1609 .put = alc_mux_enum_put, \ 1631 .put = alc_mux_enum_put, \
1610 }, \ 1632 }
1611 { } /* end */ \ 1633
1634#define DEFINE_CAPMIX(num) \
1635static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1636 _DEFINE_CAPMIX(num), \
1637 _DEFINE_CAPSRC(num), \
1638 { } /* end */ \
1639}
1640
1641#define DEFINE_CAPMIX_NOSRC(num) \
1642static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1643 _DEFINE_CAPMIX(num), \
1644 { } /* end */ \
1612} 1645}
1613 1646
1614/* up to three ADCs */ 1647/* up to three ADCs */
1615DEFINE_CAPMIX(1); 1648DEFINE_CAPMIX(1);
1616DEFINE_CAPMIX(2); 1649DEFINE_CAPMIX(2);
1617DEFINE_CAPMIX(3); 1650DEFINE_CAPMIX(3);
1618 1651DEFINE_CAPMIX_NOSRC(1);
1652DEFINE_CAPMIX_NOSRC(2);
1653DEFINE_CAPMIX_NOSRC(3);
1619 1654
1620/* 1655/*
1621 * ALC880 5-stack model 1656 * ALC880 5-stack model
@@ -1704,8 +1739,6 @@ static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1705 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1740 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1707 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1708 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1709 { 1742 {
1710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1711 .name = "Channel Mode", 1744 .name = "Channel Mode",
@@ -1882,13 +1915,6 @@ static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1882 { } /* end */ 1915 { } /* end */
1883}; 1916};
1884 1917
1885/* additional mixers to alc880_asus_mixer */
1886static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1889 { } /* end */
1890};
1891
1892/* TCL S700 */ 1918/* TCL S700 */
1893static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { 1919static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -1921,8 +1947,6 @@ static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1948 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1924 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1925 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1926 { 1950 {
1927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1928 .name = "Channel Mode", 1952 .name = "Channel Mode",
@@ -1997,6 +2021,13 @@ static const char *alc_slave_sws[] = {
1997 2021
1998static void alc_free_kctls(struct hda_codec *codec); 2022static void alc_free_kctls(struct hda_codec *codec);
1999 2023
2024/* additional beep mixers; the actual parameters are overwritten at build */
2025static struct snd_kcontrol_new alc_beep_mixer[] = {
2026 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2027 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2028 { } /* end */
2029};
2030
2000static int alc_build_controls(struct hda_codec *codec) 2031static int alc_build_controls(struct hda_codec *codec)
2001{ 2032{
2002 struct alc_spec *spec = codec->spec; 2033 struct alc_spec *spec = codec->spec;
@@ -2018,11 +2049,13 @@ static int alc_build_controls(struct hda_codec *codec)
2018 spec->multiout.dig_out_nid); 2049 spec->multiout.dig_out_nid);
2019 if (err < 0) 2050 if (err < 0)
2020 return err; 2051 return err;
2021 err = snd_hda_create_spdif_share_sw(codec, 2052 if (!spec->no_analog) {
2022 &spec->multiout); 2053 err = snd_hda_create_spdif_share_sw(codec,
2023 if (err < 0) 2054 &spec->multiout);
2024 return err; 2055 if (err < 0)
2025 spec->multiout.share_spdif = 1; 2056 return err;
2057 spec->multiout.share_spdif = 1;
2058 }
2026 } 2059 }
2027 if (spec->dig_in_nid) { 2060 if (spec->dig_in_nid) {
2028 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 2061 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -2030,8 +2063,24 @@ static int alc_build_controls(struct hda_codec *codec)
2030 return err; 2063 return err;
2031 } 2064 }
2032 2065
2066 /* create beep controls if needed */
2067 if (spec->beep_amp) {
2068 struct snd_kcontrol_new *knew;
2069 for (knew = alc_beep_mixer; knew->name; knew++) {
2070 struct snd_kcontrol *kctl;
2071 kctl = snd_ctl_new1(knew, codec);
2072 if (!kctl)
2073 return -ENOMEM;
2074 kctl->private_value = spec->beep_amp;
2075 err = snd_hda_ctl_add(codec, kctl);
2076 if (err < 0)
2077 return err;
2078 }
2079 }
2080
2033 /* if we have no master control, let's create it */ 2081 /* if we have no master control, let's create it */
2034 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 2082 if (!spec->no_analog &&
2083 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2035 unsigned int vmaster_tlv[4]; 2084 unsigned int vmaster_tlv[4];
2036 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 2085 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2037 HDA_OUTPUT, vmaster_tlv); 2086 HDA_OUTPUT, vmaster_tlv);
@@ -2040,7 +2089,8 @@ static int alc_build_controls(struct hda_codec *codec)
2040 if (err < 0) 2089 if (err < 0)
2041 return err; 2090 return err;
2042 } 2091 }
2043 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 2092 if (!spec->no_analog &&
2093 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2044 err = snd_hda_add_vmaster(codec, "Master Playback Switch", 2094 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2045 NULL, alc_slave_sws); 2095 NULL, alc_slave_sws);
2046 if (err < 0) 2096 if (err < 0)
@@ -2949,6 +2999,14 @@ static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2949 stream_tag, format, substream); 2999 stream_tag, format, substream);
2950} 3000}
2951 3001
3002static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3003 struct hda_codec *codec,
3004 struct snd_pcm_substream *substream)
3005{
3006 struct alc_spec *spec = codec->spec;
3007 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3008}
3009
2952static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 3010static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2953 struct hda_codec *codec, 3011 struct hda_codec *codec,
2954 struct snd_pcm_substream *substream) 3012 struct snd_pcm_substream *substream)
@@ -3032,7 +3090,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
3032 .ops = { 3090 .ops = {
3033 .open = alc880_dig_playback_pcm_open, 3091 .open = alc880_dig_playback_pcm_open,
3034 .close = alc880_dig_playback_pcm_close, 3092 .close = alc880_dig_playback_pcm_close,
3035 .prepare = alc880_dig_playback_pcm_prepare 3093 .prepare = alc880_dig_playback_pcm_prepare,
3094 .cleanup = alc880_dig_playback_pcm_cleanup
3036 }, 3095 },
3037}; 3096};
3038 3097
@@ -3059,6 +3118,9 @@ static int alc_build_pcms(struct hda_codec *codec)
3059 codec->num_pcms = 1; 3118 codec->num_pcms = 1;
3060 codec->pcm_info = info; 3119 codec->pcm_info = info;
3061 3120
3121 if (spec->no_analog)
3122 goto skip_analog;
3123
3062 info->name = spec->stream_name_analog; 3124 info->name = spec->stream_name_analog;
3063 if (spec->stream_analog_playback) { 3125 if (spec->stream_analog_playback) {
3064 if (snd_BUG_ON(!spec->multiout.dac_nids)) 3126 if (snd_BUG_ON(!spec->multiout.dac_nids))
@@ -3082,12 +3144,17 @@ static int alc_build_pcms(struct hda_codec *codec)
3082 } 3144 }
3083 } 3145 }
3084 3146
3147 skip_analog:
3085 /* SPDIF for stream index #1 */ 3148 /* SPDIF for stream index #1 */
3086 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 3149 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3087 codec->num_pcms = 2; 3150 codec->num_pcms = 2;
3151 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3088 info = spec->pcm_rec + 1; 3152 info = spec->pcm_rec + 1;
3089 info->name = spec->stream_name_digital; 3153 info->name = spec->stream_name_digital;
3090 info->pcm_type = HDA_PCM_TYPE_SPDIF; 3154 if (spec->dig_out_type)
3155 info->pcm_type = spec->dig_out_type;
3156 else
3157 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3091 if (spec->multiout.dig_out_nid && 3158 if (spec->multiout.dig_out_nid &&
3092 spec->stream_digital_playback) { 3159 spec->stream_digital_playback) {
3093 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 3160 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
@@ -3102,6 +3169,9 @@ static int alc_build_pcms(struct hda_codec *codec)
3102 codec->spdif_status_reset = 1; 3169 codec->spdif_status_reset = 1;
3103 } 3170 }
3104 3171
3172 if (spec->no_analog)
3173 return 0;
3174
3105 /* If the use of more than one ADC is requested for the current 3175 /* If the use of more than one ADC is requested for the current
3106 * model, configure a second analog capture-only PCM. 3176 * model, configure a second analog capture-only PCM.
3107 */ 3177 */
@@ -3160,65 +3230,17 @@ static void alc_free(struct hda_codec *codec)
3160 3230
3161 alc_free_kctls(codec); 3231 alc_free_kctls(codec);
3162 kfree(spec); 3232 kfree(spec);
3163 codec->spec = NULL; /* to be sure */ 3233 snd_hda_detach_beep_device(codec);
3164} 3234}
3165 3235
3166#ifdef SND_HDA_NEEDS_RESUME 3236#ifdef SND_HDA_NEEDS_RESUME
3167static void store_pin_configs(struct hda_codec *codec)
3168{
3169 struct alc_spec *spec = codec->spec;
3170 hda_nid_t nid, end_nid;
3171
3172 end_nid = codec->start_nid + codec->num_nodes;
3173 for (nid = codec->start_nid; nid < end_nid; nid++) {
3174 unsigned int wid_caps = get_wcaps(codec, nid);
3175 unsigned int wid_type =
3176 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3177 if (wid_type != AC_WID_PIN)
3178 continue;
3179 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3180 break;
3181 spec->pin_nids[spec->num_pins] = nid;
3182 spec->pin_cfgs[spec->num_pins] =
3183 snd_hda_codec_read(codec, nid, 0,
3184 AC_VERB_GET_CONFIG_DEFAULT, 0);
3185 spec->num_pins++;
3186 }
3187}
3188
3189static void resume_pin_configs(struct hda_codec *codec)
3190{
3191 struct alc_spec *spec = codec->spec;
3192 int i;
3193
3194 for (i = 0; i < spec->num_pins; i++) {
3195 hda_nid_t pin_nid = spec->pin_nids[i];
3196 unsigned int pin_config = spec->pin_cfgs[i];
3197 snd_hda_codec_write(codec, pin_nid, 0,
3198 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3199 pin_config & 0x000000ff);
3200 snd_hda_codec_write(codec, pin_nid, 0,
3201 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3202 (pin_config & 0x0000ff00) >> 8);
3203 snd_hda_codec_write(codec, pin_nid, 0,
3204 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3205 (pin_config & 0x00ff0000) >> 16);
3206 snd_hda_codec_write(codec, pin_nid, 0,
3207 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3208 pin_config >> 24);
3209 }
3210}
3211
3212static int alc_resume(struct hda_codec *codec) 3237static int alc_resume(struct hda_codec *codec)
3213{ 3238{
3214 resume_pin_configs(codec);
3215 codec->patch_ops.init(codec); 3239 codec->patch_ops.init(codec);
3216 snd_hda_codec_resume_amp(codec); 3240 snd_hda_codec_resume_amp(codec);
3217 snd_hda_codec_resume_cache(codec); 3241 snd_hda_codec_resume_cache(codec);
3218 return 0; 3242 return 0;
3219} 3243}
3220#else
3221#define store_pin_configs(codec)
3222#endif 3244#endif
3223 3245
3224/* 3246/*
@@ -3557,7 +3579,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
3557 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), 3579 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3558 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), 3580 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3559 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), 3581 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3560 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ 3582 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3561 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), 3583 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3562 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), 3584 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3563 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), 3585 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
@@ -3600,7 +3622,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
3600 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), 3622 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3601 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), 3623 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3602 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), 3624 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3603 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ 3625 /* default Intel */
3626 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3604 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), 3627 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3605 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), 3628 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3606 {} 3629 {}
@@ -3780,7 +3803,7 @@ static struct alc_config_preset alc880_presets[] = {
3780 .input_mux = &alc880_capture_source, 3803 .input_mux = &alc880_capture_source,
3781 }, 3804 },
3782 [ALC880_UNIWILL_DIG] = { 3805 [ALC880_UNIWILL_DIG] = {
3783 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, 3806 .mixers = { alc880_asus_mixer },
3784 .init_verbs = { alc880_volume_init_verbs, 3807 .init_verbs = { alc880_volume_init_verbs,
3785 alc880_pin_asus_init_verbs }, 3808 alc880_pin_asus_init_verbs },
3786 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
@@ -3818,8 +3841,7 @@ static struct alc_config_preset alc880_presets[] = {
3818 .init_hook = alc880_uniwill_p53_hp_automute, 3841 .init_hook = alc880_uniwill_p53_hp_automute,
3819 }, 3842 },
3820 [ALC880_FUJITSU] = { 3843 [ALC880_FUJITSU] = {
3821 .mixers = { alc880_fujitsu_mixer, 3844 .mixers = { alc880_fujitsu_mixer },
3822 alc880_pcbeep_mixer, },
3823 .init_verbs = { alc880_volume_init_verbs, 3845 .init_verbs = { alc880_volume_init_verbs,
3824 alc880_uniwill_p53_init_verbs, 3846 alc880_uniwill_p53_init_verbs,
3825 alc880_beep_init_verbs }, 3847 alc880_beep_init_verbs },
@@ -4112,7 +4134,7 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4112static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 4134static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4113 const struct auto_pin_cfg *cfg) 4135 const struct auto_pin_cfg *cfg)
4114{ 4136{
4115 struct hda_input_mux *imux = &spec->private_imux; 4137 struct hda_input_mux *imux = &spec->private_imux[0];
4116 int i, err, idx; 4138 int i, err, idx;
4117 4139
4118 for (i = 0; i < AUTO_PIN_LAST; i++) { 4140 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -4200,11 +4222,9 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4200 for (i = 0; i < AUTO_PIN_LAST; i++) { 4222 for (i = 0; i < AUTO_PIN_LAST; i++) {
4201 hda_nid_t nid = spec->autocfg.input_pins[i]; 4223 hda_nid_t nid = spec->autocfg.input_pins[i];
4202 if (alc880_is_input_pin(nid)) { 4224 if (alc880_is_input_pin(nid)) {
4203 snd_hda_codec_write(codec, nid, 0, 4225 alc_set_input_pin(codec, nid, i);
4204 AC_VERB_SET_PIN_WIDGET_CONTROL, 4226 if (nid != ALC880_PIN_CD_NID &&
4205 i <= AUTO_PIN_FRONT_MIC ? 4227 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
4206 PIN_VREF80 : PIN_IN);
4207 if (nid != ALC880_PIN_CD_NID)
4208 snd_hda_codec_write(codec, nid, 0, 4228 snd_hda_codec_write(codec, nid, 0,
4209 AC_VERB_SET_AMP_GAIN_MUTE, 4229 AC_VERB_SET_AMP_GAIN_MUTE,
4210 AMP_OUT_MUTE); 4230 AMP_OUT_MUTE);
@@ -4219,7 +4239,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4219static int alc880_parse_auto_config(struct hda_codec *codec) 4239static int alc880_parse_auto_config(struct hda_codec *codec)
4220{ 4240{
4221 struct alc_spec *spec = codec->spec; 4241 struct alc_spec *spec = codec->spec;
4222 int err; 4242 int i, err;
4223 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 4243 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4224 4244
4225 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4245 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
@@ -4250,8 +4270,23 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4250 4270
4251 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 4271 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4252 4272
4253 if (spec->autocfg.dig_out_pin) 4273 /* check multiple SPDIF-out (for recent codecs) */
4254 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 4274 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4275 hda_nid_t dig_nid;
4276 err = snd_hda_get_connections(codec,
4277 spec->autocfg.dig_out_pins[i],
4278 &dig_nid, 1);
4279 if (err < 0)
4280 continue;
4281 if (!i)
4282 spec->multiout.dig_out_nid = dig_nid;
4283 else {
4284 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4285 spec->slave_dig_outs[i - 1] = dig_nid;
4286 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4287 break;
4288 }
4289 }
4255 if (spec->autocfg.dig_in_pin) 4290 if (spec->autocfg.dig_in_pin)
4256 spec->dig_in_nid = ALC880_DIGIN_NID; 4291 spec->dig_in_nid = ALC880_DIGIN_NID;
4257 4292
@@ -4261,9 +4296,8 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4261 add_verb(spec, alc880_volume_init_verbs); 4296 add_verb(spec, alc880_volume_init_verbs);
4262 4297
4263 spec->num_mux_defs = 1; 4298 spec->num_mux_defs = 1;
4264 spec->input_mux = &spec->private_imux; 4299 spec->input_mux = &spec->private_imux[0];
4265 4300
4266 store_pin_configs(codec);
4267 return 1; 4301 return 1;
4268} 4302}
4269 4303
@@ -4278,21 +4312,33 @@ static void alc880_auto_init(struct hda_codec *codec)
4278 alc_inithook(codec); 4312 alc_inithook(codec);
4279} 4313}
4280 4314
4281/*
4282 * OK, here we have finally the patch for ALC880
4283 */
4284
4285static void set_capture_mixer(struct alc_spec *spec) 4315static void set_capture_mixer(struct alc_spec *spec)
4286{ 4316{
4287 static struct snd_kcontrol_new *caps[3] = { 4317 static struct snd_kcontrol_new *caps[2][3] = {
4288 alc_capture_mixer1, 4318 { alc_capture_mixer_nosrc1,
4289 alc_capture_mixer2, 4319 alc_capture_mixer_nosrc2,
4290 alc_capture_mixer3, 4320 alc_capture_mixer_nosrc3 },
4321 { alc_capture_mixer1,
4322 alc_capture_mixer2,
4323 alc_capture_mixer3 },
4291 }; 4324 };
4292 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) 4325 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4293 spec->cap_mixer = caps[spec->num_adc_nids - 1]; 4326 int mux;
4327 if (spec->input_mux && spec->input_mux->num_items > 1)
4328 mux = 1;
4329 else
4330 mux = 0;
4331 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4332 }
4294} 4333}
4295 4334
4335#define set_beep_amp(spec, nid, idx, dir) \
4336 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4337
4338/*
4339 * OK, here we have finally the patch for ALC880
4340 */
4341
4296static int patch_alc880(struct hda_codec *codec) 4342static int patch_alc880(struct hda_codec *codec)
4297{ 4343{
4298 struct alc_spec *spec; 4344 struct alc_spec *spec;
@@ -4328,6 +4374,12 @@ static int patch_alc880(struct hda_codec *codec)
4328 } 4374 }
4329 } 4375 }
4330 4376
4377 err = snd_hda_attach_beep_device(codec, 0x1);
4378 if (err < 0) {
4379 alc_free(codec);
4380 return err;
4381 }
4382
4331 if (board_config != ALC880_AUTO) 4383 if (board_config != ALC880_AUTO)
4332 setup_preset(spec, &alc880_presets[board_config]); 4384 setup_preset(spec, &alc880_presets[board_config]);
4333 4385
@@ -4354,6 +4406,7 @@ static int patch_alc880(struct hda_codec *codec)
4354 } 4406 }
4355 } 4407 }
4356 set_capture_mixer(spec); 4408 set_capture_mixer(spec);
4409 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4357 4410
4358 spec->vmaster_nid = 0x0c; 4411 spec->vmaster_nid = 0x0c;
4359 4412
@@ -4461,6 +4514,26 @@ static struct hda_input_mux alc260_acer_capture_sources[2] = {
4461 }, 4514 },
4462 }, 4515 },
4463}; 4516};
4517
4518/* Maxdata Favorit 100XS */
4519static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4520 {
4521 .num_items = 2,
4522 .items = {
4523 { "Line/Mic", 0x0 },
4524 { "CD", 0x4 },
4525 },
4526 },
4527 {
4528 .num_items = 3,
4529 .items = {
4530 { "Line/Mic", 0x0 },
4531 { "CD", 0x4 },
4532 { "Mixer", 0x5 },
4533 },
4534 },
4535};
4536
4464/* 4537/*
4465 * This is just place-holder, so there's something for alc_build_pcms to look 4538 * This is just place-holder, so there's something for alc_build_pcms to look
4466 * at when it calculates the maximum number of channels. ALC260 has no mixer 4539 * at when it calculates the maximum number of channels. ALC260 has no mixer
@@ -4503,12 +4576,6 @@ static struct snd_kcontrol_new alc260_input_mixer[] = {
4503 { } /* end */ 4576 { } /* end */
4504}; 4577};
4505 4578
4506static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4507 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4508 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4509 { } /* end */
4510};
4511
4512/* update HP, line and mono out pins according to the master switch */ 4579/* update HP, line and mono out pins according to the master switch */
4513static void alc260_hp_master_update(struct hda_codec *codec, 4580static void alc260_hp_master_update(struct hda_codec *codec,
4514 hda_nid_t hp, hda_nid_t line, 4581 hda_nid_t hp, hda_nid_t line,
@@ -4700,8 +4767,6 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4700 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 4767 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4701 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 4768 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4702 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 4769 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4703 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4704 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4705 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4770 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4706 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), 4771 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4707 { } /* end */ 4772 { } /* end */
@@ -4746,8 +4811,18 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
4746 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4811 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4747 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4812 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4748 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4813 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4749 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4814 { } /* end */
4750 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4815};
4816
4817/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4818 */
4819static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4820 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4821 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4822 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4823 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4824 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4825 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4751 { } /* end */ 4826 { } /* end */
4752}; 4827};
4753 4828
@@ -4765,8 +4840,6 @@ static struct snd_kcontrol_new alc260_will_mixer[] = {
4765 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4840 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4766 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4841 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4767 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4842 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4768 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4769 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4770 { } /* end */ 4843 { } /* end */
4771}; 4844};
4772 4845
@@ -5124,6 +5197,89 @@ static struct hda_verb alc260_acer_init_verbs[] = {
5124 { } 5197 { }
5125}; 5198};
5126 5199
5200/* Initialisation sequence for Maxdata Favorit 100XS
5201 * (adapted from Acer init verbs).
5202 */
5203static struct hda_verb alc260_favorit100_init_verbs[] = {
5204 /* GPIO 0 enables the output jack.
5205 * Turn this on and rely on the standard mute
5206 * methods whenever the user wants to turn these outputs off.
5207 */
5208 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5209 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5210 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5211 /* Line/Mic input jack is connected to Mic1 pin */
5212 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5213 /* Ensure all other unused pins are disabled and muted. */
5214 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5215 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5217 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5218 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5219 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5224 /* Disable digital (SPDIF) pins */
5225 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5226 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5227
5228 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5229 * bus when acting as outputs.
5230 */
5231 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5232 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5233
5234 /* Start with output sum widgets muted and their output gains at min */
5235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5243 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5244
5245 /* Unmute Line-out pin widget amp left and right
5246 * (no equiv mixer ctrl)
5247 */
5248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5249 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5250 * inputs. If the pin mode is changed by the user the pin mode control
5251 * will take care of enabling the pin's input/output buffers as needed.
5252 * Therefore there's no need to enable the input buffer at this
5253 * stage.
5254 */
5255 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5256
5257 /* Mute capture amp left and right */
5258 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5259 /* Set ADC connection select to match default mixer setting - mic
5260 * (on mic1 pin)
5261 */
5262 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5263
5264 /* Do similar with the second ADC: mute capture input amp and
5265 * set ADC connection to mic to match ALSA's default state.
5266 */
5267 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5268 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5269
5270 /* Mute all inputs to mixer widget (even unconnected ones) */
5271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5279
5280 { }
5281};
5282
5127static struct hda_verb alc260_will_verbs[] = { 5283static struct hda_verb alc260_will_verbs[] = {
5128 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5284 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5129 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, 5285 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -5270,8 +5426,6 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
5270 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), 5426 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5271 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 5427 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5272 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 5428 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5273 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5274 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5275 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), 5429 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5276 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), 5430 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5277 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), 5431 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
@@ -5469,7 +5623,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5469static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 5623static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5470 const struct auto_pin_cfg *cfg) 5624 const struct auto_pin_cfg *cfg)
5471{ 5625{
5472 struct hda_input_mux *imux = &spec->private_imux; 5626 struct hda_input_mux *imux = &spec->private_imux[0];
5473 int i, err, idx; 5627 int i, err, idx;
5474 5628
5475 for (i = 0; i < AUTO_PIN_LAST; i++) { 5629 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -5544,11 +5698,9 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
5544 for (i = 0; i < AUTO_PIN_LAST; i++) { 5698 for (i = 0; i < AUTO_PIN_LAST; i++) {
5545 hda_nid_t nid = spec->autocfg.input_pins[i]; 5699 hda_nid_t nid = spec->autocfg.input_pins[i];
5546 if (nid >= 0x12) { 5700 if (nid >= 0x12) {
5547 snd_hda_codec_write(codec, nid, 0, 5701 alc_set_input_pin(codec, nid, i);
5548 AC_VERB_SET_PIN_WIDGET_CONTROL, 5702 if (nid != ALC260_PIN_CD_NID &&
5549 i <= AUTO_PIN_FRONT_MIC ? 5703 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
5550 PIN_VREF80 : PIN_IN);
5551 if (nid != ALC260_PIN_CD_NID)
5552 snd_hda_codec_write(codec, nid, 0, 5704 snd_hda_codec_write(codec, nid, 0,
5553 AC_VERB_SET_AMP_GAIN_MUTE, 5705 AC_VERB_SET_AMP_GAIN_MUTE,
5554 AMP_OUT_MUTE); 5706 AMP_OUT_MUTE);
@@ -5621,7 +5773,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5621 5773
5622 spec->multiout.max_channels = 2; 5774 spec->multiout.max_channels = 2;
5623 5775
5624 if (spec->autocfg.dig_out_pin) 5776 if (spec->autocfg.dig_outs)
5625 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 5777 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5626 if (spec->kctls.list) 5778 if (spec->kctls.list)
5627 add_mixer(spec, spec->kctls.list); 5779 add_mixer(spec, spec->kctls.list);
@@ -5629,9 +5781,8 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5629 add_verb(spec, alc260_volume_init_verbs); 5781 add_verb(spec, alc260_volume_init_verbs);
5630 5782
5631 spec->num_mux_defs = 1; 5783 spec->num_mux_defs = 1;
5632 spec->input_mux = &spec->private_imux; 5784 spec->input_mux = &spec->private_imux[0];
5633 5785
5634 store_pin_configs(codec);
5635 return 1; 5786 return 1;
5636} 5787}
5637 5788
@@ -5668,6 +5819,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
5668 [ALC260_ACER] = "acer", 5819 [ALC260_ACER] = "acer",
5669 [ALC260_WILL] = "will", 5820 [ALC260_WILL] = "will",
5670 [ALC260_REPLACER_672V] = "replacer", 5821 [ALC260_REPLACER_672V] = "replacer",
5822 [ALC260_FAVORIT100] = "favorit100",
5671#ifdef CONFIG_SND_DEBUG 5823#ifdef CONFIG_SND_DEBUG
5672 [ALC260_TEST] = "test", 5824 [ALC260_TEST] = "test",
5673#endif 5825#endif
@@ -5677,6 +5829,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
5677static struct snd_pci_quirk alc260_cfg_tbl[] = { 5829static struct snd_pci_quirk alc260_cfg_tbl[] = {
5678 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), 5830 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5679 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), 5831 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5832 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
5680 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), 5833 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5681 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), 5834 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5682 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), 5835 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
@@ -5699,8 +5852,7 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
5699static struct alc_config_preset alc260_presets[] = { 5852static struct alc_config_preset alc260_presets[] = {
5700 [ALC260_BASIC] = { 5853 [ALC260_BASIC] = {
5701 .mixers = { alc260_base_output_mixer, 5854 .mixers = { alc260_base_output_mixer,
5702 alc260_input_mixer, 5855 alc260_input_mixer },
5703 alc260_pc_beep_mixer },
5704 .init_verbs = { alc260_init_verbs }, 5856 .init_verbs = { alc260_init_verbs },
5705 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5857 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5706 .dac_nids = alc260_dac_nids, 5858 .dac_nids = alc260_dac_nids,
@@ -5779,6 +5931,18 @@ static struct alc_config_preset alc260_presets[] = {
5779 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 5931 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5780 .input_mux = alc260_acer_capture_sources, 5932 .input_mux = alc260_acer_capture_sources,
5781 }, 5933 },
5934 [ALC260_FAVORIT100] = {
5935 .mixers = { alc260_favorit100_mixer },
5936 .init_verbs = { alc260_favorit100_init_verbs },
5937 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5938 .dac_nids = alc260_dac_nids,
5939 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5940 .adc_nids = alc260_dual_adc_nids,
5941 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5942 .channel_mode = alc260_modes,
5943 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5944 .input_mux = alc260_favorit100_capture_sources,
5945 },
5782 [ALC260_WILL] = { 5946 [ALC260_WILL] = {
5783 .mixers = { alc260_will_mixer }, 5947 .mixers = { alc260_will_mixer },
5784 .init_verbs = { alc260_init_verbs, alc260_will_verbs }, 5948 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
@@ -5855,6 +6019,12 @@ static int patch_alc260(struct hda_codec *codec)
5855 } 6019 }
5856 } 6020 }
5857 6021
6022 err = snd_hda_attach_beep_device(codec, 0x1);
6023 if (err < 0) {
6024 alc_free(codec);
6025 return err;
6026 }
6027
5858 if (board_config != ALC260_AUTO) 6028 if (board_config != ALC260_AUTO)
5859 setup_preset(spec, &alc260_presets[board_config]); 6029 setup_preset(spec, &alc260_presets[board_config]);
5860 6030
@@ -5880,6 +6050,7 @@ static int patch_alc260(struct hda_codec *codec)
5880 } 6050 }
5881 } 6051 }
5882 set_capture_mixer(spec); 6052 set_capture_mixer(spec);
6053 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
5883 6054
5884 spec->vmaster_nid = 0x08; 6055 spec->vmaster_nid = 0x08;
5885 6056
@@ -6051,8 +6222,6 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
6051 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6052 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6223 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6054 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6055 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6056 { } /* end */ 6225 { } /* end */
6057}; 6226};
6058 6227
@@ -6079,8 +6248,6 @@ static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6249 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6250 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6084 { } /* end */ 6251 { } /* end */
6085}; 6252};
6086 6253
@@ -6132,8 +6299,6 @@ static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6300 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6136 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6137 { } /* end */ 6302 { } /* end */
6138}; 6303};
6139 6304
@@ -6242,8 +6407,10 @@ static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), 6407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 6408 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 6409 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6410 /* FIXME: this looks suspicious...
6245 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), 6411 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6246 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), 6412 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6413 */
6247 { } /* end */ 6414 { } /* end */
6248}; 6415};
6249 6416
@@ -6875,19 +7042,9 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6875 7042
6876 for (i = 0; i < AUTO_PIN_LAST; i++) { 7043 for (i = 0; i < AUTO_PIN_LAST; i++) {
6877 hda_nid_t nid = spec->autocfg.input_pins[i]; 7044 hda_nid_t nid = spec->autocfg.input_pins[i];
6878 unsigned int vref;
6879 if (!nid) 7045 if (!nid)
6880 continue; 7046 continue;
6881 vref = PIN_IN; 7047 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
6882 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6883 unsigned int pincap;
6884 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6885 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
6886 AC_PINCAP_VREF_80)
6887 vref = PIN_VREF80;
6888 }
6889 snd_hda_codec_write(codec, nid, 0,
6890 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6891 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 7048 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6892 snd_hda_codec_write(codec, nid, 0, 7049 snd_hda_codec_write(codec, nid, 0,
6893 AC_VERB_SET_AMP_GAIN_MUTE, 7050 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -6898,18 +7055,21 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6898static void alc882_auto_init_input_src(struct hda_codec *codec) 7055static void alc882_auto_init_input_src(struct hda_codec *codec)
6899{ 7056{
6900 struct alc_spec *spec = codec->spec; 7057 struct alc_spec *spec = codec->spec;
6901 const struct hda_input_mux *imux = spec->input_mux;
6902 int c; 7058 int c;
6903 7059
6904 for (c = 0; c < spec->num_adc_nids; c++) { 7060 for (c = 0; c < spec->num_adc_nids; c++) {
6905 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; 7061 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6906 hda_nid_t nid = spec->capsrc_nids[c]; 7062 hda_nid_t nid = spec->capsrc_nids[c];
7063 unsigned int mux_idx;
7064 const struct hda_input_mux *imux;
6907 int conns, mute, idx, item; 7065 int conns, mute, idx, item;
6908 7066
6909 conns = snd_hda_get_connections(codec, nid, conn_list, 7067 conns = snd_hda_get_connections(codec, nid, conn_list,
6910 ARRAY_SIZE(conn_list)); 7068 ARRAY_SIZE(conn_list));
6911 if (conns < 0) 7069 if (conns < 0)
6912 continue; 7070 continue;
7071 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7072 imux = &spec->input_mux[mux_idx];
6913 for (idx = 0; idx < conns; idx++) { 7073 for (idx = 0; idx < conns; idx++) {
6914 /* if the current connection is the selected one, 7074 /* if the current connection is the selected one,
6915 * unmute it as default - otherwise mute it 7075 * unmute it as default - otherwise mute it
@@ -6922,8 +7082,20 @@ static void alc882_auto_init_input_src(struct hda_codec *codec)
6922 break; 7082 break;
6923 } 7083 }
6924 } 7084 }
6925 snd_hda_codec_write(codec, nid, 0, 7085 /* check if we have a selector or mixer
6926 AC_VERB_SET_AMP_GAIN_MUTE, mute); 7086 * we could check for the widget type instead, but
7087 * just check for Amp-In presence (in case of mixer
7088 * without amp-in there is something wrong, this
7089 * function shouldn't be used or capsrc nid is wrong)
7090 */
7091 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7092 snd_hda_codec_write(codec, nid, 0,
7093 AC_VERB_SET_AMP_GAIN_MUTE,
7094 mute);
7095 else if (mute != AMP_IN_MUTE(idx))
7096 snd_hda_codec_write(codec, nid, 0,
7097 AC_VERB_SET_CONNECT_SEL,
7098 idx);
6927 } 7099 }
6928 } 7100 }
6929} 7101}
@@ -7012,12 +7184,15 @@ static int patch_alc882(struct hda_codec *codec)
7012 break; 7184 break;
7013 case 0x106b1000: /* iMac 24 */ 7185 case 0x106b1000: /* iMac 24 */
7014 case 0x106b2800: /* AppleTV */ 7186 case 0x106b2800: /* AppleTV */
7187 case 0x106b3e00: /* iMac 24 Aluminium */
7015 board_config = ALC885_IMAC24; 7188 board_config = ALC885_IMAC24;
7016 break; 7189 break;
7190 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
7017 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ 7191 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7018 case 0x106b00a4: /* MacbookPro4,1 */ 7192 case 0x106b00a4: /* MacbookPro4,1 */
7019 case 0x106b2c00: /* Macbook Pro rev3 */ 7193 case 0x106b2c00: /* Macbook Pro rev3 */
7020 case 0x106b3600: /* Macbook 3.1 */ 7194 case 0x106b3600: /* Macbook 3.1 */
7195 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7021 board_config = ALC885_MBP3; 7196 board_config = ALC885_MBP3;
7022 break; 7197 break;
7023 default: 7198 default:
@@ -7049,6 +7224,12 @@ static int patch_alc882(struct hda_codec *codec)
7049 } 7224 }
7050 } 7225 }
7051 7226
7227 err = snd_hda_attach_beep_device(codec, 0x1);
7228 if (err < 0) {
7229 alc_free(codec);
7230 return err;
7231 }
7232
7052 if (board_config != ALC882_AUTO) 7233 if (board_config != ALC882_AUTO)
7053 setup_preset(spec, &alc882_presets[board_config]); 7234 setup_preset(spec, &alc882_presets[board_config]);
7054 7235
@@ -7069,7 +7250,7 @@ static int patch_alc882(struct hda_codec *codec)
7069 spec->stream_digital_playback = &alc882_pcm_digital_playback; 7250 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7070 spec->stream_digital_capture = &alc882_pcm_digital_capture; 7251 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7071 7252
7072 spec->is_mix_capture = 1; /* matrix-style capture */ 7253 spec->capture_style = CAPT_MIX; /* matrix-style capture */
7073 if (!spec->adc_nids && spec->input_mux) { 7254 if (!spec->adc_nids && spec->input_mux) {
7074 /* check whether NID 0x07 is valid */ 7255 /* check whether NID 0x07 is valid */
7075 unsigned int wcap = get_wcaps(codec, 0x07); 7256 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -7086,6 +7267,7 @@ static int patch_alc882(struct hda_codec *codec)
7086 } 7267 }
7087 } 7268 }
7088 set_capture_mixer(spec); 7269 set_capture_mixer(spec);
7270 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7089 7271
7090 spec->vmaster_nid = 0x0c; 7272 spec->vmaster_nid = 0x0c;
7091 7273
@@ -7137,10 +7319,14 @@ static hda_nid_t alc883_adc_nids_rev[2] = {
7137 0x09, 0x08 7319 0x09, 0x08
7138}; 7320};
7139 7321
7322#define alc889_adc_nids alc880_adc_nids
7323
7140static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; 7324static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7141 7325
7142static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; 7326static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7143 7327
7328#define alc889_capsrc_nids alc882_capsrc_nids
7329
7144/* input MUX */ 7330/* input MUX */
7145/* FIXME: should be a matrix-type input source selection */ 7331/* FIXME: should be a matrix-type input source selection */
7146 7332
@@ -7358,8 +7544,6 @@ static struct snd_kcontrol_new alc883_base_mixer[] = {
7358 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7359 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7545 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7361 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7362 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7363 { } /* end */ 7547 { } /* end */
7364}; 7548};
7365 7549
@@ -7422,8 +7606,6 @@ static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7422 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7423 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7607 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7608 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7425 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7426 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7427 { } /* end */ 7609 { } /* end */
7428}; 7610};
7429 7611
@@ -7447,8 +7629,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7629 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7630 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7631 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7450 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7451 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7452 { } /* end */ 7632 { } /* end */
7453}; 7633};
7454 7634
@@ -7473,8 +7653,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7473 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7653 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), 7654 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7655 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7476 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7477 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7478 { } /* end */ 7656 { } /* end */
7479}; 7657};
7480 7658
@@ -7498,8 +7676,6 @@ static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7498 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7676 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7499 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7677 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7501 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7502 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7503 { } /* end */ 7679 { } /* end */
7504}; 7680};
7505 7681
@@ -7907,36 +8083,83 @@ static struct hda_verb alc888_lenovo_sky_verbs[] = {
7907 { } /* end */ 8083 { } /* end */
7908}; 8084};
7909 8085
8086static struct hda_verb alc888_6st_dell_verbs[] = {
8087 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8088 { }
8089};
8090
8091static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8092{
8093 unsigned int present, bits;
8094
8095 present = snd_hda_codec_read(codec, 0x1b, 0,
8096 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8097 bits = present ? HDA_AMP_MUTE : 0;
8098 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8099 HDA_AMP_MUTE, bits);
8100 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8101 HDA_AMP_MUTE, bits);
8102 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8103 HDA_AMP_MUTE, bits);
8104}
8105
8106static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8107 unsigned int res)
8108{
8109 switch (res >> 26) {
8110 case ALC880_HP_EVENT:
8111 alc888_3st_hp_front_automute(codec);
8112 break;
8113 }
8114}
8115
7910static struct hda_verb alc888_3st_hp_verbs[] = { 8116static struct hda_verb alc888_3st_hp_verbs[] = {
7911 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 8117 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7912 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 8118 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7913 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 8119 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7914 { }
7915};
7916
7917static struct hda_verb alc888_6st_dell_verbs[] = {
7918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8120 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7919 { } 8121 { } /* end */
7920}; 8122};
7921 8123
8124/*
8125 * 2ch mode
8126 */
7922static struct hda_verb alc888_3st_hp_2ch_init[] = { 8127static struct hda_verb alc888_3st_hp_2ch_init[] = {
7923 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 8128 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7924 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 8129 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7925 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 8130 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7926 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 8131 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7927 { } 8132 { } /* end */
8133};
8134
8135/*
8136 * 4ch mode
8137 */
8138static struct hda_verb alc888_3st_hp_4ch_init[] = {
8139 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8140 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8141 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8142 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8143 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8144 { } /* end */
7928}; 8145};
7929 8146
8147/*
8148 * 6ch mode
8149 */
7930static struct hda_verb alc888_3st_hp_6ch_init[] = { 8150static struct hda_verb alc888_3st_hp_6ch_init[] = {
7931 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8151 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7932 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 8152 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8153 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7933 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8154 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7934 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 8155 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7935 { } 8156 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8157 { } /* end */
7936}; 8158};
7937 8159
7938static struct hda_channel_mode alc888_3st_hp_modes[2] = { 8160static struct hda_channel_mode alc888_3st_hp_modes[3] = {
7939 { 2, alc888_3st_hp_2ch_init }, 8161 { 2, alc888_3st_hp_2ch_init },
8162 { 4, alc888_3st_hp_4ch_init },
7940 { 6, alc888_3st_hp_6ch_init }, 8163 { 6, alc888_3st_hp_6ch_init },
7941}; 8164};
7942 8165
@@ -8197,7 +8420,7 @@ static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8197{ 8420{
8198 switch (res >> 26) { 8421 switch (res >> 26) {
8199 case ALC880_HP_EVENT: 8422 case ALC880_HP_EVENT:
8200 printk("hp_event\n"); 8423 /* printk(KERN_DEBUG "hp_event\n"); */
8201 alc888_6st_dell_front_automute(codec); 8424 alc888_6st_dell_front_automute(codec);
8202 break; 8425 break;
8203 } 8426 }
@@ -8456,6 +8679,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8456 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8679 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
8457 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8680 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8458 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), 8681 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8682 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
8459 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 8683 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8460 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 8684 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8461 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), 8685 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
@@ -8463,21 +8687,29 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8463 ALC888_ACER_ASPIRE_4930G), 8687 ALC888_ACER_ASPIRE_4930G),
8464 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", 8688 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8465 ALC888_ACER_ASPIRE_4930G), 8689 ALC888_ACER_ASPIRE_4930G),
8690 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
8691 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
8466 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 8692 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8467 ALC888_ACER_ASPIRE_4930G), 8693 ALC888_ACER_ASPIRE_4930G),
8468 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 8694 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8695 ALC888_ACER_ASPIRE_4930G),
8696 /* default Acer */
8697 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
8469 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8698 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8470 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8699 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8471 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8700 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8472 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8701 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8473 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8702 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8474 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8703 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8704 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8475 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8705 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8476 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8706 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8707 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8477 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8708 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8478 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8709 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8479 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8710 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8480 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8711 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
8712 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8481 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 8713 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8482 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 8714 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8483 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 8715 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
@@ -8509,11 +8741,12 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8509 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8741 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8510 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8742 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8511 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8743 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8512 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 8744 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8513 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8745 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8514 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8746 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8515 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), 8747 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
8516 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", 8748 ALC883_FUJITSU_PI2515),
8749 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
8517 ALC888_FUJITSU_XA3530), 8750 ALC888_FUJITSU_XA3530),
8518 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 8751 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8519 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8752 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
@@ -8526,11 +8759,20 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8526 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 8759 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8527 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), 8760 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8528 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), 8761 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8762 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8529 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), 8763 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
8530 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 8764 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8531 {} 8765 {}
8532}; 8766};
8533 8767
8768static hda_nid_t alc883_slave_dig_outs[] = {
8769 ALC1200_DIGOUT_NID, 0,
8770};
8771
8772static hda_nid_t alc1200_slave_dig_outs[] = {
8773 ALC883_DIGOUT_NID, 0,
8774};
8775
8534static struct alc_config_preset alc883_presets[] = { 8776static struct alc_config_preset alc883_presets[] = {
8535 [ALC883_3ST_2ch_DIG] = { 8777 [ALC883_3ST_2ch_DIG] = {
8536 .mixers = { alc883_3ST_2ch_mixer }, 8778 .mixers = { alc883_3ST_2ch_mixer },
@@ -8572,6 +8814,7 @@ static struct alc_config_preset alc883_presets[] = {
8572 .dac_nids = alc883_dac_nids, 8814 .dac_nids = alc883_dac_nids,
8573 .dig_out_nid = ALC883_DIGOUT_NID, 8815 .dig_out_nid = ALC883_DIGOUT_NID,
8574 .dig_in_nid = ALC883_DIGIN_NID, 8816 .dig_in_nid = ALC883_DIGIN_NID,
8817 .slave_dig_outs = alc883_slave_dig_outs,
8575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), 8818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8576 .channel_mode = alc883_3ST_6ch_intel_modes, 8819 .channel_mode = alc883_3ST_6ch_intel_modes,
8577 .need_dac_fix = 1, 8820 .need_dac_fix = 1,
@@ -8766,6 +9009,8 @@ static struct alc_config_preset alc883_presets[] = {
8766 .channel_mode = alc888_3st_hp_modes, 9009 .channel_mode = alc888_3st_hp_modes,
8767 .need_dac_fix = 1, 9010 .need_dac_fix = 1,
8768 .input_mux = &alc883_capture_source, 9011 .input_mux = &alc883_capture_source,
9012 .unsol_event = alc888_3st_hp_unsol_event,
9013 .init_hook = alc888_3st_hp_front_automute,
8769 }, 9014 },
8770 [ALC888_6ST_DELL] = { 9015 [ALC888_6ST_DELL] = {
8771 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 9016 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -8871,6 +9116,7 @@ static struct alc_config_preset alc883_presets[] = {
8871 .dac_nids = alc883_dac_nids, 9116 .dac_nids = alc883_dac_nids,
8872 .dig_out_nid = ALC1200_DIGOUT_NID, 9117 .dig_out_nid = ALC1200_DIGOUT_NID,
8873 .dig_in_nid = ALC883_DIGIN_NID, 9118 .dig_in_nid = ALC883_DIGIN_NID,
9119 .slave_dig_outs = alc1200_slave_dig_outs,
8874 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 9120 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8875 .channel_mode = alc883_sixstack_modes, 9121 .channel_mode = alc883_sixstack_modes,
8876 .input_mux = &alc883_capture_source, 9122 .input_mux = &alc883_capture_source,
@@ -8938,11 +9184,9 @@ static void alc883_auto_init_analog_input(struct hda_codec *codec)
8938 for (i = 0; i < AUTO_PIN_LAST; i++) { 9184 for (i = 0; i < AUTO_PIN_LAST; i++) {
8939 hda_nid_t nid = spec->autocfg.input_pins[i]; 9185 hda_nid_t nid = spec->autocfg.input_pins[i];
8940 if (alc883_is_input_pin(nid)) { 9186 if (alc883_is_input_pin(nid)) {
8941 snd_hda_codec_write(codec, nid, 0, 9187 alc_set_input_pin(codec, nid, i);
8942 AC_VERB_SET_PIN_WIDGET_CONTROL, 9188 if (nid != ALC883_PIN_CD_NID &&
8943 (i <= AUTO_PIN_FRONT_MIC ? 9189 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
8944 PIN_VREF80 : PIN_IN));
8945 if (nid != ALC883_PIN_CD_NID)
8946 snd_hda_codec_write(codec, nid, 0, 9190 snd_hda_codec_write(codec, nid, 0,
8947 AC_VERB_SET_AMP_GAIN_MUTE, 9191 AC_VERB_SET_AMP_GAIN_MUTE,
8948 AMP_OUT_MUTE); 9192 AMP_OUT_MUTE);
@@ -8957,6 +9201,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8957{ 9201{
8958 struct alc_spec *spec = codec->spec; 9202 struct alc_spec *spec = codec->spec;
8959 int err = alc880_parse_auto_config(codec); 9203 int err = alc880_parse_auto_config(codec);
9204 struct auto_pin_cfg *cfg = &spec->autocfg;
9205 int i;
8960 9206
8961 if (err < 0) 9207 if (err < 0)
8962 return err; 9208 return err;
@@ -8970,6 +9216,26 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8970 /* hack - override the init verbs */ 9216 /* hack - override the init verbs */
8971 spec->init_verbs[0] = alc883_auto_init_verbs; 9217 spec->init_verbs[0] = alc883_auto_init_verbs;
8972 9218
9219 /* setup input_mux for ALC889 */
9220 if (codec->vendor_id == 0x10ec0889) {
9221 /* digital-mic input pin is excluded in alc880_auto_create..()
9222 * because it's under 0x18
9223 */
9224 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9225 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9226 struct hda_input_mux *imux = &spec->private_imux[0];
9227 for (i = 1; i < 3; i++)
9228 memcpy(&spec->private_imux[i],
9229 &spec->private_imux[0],
9230 sizeof(spec->private_imux[0]));
9231 imux->items[imux->num_items].label = "Int DMic";
9232 imux->items[imux->num_items].index = 0x0b;
9233 imux->num_items++;
9234 spec->num_mux_defs = 3;
9235 spec->input_mux = spec->private_imux;
9236 }
9237 }
9238
8973 return 1; /* config found */ 9239 return 1; /* config found */
8974} 9240}
8975 9241
@@ -9021,6 +9287,12 @@ static int patch_alc883(struct hda_codec *codec)
9021 } 9287 }
9022 } 9288 }
9023 9289
9290 err = snd_hda_attach_beep_device(codec, 0x1);
9291 if (err < 0) {
9292 alc_free(codec);
9293 return err;
9294 }
9295
9024 if (board_config != ALC883_AUTO) 9296 if (board_config != ALC883_AUTO)
9025 setup_preset(spec, &alc883_presets[board_config]); 9297 setup_preset(spec, &alc883_presets[board_config]);
9026 9298
@@ -9033,14 +9305,36 @@ static int patch_alc883(struct hda_codec *codec)
9033 spec->stream_name_analog = "ALC888 Analog"; 9305 spec->stream_name_analog = "ALC888 Analog";
9034 spec->stream_name_digital = "ALC888 Digital"; 9306 spec->stream_name_digital = "ALC888 Digital";
9035 } 9307 }
9308 if (!spec->num_adc_nids) {
9309 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9310 spec->adc_nids = alc883_adc_nids;
9311 }
9312 if (!spec->capsrc_nids)
9313 spec->capsrc_nids = alc883_capsrc_nids;
9314 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9036 break; 9315 break;
9037 case 0x10ec0889: 9316 case 0x10ec0889:
9038 spec->stream_name_analog = "ALC889 Analog"; 9317 spec->stream_name_analog = "ALC889 Analog";
9039 spec->stream_name_digital = "ALC889 Digital"; 9318 spec->stream_name_digital = "ALC889 Digital";
9319 if (!spec->num_adc_nids) {
9320 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9321 spec->adc_nids = alc889_adc_nids;
9322 }
9323 if (!spec->capsrc_nids)
9324 spec->capsrc_nids = alc889_capsrc_nids;
9325 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9326 capture */
9040 break; 9327 break;
9041 default: 9328 default:
9042 spec->stream_name_analog = "ALC883 Analog"; 9329 spec->stream_name_analog = "ALC883 Analog";
9043 spec->stream_name_digital = "ALC883 Digital"; 9330 spec->stream_name_digital = "ALC883 Digital";
9331 if (!spec->num_adc_nids) {
9332 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9333 spec->adc_nids = alc883_adc_nids;
9334 }
9335 if (!spec->capsrc_nids)
9336 spec->capsrc_nids = alc883_capsrc_nids;
9337 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9044 break; 9338 break;
9045 } 9339 }
9046 9340
@@ -9051,15 +9345,9 @@ static int patch_alc883(struct hda_codec *codec)
9051 spec->stream_digital_playback = &alc883_pcm_digital_playback; 9345 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9052 spec->stream_digital_capture = &alc883_pcm_digital_capture; 9346 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9053 9347
9054 if (!spec->num_adc_nids) {
9055 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9056 spec->adc_nids = alc883_adc_nids;
9057 }
9058 if (!spec->capsrc_nids)
9059 spec->capsrc_nids = alc883_capsrc_nids;
9060 spec->is_mix_capture = 1; /* matrix-style capture */
9061 if (!spec->cap_mixer) 9348 if (!spec->cap_mixer)
9062 set_capture_mixer(spec); 9349 set_capture_mixer(spec);
9350 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9063 9351
9064 spec->vmaster_nid = 0x0c; 9352 spec->vmaster_nid = 0x0c;
9065 9353
@@ -9112,8 +9400,6 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
9112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9400 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9401 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9114 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9402 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9115 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9116 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
9117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 9403 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9119 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 9405 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
@@ -9134,8 +9420,6 @@ static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9134 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9420 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9135 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9421 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9422 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9137 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9138 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
9139 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ 9423 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9141 { } /* end */ 9425 { } /* end */
@@ -9244,8 +9528,6 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 9528 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9245 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9529 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9246 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9530 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9247 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9248 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9249 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), 9531 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9250 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), 9532 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9251 { } /* end */ 9533 { } /* end */
@@ -9274,8 +9556,6 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
9274 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 9556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9557 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9558 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9277 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9278 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9279 { } /* end */ 9559 { } /* end */
9280}; 9560};
9281 9561
@@ -9423,6 +9703,67 @@ static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9423 { } /* end */ 9703 { } /* end */
9424}; 9704};
9425 9705
9706static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9707 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9708 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9710 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9715 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9716 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9717 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9718 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9719 { } /* end */
9720};
9721
9722static struct hda_verb alc262_tyan_verbs[] = {
9723 /* Headphone automute */
9724 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9726 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9727
9728 /* P11 AUX_IN, white 4-pin connector */
9729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9730 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9731 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9732 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9733
9734 {}
9735};
9736
9737/* unsolicited event for HP jack sensing */
9738static void alc262_tyan_automute(struct hda_codec *codec)
9739{
9740 unsigned int mute;
9741 unsigned int present;
9742
9743 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9744 present = snd_hda_codec_read(codec, 0x1b, 0,
9745 AC_VERB_GET_PIN_SENSE, 0);
9746 present = (present & 0x80000000) != 0;
9747 if (present) {
9748 /* mute line output on ATX panel */
9749 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9750 HDA_AMP_MUTE, HDA_AMP_MUTE);
9751 } else {
9752 /* unmute line output if necessary */
9753 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9754 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9755 HDA_AMP_MUTE, mute);
9756 }
9757}
9758
9759static void alc262_tyan_unsol_event(struct hda_codec *codec,
9760 unsigned int res)
9761{
9762 if ((res >> 26) != ALC880_HP_EVENT)
9763 return;
9764 alc262_tyan_automute(codec);
9765}
9766
9426#define alc262_capture_mixer alc882_capture_mixer 9767#define alc262_capture_mixer alc882_capture_mixer
9427#define alc262_capture_alt_mixer alc882_capture_alt_mixer 9768#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9428 9769
@@ -9889,8 +10230,6 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
9889 }, 10230 },
9890 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 10231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9891 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 10232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9892 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9893 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
9894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10233 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
@@ -10462,8 +10801,14 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10462 alc262_ignore); 10801 alc262_ignore);
10463 if (err < 0) 10802 if (err < 0)
10464 return err; 10803 return err;
10465 if (!spec->autocfg.line_outs) 10804 if (!spec->autocfg.line_outs) {
10805 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
10806 spec->multiout.max_channels = 2;
10807 spec->no_analog = 1;
10808 goto dig_only;
10809 }
10466 return 0; /* can't find valid BIOS pin config */ 10810 return 0; /* can't find valid BIOS pin config */
10811 }
10467 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 10812 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10468 if (err < 0) 10813 if (err < 0)
10469 return err; 10814 return err;
@@ -10473,8 +10818,11 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10473 10818
10474 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 10819 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10475 10820
10476 if (spec->autocfg.dig_out_pin) 10821 dig_only:
10822 if (spec->autocfg.dig_outs) {
10477 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; 10823 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10824 spec->dig_out_type = spec->autocfg.dig_out_type[0];
10825 }
10478 if (spec->autocfg.dig_in_pin) 10826 if (spec->autocfg.dig_in_pin)
10479 spec->dig_in_nid = ALC262_DIGIN_NID; 10827 spec->dig_in_nid = ALC262_DIGIN_NID;
10480 10828
@@ -10483,13 +10831,12 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10483 10831
10484 add_verb(spec, alc262_volume_init_verbs); 10832 add_verb(spec, alc262_volume_init_verbs);
10485 spec->num_mux_defs = 1; 10833 spec->num_mux_defs = 1;
10486 spec->input_mux = &spec->private_imux; 10834 spec->input_mux = &spec->private_imux[0];
10487 10835
10488 err = alc_auto_add_mic_boost(codec); 10836 err = alc_auto_add_mic_boost(codec);
10489 if (err < 0) 10837 if (err < 0)
10490 return err; 10838 return err;
10491 10839
10492 store_pin_configs(codec);
10493 return 1; 10840 return 1;
10494} 10841}
10495 10842
@@ -10531,20 +10878,19 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
10531 [ALC262_ULTRA] = "ultra", 10878 [ALC262_ULTRA] = "ultra",
10532 [ALC262_LENOVO_3000] = "lenovo-3000", 10879 [ALC262_LENOVO_3000] = "lenovo-3000",
10533 [ALC262_NEC] = "nec", 10880 [ALC262_NEC] = "nec",
10881 [ALC262_TYAN] = "tyan",
10534 [ALC262_AUTO] = "auto", 10882 [ALC262_AUTO] = "auto",
10535}; 10883};
10536 10884
10537static struct snd_pci_quirk alc262_cfg_tbl[] = { 10885static struct snd_pci_quirk alc262_cfg_tbl[] = {
10538 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 10886 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
10539 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), 10887 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
10540 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 10888 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10541 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), 10889 ALC262_HP_BPC),
10542 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), 10890 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10543 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), 10891 ALC262_HP_BPC),
10544 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), 10892 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10545 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), 10893 ALC262_HP_BPC),
10546 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
10547 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
10548 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 10894 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
10549 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), 10895 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
10550 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 10896 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
@@ -10562,17 +10908,18 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
10562 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10908 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10563 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), 10909 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
10564 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10910 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10565 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10911 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
10566 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10912 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10567 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN", 10913 ALC262_SONY_ASSAMD),
10568 ALC262_SONY_ASSAMD),
10569 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10914 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10570 ALC262_TOSHIBA_RX1), 10915 ALC262_TOSHIBA_RX1),
10571 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), 10916 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10572 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 10917 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10573 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 10918 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10574 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 10919 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
10575 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), 10920 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10921 ALC262_ULTRA),
10922 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
10576 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), 10923 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
10577 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 10924 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
10578 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 10925 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
@@ -10788,6 +11135,19 @@ static struct alc_config_preset alc262_presets[] = {
10788 .unsol_event = alc262_hippo_unsol_event, 11135 .unsol_event = alc262_hippo_unsol_event,
10789 .init_hook = alc262_hippo_automute, 11136 .init_hook = alc262_hippo_automute,
10790 }, 11137 },
11138 [ALC262_TYAN] = {
11139 .mixers = { alc262_tyan_mixer },
11140 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11141 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11142 .dac_nids = alc262_dac_nids,
11143 .hp_nid = 0x02,
11144 .dig_out_nid = ALC262_DIGOUT_NID,
11145 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11146 .channel_mode = alc262_modes,
11147 .input_mux = &alc262_capture_source,
11148 .unsol_event = alc262_tyan_unsol_event,
11149 .init_hook = alc262_tyan_automute,
11150 },
10791}; 11151};
10792 11152
10793static int patch_alc262(struct hda_codec *codec) 11153static int patch_alc262(struct hda_codec *codec)
@@ -10840,6 +11200,14 @@ static int patch_alc262(struct hda_codec *codec)
10840 } 11200 }
10841 } 11201 }
10842 11202
11203 if (!spec->no_analog) {
11204 err = snd_hda_attach_beep_device(codec, 0x1);
11205 if (err < 0) {
11206 alc_free(codec);
11207 return err;
11208 }
11209 }
11210
10843 if (board_config != ALC262_AUTO) 11211 if (board_config != ALC262_AUTO)
10844 setup_preset(spec, &alc262_presets[board_config]); 11212 setup_preset(spec, &alc262_presets[board_config]);
10845 11213
@@ -10851,7 +11219,7 @@ static int patch_alc262(struct hda_codec *codec)
10851 spec->stream_digital_playback = &alc262_pcm_digital_playback; 11219 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10852 spec->stream_digital_capture = &alc262_pcm_digital_capture; 11220 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10853 11221
10854 spec->is_mix_capture = 1; 11222 spec->capture_style = CAPT_MIX;
10855 if (!spec->adc_nids && spec->input_mux) { 11223 if (!spec->adc_nids && spec->input_mux) {
10856 /* check whether NID 0x07 is valid */ 11224 /* check whether NID 0x07 is valid */
10857 unsigned int wcap = get_wcaps(codec, 0x07); 11225 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -10868,8 +11236,10 @@ static int patch_alc262(struct hda_codec *codec)
10868 spec->capsrc_nids = alc262_capsrc_nids; 11236 spec->capsrc_nids = alc262_capsrc_nids;
10869 } 11237 }
10870 } 11238 }
10871 if (!spec->cap_mixer) 11239 if (!spec->cap_mixer && !spec->no_analog)
10872 set_capture_mixer(spec); 11240 set_capture_mixer(spec);
11241 if (!spec->no_analog)
11242 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10873 11243
10874 spec->vmaster_nid = 0x0c; 11244 spec->vmaster_nid = 0x0c;
10875 11245
@@ -11249,19 +11619,13 @@ static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11249static struct hda_verb alc268_base_init_verbs[] = { 11619static struct hda_verb alc268_base_init_verbs[] = {
11250 /* Unmute DAC0-1 and set vol = 0 */ 11620 /* Unmute DAC0-1 and set vol = 0 */
11251 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11621 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11622 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11256 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11257 11623
11258 /* 11624 /*
11259 * Set up output mixers (0x0c - 0x0e) 11625 * Set up output mixers (0x0c - 0x0e)
11260 */ 11626 */
11261 /* set vol=0 to output mixers */ 11627 /* set vol=0 to output mixers */
11262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11265 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 11629 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11266 11630
11267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11280,9 +11644,7 @@ static struct hda_verb alc268_base_init_verbs[] = {
11280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11281 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11283 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11284 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11285 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11286 11648
11287 /* set PCBEEP vol = 0, mute connections */ 11649 /* set PCBEEP vol = 0, mute connections */
11288 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11650 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11304,10 +11666,8 @@ static struct hda_verb alc268_base_init_verbs[] = {
11304 */ 11666 */
11305static struct hda_verb alc268_volume_init_verbs[] = { 11667static struct hda_verb alc268_volume_init_verbs[] = {
11306 /* set output DAC */ 11668 /* set output DAC */
11307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11669 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11308 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11670 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11310 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11311 11671
11312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11672 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11673 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
@@ -11315,16 +11675,12 @@ static struct hda_verb alc268_volume_init_verbs[] = {
11315 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11316 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11676 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11317 11677
11318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11322 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11680 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11323 11681
11324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11327 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11328 11684
11329 /* set PCBEEP vol = 0, mute connections */ 11685 /* set PCBEEP vol = 0, mute connections */
11330 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11686 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11523,7 +11879,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11523static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 11879static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11524 const struct auto_pin_cfg *cfg) 11880 const struct auto_pin_cfg *cfg)
11525{ 11881{
11526 struct hda_input_mux *imux = &spec->private_imux; 11882 struct hda_input_mux *imux = &spec->private_imux[0];
11527 int i, idx1; 11883 int i, idx1;
11528 11884
11529 for (i = 0; i < AUTO_PIN_LAST; i++) { 11885 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -11617,9 +11973,14 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11617 alc268_ignore); 11973 alc268_ignore);
11618 if (err < 0) 11974 if (err < 0)
11619 return err; 11975 return err;
11620 if (!spec->autocfg.line_outs) 11976 if (!spec->autocfg.line_outs) {
11977 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11978 spec->multiout.max_channels = 2;
11979 spec->no_analog = 1;
11980 goto dig_only;
11981 }
11621 return 0; /* can't find valid BIOS pin config */ 11982 return 0; /* can't find valid BIOS pin config */
11622 11983 }
11623 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 11984 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11624 if (err < 0) 11985 if (err < 0)
11625 return err; 11986 return err;
@@ -11629,25 +11990,26 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11629 11990
11630 spec->multiout.max_channels = 2; 11991 spec->multiout.max_channels = 2;
11631 11992
11993 dig_only:
11632 /* digital only support output */ 11994 /* digital only support output */
11633 if (spec->autocfg.dig_out_pin) 11995 if (spec->autocfg.dig_outs) {
11634 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; 11996 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11635 11997 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11998 }
11636 if (spec->kctls.list) 11999 if (spec->kctls.list)
11637 add_mixer(spec, spec->kctls.list); 12000 add_mixer(spec, spec->kctls.list);
11638 12001
11639 if (spec->autocfg.speaker_pins[0] != 0x1d) 12002 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
11640 add_mixer(spec, alc268_beep_mixer); 12003 add_mixer(spec, alc268_beep_mixer);
11641 12004
11642 add_verb(spec, alc268_volume_init_verbs); 12005 add_verb(spec, alc268_volume_init_verbs);
11643 spec->num_mux_defs = 1; 12006 spec->num_mux_defs = 1;
11644 spec->input_mux = &spec->private_imux; 12007 spec->input_mux = &spec->private_imux[0];
11645 12008
11646 err = alc_auto_add_mic_boost(codec); 12009 err = alc_auto_add_mic_boost(codec);
11647 if (err < 0) 12010 if (err < 0)
11648 return err; 12011 return err;
11649 12012
11650 store_pin_configs(codec);
11651 return 1; 12013 return 1;
11652} 12014}
11653 12015
@@ -11709,7 +12071,7 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
11709 12071
11710static struct alc_config_preset alc268_presets[] = { 12072static struct alc_config_preset alc268_presets[] = {
11711 [ALC267_QUANTA_IL1] = { 12073 [ALC267_QUANTA_IL1] = {
11712 .mixers = { alc267_quanta_il1_mixer }, 12074 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
11713 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12075 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11714 alc267_quanta_il1_verbs }, 12076 alc267_quanta_il1_verbs },
11715 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12077 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -11791,7 +12153,8 @@ static struct alc_config_preset alc268_presets[] = {
11791 }, 12153 },
11792 [ALC268_ACER_ASPIRE_ONE] = { 12154 [ALC268_ACER_ASPIRE_ONE] = {
11793 .mixers = { alc268_acer_aspire_one_mixer, 12155 .mixers = { alc268_acer_aspire_one_mixer,
11794 alc268_capture_alt_mixer }, 12156 alc268_beep_mixer,
12157 alc268_capture_alt_mixer },
11795 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12158 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11796 alc268_acer_aspire_one_verbs }, 12159 alc268_acer_aspire_one_verbs },
11797 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12160 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -11860,7 +12223,7 @@ static int patch_alc268(struct hda_codec *codec)
11860{ 12223{
11861 struct alc_spec *spec; 12224 struct alc_spec *spec;
11862 int board_config; 12225 int board_config;
11863 int err; 12226 int i, has_beep, err;
11864 12227
11865 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 12228 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11866 if (spec == NULL) 12229 if (spec == NULL)
@@ -11909,15 +12272,30 @@ static int patch_alc268(struct hda_codec *codec)
11909 12272
11910 spec->stream_digital_playback = &alc268_pcm_digital_playback; 12273 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11911 12274
11912 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 12275 has_beep = 0;
11913 /* override the amp caps for beep generator */ 12276 for (i = 0; i < spec->num_mixers; i++) {
11914 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 12277 if (spec->mixers[i] == alc268_beep_mixer) {
12278 has_beep = 1;
12279 break;
12280 }
12281 }
12282
12283 if (has_beep) {
12284 err = snd_hda_attach_beep_device(codec, 0x1);
12285 if (err < 0) {
12286 alc_free(codec);
12287 return err;
12288 }
12289 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12290 /* override the amp caps for beep generator */
12291 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11915 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 12292 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11916 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 12293 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11917 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 12294 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11918 (0 << AC_AMPCAP_MUTE_SHIFT)); 12295 (0 << AC_AMPCAP_MUTE_SHIFT));
12296 }
11919 12297
11920 if (!spec->adc_nids && spec->input_mux) { 12298 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
11921 /* check whether NID 0x07 is valid */ 12299 /* check whether NID 0x07 is valid */
11922 unsigned int wcap = get_wcaps(codec, 0x07); 12300 unsigned int wcap = get_wcaps(codec, 0x07);
11923 int i; 12301 int i;
@@ -11998,8 +12376,6 @@ static struct snd_kcontrol_new alc269_base_mixer[] = {
11998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 12376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12001 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12002 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12003 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 12379 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12004 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 12380 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12005 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 12381 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
@@ -12026,8 +12402,6 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12026 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 12402 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 12403 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12028 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 12404 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12029 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12030 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12031 { } 12405 { }
12032}; 12406};
12033 12407
@@ -12051,8 +12425,6 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12051 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT), 12425 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12052 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT), 12426 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12053 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT), 12427 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12054 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12055 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12056 { } 12428 { }
12057}; 12429};
12058 12430
@@ -12089,13 +12461,6 @@ static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12089 { } /* end */ 12461 { } /* end */
12090}; 12462};
12091 12463
12092/* beep control */
12093static struct snd_kcontrol_new alc269_beep_mixer[] = {
12094 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12095 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12096 { } /* end */
12097};
12098
12099static struct hda_verb alc269_quanta_fl1_verbs[] = { 12464static struct hda_verb alc269_quanta_fl1_verbs[] = {
12100 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12101 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12466 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
@@ -12495,7 +12860,7 @@ static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12495 */ 12860 */
12496 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 12861 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12497 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 12862 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12498 struct hda_input_mux *imux = &spec->private_imux; 12863 struct hda_input_mux *imux = &spec->private_imux[0];
12499 imux->items[imux->num_items].label = "Int Mic"; 12864 imux->items[imux->num_items].label = "Int Mic";
12500 imux->items[imux->num_items].index = 0x05; 12865 imux->items[imux->num_items].index = 0x05;
12501 imux->num_items++; 12866 imux->num_items++;
@@ -12513,13 +12878,34 @@ static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12513#define alc269_pcm_digital_playback alc880_pcm_digital_playback 12878#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12514#define alc269_pcm_digital_capture alc880_pcm_digital_capture 12879#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12515 12880
12881static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12882 .substreams = 1,
12883 .channels_min = 2,
12884 .channels_max = 8,
12885 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12886 /* NID is set in alc_build_pcms */
12887 .ops = {
12888 .open = alc880_playback_pcm_open,
12889 .prepare = alc880_playback_pcm_prepare,
12890 .cleanup = alc880_playback_pcm_cleanup
12891 },
12892};
12893
12894static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12895 .substreams = 1,
12896 .channels_min = 2,
12897 .channels_max = 2,
12898 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12899 /* NID is set in alc_build_pcms */
12900};
12901
12516/* 12902/*
12517 * BIOS auto configuration 12903 * BIOS auto configuration
12518 */ 12904 */
12519static int alc269_parse_auto_config(struct hda_codec *codec) 12905static int alc269_parse_auto_config(struct hda_codec *codec)
12520{ 12906{
12521 struct alc_spec *spec = codec->spec; 12907 struct alc_spec *spec = codec->spec;
12522 int i, err; 12908 int err;
12523 static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 12909 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12524 12910
12525 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 12911 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
@@ -12536,22 +12922,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12536 12922
12537 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 12923 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12538 12924
12539 if (spec->autocfg.dig_out_pin) 12925 if (spec->autocfg.dig_outs)
12540 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; 12926 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12541 12927
12542 if (spec->kctls.list) 12928 if (spec->kctls.list)
12543 add_mixer(spec, spec->kctls.list); 12929 add_mixer(spec, spec->kctls.list);
12544 12930
12545 /* create a beep mixer control if the pin 0x1d isn't assigned */
12546 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12547 if (spec->autocfg.input_pins[i] == 0x1d)
12548 break;
12549 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12550 add_mixer(spec, alc269_beep_mixer);
12551
12552 add_verb(spec, alc269_init_verbs); 12931 add_verb(spec, alc269_init_verbs);
12553 spec->num_mux_defs = 1; 12932 spec->num_mux_defs = 1;
12554 spec->input_mux = &spec->private_imux; 12933 spec->input_mux = &spec->private_imux[0];
12555 /* set default input source */ 12934 /* set default input source */
12556 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], 12935 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12557 0, AC_VERB_SET_CONNECT_SEL, 12936 0, AC_VERB_SET_CONNECT_SEL,
@@ -12561,10 +12940,9 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12561 if (err < 0) 12940 if (err < 0)
12562 return err; 12941 return err;
12563 12942
12564 if (!spec->cap_mixer) 12943 if (!spec->cap_mixer && !spec->no_analog)
12565 set_capture_mixer(spec); 12944 set_capture_mixer(spec);
12566 12945
12567 store_pin_configs(codec);
12568 return 1; 12946 return 1;
12569} 12947}
12570 12948
@@ -12600,10 +12978,17 @@ static struct snd_pci_quirk alc269_cfg_tbl[] = {
12600 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), 12978 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
12601 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", 12979 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12602 ALC269_ASUS_EEEPC_P703), 12980 ALC269_ASUS_EEEPC_P703),
12981 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12982 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12983 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12984 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12985 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12986 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
12603 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", 12987 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12604 ALC269_ASUS_EEEPC_P901), 12988 ALC269_ASUS_EEEPC_P901),
12605 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", 12989 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12606 ALC269_ASUS_EEEPC_P901), 12990 ALC269_ASUS_EEEPC_P901),
12991 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
12607 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), 12992 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
12608 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), 12993 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
12609 {} 12994 {}
@@ -12661,7 +13046,7 @@ static struct alc_config_preset alc269_presets[] = {
12661 .init_hook = alc269_eeepc_dmic_inithook, 13046 .init_hook = alc269_eeepc_dmic_inithook,
12662 }, 13047 },
12663 [ALC269_FUJITSU] = { 13048 [ALC269_FUJITSU] = {
12664 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer }, 13049 .mixers = { alc269_fujitsu_mixer },
12665 .cap_mixer = alc269_epc_capture_mixer, 13050 .cap_mixer = alc269_epc_capture_mixer,
12666 .init_verbs = { alc269_init_verbs, 13051 .init_verbs = { alc269_init_verbs,
12667 alc269_eeepc_dmic_init_verbs }, 13052 alc269_eeepc_dmic_init_verbs },
@@ -12726,13 +13111,26 @@ static int patch_alc269(struct hda_codec *codec)
12726 } 13111 }
12727 } 13112 }
12728 13113
13114 err = snd_hda_attach_beep_device(codec, 0x1);
13115 if (err < 0) {
13116 alc_free(codec);
13117 return err;
13118 }
13119
12729 if (board_config != ALC269_AUTO) 13120 if (board_config != ALC269_AUTO)
12730 setup_preset(spec, &alc269_presets[board_config]); 13121 setup_preset(spec, &alc269_presets[board_config]);
12731 13122
12732 spec->stream_name_analog = "ALC269 Analog"; 13123 spec->stream_name_analog = "ALC269 Analog";
12733 spec->stream_analog_playback = &alc269_pcm_analog_playback; 13124 if (codec->subsystem_id == 0x17aa3bf8) {
12734 spec->stream_analog_capture = &alc269_pcm_analog_capture; 13125 /* Due to a hardware problem on Lenovo Ideadpad, we need to
12735 13126 * fix the sample rate of analog I/O to 44.1kHz
13127 */
13128 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13129 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13130 } else {
13131 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13132 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13133 }
12736 spec->stream_name_digital = "ALC269 Digital"; 13134 spec->stream_name_digital = "ALC269 Digital";
12737 spec->stream_digital_playback = &alc269_pcm_digital_playback; 13135 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12738 spec->stream_digital_capture = &alc269_pcm_digital_capture; 13136 spec->stream_digital_capture = &alc269_pcm_digital_capture;
@@ -12742,6 +13140,7 @@ static int patch_alc269(struct hda_codec *codec)
12742 spec->capsrc_nids = alc269_capsrc_nids; 13140 spec->capsrc_nids = alc269_capsrc_nids;
12743 if (!spec->cap_mixer) 13141 if (!spec->cap_mixer)
12744 set_capture_mixer(spec); 13142 set_capture_mixer(spec);
13143 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
12745 13144
12746 codec->patch_ops = alc_patch_ops; 13145 codec->patch_ops = alc_patch_ops;
12747 if (board_config == ALC269_AUTO) 13146 if (board_config == ALC269_AUTO)
@@ -12992,8 +13391,6 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
12992static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { 13391static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
12993 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 13392 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12994 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 13393 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12995 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12996 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12997 { } 13394 { }
12998}; 13395};
12999 13396
@@ -13467,7 +13864,7 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13467static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 13864static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13468 const struct auto_pin_cfg *cfg) 13865 const struct auto_pin_cfg *cfg)
13469{ 13866{
13470 struct hda_input_mux *imux = &spec->private_imux; 13867 struct hda_input_mux *imux = &spec->private_imux[0];
13471 int i, err, idx, idx1; 13868 int i, err, idx, idx1;
13472 13869
13473 for (i = 0; i < AUTO_PIN_LAST; i++) { 13870 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -13554,12 +13951,8 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
13554 13951
13555 for (i = 0; i < AUTO_PIN_LAST; i++) { 13952 for (i = 0; i < AUTO_PIN_LAST; i++) {
13556 hda_nid_t nid = spec->autocfg.input_pins[i]; 13953 hda_nid_t nid = spec->autocfg.input_pins[i];
13557 if (nid >= 0x0c && nid <= 0x11) { 13954 if (nid >= 0x0c && nid <= 0x11)
13558 snd_hda_codec_write(codec, nid, 0, 13955 alc_set_input_pin(codec, nid, i);
13559 AC_VERB_SET_PIN_WIDGET_CONTROL,
13560 i <= AUTO_PIN_FRONT_MIC ?
13561 PIN_VREF80 : PIN_IN);
13562 }
13563 } 13956 }
13564} 13957}
13565 13958
@@ -13595,7 +13988,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13595 13988
13596 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 13989 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13597 13990
13598 if (spec->autocfg.dig_out_pin) 13991 if (spec->autocfg.dig_outs)
13599 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 13992 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13600 13993
13601 if (spec->kctls.list) 13994 if (spec->kctls.list)
@@ -13604,13 +13997,12 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13604 add_verb(spec, alc861_auto_init_verbs); 13997 add_verb(spec, alc861_auto_init_verbs);
13605 13998
13606 spec->num_mux_defs = 1; 13999 spec->num_mux_defs = 1;
13607 spec->input_mux = &spec->private_imux; 14000 spec->input_mux = &spec->private_imux[0];
13608 14001
13609 spec->adc_nids = alc861_adc_nids; 14002 spec->adc_nids = alc861_adc_nids;
13610 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 14003 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13611 set_capture_mixer(spec); 14004 set_capture_mixer(spec);
13612 14005
13613 store_pin_configs(codec);
13614 return 1; 14006 return 1;
13615} 14007}
13616 14008
@@ -13819,6 +14211,12 @@ static int patch_alc861(struct hda_codec *codec)
13819 } 14211 }
13820 } 14212 }
13821 14213
14214 err = snd_hda_attach_beep_device(codec, 0x23);
14215 if (err < 0) {
14216 alc_free(codec);
14217 return err;
14218 }
14219
13822 if (board_config != ALC861_AUTO) 14220 if (board_config != ALC861_AUTO)
13823 setup_preset(spec, &alc861_presets[board_config]); 14221 setup_preset(spec, &alc861_presets[board_config]);
13824 14222
@@ -13830,6 +14228,8 @@ static int patch_alc861(struct hda_codec *codec)
13830 spec->stream_digital_playback = &alc861_pcm_digital_playback; 14228 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13831 spec->stream_digital_capture = &alc861_pcm_digital_capture; 14229 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13832 14230
14231 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14232
13833 spec->vmaster_nid = 0x03; 14233 spec->vmaster_nid = 0x03;
13834 14234
13835 codec->patch_ops = alc_patch_ops; 14235 codec->patch_ops = alc_patch_ops;
@@ -13986,9 +14386,6 @@ static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14387 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13988 14388
13989 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13990 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13991
13992 { } /* end */ 14389 { } /* end */
13993}; 14390};
13994 14391
@@ -14012,9 +14409,6 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14409 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14013 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14410 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14014 14411
14015 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14016 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14017
14018 { } /* end */ 14412 { } /* end */
14019}; 14413};
14020 14414
@@ -14053,8 +14447,6 @@ static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14053 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 14447 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14054 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14448 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14055 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14449 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14056 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14057 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
14058 { } /* end */ 14450 { } /* end */
14059}; 14451};
14060 14452
@@ -14365,9 +14757,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
14365 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 14757 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
14366 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 14758 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
14367 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 14759 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
14368 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 14760 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
14369 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
14370 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
14371 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), 14761 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
14372 {} 14762 {}
14373}; 14763};
@@ -14529,11 +14919,9 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14529 for (i = 0; i < AUTO_PIN_LAST; i++) { 14919 for (i = 0; i < AUTO_PIN_LAST; i++) {
14530 hda_nid_t nid = spec->autocfg.input_pins[i]; 14920 hda_nid_t nid = spec->autocfg.input_pins[i];
14531 if (alc861vd_is_input_pin(nid)) { 14921 if (alc861vd_is_input_pin(nid)) {
14532 snd_hda_codec_write(codec, nid, 0, 14922 alc_set_input_pin(codec, nid, i);
14533 AC_VERB_SET_PIN_WIDGET_CONTROL, 14923 if (nid != ALC861VD_PIN_CD_NID &&
14534 i <= AUTO_PIN_FRONT_MIC ? 14924 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
14535 PIN_VREF80 : PIN_IN);
14536 if (nid != ALC861VD_PIN_CD_NID)
14537 snd_hda_codec_write(codec, nid, 0, 14925 snd_hda_codec_write(codec, nid, 0,
14538 AC_VERB_SET_AMP_GAIN_MUTE, 14926 AC_VERB_SET_AMP_GAIN_MUTE,
14539 AMP_OUT_MUTE); 14927 AMP_OUT_MUTE);
@@ -14699,7 +15087,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14699 15087
14700 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 15088 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14701 15089
14702 if (spec->autocfg.dig_out_pin) 15090 if (spec->autocfg.dig_outs)
14703 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; 15091 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14704 15092
14705 if (spec->kctls.list) 15093 if (spec->kctls.list)
@@ -14708,13 +15096,12 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14708 add_verb(spec, alc861vd_volume_init_verbs); 15096 add_verb(spec, alc861vd_volume_init_verbs);
14709 15097
14710 spec->num_mux_defs = 1; 15098 spec->num_mux_defs = 1;
14711 spec->input_mux = &spec->private_imux; 15099 spec->input_mux = &spec->private_imux[0];
14712 15100
14713 err = alc_auto_add_mic_boost(codec); 15101 err = alc_auto_add_mic_boost(codec);
14714 if (err < 0) 15102 if (err < 0)
14715 return err; 15103 return err;
14716 15104
14717 store_pin_configs(codec);
14718 return 1; 15105 return 1;
14719} 15106}
14720 15107
@@ -14765,6 +15152,12 @@ static int patch_alc861vd(struct hda_codec *codec)
14765 } 15152 }
14766 } 15153 }
14767 15154
15155 err = snd_hda_attach_beep_device(codec, 0x23);
15156 if (err < 0) {
15157 alc_free(codec);
15158 return err;
15159 }
15160
14768 if (board_config != ALC861VD_AUTO) 15161 if (board_config != ALC861VD_AUTO)
14769 setup_preset(spec, &alc861vd_presets[board_config]); 15162 setup_preset(spec, &alc861vd_presets[board_config]);
14770 15163
@@ -14787,9 +15180,10 @@ static int patch_alc861vd(struct hda_codec *codec)
14787 spec->adc_nids = alc861vd_adc_nids; 15180 spec->adc_nids = alc861vd_adc_nids;
14788 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 15181 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
14789 spec->capsrc_nids = alc861vd_capsrc_nids; 15182 spec->capsrc_nids = alc861vd_capsrc_nids;
14790 spec->is_mix_capture = 1; 15183 spec->capture_style = CAPT_MIX;
14791 15184
14792 set_capture_mixer(spec); 15185 set_capture_mixer(spec);
15186 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
14793 15187
14794 spec->vmaster_nid = 0x02; 15188 spec->vmaster_nid = 0x02;
14795 15189
@@ -14825,12 +15219,23 @@ static hda_nid_t alc662_dac_nids[4] = {
14825 0x02, 0x03, 0x04 15219 0x02, 0x03, 0x04
14826}; 15220};
14827 15221
15222static hda_nid_t alc272_dac_nids[2] = {
15223 0x02, 0x03
15224};
15225
14828static hda_nid_t alc662_adc_nids[1] = { 15226static hda_nid_t alc662_adc_nids[1] = {
14829 /* ADC1-2 */ 15227 /* ADC1-2 */
14830 0x09, 15228 0x09,
14831}; 15229};
14832 15230
15231static hda_nid_t alc272_adc_nids[1] = {
15232 /* ADC1-2 */
15233 0x08,
15234};
15235
14833static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; 15236static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
15237static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15238
14834 15239
14835/* input MUX */ 15240/* input MUX */
14836/* FIXME: should be a matrix-type input source selection */ 15241/* FIXME: should be a matrix-type input source selection */
@@ -14978,8 +15383,6 @@ static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 15383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14981 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14982 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14983 { } /* end */ 15386 { } /* end */
14984}; 15387};
14985 15388
@@ -15001,8 +15404,6 @@ static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 15404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15004 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15005 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
15006 { } /* end */ 15407 { } /* end */
15007}; 15408};
15008 15409
@@ -15260,14 +15661,7 @@ static struct hda_verb alc662_init_verbs[] = {
15260 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 15661 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15261 /* Input mixer */ 15662 /* Input mixer */
15262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15266
15267 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 15664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15271 15665
15272 /* always trun on EAPD */ 15666 /* always trun on EAPD */
15273 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 15667 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
@@ -15462,12 +15856,48 @@ static struct hda_verb alc662_ecs_init_verbs[] = {
15462 {} 15856 {}
15463}; 15857};
15464 15858
15859static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15860 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15861 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15864 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15865 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15866 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15870 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15871 {}
15872};
15873
15874static struct hda_verb alc272_dell_init_verbs[] = {
15875 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15876 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15878 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15879 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15880 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15881 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15884 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15885 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15886 {}
15887};
15888
15465static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { 15889static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15466 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 15890 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15467 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 15891 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15468 { } /* end */ 15892 { } /* end */
15469}; 15893};
15470 15894
15895static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15896 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15897 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15898 { } /* end */
15899};
15900
15471static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) 15901static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15472{ 15902{
15473 unsigned int present; 15903 unsigned int present;
@@ -15978,56 +16408,68 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
15978}; 16408};
15979 16409
15980static struct snd_pci_quirk alc662_cfg_tbl[] = { 16410static struct snd_pci_quirk alc662_cfg_tbl[] = {
15981 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 16411 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15982 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), 16412 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
15983 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), 16413 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
15984 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
15985 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
15986 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15987 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15988 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), 16414 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15989 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), 16415 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15990 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), 16416 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15991 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15992 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), 16417 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16418 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15993 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), 16419 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15994 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15995 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
15996 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15997 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), 16420 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15998 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), 16421 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15999 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), 16422 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16423 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16424 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16425 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16426 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16427 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16428 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
16000 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), 16429 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16001 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), 16430 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16002 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), 16431 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16432 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16433 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
16003 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), 16434 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16004 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), 16435 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16005 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), 16436 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16006 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), 16437 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16007 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16008 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), 16438 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16009 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16010 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16011 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), 16439 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16012 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), 16440 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16441 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16442 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
16443 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16444 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16445 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16446 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
16447 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16448 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16449 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
16450 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16451 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16452 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16453 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16454 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16455 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
16456 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16013 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), 16457 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16014 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), 16458 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16015 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), 16459 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16016 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), 16460 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16017 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), 16461 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16018 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 16462 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16019 ALC662_3ST_6ch_DIG), 16463 ALC662_3ST_6ch_DIG),
16020 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16021 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16022 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16023 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 16464 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16024 ALC662_3ST_6ch_DIG), 16465 ALC662_3ST_6ch_DIG),
16025 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), 16466 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16467 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
16468 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16026 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", 16469 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16027 ALC662_3ST_6ch_DIG), 16470 ALC662_3ST_6ch_DIG),
16028 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), 16471 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16029 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), 16472 ALC663_ASUS_H13),
16030 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
16031 {} 16473 {}
16032}; 16474};
16033 16475
@@ -16260,6 +16702,36 @@ static struct alc_config_preset alc662_presets[] = {
16260 .unsol_event = alc663_mode6_unsol_event, 16702 .unsol_event = alc663_mode6_unsol_event,
16261 .init_hook = alc663_mode6_inithook, 16703 .init_hook = alc663_mode6_inithook,
16262 }, 16704 },
16705 [ALC272_DELL] = {
16706 .mixers = { alc663_m51va_mixer },
16707 .cap_mixer = alc272_auto_capture_mixer,
16708 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16709 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16710 .dac_nids = alc662_dac_nids,
16711 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16712 .adc_nids = alc272_adc_nids,
16713 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16714 .capsrc_nids = alc272_capsrc_nids,
16715 .channel_mode = alc662_3ST_2ch_modes,
16716 .input_mux = &alc663_m51va_capture_source,
16717 .unsol_event = alc663_m51va_unsol_event,
16718 .init_hook = alc663_m51va_inithook,
16719 },
16720 [ALC272_DELL_ZM1] = {
16721 .mixers = { alc663_m51va_mixer },
16722 .cap_mixer = alc662_auto_capture_mixer,
16723 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16724 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16725 .dac_nids = alc662_dac_nids,
16726 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16727 .adc_nids = alc662_adc_nids,
16728 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16729 .capsrc_nids = alc662_capsrc_nids,
16730 .channel_mode = alc662_3ST_2ch_modes,
16731 .input_mux = &alc663_m51va_capture_source,
16732 .unsol_event = alc663_m51va_unsol_event,
16733 .init_hook = alc663_m51va_inithook,
16734 },
16263}; 16735};
16264 16736
16265 16737
@@ -16347,7 +16819,7 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16347 16819
16348 if (alc880_is_fixed_pin(pin)) { 16820 if (alc880_is_fixed_pin(pin)) {
16349 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 16821 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16350 /* printk("DAC nid=%x\n",nid); */ 16822 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
16351 /* specify the DAC as the extra output */ 16823 /* specify the DAC as the extra output */
16352 if (!spec->multiout.hp_nid) 16824 if (!spec->multiout.hp_nid)
16353 spec->multiout.hp_nid = nid; 16825 spec->multiout.hp_nid = nid;
@@ -16377,26 +16849,58 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16377 return 0; 16849 return 0;
16378} 16850}
16379 16851
16852/* return the index of the src widget from the connection list of the nid.
16853 * return -1 if not found
16854 */
16855static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16856 hda_nid_t src)
16857{
16858 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16859 int i, conns;
16860
16861 conns = snd_hda_get_connections(codec, nid, conn_list,
16862 ARRAY_SIZE(conn_list));
16863 if (conns < 0)
16864 return -1;
16865 for (i = 0; i < conns; i++)
16866 if (conn_list[i] == src)
16867 return i;
16868 return -1;
16869}
16870
16871static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16872{
16873 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
16874 return (pincap & AC_PINCAP_IN) != 0;
16875}
16876
16380/* create playback/capture controls for input pins */ 16877/* create playback/capture controls for input pins */
16381static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, 16878static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
16382 const struct auto_pin_cfg *cfg) 16879 const struct auto_pin_cfg *cfg)
16383{ 16880{
16384 struct hda_input_mux *imux = &spec->private_imux; 16881 struct alc_spec *spec = codec->spec;
16882 struct hda_input_mux *imux = &spec->private_imux[0];
16385 int i, err, idx; 16883 int i, err, idx;
16386 16884
16387 for (i = 0; i < AUTO_PIN_LAST; i++) { 16885 for (i = 0; i < AUTO_PIN_LAST; i++) {
16388 if (alc880_is_input_pin(cfg->input_pins[i])) { 16886 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16389 idx = alc880_input_pin_idx(cfg->input_pins[i]); 16887 idx = alc662_input_pin_idx(codec, 0x0b,
16390 err = new_analog_input(spec, cfg->input_pins[i], 16888 cfg->input_pins[i]);
16391 auto_pin_cfg_labels[i], 16889 if (idx >= 0) {
16392 idx, 0x0b); 16890 err = new_analog_input(spec, cfg->input_pins[i],
16393 if (err < 0) 16891 auto_pin_cfg_labels[i],
16394 return err; 16892 idx, 0x0b);
16395 imux->items[imux->num_items].label = 16893 if (err < 0)
16396 auto_pin_cfg_labels[i]; 16894 return err;
16397 imux->items[imux->num_items].index = 16895 }
16398 alc880_input_pin_idx(cfg->input_pins[i]); 16896 idx = alc662_input_pin_idx(codec, 0x22,
16399 imux->num_items++; 16897 cfg->input_pins[i]);
16898 if (idx >= 0) {
16899 imux->items[imux->num_items].label =
16900 auto_pin_cfg_labels[i];
16901 imux->items[imux->num_items].index = idx;
16902 imux->num_items++;
16903 }
16400 } 16904 }
16401 } 16905 }
16402 return 0; 16906 return 0;
@@ -16446,7 +16950,6 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec)
16446 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 16950 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
16447} 16951}
16448 16952
16449#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16450#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID 16953#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16451 16954
16452static void alc662_auto_init_analog_input(struct hda_codec *codec) 16955static void alc662_auto_init_analog_input(struct hda_codec *codec)
@@ -16456,12 +16959,10 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)
16456 16959
16457 for (i = 0; i < AUTO_PIN_LAST; i++) { 16960 for (i = 0; i < AUTO_PIN_LAST; i++) {
16458 hda_nid_t nid = spec->autocfg.input_pins[i]; 16961 hda_nid_t nid = spec->autocfg.input_pins[i];
16459 if (alc662_is_input_pin(nid)) { 16962 if (alc662_is_input_pin(codec, nid)) {
16460 snd_hda_codec_write(codec, nid, 0, 16963 alc_set_input_pin(codec, nid, i);
16461 AC_VERB_SET_PIN_WIDGET_CONTROL, 16964 if (nid != ALC662_PIN_CD_NID &&
16462 (i <= AUTO_PIN_FRONT_MIC ? 16965 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
16463 PIN_VREF80 : PIN_IN));
16464 if (nid != ALC662_PIN_CD_NID)
16465 snd_hda_codec_write(codec, nid, 0, 16966 snd_hda_codec_write(codec, nid, 0,
16466 AC_VERB_SET_AMP_GAIN_MUTE, 16967 AC_VERB_SET_AMP_GAIN_MUTE,
16467 AMP_OUT_MUTE); 16968 AMP_OUT_MUTE);
@@ -16499,20 +17000,20 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16499 "Headphone"); 17000 "Headphone");
16500 if (err < 0) 17001 if (err < 0)
16501 return err; 17002 return err;
16502 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); 17003 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
16503 if (err < 0) 17004 if (err < 0)
16504 return err; 17005 return err;
16505 17006
16506 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 17007 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16507 17008
16508 if (spec->autocfg.dig_out_pin) 17009 if (spec->autocfg.dig_outs)
16509 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 17010 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16510 17011
16511 if (spec->kctls.list) 17012 if (spec->kctls.list)
16512 add_mixer(spec, spec->kctls.list); 17013 add_mixer(spec, spec->kctls.list);
16513 17014
16514 spec->num_mux_defs = 1; 17015 spec->num_mux_defs = 1;
16515 spec->input_mux = &spec->private_imux; 17016 spec->input_mux = &spec->private_imux[0];
16516 17017
16517 add_verb(spec, alc662_auto_init_verbs); 17018 add_verb(spec, alc662_auto_init_verbs);
16518 if (codec->vendor_id == 0x10ec0663) 17019 if (codec->vendor_id == 0x10ec0663)
@@ -16522,7 +17023,6 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16522 if (err < 0) 17023 if (err < 0)
16523 return err; 17024 return err;
16524 17025
16525 store_pin_configs(codec);
16526 return 1; 17026 return 1;
16527} 17027}
16528 17028
@@ -16574,6 +17074,12 @@ static int patch_alc662(struct hda_codec *codec)
16574 } 17074 }
16575 } 17075 }
16576 17076
17077 err = snd_hda_attach_beep_device(codec, 0x1);
17078 if (err < 0) {
17079 alc_free(codec);
17080 return err;
17081 }
17082
16577 if (board_config != ALC662_AUTO) 17083 if (board_config != ALC662_AUTO)
16578 setup_preset(spec, &alc662_presets[board_config]); 17084 setup_preset(spec, &alc662_presets[board_config]);
16579 17085
@@ -16597,10 +17103,14 @@ static int patch_alc662(struct hda_codec *codec)
16597 spec->adc_nids = alc662_adc_nids; 17103 spec->adc_nids = alc662_adc_nids;
16598 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 17104 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16599 spec->capsrc_nids = alc662_capsrc_nids; 17105 spec->capsrc_nids = alc662_capsrc_nids;
16600 spec->is_mix_capture = 1; 17106 spec->capture_style = CAPT_MIX;
16601 17107
16602 if (!spec->cap_mixer) 17108 if (!spec->cap_mixer)
16603 set_capture_mixer(spec); 17109 set_capture_mixer(spec);
17110 if (codec->vendor_id == 0x10ec0662)
17111 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17112 else
17113 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
16604 17114
16605 spec->vmaster_nid = 0x02; 17115 spec->vmaster_nid = 0x02;
16606 17116
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 35b83dc6e19e..917bc5d3ac2c 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -43,6 +43,7 @@ enum {
43}; 43};
44 44
45enum { 45enum {
46 STAC_AUTO,
46 STAC_REF, 47 STAC_REF,
47 STAC_9200_OQO, 48 STAC_9200_OQO,
48 STAC_9200_DELL_D21, 49 STAC_9200_DELL_D21,
@@ -55,20 +56,24 @@ enum {
55 STAC_9200_DELL_M25, 56 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26, 57 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27, 58 STAC_9200_DELL_M27,
58 STAC_9200_GATEWAY, 59 STAC_9200_M4,
60 STAC_9200_M4_2,
59 STAC_9200_PANASONIC, 61 STAC_9200_PANASONIC,
60 STAC_9200_MODELS 62 STAC_9200_MODELS
61}; 63};
62 64
63enum { 65enum {
66 STAC_9205_AUTO,
64 STAC_9205_REF, 67 STAC_9205_REF,
65 STAC_9205_DELL_M42, 68 STAC_9205_DELL_M42,
66 STAC_9205_DELL_M43, 69 STAC_9205_DELL_M43,
67 STAC_9205_DELL_M44, 70 STAC_9205_DELL_M44,
71 STAC_9205_EAPD,
68 STAC_9205_MODELS 72 STAC_9205_MODELS
69}; 73};
70 74
71enum { 75enum {
76 STAC_92HD73XX_AUTO,
72 STAC_92HD73XX_NO_JD, /* no jack-detection */ 77 STAC_92HD73XX_NO_JD, /* no jack-detection */
73 STAC_92HD73XX_REF, 78 STAC_92HD73XX_REF,
74 STAC_DELL_M6_AMIC, 79 STAC_DELL_M6_AMIC,
@@ -79,28 +84,40 @@ enum {
79}; 84};
80 85
81enum { 86enum {
87 STAC_92HD83XXX_AUTO,
82 STAC_92HD83XXX_REF, 88 STAC_92HD83XXX_REF,
89 STAC_92HD83XXX_PWR_REF,
90 STAC_DELL_S14,
83 STAC_92HD83XXX_MODELS 91 STAC_92HD83XXX_MODELS
84}; 92};
85 93
86enum { 94enum {
95 STAC_92HD71BXX_AUTO,
87 STAC_92HD71BXX_REF, 96 STAC_92HD71BXX_REF,
88 STAC_DELL_M4_1, 97 STAC_DELL_M4_1,
89 STAC_DELL_M4_2, 98 STAC_DELL_M4_2,
90 STAC_DELL_M4_3, 99 STAC_DELL_M4_3,
91 STAC_HP_M4, 100 STAC_HP_M4,
101 STAC_HP_DV5,
102 STAC_HP_HDX,
92 STAC_92HD71BXX_MODELS 103 STAC_92HD71BXX_MODELS
93}; 104};
94 105
95enum { 106enum {
107 STAC_925x_AUTO,
96 STAC_925x_REF, 108 STAC_925x_REF,
109 STAC_M1,
110 STAC_M1_2,
111 STAC_M2,
97 STAC_M2_2, 112 STAC_M2_2,
98 STAC_MA6, 113 STAC_M3,
99 STAC_PA6, 114 STAC_M5,
115 STAC_M6,
100 STAC_925x_MODELS 116 STAC_925x_MODELS
101}; 117};
102 118
103enum { 119enum {
120 STAC_922X_AUTO,
104 STAC_D945_REF, 121 STAC_D945_REF,
105 STAC_D945GTP3, 122 STAC_D945GTP3,
106 STAC_D945GTP5, 123 STAC_D945GTP5,
@@ -128,6 +145,7 @@ enum {
128}; 145};
129 146
130enum { 147enum {
148 STAC_927X_AUTO,
131 STAC_D965_REF_NO_JD, /* no jack-detection */ 149 STAC_D965_REF_NO_JD, /* no jack-detection */
132 STAC_D965_REF, 150 STAC_D965_REF,
133 STAC_D965_3ST, 151 STAC_D965_3ST,
@@ -137,6 +155,12 @@ enum {
137 STAC_927X_MODELS 155 STAC_927X_MODELS
138}; 156};
139 157
158enum {
159 STAC_9872_AUTO,
160 STAC_9872_VAIO,
161 STAC_9872_MODELS
162};
163
140struct sigmatel_event { 164struct sigmatel_event {
141 hda_nid_t nid; 165 hda_nid_t nid;
142 unsigned char type; 166 unsigned char type;
@@ -160,6 +184,7 @@ struct sigmatel_spec {
160 unsigned int alt_switch: 1; 184 unsigned int alt_switch: 1;
161 unsigned int hp_detect: 1; 185 unsigned int hp_detect: 1;
162 unsigned int spdif_mute: 1; 186 unsigned int spdif_mute: 1;
187 unsigned int check_volume_offset:1;
163 188
164 /* gpio lines */ 189 /* gpio lines */
165 unsigned int eapd_mask; 190 unsigned int eapd_mask;
@@ -172,6 +197,7 @@ struct sigmatel_spec {
172 unsigned int stream_delay; 197 unsigned int stream_delay;
173 198
174 /* analog loopback */ 199 /* analog loopback */
200 struct snd_kcontrol_new *aloopback_ctl;
175 unsigned char aloopback_mask; 201 unsigned char aloopback_mask;
176 unsigned char aloopback_shift; 202 unsigned char aloopback_shift;
177 203
@@ -196,6 +222,8 @@ struct sigmatel_spec {
196 hda_nid_t hp_dacs[5]; 222 hda_nid_t hp_dacs[5];
197 hda_nid_t speaker_dacs[5]; 223 hda_nid_t speaker_dacs[5];
198 224
225 int volume_offset;
226
199 /* capture */ 227 /* capture */
200 hda_nid_t *adc_nids; 228 hda_nid_t *adc_nids;
201 unsigned int num_adcs; 229 unsigned int num_adcs;
@@ -217,7 +245,6 @@ struct sigmatel_spec {
217 /* pin widgets */ 245 /* pin widgets */
218 hda_nid_t *pin_nids; 246 hda_nid_t *pin_nids;
219 unsigned int num_pins; 247 unsigned int num_pins;
220 unsigned int *pin_configs;
221 248
222 /* codec specific stuff */ 249 /* codec specific stuff */
223 struct hda_verb *init; 250 struct hda_verb *init;
@@ -328,7 +355,11 @@ static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
328}; 355};
329 356
330static unsigned int stac92hd83xxx_pwr_mapping[4] = { 357static unsigned int stac92hd83xxx_pwr_mapping[4] = {
331 0x03, 0x0c, 0x10, 0x40, 358 0x03, 0x0c, 0x20, 0x40,
359};
360
361static hda_nid_t stac92hd83xxx_amp_nids[1] = {
362 0xc,
332}; 363};
333 364
334static hda_nid_t stac92hd71bxx_pwr_nids[3] = { 365static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
@@ -389,6 +420,10 @@ static hda_nid_t stac922x_mux_nids[2] = {
389 0x12, 0x13, 420 0x12, 0x13,
390}; 421};
391 422
423static hda_nid_t stac927x_slave_dig_outs[2] = {
424 0x1f, 0,
425};
426
392static hda_nid_t stac927x_adc_nids[3] = { 427static hda_nid_t stac927x_adc_nids[3] = {
393 0x07, 0x08, 0x09 428 0x07, 0x08, 0x09
394}; 429};
@@ -461,15 +496,21 @@ static hda_nid_t stac92hd73xx_pin_nids[13] = {
461 0x14, 0x22, 0x23 496 0x14, 0x22, 0x23
462}; 497};
463 498
464static hda_nid_t stac92hd83xxx_pin_nids[14] = { 499static hda_nid_t stac92hd83xxx_pin_nids[10] = {
465 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 500 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
466 0x0f, 0x10, 0x11, 0x12, 0x13, 501 0x0f, 0x10, 0x11, 0x1f, 0x20,
467 0x1d, 0x1e, 0x1f, 0x20
468}; 502};
469static hda_nid_t stac92hd71bxx_pin_nids[11] = { 503
504#define STAC92HD71BXX_NUM_PINS 13
505static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
506 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
507 0x00, 0x14, 0x18, 0x19, 0x1e,
508 0x1f, 0x20, 0x27
509};
510static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
470 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 511 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
471 0x0f, 0x14, 0x18, 0x19, 0x1e, 512 0x0f, 0x14, 0x18, 0x19, 0x1e,
472 0x1f, 513 0x1f, 0x20, 0x27
473}; 514};
474 515
475static hda_nid_t stac927x_pin_nids[14] = { 516static hda_nid_t stac927x_pin_nids[14] = {
@@ -831,13 +872,9 @@ static struct hda_verb stac92hd73xx_10ch_core_init[] = {
831}; 872};
832 873
833static struct hda_verb stac92hd83xxx_core_init[] = { 874static struct hda_verb stac92hd83xxx_core_init[] = {
834 /* start of config #1 */ 875 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
835 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3}, 876 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
836 877 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
837 /* start of config #2 */
838 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
839 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
840 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
841 878
842 /* power state controls amps */ 879 /* power state controls amps */
843 { 0x01, AC_VERB_SET_EAPD, 1 << 2}, 880 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
@@ -847,26 +884,25 @@ static struct hda_verb stac92hd83xxx_core_init[] = {
847static struct hda_verb stac92hd71bxx_core_init[] = { 884static struct hda_verb stac92hd71bxx_core_init[] = {
848 /* set master volume and direct control */ 885 /* set master volume and direct control */
849 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 886 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
850 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
851 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
852 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
853 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
854 {} 887 {}
855}; 888};
856 889
857#define HD_DISABLE_PORTF 2 890#define HD_DISABLE_PORTF 1
858static struct hda_verb stac92hd71bxx_analog_core_init[] = { 891static struct hda_verb stac92hd71bxx_analog_core_init[] = {
859 /* start of config #1 */ 892 /* start of config #1 */
860 893
861 /* connect port 0f to audio mixer */ 894 /* connect port 0f to audio mixer */
862 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, 895 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
863 /* unmute right and left channels for node 0x0f */
864 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 /* start of config #2 */ 896 /* start of config #2 */
866 897
867 /* set master volume and direct control */ 898 /* set master volume and direct control */
868 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 899 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
869 /* unmute right and left channels for nodes 0x0a, 0xd */ 900 {}
901};
902
903static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
904 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
905 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 906 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
871 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 907 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 {} 908 {}
@@ -875,6 +911,8 @@ static struct hda_verb stac92hd71bxx_analog_core_init[] = {
875static struct hda_verb stac925x_core_init[] = { 911static struct hda_verb stac925x_core_init[] = {
876 /* set dac0mux for dac converter */ 912 /* set dac0mux for dac converter */
877 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, 913 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
914 /* mute the master volume */
915 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
878 {} 916 {}
879}; 917};
880 918
@@ -945,16 +983,6 @@ static struct hda_verb stac9205_core_init[] = {
945 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ 983 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
946 } 984 }
947 985
948#define STAC_INPUT_SOURCE(cnt) \
949 { \
950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
951 .name = "Input Source", \
952 .count = cnt, \
953 .info = stac92xx_mux_enum_info, \
954 .get = stac92xx_mux_enum_get, \
955 .put = stac92xx_mux_enum_put, \
956 }
957
958#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ 986#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
959 { \ 987 { \
960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -969,7 +997,6 @@ static struct hda_verb stac9205_core_init[] = {
969static struct snd_kcontrol_new stac9200_mixer[] = { 997static struct snd_kcontrol_new stac9200_mixer[] = {
970 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 998 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
971 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 999 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
972 STAC_INPUT_SOURCE(1),
973 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 1000 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
974 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), 1001 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
975 { } /* end */ 1002 { } /* end */
@@ -994,8 +1021,6 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
994 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), 1021 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
995 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), 1022 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
996 1023
997 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
998
999 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1001 1026
@@ -1005,9 +1030,22 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1005 { } /* end */ 1030 { } /* end */
1006}; 1031};
1007 1032
1008static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { 1033static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1034 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1035 {}
1036};
1037
1038static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1009 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), 1039 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1040 {}
1041};
1042
1043static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1045 {}
1046};
1010 1047
1048static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1011 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1049 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1050 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 1051
@@ -1032,8 +1070,6 @@ static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1032}; 1070};
1033 1071
1034static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { 1072static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1035 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1036
1037 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1038 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1039 1075
@@ -1085,9 +1121,6 @@ static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1085}; 1121};
1086 1122
1087static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { 1123static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1088 STAC_INPUT_SOURCE(2),
1089 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1090
1091 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1093 1126
@@ -1113,10 +1146,11 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1113 { } /* end */ 1146 { } /* end */
1114}; 1147};
1115 1148
1116static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { 1149static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1117 STAC_INPUT_SOURCE(2), 1150 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1118 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), 1151};
1119 1152
1153static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1122 1156
@@ -1126,16 +1160,14 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1126}; 1160};
1127 1161
1128static struct snd_kcontrol_new stac925x_mixer[] = { 1162static struct snd_kcontrol_new stac925x_mixer[] = {
1129 STAC_INPUT_SOURCE(1), 1163 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1164 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), 1165 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), 1166 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1132 { } /* end */ 1167 { } /* end */
1133}; 1168};
1134 1169
1135static struct snd_kcontrol_new stac9205_mixer[] = { 1170static struct snd_kcontrol_new stac9205_mixer[] = {
1136 STAC_INPUT_SOURCE(2),
1137 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1138
1139 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), 1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1140 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), 1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1141 1173
@@ -1144,9 +1176,13 @@ static struct snd_kcontrol_new stac9205_mixer[] = {
1144 { } /* end */ 1176 { } /* end */
1145}; 1177};
1146 1178
1179static struct snd_kcontrol_new stac9205_loopback[] = {
1180 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1181 {}
1182};
1183
1147/* This needs to be generated dynamically based on sequence */ 1184/* This needs to be generated dynamically based on sequence */
1148static struct snd_kcontrol_new stac922x_mixer[] = { 1185static struct snd_kcontrol_new stac922x_mixer[] = {
1149 STAC_INPUT_SOURCE(2),
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), 1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), 1187 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1152 1188
@@ -1157,9 +1193,6 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
1157 1193
1158 1194
1159static struct snd_kcontrol_new stac927x_mixer[] = { 1195static struct snd_kcontrol_new stac927x_mixer[] = {
1160 STAC_INPUT_SOURCE(3),
1161 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1162
1163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), 1196 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), 1197 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1165 1198
@@ -1171,6 +1204,11 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
1171 { } /* end */ 1204 { } /* end */
1172}; 1205};
1173 1206
1207static struct snd_kcontrol_new stac927x_loopback[] = {
1208 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1209 {}
1210};
1211
1174static struct snd_kcontrol_new stac_dmux_mixer = { 1212static struct snd_kcontrol_new stac_dmux_mixer = {
1175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1176 .name = "Digital Input Source", 1214 .name = "Digital Input Source",
@@ -1196,10 +1234,7 @@ static const char *slave_vols[] = {
1196 "LFE Playback Volume", 1234 "LFE Playback Volume",
1197 "Side Playback Volume", 1235 "Side Playback Volume",
1198 "Headphone Playback Volume", 1236 "Headphone Playback Volume",
1199 "Headphone Playback Volume",
1200 "Speaker Playback Volume", 1237 "Speaker Playback Volume",
1201 "External Speaker Playback Volume",
1202 "Speaker2 Playback Volume",
1203 NULL 1238 NULL
1204}; 1239};
1205 1240
@@ -1210,10 +1245,7 @@ static const char *slave_sws[] = {
1210 "LFE Playback Switch", 1245 "LFE Playback Switch",
1211 "Side Playback Switch", 1246 "Side Playback Switch",
1212 "Headphone Playback Switch", 1247 "Headphone Playback Switch",
1213 "Headphone Playback Switch",
1214 "Speaker Playback Switch", 1248 "Speaker Playback Switch",
1215 "External Speaker Playback Switch",
1216 "Speaker2 Playback Switch",
1217 "IEC958 Playback Switch", 1249 "IEC958 Playback Switch",
1218 NULL 1250 NULL
1219}; 1251};
@@ -1283,6 +1315,8 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1283 unsigned int vmaster_tlv[4]; 1315 unsigned int vmaster_tlv[4];
1284 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], 1316 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1285 HDA_OUTPUT, vmaster_tlv); 1317 HDA_OUTPUT, vmaster_tlv);
1318 /* correct volume offset */
1319 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1286 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1320 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1287 vmaster_tlv, slave_vols); 1321 vmaster_tlv, slave_vols);
1288 if (err < 0) 1322 if (err < 0)
@@ -1295,6 +1329,13 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1295 return err; 1329 return err;
1296 } 1330 }
1297 1331
1332 if (spec->aloopback_ctl &&
1333 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1334 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1335 if (err < 0)
1336 return err;
1337 }
1338
1298 stac92xx_free_kctls(codec); /* no longer needed */ 1339 stac92xx_free_kctls(codec); /* no longer needed */
1299 1340
1300 /* create jack input elements */ 1341 /* create jack input elements */
@@ -1334,7 +1375,16 @@ static unsigned int ref9200_pin_configs[8] = {
1334 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, 1375 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1335}; 1376};
1336 1377
1337/* 1378static unsigned int gateway9200_m4_pin_configs[8] = {
1379 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1380 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1381};
1382static unsigned int gateway9200_m4_2_pin_configs[8] = {
1383 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1384 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1385};
1386
1387/*
1338 STAC 9200 pin configs for 1388 STAC 9200 pin configs for
1339 102801A8 1389 102801A8
1340 102801DE 1390 102801DE
@@ -1464,10 +1514,13 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1464 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, 1514 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1465 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, 1515 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1466 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, 1516 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1517 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1518 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1467 [STAC_9200_PANASONIC] = ref9200_pin_configs, 1519 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1468}; 1520};
1469 1521
1470static const char *stac9200_models[STAC_9200_MODELS] = { 1522static const char *stac9200_models[STAC_9200_MODELS] = {
1523 [STAC_AUTO] = "auto",
1471 [STAC_REF] = "ref", 1524 [STAC_REF] = "ref",
1472 [STAC_9200_OQO] = "oqo", 1525 [STAC_9200_OQO] = "oqo",
1473 [STAC_9200_DELL_D21] = "dell-d21", 1526 [STAC_9200_DELL_D21] = "dell-d21",
@@ -1480,7 +1533,8 @@ static const char *stac9200_models[STAC_9200_MODELS] = {
1480 [STAC_9200_DELL_M25] = "dell-m25", 1533 [STAC_9200_DELL_M25] = "dell-m25",
1481 [STAC_9200_DELL_M26] = "dell-m26", 1534 [STAC_9200_DELL_M26] = "dell-m26",
1482 [STAC_9200_DELL_M27] = "dell-m27", 1535 [STAC_9200_DELL_M27] = "dell-m27",
1483 [STAC_9200_GATEWAY] = "gateway", 1536 [STAC_9200_M4] = "gateway-m4",
1537 [STAC_9200_M4_2] = "gateway-m4-2",
1484 [STAC_9200_PANASONIC] = "panasonic", 1538 [STAC_9200_PANASONIC] = "panasonic",
1485}; 1539};
1486 1540
@@ -1488,6 +1542,8 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1488 /* SigmaTel reference board */ 1542 /* SigmaTel reference board */
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1490 "DFI LanParty", STAC_REF), 1544 "DFI LanParty", STAC_REF),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1546 "DFI LanParty", STAC_REF),
1491 /* Dell laptops have BIOS problem */ 1547 /* Dell laptops have BIOS problem */
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, 1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1493 "unknown Dell", STAC_9200_DELL_D21), 1549 "unknown Dell", STAC_9200_DELL_D21),
@@ -1550,11 +1606,9 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1550 /* Panasonic */ 1606 /* Panasonic */
1551 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), 1607 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1552 /* Gateway machines needs EAPD to be set on resume */ 1608 /* Gateway machines needs EAPD to be set on resume */
1553 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), 1609 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1554 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", 1610 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1555 STAC_9200_GATEWAY), 1611 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1556 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1557 STAC_9200_GATEWAY),
1558 /* OQO Mobile */ 1612 /* OQO Mobile */
1559 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), 1613 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1560 {} /* terminator */ 1614 {} /* terminator */
@@ -1565,44 +1619,87 @@ static unsigned int ref925x_pin_configs[8] = {
1565 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, 1619 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1566}; 1620};
1567 1621
1568static unsigned int stac925x_MA6_pin_configs[8] = { 1622static unsigned int stac925xM1_pin_configs[8] = {
1569 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, 1623 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1570 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, 1624 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1571}; 1625};
1572 1626
1573static unsigned int stac925x_PA6_pin_configs[8] = { 1627static unsigned int stac925xM1_2_pin_configs[8] = {
1574 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, 1628 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1575 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e, 1629 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1630};
1631
1632static unsigned int stac925xM2_pin_configs[8] = {
1633 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1634 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1576}; 1635};
1577 1636
1578static unsigned int stac925xM2_2_pin_configs[8] = { 1637static unsigned int stac925xM2_2_pin_configs[8] = {
1579 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020, 1638 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1580 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e, 1639 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1640};
1641
1642static unsigned int stac925xM3_pin_configs[8] = {
1643 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1644 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1645};
1646
1647static unsigned int stac925xM5_pin_configs[8] = {
1648 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1649 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1650};
1651
1652static unsigned int stac925xM6_pin_configs[8] = {
1653 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1654 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1581}; 1655};
1582 1656
1583static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { 1657static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1584 [STAC_REF] = ref925x_pin_configs, 1658 [STAC_REF] = ref925x_pin_configs,
1659 [STAC_M1] = stac925xM1_pin_configs,
1660 [STAC_M1_2] = stac925xM1_2_pin_configs,
1661 [STAC_M2] = stac925xM2_pin_configs,
1585 [STAC_M2_2] = stac925xM2_2_pin_configs, 1662 [STAC_M2_2] = stac925xM2_2_pin_configs,
1586 [STAC_MA6] = stac925x_MA6_pin_configs, 1663 [STAC_M3] = stac925xM3_pin_configs,
1587 [STAC_PA6] = stac925x_PA6_pin_configs, 1664 [STAC_M5] = stac925xM5_pin_configs,
1665 [STAC_M6] = stac925xM6_pin_configs,
1588}; 1666};
1589 1667
1590static const char *stac925x_models[STAC_925x_MODELS] = { 1668static const char *stac925x_models[STAC_925x_MODELS] = {
1669 [STAC_925x_AUTO] = "auto",
1591 [STAC_REF] = "ref", 1670 [STAC_REF] = "ref",
1671 [STAC_M1] = "m1",
1672 [STAC_M1_2] = "m1-2",
1673 [STAC_M2] = "m2",
1592 [STAC_M2_2] = "m2-2", 1674 [STAC_M2_2] = "m2-2",
1593 [STAC_MA6] = "m6", 1675 [STAC_M3] = "m3",
1594 [STAC_PA6] = "pa6", 1676 [STAC_M5] = "m5",
1677 [STAC_M6] = "m6",
1678};
1679
1680static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1681 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1682 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1683 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1684 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1685 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1686 /* Not sure about the brand name for those */
1687 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1688 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1689 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1690 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1691 {} /* terminator */
1595}; 1692};
1596 1693
1597static struct snd_pci_quirk stac925x_cfg_tbl[] = { 1694static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1598 /* SigmaTel reference board */ 1695 /* SigmaTel reference board */
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), 1696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1600 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), 1698 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1601 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), 1699
1602 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), 1700 /* Default table for unknown ID */
1603 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), 1701 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1604 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6), 1702
1605 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1606 {} /* terminator */ 1703 {} /* terminator */
1607}; 1704};
1608 1705
@@ -1629,6 +1726,7 @@ static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1629}; 1726};
1630 1727
1631static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1728static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1729 [STAC_92HD73XX_AUTO] = "auto",
1632 [STAC_92HD73XX_NO_JD] = "no-jd", 1730 [STAC_92HD73XX_NO_JD] = "no-jd",
1633 [STAC_92HD73XX_REF] = "ref", 1731 [STAC_92HD73XX_REF] = "ref",
1634 [STAC_DELL_M6_AMIC] = "dell-m6-amic", 1732 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
@@ -1641,6 +1739,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1641 /* SigmaTel reference board */ 1739 /* SigmaTel reference board */
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1643 "DFI LanParty", STAC_92HD73XX_REF), 1741 "DFI LanParty", STAC_92HD73XX_REF),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1743 "DFI LanParty", STAC_92HD73XX_REF),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, 1744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1645 "Dell Studio 1535", STAC_DELL_M6_DMIC), 1745 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, 1746 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
@@ -1664,50 +1764,68 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1664 {} /* terminator */ 1764 {} /* terminator */
1665}; 1765};
1666 1766
1667static unsigned int ref92hd83xxx_pin_configs[14] = { 1767static unsigned int ref92hd83xxx_pin_configs[10] = {
1668 0x02214030, 0x02211010, 0x02a19020, 0x02170130, 1768 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1669 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, 1769 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1670 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1671 0x01451160, 0x98560170, 1770 0x01451160, 0x98560170,
1672}; 1771};
1673 1772
1773static unsigned int dell_s14_pin_configs[10] = {
1774 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1775 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1776 0x40f000f0, 0x40f000f0,
1777};
1778
1674static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { 1779static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1675 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, 1780 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1781 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1782 [STAC_DELL_S14] = dell_s14_pin_configs,
1676}; 1783};
1677 1784
1678static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { 1785static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1786 [STAC_92HD83XXX_AUTO] = "auto",
1679 [STAC_92HD83XXX_REF] = "ref", 1787 [STAC_92HD83XXX_REF] = "ref",
1788 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1789 [STAC_DELL_S14] = "dell-s14",
1680}; 1790};
1681 1791
1682static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { 1792static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1683 /* SigmaTel reference board */ 1793 /* SigmaTel reference board */
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1794 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1685 "DFI LanParty", STAC_92HD71BXX_REF), 1795 "DFI LanParty", STAC_92HD83XXX_REF),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1797 "DFI LanParty", STAC_92HD83XXX_REF),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1799 "unknown Dell", STAC_DELL_S14),
1686 {} /* terminator */ 1800 {} /* terminator */
1687}; 1801};
1688 1802
1689static unsigned int ref92hd71bxx_pin_configs[11] = { 1803static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1690 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, 1804 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1691 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, 1805 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1692 0x90a000f0, 0x01452050, 0x01452050, 1806 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1807 0x00000000
1693}; 1808};
1694 1809
1695static unsigned int dell_m4_1_pin_configs[11] = { 1810static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1696 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, 1811 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1697 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, 1812 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1698 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 1813 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1814 0x00000000
1699}; 1815};
1700 1816
1701static unsigned int dell_m4_2_pin_configs[11] = { 1817static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1702 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, 1818 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1703 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, 1819 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1704 0x40f000f0, 0x044413b0, 0x044413b0, 1820 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1821 0x00000000
1705}; 1822};
1706 1823
1707static unsigned int dell_m4_3_pin_configs[11] = { 1824static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1708 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, 1825 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1709 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, 1826 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1710 0x40f000f0, 0x044413b0, 0x044413b0, 1827 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1828 0x00000000
1711}; 1829};
1712 1830
1713static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { 1831static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
@@ -1716,28 +1834,39 @@ static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1716 [STAC_DELL_M4_2] = dell_m4_2_pin_configs, 1834 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1717 [STAC_DELL_M4_3] = dell_m4_3_pin_configs, 1835 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1718 [STAC_HP_M4] = NULL, 1836 [STAC_HP_M4] = NULL,
1837 [STAC_HP_DV5] = NULL,
1838 [STAC_HP_HDX] = NULL,
1719}; 1839};
1720 1840
1721static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { 1841static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1842 [STAC_92HD71BXX_AUTO] = "auto",
1722 [STAC_92HD71BXX_REF] = "ref", 1843 [STAC_92HD71BXX_REF] = "ref",
1723 [STAC_DELL_M4_1] = "dell-m4-1", 1844 [STAC_DELL_M4_1] = "dell-m4-1",
1724 [STAC_DELL_M4_2] = "dell-m4-2", 1845 [STAC_DELL_M4_2] = "dell-m4-2",
1725 [STAC_DELL_M4_3] = "dell-m4-3", 1846 [STAC_DELL_M4_3] = "dell-m4-3",
1726 [STAC_HP_M4] = "hp-m4", 1847 [STAC_HP_M4] = "hp-m4",
1848 [STAC_HP_DV5] = "hp-dv5",
1849 [STAC_HP_HDX] = "hp-hdx",
1727}; 1850};
1728 1851
1729static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { 1852static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1730 /* SigmaTel reference board */ 1853 /* SigmaTel reference board */
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1854 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1732 "DFI LanParty", STAC_92HD71BXX_REF), 1855 "DFI LanParty", STAC_92HD71BXX_REF),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, 1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1734 "HP dv5", STAC_HP_M4), 1857 "DFI LanParty", STAC_92HD71BXX_REF),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, 1858 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1736 "HP dv7", STAC_HP_M4), 1859 "HP", STAC_HP_DV5),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc, 1860 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1738 "HP dv7", STAC_HP_M4), 1861 "HP dv4-7", STAC_HP_DV5),
1862 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1863 "HP dv4-7", STAC_HP_DV5),
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1865 "HP HDX", STAC_HP_HDX), /* HDX18 */
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, 1866 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1740 "unknown HP", STAC_HP_M4), 1867 "HP mini 1000", STAC_HP_M4),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1869 "HP HDX", STAC_HP_HDX), /* HDX16 */
1741 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1870 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1742 "unknown Dell", STAC_DELL_M4_1), 1871 "unknown Dell", STAC_DELL_M4_1),
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, 1872 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
@@ -1889,6 +2018,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1889}; 2018};
1890 2019
1891static const char *stac922x_models[STAC_922X_MODELS] = { 2020static const char *stac922x_models[STAC_922X_MODELS] = {
2021 [STAC_922X_AUTO] = "auto",
1892 [STAC_D945_REF] = "ref", 2022 [STAC_D945_REF] = "ref",
1893 [STAC_D945GTP5] = "5stack", 2023 [STAC_D945GTP5] = "5stack",
1894 [STAC_D945GTP3] = "3stack", 2024 [STAC_D945GTP3] = "3stack",
@@ -1916,6 +2046,8 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1916 /* SigmaTel reference board */ 2046 /* SigmaTel reference board */
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1918 "DFI LanParty", STAC_D945_REF), 2048 "DFI LanParty", STAC_D945_REF),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2050 "DFI LanParty", STAC_D945_REF),
1919 /* Intel 945G based systems */ 2051 /* Intel 945G based systems */
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, 2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1921 "Intel D945G", STAC_D945GTP3), 2053 "Intel D945G", STAC_D945GTP3),
@@ -1969,6 +2101,9 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1969 "Intel D945P", STAC_D945GTP3), 2101 "Intel D945P", STAC_D945GTP3),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, 2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1971 "Intel D945P", STAC_D945GTP5), 2103 "Intel D945P", STAC_D945GTP5),
2104 /* other intel */
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2106 "Intel D945", STAC_D945_REF),
1972 /* other systems */ 2107 /* other systems */
1973 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ 2108 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1974 SND_PCI_QUIRK(0x8384, 0x7680, 2109 SND_PCI_QUIRK(0x8384, 0x7680,
@@ -1993,31 +2128,7 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, 2128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1994 "Dell XPS M1210", STAC_922X_DELL_M82), 2129 "Dell XPS M1210", STAC_922X_DELL_M82),
1995 /* ECS/PC Chips boards */ 2130 /* ECS/PC Chips boards */
1996 SND_PCI_QUIRK(0x1019, 0x2144, 2131 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1997 "ECS/PC chips", STAC_ECS_202),
1998 SND_PCI_QUIRK(0x1019, 0x2608,
1999 "ECS/PC chips", STAC_ECS_202),
2000 SND_PCI_QUIRK(0x1019, 0x2633,
2001 "ECS/PC chips P17G/1333", STAC_ECS_202),
2002 SND_PCI_QUIRK(0x1019, 0x2811,
2003 "ECS/PC chips", STAC_ECS_202),
2004 SND_PCI_QUIRK(0x1019, 0x2812,
2005 "ECS/PC chips", STAC_ECS_202),
2006 SND_PCI_QUIRK(0x1019, 0x2813,
2007 "ECS/PC chips", STAC_ECS_202),
2008 SND_PCI_QUIRK(0x1019, 0x2814,
2009 "ECS/PC chips", STAC_ECS_202),
2010 SND_PCI_QUIRK(0x1019, 0x2815,
2011 "ECS/PC chips", STAC_ECS_202),
2012 SND_PCI_QUIRK(0x1019, 0x2816,
2013 "ECS/PC chips", STAC_ECS_202),
2014 SND_PCI_QUIRK(0x1019, 0x2817,
2015 "ECS/PC chips", STAC_ECS_202),
2016 SND_PCI_QUIRK(0x1019, 0x2818,
2017 "ECS/PC chips", STAC_ECS_202),
2018 SND_PCI_QUIRK(0x1019, 0x2819,
2019 "ECS/PC chips", STAC_ECS_202),
2020 SND_PCI_QUIRK(0x1019, 0x2820,
2021 "ECS/PC chips", STAC_ECS_202), 2132 "ECS/PC chips", STAC_ECS_202),
2022 {} /* terminator */ 2133 {} /* terminator */
2023}; 2134};
@@ -2060,6 +2171,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2060}; 2171};
2061 2172
2062static const char *stac927x_models[STAC_927X_MODELS] = { 2173static const char *stac927x_models[STAC_927X_MODELS] = {
2174 [STAC_927X_AUTO] = "auto",
2063 [STAC_D965_REF_NO_JD] = "ref-no-jd", 2175 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2064 [STAC_D965_REF] = "ref", 2176 [STAC_D965_REF] = "ref",
2065 [STAC_D965_3ST] = "3stack", 2177 [STAC_D965_3ST] = "3stack",
@@ -2072,26 +2184,16 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2072 /* SigmaTel reference board */ 2184 /* SigmaTel reference board */
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2074 "DFI LanParty", STAC_D965_REF), 2186 "DFI LanParty", STAC_D965_REF),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2188 "DFI LanParty", STAC_D965_REF),
2075 /* Intel 946 based systems */ 2189 /* Intel 946 based systems */
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), 2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), 2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2078 /* 965 based 3 stack systems */ 2192 /* 965 based 3 stack systems */
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), 2193 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), 2194 "Intel D965", STAC_D965_3ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), 2195 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), 2196 "Intel D965", STAC_D965_3ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2095 /* Dell 3 stack systems */ 2197 /* Dell 3 stack systems */
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST), 2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), 2199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
@@ -2107,15 +2209,10 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), 2209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS), 2210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2109 /* 965 based 5 stack systems */ 2211 /* 965 based 5 stack systems */
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), 2212 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), 2213 "Intel D965", STAC_D965_5ST),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), 2214 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), 2215 "Intel D965", STAC_D965_5ST),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2119 {} /* terminator */ 2216 {} /* terminator */
2120}; 2217};
2121 2218
@@ -2168,19 +2265,25 @@ static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2168 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, 2265 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2169 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, 2266 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2170 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, 2267 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2268 [STAC_9205_EAPD] = NULL,
2171}; 2269};
2172 2270
2173static const char *stac9205_models[STAC_9205_MODELS] = { 2271static const char *stac9205_models[STAC_9205_MODELS] = {
2272 [STAC_9205_AUTO] = "auto",
2174 [STAC_9205_REF] = "ref", 2273 [STAC_9205_REF] = "ref",
2175 [STAC_9205_DELL_M42] = "dell-m42", 2274 [STAC_9205_DELL_M42] = "dell-m42",
2176 [STAC_9205_DELL_M43] = "dell-m43", 2275 [STAC_9205_DELL_M43] = "dell-m43",
2177 [STAC_9205_DELL_M44] = "dell-m44", 2276 [STAC_9205_DELL_M44] = "dell-m44",
2277 [STAC_9205_EAPD] = "eapd",
2178}; 2278};
2179 2279
2180static struct snd_pci_quirk stac9205_cfg_tbl[] = { 2280static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2181 /* SigmaTel reference board */ 2281 /* SigmaTel reference board */
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2282 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2183 "DFI LanParty", STAC_9205_REF), 2283 "DFI LanParty", STAC_9205_REF),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2285 "DFI LanParty", STAC_9205_REF),
2286 /* Dell */
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, 2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2185 "unknown Dell", STAC_9205_DELL_M42), 2288 "unknown Dell", STAC_9205_DELL_M42),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, 2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
@@ -2211,101 +2314,24 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2211 "Dell Inspiron", STAC_9205_DELL_M44), 2314 "Dell Inspiron", STAC_9205_DELL_M44),
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, 2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2213 "Dell Vostro 1500", STAC_9205_DELL_M42), 2316 "Dell Vostro 1500", STAC_9205_DELL_M42),
2317 /* Gateway */
2318 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2214 {} /* terminator */ 2319 {} /* terminator */
2215}; 2320};
2216 2321
2217static int stac92xx_save_bios_config_regs(struct hda_codec *codec) 2322static void stac92xx_set_config_regs(struct hda_codec *codec,
2323 unsigned int *pincfgs)
2218{ 2324{
2219 int i; 2325 int i;
2220 struct sigmatel_spec *spec = codec->spec; 2326 struct sigmatel_spec *spec = codec->spec;
2221
2222 kfree(spec->pin_configs);
2223 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2224 GFP_KERNEL);
2225 if (!spec->pin_configs)
2226 return -ENOMEM;
2227
2228 for (i = 0; i < spec->num_pins; i++) {
2229 hda_nid_t nid = spec->pin_nids[i];
2230 unsigned int pin_cfg;
2231
2232 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2233 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2234 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2235 nid, pin_cfg);
2236 spec->pin_configs[i] = pin_cfg;
2237 }
2238
2239 return 0;
2240}
2241 2327
2242static void stac92xx_set_config_reg(struct hda_codec *codec, 2328 if (!pincfgs)
2243 hda_nid_t pin_nid, unsigned int pin_config) 2329 return;
2244{
2245 int i;
2246 snd_hda_codec_write(codec, pin_nid, 0,
2247 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2248 pin_config & 0x000000ff);
2249 snd_hda_codec_write(codec, pin_nid, 0,
2250 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2251 (pin_config & 0x0000ff00) >> 8);
2252 snd_hda_codec_write(codec, pin_nid, 0,
2253 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2254 (pin_config & 0x00ff0000) >> 16);
2255 snd_hda_codec_write(codec, pin_nid, 0,
2256 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2257 pin_config >> 24);
2258 i = snd_hda_codec_read(codec, pin_nid, 0,
2259 AC_VERB_GET_CONFIG_DEFAULT,
2260 0x00);
2261 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2262 pin_nid, i);
2263}
2264
2265static void stac92xx_set_config_regs(struct hda_codec *codec)
2266{
2267 int i;
2268 struct sigmatel_spec *spec = codec->spec;
2269
2270 if (!spec->pin_configs)
2271 return;
2272 2330
2273 for (i = 0; i < spec->num_pins; i++) 2331 for (i = 0; i < spec->num_pins; i++)
2274 stac92xx_set_config_reg(codec, spec->pin_nids[i], 2332 if (spec->pin_nids[i] && pincfgs[i])
2275 spec->pin_configs[i]); 2333 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2276} 2334 pincfgs[i]);
2277
2278static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2279{
2280 struct sigmatel_spec *spec = codec->spec;
2281
2282 if (!pins)
2283 return stac92xx_save_bios_config_regs(codec);
2284
2285 kfree(spec->pin_configs);
2286 spec->pin_configs = kmemdup(pins,
2287 spec->num_pins * sizeof(*pins),
2288 GFP_KERNEL);
2289 if (!spec->pin_configs)
2290 return -ENOMEM;
2291
2292 stac92xx_set_config_regs(codec);
2293 return 0;
2294}
2295
2296static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2297 unsigned int cfg)
2298{
2299 struct sigmatel_spec *spec = codec->spec;
2300 int i;
2301
2302 for (i = 0; i < spec->num_pins; i++) {
2303 if (spec->pin_nids[i] == nid) {
2304 spec->pin_configs[i] = cfg;
2305 stac92xx_set_config_reg(codec, nid, cfg);
2306 break;
2307 }
2308 }
2309} 2335}
2310 2336
2311/* 2337/*
@@ -2370,6 +2396,14 @@ static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2370 stream_tag, format, substream); 2396 stream_tag, format, substream);
2371} 2397}
2372 2398
2399static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2400 struct hda_codec *codec,
2401 struct snd_pcm_substream *substream)
2402{
2403 struct sigmatel_spec *spec = codec->spec;
2404 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2405}
2406
2373 2407
2374/* 2408/*
2375 * Analog capture callbacks 2409 * Analog capture callbacks
@@ -2414,7 +2448,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2414 .ops = { 2448 .ops = {
2415 .open = stac92xx_dig_playback_pcm_open, 2449 .open = stac92xx_dig_playback_pcm_open,
2416 .close = stac92xx_dig_playback_pcm_close, 2450 .close = stac92xx_dig_playback_pcm_close,
2417 .prepare = stac92xx_dig_playback_pcm_prepare 2451 .prepare = stac92xx_dig_playback_pcm_prepare,
2452 .cleanup = stac92xx_dig_playback_pcm_cleanup
2418 }, 2453 },
2419}; 2454};
2420 2455
@@ -2469,6 +2504,8 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
2469 2504
2470 info->name = "STAC92xx Analog"; 2505 info->name = "STAC92xx Analog";
2471 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 2506 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2507 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2508 spec->multiout.dac_nids[0];
2472 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 2509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2473 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2474 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; 2511 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
@@ -2484,7 +2521,7 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
2484 codec->num_pcms++; 2521 codec->num_pcms++;
2485 info++; 2522 info++;
2486 info->name = "STAC92xx Digital"; 2523 info->name = "STAC92xx Digital";
2487 info->pcm_type = HDA_PCM_TYPE_SPDIF; 2524 info->pcm_type = spec->autocfg.dig_out_type[0];
2488 if (spec->multiout.dig_out_nid) { 2525 if (spec->multiout.dig_out_nid) {
2489 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; 2526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2490 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2527 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -2500,8 +2537,7 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
2500 2537
2501static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) 2538static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2502{ 2539{
2503 unsigned int pincap = snd_hda_param_read(codec, nid, 2540 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2504 AC_PAR_PIN_CAP);
2505 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; 2541 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2506 if (pincap & AC_PINCAP_VREF_100) 2542 if (pincap & AC_PINCAP_VREF_100)
2507 return AC_PINCTL_VREF_100; 2543 return AC_PINCTL_VREF_100;
@@ -2676,22 +2712,37 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2676}; 2712};
2677 2713
2678/* add dynamic controls */ 2714/* add dynamic controls */
2679static int stac92xx_add_control_temp(struct sigmatel_spec *spec, 2715static struct snd_kcontrol_new *
2680 struct snd_kcontrol_new *ktemp, 2716stac_control_new(struct sigmatel_spec *spec,
2681 int idx, const char *name, 2717 struct snd_kcontrol_new *ktemp,
2682 unsigned long val) 2718 const char *name)
2683{ 2719{
2684 struct snd_kcontrol_new *knew; 2720 struct snd_kcontrol_new *knew;
2685 2721
2686 snd_array_init(&spec->kctls, sizeof(*knew), 32); 2722 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2687 knew = snd_array_new(&spec->kctls); 2723 knew = snd_array_new(&spec->kctls);
2688 if (!knew) 2724 if (!knew)
2689 return -ENOMEM; 2725 return NULL;
2690 *knew = *ktemp; 2726 *knew = *ktemp;
2691 knew->index = idx;
2692 knew->name = kstrdup(name, GFP_KERNEL); 2727 knew->name = kstrdup(name, GFP_KERNEL);
2693 if (!knew->name) 2728 if (!knew->name) {
2729 /* roolback */
2730 memset(knew, 0, sizeof(*knew));
2731 spec->kctls.alloced--;
2732 return NULL;
2733 }
2734 return knew;
2735}
2736
2737static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2738 struct snd_kcontrol_new *ktemp,
2739 int idx, const char *name,
2740 unsigned long val)
2741{
2742 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2743 if (!knew)
2694 return -ENOMEM; 2744 return -ENOMEM;
2745 knew->index = idx;
2695 knew->private_value = val; 2746 knew->private_value = val;
2696 return 0; 2747 return 0;
2697} 2748}
@@ -2713,6 +2764,29 @@ static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2713 return stac92xx_add_control_idx(spec, type, 0, name, val); 2764 return stac92xx_add_control_idx(spec, type, 0, name, val);
2714} 2765}
2715 2766
2767static struct snd_kcontrol_new stac_input_src_temp = {
2768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2769 .name = "Input Source",
2770 .info = stac92xx_mux_enum_info,
2771 .get = stac92xx_mux_enum_get,
2772 .put = stac92xx_mux_enum_put,
2773};
2774
2775static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2776{
2777 struct snd_kcontrol_new *knew;
2778 struct hda_input_mux *imux = &spec->private_imux;
2779
2780 if (!spec->num_adcs || imux->num_items <= 1)
2781 return 0; /* no need for input source control */
2782 knew = stac_control_new(spec, &stac_input_src_temp,
2783 stac_input_src_temp.name);
2784 if (!knew)
2785 return -ENOMEM;
2786 knew->count = spec->num_adcs;
2787 return 0;
2788}
2789
2716/* check whether the line-input can be used as line-out */ 2790/* check whether the line-input can be used as line-out */
2717static hda_nid_t check_line_out_switch(struct hda_codec *codec) 2791static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2718{ 2792{
@@ -2724,7 +2798,7 @@ static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2724 if (cfg->line_out_type != AUTO_PIN_LINE_OUT) 2798 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2725 return 0; 2799 return 0;
2726 nid = cfg->input_pins[AUTO_PIN_LINE]; 2800 nid = cfg->input_pins[AUTO_PIN_LINE];
2727 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 2801 pincap = snd_hda_query_pin_caps(codec, nid);
2728 if (pincap & AC_PINCAP_OUT) 2802 if (pincap & AC_PINCAP_OUT)
2729 return nid; 2803 return nid;
2730 return 0; 2804 return 0;
@@ -2743,12 +2817,11 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2743 mic_pin = AUTO_PIN_MIC; 2817 mic_pin = AUTO_PIN_MIC;
2744 for (;;) { 2818 for (;;) {
2745 hda_nid_t nid = cfg->input_pins[mic_pin]; 2819 hda_nid_t nid = cfg->input_pins[mic_pin];
2746 def_conf = snd_hda_codec_read(codec, nid, 0, 2820 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2747 AC_VERB_GET_CONFIG_DEFAULT, 0);
2748 /* some laptops have an internal analog microphone 2821 /* some laptops have an internal analog microphone
2749 * which can't be used as a output */ 2822 * which can't be used as a output */
2750 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { 2823 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2751 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 2824 pincap = snd_hda_query_pin_caps(codec, nid);
2752 if (pincap & AC_PINCAP_OUT) 2825 if (pincap & AC_PINCAP_OUT)
2753 return nid; 2826 return nid;
2754 } 2827 }
@@ -2796,8 +2869,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2796 conn_len = snd_hda_get_connections(codec, nid, conn, 2869 conn_len = snd_hda_get_connections(codec, nid, conn,
2797 HDA_MAX_CONNECTIONS); 2870 HDA_MAX_CONNECTIONS);
2798 for (j = 0; j < conn_len; j++) { 2871 for (j = 0; j < conn_len; j++) {
2799 wcaps = snd_hda_param_read(codec, conn[j], 2872 wcaps = get_wcaps(codec, conn[j]);
2800 AC_PAR_AUDIO_WIDGET_CAP);
2801 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2873 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2802 /* we check only analog outputs */ 2874 /* we check only analog outputs */
2803 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) 2875 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
@@ -2812,6 +2884,16 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2812 return conn[j]; 2884 return conn[j];
2813 } 2885 }
2814 } 2886 }
2887 /* if all DACs are already assigned, connect to the primary DAC */
2888 if (conn_len > 1) {
2889 for (j = 0; j < conn_len; j++) {
2890 if (conn[j] == spec->multiout.dac_nids[0]) {
2891 snd_hda_codec_write_cache(codec, nid, 0,
2892 AC_VERB_SET_CONNECT_SEL, j);
2893 break;
2894 }
2895 }
2896 }
2815 return 0; 2897 return 0;
2816} 2898}
2817 2899
@@ -2852,6 +2934,26 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2852 add_spec_dacs(spec, dac); 2934 add_spec_dacs(spec, dac);
2853 } 2935 }
2854 2936
2937 for (i = 0; i < cfg->hp_outs; i++) {
2938 nid = cfg->hp_pins[i];
2939 dac = get_unassigned_dac(codec, nid);
2940 if (dac) {
2941 if (!spec->multiout.hp_nid)
2942 spec->multiout.hp_nid = dac;
2943 else
2944 add_spec_extra_dacs(spec, dac);
2945 }
2946 spec->hp_dacs[i] = dac;
2947 }
2948
2949 for (i = 0; i < cfg->speaker_outs; i++) {
2950 nid = cfg->speaker_pins[i];
2951 dac = get_unassigned_dac(codec, nid);
2952 if (dac)
2953 add_spec_extra_dacs(spec, dac);
2954 spec->speaker_dacs[i] = dac;
2955 }
2956
2855 /* add line-in as output */ 2957 /* add line-in as output */
2856 nid = check_line_out_switch(codec); 2958 nid = check_line_out_switch(codec);
2857 if (nid) { 2959 if (nid) {
@@ -2879,26 +2981,6 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2879 } 2981 }
2880 } 2982 }
2881 2983
2882 for (i = 0; i < cfg->hp_outs; i++) {
2883 nid = cfg->hp_pins[i];
2884 dac = get_unassigned_dac(codec, nid);
2885 if (dac) {
2886 if (!spec->multiout.hp_nid)
2887 spec->multiout.hp_nid = dac;
2888 else
2889 add_spec_extra_dacs(spec, dac);
2890 }
2891 spec->hp_dacs[i] = dac;
2892 }
2893
2894 for (i = 0; i < cfg->speaker_outs; i++) {
2895 nid = cfg->speaker_pins[i];
2896 dac = get_unassigned_dac(codec, nid);
2897 if (dac)
2898 add_spec_extra_dacs(spec, dac);
2899 spec->speaker_dacs[i] = dac;
2900 }
2901
2902 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 2984 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2903 spec->multiout.num_dacs, 2985 spec->multiout.num_dacs,
2904 spec->multiout.dac_nids[0], 2986 spec->multiout.dac_nids[0],
@@ -2911,24 +2993,47 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2911} 2993}
2912 2994
2913/* create volume control/switch for the given prefx type */ 2995/* create volume control/switch for the given prefx type */
2914static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) 2996static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2997 int idx, hda_nid_t nid, int chs)
2915{ 2998{
2999 struct sigmatel_spec *spec = codec->spec;
2916 char name[32]; 3000 char name[32];
2917 int err; 3001 int err;
2918 3002
3003 if (!spec->check_volume_offset) {
3004 unsigned int caps, step, nums, db_scale;
3005 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3006 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3007 AC_AMPCAP_STEP_SIZE_SHIFT;
3008 step = (step + 1) * 25; /* in .01dB unit */
3009 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3010 AC_AMPCAP_NUM_STEPS_SHIFT;
3011 db_scale = nums * step;
3012 /* if dB scale is over -64dB, and finer enough,
3013 * let's reduce it to half
3014 */
3015 if (db_scale > 6400 && nums >= 0x1f)
3016 spec->volume_offset = nums / 2;
3017 spec->check_volume_offset = 1;
3018 }
3019
2919 sprintf(name, "%s Playback Volume", pfx); 3020 sprintf(name, "%s Playback Volume", pfx);
2920 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, 3021 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
2921 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); 3022 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3023 spec->volume_offset));
2922 if (err < 0) 3024 if (err < 0)
2923 return err; 3025 return err;
2924 sprintf(name, "%s Playback Switch", pfx); 3026 sprintf(name, "%s Playback Switch", pfx);
2925 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, 3027 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
2926 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); 3028 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2927 if (err < 0) 3029 if (err < 0)
2928 return err; 3030 return err;
2929 return 0; 3031 return 0;
2930} 3032}
2931 3033
3034#define create_controls(codec, pfx, nid, chs) \
3035 create_controls_idx(codec, pfx, 0, nid, chs)
3036
2932static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) 3037static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2933{ 3038{
2934 if (spec->multiout.num_dacs > 4) { 3039 if (spec->multiout.num_dacs > 4) {
@@ -2954,40 +3059,37 @@ static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2954 return 1; 3059 return 1;
2955} 3060}
2956 3061
2957static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) 3062/* Create output controls
2958{ 3063 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
2959 int i; 3064 */
2960 3065static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
2961 if (spec->autocfg.line_outs != 1) 3066 const hda_nid_t *pins,
2962 return 0; 3067 const hda_nid_t *dac_nids,
2963 if (spec->multiout.hp_nid == nid) 3068 int type)
2964 return 0;
2965 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
2966 if (spec->multiout.extra_out_nid[i] == nid)
2967 return 0;
2968 return 1;
2969}
2970
2971/* add playback controls from the parsed DAC table */
2972static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2973 const struct auto_pin_cfg *cfg)
2974{ 3069{
2975 struct sigmatel_spec *spec = codec->spec; 3070 struct sigmatel_spec *spec = codec->spec;
2976 static const char *chname[4] = { 3071 static const char *chname[4] = {
2977 "Front", "Surround", NULL /*CLFE*/, "Side" 3072 "Front", "Surround", NULL /*CLFE*/, "Side"
2978 }; 3073 };
2979 hda_nid_t nid = 0; 3074 hda_nid_t nid;
2980 int i, err; 3075 int i, err;
2981 unsigned int wid_caps; 3076 unsigned int wid_caps;
2982 3077
2983 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { 3078 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
2984 nid = spec->multiout.dac_nids[i]; 3079 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
2985 if (i == 2) { 3080 wid_caps = get_wcaps(codec, pins[i]);
3081 if (wid_caps & AC_WCAP_UNSOL_CAP)
3082 spec->hp_detect = 1;
3083 }
3084 nid = dac_nids[i];
3085 if (!nid)
3086 continue;
3087 if (type != AUTO_PIN_HP_OUT && i == 2) {
2986 /* Center/LFE */ 3088 /* Center/LFE */
2987 err = create_controls(spec, "Center", nid, 1); 3089 err = create_controls(codec, "Center", nid, 1);
2988 if (err < 0) 3090 if (err < 0)
2989 return err; 3091 return err;
2990 err = create_controls(spec, "LFE", nid, 2); 3092 err = create_controls(codec, "LFE", nid, 2);
2991 if (err < 0) 3093 if (err < 0)
2992 return err; 3094 return err;
2993 3095
@@ -3003,23 +3105,42 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3003 } 3105 }
3004 3106
3005 } else { 3107 } else {
3006 const char *name = chname[i]; 3108 const char *name;
3007 /* if it's a single DAC, assign a better name */ 3109 int idx;
3008 if (!i && is_unique_dac(spec, nid)) { 3110 switch (type) {
3009 switch (cfg->line_out_type) { 3111 case AUTO_PIN_HP_OUT:
3010 case AUTO_PIN_HP_OUT: 3112 name = "Headphone";
3011 name = "Headphone"; 3113 idx = i;
3012 break; 3114 break;
3013 case AUTO_PIN_SPEAKER_OUT: 3115 case AUTO_PIN_SPEAKER_OUT:
3014 name = "Speaker"; 3116 name = "Speaker";
3015 break; 3117 idx = i;
3016 } 3118 break;
3119 default:
3120 name = chname[i];
3121 idx = 0;
3122 break;
3017 } 3123 }
3018 err = create_controls(spec, name, nid, 3); 3124 err = create_controls_idx(codec, name, idx, nid, 3);
3019 if (err < 0) 3125 if (err < 0)
3020 return err; 3126 return err;
3021 } 3127 }
3022 } 3128 }
3129 return 0;
3130}
3131
3132/* add playback controls from the parsed DAC table */
3133static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3134 const struct auto_pin_cfg *cfg)
3135{
3136 struct sigmatel_spec *spec = codec->spec;
3137 int err;
3138
3139 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3140 spec->multiout.dac_nids,
3141 cfg->line_out_type);
3142 if (err < 0)
3143 return err;
3023 3144
3024 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { 3145 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3025 err = stac92xx_add_control(spec, 3146 err = stac92xx_add_control(spec,
@@ -3054,40 +3175,18 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3054 struct auto_pin_cfg *cfg) 3175 struct auto_pin_cfg *cfg)
3055{ 3176{
3056 struct sigmatel_spec *spec = codec->spec; 3177 struct sigmatel_spec *spec = codec->spec;
3057 hda_nid_t nid; 3178 int err;
3058 int i, err, nums; 3179
3180 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3181 spec->hp_dacs, AUTO_PIN_HP_OUT);
3182 if (err < 0)
3183 return err;
3184
3185 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3186 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3187 if (err < 0)
3188 return err;
3059 3189
3060 nums = 0;
3061 for (i = 0; i < cfg->hp_outs; i++) {
3062 static const char *pfxs[] = {
3063 "Headphone", "Headphone2", "Headphone3",
3064 };
3065 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3066 if (wid_caps & AC_WCAP_UNSOL_CAP)
3067 spec->hp_detect = 1;
3068 if (nums >= ARRAY_SIZE(pfxs))
3069 continue;
3070 nid = spec->hp_dacs[i];
3071 if (!nid)
3072 continue;
3073 err = create_controls(spec, pfxs[nums++], nid, 3);
3074 if (err < 0)
3075 return err;
3076 }
3077 nums = 0;
3078 for (i = 0; i < cfg->speaker_outs; i++) {
3079 static const char *pfxs[] = {
3080 "Speaker", "External Speaker", "Speaker2",
3081 };
3082 if (nums >= ARRAY_SIZE(pfxs))
3083 continue;
3084 nid = spec->speaker_dacs[i];
3085 if (!nid)
3086 continue;
3087 err = create_controls(spec, pfxs[nums++], nid, 3);
3088 if (err < 0)
3089 return err;
3090 }
3091 return 0; 3190 return 0;
3092} 3191}
3093 3192
@@ -3296,11 +3395,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3296 unsigned int wcaps; 3395 unsigned int wcaps;
3297 unsigned int def_conf; 3396 unsigned int def_conf;
3298 3397
3299 def_conf = snd_hda_codec_read(codec, 3398 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3300 spec->dmic_nids[i],
3301 0,
3302 AC_VERB_GET_CONFIG_DEFAULT,
3303 0);
3304 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3399 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3305 continue; 3400 continue;
3306 3401
@@ -3424,6 +3519,7 @@ static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3424static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) 3519static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3425{ 3520{
3426 struct sigmatel_spec *spec = codec->spec; 3521 struct sigmatel_spec *spec = codec->spec;
3522 int hp_swap = 0;
3427 int err; 3523 int err;
3428 3524
3429 if ((err = snd_hda_parse_pin_def_config(codec, 3525 if ((err = snd_hda_parse_pin_def_config(codec,
@@ -3451,6 +3547,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3451 spec->autocfg.line_outs = spec->autocfg.hp_outs; 3547 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3452 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; 3548 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3453 spec->autocfg.hp_outs = 0; 3549 spec->autocfg.hp_outs = 0;
3550 hp_swap = 1;
3454 } 3551 }
3455 if (spec->autocfg.mono_out_pin) { 3552 if (spec->autocfg.mono_out_pin) {
3456 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & 3553 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
@@ -3506,13 +3603,12 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3506 err = stac92xx_auto_fill_dac_nids(codec); 3603 err = stac92xx_auto_fill_dac_nids(codec);
3507 if (err < 0) 3604 if (err < 0)
3508 return err; 3605 return err;
3606 err = stac92xx_auto_create_multi_out_ctls(codec,
3607 &spec->autocfg);
3608 if (err < 0)
3609 return err;
3509 } 3610 }
3510 3611
3511 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3512
3513 if (err < 0)
3514 return err;
3515
3516 /* setup analog beep controls */ 3612 /* setup analog beep controls */
3517 if (spec->anabeep_nid > 0) { 3613 if (spec->anabeep_nid > 0) {
3518 err = stac92xx_auto_create_beep_ctls(codec, 3614 err = stac92xx_auto_create_beep_ctls(codec,
@@ -3545,12 +3641,19 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3545#endif 3641#endif
3546 3642
3547 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); 3643 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3548
3549 if (err < 0) 3644 if (err < 0)
3550 return err; 3645 return err;
3551 3646
3552 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); 3647 /* All output parsing done, now restore the swapped hp pins */
3648 if (hp_swap) {
3649 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3650 sizeof(spec->autocfg.hp_pins));
3651 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3652 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3653 spec->autocfg.line_outs = 0;
3654 }
3553 3655
3656 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3554 if (err < 0) 3657 if (err < 0)
3555 return err; 3658 return err;
3556 3659
@@ -3579,11 +3682,15 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3579 return err; 3682 return err;
3580 } 3683 }
3581 3684
3685 err = stac92xx_add_input_source(spec);
3686 if (err < 0)
3687 return err;
3688
3582 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3689 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3583 if (spec->multiout.max_channels > 2) 3690 if (spec->multiout.max_channels > 2)
3584 spec->surr_switch = 1; 3691 spec->surr_switch = 1;
3585 3692
3586 if (spec->autocfg.dig_out_pin) 3693 if (spec->autocfg.dig_outs)
3587 spec->multiout.dig_out_nid = dig_out; 3694 spec->multiout.dig_out_nid = dig_out;
3588 if (dig_in && spec->autocfg.dig_in_pin) 3695 if (dig_in && spec->autocfg.dig_in_pin)
3589 spec->dig_in_nid = dig_in; 3696 spec->dig_in_nid = dig_in;
@@ -3646,9 +3753,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3646 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { 3753 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3647 hda_nid_t pin = spec->autocfg.line_out_pins[i]; 3754 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3648 unsigned int defcfg; 3755 unsigned int defcfg;
3649 defcfg = snd_hda_codec_read(codec, pin, 0, 3756 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3650 AC_VERB_GET_CONFIG_DEFAULT,
3651 0x00);
3652 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { 3757 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3653 unsigned int wcaps = get_wcaps(codec, pin); 3758 unsigned int wcaps = get_wcaps(codec, pin);
3654 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 3759 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
@@ -3661,7 +3766,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3661 } 3766 }
3662 3767
3663 if (lfe_pin) { 3768 if (lfe_pin) {
3664 err = create_controls(spec, "LFE", lfe_pin, 1); 3769 err = create_controls(codec, "LFE", lfe_pin, 1);
3665 if (err < 0) 3770 if (err < 0)
3666 return err; 3771 return err;
3667 } 3772 }
@@ -3692,7 +3797,11 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
3692 return err; 3797 return err;
3693 } 3798 }
3694 3799
3695 if (spec->autocfg.dig_out_pin) 3800 err = stac92xx_add_input_source(spec);
3801 if (err < 0)
3802 return err;
3803
3804 if (spec->autocfg.dig_outs)
3696 spec->multiout.dig_out_nid = 0x05; 3805 spec->multiout.dig_out_nid = 0x05;
3697 if (spec->autocfg.dig_in_pin) 3806 if (spec->autocfg.dig_in_pin)
3698 spec->dig_in_nid = 0x04; 3807 spec->dig_in_nid = 0x04;
@@ -3742,16 +3851,25 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3742 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ 3851 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3743} 3852}
3744 3853
3854#ifdef CONFIG_SND_JACK
3855static void stac92xx_free_jack_priv(struct snd_jack *jack)
3856{
3857 struct sigmatel_jack *jacks = jack->private_data;
3858 jacks->nid = 0;
3859 jacks->jack = NULL;
3860}
3861#endif
3862
3745static int stac92xx_add_jack(struct hda_codec *codec, 3863static int stac92xx_add_jack(struct hda_codec *codec,
3746 hda_nid_t nid, int type) 3864 hda_nid_t nid, int type)
3747{ 3865{
3748#ifdef CONFIG_SND_JACK 3866#ifdef CONFIG_SND_JACK
3749 struct sigmatel_spec *spec = codec->spec; 3867 struct sigmatel_spec *spec = codec->spec;
3750 struct sigmatel_jack *jack; 3868 struct sigmatel_jack *jack;
3751 int def_conf = snd_hda_codec_read(codec, nid, 3869 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3752 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3753 int connectivity = get_defcfg_connect(def_conf); 3870 int connectivity = get_defcfg_connect(def_conf);
3754 char name[32]; 3871 char name[32];
3872 int err;
3755 3873
3756 if (connectivity && connectivity != AC_JACK_PORT_FIXED) 3874 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3757 return 0; 3875 return 0;
@@ -3768,10 +3886,15 @@ static int stac92xx_add_jack(struct hda_codec *codec,
3768 snd_hda_get_jack_connectivity(def_conf), 3886 snd_hda_get_jack_connectivity(def_conf),
3769 snd_hda_get_jack_location(def_conf)); 3887 snd_hda_get_jack_location(def_conf));
3770 3888
3771 return snd_jack_new(codec->bus->card, name, type, &jack->jack); 3889 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
3772#else 3890 if (err < 0) {
3773 return 0; 3891 jack->nid = 0;
3892 return err;
3893 }
3894 jack->jack->private_data = jack;
3895 jack->jack->private_free = stac92xx_free_jack_priv;
3774#endif 3896#endif
3897 return 0;
3775} 3898}
3776 3899
3777static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, 3900static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
@@ -3864,6 +3987,36 @@ static void stac92xx_power_down(struct hda_codec *codec)
3864static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, 3987static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3865 int enable); 3988 int enable);
3866 3989
3990/* override some hints from the hwdep entry */
3991static void stac_store_hints(struct hda_codec *codec)
3992{
3993 struct sigmatel_spec *spec = codec->spec;
3994 const char *p;
3995 int val;
3996
3997 val = snd_hda_get_bool_hint(codec, "hp_detect");
3998 if (val >= 0)
3999 spec->hp_detect = val;
4000 p = snd_hda_get_hint(codec, "gpio_mask");
4001 if (p) {
4002 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4003 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4004 spec->gpio_mask;
4005 }
4006 p = snd_hda_get_hint(codec, "gpio_dir");
4007 if (p)
4008 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4009 p = snd_hda_get_hint(codec, "gpio_data");
4010 if (p)
4011 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4012 p = snd_hda_get_hint(codec, "eapd_mask");
4013 if (p)
4014 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4015 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4016 if (val >= 0)
4017 spec->eapd_switch = val;
4018}
4019
3867static int stac92xx_init(struct hda_codec *codec) 4020static int stac92xx_init(struct hda_codec *codec)
3868{ 4021{
3869 struct sigmatel_spec *spec = codec->spec; 4022 struct sigmatel_spec *spec = codec->spec;
@@ -3880,6 +4033,9 @@ static int stac92xx_init(struct hda_codec *codec)
3880 spec->adc_nids[i], 0, 4033 spec->adc_nids[i], 0,
3881 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 4034 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3882 4035
4036 /* override some hints */
4037 stac_store_hints(codec);
4038
3883 /* set up GPIO */ 4039 /* set up GPIO */
3884 gpio = spec->gpio_data; 4040 gpio = spec->gpio_data;
3885 /* turn on EAPD statically when spec->eapd_switch isn't set. 4041 /* turn on EAPD statically when spec->eapd_switch isn't set.
@@ -3929,8 +4085,7 @@ static int stac92xx_init(struct hda_codec *codec)
3929 pinctl); 4085 pinctl);
3930 } 4086 }
3931 } 4087 }
3932 conf = snd_hda_codec_read(codec, nid, 0, 4088 conf = snd_hda_codec_get_pincfg(codec, nid);
3933 AC_VERB_GET_CONFIG_DEFAULT, 0);
3934 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4089 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3935 enable_pin_detect(codec, nid, 4090 enable_pin_detect(codec, nid,
3936 STAC_INSERT_EVENT); 4091 STAC_INSERT_EVENT);
@@ -3942,8 +4097,8 @@ static int stac92xx_init(struct hda_codec *codec)
3942 for (i = 0; i < spec->num_dmics; i++) 4097 for (i = 0; i < spec->num_dmics; i++)
3943 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], 4098 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3944 AC_PINCTL_IN_EN); 4099 AC_PINCTL_IN_EN);
3945 if (cfg->dig_out_pin) 4100 if (cfg->dig_out_pins[0])
3946 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 4101 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
3947 AC_PINCTL_OUT_EN); 4102 AC_PINCTL_OUT_EN);
3948 if (cfg->dig_in_pin) 4103 if (cfg->dig_in_pin)
3949 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, 4104 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
@@ -3971,8 +4126,7 @@ static int stac92xx_init(struct hda_codec *codec)
3971 stac_toggle_power_map(codec, nid, 1); 4126 stac_toggle_power_map(codec, nid, 1);
3972 continue; 4127 continue;
3973 } 4128 }
3974 def_conf = snd_hda_codec_read(codec, nid, 0, 4129 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3975 AC_VERB_GET_CONFIG_DEFAULT, 0);
3976 def_conf = get_defcfg_connect(def_conf); 4130 def_conf = get_defcfg_connect(def_conf);
3977 /* skip any ports that don't have jacks since presence 4131 /* skip any ports that don't have jacks since presence
3978 * detection is useless */ 4132 * detection is useless */
@@ -3999,8 +4153,10 @@ static void stac92xx_free_jacks(struct hda_codec *codec)
3999 if (!codec->bus->shutdown && spec->jacks.list) { 4153 if (!codec->bus->shutdown && spec->jacks.list) {
4000 struct sigmatel_jack *jacks = spec->jacks.list; 4154 struct sigmatel_jack *jacks = spec->jacks.list;
4001 int i; 4155 int i;
4002 for (i = 0; i < spec->jacks.used; i++) 4156 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4003 snd_device_free(codec->bus->card, &jacks[i].jack); 4157 if (jacks->jack)
4158 snd_device_free(codec->bus->card, jacks->jack);
4159 }
4004 } 4160 }
4005 snd_array_free(&spec->jacks); 4161 snd_array_free(&spec->jacks);
4006#endif 4162#endif
@@ -4026,7 +4182,6 @@ static void stac92xx_free(struct hda_codec *codec)
4026 if (! spec) 4182 if (! spec)
4027 return; 4183 return;
4028 4184
4029 kfree(spec->pin_configs);
4030 stac92xx_free_jacks(codec); 4185 stac92xx_free_jacks(codec);
4031 snd_array_free(&spec->events); 4186 snd_array_free(&spec->events);
4032 4187
@@ -4037,7 +4192,9 @@ static void stac92xx_free(struct hda_codec *codec)
4037static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, 4192static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4038 unsigned int flag) 4193 unsigned int flag)
4039{ 4194{
4040 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 4195 unsigned int old_ctl, pin_ctl;
4196
4197 pin_ctl = snd_hda_codec_read(codec, nid,
4041 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 4198 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4042 4199
4043 if (pin_ctl & AC_PINCTL_IN_EN) { 4200 if (pin_ctl & AC_PINCTL_IN_EN) {
@@ -4051,14 +4208,17 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4051 return; 4208 return;
4052 } 4209 }
4053 4210
4211 old_ctl = pin_ctl;
4054 /* if setting pin direction bits, clear the current 4212 /* if setting pin direction bits, clear the current
4055 direction bits first */ 4213 direction bits first */
4056 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) 4214 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4057 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); 4215 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4058 4216
4059 snd_hda_codec_write_cache(codec, nid, 0, 4217 pin_ctl |= flag;
4060 AC_VERB_SET_PIN_WIDGET_CONTROL, 4218 if (old_ctl != pin_ctl)
4061 pin_ctl | flag); 4219 snd_hda_codec_write_cache(codec, nid, 0,
4220 AC_VERB_SET_PIN_WIDGET_CONTROL,
4221 pin_ctl);
4062} 4222}
4063 4223
4064static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, 4224static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
@@ -4066,9 +4226,10 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4066{ 4226{
4067 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 4227 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4068 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 4228 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4069 snd_hda_codec_write_cache(codec, nid, 0, 4229 if (pin_ctl & flag)
4070 AC_VERB_SET_PIN_WIDGET_CONTROL, 4230 snd_hda_codec_write_cache(codec, nid, 0,
4071 pin_ctl & ~flag); 4231 AC_VERB_SET_PIN_WIDGET_CONTROL,
4232 pin_ctl & ~flag);
4072} 4233}
4073 4234
4074static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) 4235static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
@@ -4163,8 +4324,19 @@ static void stac92xx_hp_detect(struct hda_codec *codec)
4163 continue; 4324 continue;
4164 if (presence) 4325 if (presence)
4165 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); 4326 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4327#if 0 /* FIXME */
4328/* Resetting the pinctl like below may lead to (a sort of) regressions
4329 * on some devices since they use the HP pin actually for line/speaker
4330 * outs although the default pin config shows a different pin (that is
4331 * wrong and useless).
4332 *
4333 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4334 * But, disabling the code below just works around it, and I'm too tired of
4335 * bug reports with such devices...
4336 */
4166 else 4337 else
4167 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); 4338 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4339#endif /* FIXME */
4168 } 4340 }
4169} 4341}
4170 4342
@@ -4258,6 +4430,24 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4258 if (spec->num_pwrs > 0) 4430 if (spec->num_pwrs > 0)
4259 stac92xx_pin_sense(codec, event->nid); 4431 stac92xx_pin_sense(codec, event->nid);
4260 stac92xx_report_jack(codec, event->nid); 4432 stac92xx_report_jack(codec, event->nid);
4433
4434 switch (codec->subsystem_id) {
4435 case 0x103c308f:
4436 if (event->nid == 0xb) {
4437 int pin = AC_PINCTL_IN_EN;
4438
4439 if (get_pin_presence(codec, 0xa)
4440 && get_pin_presence(codec, 0xb))
4441 pin |= AC_PINCTL_VREF_80;
4442 if (!get_pin_presence(codec, 0xb))
4443 pin |= AC_PINCTL_VREF_80;
4444
4445 /* toggle VREF state based on mic + hp pin
4446 * status
4447 */
4448 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4449 }
4450 }
4261 break; 4451 break;
4262 case STAC_VREF_EVENT: 4452 case STAC_VREF_EVENT:
4263 data = snd_hda_codec_read(codec, codec->afg, 0, 4453 data = snd_hda_codec_read(codec, codec->afg, 0,
@@ -4320,7 +4510,6 @@ static int stac92xx_resume(struct hda_codec *codec)
4320{ 4510{
4321 struct sigmatel_spec *spec = codec->spec; 4511 struct sigmatel_spec *spec = codec->spec;
4322 4512
4323 stac92xx_set_config_regs(codec);
4324 stac92xx_init(codec); 4513 stac92xx_init(codec);
4325 snd_hda_codec_resume_amp(codec); 4514 snd_hda_codec_resume_amp(codec);
4326 snd_hda_codec_resume_cache(codec); 4515 snd_hda_codec_resume_cache(codec);
@@ -4331,6 +4520,37 @@ static int stac92xx_resume(struct hda_codec *codec)
4331 return 0; 4520 return 0;
4332} 4521}
4333 4522
4523
4524/*
4525 * using power check for controlling mute led of HP HDX notebooks
4526 * check for mute state only on Speakers (nid = 0x10)
4527 *
4528 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4529 * the LED is NOT working properly !
4530 */
4531
4532#ifdef CONFIG_SND_HDA_POWER_SAVE
4533static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
4534 hda_nid_t nid)
4535{
4536 struct sigmatel_spec *spec = codec->spec;
4537
4538 if (nid == 0x10) {
4539 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4540 HDA_AMP_MUTE)
4541 spec->gpio_data &= ~0x08; /* orange */
4542 else
4543 spec->gpio_data |= 0x08; /* white */
4544
4545 stac_gpio_set(codec, spec->gpio_mask,
4546 spec->gpio_dir,
4547 spec->gpio_data);
4548 }
4549
4550 return 0;
4551}
4552#endif
4553
4334static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) 4554static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4335{ 4555{
4336 struct sigmatel_spec *spec = codec->spec; 4556 struct sigmatel_spec *spec = codec->spec;
@@ -4369,16 +4589,11 @@ static int patch_stac9200(struct hda_codec *codec)
4369 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, 4589 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4370 stac9200_models, 4590 stac9200_models,
4371 stac9200_cfg_tbl); 4591 stac9200_cfg_tbl);
4372 if (spec->board_config < 0) { 4592 if (spec->board_config < 0)
4373 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 4593 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4374 err = stac92xx_save_bios_config_regs(codec); 4594 else
4375 } else 4595 stac92xx_set_config_regs(codec,
4376 err = stac_save_pin_cfgs(codec,
4377 stac9200_brd_tbl[spec->board_config]); 4596 stac9200_brd_tbl[spec->board_config]);
4378 if (err < 0) {
4379 stac92xx_free(codec);
4380 return err;
4381 }
4382 4597
4383 spec->multiout.max_channels = 2; 4598 spec->multiout.max_channels = 2;
4384 spec->multiout.num_dacs = 1; 4599 spec->multiout.num_dacs = 1;
@@ -4390,7 +4605,8 @@ static int patch_stac9200(struct hda_codec *codec)
4390 spec->num_adcs = 1; 4605 spec->num_adcs = 1;
4391 spec->num_pwrs = 0; 4606 spec->num_pwrs = 0;
4392 4607
4393 if (spec->board_config == STAC_9200_GATEWAY || 4608 if (spec->board_config == STAC_9200_M4 ||
4609 spec->board_config == STAC_9200_M4_2 ||
4394 spec->board_config == STAC_9200_OQO) 4610 spec->board_config == STAC_9200_OQO)
4395 spec->init = stac9200_eapd_init; 4611 spec->init = stac9200_eapd_init;
4396 else 4612 else
@@ -4408,6 +4624,12 @@ static int patch_stac9200(struct hda_codec *codec)
4408 return err; 4624 return err;
4409 } 4625 }
4410 4626
4627 /* CF-74 has no headphone detection, and the driver should *NOT*
4628 * do detection and HP/speaker toggle because the hardware does it.
4629 */
4630 if (spec->board_config == STAC_9200_PANASONIC)
4631 spec->hp_detect = 0;
4632
4411 codec->patch_ops = stac92xx_patch_ops; 4633 codec->patch_ops = stac92xx_patch_ops;
4412 4634
4413 return 0; 4635 return 0;
@@ -4425,21 +4647,26 @@ static int patch_stac925x(struct hda_codec *codec)
4425 codec->spec = spec; 4647 codec->spec = spec;
4426 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); 4648 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4427 spec->pin_nids = stac925x_pin_nids; 4649 spec->pin_nids = stac925x_pin_nids;
4428 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, 4650
4651 /* Check first for codec ID */
4652 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4653 STAC_925x_MODELS,
4654 stac925x_models,
4655 stac925x_codec_id_cfg_tbl);
4656
4657 /* Now checks for PCI ID, if codec ID is not found */
4658 if (spec->board_config < 0)
4659 spec->board_config = snd_hda_check_board_config(codec,
4660 STAC_925x_MODELS,
4429 stac925x_models, 4661 stac925x_models,
4430 stac925x_cfg_tbl); 4662 stac925x_cfg_tbl);
4431 again: 4663 again:
4432 if (spec->board_config < 0) { 4664 if (spec->board_config < 0)
4433 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 4665 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4434 "using BIOS defaults\n"); 4666 "using BIOS defaults\n");
4435 err = stac92xx_save_bios_config_regs(codec); 4667 else
4436 } else 4668 stac92xx_set_config_regs(codec,
4437 err = stac_save_pin_cfgs(codec,
4438 stac925x_brd_tbl[spec->board_config]); 4669 stac925x_brd_tbl[spec->board_config]);
4439 if (err < 0) {
4440 stac92xx_free(codec);
4441 return err;
4442 }
4443 4670
4444 spec->multiout.max_channels = 2; 4671 spec->multiout.max_channels = 2;
4445 spec->multiout.num_dacs = 1; 4672 spec->multiout.num_dacs = 1;
@@ -4517,17 +4744,12 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
4517 stac92hd73xx_models, 4744 stac92hd73xx_models,
4518 stac92hd73xx_cfg_tbl); 4745 stac92hd73xx_cfg_tbl);
4519again: 4746again:
4520 if (spec->board_config < 0) { 4747 if (spec->board_config < 0)
4521 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4748 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4522 " STAC92HD73XX, using BIOS defaults\n"); 4749 " STAC92HD73XX, using BIOS defaults\n");
4523 err = stac92xx_save_bios_config_regs(codec); 4750 else
4524 } else 4751 stac92xx_set_config_regs(codec,
4525 err = stac_save_pin_cfgs(codec,
4526 stac92hd73xx_brd_tbl[spec->board_config]); 4752 stac92hd73xx_brd_tbl[spec->board_config]);
4527 if (err < 0) {
4528 stac92xx_free(codec);
4529 return err;
4530 }
4531 4753
4532 num_dacs = snd_hda_get_connections(codec, 0x0a, 4754 num_dacs = snd_hda_get_connections(codec, 0x0a,
4533 conn, STAC92HD73_DAC_COUNT + 2) - 1; 4755 conn, STAC92HD73_DAC_COUNT + 2) - 1;
@@ -4541,14 +4763,18 @@ again:
4541 case 0x3: /* 6 Channel */ 4763 case 0x3: /* 6 Channel */
4542 spec->mixer = stac92hd73xx_6ch_mixer; 4764 spec->mixer = stac92hd73xx_6ch_mixer;
4543 spec->init = stac92hd73xx_6ch_core_init; 4765 spec->init = stac92hd73xx_6ch_core_init;
4766 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4544 break; 4767 break;
4545 case 0x4: /* 8 Channel */ 4768 case 0x4: /* 8 Channel */
4546 spec->mixer = stac92hd73xx_8ch_mixer; 4769 spec->mixer = stac92hd73xx_8ch_mixer;
4547 spec->init = stac92hd73xx_8ch_core_init; 4770 spec->init = stac92hd73xx_8ch_core_init;
4771 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4548 break; 4772 break;
4549 case 0x5: /* 10 Channel */ 4773 case 0x5: /* 10 Channel */
4550 spec->mixer = stac92hd73xx_10ch_mixer; 4774 spec->mixer = stac92hd73xx_10ch_mixer;
4551 spec->init = stac92hd73xx_10ch_core_init; 4775 spec->init = stac92hd73xx_10ch_core_init;
4776 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4777 break;
4552 } 4778 }
4553 spec->multiout.dac_nids = spec->dac_nids; 4779 spec->multiout.dac_nids = spec->dac_nids;
4554 4780
@@ -4587,18 +4813,18 @@ again:
4587 spec->init = dell_m6_core_init; 4813 spec->init = dell_m6_core_init;
4588 switch (spec->board_config) { 4814 switch (spec->board_config) {
4589 case STAC_DELL_M6_AMIC: /* Analog Mics */ 4815 case STAC_DELL_M6_AMIC: /* Analog Mics */
4590 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4816 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4591 spec->num_dmics = 0; 4817 spec->num_dmics = 0;
4592 spec->private_dimux.num_items = 1; 4818 spec->private_dimux.num_items = 1;
4593 break; 4819 break;
4594 case STAC_DELL_M6_DMIC: /* Digital Mics */ 4820 case STAC_DELL_M6_DMIC: /* Digital Mics */
4595 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4821 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4596 spec->num_dmics = 1; 4822 spec->num_dmics = 1;
4597 spec->private_dimux.num_items = 2; 4823 spec->private_dimux.num_items = 2;
4598 break; 4824 break;
4599 case STAC_DELL_M6_BOTH: /* Both */ 4825 case STAC_DELL_M6_BOTH: /* Both */
4600 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4826 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4601 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4827 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4602 spec->num_dmics = 1; 4828 spec->num_dmics = 1;
4603 spec->private_dimux.num_items = 2; 4829 spec->private_dimux.num_items = 2;
4604 break; 4830 break;
@@ -4658,7 +4884,10 @@ static struct hda_input_mux stac92hd83xxx_dmux = {
4658static int patch_stac92hd83xxx(struct hda_codec *codec) 4884static int patch_stac92hd83xxx(struct hda_codec *codec)
4659{ 4885{
4660 struct sigmatel_spec *spec; 4886 struct sigmatel_spec *spec;
4887 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4661 int err; 4888 int err;
4889 int num_dacs;
4890 hda_nid_t nid;
4662 4891
4663 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4892 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4664 if (spec == NULL) 4893 if (spec == NULL)
@@ -4672,23 +4901,17 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4672 spec->dmux_nids = stac92hd83xxx_dmux_nids; 4901 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4673 spec->adc_nids = stac92hd83xxx_adc_nids; 4902 spec->adc_nids = stac92hd83xxx_adc_nids;
4674 spec->pwr_nids = stac92hd83xxx_pwr_nids; 4903 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4904 spec->amp_nids = stac92hd83xxx_amp_nids;
4675 spec->pwr_mapping = stac92hd83xxx_pwr_mapping; 4905 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4676 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); 4906 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4677 spec->multiout.dac_nids = spec->dac_nids; 4907 spec->multiout.dac_nids = spec->dac_nids;
4678 4908
4679 spec->init = stac92hd83xxx_core_init; 4909 spec->init = stac92hd83xxx_core_init;
4680 switch (codec->vendor_id) {
4681 case 0x111d7605:
4682 break;
4683 default:
4684 spec->num_pwrs--;
4685 spec->init++; /* switch to config #2 */
4686 }
4687
4688 spec->mixer = stac92hd83xxx_mixer; 4910 spec->mixer = stac92hd83xxx_mixer;
4689 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); 4911 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4690 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); 4912 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4691 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); 4913 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4914 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
4692 spec->num_dmics = STAC92HD83XXX_NUM_DMICS; 4915 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4693 spec->dinput_mux = &stac92hd83xxx_dmux; 4916 spec->dinput_mux = &stac92hd83xxx_dmux;
4694 spec->pin_nids = stac92hd83xxx_pin_nids; 4917 spec->pin_nids = stac92hd83xxx_pin_nids;
@@ -4697,16 +4920,21 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4697 stac92hd83xxx_models, 4920 stac92hd83xxx_models,
4698 stac92hd83xxx_cfg_tbl); 4921 stac92hd83xxx_cfg_tbl);
4699again: 4922again:
4700 if (spec->board_config < 0) { 4923 if (spec->board_config < 0)
4701 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4924 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4702 " STAC92HD83XXX, using BIOS defaults\n"); 4925 " STAC92HD83XXX, using BIOS defaults\n");
4703 err = stac92xx_save_bios_config_regs(codec); 4926 else
4704 } else 4927 stac92xx_set_config_regs(codec,
4705 err = stac_save_pin_cfgs(codec,
4706 stac92hd83xxx_brd_tbl[spec->board_config]); 4928 stac92hd83xxx_brd_tbl[spec->board_config]);
4707 if (err < 0) { 4929
4708 stac92xx_free(codec); 4930 switch (codec->vendor_id) {
4709 return err; 4931 case 0x111d7604:
4932 case 0x111d7605:
4933 case 0x111d76d5:
4934 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4935 break;
4936 spec->num_pwrs = 0;
4937 break;
4710 } 4938 }
4711 4939
4712 err = stac92xx_parse_auto_config(codec, 0x1d, 0); 4940 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
@@ -4725,6 +4953,23 @@ again:
4725 return err; 4953 return err;
4726 } 4954 }
4727 4955
4956 switch (spec->board_config) {
4957 case STAC_DELL_S14:
4958 nid = 0xf;
4959 break;
4960 default:
4961 nid = 0xe;
4962 break;
4963 }
4964
4965 num_dacs = snd_hda_get_connections(codec, nid,
4966 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4967
4968 /* set port X to select the last DAC
4969 */
4970 snd_hda_codec_write_cache(codec, nid, 0,
4971 AC_VERB_SET_CONNECT_SEL, num_dacs);
4972
4728 codec->patch_ops = stac92xx_patch_ops; 4973 codec->patch_ops = stac92xx_patch_ops;
4729 4974
4730 codec->proc_widget_hook = stac92hd_proc_hook; 4975 codec->proc_widget_hook = stac92hd_proc_hook;
@@ -4732,7 +4977,16 @@ again:
4732 return 0; 4977 return 0;
4733} 4978}
4734 4979
4735static struct hda_input_mux stac92hd71bxx_dmux = { 4980static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4981 .num_items = 3,
4982 .items = {
4983 { "Analog Inputs", 0x00 },
4984 { "Digital Mic 1", 0x02 },
4985 { "Digital Mic 2", 0x03 },
4986 }
4987};
4988
4989static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
4736 .num_items = 4, 4990 .num_items = 4,
4737 .items = { 4991 .items = {
4738 { "Analog Inputs", 0x00 }, 4992 { "Analog Inputs", 0x00 },
@@ -4742,10 +4996,67 @@ static struct hda_input_mux stac92hd71bxx_dmux = {
4742 } 4996 }
4743}; 4997};
4744 4998
4999/* get the pin connection (fixed, none, etc) */
5000static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5001{
5002 struct sigmatel_spec *spec = codec->spec;
5003 unsigned int cfg;
5004
5005 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5006 return get_defcfg_connect(cfg);
5007}
5008
5009static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5010 hda_nid_t *nids, int num_nids)
5011{
5012 struct sigmatel_spec *spec = codec->spec;
5013 int idx, num;
5014 unsigned int def_conf;
5015
5016 for (num = 0; num < num_nids; num++) {
5017 for (idx = 0; idx < spec->num_pins; idx++)
5018 if (spec->pin_nids[idx] == nids[num])
5019 break;
5020 if (idx >= spec->num_pins)
5021 break;
5022 def_conf = stac_get_defcfg_connect(codec, idx);
5023 if (def_conf == AC_JACK_PORT_NONE)
5024 break;
5025 }
5026 return num;
5027}
5028
5029static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5030 hda_nid_t dig0pin)
5031{
5032 struct sigmatel_spec *spec = codec->spec;
5033 int idx;
5034
5035 for (idx = 0; idx < spec->num_pins; idx++)
5036 if (spec->pin_nids[idx] == dig0pin)
5037 break;
5038 if ((idx + 2) >= spec->num_pins)
5039 return 0;
5040
5041 /* dig1pin case */
5042 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5043 return 2;
5044
5045 /* dig0pin + dig2pin case */
5046 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5047 return 2;
5048 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5049 return 1;
5050 else
5051 return 0;
5052}
5053
4745static int patch_stac92hd71bxx(struct hda_codec *codec) 5054static int patch_stac92hd71bxx(struct hda_codec *codec)
4746{ 5055{
4747 struct sigmatel_spec *spec; 5056 struct sigmatel_spec *spec;
5057 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4748 int err = 0; 5058 int err = 0;
5059 unsigned int ndmic_nids = 0;
4749 5060
4750 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5061 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4751 if (spec == NULL) 5062 if (spec == NULL)
@@ -4753,27 +5064,32 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
4753 5064
4754 codec->spec = spec; 5065 codec->spec = spec;
4755 codec->patch_ops = stac92xx_patch_ops; 5066 codec->patch_ops = stac92xx_patch_ops;
4756 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); 5067 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5068 switch (codec->vendor_id) {
5069 case 0x111d76b6:
5070 case 0x111d76b7:
5071 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5072 break;
5073 case 0x111d7603:
5074 case 0x111d7608:
5075 /* On 92HD75Bx 0x27 isn't a pin nid */
5076 spec->num_pins--;
5077 /* fallthrough */
5078 default:
5079 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5080 }
4757 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); 5081 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4758 spec->pin_nids = stac92hd71bxx_pin_nids;
4759 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4760 sizeof(stac92hd71bxx_dmux));
4761 spec->board_config = snd_hda_check_board_config(codec, 5082 spec->board_config = snd_hda_check_board_config(codec,
4762 STAC_92HD71BXX_MODELS, 5083 STAC_92HD71BXX_MODELS,
4763 stac92hd71bxx_models, 5084 stac92hd71bxx_models,
4764 stac92hd71bxx_cfg_tbl); 5085 stac92hd71bxx_cfg_tbl);
4765again: 5086again:
4766 if (spec->board_config < 0) { 5087 if (spec->board_config < 0)
4767 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5088 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4768 " STAC92HD71BXX, using BIOS defaults\n"); 5089 " STAC92HD71BXX, using BIOS defaults\n");
4769 err = stac92xx_save_bios_config_regs(codec); 5090 else
4770 } else 5091 stac92xx_set_config_regs(codec,
4771 err = stac_save_pin_cfgs(codec,
4772 stac92hd71bxx_brd_tbl[spec->board_config]); 5092 stac92hd71bxx_brd_tbl[spec->board_config]);
4773 if (err < 0) {
4774 stac92xx_free(codec);
4775 return err;
4776 }
4777 5093
4778 if (spec->board_config > STAC_92HD71BXX_REF) { 5094 if (spec->board_config > STAC_92HD71BXX_REF) {
4779 /* GPIO0 = EAPD */ 5095 /* GPIO0 = EAPD */
@@ -4782,16 +5098,34 @@ again:
4782 spec->gpio_data = 0x01; 5098 spec->gpio_data = 0x01;
4783 } 5099 }
4784 5100
5101 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5102 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5103
4785 switch (codec->vendor_id) { 5104 switch (codec->vendor_id) {
4786 case 0x111d76b6: /* 4 Port without Analog Mixer */ 5105 case 0x111d76b6: /* 4 Port without Analog Mixer */
4787 case 0x111d76b7: 5106 case 0x111d76b7:
5107 unmute_init++;
5108 /* fallthru */
4788 case 0x111d76b4: /* 6 Port without Analog Mixer */ 5109 case 0x111d76b4: /* 6 Port without Analog Mixer */
4789 case 0x111d76b5: 5110 case 0x111d76b5:
5111 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5112 sizeof(stac92hd71bxx_dmux_nomixer));
4790 spec->mixer = stac92hd71bxx_mixer; 5113 spec->mixer = stac92hd71bxx_mixer;
4791 spec->init = stac92hd71bxx_core_init; 5114 spec->init = stac92hd71bxx_core_init;
4792 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5115 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5116 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5117 stac92hd71bxx_dmic_nids,
5118 STAC92HD71BXX_NUM_DMICS);
5119 if (spec->num_dmics) {
5120 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5121 spec->dinput_mux = &spec->private_dimux;
5122 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5123 }
4793 break; 5124 break;
4794 case 0x111d7608: /* 5 Port with Analog Mixer */ 5125 case 0x111d7608: /* 5 Port with Analog Mixer */
5126 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5127 sizeof(stac92hd71bxx_dmux_amixer));
5128 spec->private_dimux.num_items--;
4795 switch (spec->board_config) { 5129 switch (spec->board_config) {
4796 case STAC_HP_M4: 5130 case STAC_HP_M4:
4797 /* Enable VREF power saving on GPIO1 detect */ 5131 /* Enable VREF power saving on GPIO1 detect */
@@ -4818,7 +5152,15 @@ again:
4818 5152
4819 /* disable VSW */ 5153 /* disable VSW */
4820 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; 5154 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4821 stac_change_pin_config(codec, 0xf, 0x40f000f0); 5155 unmute_init++;
5156 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5157 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5158 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5159 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5160 stac92hd71bxx_dmic_nids,
5161 STAC92HD71BXX_NUM_DMICS - 1);
5162 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5163 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
4822 break; 5164 break;
4823 case 0x111d7603: /* 6 Port with Analog Mixer */ 5165 case 0x111d7603: /* 6 Port with Analog Mixer */
4824 if ((codec->revision_id & 0xf) == 1) 5166 if ((codec->revision_id & 0xf) == 1)
@@ -4828,12 +5170,23 @@ again:
4828 spec->num_pwrs = 0; 5170 spec->num_pwrs = 0;
4829 /* fallthru */ 5171 /* fallthru */
4830 default: 5172 default:
5173 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5174 sizeof(stac92hd71bxx_dmux_amixer));
4831 spec->dinput_mux = &spec->private_dimux; 5175 spec->dinput_mux = &spec->private_dimux;
4832 spec->mixer = stac92hd71bxx_analog_mixer; 5176 spec->mixer = stac92hd71bxx_analog_mixer;
4833 spec->init = stac92hd71bxx_analog_core_init; 5177 spec->init = stac92hd71bxx_analog_core_init;
4834 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5178 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5179 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5180 stac92hd71bxx_dmic_nids,
5181 STAC92HD71BXX_NUM_DMICS);
5182 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5183 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4835 } 5184 }
4836 5185
5186 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5187 snd_hda_sequence_write_cache(codec, unmute_init);
5188
5189 spec->aloopback_ctl = stac92hd71bxx_loopback;
4837 spec->aloopback_mask = 0x50; 5190 spec->aloopback_mask = 0x50;
4838 spec->aloopback_shift = 0; 5191 spec->aloopback_shift = 0;
4839 5192
@@ -4841,18 +5194,17 @@ again:
4841 spec->digbeep_nid = 0x26; 5194 spec->digbeep_nid = 0x26;
4842 spec->mux_nids = stac92hd71bxx_mux_nids; 5195 spec->mux_nids = stac92hd71bxx_mux_nids;
4843 spec->adc_nids = stac92hd71bxx_adc_nids; 5196 spec->adc_nids = stac92hd71bxx_adc_nids;
4844 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4845 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4846 spec->smux_nids = stac92hd71bxx_smux_nids; 5197 spec->smux_nids = stac92hd71bxx_smux_nids;
4847 spec->pwr_nids = stac92hd71bxx_pwr_nids; 5198 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4848 5199
4849 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); 5200 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4850 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); 5201 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5202 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
4851 5203
4852 switch (spec->board_config) { 5204 switch (spec->board_config) {
4853 case STAC_HP_M4: 5205 case STAC_HP_M4:
4854 /* enable internal microphone */ 5206 /* enable internal microphone */
4855 stac_change_pin_config(codec, 0x0e, 0x01813040); 5207 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
4856 stac92xx_auto_set_pinctl(codec, 0x0e, 5208 stac92xx_auto_set_pinctl(codec, 0x0e,
4857 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); 5209 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4858 /* fallthru */ 5210 /* fallthru */
@@ -4865,21 +5217,38 @@ again:
4865 case STAC_DELL_M4_3: 5217 case STAC_DELL_M4_3:
4866 spec->num_dmics = 1; 5218 spec->num_dmics = 1;
4867 spec->num_smuxes = 0; 5219 spec->num_smuxes = 0;
4868 spec->num_dmuxes = 0; 5220 spec->num_dmuxes = 1;
5221 break;
5222 case STAC_HP_DV5:
5223 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5224 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5225 break;
5226 case STAC_HP_HDX:
5227 spec->num_dmics = 1;
5228 spec->num_dmuxes = 1;
5229 spec->num_smuxes = 1;
5230 /*
5231 * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
5232 * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
5233 */
5234#ifdef CONFIG_SND_HDA_POWER_SAVE
5235 /* orange/white mute led on GPIO3, orange=0, white=1 */
5236 spec->gpio_mask |= 0x08;
5237 spec->gpio_dir |= 0x08;
5238 spec->gpio_data |= 0x08; /* set to white */
5239
5240 /* register check_power_status callback. */
5241 codec->patch_ops.check_power_status =
5242 stac92xx_hp_hdx_check_power_status;
5243#endif
4869 break; 5244 break;
4870 default:
4871 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4872 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4873 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4874 }; 5245 };
4875 5246
4876 spec->multiout.dac_nids = spec->dac_nids; 5247 spec->multiout.dac_nids = spec->dac_nids;
4877 if (spec->dinput_mux) 5248 if (spec->dinput_mux)
4878 spec->private_dimux.num_items += 5249 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
4879 spec->num_dmics -
4880 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4881 5250
4882 err = stac92xx_parse_auto_config(codec, 0x21, 0x23); 5251 err = stac92xx_parse_auto_config(codec, 0x21, 0);
4883 if (!err) { 5252 if (!err) {
4884 if (spec->board_config < 0) { 5253 if (spec->board_config < 0) {
4885 printk(KERN_WARNING "hda_codec: No auto-config is " 5254 printk(KERN_WARNING "hda_codec: No auto-config is "
@@ -4954,17 +5323,12 @@ static int patch_stac922x(struct hda_codec *codec)
4954 } 5323 }
4955 5324
4956 again: 5325 again:
4957 if (spec->board_config < 0) { 5326 if (spec->board_config < 0)
4958 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " 5327 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4959 "using BIOS defaults\n"); 5328 "using BIOS defaults\n");
4960 err = stac92xx_save_bios_config_regs(codec); 5329 else
4961 } else 5330 stac92xx_set_config_regs(codec,
4962 err = stac_save_pin_cfgs(codec,
4963 stac922x_brd_tbl[spec->board_config]); 5331 stac922x_brd_tbl[spec->board_config]);
4964 if (err < 0) {
4965 stac92xx_free(codec);
4966 return err;
4967 }
4968 5332
4969 spec->adc_nids = stac922x_adc_nids; 5333 spec->adc_nids = stac922x_adc_nids;
4970 spec->mux_nids = stac922x_mux_nids; 5334 spec->mux_nids = stac922x_mux_nids;
@@ -5015,24 +5379,19 @@ static int patch_stac927x(struct hda_codec *codec)
5015 return -ENOMEM; 5379 return -ENOMEM;
5016 5380
5017 codec->spec = spec; 5381 codec->spec = spec;
5382 codec->slave_dig_outs = stac927x_slave_dig_outs;
5018 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); 5383 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5019 spec->pin_nids = stac927x_pin_nids; 5384 spec->pin_nids = stac927x_pin_nids;
5020 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, 5385 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5021 stac927x_models, 5386 stac927x_models,
5022 stac927x_cfg_tbl); 5387 stac927x_cfg_tbl);
5023 again: 5388 again:
5024 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) { 5389 if (spec->board_config < 0)
5025 if (spec->board_config < 0) 5390 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5026 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5391 "STAC927x, using BIOS defaults\n");
5027 "STAC927x, using BIOS defaults\n"); 5392 else
5028 err = stac92xx_save_bios_config_regs(codec); 5393 stac92xx_set_config_regs(codec,
5029 } else
5030 err = stac_save_pin_cfgs(codec,
5031 stac927x_brd_tbl[spec->board_config]); 5394 stac927x_brd_tbl[spec->board_config]);
5032 if (err < 0) {
5033 stac92xx_free(codec);
5034 return err;
5035 }
5036 5395
5037 spec->digbeep_nid = 0x23; 5396 spec->digbeep_nid = 0x23;
5038 spec->adc_nids = stac927x_adc_nids; 5397 spec->adc_nids = stac927x_adc_nids;
@@ -5061,15 +5420,15 @@ static int patch_stac927x(struct hda_codec *codec)
5061 case 0x10280209: 5420 case 0x10280209:
5062 case 0x1028022e: 5421 case 0x1028022e:
5063 /* correct the device field to SPDIF out */ 5422 /* correct the device field to SPDIF out */
5064 stac_change_pin_config(codec, 0x21, 0x01442070); 5423 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5065 break; 5424 break;
5066 }; 5425 };
5067 /* configure the analog microphone on some laptops */ 5426 /* configure the analog microphone on some laptops */
5068 stac_change_pin_config(codec, 0x0c, 0x90a79130); 5427 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5069 /* correct the front output jack as a hp out */ 5428 /* correct the front output jack as a hp out */
5070 stac_change_pin_config(codec, 0x0f, 0x0227011f); 5429 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5071 /* correct the front input jack as a mic */ 5430 /* correct the front input jack as a mic */
5072 stac_change_pin_config(codec, 0x0e, 0x02a79130); 5431 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5073 /* fallthru */ 5432 /* fallthru */
5074 case STAC_DELL_3ST: 5433 case STAC_DELL_3ST:
5075 /* GPIO2 High = Enable EAPD */ 5434 /* GPIO2 High = Enable EAPD */
@@ -5096,6 +5455,7 @@ static int patch_stac927x(struct hda_codec *codec)
5096 } 5455 }
5097 5456
5098 spec->num_pwrs = 0; 5457 spec->num_pwrs = 0;
5458 spec->aloopback_ctl = stac927x_loopback;
5099 spec->aloopback_mask = 0x40; 5459 spec->aloopback_mask = 0x40;
5100 spec->aloopback_shift = 0; 5460 spec->aloopback_shift = 0;
5101 spec->eapd_switch = 1; 5461 spec->eapd_switch = 1;
@@ -5154,16 +5514,11 @@ static int patch_stac9205(struct hda_codec *codec)
5154 stac9205_models, 5514 stac9205_models,
5155 stac9205_cfg_tbl); 5515 stac9205_cfg_tbl);
5156 again: 5516 again:
5157 if (spec->board_config < 0) { 5517 if (spec->board_config < 0)
5158 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); 5518 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5159 err = stac92xx_save_bios_config_regs(codec); 5519 else
5160 } else 5520 stac92xx_set_config_regs(codec,
5161 err = stac_save_pin_cfgs(codec,
5162 stac9205_brd_tbl[spec->board_config]); 5521 stac9205_brd_tbl[spec->board_config]);
5163 if (err < 0) {
5164 stac92xx_free(codec);
5165 return err;
5166 }
5167 5522
5168 spec->digbeep_nid = 0x23; 5523 spec->digbeep_nid = 0x23;
5169 spec->adc_nids = stac9205_adc_nids; 5524 spec->adc_nids = stac9205_adc_nids;
@@ -5180,17 +5535,20 @@ static int patch_stac9205(struct hda_codec *codec)
5180 5535
5181 spec->init = stac9205_core_init; 5536 spec->init = stac9205_core_init;
5182 spec->mixer = stac9205_mixer; 5537 spec->mixer = stac9205_mixer;
5538 spec->aloopback_ctl = stac9205_loopback;
5183 5539
5184 spec->aloopback_mask = 0x40; 5540 spec->aloopback_mask = 0x40;
5185 spec->aloopback_shift = 0; 5541 spec->aloopback_shift = 0;
5186 spec->eapd_switch = 1; 5542 /* Turn on/off EAPD per HP plugging */
5543 if (spec->board_config != STAC_9205_EAPD)
5544 spec->eapd_switch = 1;
5187 spec->multiout.dac_nids = spec->dac_nids; 5545 spec->multiout.dac_nids = spec->dac_nids;
5188 5546
5189 switch (spec->board_config){ 5547 switch (spec->board_config){
5190 case STAC_9205_DELL_M43: 5548 case STAC_9205_DELL_M43:
5191 /* Enable SPDIF in/out */ 5549 /* Enable SPDIF in/out */
5192 stac_change_pin_config(codec, 0x1f, 0x01441030); 5550 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5193 stac_change_pin_config(codec, 0x20, 0x1c410030); 5551 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5194 5552
5195 /* Enable unsol response for GPIO4/Dock HP connection */ 5553 /* Enable unsol response for GPIO4/Dock HP connection */
5196 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); 5554 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
@@ -5247,223 +5605,87 @@ static int patch_stac9205(struct hda_codec *codec)
5247 * STAC9872 hack 5605 * STAC9872 hack
5248 */ 5606 */
5249 5607
5250/* static config for Sony VAIO FE550G and Sony VAIO AR */ 5608static struct hda_verb stac9872_core_init[] = {
5251static hda_nid_t vaio_dacs[] = { 0x2 };
5252#define VAIO_HP_DAC 0x5
5253static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5254static hda_nid_t vaio_mux_nids[] = { 0x15 };
5255
5256static struct hda_input_mux vaio_mux = {
5257 .num_items = 3,
5258 .items = {
5259 /* { "HP", 0x0 }, */
5260 { "Mic Jack", 0x1 },
5261 { "Internal Mic", 0x2 },
5262 { "PCM", 0x3 },
5263 }
5264};
5265
5266static struct hda_verb vaio_init[] = {
5267 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5268 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5269 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5270 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5271 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ 5609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5274 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5275 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ 5610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5279 {} 5611 {}
5280}; 5612};
5281 5613
5282static struct hda_verb vaio_ar_init[] = { 5614static struct snd_kcontrol_new stac9872_mixer[] = {
5283 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5284 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5285 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5286 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5287/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5290 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5291 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5292/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5296 {}
5297};
5298
5299static struct snd_kcontrol_new vaio_mixer[] = {
5300 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5301 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5302 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5303 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5304 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5305 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 5615 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5306 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 5616 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5307 { 5617 { } /* end */
5308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5309 .name = "Capture Source",
5310 .count = 1,
5311 .info = stac92xx_mux_enum_info,
5312 .get = stac92xx_mux_enum_get,
5313 .put = stac92xx_mux_enum_put,
5314 },
5315 {}
5316}; 5618};
5317 5619
5318static struct snd_kcontrol_new vaio_ar_mixer[] = { 5620static hda_nid_t stac9872_pin_nids[] = {
5319 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT), 5621 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5320 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT), 5622 0x11, 0x13, 0x14,
5321 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5322 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5323 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5324 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5325 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5326 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5327 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5328 {
5329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5330 .name = "Capture Source",
5331 .count = 1,
5332 .info = stac92xx_mux_enum_info,
5333 .get = stac92xx_mux_enum_get,
5334 .put = stac92xx_mux_enum_put,
5335 },
5336 {}
5337}; 5623};
5338 5624
5339static struct hda_codec_ops stac9872_patch_ops = { 5625static hda_nid_t stac9872_adc_nids[] = {
5340 .build_controls = stac92xx_build_controls, 5626 0x8 /*,0x6*/
5341 .build_pcms = stac92xx_build_pcms,
5342 .init = stac92xx_init,
5343 .free = stac92xx_free,
5344#ifdef SND_HDA_NEEDS_RESUME
5345 .resume = stac92xx_resume,
5346#endif
5347}; 5627};
5348 5628
5349static int stac9872_vaio_init(struct hda_codec *codec) 5629static hda_nid_t stac9872_mux_nids[] = {
5350{ 5630 0x15
5351 int err;
5352
5353 err = stac92xx_init(codec);
5354 if (err < 0)
5355 return err;
5356 if (codec->patch_ops.unsol_event)
5357 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5358 return 0;
5359}
5360
5361static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5362{
5363 if (get_pin_presence(codec, 0x0a)) {
5364 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5365 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5366 } else {
5367 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5368 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5369 }
5370}
5371
5372static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5373{
5374 switch (res >> 26) {
5375 case STAC_HP_EVENT:
5376 stac9872_vaio_hp_detect(codec, res);
5377 break;
5378 }
5379}
5380
5381static struct hda_codec_ops stac9872_vaio_patch_ops = {
5382 .build_controls = stac92xx_build_controls,
5383 .build_pcms = stac92xx_build_pcms,
5384 .init = stac9872_vaio_init,
5385 .free = stac92xx_free,
5386 .unsol_event = stac9872_vaio_unsol_event,
5387#ifdef CONFIG_PM
5388 .resume = stac92xx_resume,
5389#endif
5390}; 5631};
5391 5632
5392enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ 5633static unsigned int stac9872_vaio_pin_configs[9] = {
5393 CXD9872RD_VAIO, 5634 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5394 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ 5635 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5395 STAC9872AK_VAIO, 5636 0x90a7013e
5396 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5397 STAC9872K_VAIO,
5398 /* AR Series. id=0x83847664 and subsys=104D1300 */
5399 CXD9872AKD_VAIO,
5400 STAC_9872_MODELS,
5401}; 5637};
5402 5638
5403static const char *stac9872_models[STAC_9872_MODELS] = { 5639static const char *stac9872_models[STAC_9872_MODELS] = {
5404 [CXD9872RD_VAIO] = "vaio", 5640 [STAC_9872_AUTO] = "auto",
5405 [CXD9872AKD_VAIO] = "vaio-ar", 5641 [STAC_9872_VAIO] = "vaio",
5642};
5643
5644static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5645 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5406}; 5646};
5407 5647
5408static struct snd_pci_quirk stac9872_cfg_tbl[] = { 5648static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5409 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 5649 {} /* terminator */
5410 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5411 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5412 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5413 {}
5414}; 5650};
5415 5651
5416static int patch_stac9872(struct hda_codec *codec) 5652static int patch_stac9872(struct hda_codec *codec)
5417{ 5653{
5418 struct sigmatel_spec *spec; 5654 struct sigmatel_spec *spec;
5419 int board_config; 5655 int err;
5420 5656
5421 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5422 stac9872_models,
5423 stac9872_cfg_tbl);
5424 if (board_config < 0)
5425 /* unknown config, let generic-parser do its job... */
5426 return snd_hda_parse_generic_codec(codec);
5427
5428 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5657 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5429 if (spec == NULL) 5658 if (spec == NULL)
5430 return -ENOMEM; 5659 return -ENOMEM;
5431
5432 codec->spec = spec; 5660 codec->spec = spec;
5433 switch (board_config) {
5434 case CXD9872RD_VAIO:
5435 case STAC9872AK_VAIO:
5436 case STAC9872K_VAIO:
5437 spec->mixer = vaio_mixer;
5438 spec->init = vaio_init;
5439 spec->multiout.max_channels = 2;
5440 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5441 spec->multiout.dac_nids = vaio_dacs;
5442 spec->multiout.hp_nid = VAIO_HP_DAC;
5443 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5444 spec->adc_nids = vaio_adcs;
5445 spec->num_pwrs = 0;
5446 spec->input_mux = &vaio_mux;
5447 spec->mux_nids = vaio_mux_nids;
5448 codec->patch_ops = stac9872_vaio_patch_ops;
5449 break;
5450
5451 case CXD9872AKD_VAIO:
5452 spec->mixer = vaio_ar_mixer;
5453 spec->init = vaio_ar_init;
5454 spec->multiout.max_channels = 2;
5455 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5456 spec->multiout.dac_nids = vaio_dacs;
5457 spec->multiout.hp_nid = VAIO_HP_DAC;
5458 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5459 spec->num_pwrs = 0;
5460 spec->adc_nids = vaio_adcs;
5461 spec->input_mux = &vaio_mux;
5462 spec->mux_nids = vaio_mux_nids;
5463 codec->patch_ops = stac9872_patch_ops;
5464 break;
5465 }
5466 5661
5662 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5663 stac9872_models,
5664 stac9872_cfg_tbl);
5665 if (spec->board_config < 0)
5666 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5667 "using BIOS defaults\n");
5668 else
5669 stac92xx_set_config_regs(codec,
5670 stac9872_brd_tbl[spec->board_config]);
5671
5672 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5673 spec->pin_nids = stac9872_pin_nids;
5674 spec->multiout.dac_nids = spec->dac_nids;
5675 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5676 spec->adc_nids = stac9872_adc_nids;
5677 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5678 spec->mux_nids = stac9872_mux_nids;
5679 spec->mixer = stac9872_mixer;
5680 spec->init = stac9872_core_init;
5681
5682 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5683 if (err < 0) {
5684 stac92xx_free(codec);
5685 return -EINVAL;
5686 }
5687 spec->input_mux = &spec->private_imux;
5688 codec->patch_ops = stac92xx_patch_ops;
5467 return 0; 5689 return 0;
5468} 5690}
5469 5691
@@ -5521,6 +5743,7 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5521 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, 5743 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5522 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, 5744 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5523 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, 5745 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5746 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5524 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, 5747 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5525 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, 5748 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5526 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, 5749 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index c761394cbe84..b25a5cc637d6 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1308,16 +1308,13 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
1308 unsigned int def_conf; 1308 unsigned int def_conf;
1309 unsigned char seqassoc; 1309 unsigned char seqassoc;
1310 1310
1311 def_conf = snd_hda_codec_read(codec, nid, 0, 1311 def_conf = snd_hda_codec_get_pincfg(codec, nid);
1312 AC_VERB_GET_CONFIG_DEFAULT, 0);
1313 seqassoc = (unsigned char) get_defcfg_association(def_conf); 1312 seqassoc = (unsigned char) get_defcfg_association(def_conf);
1314 seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); 1313 seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
1315 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) { 1314 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) {
1316 if (seqassoc == 0xff) { 1315 if (seqassoc == 0xff) {
1317 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); 1316 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
1318 snd_hda_codec_write(codec, nid, 0, 1317 snd_hda_codec_set_pincfg(codec, nid, def_conf);
1319 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1320 def_conf >> 24);
1321 } 1318 }
1322 } 1319 }
1323 1320
@@ -1354,7 +1351,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
1354 1351
1355 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1352 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1356 1353
1357 if (spec->autocfg.dig_out_pin) 1354 if (spec->autocfg.dig_outs)
1358 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; 1355 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID;
1359 if (spec->autocfg.dig_in_pin) 1356 if (spec->autocfg.dig_in_pin)
1360 spec->dig_in_nid = VT1708_DIGIN_NID; 1357 spec->dig_in_nid = VT1708_DIGIN_NID;
@@ -1827,7 +1824,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
1827 1824
1828 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1825 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1829 1826
1830 if (spec->autocfg.dig_out_pin) 1827 if (spec->autocfg.dig_outs)
1831 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; 1828 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID;
1832 if (spec->autocfg.dig_in_pin) 1829 if (spec->autocfg.dig_in_pin)
1833 spec->dig_in_nid = VT1709_DIGIN_NID; 1830 spec->dig_in_nid = VT1709_DIGIN_NID;
@@ -2371,7 +2368,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
2371 2368
2372 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2369 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2373 2370
2374 if (spec->autocfg.dig_out_pin) 2371 if (spec->autocfg.dig_outs)
2375 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID; 2372 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID;
2376 if (spec->autocfg.dig_in_pin) 2373 if (spec->autocfg.dig_in_pin)
2377 spec->dig_in_nid = VT1708B_DIGIN_NID; 2374 spec->dig_in_nid = VT1708B_DIGIN_NID;
@@ -2836,7 +2833,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
2836 2833
2837 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2834 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2838 2835
2839 if (spec->autocfg.dig_out_pin) 2836 if (spec->autocfg.dig_outs)
2840 spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID; 2837 spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID;
2841 2838
2842 spec->extra_dig_out_nid = 0x15; 2839 spec->extra_dig_out_nid = 0x15;
@@ -3155,7 +3152,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
3155 3152
3156 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3153 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3157 3154
3158 if (spec->autocfg.dig_out_pin) 3155 if (spec->autocfg.dig_outs)
3159 spec->multiout.dig_out_nid = VT1702_DIGOUT_NID; 3156 spec->multiout.dig_out_nid = VT1702_DIGOUT_NID;
3160 3157
3161 spec->extra_dig_out_nid = 0x1B; 3158 spec->extra_dig_out_nid = 0x1B;
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index bab1c700f497..0d0cdbdb4486 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -458,7 +458,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id)
458 u16 pbkstatus; 458 u16 pbkstatus;
459 struct snd_pcm_substream *substream; 459 struct snd_pcm_substream *substream;
460 pbkstatus = inw(ICEDS(ice, INTSTAT)); 460 pbkstatus = inw(ICEDS(ice, INTSTAT));
461 /* printk("pbkstatus = 0x%x\n", pbkstatus); */ 461 /* printk(KERN_DEBUG "pbkstatus = 0x%x\n", pbkstatus); */
462 for (idx = 0; idx < 6; idx++) { 462 for (idx = 0; idx < 6; idx++) {
463 if ((pbkstatus & (3 << (idx * 2))) == 0) 463 if ((pbkstatus & (3 << (idx * 2))) == 0)
464 continue; 464 continue;
@@ -2533,8 +2533,8 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
2533 if (err < 0) 2533 if (err < 0)
2534 return err; 2534 return err;
2535 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2535 /* check, if we can restrict PCI DMA transfers to 28 bits */
2536 if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || 2536 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2537 pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { 2537 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2538 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2538 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
2539 pci_disable_device(pci); 2539 pci_disable_device(pci);
2540 return -ENXIO; 2540 return -ENXIO;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 7ff36d3f0f44..128510e77a78 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -241,6 +241,8 @@ get_rawmidi_substream(struct snd_ice1712 *ice, unsigned int stream)
241 struct snd_rawmidi_substream, list); 241 struct snd_rawmidi_substream, list);
242} 242}
243 243
244static void enable_midi_irq(struct snd_ice1712 *ice, u8 flag, int enable);
245
244static void vt1724_midi_write(struct snd_ice1712 *ice) 246static void vt1724_midi_write(struct snd_ice1712 *ice)
245{ 247{
246 struct snd_rawmidi_substream *s; 248 struct snd_rawmidi_substream *s;
@@ -254,6 +256,11 @@ static void vt1724_midi_write(struct snd_ice1712 *ice)
254 for (i = 0; i < count; ++i) 256 for (i = 0; i < count; ++i)
255 outb(buffer[i], ICEREG1724(ice, MPU_DATA)); 257 outb(buffer[i], ICEREG1724(ice, MPU_DATA));
256 } 258 }
259 /* mask irq when all bytes have been transmitted.
260 * enabled again in output_trigger when the new data comes in.
261 */
262 enable_midi_irq(ice, VT1724_IRQ_MPU_TX,
263 !snd_rawmidi_transmit_empty(s));
257} 264}
258 265
259static void vt1724_midi_read(struct snd_ice1712 *ice) 266static void vt1724_midi_read(struct snd_ice1712 *ice)
@@ -272,31 +279,34 @@ static void vt1724_midi_read(struct snd_ice1712 *ice)
272 } 279 }
273} 280}
274 281
275static void vt1724_enable_midi_irq(struct snd_rawmidi_substream *substream, 282/* call with ice->reg_lock */
276 u8 flag, int enable) 283static void enable_midi_irq(struct snd_ice1712 *ice, u8 flag, int enable)
277{ 284{
278 struct snd_ice1712 *ice = substream->rmidi->private_data; 285 u8 mask = inb(ICEREG1724(ice, IRQMASK));
279 u8 mask;
280
281 spin_lock_irq(&ice->reg_lock);
282 mask = inb(ICEREG1724(ice, IRQMASK));
283 if (enable) 286 if (enable)
284 mask &= ~flag; 287 mask &= ~flag;
285 else 288 else
286 mask |= flag; 289 mask |= flag;
287 outb(mask, ICEREG1724(ice, IRQMASK)); 290 outb(mask, ICEREG1724(ice, IRQMASK));
291}
292
293static void vt1724_enable_midi_irq(struct snd_rawmidi_substream *substream,
294 u8 flag, int enable)
295{
296 struct snd_ice1712 *ice = substream->rmidi->private_data;
297
298 spin_lock_irq(&ice->reg_lock);
299 enable_midi_irq(ice, flag, enable);
288 spin_unlock_irq(&ice->reg_lock); 300 spin_unlock_irq(&ice->reg_lock);
289} 301}
290 302
291static int vt1724_midi_output_open(struct snd_rawmidi_substream *s) 303static int vt1724_midi_output_open(struct snd_rawmidi_substream *s)
292{ 304{
293 vt1724_enable_midi_irq(s, VT1724_IRQ_MPU_TX, 1);
294 return 0; 305 return 0;
295} 306}
296 307
297static int vt1724_midi_output_close(struct snd_rawmidi_substream *s) 308static int vt1724_midi_output_close(struct snd_rawmidi_substream *s)
298{ 309{
299 vt1724_enable_midi_irq(s, VT1724_IRQ_MPU_TX, 0);
300 return 0; 310 return 0;
301} 311}
302 312
@@ -311,6 +321,7 @@ static void vt1724_midi_output_trigger(struct snd_rawmidi_substream *s, int up)
311 vt1724_midi_write(ice); 321 vt1724_midi_write(ice);
312 } else { 322 } else {
313 ice->midi_output = 0; 323 ice->midi_output = 0;
324 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
314 } 325 }
315 spin_unlock_irqrestore(&ice->reg_lock, flags); 326 spin_unlock_irqrestore(&ice->reg_lock, flags);
316} 327}
@@ -320,6 +331,7 @@ static void vt1724_midi_output_drain(struct snd_rawmidi_substream *s)
320 struct snd_ice1712 *ice = s->rmidi->private_data; 331 struct snd_ice1712 *ice = s->rmidi->private_data;
321 unsigned long timeout; 332 unsigned long timeout;
322 333
334 vt1724_enable_midi_irq(s, VT1724_IRQ_MPU_TX, 0);
323 /* 32 bytes should be transmitted in less than about 12 ms */ 335 /* 32 bytes should be transmitted in less than about 12 ms */
324 timeout = jiffies + msecs_to_jiffies(15); 336 timeout = jiffies + msecs_to_jiffies(15);
325 do { 337 do {
@@ -389,24 +401,24 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
389 status &= status_mask; 401 status &= status_mask;
390 if (status == 0) 402 if (status == 0)
391 break; 403 break;
404 spin_lock(&ice->reg_lock);
392 if (++timeout > 10) { 405 if (++timeout > 10) {
393 status = inb(ICEREG1724(ice, IRQSTAT)); 406 status = inb(ICEREG1724(ice, IRQSTAT));
394 printk(KERN_ERR "ice1724: Too long irq loop, " 407 printk(KERN_ERR "ice1724: Too long irq loop, "
395 "status = 0x%x\n", status); 408 "status = 0x%x\n", status);
396 if (status & VT1724_IRQ_MPU_TX) { 409 if (status & VT1724_IRQ_MPU_TX) {
397 printk(KERN_ERR "ice1724: Disabling MPU_TX\n"); 410 printk(KERN_ERR "ice1724: Disabling MPU_TX\n");
398 outb(inb(ICEREG1724(ice, IRQMASK)) | 411 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
399 VT1724_IRQ_MPU_TX,
400 ICEREG1724(ice, IRQMASK));
401 } 412 }
413 spin_unlock(&ice->reg_lock);
402 break; 414 break;
403 } 415 }
404 handled = 1; 416 handled = 1;
405 if (status & VT1724_IRQ_MPU_TX) { 417 if (status & VT1724_IRQ_MPU_TX) {
406 spin_lock(&ice->reg_lock);
407 if (ice->midi_output) 418 if (ice->midi_output)
408 vt1724_midi_write(ice); 419 vt1724_midi_write(ice);
409 spin_unlock(&ice->reg_lock); 420 else
421 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
410 /* Due to mysterical reasons, MPU_TX is always 422 /* Due to mysterical reasons, MPU_TX is always
411 * generated (and can't be cleared) when a PCM 423 * generated (and can't be cleared) when a PCM
412 * playback is going. So let's ignore at the 424 * playback is going. So let's ignore at the
@@ -415,15 +427,14 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
415 status_mask &= ~VT1724_IRQ_MPU_TX; 427 status_mask &= ~VT1724_IRQ_MPU_TX;
416 } 428 }
417 if (status & VT1724_IRQ_MPU_RX) { 429 if (status & VT1724_IRQ_MPU_RX) {
418 spin_lock(&ice->reg_lock);
419 if (ice->midi_input) 430 if (ice->midi_input)
420 vt1724_midi_read(ice); 431 vt1724_midi_read(ice);
421 else 432 else
422 vt1724_midi_clear_rx(ice); 433 vt1724_midi_clear_rx(ice);
423 spin_unlock(&ice->reg_lock);
424 } 434 }
425 /* ack MPU irq */ 435 /* ack MPU irq */
426 outb(status, ICEREG1724(ice, IRQSTAT)); 436 outb(status, ICEREG1724(ice, IRQSTAT));
437 spin_unlock(&ice->reg_lock);
427 if (status & VT1724_IRQ_MTPCM) { 438 if (status & VT1724_IRQ_MTPCM) {
428 /* 439 /*
429 * Multi-track PCM 440 * Multi-track PCM
@@ -745,7 +756,14 @@ static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
745 756
746 spin_unlock_irq(&ice->reg_lock); 757 spin_unlock_irq(&ice->reg_lock);
747 758
748 /* printk("pro prepare: ch = %d, addr = 0x%x, buffer = 0x%x, period = 0x%x\n", substream->runtime->channels, (unsigned int)substream->runtime->dma_addr, snd_pcm_lib_buffer_bytes(substream), snd_pcm_lib_period_bytes(substream)); */ 759 /*
760 printk(KERN_DEBUG "pro prepare: ch = %d, addr = 0x%x, "
761 "buffer = 0x%x, period = 0x%x\n",
762 substream->runtime->channels,
763 (unsigned int)substream->runtime->dma_addr,
764 snd_pcm_lib_buffer_bytes(substream),
765 snd_pcm_lib_period_bytes(substream));
766 */
749 return 0; 767 return 0;
750} 768}
751 769
@@ -2122,7 +2140,9 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
2122 wait_i2c_busy(ice); 2140 wait_i2c_busy(ice);
2123 val = inb(ICEREG1724(ice, I2C_DATA)); 2141 val = inb(ICEREG1724(ice, I2C_DATA));
2124 mutex_unlock(&ice->i2c_mutex); 2142 mutex_unlock(&ice->i2c_mutex);
2125 /* printk("i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); */ 2143 /*
2144 printk(KERN_DEBUG "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
2145 */
2126 return val; 2146 return val;
2127} 2147}
2128 2148
@@ -2131,7 +2151,9 @@ void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
2131{ 2151{
2132 mutex_lock(&ice->i2c_mutex); 2152 mutex_lock(&ice->i2c_mutex);
2133 wait_i2c_busy(ice); 2153 wait_i2c_busy(ice);
2134 /* printk("i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); */ 2154 /*
2155 printk(KERN_DEBUG "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
2156 */
2135 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 2157 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
2136 outb(data, ICEREG1724(ice, I2C_DATA)); 2158 outb(data, ICEREG1724(ice, I2C_DATA));
2137 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR)); 2159 outb(dev | VT1724_I2C_WRITE, ICEREG1724(ice, I2C_DEV_ADDR));
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index c51659b9caf6..fd948bfd9aef 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -345,8 +345,9 @@ static int juli_mute_put(struct snd_kcontrol *kcontrol,
345 new_gpio = old_gpio & 345 new_gpio = old_gpio &
346 ~((unsigned int) kcontrol->private_value); 346 ~((unsigned int) kcontrol->private_value);
347 } 347 }
348 /* printk("JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, \ 348 /* printk(KERN_DEBUG
349 new_gpio 0x%x\n", 349 "JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, "
350 "new_gpio 0x%x\n",
350 (unsigned int)ucontrol->value.integer.value[0], old_gpio, 351 (unsigned int)ucontrol->value.integer.value[0], old_gpio,
351 new_gpio); */ 352 new_gpio); */
352 if (old_gpio != new_gpio) { 353 if (old_gpio != new_gpio) {
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 48d3679292a7..2a8e5cd8f2d8 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -133,8 +133,10 @@ static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
133 idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME; 133 idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
134 /* due to possible conflicts with stac9460_set_rate_val, mutexing */ 134 /* due to possible conflicts with stac9460_set_rate_val, mutexing */
135 mutex_lock(&spec->mute_mutex); 135 mutex_lock(&spec->mute_mutex);
136 /*printk("Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx, 136 /*
137 ucontrol->value.integer.value[0]);*/ 137 printk(KERN_DEBUG "Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx,
138 ucontrol->value.integer.value[0]);
139 */
138 change = stac9460_dac_mute(ice, idx, ucontrol->value.integer.value[0]); 140 change = stac9460_dac_mute(ice, idx, ucontrol->value.integer.value[0]);
139 mutex_unlock(&spec->mute_mutex); 141 mutex_unlock(&spec->mute_mutex);
140 return change; 142 return change;
@@ -185,7 +187,10 @@ static int stac9460_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
185 change = (ovol != nvol); 187 change = (ovol != nvol);
186 if (change) { 188 if (change) {
187 ovol = (0x7f - nvol) | (tmp & 0x80); 189 ovol = (0x7f - nvol) | (tmp & 0x80);
188 /*printk("DAC Volume: reg 0x%02x: 0x%02x\n", idx, ovol);*/ 190 /*
191 printk(KERN_DEBUG "DAC Volume: reg 0x%02x: 0x%02x\n",
192 idx, ovol);
193 */
189 stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80)); 194 stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
190 } 195 }
191 return change; 196 return change;
@@ -344,7 +349,7 @@ static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
344 for (idx = 0; idx < 7 ; ++idx) 349 for (idx = 0; idx < 7 ; ++idx)
345 changed[idx] = stac9460_dac_mute(ice, 350 changed[idx] = stac9460_dac_mute(ice,
346 STAC946X_MASTER_VOLUME + idx, 0); 351 STAC946X_MASTER_VOLUME + idx, 0);
347 /*printk("Rate change: %d, new MC: 0x%02x\n", rate, new);*/ 352 /*printk(KERN_DEBUG "Rate change: %d, new MC: 0x%02x\n", rate, new);*/
348 stac9460_put(ice, STAC946X_MASTER_CLOCKING, new); 353 stac9460_put(ice, STAC946X_MASTER_CLOCKING, new);
349 udelay(10); 354 udelay(10);
350 /* unmuting - only originally unmuted dacs - 355 /* unmuting - only originally unmuted dacs -
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 671ff65db029..173bebf9f51d 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -355,6 +355,9 @@ struct ichdev {
355 unsigned int fragsize1; 355 unsigned int fragsize1;
356 unsigned int position; 356 unsigned int position;
357 unsigned int pos_shift; 357 unsigned int pos_shift;
358 unsigned int last_pos;
359 unsigned long last_pos_jiffies;
360 unsigned int jiffy_to_bytes;
358 int frags; 361 int frags;
359 int lvi; 362 int lvi;
360 int lvi_frag; 363 int lvi_frag;
@@ -617,7 +620,7 @@ static int snd_intel8x0_ali_codec_semaphore(struct intel8x0 *chip)
617 int time = 100; 620 int time = 100;
618 if (chip->buggy_semaphore) 621 if (chip->buggy_semaphore)
619 return 0; /* just ignore ... */ 622 return 0; /* just ignore ... */
620 while (time-- && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) 623 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
621 udelay(1); 624 udelay(1);
622 if (! time && ! chip->in_ac97_init) 625 if (! time && ! chip->in_ac97_init)
623 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n"); 626 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n");
@@ -689,7 +692,7 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
689 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ 692 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
690 ichdev->fragsize >> ichdev->pos_shift); 693 ichdev->fragsize >> ichdev->pos_shift);
691#if 0 694#if 0
692 printk("bdbar[%i] = 0x%x [0x%x]\n", 695 printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
693 idx + 0, bdbar[idx + 0], bdbar[idx + 1]); 696 idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
694#endif 697#endif
695 } 698 }
@@ -701,8 +704,10 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
701 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; 704 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
702 ichdev->position = 0; 705 ichdev->position = 0;
703#if 0 706#if 0
704 printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n", 707 printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
705 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1); 708 "period_size1 = 0x%x\n",
709 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
710 ichdev->fragsize1);
706#endif 711#endif
707 /* clear interrupts */ 712 /* clear interrupts */
708 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); 713 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
@@ -768,7 +773,8 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
768 ichdev->lvi_frag %= ichdev->frags; 773 ichdev->lvi_frag %= ichdev->frags;
769 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1); 774 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
770#if 0 775#if 0
771 printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", 776 printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, "
777 "all = 0x%x, 0x%x\n",
772 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], 778 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
773 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), 779 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
774 inl(port + 4), inb(port + ICH_REG_OFF_CR)); 780 inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@ -835,7 +841,10 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd
835 ichdev->suspended = 0; 841 ichdev->suspended = 0;
836 /* fallthru */ 842 /* fallthru */
837 case SNDRV_PCM_TRIGGER_START: 843 case SNDRV_PCM_TRIGGER_START:
844 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
838 val = ICH_IOCE | ICH_STARTBM; 845 val = ICH_IOCE | ICH_STARTBM;
846 ichdev->last_pos = ichdev->position;
847 ichdev->last_pos_jiffies = jiffies;
839 break; 848 break;
840 case SNDRV_PCM_TRIGGER_SUSPEND: 849 case SNDRV_PCM_TRIGGER_SUSPEND:
841 ichdev->suspended = 1; 850 ichdev->suspended = 1;
@@ -846,9 +855,6 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd
846 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 855 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
847 val = ICH_IOCE; 856 val = ICH_IOCE;
848 break; 857 break;
849 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
850 val = ICH_IOCE | ICH_STARTBM;
851 break;
852 default: 858 default:
853 return -EINVAL; 859 return -EINVAL;
854 } 860 }
@@ -1042,6 +1048,7 @@ static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream)
1042 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; 1048 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
1043 } 1049 }
1044 snd_intel8x0_setup_periods(chip, ichdev); 1050 snd_intel8x0_setup_periods(chip, ichdev);
1051 ichdev->jiffy_to_bytes = (runtime->rate * 4 * ichdev->pos_shift) / HZ;
1045 return 0; 1052 return 0;
1046} 1053}
1047 1054
@@ -1050,7 +1057,7 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs
1050 struct intel8x0 *chip = snd_pcm_substream_chip(substream); 1057 struct intel8x0 *chip = snd_pcm_substream_chip(substream);
1051 struct ichdev *ichdev = get_ichdev(substream); 1058 struct ichdev *ichdev = get_ichdev(substream);
1052 size_t ptr1, ptr; 1059 size_t ptr1, ptr;
1053 int civ, timeout = 100; 1060 int civ, timeout = 10;
1054 unsigned int position; 1061 unsigned int position;
1055 1062
1056 spin_lock(&chip->reg_lock); 1063 spin_lock(&chip->reg_lock);
@@ -1066,9 +1073,19 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs
1066 ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) 1073 ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
1067 break; 1074 break;
1068 } while (timeout--); 1075 } while (timeout--);
1069 ptr1 <<= ichdev->pos_shift; 1076 if (ptr1 != 0) {
1070 ptr = ichdev->fragsize1 - ptr1; 1077 ptr1 <<= ichdev->pos_shift;
1071 ptr += position; 1078 ptr = ichdev->fragsize1 - ptr1;
1079 ptr += position;
1080 ichdev->last_pos = ptr;
1081 ichdev->last_pos_jiffies = jiffies;
1082 } else {
1083 ptr1 = jiffies - ichdev->last_pos_jiffies;
1084 if (ptr1)
1085 ptr1 -= 1;
1086 ptr = ichdev->last_pos + ptr1 * ichdev->jiffy_to_bytes;
1087 ptr %= ichdev->size;
1088 }
1072 spin_unlock(&chip->reg_lock); 1089 spin_unlock(&chip->reg_lock);
1073 if (ptr >= ichdev->size) 1090 if (ptr >= ichdev->size)
1074 return 0; 1091 return 0;
@@ -1837,6 +1854,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1837 }, 1854 },
1838 { 1855 {
1839 .subvendor = 0x1028, 1856 .subvendor = 0x1028,
1857 .subdevice = 0x016a,
1858 .name = "Dell Inspiron 8600", /* STAC9750/51 */
1859 .type = AC97_TUNE_HP_ONLY
1860 },
1861 {
1862 .subvendor = 0x1028,
1840 .subdevice = 0x0186, 1863 .subdevice = 0x0186,
1841 .name = "Dell Latitude D810", /* cf. Malone #41015 */ 1864 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1842 .type = AC97_TUNE_HP_MUTE_LED 1865 .type = AC97_TUNE_HP_MUTE_LED
@@ -1879,12 +1902,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1879 }, 1902 },
1880 { 1903 {
1881 .subvendor = 0x103c, 1904 .subvendor = 0x103c,
1882 .subdevice = 0x0934,
1883 .name = "HP nx8220",
1884 .type = AC97_TUNE_MUTE_LED
1885 },
1886 {
1887 .subvendor = 0x103c,
1888 .subdevice = 0x129d, 1905 .subdevice = 0x129d,
1889 .name = "HP xw8000", 1906 .name = "HP xw8000",
1890 .type = AC97_TUNE_HP_ONLY 1907 .type = AC97_TUNE_HP_ONLY
@@ -2287,23 +2304,23 @@ static void do_ali_reset(struct intel8x0 *chip)
2287 iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000); 2304 iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000);
2288} 2305}
2289 2306
2290static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing) 2307#ifdef CONFIG_SND_AC97_POWER_SAVE
2291{ 2308static struct snd_pci_quirk ich_chip_reset_mode[] = {
2292 unsigned long end_time; 2309 SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1),
2293 unsigned int cnt, status, nstatus; 2310 { } /* end */
2294 2311};
2295 /* put logic to right state */
2296 /* first clear status bits */
2297 status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
2298 if (chip->device_type == DEVICE_NFORCE)
2299 status |= ICH_NVSPINT;
2300 cnt = igetdword(chip, ICHREG(GLOB_STA));
2301 iputdword(chip, ICHREG(GLOB_STA), cnt & status);
2302 2312
2313static int snd_intel8x0_ich_chip_cold_reset(struct intel8x0 *chip)
2314{
2315 unsigned int cnt;
2303 /* ACLink on, 2 channels */ 2316 /* ACLink on, 2 channels */
2317
2318 if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
2319 return -EIO;
2320
2304 cnt = igetdword(chip, ICHREG(GLOB_CNT)); 2321 cnt = igetdword(chip, ICHREG(GLOB_CNT));
2305 cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK); 2322 cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
2306#ifdef CONFIG_SND_AC97_POWER_SAVE 2323
2307 /* do cold reset - the full ac97 powerdown may leave the controller 2324 /* do cold reset - the full ac97 powerdown may leave the controller
2308 * in a warm state but actually it cannot communicate with the codec. 2325 * in a warm state but actually it cannot communicate with the codec.
2309 */ 2326 */
@@ -2312,22 +2329,58 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
2312 udelay(10); 2329 udelay(10);
2313 iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD); 2330 iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD);
2314 msleep(1); 2331 msleep(1);
2332 return 0;
2333}
2334#define snd_intel8x0_ich_chip_can_cold_reset(chip) \
2335 (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
2315#else 2336#else
2337#define snd_intel8x0_ich_chip_cold_reset(chip) 0
2338#define snd_intel8x0_ich_chip_can_cold_reset(chip) (0)
2339#endif
2340
2341static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
2342{
2343 unsigned long end_time;
2344 unsigned int cnt;
2345 /* ACLink on, 2 channels */
2346 cnt = igetdword(chip, ICHREG(GLOB_CNT));
2347 cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
2316 /* finish cold or do warm reset */ 2348 /* finish cold or do warm reset */
2317 cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM; 2349 cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
2318 iputdword(chip, ICHREG(GLOB_CNT), cnt); 2350 iputdword(chip, ICHREG(GLOB_CNT), cnt);
2319 end_time = (jiffies + (HZ / 4)) + 1; 2351 end_time = (jiffies + (HZ / 4)) + 1;
2320 do { 2352 do {
2321 if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0) 2353 if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
2322 goto __ok; 2354 return 0;
2323 schedule_timeout_uninterruptible(1); 2355 schedule_timeout_uninterruptible(1);
2324 } while (time_after_eq(end_time, jiffies)); 2356 } while (time_after_eq(end_time, jiffies));
2325 snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", 2357 snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
2326 igetdword(chip, ICHREG(GLOB_CNT))); 2358 igetdword(chip, ICHREG(GLOB_CNT)));
2327 return -EIO; 2359 return -EIO;
2360}
2361
2362static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
2363{
2364 unsigned long end_time;
2365 unsigned int status, nstatus;
2366 unsigned int cnt;
2367 int err;
2368
2369 /* put logic to right state */
2370 /* first clear status bits */
2371 status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
2372 if (chip->device_type == DEVICE_NFORCE)
2373 status |= ICH_NVSPINT;
2374 cnt = igetdword(chip, ICHREG(GLOB_STA));
2375 iputdword(chip, ICHREG(GLOB_STA), cnt & status);
2376
2377 if (snd_intel8x0_ich_chip_can_cold_reset(chip))
2378 err = snd_intel8x0_ich_chip_cold_reset(chip);
2379 else
2380 err = snd_intel8x0_ich_chip_reset(chip);
2381 if (err < 0)
2382 return err;
2328 2383
2329 __ok:
2330#endif
2331 if (probing) { 2384 if (probing) {
2332 /* wait for any codec ready status. 2385 /* wait for any codec ready status.
2333 * Once it becomes ready it should remain ready 2386 * Once it becomes ready it should remain ready
@@ -2622,12 +2675,14 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2622 struct snd_pcm_substream *subs; 2675 struct snd_pcm_substream *subs;
2623 struct ichdev *ichdev; 2676 struct ichdev *ichdev;
2624 unsigned long port; 2677 unsigned long port;
2625 unsigned long pos, t; 2678 unsigned long pos, pos1, t;
2626 struct timeval start_time, stop_time; 2679 int civ, timeout = 1000, attempt = 1;
2680 struct timespec start_time, stop_time;
2627 2681
2628 if (chip->ac97_bus->clock != 48000) 2682 if (chip->ac97_bus->clock != 48000)
2629 return; /* specified in module option */ 2683 return; /* specified in module option */
2630 2684
2685 __again:
2631 subs = chip->pcm[0]->streams[0].substream; 2686 subs = chip->pcm[0]->streams[0].substream;
2632 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { 2687 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
2633 snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); 2688 snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n");
@@ -2635,7 +2690,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2635 } 2690 }
2636 ichdev = &chip->ichd[ICHD_PCMOUT]; 2691 ichdev = &chip->ichd[ICHD_PCMOUT];
2637 ichdev->physbuf = subs->dma_buffer.addr; 2692 ichdev->physbuf = subs->dma_buffer.addr;
2638 ichdev->size = chip->ichd[ICHD_PCMOUT].fragsize = INTEL8X0_TESTBUF_SIZE; 2693 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE;
2639 ichdev->substream = NULL; /* don't process interrupts */ 2694 ichdev->substream = NULL; /* don't process interrupts */
2640 2695
2641 /* set rate */ 2696 /* set rate */
@@ -2654,16 +2709,31 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2654 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); 2709 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE);
2655 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); 2710 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
2656 } 2711 }
2657 do_gettimeofday(&start_time); 2712 do_posix_clock_monotonic_gettime(&start_time);
2658 spin_unlock_irq(&chip->reg_lock); 2713 spin_unlock_irq(&chip->reg_lock);
2659 msleep(50); 2714 msleep(50);
2660 spin_lock_irq(&chip->reg_lock); 2715 spin_lock_irq(&chip->reg_lock);
2661 /* check the position */ 2716 /* check the position */
2662 pos = ichdev->fragsize1; 2717 do {
2663 pos -= igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << ichdev->pos_shift; 2718 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
2664 pos += ichdev->position; 2719 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
2720 if (pos1 == 0) {
2721 udelay(10);
2722 continue;
2723 }
2724 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
2725 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
2726 break;
2727 } while (timeout--);
2728 if (pos1 == 0) { /* oops, this value is not reliable */
2729 pos = 0;
2730 } else {
2731 pos = ichdev->fragsize1;
2732 pos -= pos1 << ichdev->pos_shift;
2733 pos += ichdev->position;
2734 }
2665 chip->in_measurement = 0; 2735 chip->in_measurement = 0;
2666 do_gettimeofday(&stop_time); 2736 do_posix_clock_monotonic_gettime(&stop_time);
2667 /* stop */ 2737 /* stop */
2668 if (chip->device_type == DEVICE_ALI) { 2738 if (chip->device_type == DEVICE_ALI) {
2669 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); 2739 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16));
@@ -2678,22 +2748,42 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2678 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); 2748 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS);
2679 spin_unlock_irq(&chip->reg_lock); 2749 spin_unlock_irq(&chip->reg_lock);
2680 2750
2751 if (pos == 0) {
2752 snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
2753 __retry:
2754 if (attempt < 3) {
2755 msleep(300);
2756 attempt++;
2757 goto __again;
2758 }
2759 goto __end;
2760 }
2761
2762 pos /= 4;
2681 t = stop_time.tv_sec - start_time.tv_sec; 2763 t = stop_time.tv_sec - start_time.tv_sec;
2682 t *= 1000000; 2764 t *= 1000000;
2683 t += stop_time.tv_usec - start_time.tv_usec; 2765 t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
2684 printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t); 2766 printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
2685 if (t == 0) { 2767 if (t == 0) {
2686 snd_printk(KERN_ERR "?? calculation error..\n"); 2768 snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
2687 return; 2769 goto __retry;
2688 } 2770 }
2689 pos = (pos / 4) * 1000; 2771 pos *= 1000;
2690 pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; 2772 pos = (pos / t) * 1000 + ((pos % t) * 1000) / t;
2691 if (pos < 40000 || pos >= 60000) 2773 if (pos < 40000 || pos >= 60000) {
2692 /* abnormal value. hw problem? */ 2774 /* abnormal value. hw problem? */
2693 printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); 2775 printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos);
2776 goto __retry;
2777 } else if (pos > 40500 && pos < 41500)
2778 /* first exception - 41000Hz reference clock */
2779 chip->ac97_bus->clock = 41000;
2780 else if (pos > 43600 && pos < 44600)
2781 /* second exception - 44100HZ reference clock */
2782 chip->ac97_bus->clock = 44100;
2694 else if (pos < 47500 || pos > 48500) 2783 else if (pos < 47500 || pos > 48500)
2695 /* not 48000Hz, tuning the clock.. */ 2784 /* not 48000Hz, tuning the clock.. */
2696 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; 2785 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
2786 __end:
2697 printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock); 2787 printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
2698 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); 2788 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
2699} 2789}
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 33a843c19316..6ec0fc50d6be 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -411,7 +411,10 @@ static void snd_intel8x0_setup_periods(struct intel8x0m *chip, struct ichdev *ic
411 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size)); 411 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size));
412 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ 412 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
413 ichdev->fragsize >> chip->pcm_pos_shift); 413 ichdev->fragsize >> chip->pcm_pos_shift);
414 // printk("bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]); 414 /*
415 printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
416 idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
417 */
415 } 418 }
416 ichdev->frags = ichdev->size / ichdev->fragsize; 419 ichdev->frags = ichdev->size / ichdev->fragsize;
417 } 420 }
@@ -421,8 +424,10 @@ static void snd_intel8x0_setup_periods(struct intel8x0m *chip, struct ichdev *ic
421 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; 424 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
422 ichdev->position = 0; 425 ichdev->position = 0;
423#if 0 426#if 0
424 printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n", 427 printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
425 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1); 428 "period_size1 = 0x%x\n",
429 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
430 ichdev->fragsize1);
426#endif 431#endif
427 /* clear interrupts */ 432 /* clear interrupts */
428 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); 433 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
@@ -465,7 +470,8 @@ static inline void snd_intel8x0_update(struct intel8x0m *chip, struct ichdev *ic
465 ichdev->lvi_frag * 470 ichdev->lvi_frag *
466 ichdev->fragsize1); 471 ichdev->fragsize1);
467#if 0 472#if 0
468 printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", 473 printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], "
474 "prefetch = %i, all = 0x%x, 0x%x\n",
469 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], 475 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
470 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), 476 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
471 inl(port + 4), inb(port + ICH_REG_OFF_CR)); 477 inl(port + 4), inb(port + ICH_REG_OFF_CR));
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 8b79969034be..7cc38a11e997 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1238,7 +1238,8 @@ static struct snd_pcm_hardware snd_korg1212_playback_info =
1238{ 1238{
1239 .info = (SNDRV_PCM_INFO_MMAP | 1239 .info = (SNDRV_PCM_INFO_MMAP |
1240 SNDRV_PCM_INFO_MMAP_VALID | 1240 SNDRV_PCM_INFO_MMAP_VALID |
1241 SNDRV_PCM_INFO_INTERLEAVED), 1241 SNDRV_PCM_INFO_INTERLEAVED |
1242 SNDRV_PCM_INFO_BATCH),
1242 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1243 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1243 .rates = (SNDRV_PCM_RATE_44100 | 1244 .rates = (SNDRV_PCM_RATE_44100 |
1244 SNDRV_PCM_RATE_48000), 1245 SNDRV_PCM_RATE_48000),
@@ -1258,7 +1259,8 @@ static struct snd_pcm_hardware snd_korg1212_capture_info =
1258{ 1259{
1259 .info = (SNDRV_PCM_INFO_MMAP | 1260 .info = (SNDRV_PCM_INFO_MMAP |
1260 SNDRV_PCM_INFO_MMAP_VALID | 1261 SNDRV_PCM_INFO_MMAP_VALID |
1261 SNDRV_PCM_INFO_INTERLEAVED), 1262 SNDRV_PCM_INFO_INTERLEAVED |
1263 SNDRV_PCM_INFO_BATCH),
1262 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1264 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1263 .rates = (SNDRV_PCM_RATE_44100 | 1265 .rates = (SNDRV_PCM_RATE_44100 |
1264 SNDRV_PCM_RATE_48000), 1266 SNDRV_PCM_RATE_48000),
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 70141548f251..75283fbb4b3f 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2530,8 +2530,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2530 return -EIO; 2530 return -EIO;
2531 2531
2532 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2532 /* check, if we can restrict PCI DMA transfers to 28 bits */
2533 if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || 2533 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2534 pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { 2534 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2535 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2535 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
2536 pci_disable_device(pci); 2536 pci_disable_device(pci);
2537 return -ENXIO; 2537 return -ENXIO;
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index bfc19e36c4b6..82bc5b9e7629 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -607,6 +607,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
607 /* set the format to the board */ 607 /* set the format to the board */
608 err = mixart_set_format(stream, format); 608 err = mixart_set_format(stream, format);
609 if(err < 0) { 609 if(err < 0) {
610 mutex_unlock(&mgr->setup_mutex);
610 return err; 611 return err;
611 } 612 }
612 613
@@ -1290,7 +1291,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
1290 pci_set_master(pci); 1291 pci_set_master(pci);
1291 1292
1292 /* check if we can restrict PCI DMA transfers to 32 bits */ 1293 /* check if we can restrict PCI DMA transfers to 32 bits */
1293 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) { 1294 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1294 snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n"); 1295 snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
1295 pci_disable_device(pci); 1296 pci_disable_device(pci);
1296 return -ENXIO; 1297 return -ENXIO;
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index 3782b52bc0e8..4cf4cd8c939c 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -345,8 +345,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
345 status_daught = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_DXLX_STATUS_OFFSET )); 345 status_daught = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_DXLX_STATUS_OFFSET ));
346 346
347 /* motherboard xilinx status 5 will say that the board is performing a reset */ 347 /* motherboard xilinx status 5 will say that the board is performing a reset */
348 if( status_xilinx == 5 ) { 348 if (status_xilinx == 5) {
349 snd_printk( KERN_ERR "miXart is resetting !\n"); 349 snd_printk(KERN_ERR "miXart is resetting !\n");
350 return -EAGAIN; /* try again later */ 350 return -EAGAIN; /* try again later */
351 } 351 }
352 352
@@ -354,13 +354,14 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
354 case MIXART_MOTHERBOARD_XLX_INDEX: 354 case MIXART_MOTHERBOARD_XLX_INDEX:
355 355
356 /* xilinx already loaded ? */ 356 /* xilinx already loaded ? */
357 if( status_xilinx == 4 ) { 357 if (status_xilinx == 4) {
358 snd_printk( KERN_DEBUG "xilinx is already loaded !\n"); 358 snd_printk(KERN_DEBUG "xilinx is already loaded !\n");
359 return 0; 359 return 0;
360 } 360 }
361 /* the status should be 0 == "idle" */ 361 /* the status should be 0 == "idle" */
362 if( status_xilinx != 0 ) { 362 if (status_xilinx != 0) {
363 snd_printk( KERN_ERR "xilinx load error ! status = %d\n", status_xilinx); 363 snd_printk(KERN_ERR "xilinx load error ! status = %d\n",
364 status_xilinx);
364 return -EIO; /* modprob -r may help ? */ 365 return -EIO; /* modprob -r may help ? */
365 } 366 }
366 367
@@ -389,21 +390,23 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
389 390
390 case MIXART_MOTHERBOARD_ELF_INDEX: 391 case MIXART_MOTHERBOARD_ELF_INDEX:
391 392
392 if( status_elf == 4 ) { 393 if (status_elf == 4) {
393 snd_printk( KERN_DEBUG "elf file already loaded !\n"); 394 snd_printk(KERN_DEBUG "elf file already loaded !\n");
394 return 0; 395 return 0;
395 } 396 }
396 397
397 /* the status should be 0 == "idle" */ 398 /* the status should be 0 == "idle" */
398 if( status_elf != 0 ) { 399 if (status_elf != 0) {
399 snd_printk( KERN_ERR "elf load error ! status = %d\n", status_elf); 400 snd_printk(KERN_ERR "elf load error ! status = %d\n",
401 status_elf);
400 return -EIO; /* modprob -r may help ? */ 402 return -EIO; /* modprob -r may help ? */
401 } 403 }
402 404
403 /* wait for xilinx status == 4 */ 405 /* wait for xilinx status == 4 */
404 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */ 406 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */
405 if (err < 0) { 407 if (err < 0) {
406 snd_printk( KERN_ERR "xilinx was not loaded or could not be started\n"); 408 snd_printk(KERN_ERR "xilinx was not loaded or "
409 "could not be started\n");
407 return err; 410 return err;
408 } 411 }
409 412
@@ -424,7 +427,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
424 /* wait for elf status == 4 */ 427 /* wait for elf status == 4 */
425 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */ 428 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */
426 if (err < 0) { 429 if (err < 0) {
427 snd_printk( KERN_ERR "elf could not be started\n"); 430 snd_printk(KERN_ERR "elf could not be started\n");
428 return err; 431 return err;
429 } 432 }
430 433
@@ -437,15 +440,16 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
437 default: 440 default:
438 441
439 /* elf and xilinx should be loaded */ 442 /* elf and xilinx should be loaded */
440 if( (status_elf != 4) || (status_xilinx != 4) ) { 443 if (status_elf != 4 || status_xilinx != 4) {
441 printk( KERN_ERR "xilinx or elf not successfully loaded\n"); 444 printk(KERN_ERR "xilinx or elf not "
445 "successfully loaded\n");
442 return -EIO; /* modprob -r may help ? */ 446 return -EIO; /* modprob -r may help ? */
443 } 447 }
444 448
445 /* wait for daughter detection != 0 */ 449 /* wait for daughter detection != 0 */
446 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */ 450 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */
447 if (err < 0) { 451 if (err < 0) {
448 snd_printk( KERN_ERR "error starting elf file\n"); 452 snd_printk(KERN_ERR "error starting elf file\n");
449 return err; 453 return err;
450 } 454 }
451 455
@@ -460,8 +464,9 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
460 return -EINVAL; 464 return -EINVAL;
461 465
462 /* daughter should be idle */ 466 /* daughter should be idle */
463 if( status_daught != 0 ) { 467 if (status_daught != 0) {
464 printk( KERN_ERR "daughter load error ! status = %d\n", status_daught); 468 printk(KERN_ERR "daughter load error ! status = %d\n",
469 status_daught);
465 return -EIO; /* modprob -r may help ? */ 470 return -EIO; /* modprob -r may help ? */
466 } 471 }
467 472
@@ -480,7 +485,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
480 /* wait for status == 2 */ 485 /* wait for status == 2 */
481 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */ 486 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */
482 if (err < 0) { 487 if (err < 0) {
483 snd_printk( KERN_ERR "daughter board load error\n"); 488 snd_printk(KERN_ERR "daughter board load error\n");
484 return err; 489 return err;
485 } 490 }
486 491
@@ -502,7 +507,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
502 /* wait for daughter status == 3 */ 507 /* wait for daughter status == 3 */
503 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */ 508 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */
504 if (err < 0) { 509 if (err < 0) {
505 snd_printk( KERN_ERR "daughter board could not be initialised\n"); 510 snd_printk(KERN_ERR
511 "daughter board could not be initialised\n");
506 return err; 512 return err;
507 } 513 }
508 514
@@ -512,7 +518,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
512 /* first communication with embedded */ 518 /* first communication with embedded */
513 err = mixart_first_init(mgr); 519 err = mixart_first_init(mgr);
514 if (err < 0) { 520 if (err < 0) {
515 snd_printk( KERN_ERR "miXart could not be set up\n"); 521 snd_printk(KERN_ERR "miXart could not be set up\n");
516 return err; 522 return err;
517 } 523 }
518 524
@@ -581,16 +587,6 @@ MODULE_FIRMWARE("mixart/miXart8AES.xlx");
581/* miXart hwdep interface id string */ 587/* miXart hwdep interface id string */
582#define SND_MIXART_HWDEP_ID "miXart Loader" 588#define SND_MIXART_HWDEP_ID "miXart Loader"
583 589
584static int mixart_hwdep_open(struct snd_hwdep *hw, struct file *file)
585{
586 return 0;
587}
588
589static int mixart_hwdep_release(struct snd_hwdep *hw, struct file *file)
590{
591 return 0;
592}
593
594static int mixart_hwdep_dsp_status(struct snd_hwdep *hw, 590static int mixart_hwdep_dsp_status(struct snd_hwdep *hw,
595 struct snd_hwdep_dsp_status *info) 591 struct snd_hwdep_dsp_status *info)
596{ 592{
@@ -643,8 +639,6 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
643 639
644 hw->iface = SNDRV_HWDEP_IFACE_MIXART; 640 hw->iface = SNDRV_HWDEP_IFACE_MIXART;
645 hw->private_data = mgr; 641 hw->private_data = mgr;
646 hw->ops.open = mixart_hwdep_open;
647 hw->ops.release = mixart_hwdep_release;
648 hw->ops.dsp_status = mixart_hwdep_dsp_status; 642 hw->ops.dsp_status = mixart_hwdep_dsp_status;
649 hw->ops.dsp_load = mixart_hwdep_dsp_load; 643 hw->ops.dsp_load = mixart_hwdep_dsp_load;
650 hw->exclusive = 1; 644 hw->exclusive = 1;
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index 1ab833f843eb..84ef13183419 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -45,6 +45,7 @@ MODULE_PARM_DESC(enable, "enable card");
45static struct pci_device_id hifier_ids[] __devinitdata = { 45static struct pci_device_id hifier_ids[] __devinitdata = {
46 { OXYGEN_PCI_SUBID(0x14c3, 0x1710) }, 46 { OXYGEN_PCI_SUBID(0x14c3, 0x1710) },
47 { OXYGEN_PCI_SUBID(0x14c3, 0x1711) }, 47 { OXYGEN_PCI_SUBID(0x14c3, 0x1711) },
48 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
48 { } 49 { }
49}; 50};
50MODULE_DEVICE_TABLE(pci, hifier_ids); 51MODULE_DEVICE_TABLE(pci, hifier_ids);
@@ -151,7 +152,6 @@ static const struct oxygen_model model_hifier = {
151 .shortname = "C-Media CMI8787", 152 .shortname = "C-Media CMI8787",
152 .longname = "C-Media Oxygen HD Audio", 153 .longname = "C-Media Oxygen HD Audio",
153 .chip = "CMI8788", 154 .chip = "CMI8788",
154 .owner = THIS_MODULE,
155 .init = hifier_init, 155 .init = hifier_init,
156 .control_filter = hifier_control_filter, 156 .control_filter = hifier_control_filter,
157 .cleanup = hifier_cleanup, 157 .cleanup = hifier_cleanup,
@@ -173,6 +173,13 @@ static const struct oxygen_model model_hifier = {
173 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 173 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
174}; 174};
175 175
176static int __devinit get_hifier_model(struct oxygen *chip,
177 const struct pci_device_id *id)
178{
179 chip->model = model_hifier;
180 return 0;
181}
182
176static int __devinit hifier_probe(struct pci_dev *pci, 183static int __devinit hifier_probe(struct pci_dev *pci,
177 const struct pci_device_id *pci_id) 184 const struct pci_device_id *pci_id)
178{ 185{
@@ -185,7 +192,8 @@ static int __devinit hifier_probe(struct pci_dev *pci,
185 ++dev; 192 ++dev;
186 return -ENOENT; 193 return -ENOENT;
187 } 194 }
188 err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier, 0); 195 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
196 hifier_ids, get_hifier_model);
189 if (err >= 0) 197 if (err >= 0)
190 ++dev; 198 ++dev;
191 return err; 199 return err;
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index de999c6d6dd3..72db4c39007f 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * C-Media CMI8788 driver for C-Media's reference design and for the X-Meridian 2 * C-Media CMI8788 driver for C-Media's reference design and similar models
3 * 3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * 5 *
@@ -26,6 +26,7 @@
26 * 26 *
27 * GPIO 0 -> DFS0 of AK5385 27 * GPIO 0 -> DFS0 of AK5385
28 * GPIO 1 -> DFS1 of AK5385 28 * GPIO 1 -> DFS1 of AK5385
29 * GPIO 8 -> enable headphone amplifier on HT-Omega models
29 */ 30 */
30 31
31#include <linux/delay.h> 32#include <linux/delay.h>
@@ -61,7 +62,8 @@ MODULE_PARM_DESC(enable, "enable card");
61enum { 62enum {
62 MODEL_CMEDIA_REF, /* C-Media's reference design */ 63 MODEL_CMEDIA_REF, /* C-Media's reference design */
63 MODEL_MERIDIAN, /* AuzenTech X-Meridian */ 64 MODEL_MERIDIAN, /* AuzenTech X-Meridian */
64 MODEL_HALO, /* HT-Omega Claro halo */ 65 MODEL_CLARO, /* HT-Omega Claro */
66 MODEL_CLARO_HALO, /* HT-Omega Claro halo */
65}; 67};
66 68
67static struct pci_device_id oxygen_ids[] __devinitdata = { 69static struct pci_device_id oxygen_ids[] __devinitdata = {
@@ -74,8 +76,8 @@ static struct pci_device_id oxygen_ids[] __devinitdata = {
74 { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF }, 76 { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF },
75 { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF }, 77 { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF },
76 { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN }, 78 { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN },
77 { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CMEDIA_REF }, 79 { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CLARO },
78 { OXYGEN_PCI_SUBID(0x7284, 0x9781), .driver_data = MODEL_HALO }, 80 { OXYGEN_PCI_SUBID(0x7284, 0x9781), .driver_data = MODEL_CLARO_HALO },
79 { } 81 { }
80}; 82};
81MODULE_DEVICE_TABLE(pci, oxygen_ids); 83MODULE_DEVICE_TABLE(pci, oxygen_ids);
@@ -86,6 +88,8 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids);
86#define GPIO_AK5385_DFS_DOUBLE 0x0001 88#define GPIO_AK5385_DFS_DOUBLE 0x0001
87#define GPIO_AK5385_DFS_QUAD 0x0002 89#define GPIO_AK5385_DFS_QUAD 0x0002
88 90
91#define GPIO_CLARO_HP 0x0100
92
89struct generic_data { 93struct generic_data {
90 u8 ak4396_ctl2; 94 u8 ak4396_ctl2;
91 u16 saved_wm8785_registers[2]; 95 u16 saved_wm8785_registers[2];
@@ -196,10 +200,46 @@ static void meridian_init(struct oxygen *chip)
196 ak5385_init(chip); 200 ak5385_init(chip);
197} 201}
198 202
203static void claro_enable_hp(struct oxygen *chip)
204{
205 msleep(300);
206 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_CLARO_HP);
207 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_CLARO_HP);
208}
209
210static void claro_init(struct oxygen *chip)
211{
212 ak4396_init(chip);
213 wm8785_init(chip);
214 claro_enable_hp(chip);
215}
216
217static void claro_halo_init(struct oxygen *chip)
218{
219 ak4396_init(chip);
220 ak5385_init(chip);
221 claro_enable_hp(chip);
222}
223
199static void generic_cleanup(struct oxygen *chip) 224static void generic_cleanup(struct oxygen *chip)
200{ 225{
201} 226}
202 227
228static void claro_disable_hp(struct oxygen *chip)
229{
230 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_CLARO_HP);
231}
232
233static void claro_cleanup(struct oxygen *chip)
234{
235 claro_disable_hp(chip);
236}
237
238static void claro_suspend(struct oxygen *chip)
239{
240 claro_disable_hp(chip);
241}
242
203static void generic_resume(struct oxygen *chip) 243static void generic_resume(struct oxygen *chip)
204{ 244{
205 ak4396_registers_init(chip); 245 ak4396_registers_init(chip);
@@ -211,6 +251,12 @@ static void meridian_resume(struct oxygen *chip)
211 ak4396_registers_init(chip); 251 ak4396_registers_init(chip);
212} 252}
213 253
254static void claro_resume(struct oxygen *chip)
255{
256 ak4396_registers_init(chip);
257 claro_enable_hp(chip);
258}
259
214static void set_ak4396_params(struct oxygen *chip, 260static void set_ak4396_params(struct oxygen *chip,
215 struct snd_pcm_hw_params *params) 261 struct snd_pcm_hw_params *params)
216{ 262{
@@ -293,30 +339,10 @@ static void set_ak5385_params(struct oxygen *chip,
293 339
294static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); 340static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
295 341
296static int generic_probe(struct oxygen *chip, unsigned long driver_data)
297{
298 if (driver_data == MODEL_MERIDIAN) {
299 chip->model.init = meridian_init;
300 chip->model.resume = meridian_resume;
301 chip->model.set_adc_params = set_ak5385_params;
302 chip->model.device_config = PLAYBACK_0_TO_I2S |
303 PLAYBACK_1_TO_SPDIF |
304 CAPTURE_0_FROM_I2S_2 |
305 CAPTURE_1_FROM_SPDIF;
306 }
307 if (driver_data == MODEL_MERIDIAN || driver_data == MODEL_HALO) {
308 chip->model.misc_flags = OXYGEN_MISC_MIDI;
309 chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT;
310 }
311 return 0;
312}
313
314static const struct oxygen_model model_generic = { 342static const struct oxygen_model model_generic = {
315 .shortname = "C-Media CMI8788", 343 .shortname = "C-Media CMI8788",
316 .longname = "C-Media Oxygen HD Audio", 344 .longname = "C-Media Oxygen HD Audio",
317 .chip = "CMI8788", 345 .chip = "CMI8788",
318 .owner = THIS_MODULE,
319 .probe = generic_probe,
320 .init = generic_init, 346 .init = generic_init,
321 .cleanup = generic_cleanup, 347 .cleanup = generic_cleanup,
322 .resume = generic_resume, 348 .resume = generic_resume,
@@ -341,6 +367,42 @@ static const struct oxygen_model model_generic = {
341 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 367 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
342}; 368};
343 369
370static int __devinit get_oxygen_model(struct oxygen *chip,
371 const struct pci_device_id *id)
372{
373 chip->model = model_generic;
374 switch (id->driver_data) {
375 case MODEL_MERIDIAN:
376 chip->model.init = meridian_init;
377 chip->model.resume = meridian_resume;
378 chip->model.set_adc_params = set_ak5385_params;
379 chip->model.device_config = PLAYBACK_0_TO_I2S |
380 PLAYBACK_1_TO_SPDIF |
381 CAPTURE_0_FROM_I2S_2 |
382 CAPTURE_1_FROM_SPDIF;
383 break;
384 case MODEL_CLARO:
385 chip->model.init = claro_init;
386 chip->model.cleanup = claro_cleanup;
387 chip->model.suspend = claro_suspend;
388 chip->model.resume = claro_resume;
389 break;
390 case MODEL_CLARO_HALO:
391 chip->model.init = claro_halo_init;
392 chip->model.cleanup = claro_cleanup;
393 chip->model.suspend = claro_suspend;
394 chip->model.resume = claro_resume;
395 chip->model.set_adc_params = set_ak5385_params;
396 break;
397 }
398 if (id->driver_data == MODEL_MERIDIAN ||
399 id->driver_data == MODEL_CLARO_HALO) {
400 chip->model.misc_flags = OXYGEN_MISC_MIDI;
401 chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT;
402 }
403 return 0;
404}
405
344static int __devinit generic_oxygen_probe(struct pci_dev *pci, 406static int __devinit generic_oxygen_probe(struct pci_dev *pci,
345 const struct pci_device_id *pci_id) 407 const struct pci_device_id *pci_id)
346{ 408{
@@ -353,8 +415,8 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci,
353 ++dev; 415 ++dev;
354 return -ENOENT; 416 return -ENOENT;
355 } 417 }
356 err = oxygen_pci_probe(pci, index[dev], id[dev], 418 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
357 &model_generic, pci_id->driver_data); 419 oxygen_ids, get_oxygen_model);
358 if (err >= 0) 420 if (err >= 0)
359 ++dev; 421 ++dev;
360 return err; 422 return err;
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 19107c6307e5..bd615dbffadb 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -18,6 +18,8 @@
18 18
19#define OXYGEN_IO_SIZE 0x100 19#define OXYGEN_IO_SIZE 0x100
20 20
21#define OXYGEN_EEPROM_ID 0x434d /* "CM" */
22
21/* model-specific configuration of outputs/inputs */ 23/* model-specific configuration of outputs/inputs */
22#define PLAYBACK_0_TO_I2S 0x0001 24#define PLAYBACK_0_TO_I2S 0x0001
23 /* PLAYBACK_0_TO_AC97_0 not implemented */ 25 /* PLAYBACK_0_TO_AC97_0 not implemented */
@@ -49,7 +51,13 @@ enum {
49 .subvendor = sv, \ 51 .subvendor = sv, \
50 .subdevice = sd 52 .subdevice = sd
51 53
54#define BROKEN_EEPROM_DRIVER_DATA ((unsigned long)-1)
55#define OXYGEN_PCI_SUBID_BROKEN_EEPROM \
56 OXYGEN_PCI_SUBID(PCI_VENDOR_ID_CMEDIA, 0x8788), \
57 .driver_data = BROKEN_EEPROM_DRIVER_DATA
58
52struct pci_dev; 59struct pci_dev;
60struct pci_device_id;
53struct snd_card; 61struct snd_card;
54struct snd_pcm_substream; 62struct snd_pcm_substream;
55struct snd_pcm_hardware; 63struct snd_pcm_hardware;
@@ -62,8 +70,6 @@ struct oxygen_model {
62 const char *shortname; 70 const char *shortname;
63 const char *longname; 71 const char *longname;
64 const char *chip; 72 const char *chip;
65 struct module *owner;
66 int (*probe)(struct oxygen *chip, unsigned long driver_data);
67 void (*init)(struct oxygen *chip); 73 void (*init)(struct oxygen *chip);
68 int (*control_filter)(struct snd_kcontrol_new *template); 74 int (*control_filter)(struct snd_kcontrol_new *template);
69 int (*mixer_init)(struct oxygen *chip); 75 int (*mixer_init)(struct oxygen *chip);
@@ -83,6 +89,7 @@ struct oxygen_model {
83 void (*ac97_switch)(struct oxygen *chip, 89 void (*ac97_switch)(struct oxygen *chip,
84 unsigned int reg, unsigned int mute); 90 unsigned int reg, unsigned int mute);
85 const unsigned int *dac_tlv; 91 const unsigned int *dac_tlv;
92 unsigned long private_data;
86 size_t model_data_size; 93 size_t model_data_size;
87 unsigned int device_config; 94 unsigned int device_config;
88 u8 dac_channels; 95 u8 dac_channels;
@@ -134,8 +141,12 @@ struct oxygen {
134/* oxygen_lib.c */ 141/* oxygen_lib.c */
135 142
136int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, 143int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
137 const struct oxygen_model *model, 144 struct module *owner,
138 unsigned long driver_data); 145 const struct pci_device_id *ids,
146 int (*get_model)(struct oxygen *chip,
147 const struct pci_device_id *id
148 )
149 );
139void oxygen_pci_remove(struct pci_dev *pci); 150void oxygen_pci_remove(struct pci_dev *pci);
140#ifdef CONFIG_PM 151#ifdef CONFIG_PM
141int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state); 152int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state);
@@ -180,6 +191,9 @@ void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data);
180void oxygen_reset_uart(struct oxygen *chip); 191void oxygen_reset_uart(struct oxygen *chip);
181void oxygen_write_uart(struct oxygen *chip, u8 data); 192void oxygen_write_uart(struct oxygen *chip, u8 data);
182 193
194u16 oxygen_read_eeprom(struct oxygen *chip, unsigned int index);
195void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value);
196
183static inline void oxygen_set_bits8(struct oxygen *chip, 197static inline void oxygen_set_bits8(struct oxygen *chip,
184 unsigned int reg, u8 value) 198 unsigned int reg, u8 value)
185{ 199{
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c
index 3126c4b403dd..c1eb923f2ac9 100644
--- a/sound/pci/oxygen/oxygen_io.c
+++ b/sound/pci/oxygen/oxygen_io.c
@@ -254,3 +254,34 @@ void oxygen_write_uart(struct oxygen *chip, u8 data)
254 _write_uart(chip, 0, data); 254 _write_uart(chip, 0, data);
255} 255}
256EXPORT_SYMBOL(oxygen_write_uart); 256EXPORT_SYMBOL(oxygen_write_uart);
257
258u16 oxygen_read_eeprom(struct oxygen *chip, unsigned int index)
259{
260 unsigned int timeout;
261
262 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL,
263 index | OXYGEN_EEPROM_DIR_READ);
264 for (timeout = 0; timeout < 100; ++timeout) {
265 udelay(1);
266 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS)
267 & OXYGEN_EEPROM_BUSY))
268 break;
269 }
270 return oxygen_read16(chip, OXYGEN_EEPROM_DATA);
271}
272
273void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value)
274{
275 unsigned int timeout;
276
277 oxygen_write16(chip, OXYGEN_EEPROM_DATA, value);
278 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL,
279 index | OXYGEN_EEPROM_DIR_WRITE);
280 for (timeout = 0; timeout < 10; ++timeout) {
281 msleep(1);
282 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS)
283 & OXYGEN_EEPROM_BUSY))
284 return;
285 }
286 snd_printk(KERN_ERR "EEPROM write timeout\n");
287}
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 9c81e0b05113..312251d39696 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -34,6 +34,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
34MODULE_DESCRIPTION("C-Media CMI8788 helper library"); 34MODULE_DESCRIPTION("C-Media CMI8788 helper library");
35MODULE_LICENSE("GPL v2"); 35MODULE_LICENSE("GPL v2");
36 36
37#define DRIVER "oxygen"
37 38
38static inline int oxygen_uart_input_ready(struct oxygen *chip) 39static inline int oxygen_uart_input_ready(struct oxygen *chip)
39{ 40{
@@ -243,6 +244,62 @@ static void oxygen_proc_init(struct oxygen *chip)
243#define oxygen_proc_init(chip) 244#define oxygen_proc_init(chip)
244#endif 245#endif
245 246
247static const struct pci_device_id *
248oxygen_search_pci_id(struct oxygen *chip, const struct pci_device_id ids[])
249{
250 u16 subdevice;
251
252 /*
253 * Make sure the EEPROM pins are available, i.e., not used for SPI.
254 * (This function is called before we initialize or use SPI.)
255 */
256 oxygen_clear_bits8(chip, OXYGEN_FUNCTION,
257 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
258 /*
259 * Read the subsystem device ID directly from the EEPROM, because the
260 * chip didn't if the first EEPROM word was overwritten.
261 */
262 subdevice = oxygen_read_eeprom(chip, 2);
263 /*
264 * We use only the subsystem device ID for searching because it is
265 * unique even without the subsystem vendor ID, which may have been
266 * overwritten in the EEPROM.
267 */
268 for (; ids->vendor; ++ids)
269 if (ids->subdevice == subdevice &&
270 ids->driver_data != BROKEN_EEPROM_DRIVER_DATA)
271 return ids;
272 return NULL;
273}
274
275static void oxygen_restore_eeprom(struct oxygen *chip,
276 const struct pci_device_id *id)
277{
278 if (oxygen_read_eeprom(chip, 0) != OXYGEN_EEPROM_ID) {
279 /*
280 * This function gets called only when a known card model has
281 * been detected, i.e., we know there is a valid subsystem
282 * product ID at index 2 in the EEPROM. Therefore, we have
283 * been able to deduce the correct subsystem vendor ID, and
284 * this is enough information to restore the original EEPROM
285 * contents.
286 */
287 oxygen_write_eeprom(chip, 1, id->subvendor);
288 oxygen_write_eeprom(chip, 0, OXYGEN_EEPROM_ID);
289
290 oxygen_set_bits8(chip, OXYGEN_MISC,
291 OXYGEN_MISC_WRITE_PCI_SUBID);
292 pci_write_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID,
293 id->subvendor);
294 pci_write_config_word(chip->pci, PCI_SUBSYSTEM_ID,
295 id->subdevice);
296 oxygen_clear_bits8(chip, OXYGEN_MISC,
297 OXYGEN_MISC_WRITE_PCI_SUBID);
298
299 snd_printk(KERN_INFO "EEPROM ID restored\n");
300 }
301}
302
246static void oxygen_init(struct oxygen *chip) 303static void oxygen_init(struct oxygen *chip)
247{ 304{
248 unsigned int i; 305 unsigned int i;
@@ -446,21 +503,26 @@ static void oxygen_card_free(struct snd_card *card)
446 free_irq(chip->irq, chip); 503 free_irq(chip->irq, chip);
447 flush_scheduled_work(); 504 flush_scheduled_work();
448 chip->model.cleanup(chip); 505 chip->model.cleanup(chip);
506 kfree(chip->model_data);
449 mutex_destroy(&chip->mutex); 507 mutex_destroy(&chip->mutex);
450 pci_release_regions(chip->pci); 508 pci_release_regions(chip->pci);
451 pci_disable_device(chip->pci); 509 pci_disable_device(chip->pci);
452} 510}
453 511
454int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, 512int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
455 const struct oxygen_model *model, 513 struct module *owner,
456 unsigned long driver_data) 514 const struct pci_device_id *ids,
515 int (*get_model)(struct oxygen *chip,
516 const struct pci_device_id *id
517 )
518 )
457{ 519{
458 struct snd_card *card; 520 struct snd_card *card;
459 struct oxygen *chip; 521 struct oxygen *chip;
522 const struct pci_device_id *pci_id;
460 int err; 523 int err;
461 524
462 err = snd_card_create(index, id, model->owner, 525 err = snd_card_create(index, id, owner, sizeof(*chip), &card);
463 sizeof(*chip) + model->model_data_size, &card);
464 if (err < 0) 526 if (err < 0)
465 return err; 527 return err;
466 528
@@ -468,8 +530,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
468 chip->card = card; 530 chip->card = card;
469 chip->pci = pci; 531 chip->pci = pci;
470 chip->irq = -1; 532 chip->irq = -1;
471 chip->model = *model;
472 chip->model_data = chip + 1;
473 spin_lock_init(&chip->reg_lock); 533 spin_lock_init(&chip->reg_lock);
474 mutex_init(&chip->mutex); 534 mutex_init(&chip->mutex);
475 INIT_WORK(&chip->spdif_input_bits_work, 535 INIT_WORK(&chip->spdif_input_bits_work,
@@ -481,7 +541,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
481 if (err < 0) 541 if (err < 0)
482 goto err_card; 542 goto err_card;
483 543
484 err = pci_request_regions(pci, model->chip); 544 err = pci_request_regions(pci, DRIVER);
485 if (err < 0) { 545 if (err < 0) {
486 snd_printk(KERN_ERR "cannot reserve PCI resources\n"); 546 snd_printk(KERN_ERR "cannot reserve PCI resources\n");
487 goto err_pci_enable; 547 goto err_pci_enable;
@@ -495,20 +555,34 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
495 } 555 }
496 chip->addr = pci_resource_start(pci, 0); 556 chip->addr = pci_resource_start(pci, 0);
497 557
558 pci_id = oxygen_search_pci_id(chip, ids);
559 if (!pci_id) {
560 err = -ENODEV;
561 goto err_pci_regions;
562 }
563 oxygen_restore_eeprom(chip, pci_id);
564 err = get_model(chip, pci_id);
565 if (err < 0)
566 goto err_pci_regions;
567
568 if (chip->model.model_data_size) {
569 chip->model_data = kzalloc(chip->model.model_data_size,
570 GFP_KERNEL);
571 if (!chip->model_data) {
572 err = -ENOMEM;
573 goto err_pci_regions;
574 }
575 }
576
498 pci_set_master(pci); 577 pci_set_master(pci);
499 snd_card_set_dev(card, &pci->dev); 578 snd_card_set_dev(card, &pci->dev);
500 card->private_free = oxygen_card_free; 579 card->private_free = oxygen_card_free;
501 580
502 if (chip->model.probe) {
503 err = chip->model.probe(chip, driver_data);
504 if (err < 0)
505 goto err_card;
506 }
507 oxygen_init(chip); 581 oxygen_init(chip);
508 chip->model.init(chip); 582 chip->model.init(chip);
509 583
510 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED, 584 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
511 chip->model.chip, chip); 585 DRIVER, chip);
512 if (err < 0) { 586 if (err < 0) {
513 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq); 587 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq);
514 goto err_card; 588 goto err_card;
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 98c6a8c65d81..bc5ce11c8b14 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -112,6 +112,34 @@
112 * CS4362A: AD0 <- 0 112 * CS4362A: AD0 <- 0
113 */ 113 */
114 114
115/*
116 * Xonar Essence STX
117 * -----------------
118 *
119 * CMI8788:
120 *
121 * I²C <-> PCM1792A
122 *
123 * GPI 0 <- external power present
124 *
125 * GPIO 0 -> enable output to speakers
126 * GPIO 1 -> route HP to front panel (0) or rear jack (1)
127 * GPIO 2 -> M0 of CS5381
128 * GPIO 3 -> M1 of CS5381
129 * GPIO 7 -> route output to speaker jacks (0) or HP (1)
130 * GPIO 8 -> route input jack to line-in (0) or mic-in (1)
131 *
132 * PCM1792A:
133 *
134 * AD0 <- 0
135 *
136 * H6 daughterboard
137 * ----------------
138 *
139 * GPIO 4 <- 0
140 * GPIO 5 <- 0
141 */
142
115#include <linux/pci.h> 143#include <linux/pci.h>
116#include <linux/delay.h> 144#include <linux/delay.h>
117#include <linux/mutex.h> 145#include <linux/mutex.h>
@@ -152,6 +180,7 @@ enum {
152 MODEL_DX, 180 MODEL_DX,
153 MODEL_HDAV, /* without daughterboard */ 181 MODEL_HDAV, /* without daughterboard */
154 MODEL_HDAV_H6, /* with H6 daughterboard */ 182 MODEL_HDAV_H6, /* with H6 daughterboard */
183 MODEL_STX,
155}; 184};
156 185
157static struct pci_device_id xonar_ids[] __devinitdata = { 186static struct pci_device_id xonar_ids[] __devinitdata = {
@@ -160,6 +189,8 @@ static struct pci_device_id xonar_ids[] __devinitdata = {
160 { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, 189 { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X },
161 { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV }, 190 { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV },
162 { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, 191 { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 },
192 { OXYGEN_PCI_SUBID(0x1043, 0x835c), .driver_data = MODEL_STX },
193 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
163 { } 194 { }
164}; 195};
165MODULE_DEVICE_TABLE(pci, xonar_ids); 196MODULE_DEVICE_TABLE(pci, xonar_ids);
@@ -183,12 +214,14 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
183#define GPIO_HDAV_DB_H6 0x0000 214#define GPIO_HDAV_DB_H6 0x0000
184#define GPIO_HDAV_DB_XX 0x0020 215#define GPIO_HDAV_DB_XX 0x0020
185 216
217#define GPIO_ST_HP_REAR 0x0002
218#define GPIO_ST_HP 0x0080
219
186#define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ADx=i, /W=0 */ 220#define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ADx=i, /W=0 */
187#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ 221#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */
188#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ 222#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */
189 223
190struct xonar_data { 224struct xonar_data {
191 unsigned int model;
192 unsigned int anti_pop_delay; 225 unsigned int anti_pop_delay;
193 unsigned int dacs; 226 unsigned int dacs;
194 u16 output_enable_bit; 227 u16 output_enable_bit;
@@ -334,15 +367,9 @@ static void xonar_d2_init(struct oxygen *chip)
334 struct xonar_data *data = chip->model_data; 367 struct xonar_data *data = chip->model_data;
335 368
336 data->anti_pop_delay = 300; 369 data->anti_pop_delay = 300;
370 data->dacs = 4;
337 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE; 371 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE;
338 data->pcm1796_oversampling = PCM1796_OS_64; 372 data->pcm1796_oversampling = PCM1796_OS_64;
339 if (data->model == MODEL_D2X) {
340 data->ext_power_reg = OXYGEN_GPIO_DATA;
341 data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK;
342 data->ext_power_bit = GPIO_D2X_EXT_POWER;
343 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
344 GPIO_D2X_EXT_POWER);
345 }
346 373
347 pcm1796_init(chip); 374 pcm1796_init(chip);
348 375
@@ -355,6 +382,18 @@ static void xonar_d2_init(struct oxygen *chip)
355 snd_component_add(chip->card, "CS5381"); 382 snd_component_add(chip->card, "CS5381");
356} 383}
357 384
385static void xonar_d2x_init(struct oxygen *chip)
386{
387 struct xonar_data *data = chip->model_data;
388
389 data->ext_power_reg = OXYGEN_GPIO_DATA;
390 data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK;
391 data->ext_power_bit = GPIO_D2X_EXT_POWER;
392 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER);
393
394 xonar_d2_init(chip);
395}
396
358static void update_cs4362a_volumes(struct oxygen *chip) 397static void update_cs4362a_volumes(struct oxygen *chip)
359{ 398{
360 u8 mute; 399 u8 mute;
@@ -422,11 +461,6 @@ static void xonar_d1_init(struct oxygen *chip)
422 data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST; 461 data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST;
423 data->cs4362a_fm = CS4362A_FM_SINGLE | 462 data->cs4362a_fm = CS4362A_FM_SINGLE |
424 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; 463 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L;
425 if (data->model == MODEL_DX) {
426 data->ext_power_reg = OXYGEN_GPI_DATA;
427 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
428 data->ext_power_bit = GPI_DX_EXT_POWER;
429 }
430 464
431 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, 465 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
432 OXYGEN_2WIRE_LENGTH_8 | 466 OXYGEN_2WIRE_LENGTH_8 |
@@ -447,6 +481,17 @@ static void xonar_d1_init(struct oxygen *chip)
447 snd_component_add(chip->card, "CS5361"); 481 snd_component_add(chip->card, "CS5361");
448} 482}
449 483
484static void xonar_dx_init(struct oxygen *chip)
485{
486 struct xonar_data *data = chip->model_data;
487
488 data->ext_power_reg = OXYGEN_GPI_DATA;
489 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
490 data->ext_power_bit = GPI_DX_EXT_POWER;
491
492 xonar_d1_init(chip);
493}
494
450static void xonar_hdav_init(struct oxygen *chip) 495static void xonar_hdav_init(struct oxygen *chip)
451{ 496{
452 struct xonar_data *data = chip->model_data; 497 struct xonar_data *data = chip->model_data;
@@ -458,6 +503,7 @@ static void xonar_hdav_init(struct oxygen *chip)
458 OXYGEN_2WIRE_SPEED_FAST); 503 OXYGEN_2WIRE_SPEED_FAST);
459 504
460 data->anti_pop_delay = 100; 505 data->anti_pop_delay = 100;
506 data->dacs = chip->model.private_data == MODEL_HDAV_H6 ? 4 : 1;
461 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; 507 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
462 data->ext_power_reg = OXYGEN_GPI_DATA; 508 data->ext_power_reg = OXYGEN_GPI_DATA;
463 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; 509 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
@@ -484,6 +530,36 @@ static void xonar_hdav_init(struct oxygen *chip)
484 snd_component_add(chip->card, "CS5381"); 530 snd_component_add(chip->card, "CS5381");
485} 531}
486 532
533static void xonar_stx_init(struct oxygen *chip)
534{
535 struct xonar_data *data = chip->model_data;
536
537 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
538 OXYGEN_2WIRE_LENGTH_8 |
539 OXYGEN_2WIRE_INTERRUPT_MASK |
540 OXYGEN_2WIRE_SPEED_FAST);
541
542 data->anti_pop_delay = 100;
543 data->dacs = 1;
544 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
545 data->ext_power_reg = OXYGEN_GPI_DATA;
546 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
547 data->ext_power_bit = GPI_DX_EXT_POWER;
548 data->pcm1796_oversampling = PCM1796_OS_64;
549
550 pcm1796_init(chip);
551
552 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
553 GPIO_DX_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP);
554 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA,
555 GPIO_DX_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP);
556
557 xonar_common_init(chip);
558
559 snd_component_add(chip->card, "PCM1792A");
560 snd_component_add(chip->card, "CS5381");
561}
562
487static void xonar_disable_output(struct oxygen *chip) 563static void xonar_disable_output(struct oxygen *chip)
488{ 564{
489 struct xonar_data *data = chip->model_data; 565 struct xonar_data *data = chip->model_data;
@@ -511,6 +587,11 @@ static void xonar_hdav_cleanup(struct oxygen *chip)
511 xonar_disable_output(chip); 587 xonar_disable_output(chip);
512} 588}
513 589
590static void xonar_st_cleanup(struct oxygen *chip)
591{
592 xonar_disable_output(chip);
593}
594
514static void xonar_d2_suspend(struct oxygen *chip) 595static void xonar_d2_suspend(struct oxygen *chip)
515{ 596{
516 xonar_d2_cleanup(chip); 597 xonar_d2_cleanup(chip);
@@ -527,6 +608,11 @@ static void xonar_hdav_suspend(struct oxygen *chip)
527 msleep(2); 608 msleep(2);
528} 609}
529 610
611static void xonar_st_suspend(struct oxygen *chip)
612{
613 xonar_st_cleanup(chip);
614}
615
530static void xonar_d2_resume(struct oxygen *chip) 616static void xonar_d2_resume(struct oxygen *chip)
531{ 617{
532 pcm1796_init(chip); 618 pcm1796_init(chip);
@@ -554,6 +640,12 @@ static void xonar_hdav_resume(struct oxygen *chip)
554 xonar_enable_output(chip); 640 xonar_enable_output(chip);
555} 641}
556 642
643static void xonar_st_resume(struct oxygen *chip)
644{
645 pcm1796_init(chip);
646 xonar_enable_output(chip);
647}
648
557static void xonar_hdav_pcm_hardware_filter(unsigned int channel, 649static void xonar_hdav_pcm_hardware_filter(unsigned int channel,
558 struct snd_pcm_hardware *hardware) 650 struct snd_pcm_hardware *hardware)
559{ 651{
@@ -676,7 +768,7 @@ static void xonar_hdav_uart_input(struct oxygen *chip)
676 if (chip->uart_input_count >= 2 && 768 if (chip->uart_input_count >= 2 &&
677 chip->uart_input[chip->uart_input_count - 2] == 'O' && 769 chip->uart_input[chip->uart_input_count - 2] == 'O' &&
678 chip->uart_input[chip->uart_input_count - 1] == 'K') { 770 chip->uart_input[chip->uart_input_count - 1] == 'K') {
679 printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:"); 771 printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:\n");
680 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 772 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
681 chip->uart_input, chip->uart_input_count); 773 chip->uart_input, chip->uart_input_count);
682 chip->uart_input_count = 0; 774 chip->uart_input_count = 0;
@@ -733,6 +825,72 @@ static const struct snd_kcontrol_new front_panel_switch = {
733 .private_value = GPIO_DX_FRONT_PANEL, 825 .private_value = GPIO_DX_FRONT_PANEL,
734}; 826};
735 827
828static int st_output_switch_info(struct snd_kcontrol *ctl,
829 struct snd_ctl_elem_info *info)
830{
831 static const char *const names[3] = {
832 "Speakers", "Headphones", "FP Headphones"
833 };
834
835 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
836 info->count = 1;
837 info->value.enumerated.items = 3;
838 if (info->value.enumerated.item >= 3)
839 info->value.enumerated.item = 2;
840 strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
841 return 0;
842}
843
844static int st_output_switch_get(struct snd_kcontrol *ctl,
845 struct snd_ctl_elem_value *value)
846{
847 struct oxygen *chip = ctl->private_data;
848 u16 gpio;
849
850 gpio = oxygen_read16(chip, OXYGEN_GPIO_DATA);
851 if (!(gpio & GPIO_ST_HP))
852 value->value.enumerated.item[0] = 0;
853 else if (gpio & GPIO_ST_HP_REAR)
854 value->value.enumerated.item[0] = 1;
855 else
856 value->value.enumerated.item[0] = 2;
857 return 0;
858}
859
860
861static int st_output_switch_put(struct snd_kcontrol *ctl,
862 struct snd_ctl_elem_value *value)
863{
864 struct oxygen *chip = ctl->private_data;
865 u16 gpio_old, gpio;
866
867 mutex_lock(&chip->mutex);
868 gpio_old = oxygen_read16(chip, OXYGEN_GPIO_DATA);
869 gpio = gpio_old;
870 switch (value->value.enumerated.item[0]) {
871 case 0:
872 gpio &= ~(GPIO_ST_HP | GPIO_ST_HP_REAR);
873 break;
874 case 1:
875 gpio |= GPIO_ST_HP | GPIO_ST_HP_REAR;
876 break;
877 case 2:
878 gpio = (gpio | GPIO_ST_HP) & ~GPIO_ST_HP_REAR;
879 break;
880 }
881 oxygen_write16(chip, OXYGEN_GPIO_DATA, gpio);
882 mutex_unlock(&chip->mutex);
883 return gpio != gpio_old;
884}
885
886static const struct snd_kcontrol_new st_output_switch = {
887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
888 .name = "Analog Output",
889 .info = st_output_switch_info,
890 .get = st_output_switch_get,
891 .put = st_output_switch_put,
892};
893
736static void xonar_line_mic_ac97_switch(struct oxygen *chip, 894static void xonar_line_mic_ac97_switch(struct oxygen *chip,
737 unsigned int reg, unsigned int mute) 895 unsigned int reg, unsigned int mute)
738{ 896{
@@ -745,8 +903,8 @@ static void xonar_line_mic_ac97_switch(struct oxygen *chip,
745 } 903 }
746} 904}
747 905
748static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0); 906static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -6000, 50, 0);
749static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0); 907static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -6000, 100, 0);
750 908
751static int xonar_d2_control_filter(struct snd_kcontrol_new *template) 909static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
752{ 910{
@@ -763,6 +921,15 @@ static int xonar_d1_control_filter(struct snd_kcontrol_new *template)
763 return 0; 921 return 0;
764} 922}
765 923
924static int xonar_st_control_filter(struct snd_kcontrol_new *template)
925{
926 if (!strncmp(template->name, "CD Capture ", 11))
927 return 1; /* no CD input */
928 if (!strcmp(template->name, "Stereo Upmixing"))
929 return 1; /* stereo only - we don't need upmixing */
930 return 0;
931}
932
766static int xonar_d2_mixer_init(struct oxygen *chip) 933static int xonar_d2_mixer_init(struct oxygen *chip)
767{ 934{
768 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); 935 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
@@ -773,51 +940,14 @@ static int xonar_d1_mixer_init(struct oxygen *chip)
773 return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip)); 940 return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip));
774} 941}
775 942
776static int xonar_model_probe(struct oxygen *chip, unsigned long driver_data) 943static int xonar_st_mixer_init(struct oxygen *chip)
777{ 944{
778 static const char *const names[] = { 945 return snd_ctl_add(chip->card, snd_ctl_new1(&st_output_switch, chip));
779 [MODEL_D1] = "Xonar D1",
780 [MODEL_DX] = "Xonar DX",
781 [MODEL_D2] = "Xonar D2",
782 [MODEL_D2X] = "Xonar D2X",
783 [MODEL_HDAV] = "Xonar HDAV1.3",
784 [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6",
785 };
786 static const u8 dacs[] = {
787 [MODEL_D1] = 2,
788 [MODEL_DX] = 2,
789 [MODEL_D2] = 4,
790 [MODEL_D2X] = 4,
791 [MODEL_HDAV] = 1,
792 [MODEL_HDAV_H6] = 4,
793 };
794 struct xonar_data *data = chip->model_data;
795
796 data->model = driver_data;
797 if (data->model == MODEL_HDAV) {
798 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
799 GPIO_HDAV_DB_MASK);
800 switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) &
801 GPIO_HDAV_DB_MASK) {
802 case GPIO_HDAV_DB_H6:
803 data->model = MODEL_HDAV_H6;
804 break;
805 case GPIO_HDAV_DB_XX:
806 snd_printk(KERN_ERR "unknown daughterboard\n");
807 return -ENODEV;
808 }
809 }
810
811 data->dacs = dacs[data->model];
812 chip->model.shortname = names[data->model];
813 return 0;
814} 946}
815 947
816static const struct oxygen_model model_xonar_d2 = { 948static const struct oxygen_model model_xonar_d2 = {
817 .longname = "Asus Virtuoso 200", 949 .longname = "Asus Virtuoso 200",
818 .chip = "AV200", 950 .chip = "AV200",
819 .owner = THIS_MODULE,
820 .probe = xonar_model_probe,
821 .init = xonar_d2_init, 951 .init = xonar_d2_init,
822 .control_filter = xonar_d2_control_filter, 952 .control_filter = xonar_d2_control_filter,
823 .mixer_init = xonar_d2_mixer_init, 953 .mixer_init = xonar_d2_mixer_init,
@@ -837,8 +967,8 @@ static const struct oxygen_model model_xonar_d2 = {
837 MIDI_OUTPUT | 967 MIDI_OUTPUT |
838 MIDI_INPUT, 968 MIDI_INPUT,
839 .dac_channels = 8, 969 .dac_channels = 8,
840 .dac_volume_min = 0x0f, 970 .dac_volume_min = 255 - 2*60,
841 .dac_volume_max = 0xff, 971 .dac_volume_max = 255,
842 .misc_flags = OXYGEN_MISC_MIDI, 972 .misc_flags = OXYGEN_MISC_MIDI,
843 .function_flags = OXYGEN_FUNCTION_SPI | 973 .function_flags = OXYGEN_FUNCTION_SPI |
844 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 974 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
@@ -849,8 +979,6 @@ static const struct oxygen_model model_xonar_d2 = {
849static const struct oxygen_model model_xonar_d1 = { 979static const struct oxygen_model model_xonar_d1 = {
850 .longname = "Asus Virtuoso 100", 980 .longname = "Asus Virtuoso 100",
851 .chip = "AV200", 981 .chip = "AV200",
852 .owner = THIS_MODULE,
853 .probe = xonar_model_probe,
854 .init = xonar_d1_init, 982 .init = xonar_d1_init,
855 .control_filter = xonar_d1_control_filter, 983 .control_filter = xonar_d1_control_filter,
856 .mixer_init = xonar_d1_mixer_init, 984 .mixer_init = xonar_d1_mixer_init,
@@ -868,7 +996,7 @@ static const struct oxygen_model model_xonar_d1 = {
868 PLAYBACK_1_TO_SPDIF | 996 PLAYBACK_1_TO_SPDIF |
869 CAPTURE_0_FROM_I2S_2, 997 CAPTURE_0_FROM_I2S_2,
870 .dac_channels = 8, 998 .dac_channels = 8,
871 .dac_volume_min = 0, 999 .dac_volume_min = 127 - 60,
872 .dac_volume_max = 127, 1000 .dac_volume_max = 127,
873 .function_flags = OXYGEN_FUNCTION_2WIRE, 1001 .function_flags = OXYGEN_FUNCTION_2WIRE,
874 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 1002 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
@@ -878,8 +1006,6 @@ static const struct oxygen_model model_xonar_d1 = {
878static const struct oxygen_model model_xonar_hdav = { 1006static const struct oxygen_model model_xonar_hdav = {
879 .longname = "Asus Virtuoso 200", 1007 .longname = "Asus Virtuoso 200",
880 .chip = "AV200", 1008 .chip = "AV200",
881 .owner = THIS_MODULE,
882 .probe = xonar_model_probe,
883 .init = xonar_hdav_init, 1009 .init = xonar_hdav_init,
884 .cleanup = xonar_hdav_cleanup, 1010 .cleanup = xonar_hdav_cleanup,
885 .suspend = xonar_hdav_suspend, 1011 .suspend = xonar_hdav_suspend,
@@ -897,15 +1023,43 @@ static const struct oxygen_model model_xonar_hdav = {
897 PLAYBACK_1_TO_SPDIF | 1023 PLAYBACK_1_TO_SPDIF |
898 CAPTURE_0_FROM_I2S_2, 1024 CAPTURE_0_FROM_I2S_2,
899 .dac_channels = 8, 1025 .dac_channels = 8,
900 .dac_volume_min = 0x0f, 1026 .dac_volume_min = 255 - 2*60,
901 .dac_volume_max = 0xff, 1027 .dac_volume_max = 255,
1028 .misc_flags = OXYGEN_MISC_MIDI,
902 .function_flags = OXYGEN_FUNCTION_2WIRE, 1029 .function_flags = OXYGEN_FUNCTION_2WIRE,
903 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 1030 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
904 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 1031 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
905}; 1032};
906 1033
907static int __devinit xonar_probe(struct pci_dev *pci, 1034static const struct oxygen_model model_xonar_st = {
908 const struct pci_device_id *pci_id) 1035 .longname = "Asus Virtuoso 100",
1036 .chip = "AV200",
1037 .init = xonar_stx_init,
1038 .control_filter = xonar_st_control_filter,
1039 .mixer_init = xonar_st_mixer_init,
1040 .cleanup = xonar_st_cleanup,
1041 .suspend = xonar_st_suspend,
1042 .resume = xonar_st_resume,
1043 .set_dac_params = set_pcm1796_params,
1044 .set_adc_params = set_cs53x1_params,
1045 .update_dac_volume = update_pcm1796_volume,
1046 .update_dac_mute = update_pcm1796_mute,
1047 .ac97_switch = xonar_line_mic_ac97_switch,
1048 .dac_tlv = pcm1796_db_scale,
1049 .model_data_size = sizeof(struct xonar_data),
1050 .device_config = PLAYBACK_0_TO_I2S |
1051 PLAYBACK_1_TO_SPDIF |
1052 CAPTURE_0_FROM_I2S_2,
1053 .dac_channels = 2,
1054 .dac_volume_min = 255 - 2*60,
1055 .dac_volume_max = 255,
1056 .function_flags = OXYGEN_FUNCTION_2WIRE,
1057 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
1058 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
1059};
1060
1061static int __devinit get_xonar_model(struct oxygen *chip,
1062 const struct pci_device_id *id)
909{ 1063{
910 static const struct oxygen_model *const models[] = { 1064 static const struct oxygen_model *const models[] = {
911 [MODEL_D1] = &model_xonar_d1, 1065 [MODEL_D1] = &model_xonar_d1,
@@ -913,7 +1067,57 @@ static int __devinit xonar_probe(struct pci_dev *pci,
913 [MODEL_D2] = &model_xonar_d2, 1067 [MODEL_D2] = &model_xonar_d2,
914 [MODEL_D2X] = &model_xonar_d2, 1068 [MODEL_D2X] = &model_xonar_d2,
915 [MODEL_HDAV] = &model_xonar_hdav, 1069 [MODEL_HDAV] = &model_xonar_hdav,
1070 [MODEL_STX] = &model_xonar_st,
916 }; 1071 };
1072 static const char *const names[] = {
1073 [MODEL_D1] = "Xonar D1",
1074 [MODEL_DX] = "Xonar DX",
1075 [MODEL_D2] = "Xonar D2",
1076 [MODEL_D2X] = "Xonar D2X",
1077 [MODEL_HDAV] = "Xonar HDAV1.3",
1078 [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6",
1079 [MODEL_STX] = "Xonar Essence STX",
1080 };
1081 unsigned int model = id->driver_data;
1082
1083 if (model >= ARRAY_SIZE(models) || !models[model])
1084 return -EINVAL;
1085 chip->model = *models[model];
1086
1087 switch (model) {
1088 case MODEL_D2X:
1089 chip->model.init = xonar_d2x_init;
1090 break;
1091 case MODEL_DX:
1092 chip->model.init = xonar_dx_init;
1093 break;
1094 case MODEL_HDAV:
1095 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
1096 GPIO_HDAV_DB_MASK);
1097 switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) &
1098 GPIO_HDAV_DB_MASK) {
1099 case GPIO_HDAV_DB_H6:
1100 model = MODEL_HDAV_H6;
1101 break;
1102 case GPIO_HDAV_DB_XX:
1103 snd_printk(KERN_ERR "unknown daughterboard\n");
1104 return -ENODEV;
1105 }
1106 break;
1107 case MODEL_STX:
1108 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
1109 GPIO_HDAV_DB_MASK);
1110 break;
1111 }
1112
1113 chip->model.shortname = names[model];
1114 chip->model.private_data = model;
1115 return 0;
1116}
1117
1118static int __devinit xonar_probe(struct pci_dev *pci,
1119 const struct pci_device_id *pci_id)
1120{
917 static int dev; 1121 static int dev;
918 int err; 1122 int err;
919 1123
@@ -923,10 +1127,8 @@ static int __devinit xonar_probe(struct pci_dev *pci,
923 ++dev; 1127 ++dev;
924 return -ENOENT; 1128 return -ENOENT;
925 } 1129 }
926 BUG_ON(pci_id->driver_data >= ARRAY_SIZE(models)); 1130 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
927 err = oxygen_pci_probe(pci, index[dev], id[dev], 1131 xonar_ids, get_xonar_model);
928 models[pci_id->driver_data],
929 pci_id->driver_data);
930 if (err >= 0) 1132 if (err >= 0)
931 ++dev; 1133 ++dev;
932 return err; 1134 return err;
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 7f95459c8b1f..833e9c7b27c7 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1334,6 +1334,40 @@ static void pcxhr_proc_sync(struct snd_info_entry *entry,
1334 snd_iprintf(buffer, "\n"); 1334 snd_iprintf(buffer, "\n");
1335} 1335}
1336 1336
1337static void pcxhr_proc_gpio_read(struct snd_info_entry *entry,
1338 struct snd_info_buffer *buffer)
1339{
1340 struct snd_pcxhr *chip = entry->private_data;
1341 struct pcxhr_mgr *mgr = chip->mgr;
1342 /* commands available when embedded DSP is running */
1343 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) {
1344 /* gpio ports on stereo boards only available */
1345 int value = 0;
1346 hr222_read_gpio(mgr, 1, &value); /* GPI */
1347 snd_iprintf(buffer, "GPI: 0x%x\n", value);
1348 hr222_read_gpio(mgr, 0, &value); /* GP0 */
1349 snd_iprintf(buffer, "GPO: 0x%x\n", value);
1350 } else
1351 snd_iprintf(buffer, "no firmware loaded\n");
1352 snd_iprintf(buffer, "\n");
1353}
1354static void pcxhr_proc_gpo_write(struct snd_info_entry *entry,
1355 struct snd_info_buffer *buffer)
1356{
1357 struct snd_pcxhr *chip = entry->private_data;
1358 struct pcxhr_mgr *mgr = chip->mgr;
1359 char line[64];
1360 int value;
1361 /* commands available when embedded DSP is running */
1362 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)))
1363 return;
1364 while (!snd_info_get_line(buffer, line, sizeof(line))) {
1365 if (sscanf(line, "GPO: 0x%x", &value) != 1)
1366 continue;
1367 hr222_write_gpo(mgr, value); /* GP0 */
1368 }
1369}
1370
1337static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) 1371static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip)
1338{ 1372{
1339 struct snd_info_entry *entry; 1373 struct snd_info_entry *entry;
@@ -1342,6 +1376,13 @@ static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip)
1342 snd_info_set_text_ops(entry, chip, pcxhr_proc_info); 1376 snd_info_set_text_ops(entry, chip, pcxhr_proc_info);
1343 if (! snd_card_proc_new(chip->card, "sync", &entry)) 1377 if (! snd_card_proc_new(chip->card, "sync", &entry))
1344 snd_info_set_text_ops(entry, chip, pcxhr_proc_sync); 1378 snd_info_set_text_ops(entry, chip, pcxhr_proc_sync);
1379 /* gpio available on stereo sound cards only */
1380 if (chip->mgr->is_hr_stereo &&
1381 !snd_card_proc_new(chip->card, "gpio", &entry)) {
1382 snd_info_set_text_ops(entry, chip, pcxhr_proc_gpio_read);
1383 entry->c.text.write = pcxhr_proc_gpo_write;
1384 entry->mode |= S_IWUSR;
1385 }
1345} 1386}
1346/* end of proc interface */ 1387/* end of proc interface */
1347 1388
@@ -1408,7 +1449,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci,
1408 pci_set_master(pci); 1449 pci_set_master(pci);
1409 1450
1410 /* check if we can restrict PCI DMA transfers to 32 bits */ 1451 /* check if we can restrict PCI DMA transfers to 32 bits */
1411 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) { 1452 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1412 snd_printk(KERN_ERR "architecture does not support " 1453 snd_printk(KERN_ERR "architecture does not support "
1413 "32bit PCI busmaster DMA\n"); 1454 "32bit PCI busmaster DMA\n");
1414 pci_disable_device(pci); 1455 pci_disable_device(pci);
diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h
index 84131a916c92..bda776c49884 100644
--- a/sound/pci/pcxhr/pcxhr.h
+++ b/sound/pci/pcxhr/pcxhr.h
@@ -27,8 +27,8 @@
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <sound/pcm.h> 28#include <sound/pcm.h>
29 29
30#define PCXHR_DRIVER_VERSION 0x000905 /* 0.9.5 */ 30#define PCXHR_DRIVER_VERSION 0x000906 /* 0.9.6 */
31#define PCXHR_DRIVER_VERSION_STRING "0.9.5" /* 0.9.5 */ 31#define PCXHR_DRIVER_VERSION_STRING "0.9.6" /* 0.9.6 */
32 32
33 33
34#define PCXHR_MAX_CARDS 6 34#define PCXHR_MAX_CARDS 6
@@ -97,12 +97,12 @@ struct pcxhr_mgr {
97 int capture_chips; 97 int capture_chips;
98 int fw_file_set; 98 int fw_file_set;
99 int firmware_num; 99 int firmware_num;
100 int is_hr_stereo:1; 100 unsigned int is_hr_stereo:1;
101 int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */ 101 unsigned int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */
102 int board_has_analog:1; /* if 0 the board is digital only */ 102 unsigned int board_has_analog:1; /* if 0 the board is digital only */
103 int board_has_mic:1; /* if 1 the board has microphone input */ 103 unsigned int board_has_mic:1; /* if 1 the board has microphone input */
104 int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */ 104 unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */
105 int mono_capture:1; /* if 1 the board does mono capture */ 105 unsigned int mono_capture:1; /* if 1 the board does mono capture */
106 106
107 struct snd_dma_buffer hostport; 107 struct snd_dma_buffer hostport;
108 108
@@ -124,6 +124,7 @@ struct pcxhr_mgr {
124 124
125 unsigned char xlx_cfg; /* copy of PCXHR_XLX_CFG register */ 125 unsigned char xlx_cfg; /* copy of PCXHR_XLX_CFG register */
126 unsigned char xlx_selmic; /* copy of PCXHR_XLX_SELMIC register */ 126 unsigned char xlx_selmic; /* copy of PCXHR_XLX_SELMIC register */
127 unsigned char dsp_reset; /* copy of PCXHR_DSP_RESET register */
127}; 128};
128 129
129 130
diff --git a/sound/pci/pcxhr/pcxhr_core.h b/sound/pci/pcxhr/pcxhr_core.h
index bbbd66d13a64..be0173796cdb 100644
--- a/sound/pci/pcxhr/pcxhr_core.h
+++ b/sound/pci/pcxhr/pcxhr_core.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for Digigram pcxhr compatible soundcards 2 * Driver for Digigram pcxhr compatible soundcards
3 * 3 *
4 * low level interface with interrupt ans message handling 4 * low level interface with interrupt and message handling
5 * 5 *
6 * Copyright (c) 2004 by Digigram <alsa@digigram.com> 6 * Copyright (c) 2004 by Digigram <alsa@digigram.com>
7 * 7 *
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index 592743a298b0..17cb1233a903 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -471,16 +471,6 @@ static int pcxhr_hwdep_dsp_load(struct snd_hwdep *hw,
471 return 0; 471 return 0;
472} 472}
473 473
474static int pcxhr_hwdep_open(struct snd_hwdep *hw, struct file *file)
475{
476 return 0;
477}
478
479static int pcxhr_hwdep_release(struct snd_hwdep *hw, struct file *file)
480{
481 return 0;
482}
483
484int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) 474int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
485{ 475{
486 int err; 476 int err;
@@ -495,8 +485,6 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
495 485
496 hw->iface = SNDRV_HWDEP_IFACE_PCXHR; 486 hw->iface = SNDRV_HWDEP_IFACE_PCXHR;
497 hw->private_data = mgr; 487 hw->private_data = mgr;
498 hw->ops.open = pcxhr_hwdep_open;
499 hw->ops.release = pcxhr_hwdep_release;
500 hw->ops.dsp_status = pcxhr_hwdep_dsp_status; 488 hw->ops.dsp_status = pcxhr_hwdep_dsp_status;
501 hw->ops.dsp_load = pcxhr_hwdep_dsp_load; 489 hw->ops.dsp_load = pcxhr_hwdep_dsp_load;
502 hw->exclusive = 1; 490 hw->exclusive = 1;
diff --git a/sound/pci/pcxhr/pcxhr_mix22.c b/sound/pci/pcxhr/pcxhr_mix22.c
index ff019126b672..1cb82c0a9cb3 100644
--- a/sound/pci/pcxhr/pcxhr_mix22.c
+++ b/sound/pci/pcxhr/pcxhr_mix22.c
@@ -53,6 +53,8 @@
53#define PCXHR_DSP_RESET_DSP 0x01 53#define PCXHR_DSP_RESET_DSP 0x01
54#define PCXHR_DSP_RESET_MUTE 0x02 54#define PCXHR_DSP_RESET_MUTE 0x02
55#define PCXHR_DSP_RESET_CODEC 0x08 55#define PCXHR_DSP_RESET_CODEC 0x08
56#define PCXHR_DSP_RESET_GPO_OFFSET 5
57#define PCXHR_DSP_RESET_GPO_MASK 0x60
56 58
57/* values for PCHR_XLX_CFG register */ 59/* values for PCHR_XLX_CFG register */
58#define PCXHR_CFG_SYNCDSP_MASK 0x80 60#define PCXHR_CFG_SYNCDSP_MASK 0x80
@@ -81,6 +83,8 @@
81/* values for PCHR_XLX_STATUS register - READ */ 83/* values for PCHR_XLX_STATUS register - READ */
82#define PCXHR_STAT_SRC_LOCK 0x01 84#define PCXHR_STAT_SRC_LOCK 0x01
83#define PCXHR_STAT_LEVEL_IN 0x02 85#define PCXHR_STAT_LEVEL_IN 0x02
86#define PCXHR_STAT_GPI_OFFSET 2
87#define PCXHR_STAT_GPI_MASK 0x0C
84#define PCXHR_STAT_MIC_CAPS 0x10 88#define PCXHR_STAT_MIC_CAPS 0x10
85/* values for PCHR_XLX_STATUS register - WRITE */ 89/* values for PCHR_XLX_STATUS register - WRITE */
86#define PCXHR_STAT_FREQ_SYNC_MASK 0x01 90#define PCXHR_STAT_FREQ_SYNC_MASK 0x01
@@ -291,10 +295,11 @@ int hr222_sub_init(struct pcxhr_mgr *mgr)
291 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, 295 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET,
292 PCXHR_DSP_RESET_DSP); 296 PCXHR_DSP_RESET_DSP);
293 msleep(5); 297 msleep(5);
294 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, 298 mgr->dsp_reset = PCXHR_DSP_RESET_DSP |
295 PCXHR_DSP_RESET_DSP | 299 PCXHR_DSP_RESET_MUTE |
296 PCXHR_DSP_RESET_MUTE | 300 PCXHR_DSP_RESET_CODEC;
297 PCXHR_DSP_RESET_CODEC); 301 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, mgr->dsp_reset);
302 /* hr222_write_gpo(mgr, 0); does the same */
298 msleep(5); 303 msleep(5);
299 304
300 /* config AKM */ 305 /* config AKM */
@@ -496,6 +501,33 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
496} 501}
497 502
498 503
504int hr222_read_gpio(struct pcxhr_mgr *mgr, int is_gpi, int *value)
505{
506 if (is_gpi) {
507 unsigned char reg = PCXHR_INPB(mgr, PCXHR_XLX_STATUS);
508 *value = (int)(reg & PCXHR_STAT_GPI_MASK) >>
509 PCXHR_STAT_GPI_OFFSET;
510 } else {
511 *value = (int)(mgr->dsp_reset & PCXHR_DSP_RESET_GPO_MASK) >>
512 PCXHR_DSP_RESET_GPO_OFFSET;
513 }
514 return 0;
515}
516
517
518int hr222_write_gpo(struct pcxhr_mgr *mgr, int value)
519{
520 unsigned char reg = mgr->dsp_reset & ~PCXHR_DSP_RESET_GPO_MASK;
521
522 reg |= (unsigned char)(value << PCXHR_DSP_RESET_GPO_OFFSET) &
523 PCXHR_DSP_RESET_GPO_MASK;
524
525 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, reg);
526 mgr->dsp_reset = reg;
527 return 0;
528}
529
530
499int hr222_update_analog_audio_level(struct snd_pcxhr *chip, 531int hr222_update_analog_audio_level(struct snd_pcxhr *chip,
500 int is_capture, int channel) 532 int is_capture, int channel)
501{ 533{
diff --git a/sound/pci/pcxhr/pcxhr_mix22.h b/sound/pci/pcxhr/pcxhr_mix22.h
index 6b318b2f0100..5a37a0007e8f 100644
--- a/sound/pci/pcxhr/pcxhr_mix22.h
+++ b/sound/pci/pcxhr/pcxhr_mix22.h
@@ -32,6 +32,9 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
32 enum pcxhr_clock_type clock_type, 32 enum pcxhr_clock_type clock_type,
33 int *sample_rate); 33 int *sample_rate);
34 34
35int hr222_read_gpio(struct pcxhr_mgr *mgr, int is_gpi, int *value);
36int hr222_write_gpo(struct pcxhr_mgr *mgr, int value);
37
35#define HR222_LINE_PLAYBACK_LEVEL_MIN 0 /* -25.5 dB */ 38#define HR222_LINE_PLAYBACK_LEVEL_MIN 0 /* -25.5 dB */
36#define HR222_LINE_PLAYBACK_ZERO_LEVEL 51 /* 0.0 dB */ 39#define HR222_LINE_PLAYBACK_ZERO_LEVEL 51 /* 0.0 dB */
37#define HR222_LINE_PLAYBACK_LEVEL_MAX 99 /* +24.0 dB */ 40#define HR222_LINE_PLAYBACK_LEVEL_MAX 99 /* +24.0 dB */
diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c
index 2436e374586f..fec049344621 100644
--- a/sound/pci/pcxhr/pcxhr_mixer.c
+++ b/sound/pci/pcxhr/pcxhr_mixer.c
@@ -789,11 +789,15 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
789 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) { 789 if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
790 mutex_lock(&mgr->setup_mutex); 790 mutex_lock(&mgr->setup_mutex);
791 mgr->use_clock_type = ucontrol->value.enumerated.item[0]; 791 mgr->use_clock_type = ucontrol->value.enumerated.item[0];
792 if (mgr->use_clock_type) 792 rate = 0;
793 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) {
793 pcxhr_get_external_clock(mgr, mgr->use_clock_type, 794 pcxhr_get_external_clock(mgr, mgr->use_clock_type,
794 &rate); 795 &rate);
795 else 796 } else {
796 rate = mgr->sample_rate; 797 rate = mgr->sample_rate;
798 if (!rate)
799 rate = 48000;
800 }
797 if (rate) { 801 if (rate) {
798 pcxhr_set_clock(mgr, rate); 802 pcxhr_set_clock(mgr, rate);
799 if (mgr->sample_rate) 803 if (mgr->sample_rate)
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 05b3f795a168..314e73531bd1 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -113,7 +113,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
113 113
114/* the meters are regular i/o-mapped registers, but offset 114/* the meters are regular i/o-mapped registers, but offset
115 considerably from the rest. the peak registers are reset 115 considerably from the rest. the peak registers are reset
116 when read; the least-significant 4 bits are full-scale counters; 116 when read; the least-significant 4 bits are full-scale counters;
117 the actual peak value is in the most-significant 24 bits. 117 the actual peak value is in the most-significant 24 bits.
118*/ 118*/
119 119
@@ -131,7 +131,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
131 26*3 values are read in ss mode 131 26*3 values are read in ss mode
132 14*3 in ds mode, with no gap between values 132 14*3 in ds mode, with no gap between values
133*/ 133*/
134#define HDSP_9652_peakBase 7164 134#define HDSP_9652_peakBase 7164
135#define HDSP_9652_rmsBase 4096 135#define HDSP_9652_rmsBase 4096
136 136
137/* c.f. the hdsp_9632_meters_t struct */ 137/* c.f. the hdsp_9632_meters_t struct */
@@ -173,12 +173,12 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
173#define HDSP_SPDIFEmphasis (1<<10) /* 0=none, 1=on */ 173#define HDSP_SPDIFEmphasis (1<<10) /* 0=none, 1=on */
174#define HDSP_SPDIFNonAudio (1<<11) /* 0=off, 1=on */ 174#define HDSP_SPDIFNonAudio (1<<11) /* 0=off, 1=on */
175#define HDSP_SPDIFOpticalOut (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */ 175#define HDSP_SPDIFOpticalOut (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */
176#define HDSP_SyncRef2 (1<<13) 176#define HDSP_SyncRef2 (1<<13)
177#define HDSP_SPDIFInputSelect0 (1<<14) 177#define HDSP_SPDIFInputSelect0 (1<<14)
178#define HDSP_SPDIFInputSelect1 (1<<15) 178#define HDSP_SPDIFInputSelect1 (1<<15)
179#define HDSP_SyncRef0 (1<<16) 179#define HDSP_SyncRef0 (1<<16)
180#define HDSP_SyncRef1 (1<<17) 180#define HDSP_SyncRef1 (1<<17)
181#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */ 181#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */
182#define HDSP_XLRBreakoutCable (1<<20) /* For H9632 cards */ 182#define HDSP_XLRBreakoutCable (1<<20) /* For H9632 cards */
183#define HDSP_Midi0InterruptEnable (1<<22) 183#define HDSP_Midi0InterruptEnable (1<<22)
184#define HDSP_Midi1InterruptEnable (1<<23) 184#define HDSP_Midi1InterruptEnable (1<<23)
@@ -314,7 +314,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
314#define HDSP_TimecodeSync (1<<27) 314#define HDSP_TimecodeSync (1<<27)
315#define HDSP_AEBO (1<<28) /* H9632 specific Analog Extension Boards */ 315#define HDSP_AEBO (1<<28) /* H9632 specific Analog Extension Boards */
316#define HDSP_AEBI (1<<29) /* 0 = present, 1 = absent */ 316#define HDSP_AEBI (1<<29) /* 0 = present, 1 = absent */
317#define HDSP_midi0IRQPending (1<<30) 317#define HDSP_midi0IRQPending (1<<30)
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)
@@ -391,7 +391,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
391#define HDSP_CHANNEL_BUFFER_BYTES (4*HDSP_CHANNEL_BUFFER_SAMPLES) 391#define HDSP_CHANNEL_BUFFER_BYTES (4*HDSP_CHANNEL_BUFFER_SAMPLES)
392 392
393/* the size of the area we need to allocate for DMA transfers. the 393/* the size of the area we need to allocate for DMA transfers. the
394 size is the same regardless of the number of channels - the 394 size is the same regardless of the number of channels - the
395 Multiface still uses the same memory area. 395 Multiface still uses the same memory area.
396 396
397 Note that we allocate 1 more channel than is apparently needed 397 Note that we allocate 1 more channel than is apparently needed
@@ -460,7 +460,7 @@ struct hdsp {
460 unsigned char qs_in_channels; /* quad speed mode for H9632 */ 460 unsigned char qs_in_channels; /* quad speed mode for H9632 */
461 unsigned char ds_in_channels; 461 unsigned char ds_in_channels;
462 unsigned char ss_in_channels; /* different for multiface/digiface */ 462 unsigned char ss_in_channels; /* different for multiface/digiface */
463 unsigned char qs_out_channels; 463 unsigned char qs_out_channels;
464 unsigned char ds_out_channels; 464 unsigned char ds_out_channels;
465 unsigned char ss_out_channels; 465 unsigned char ss_out_channels;
466 466
@@ -502,9 +502,9 @@ static char channel_map_df_ss[HDSP_MAX_CHANNELS] = {
502 502
503static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ 503static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */
504 /* Analog */ 504 /* Analog */
505 0, 1, 2, 3, 4, 5, 6, 7, 505 0, 1, 2, 3, 4, 5, 6, 7,
506 /* ADAT 2 */ 506 /* ADAT 2 */
507 16, 17, 18, 19, 20, 21, 22, 23, 507 16, 17, 18, 19, 20, 21, 22, 23,
508 /* SPDIF */ 508 /* SPDIF */
509 24, 25, 509 24, 25,
510 -1, -1, -1, -1, -1, -1, -1, -1 510 -1, -1, -1, -1, -1, -1, -1, -1
@@ -525,11 +525,11 @@ static char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = {
525 /* SPDIF */ 525 /* SPDIF */
526 8, 9, 526 8, 9,
527 /* Analog */ 527 /* Analog */
528 10, 11, 528 10, 11,
529 /* AO4S-192 and AI4S-192 extension boards */ 529 /* AO4S-192 and AI4S-192 extension boards */
530 12, 13, 14, 15, 530 12, 13, 14, 15,
531 /* others don't exist */ 531 /* others don't exist */
532 -1, -1, -1, -1, -1, -1, -1, -1, 532 -1, -1, -1, -1, -1, -1, -1, -1,
533 -1, -1 533 -1, -1
534}; 534};
535 535
@@ -539,7 +539,7 @@ static char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = {
539 /* SPDIF */ 539 /* SPDIF */
540 8, 9, 540 8, 9,
541 /* Analog */ 541 /* Analog */
542 10, 11, 542 10, 11,
543 /* AO4S-192 and AI4S-192 extension boards */ 543 /* AO4S-192 and AI4S-192 extension boards */
544 12, 13, 14, 15, 544 12, 13, 14, 15,
545 /* others don't exist */ 545 /* others don't exist */
@@ -587,7 +587,7 @@ static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_d
587static struct pci_device_id snd_hdsp_ids[] = { 587static struct pci_device_id snd_hdsp_ids[] = {
588 { 588 {
589 .vendor = PCI_VENDOR_ID_XILINX, 589 .vendor = PCI_VENDOR_ID_XILINX,
590 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 590 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP,
591 .subvendor = PCI_ANY_ID, 591 .subvendor = PCI_ANY_ID,
592 .subdevice = PCI_ANY_ID, 592 .subdevice = PCI_ANY_ID,
593 }, /* RME Hammerfall-DSP */ 593 }, /* RME Hammerfall-DSP */
@@ -653,7 +653,6 @@ static unsigned int hdsp_read(struct hdsp *hdsp, int reg)
653 653
654static int hdsp_check_for_iobox (struct hdsp *hdsp) 654static int hdsp_check_for_iobox (struct hdsp *hdsp)
655{ 655{
656
657 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; 656 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
658 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) { 657 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) {
659 snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n"); 658 snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n");
@@ -661,7 +660,29 @@ static int hdsp_check_for_iobox (struct hdsp *hdsp)
661 return -EIO; 660 return -EIO;
662 } 661 }
663 return 0; 662 return 0;
663}
664 664
665static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops,
666 unsigned int delay)
667{
668 unsigned int i;
669
670 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
671 return 0;
672
673 for (i = 0; i != loops; ++i) {
674 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError)
675 msleep(delay);
676 else {
677 snd_printd("Hammerfall-DSP: iobox found after %ums!\n",
678 i * delay);
679 return 0;
680 }
681 }
682
683 snd_printk("Hammerfall-DSP: no Digiface or Multiface connected!\n");
684 hdsp->state &= ~HDSP_FirmwareLoaded;
685 return -EIO;
665} 686}
666 687
667static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { 688static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
@@ -670,19 +691,19 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
670 unsigned long flags; 691 unsigned long flags;
671 692
672 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 693 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
673 694
674 snd_printk ("Hammerfall-DSP: loading firmware\n"); 695 snd_printk ("Hammerfall-DSP: loading firmware\n");
675 696
676 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); 697 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
677 hdsp_write (hdsp, HDSP_fifoData, 0); 698 hdsp_write (hdsp, HDSP_fifoData, 0);
678 699
679 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 700 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
680 snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n"); 701 snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n");
681 return -EIO; 702 return -EIO;
682 } 703 }
683 704
684 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD); 705 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD);
685 706
686 for (i = 0; i < 24413; ++i) { 707 for (i = 0; i < 24413; ++i) {
687 hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]); 708 hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]);
688 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { 709 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) {
@@ -692,7 +713,7 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
692 } 713 }
693 714
694 ssleep(3); 715 ssleep(3);
695 716
696 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 717 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
697 snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n"); 718 snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n");
698 return -EIO; 719 return -EIO;
@@ -705,15 +726,15 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
705#endif 726#endif
706 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); 727 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
707 snd_printk ("Hammerfall-DSP: finished firmware loading\n"); 728 snd_printk ("Hammerfall-DSP: finished firmware loading\n");
708 729
709 } 730 }
710 if (hdsp->state & HDSP_InitializationComplete) { 731 if (hdsp->state & HDSP_InitializationComplete) {
711 snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n"); 732 snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
712 spin_lock_irqsave(&hdsp->lock, flags); 733 spin_lock_irqsave(&hdsp->lock, flags);
713 snd_hdsp_set_defaults(hdsp); 734 snd_hdsp_set_defaults(hdsp);
714 spin_unlock_irqrestore(&hdsp->lock, flags); 735 spin_unlock_irqrestore(&hdsp->lock, flags);
715 } 736 }
716 737
717 hdsp->state |= HDSP_FirmwareLoaded; 738 hdsp->state |= HDSP_FirmwareLoaded;
718 739
719 return 0; 740 return 0;
@@ -722,7 +743,7 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
722static int hdsp_get_iobox_version (struct hdsp *hdsp) 743static int hdsp_get_iobox_version (struct hdsp *hdsp)
723{ 744{
724 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 745 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
725 746
726 hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM); 747 hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM);
727 hdsp_write (hdsp, HDSP_fifoData, 0); 748 hdsp_write (hdsp, HDSP_fifoData, 0);
728 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) 749 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0)
@@ -738,7 +759,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
738 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT); 759 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT);
739 } else { 760 } else {
740 hdsp->io_type = Digiface; 761 hdsp->io_type = Digiface;
741 } 762 }
742 } else { 763 } else {
743 /* firmware was already loaded, get iobox type */ 764 /* firmware was already loaded, get iobox type */
744 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) 765 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
@@ -786,13 +807,13 @@ static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand)
786 807
787 808
788static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) 809static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
789{ 810{
790 int i; 811 int i;
791 812
792 /* the fifoStatus registers reports on how many words 813 /* the fifoStatus registers reports on how many words
793 are available in the command FIFO. 814 are available in the command FIFO.
794 */ 815 */
795 816
796 for (i = 0; i < timeout; i++) { 817 for (i = 0; i < timeout; i++) {
797 818
798 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) 819 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count)
@@ -824,11 +845,11 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
824 845
825 if (addr >= HDSP_MATRIX_MIXER_SIZE) 846 if (addr >= HDSP_MATRIX_MIXER_SIZE)
826 return -1; 847 return -1;
827 848
828 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { 849 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) {
829 850
830 /* from martin bjornsen: 851 /* from martin bjornsen:
831 852
832 "You can only write dwords to the 853 "You can only write dwords to the
833 mixer memory which contain two 854 mixer memory which contain two
834 mixer values in the low and high 855 mixer values in the low and high
@@ -847,7 +868,7 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
847 868
848 hdsp->mixer_matrix[addr] = data; 869 hdsp->mixer_matrix[addr] = data;
849 870
850 871
851 /* `addr' addresses a 16-bit wide address, but 872 /* `addr' addresses a 16-bit wide address, but
852 the address space accessed via hdsp_write 873 the address space accessed via hdsp_write
853 uses byte offsets. put another way, addr 874 uses byte offsets. put another way, addr
@@ -856,17 +877,17 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
856 to access 0 to 2703 ... 877 to access 0 to 2703 ...
857 */ 878 */
858 ad = addr/2; 879 ad = addr/2;
859 880
860 hdsp_write (hdsp, 4096 + (ad*4), 881 hdsp_write (hdsp, 4096 + (ad*4),
861 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + 882 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) +
862 hdsp->mixer_matrix[addr&0x7fe]); 883 hdsp->mixer_matrix[addr&0x7fe]);
863 884
864 return 0; 885 return 0;
865 886
866 } else { 887 } else {
867 888
868 ad = (addr << 16) + data; 889 ad = (addr << 16) + data;
869 890
870 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) 891 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT))
871 return -1; 892 return -1;
872 893
@@ -902,7 +923,7 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
902 923
903 if (status & HDSP_SPDIFErrorFlag) 924 if (status & HDSP_SPDIFErrorFlag)
904 return 0; 925 return 0;
905 926
906 switch (rate_bits) { 927 switch (rate_bits) {
907 case HDSP_spdifFrequency32KHz: return 32000; 928 case HDSP_spdifFrequency32KHz: return 32000;
908 case HDSP_spdifFrequency44_1KHz: return 44100; 929 case HDSP_spdifFrequency44_1KHz: return 44100;
@@ -910,13 +931,13 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
910 case HDSP_spdifFrequency64KHz: return 64000; 931 case HDSP_spdifFrequency64KHz: return 64000;
911 case HDSP_spdifFrequency88_2KHz: return 88200; 932 case HDSP_spdifFrequency88_2KHz: return 88200;
912 case HDSP_spdifFrequency96KHz: return 96000; 933 case HDSP_spdifFrequency96KHz: return 96000;
913 case HDSP_spdifFrequency128KHz: 934 case HDSP_spdifFrequency128KHz:
914 if (hdsp->io_type == H9632) return 128000; 935 if (hdsp->io_type == H9632) return 128000;
915 break; 936 break;
916 case HDSP_spdifFrequency176_4KHz: 937 case HDSP_spdifFrequency176_4KHz:
917 if (hdsp->io_type == H9632) return 176400; 938 if (hdsp->io_type == H9632) return 176400;
918 break; 939 break;
919 case HDSP_spdifFrequency192KHz: 940 case HDSP_spdifFrequency192KHz:
920 if (hdsp->io_type == H9632) return 192000; 941 if (hdsp->io_type == H9632) return 192000;
921 break; 942 break;
922 default: 943 default:
@@ -1027,7 +1048,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1027{ 1048{
1028 u64 n; 1049 u64 n;
1029 u32 r; 1050 u32 r;
1030 1051
1031 if (rate >= 112000) 1052 if (rate >= 112000)
1032 rate /= 4; 1053 rate /= 4;
1033 else if (rate >= 56000) 1054 else if (rate >= 56000)
@@ -1053,35 +1074,35 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1053 there is no need for it (e.g. during module 1074 there is no need for it (e.g. during module
1054 initialization). 1075 initialization).
1055 */ 1076 */
1056 1077
1057 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 1078 if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
1058 if (called_internally) { 1079 if (called_internally) {
1059 /* request from ctl or card initialization */ 1080 /* request from ctl or card initialization */
1060 snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n"); 1081 snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
1061 return -1; 1082 return -1;
1062 } else { 1083 } else {
1063 /* hw_param request while in AutoSync mode */ 1084 /* hw_param request while in AutoSync mode */
1064 int external_freq = hdsp_external_sample_rate(hdsp); 1085 int external_freq = hdsp_external_sample_rate(hdsp);
1065 int spdif_freq = hdsp_spdif_sample_rate(hdsp); 1086 int spdif_freq = hdsp_spdif_sample_rate(hdsp);
1066 1087
1067 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1088 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1068 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n"); 1089 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
1069 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1090 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1070 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n"); 1091 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");
1071 else if (rate != external_freq) { 1092 else if (rate != external_freq) {
1072 snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n"); 1093 snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
1073 return -1; 1094 return -1;
1074 } 1095 }
1075 } 1096 }
1076 } 1097 }
1077 1098
1078 current_rate = hdsp->system_sample_rate; 1099 current_rate = hdsp->system_sample_rate;
1079 1100
1080 /* Changing from a "single speed" to a "double speed" rate is 1101 /* Changing from a "single speed" to a "double speed" rate is
1081 not allowed if any substreams are open. This is because 1102 not allowed if any substreams are open. This is because
1082 such a change causes a shift in the location of 1103 such a change causes a shift in the location of
1083 the DMA buffers and a reduction in the number of available 1104 the DMA buffers and a reduction in the number of available
1084 buffers. 1105 buffers.
1085 1106
1086 Note that a similar but essentially insoluble problem 1107 Note that a similar but essentially insoluble problem
1087 exists for externally-driven rate changes. All we can do 1108 exists for externally-driven rate changes. All we can do
@@ -1089,7 +1110,7 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1089 1110
1090 if (rate > 96000 && hdsp->io_type != H9632) 1111 if (rate > 96000 && hdsp->io_type != H9632)
1091 return -EINVAL; 1112 return -EINVAL;
1092 1113
1093 switch (rate) { 1114 switch (rate) {
1094 case 32000: 1115 case 32000:
1095 if (current_rate > 48000) 1116 if (current_rate > 48000)
@@ -1179,7 +1200,7 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1179 break; 1200 break;
1180 } 1201 }
1181 } 1202 }
1182 1203
1183 hdsp->system_sample_rate = rate; 1204 hdsp->system_sample_rate = rate;
1184 1205
1185 return 0; 1206 return 0;
@@ -1245,16 +1266,16 @@ static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)
1245 unsigned char buf[128]; 1266 unsigned char buf[128];
1246 1267
1247 /* Output is not interrupt driven */ 1268 /* Output is not interrupt driven */
1248 1269
1249 spin_lock_irqsave (&hmidi->lock, flags); 1270 spin_lock_irqsave (&hmidi->lock, flags);
1250 if (hmidi->output) { 1271 if (hmidi->output) {
1251 if (!snd_rawmidi_transmit_empty (hmidi->output)) { 1272 if (!snd_rawmidi_transmit_empty (hmidi->output)) {
1252 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) { 1273 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) {
1253 if (n_pending > (int)sizeof (buf)) 1274 if (n_pending > (int)sizeof (buf))
1254 n_pending = sizeof (buf); 1275 n_pending = sizeof (buf);
1255 1276
1256 if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) { 1277 if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) {
1257 for (i = 0; i < to_write; ++i) 1278 for (i = 0; i < to_write; ++i)
1258 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); 1279 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]);
1259 } 1280 }
1260 } 1281 }
@@ -1325,14 +1346,14 @@ static void snd_hdsp_midi_output_timer(unsigned long data)
1325{ 1346{
1326 struct hdsp_midi *hmidi = (struct hdsp_midi *) data; 1347 struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
1327 unsigned long flags; 1348 unsigned long flags;
1328 1349
1329 snd_hdsp_midi_output_write(hmidi); 1350 snd_hdsp_midi_output_write(hmidi);
1330 spin_lock_irqsave (&hmidi->lock, flags); 1351 spin_lock_irqsave (&hmidi->lock, flags);
1331 1352
1332 /* this does not bump hmidi->istimer, because the 1353 /* this does not bump hmidi->istimer, because the
1333 kernel automatically removed the timer when it 1354 kernel automatically removed the timer when it
1334 expired, and we are now adding it back, thus 1355 expired, and we are now adding it back, thus
1335 leaving istimer wherever it was set before. 1356 leaving istimer wherever it was set before.
1336 */ 1357 */
1337 1358
1338 if (hmidi->istimer) { 1359 if (hmidi->istimer) {
@@ -1501,7 +1522,7 @@ static int snd_hdsp_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd
1501static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1522static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1502{ 1523{
1503 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1524 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1504 1525
1505 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); 1526 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif);
1506 return 0; 1527 return 0;
1507} 1528}
@@ -1511,7 +1532,7 @@ static int snd_hdsp_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_
1511 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1532 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1512 int change; 1533 int change;
1513 u32 val; 1534 u32 val;
1514 1535
1515 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958); 1536 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
1516 spin_lock_irq(&hdsp->lock); 1537 spin_lock_irq(&hdsp->lock);
1517 change = val != hdsp->creg_spdif; 1538 change = val != hdsp->creg_spdif;
@@ -1530,7 +1551,7 @@ static int snd_hdsp_control_spdif_stream_info(struct snd_kcontrol *kcontrol, str
1530static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1551static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1531{ 1552{
1532 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1553 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1533 1554
1534 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); 1555 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream);
1535 return 0; 1556 return 0;
1536} 1557}
@@ -1540,7 +1561,7 @@ static int snd_hdsp_control_spdif_stream_put(struct snd_kcontrol *kcontrol, stru
1540 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1561 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1541 int change; 1562 int change;
1542 u32 val; 1563 u32 val;
1543 1564
1544 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958); 1565 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
1545 spin_lock_irq(&hdsp->lock); 1566 spin_lock_irq(&hdsp->lock);
1546 change = val != hdsp->creg_spdif_stream; 1567 change = val != hdsp->creg_spdif_stream;
@@ -1602,7 +1623,7 @@ static int snd_hdsp_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_
1602static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1623static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1603{ 1624{
1604 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1625 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1605 1626
1606 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); 1627 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp);
1607 return 0; 1628 return 0;
1608} 1629}
@@ -1612,7 +1633,7 @@ static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1612 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1633 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1613 int change; 1634 int change;
1614 unsigned int val; 1635 unsigned int val;
1615 1636
1616 if (!snd_hdsp_use_is_exclusive(hdsp)) 1637 if (!snd_hdsp_use_is_exclusive(hdsp))
1617 return -EBUSY; 1638 return -EBUSY;
1618 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); 1639 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3);
@@ -1649,7 +1670,7 @@ static int hdsp_set_spdif_output(struct hdsp *hdsp, int out)
1649static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1670static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1650{ 1671{
1651 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1672 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1652 1673
1653 ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp); 1674 ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp);
1654 return 0; 1675 return 0;
1655} 1676}
@@ -1659,7 +1680,7 @@ static int snd_hdsp_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_
1659 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1680 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1660 int change; 1681 int change;
1661 unsigned int val; 1682 unsigned int val;
1662 1683
1663 if (!snd_hdsp_use_is_exclusive(hdsp)) 1684 if (!snd_hdsp_use_is_exclusive(hdsp))
1664 return -EBUSY; 1685 return -EBUSY;
1665 val = ucontrol->value.integer.value[0] & 1; 1686 val = ucontrol->value.integer.value[0] & 1;
@@ -1693,7 +1714,7 @@ static int hdsp_set_spdif_professional(struct hdsp *hdsp, int val)
1693static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1714static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1694{ 1715{
1695 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1716 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1696 1717
1697 ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp); 1718 ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp);
1698 return 0; 1719 return 0;
1699} 1720}
@@ -1703,7 +1724,7 @@ static int snd_hdsp_put_spdif_professional(struct snd_kcontrol *kcontrol, struct
1703 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1724 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1704 int change; 1725 int change;
1705 unsigned int val; 1726 unsigned int val;
1706 1727
1707 if (!snd_hdsp_use_is_exclusive(hdsp)) 1728 if (!snd_hdsp_use_is_exclusive(hdsp))
1708 return -EBUSY; 1729 return -EBUSY;
1709 val = ucontrol->value.integer.value[0] & 1; 1730 val = ucontrol->value.integer.value[0] & 1;
@@ -1737,7 +1758,7 @@ static int hdsp_set_spdif_emphasis(struct hdsp *hdsp, int val)
1737static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1758static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1738{ 1759{
1739 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1760 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1740 1761
1741 ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp); 1762 ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);
1742 return 0; 1763 return 0;
1743} 1764}
@@ -1747,7 +1768,7 @@ static int snd_hdsp_put_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd
1747 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1768 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1748 int change; 1769 int change;
1749 unsigned int val; 1770 unsigned int val;
1750 1771
1751 if (!snd_hdsp_use_is_exclusive(hdsp)) 1772 if (!snd_hdsp_use_is_exclusive(hdsp))
1752 return -EBUSY; 1773 return -EBUSY;
1753 val = ucontrol->value.integer.value[0] & 1; 1774 val = ucontrol->value.integer.value[0] & 1;
@@ -1781,7 +1802,7 @@ static int hdsp_set_spdif_nonaudio(struct hdsp *hdsp, int val)
1781static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1802static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1782{ 1803{
1783 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1804 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1784 1805
1785 ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp); 1806 ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);
1786 return 0; 1807 return 0;
1787} 1808}
@@ -1791,7 +1812,7 @@ static int snd_hdsp_put_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd
1791 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1812 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1792 int change; 1813 int change;
1793 unsigned int val; 1814 unsigned int val;
1794 1815
1795 if (!snd_hdsp_use_is_exclusive(hdsp)) 1816 if (!snd_hdsp_use_is_exclusive(hdsp))
1796 return -EBUSY; 1817 return -EBUSY;
1797 val = ucontrol->value.integer.value[0] & 1; 1818 val = ucontrol->value.integer.value[0] & 1;
@@ -1828,7 +1849,7 @@ static int snd_hdsp_info_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct
1828static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1849static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1829{ 1850{
1830 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1851 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1831 1852
1832 switch (hdsp_spdif_sample_rate(hdsp)) { 1853 switch (hdsp_spdif_sample_rate(hdsp)) {
1833 case 32000: 1854 case 32000:
1834 ucontrol->value.enumerated.item[0] = 0; 1855 ucontrol->value.enumerated.item[0] = 0;
@@ -1858,7 +1879,7 @@ static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct
1858 ucontrol->value.enumerated.item[0] = 9; 1879 ucontrol->value.enumerated.item[0] = 9;
1859 break; 1880 break;
1860 default: 1881 default:
1861 ucontrol->value.enumerated.item[0] = 6; 1882 ucontrol->value.enumerated.item[0] = 6;
1862 } 1883 }
1863 return 0; 1884 return 0;
1864} 1885}
@@ -1882,7 +1903,7 @@ static int snd_hdsp_info_system_sample_rate(struct snd_kcontrol *kcontrol, struc
1882static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1903static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1883{ 1904{
1884 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1905 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1885 1906
1886 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; 1907 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;
1887 return 0; 1908 return 0;
1888} 1909}
@@ -1899,7 +1920,7 @@ static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct
1899static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1920static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1900{ 1921{
1901 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1922 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1902 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"}; 1923 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
1903 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1924 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1904 uinfo->count = 1; 1925 uinfo->count = 1;
1905 uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ; 1926 uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ;
@@ -1912,7 +1933,7 @@ static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, str
1912static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1933static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1913{ 1934{
1914 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1935 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1915 1936
1916 switch (hdsp_external_sample_rate(hdsp)) { 1937 switch (hdsp_external_sample_rate(hdsp)) {
1917 case 32000: 1938 case 32000:
1918 ucontrol->value.enumerated.item[0] = 0; 1939 ucontrol->value.enumerated.item[0] = 0;
@@ -1940,9 +1961,9 @@ static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, stru
1940 break; 1961 break;
1941 case 192000: 1962 case 192000:
1942 ucontrol->value.enumerated.item[0] = 9; 1963 ucontrol->value.enumerated.item[0] = 9;
1943 break; 1964 break;
1944 default: 1965 default:
1945 ucontrol->value.enumerated.item[0] = 6; 1966 ucontrol->value.enumerated.item[0] = 6;
1946 } 1967 }
1947 return 0; 1968 return 0;
1948} 1969}
@@ -1968,7 +1989,7 @@ static int hdsp_system_clock_mode(struct hdsp *hdsp)
1968static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1989static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1969{ 1990{
1970 static char *texts[] = {"Master", "Slave" }; 1991 static char *texts[] = {"Master", "Slave" };
1971 1992
1972 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1993 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1973 uinfo->count = 1; 1994 uinfo->count = 1;
1974 uinfo->value.enumerated.items = 2; 1995 uinfo->value.enumerated.items = 2;
@@ -1981,7 +2002,7 @@ static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct
1981static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2002static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1982{ 2003{
1983 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2004 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1984 2005
1985 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); 2006 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);
1986 return 0; 2007 return 0;
1987} 2008}
@@ -2018,7 +2039,7 @@ static int hdsp_clock_source(struct hdsp *hdsp)
2018 case 192000: 2039 case 192000:
2019 return 9; 2040 return 9;
2020 default: 2041 default:
2021 return 3; 2042 return 3;
2022 } 2043 }
2023 } else { 2044 } else {
2024 return 0; 2045 return 0;
@@ -2032,7 +2053,7 @@ static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
2032 case HDSP_CLOCK_SOURCE_AUTOSYNC: 2053 case HDSP_CLOCK_SOURCE_AUTOSYNC:
2033 if (hdsp_external_sample_rate(hdsp) != 0) { 2054 if (hdsp_external_sample_rate(hdsp) != 0) {
2034 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { 2055 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) {
2035 hdsp->control_register &= ~HDSP_ClockModeMaster; 2056 hdsp->control_register &= ~HDSP_ClockModeMaster;
2036 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 2057 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
2037 return 0; 2058 return 0;
2038 } 2059 }
@@ -2043,7 +2064,7 @@ static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
2043 break; 2064 break;
2044 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ: 2065 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ:
2045 rate = 44100; 2066 rate = 44100;
2046 break; 2067 break;
2047 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ: 2068 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ:
2048 rate = 48000; 2069 rate = 48000;
2049 break; 2070 break;
@@ -2078,13 +2099,13 @@ static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_
2078{ 2099{
2079 static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" }; 2100 static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
2080 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2101 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2081 2102
2082 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2103 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2083 uinfo->count = 1; 2104 uinfo->count = 1;
2084 if (hdsp->io_type == H9632) 2105 if (hdsp->io_type == H9632)
2085 uinfo->value.enumerated.items = 10; 2106 uinfo->value.enumerated.items = 10;
2086 else 2107 else
2087 uinfo->value.enumerated.items = 7; 2108 uinfo->value.enumerated.items = 7;
2088 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2109 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2089 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2110 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2090 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2111 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
@@ -2094,7 +2115,7 @@ static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_
2094static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2115static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2095{ 2116{
2096 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2117 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2097 2118
2098 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); 2119 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);
2099 return 0; 2120 return 0;
2100} 2121}
@@ -2104,7 +2125,7 @@ static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_c
2104 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2105 int change; 2126 int change;
2106 int val; 2127 int val;
2107 2128
2108 if (!snd_hdsp_use_is_exclusive(hdsp)) 2129 if (!snd_hdsp_use_is_exclusive(hdsp))
2109 return -EBUSY; 2130 return -EBUSY;
2110 val = ucontrol->value.enumerated.item[0]; 2131 val = ucontrol->value.enumerated.item[0];
@@ -2130,7 +2151,7 @@ static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_c
2130static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2151static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2131{ 2152{
2132 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2153 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2133 2154
2134 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; 2155 ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
2135 return 0; 2156 return 0;
2136} 2157}
@@ -2165,7 +2186,7 @@ static int hdsp_da_gain(struct hdsp *hdsp)
2165 case HDSP_DAGainMinus10dBV: 2186 case HDSP_DAGainMinus10dBV:
2166 return 2; 2187 return 2;
2167 default: 2188 default:
2168 return 1; 2189 return 1;
2169 } 2190 }
2170} 2191}
2171 2192
@@ -2180,8 +2201,8 @@ static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
2180 hdsp->control_register |= HDSP_DAGainPlus4dBu; 2201 hdsp->control_register |= HDSP_DAGainPlus4dBu;
2181 break; 2202 break;
2182 case 2: 2203 case 2:
2183 hdsp->control_register |= HDSP_DAGainMinus10dBV; 2204 hdsp->control_register |= HDSP_DAGainMinus10dBV;
2184 break; 2205 break;
2185 default: 2206 default:
2186 return -1; 2207 return -1;
2187 2208
@@ -2193,7 +2214,7 @@ static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
2193static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2214static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2194{ 2215{
2195 static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"}; 2216 static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
2196 2217
2197 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2218 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2198 uinfo->count = 1; 2219 uinfo->count = 1;
2199 uinfo->value.enumerated.items = 3; 2220 uinfo->value.enumerated.items = 3;
@@ -2206,7 +2227,7 @@ static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2206static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2227static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2207{ 2228{
2208 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2229 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2209 2230
2210 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); 2231 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
2211 return 0; 2232 return 0;
2212} 2233}
@@ -2216,7 +2237,7 @@ static int snd_hdsp_put_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_el
2216 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2237 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2217 int change; 2238 int change;
2218 int val; 2239 int val;
2219 2240
2220 if (!snd_hdsp_use_is_exclusive(hdsp)) 2241 if (!snd_hdsp_use_is_exclusive(hdsp))
2221 return -EBUSY; 2242 return -EBUSY;
2222 val = ucontrol->value.enumerated.item[0]; 2243 val = ucontrol->value.enumerated.item[0];
@@ -2250,7 +2271,7 @@ static int hdsp_ad_gain(struct hdsp *hdsp)
2250 case HDSP_ADGainLowGain: 2271 case HDSP_ADGainLowGain:
2251 return 2; 2272 return 2;
2252 default: 2273 default:
2253 return 1; 2274 return 1;
2254 } 2275 }
2255} 2276}
2256 2277
@@ -2262,11 +2283,11 @@ static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
2262 hdsp->control_register |= HDSP_ADGainMinus10dBV; 2283 hdsp->control_register |= HDSP_ADGainMinus10dBV;
2263 break; 2284 break;
2264 case 1: 2285 case 1:
2265 hdsp->control_register |= HDSP_ADGainPlus4dBu; 2286 hdsp->control_register |= HDSP_ADGainPlus4dBu;
2266 break; 2287 break;
2267 case 2: 2288 case 2:
2268 hdsp->control_register |= HDSP_ADGainLowGain; 2289 hdsp->control_register |= HDSP_ADGainLowGain;
2269 break; 2290 break;
2270 default: 2291 default:
2271 return -1; 2292 return -1;
2272 2293
@@ -2278,7 +2299,7 @@ static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
2278static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2299static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2279{ 2300{
2280 static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"}; 2301 static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
2281 2302
2282 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2303 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2283 uinfo->count = 1; 2304 uinfo->count = 1;
2284 uinfo->value.enumerated.items = 3; 2305 uinfo->value.enumerated.items = 3;
@@ -2291,7 +2312,7 @@ static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2291static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2312static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2292{ 2313{
2293 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2314 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2294 2315
2295 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); 2316 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
2296 return 0; 2317 return 0;
2297} 2318}
@@ -2301,7 +2322,7 @@ static int snd_hdsp_put_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_el
2301 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2322 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2302 int change; 2323 int change;
2303 int val; 2324 int val;
2304 2325
2305 if (!snd_hdsp_use_is_exclusive(hdsp)) 2326 if (!snd_hdsp_use_is_exclusive(hdsp))
2306 return -EBUSY; 2327 return -EBUSY;
2307 val = ucontrol->value.enumerated.item[0]; 2328 val = ucontrol->value.enumerated.item[0];
@@ -2335,7 +2356,7 @@ static int hdsp_phone_gain(struct hdsp *hdsp)
2335 case HDSP_PhoneGainMinus12dB: 2356 case HDSP_PhoneGainMinus12dB:
2336 return 2; 2357 return 2;
2337 default: 2358 default:
2338 return 0; 2359 return 0;
2339 } 2360 }
2340} 2361}
2341 2362
@@ -2347,11 +2368,11 @@ static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
2347 hdsp->control_register |= HDSP_PhoneGain0dB; 2368 hdsp->control_register |= HDSP_PhoneGain0dB;
2348 break; 2369 break;
2349 case 1: 2370 case 1:
2350 hdsp->control_register |= HDSP_PhoneGainMinus6dB; 2371 hdsp->control_register |= HDSP_PhoneGainMinus6dB;
2351 break; 2372 break;
2352 case 2: 2373 case 2:
2353 hdsp->control_register |= HDSP_PhoneGainMinus12dB; 2374 hdsp->control_register |= HDSP_PhoneGainMinus12dB;
2354 break; 2375 break;
2355 default: 2376 default:
2356 return -1; 2377 return -1;
2357 2378
@@ -2363,7 +2384,7 @@ static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
2363static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2384static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2364{ 2385{
2365 static char *texts[] = {"0 dB", "-6 dB", "-12 dB"}; 2386 static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
2366 2387
2367 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2388 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2368 uinfo->count = 1; 2389 uinfo->count = 1;
2369 uinfo->value.enumerated.items = 3; 2390 uinfo->value.enumerated.items = 3;
@@ -2376,7 +2397,7 @@ static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ct
2376static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2397static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2377{ 2398{
2378 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2399 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2379 2400
2380 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); 2401 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
2381 return 0; 2402 return 0;
2382} 2403}
@@ -2386,7 +2407,7 @@ static int snd_hdsp_put_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl
2386 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2407 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2387 int change; 2408 int change;
2388 int val; 2409 int val;
2389 2410
2390 if (!snd_hdsp_use_is_exclusive(hdsp)) 2411 if (!snd_hdsp_use_is_exclusive(hdsp))
2391 return -EBUSY; 2412 return -EBUSY;
2392 val = ucontrol->value.enumerated.item[0]; 2413 val = ucontrol->value.enumerated.item[0];
@@ -2432,7 +2453,7 @@ static int hdsp_set_xlr_breakout_cable(struct hdsp *hdsp, int mode)
2432static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2453static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2433{ 2454{
2434 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2455 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2435 2456
2436 ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp); 2457 ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
2437 return 0; 2458 return 0;
2438} 2459}
@@ -2442,7 +2463,7 @@ static int snd_hdsp_put_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct
2442 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2463 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2443 int change; 2464 int change;
2444 int val; 2465 int val;
2445 2466
2446 if (!snd_hdsp_use_is_exclusive(hdsp)) 2467 if (!snd_hdsp_use_is_exclusive(hdsp))
2447 return -EBUSY; 2468 return -EBUSY;
2448 val = ucontrol->value.integer.value[0] & 1; 2469 val = ucontrol->value.integer.value[0] & 1;
@@ -2488,7 +2509,7 @@ static int hdsp_set_aeb(struct hdsp *hdsp, int mode)
2488static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2509static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2489{ 2510{
2490 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2511 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2491 2512
2492 ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp); 2513 ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
2493 return 0; 2514 return 0;
2494} 2515}
@@ -2498,7 +2519,7 @@ static int snd_hdsp_put_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
2498 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2519 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2499 int change; 2520 int change;
2500 int val; 2521 int val;
2501 2522
2502 if (!snd_hdsp_use_is_exclusive(hdsp)) 2523 if (!snd_hdsp_use_is_exclusive(hdsp))
2503 return -EBUSY; 2524 return -EBUSY;
2504 val = ucontrol->value.integer.value[0] & 1; 2525 val = ucontrol->value.integer.value[0] & 1;
@@ -2576,7 +2597,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2576{ 2597{
2577 static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" }; 2598 static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
2578 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2599 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2579 2600
2580 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2601 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2581 uinfo->count = 1; 2602 uinfo->count = 1;
2582 2603
@@ -2595,7 +2616,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2595 uinfo->value.enumerated.items = 0; 2616 uinfo->value.enumerated.items = 0;
2596 break; 2617 break;
2597 } 2618 }
2598 2619
2599 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2620 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2600 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2621 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2601 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
@@ -2605,7 +2626,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2605static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2626static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2606{ 2627{
2607 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2628 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2608 2629
2609 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); 2630 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
2610 return 0; 2631 return 0;
2611} 2632}
@@ -2615,7 +2636,7 @@ static int snd_hdsp_put_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_
2615 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2636 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2616 int change, max; 2637 int change, max;
2617 unsigned int val; 2638 unsigned int val;
2618 2639
2619 if (!snd_hdsp_use_is_exclusive(hdsp)) 2640 if (!snd_hdsp_use_is_exclusive(hdsp))
2620 return -EBUSY; 2641 return -EBUSY;
2621 2642
@@ -2664,7 +2685,7 @@ static int hdsp_autosync_ref(struct hdsp *hdsp)
2664 case HDSP_SelSyncRef_SPDIF: 2685 case HDSP_SelSyncRef_SPDIF:
2665 return HDSP_AUTOSYNC_FROM_SPDIF; 2686 return HDSP_AUTOSYNC_FROM_SPDIF;
2666 case HDSP_SelSyncRefMask: 2687 case HDSP_SelSyncRefMask:
2667 return HDSP_AUTOSYNC_FROM_NONE; 2688 return HDSP_AUTOSYNC_FROM_NONE;
2668 case HDSP_SelSyncRef_ADAT1: 2689 case HDSP_SelSyncRef_ADAT1:
2669 return HDSP_AUTOSYNC_FROM_ADAT1; 2690 return HDSP_AUTOSYNC_FROM_ADAT1;
2670 case HDSP_SelSyncRef_ADAT2: 2691 case HDSP_SelSyncRef_ADAT2:
@@ -2680,7 +2701,7 @@ static int hdsp_autosync_ref(struct hdsp *hdsp)
2680static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2701static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2681{ 2702{
2682 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" }; 2703 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" };
2683 2704
2684 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2705 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2685 uinfo->count = 1; 2706 uinfo->count = 1;
2686 uinfo->value.enumerated.items = 7; 2707 uinfo->value.enumerated.items = 7;
@@ -2693,7 +2714,7 @@ static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_
2693static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2714static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2694{ 2715{
2695 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2716 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2696 2717
2697 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); 2718 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp);
2698 return 0; 2719 return 0;
2699} 2720}
@@ -2727,7 +2748,7 @@ static int hdsp_set_line_output(struct hdsp *hdsp, int out)
2727static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2748static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2728{ 2749{
2729 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2750 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2730 2751
2731 spin_lock_irq(&hdsp->lock); 2752 spin_lock_irq(&hdsp->lock);
2732 ucontrol->value.integer.value[0] = hdsp_line_out(hdsp); 2753 ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
2733 spin_unlock_irq(&hdsp->lock); 2754 spin_unlock_irq(&hdsp->lock);
@@ -2739,7 +2760,7 @@ static int snd_hdsp_put_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2739 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2760 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2740 int change; 2761 int change;
2741 unsigned int val; 2762 unsigned int val;
2742 2763
2743 if (!snd_hdsp_use_is_exclusive(hdsp)) 2764 if (!snd_hdsp_use_is_exclusive(hdsp))
2744 return -EBUSY; 2765 return -EBUSY;
2745 val = ucontrol->value.integer.value[0] & 1; 2766 val = ucontrol->value.integer.value[0] & 1;
@@ -2773,7 +2794,7 @@ static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise)
2773static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2794static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2774{ 2795{
2775 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2796 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2776 2797
2777 spin_lock_irq(&hdsp->lock); 2798 spin_lock_irq(&hdsp->lock);
2778 ucontrol->value.integer.value[0] = hdsp->precise_ptr; 2799 ucontrol->value.integer.value[0] = hdsp->precise_ptr;
2779 spin_unlock_irq(&hdsp->lock); 2800 spin_unlock_irq(&hdsp->lock);
@@ -2785,7 +2806,7 @@ static int snd_hdsp_put_precise_pointer(struct snd_kcontrol *kcontrol, struct sn
2785 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2806 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2786 int change; 2807 int change;
2787 unsigned int val; 2808 unsigned int val;
2788 2809
2789 if (!snd_hdsp_use_is_exclusive(hdsp)) 2810 if (!snd_hdsp_use_is_exclusive(hdsp))
2790 return -EBUSY; 2811 return -EBUSY;
2791 val = ucontrol->value.integer.value[0] & 1; 2812 val = ucontrol->value.integer.value[0] & 1;
@@ -2819,7 +2840,7 @@ static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet)
2819static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2840static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2820{ 2841{
2821 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2842 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2822 2843
2823 spin_lock_irq(&hdsp->lock); 2844 spin_lock_irq(&hdsp->lock);
2824 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet; 2845 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet;
2825 spin_unlock_irq(&hdsp->lock); 2846 spin_unlock_irq(&hdsp->lock);
@@ -2831,7 +2852,7 @@ static int snd_hdsp_put_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct s
2831 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2852 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2832 int change; 2853 int change;
2833 unsigned int val; 2854 unsigned int val;
2834 2855
2835 if (!snd_hdsp_use_is_exclusive(hdsp)) 2856 if (!snd_hdsp_use_is_exclusive(hdsp))
2836 return -EBUSY; 2857 return -EBUSY;
2837 val = ucontrol->value.integer.value[0] & 1; 2858 val = ucontrol->value.integer.value[0] & 1;
@@ -2873,12 +2894,12 @@ static int snd_hdsp_get_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
2873 2894
2874 source = ucontrol->value.integer.value[0]; 2895 source = ucontrol->value.integer.value[0];
2875 destination = ucontrol->value.integer.value[1]; 2896 destination = ucontrol->value.integer.value[1];
2876 2897
2877 if (source >= hdsp->max_channels) 2898 if (source >= hdsp->max_channels)
2878 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); 2899 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
2879 else 2900 else
2880 addr = hdsp_input_to_output_key(hdsp,source, destination); 2901 addr = hdsp_input_to_output_key(hdsp,source, destination);
2881 2902
2882 spin_lock_irq(&hdsp->lock); 2903 spin_lock_irq(&hdsp->lock);
2883 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); 2904 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr);
2884 spin_unlock_irq(&hdsp->lock); 2905 spin_unlock_irq(&hdsp->lock);
@@ -2926,7 +2947,7 @@ static int snd_hdsp_put_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
2926 2947
2927static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2948static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2928{ 2949{
2929 static char *texts[] = {"No Lock", "Lock", "Sync" }; 2950 static char *texts[] = {"No Lock", "Lock", "Sync" };
2930 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2951 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2931 uinfo->count = 1; 2952 uinfo->count = 1;
2932 uinfo->value.enumerated.items = 3; 2953 uinfo->value.enumerated.items = 3;
@@ -2971,7 +2992,7 @@ static int hdsp_spdif_sync_check(struct hdsp *hdsp)
2971 int status = hdsp_read(hdsp, HDSP_statusRegister); 2992 int status = hdsp_read(hdsp, HDSP_statusRegister);
2972 if (status & HDSP_SPDIFErrorFlag) 2993 if (status & HDSP_SPDIFErrorFlag)
2973 return 0; 2994 return 0;
2974 else { 2995 else {
2975 if (status & HDSP_SPDIFSync) 2996 if (status & HDSP_SPDIFSync)
2976 return 2; 2997 return 2;
2977 else 2998 else
@@ -3007,7 +3028,7 @@ static int hdsp_adatsync_sync_check(struct hdsp *hdsp)
3007 return 1; 3028 return 1;
3008 } else 3029 } else
3009 return 0; 3030 return 0;
3010} 3031}
3011 3032
3012static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3033static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3013{ 3034{
@@ -3025,17 +3046,17 @@ static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struc
3025} 3046}
3026 3047
3027static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) 3048static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx)
3028{ 3049{
3029 int status = hdsp_read(hdsp, HDSP_statusRegister); 3050 int status = hdsp_read(hdsp, HDSP_statusRegister);
3030 3051
3031 if (status & (HDSP_Lock0>>idx)) { 3052 if (status & (HDSP_Lock0>>idx)) {
3032 if (status & (HDSP_Sync0>>idx)) 3053 if (status & (HDSP_Sync0>>idx))
3033 return 2; 3054 return 2;
3034 else 3055 else
3035 return 1; 3056 return 1;
3036 } else 3057 } else
3037 return 0; 3058 return 0;
3038} 3059}
3039 3060
3040static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3061static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3041{ 3062{
@@ -3053,7 +3074,7 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3053 break; 3074 break;
3054 case Multiface: 3075 case Multiface:
3055 case H9632: 3076 case H9632:
3056 if (offset >= 1) 3077 if (offset >= 1)
3057 return -EINVAL; 3078 return -EINVAL;
3058 break; 3079 break;
3059 default: 3080 default:
@@ -3115,7 +3136,7 @@ static int snd_hdsp_info_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ct
3115static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3136static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3116{ 3137{
3117 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3138 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3118 3139
3119 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp); 3140 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
3120 return 0; 3141 return 0;
3121} 3142}
@@ -3125,7 +3146,7 @@ static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl
3125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3146 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3126 int change; 3147 int change;
3127 int val; 3148 int val;
3128 3149
3129 if (!snd_hdsp_use_is_exclusive(hdsp)) 3150 if (!snd_hdsp_use_is_exclusive(hdsp))
3130 return -EBUSY; 3151 return -EBUSY;
3131 val = ucontrol->value.enumerated.item[0]; 3152 val = ucontrol->value.enumerated.item[0];
@@ -3170,7 +3191,7 @@ static struct snd_kcontrol_new snd_hdsp_controls[] = {
3170 .get = snd_hdsp_control_spdif_mask_get, 3191 .get = snd_hdsp_control_spdif_mask_get,
3171 .private_value = IEC958_AES0_NONAUDIO | 3192 .private_value = IEC958_AES0_NONAUDIO |
3172 IEC958_AES0_PROFESSIONAL | 3193 IEC958_AES0_PROFESSIONAL |
3173 IEC958_AES0_CON_EMPHASIS, 3194 IEC958_AES0_CON_EMPHASIS,
3174}, 3195},
3175{ 3196{
3176 .access = SNDRV_CTL_ELEM_ACCESS_READ, 3197 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -3188,7 +3209,7 @@ HDSP_SPDIF_OUT("IEC958 Output also on ADAT1", 0),
3188HDSP_SPDIF_PROFESSIONAL("IEC958 Professional Bit", 0), 3209HDSP_SPDIF_PROFESSIONAL("IEC958 Professional Bit", 0),
3189HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0), 3210HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0),
3190HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), 3211HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
3191/* 'Sample Clock Source' complies with the alsa control naming scheme */ 3212/* 'Sample Clock Source' complies with the alsa control naming scheme */
3192HDSP_CLOCK_SOURCE("Sample Clock Source", 0), 3213HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
3193{ 3214{
3194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -3240,7 +3261,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
3240 return err; 3261 return err;
3241 } 3262 }
3242 } 3263 }
3243 3264
3244 /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */ 3265 /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
3245 if (hdsp->io_type == H9632) { 3266 if (hdsp->io_type == H9632) {
3246 for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) { 3267 for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) {
@@ -3259,7 +3280,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
3259} 3280}
3260 3281
3261/*------------------------------------------------------------ 3282/*------------------------------------------------------------
3262 /proc interface 3283 /proc interface
3263 ------------------------------------------------------------*/ 3284 ------------------------------------------------------------*/
3264 3285
3265static void 3286static void
@@ -3298,7 +3319,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3298 } 3319 }
3299 } 3320 }
3300 } 3321 }
3301 3322
3302 status = hdsp_read(hdsp, HDSP_statusRegister); 3323 status = hdsp_read(hdsp, HDSP_statusRegister);
3303 status2 = hdsp_read(hdsp, HDSP_status2Register); 3324 status2 = hdsp_read(hdsp, HDSP_status2Register);
3304 3325
@@ -3362,17 +3383,17 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3362 break; 3383 break;
3363 case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ: 3384 case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:
3364 clock_source = "Internal 192 kHz"; 3385 clock_source = "Internal 192 kHz";
3365 break; 3386 break;
3366 default: 3387 default:
3367 clock_source = "Error"; 3388 clock_source = "Error";
3368 } 3389 }
3369 snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source); 3390 snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source);
3370 3391
3371 if (hdsp_system_clock_mode(hdsp)) 3392 if (hdsp_system_clock_mode(hdsp))
3372 system_clock_mode = "Slave"; 3393 system_clock_mode = "Slave";
3373 else 3394 else
3374 system_clock_mode = "Master"; 3395 system_clock_mode = "Master";
3375 3396
3376 switch (hdsp_pref_sync_ref (hdsp)) { 3397 switch (hdsp_pref_sync_ref (hdsp)) {
3377 case HDSP_SYNC_FROM_WORD: 3398 case HDSP_SYNC_FROM_WORD:
3378 pref_sync_ref = "Word Clock"; 3399 pref_sync_ref = "Word Clock";
@@ -3397,7 +3418,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3397 break; 3418 break;
3398 } 3419 }
3399 snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref); 3420 snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref);
3400 3421
3401 switch (hdsp_autosync_ref (hdsp)) { 3422 switch (hdsp_autosync_ref (hdsp)) {
3402 case HDSP_AUTOSYNC_FROM_WORD: 3423 case HDSP_AUTOSYNC_FROM_WORD:
3403 autosync_ref = "Word Clock"; 3424 autosync_ref = "Word Clock";
@@ -3410,7 +3431,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3410 break; 3431 break;
3411 case HDSP_AUTOSYNC_FROM_NONE: 3432 case HDSP_AUTOSYNC_FROM_NONE:
3412 autosync_ref = "None"; 3433 autosync_ref = "None";
3413 break; 3434 break;
3414 case HDSP_AUTOSYNC_FROM_ADAT1: 3435 case HDSP_AUTOSYNC_FROM_ADAT1:
3415 autosync_ref = "ADAT1"; 3436 autosync_ref = "ADAT1";
3416 break; 3437 break;
@@ -3425,14 +3446,14 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3425 break; 3446 break;
3426 } 3447 }
3427 snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref); 3448 snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref);
3428 3449
3429 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); 3450 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp));
3430 3451
3431 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); 3452 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
3432 3453
3433 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); 3454 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
3434 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); 3455 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
3435 3456
3436 snd_iprintf(buffer, "\n"); 3457 snd_iprintf(buffer, "\n");
3437 3458
3438 switch (hdsp_spdif_in(hdsp)) { 3459 switch (hdsp_spdif_in(hdsp)) {
@@ -3452,7 +3473,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3452 snd_iprintf(buffer, "IEC958 input: ???\n"); 3473 snd_iprintf(buffer, "IEC958 input: ???\n");
3453 break; 3474 break;
3454 } 3475 }
3455 3476
3456 if (hdsp->control_register & HDSP_SPDIFOpticalOut) 3477 if (hdsp->control_register & HDSP_SPDIFOpticalOut)
3457 snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n"); 3478 snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n");
3458 else 3479 else
@@ -3510,13 +3531,13 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3510 snd_iprintf (buffer, "SPDIF: No Lock\n"); 3531 snd_iprintf (buffer, "SPDIF: No Lock\n");
3511 else 3532 else
3512 snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock"); 3533 snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock");
3513 3534
3514 x = status2 & HDSP_wc_sync; 3535 x = status2 & HDSP_wc_sync;
3515 if (status2 & HDSP_wc_lock) 3536 if (status2 & HDSP_wc_lock)
3516 snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock"); 3537 snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock");
3517 else 3538 else
3518 snd_iprintf (buffer, "Word Clock: No Lock\n"); 3539 snd_iprintf (buffer, "Word Clock: No Lock\n");
3519 3540
3520 x = status & HDSP_TimecodeSync; 3541 x = status & HDSP_TimecodeSync;
3521 if (status & HDSP_TimecodeLock) 3542 if (status & HDSP_TimecodeLock)
3522 snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock"); 3543 snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock");
@@ -3524,11 +3545,11 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3524 snd_iprintf(buffer, "ADAT Sync: No Lock\n"); 3545 snd_iprintf(buffer, "ADAT Sync: No Lock\n");
3525 3546
3526 snd_iprintf(buffer, "\n"); 3547 snd_iprintf(buffer, "\n");
3527 3548
3528 /* Informations about H9632 specific controls */ 3549 /* Informations about H9632 specific controls */
3529 if (hdsp->io_type == H9632) { 3550 if (hdsp->io_type == H9632) {
3530 char *tmp; 3551 char *tmp;
3531 3552
3532 switch (hdsp_ad_gain(hdsp)) { 3553 switch (hdsp_ad_gain(hdsp)) {
3533 case 0: 3554 case 0:
3534 tmp = "-10 dBV"; 3555 tmp = "-10 dBV";
@@ -3554,7 +3575,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3554 break; 3575 break;
3555 } 3576 }
3556 snd_iprintf(buffer, "DA Gain : %s\n", tmp); 3577 snd_iprintf(buffer, "DA Gain : %s\n", tmp);
3557 3578
3558 switch (hdsp_phone_gain(hdsp)) { 3579 switch (hdsp_phone_gain(hdsp)) {
3559 case 0: 3580 case 0:
3560 tmp = "0 dB"; 3581 tmp = "0 dB";
@@ -3568,8 +3589,8 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3568 } 3589 }
3569 snd_iprintf(buffer, "Phones Gain : %s\n", tmp); 3590 snd_iprintf(buffer, "Phones Gain : %s\n", tmp);
3570 3591
3571 snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no"); 3592 snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no");
3572 3593
3573 if (hdsp->control_register & HDSP_AnalogExtensionBoard) 3594 if (hdsp->control_register & HDSP_AnalogExtensionBoard)
3574 snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n"); 3595 snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
3575 else 3596 else
@@ -3632,18 +3653,18 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3632 3653
3633 /* set defaults: 3654 /* set defaults:
3634 3655
3635 SPDIF Input via Coax 3656 SPDIF Input via Coax
3636 Master clock mode 3657 Master clock mode
3637 maximum latency (7 => 2^7 = 8192 samples, 64Kbyte buffer, 3658 maximum latency (7 => 2^7 = 8192 samples, 64Kbyte buffer,
3638 which implies 2 4096 sample, 32Kbyte periods). 3659 which implies 2 4096 sample, 32Kbyte periods).
3639 Enable line out. 3660 Enable line out.
3640 */ 3661 */
3641 3662
3642 hdsp->control_register = HDSP_ClockModeMaster | 3663 hdsp->control_register = HDSP_ClockModeMaster |
3643 HDSP_SPDIFInputCoaxial | 3664 HDSP_SPDIFInputCoaxial |
3644 hdsp_encode_latency(7) | 3665 hdsp_encode_latency(7) |
3645 HDSP_LineOut; 3666 HDSP_LineOut;
3646 3667
3647 3668
3648 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 3669 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
3649 3670
@@ -3661,7 +3682,7 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3661 hdsp_compute_period_size(hdsp); 3682 hdsp_compute_period_size(hdsp);
3662 3683
3663 /* silence everything */ 3684 /* silence everything */
3664 3685
3665 for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i) 3686 for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i)
3666 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; 3687 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN;
3667 3688
@@ -3669,7 +3690,7 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3669 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) 3690 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN))
3670 return -EIO; 3691 return -EIO;
3671 } 3692 }
3672 3693
3673 /* H9632 specific defaults */ 3694 /* H9632 specific defaults */
3674 if (hdsp->io_type == H9632) { 3695 if (hdsp->io_type == H9632) {
3675 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); 3696 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB);
@@ -3687,12 +3708,12 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3687static void hdsp_midi_tasklet(unsigned long arg) 3708static void hdsp_midi_tasklet(unsigned long arg)
3688{ 3709{
3689 struct hdsp *hdsp = (struct hdsp *)arg; 3710 struct hdsp *hdsp = (struct hdsp *)arg;
3690 3711
3691 if (hdsp->midi[0].pending) 3712 if (hdsp->midi[0].pending)
3692 snd_hdsp_midi_input_read (&hdsp->midi[0]); 3713 snd_hdsp_midi_input_read (&hdsp->midi[0]);
3693 if (hdsp->midi[1].pending) 3714 if (hdsp->midi[1].pending)
3694 snd_hdsp_midi_input_read (&hdsp->midi[1]); 3715 snd_hdsp_midi_input_read (&hdsp->midi[1]);
3695} 3716}
3696 3717
3697static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id) 3718static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3698{ 3719{
@@ -3704,7 +3725,7 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3704 unsigned int midi0status; 3725 unsigned int midi0status;
3705 unsigned int midi1status; 3726 unsigned int midi1status;
3706 int schedule = 0; 3727 int schedule = 0;
3707 3728
3708 status = hdsp_read(hdsp, HDSP_statusRegister); 3729 status = hdsp_read(hdsp, HDSP_statusRegister);
3709 3730
3710 audio = status & HDSP_audioIRQPending; 3731 audio = status & HDSP_audioIRQPending;
@@ -3718,15 +3739,18 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3718 3739
3719 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; 3740 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff;
3720 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; 3741 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff;
3721 3742
3743 if (!(hdsp->state & HDSP_InitializationComplete))
3744 return IRQ_HANDLED;
3745
3722 if (audio) { 3746 if (audio) {
3723 if (hdsp->capture_substream) 3747 if (hdsp->capture_substream)
3724 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); 3748 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
3725 3749
3726 if (hdsp->playback_substream) 3750 if (hdsp->playback_substream)
3727 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); 3751 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
3728 } 3752 }
3729 3753
3730 if (midi0 && midi0status) { 3754 if (midi0 && midi0status) {
3731 if (hdsp->use_midi_tasklet) { 3755 if (hdsp->use_midi_tasklet) {
3732 /* we disable interrupts for this input until processing is done */ 3756 /* we disable interrupts for this input until processing is done */
@@ -3769,10 +3793,10 @@ static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
3769 3793
3770 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) 3794 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels))
3771 return NULL; 3795 return NULL;
3772 3796
3773 if ((mapped_channel = hdsp->channel_map[channel]) < 0) 3797 if ((mapped_channel = hdsp->channel_map[channel]) < 0)
3774 return NULL; 3798 return NULL;
3775 3799
3776 if (stream == SNDRV_PCM_STREAM_CAPTURE) 3800 if (stream == SNDRV_PCM_STREAM_CAPTURE)
3777 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); 3801 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
3778 else 3802 else
@@ -3965,7 +3989,7 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
3965 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3989 struct hdsp *hdsp = snd_pcm_substream_chip(substream);
3966 struct snd_pcm_substream *other; 3990 struct snd_pcm_substream *other;
3967 int running; 3991 int running;
3968 3992
3969 if (hdsp_check_for_iobox (hdsp)) 3993 if (hdsp_check_for_iobox (hdsp))
3970 return -EIO; 3994 return -EIO;
3971 3995
@@ -4059,10 +4083,10 @@ static struct snd_pcm_hardware snd_hdsp_playback_subinfo =
4059 .formats = SNDRV_PCM_FMTBIT_S32_LE, 4083 .formats = SNDRV_PCM_FMTBIT_S32_LE,
4060#endif 4084#endif
4061 .rates = (SNDRV_PCM_RATE_32000 | 4085 .rates = (SNDRV_PCM_RATE_32000 |
4062 SNDRV_PCM_RATE_44100 | 4086 SNDRV_PCM_RATE_44100 |
4063 SNDRV_PCM_RATE_48000 | 4087 SNDRV_PCM_RATE_48000 |
4064 SNDRV_PCM_RATE_64000 | 4088 SNDRV_PCM_RATE_64000 |
4065 SNDRV_PCM_RATE_88200 | 4089 SNDRV_PCM_RATE_88200 |
4066 SNDRV_PCM_RATE_96000), 4090 SNDRV_PCM_RATE_96000),
4067 .rate_min = 32000, 4091 .rate_min = 32000,
4068 .rate_max = 96000, 4092 .rate_max = 96000,
@@ -4088,10 +4112,10 @@ static struct snd_pcm_hardware snd_hdsp_capture_subinfo =
4088 .formats = SNDRV_PCM_FMTBIT_S32_LE, 4112 .formats = SNDRV_PCM_FMTBIT_S32_LE,
4089#endif 4113#endif
4090 .rates = (SNDRV_PCM_RATE_32000 | 4114 .rates = (SNDRV_PCM_RATE_32000 |
4091 SNDRV_PCM_RATE_44100 | 4115 SNDRV_PCM_RATE_44100 |
4092 SNDRV_PCM_RATE_48000 | 4116 SNDRV_PCM_RATE_48000 |
4093 SNDRV_PCM_RATE_64000 | 4117 SNDRV_PCM_RATE_64000 |
4094 SNDRV_PCM_RATE_88200 | 4118 SNDRV_PCM_RATE_88200 |
4095 SNDRV_PCM_RATE_96000), 4119 SNDRV_PCM_RATE_96000),
4096 .rate_min = 32000, 4120 .rate_min = 32000,
4097 .rate_max = 96000, 4121 .rate_max = 96000,
@@ -4170,7 +4194,7 @@ static int snd_hdsp_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
4170 .max = hdsp->qs_in_channels, 4194 .max = hdsp->qs_in_channels,
4171 .integer = 1, 4195 .integer = 1,
4172 }; 4196 };
4173 return snd_interval_refine(c, &t); 4197 return snd_interval_refine(c, &t);
4174 } else if (r->min > 48000 && r->max <= 96000) { 4198 } else if (r->min > 48000 && r->max <= 96000) {
4175 struct snd_interval t = { 4199 struct snd_interval t = {
4176 .min = hdsp->ds_in_channels, 4200 .min = hdsp->ds_in_channels,
@@ -4201,7 +4225,7 @@ static int snd_hdsp_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params,
4201 .max = hdsp->qs_out_channels, 4225 .max = hdsp->qs_out_channels,
4202 .integer = 1, 4226 .integer = 1,
4203 }; 4227 };
4204 return snd_interval_refine(c, &t); 4228 return snd_interval_refine(c, &t);
4205 } else if (r->min > 48000 && r->max <= 96000) { 4229 } else if (r->min > 48000 && r->max <= 96000) {
4206 struct snd_interval t = { 4230 struct snd_interval t = {
4207 .min = hdsp->ds_out_channels, 4231 .min = hdsp->ds_out_channels,
@@ -4318,8 +4342,8 @@ static int snd_hdsp_playback_open(struct snd_pcm_substream *substream)
4318 if (hdsp->io_type == H9632) { 4342 if (hdsp->io_type == H9632) {
4319 runtime->hw.channels_min = hdsp->qs_out_channels; 4343 runtime->hw.channels_min = hdsp->qs_out_channels;
4320 runtime->hw.channels_max = hdsp->ss_out_channels; 4344 runtime->hw.channels_max = hdsp->ss_out_channels;
4321 } 4345 }
4322 4346
4323 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4347 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4324 snd_hdsp_hw_rule_out_channels, hdsp, 4348 snd_hdsp_hw_rule_out_channels, hdsp,
4325 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4349 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
@@ -4413,13 +4437,6 @@ static int snd_hdsp_capture_release(struct snd_pcm_substream *substream)
4413 return 0; 4437 return 0;
4414} 4438}
4415 4439
4416static int snd_hdsp_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file)
4417{
4418 /* we have nothing to initialize but the call is required */
4419 return 0;
4420}
4421
4422
4423/* helper functions for copying meter values */ 4440/* helper functions for copying meter values */
4424static inline int copy_u32_le(void __user *dest, void __iomem *src) 4441static inline int copy_u32_le(void __user *dest, void __iomem *src)
4425{ 4442{
@@ -4536,7 +4553,7 @@ static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rm
4536 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, 4553 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4,
4537 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) 4554 hdsp->iobase + HDSP_playbackRmsLevel + i * 8))
4538 return -EFAULT; 4555 return -EFAULT;
4539 if (copy_u64_le(&peak_rms->input_rms[i], 4556 if (copy_u64_le(&peak_rms->input_rms[i],
4540 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, 4557 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4,
4541 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) 4558 hdsp->iobase + HDSP_inputRmsLevel + i * 8))
4542 return -EFAULT; 4559 return -EFAULT;
@@ -4546,7 +4563,7 @@ static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rm
4546 4563
4547static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) 4564static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
4548{ 4565{
4549 struct hdsp *hdsp = (struct hdsp *)hw->private_data; 4566 struct hdsp *hdsp = (struct hdsp *)hw->private_data;
4550 void __user *argp = (void __user *)arg; 4567 void __user *argp = (void __user *)arg;
4551 int err; 4568 int err;
4552 4569
@@ -4580,7 +4597,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4580 struct hdsp_config_info info; 4597 struct hdsp_config_info info;
4581 unsigned long flags; 4598 unsigned long flags;
4582 int i; 4599 int i;
4583 4600
4584 err = hdsp_check_for_iobox(hdsp); 4601 err = hdsp_check_for_iobox(hdsp);
4585 if (err < 0) 4602 if (err < 0)
4586 return err; 4603 return err;
@@ -4614,7 +4631,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4614 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); 4631 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp);
4615 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); 4632 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp);
4616 info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp); 4633 info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
4617 4634
4618 } 4635 }
4619 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) 4636 if (hdsp->io_type == H9632 || hdsp->io_type == H9652)
4620 info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp); 4637 info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
@@ -4625,7 +4642,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4625 } 4642 }
4626 case SNDRV_HDSP_IOCTL_GET_9632_AEB: { 4643 case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
4627 struct hdsp_9632_aeb h9632_aeb; 4644 struct hdsp_9632_aeb h9632_aeb;
4628 4645
4629 if (hdsp->io_type != H9632) return -EINVAL; 4646 if (hdsp->io_type != H9632) return -EINVAL;
4630 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; 4647 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
4631 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; 4648 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS;
@@ -4636,7 +4653,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4636 case SNDRV_HDSP_IOCTL_GET_VERSION: { 4653 case SNDRV_HDSP_IOCTL_GET_VERSION: {
4637 struct hdsp_version hdsp_version; 4654 struct hdsp_version hdsp_version;
4638 int err; 4655 int err;
4639 4656
4640 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; 4657 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
4641 if (hdsp->io_type == Undefined) { 4658 if (hdsp->io_type == Undefined) {
4642 if ((err = hdsp_get_iobox_version(hdsp)) < 0) 4659 if ((err = hdsp_get_iobox_version(hdsp)) < 0)
@@ -4652,7 +4669,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4652 struct hdsp_firmware __user *firmware; 4669 struct hdsp_firmware __user *firmware;
4653 u32 __user *firmware_data; 4670 u32 __user *firmware_data;
4654 int err; 4671 int err;
4655 4672
4656 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; 4673 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
4657 /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */ 4674 /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */
4658 if (hdsp->io_type == Undefined) return -EINVAL; 4675 if (hdsp->io_type == Undefined) return -EINVAL;
@@ -4665,25 +4682,25 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4665 4682
4666 if (get_user(firmware_data, &firmware->firmware_data)) 4683 if (get_user(firmware_data, &firmware->firmware_data))
4667 return -EFAULT; 4684 return -EFAULT;
4668 4685
4669 if (hdsp_check_for_iobox (hdsp)) 4686 if (hdsp_check_for_iobox (hdsp))
4670 return -EIO; 4687 return -EIO;
4671 4688
4672 if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0) 4689 if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0)
4673 return -EFAULT; 4690 return -EFAULT;
4674 4691
4675 hdsp->state |= HDSP_FirmwareCached; 4692 hdsp->state |= HDSP_FirmwareCached;
4676 4693
4677 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) 4694 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
4678 return err; 4695 return err;
4679 4696
4680 if (!(hdsp->state & HDSP_InitializationComplete)) { 4697 if (!(hdsp->state & HDSP_InitializationComplete)) {
4681 if ((err = snd_hdsp_enable_io(hdsp)) < 0) 4698 if ((err = snd_hdsp_enable_io(hdsp)) < 0)
4682 return err; 4699 return err;
4683 4700
4684 snd_hdsp_initialize_channels(hdsp); 4701 snd_hdsp_initialize_channels(hdsp);
4685 snd_hdsp_initialize_midi_flush(hdsp); 4702 snd_hdsp_initialize_midi_flush(hdsp);
4686 4703
4687 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { 4704 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
4688 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n"); 4705 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
4689 return err; 4706 return err;
@@ -4730,18 +4747,16 @@ static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp)
4730{ 4747{
4731 struct snd_hwdep *hw; 4748 struct snd_hwdep *hw;
4732 int err; 4749 int err;
4733 4750
4734 if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0) 4751 if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0)
4735 return err; 4752 return err;
4736 4753
4737 hdsp->hwdep = hw; 4754 hdsp->hwdep = hw;
4738 hw->private_data = hdsp; 4755 hw->private_data = hdsp;
4739 strcpy(hw->name, "HDSP hwdep interface"); 4756 strcpy(hw->name, "HDSP hwdep interface");
4740 4757
4741 hw->ops.open = snd_hdsp_hwdep_dummy_op;
4742 hw->ops.ioctl = snd_hdsp_hwdep_ioctl; 4758 hw->ops.ioctl = snd_hdsp_hwdep_ioctl;
4743 hw->ops.release = snd_hdsp_hwdep_dummy_op; 4759
4744
4745 return 0; 4760 return 0;
4746} 4761}
4747 4762
@@ -4774,24 +4789,24 @@ static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp)
4774static int snd_hdsp_enable_io (struct hdsp *hdsp) 4789static int snd_hdsp_enable_io (struct hdsp *hdsp)
4775{ 4790{
4776 int i; 4791 int i;
4777 4792
4778 if (hdsp_fifo_wait (hdsp, 0, 100)) { 4793 if (hdsp_fifo_wait (hdsp, 0, 100)) {
4779 snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n"); 4794 snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
4780 return -EIO; 4795 return -EIO;
4781 } 4796 }
4782 4797
4783 for (i = 0; i < hdsp->max_channels; ++i) { 4798 for (i = 0; i < hdsp->max_channels; ++i) {
4784 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); 4799 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1);
4785 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); 4800 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1);
4786 } 4801 }
4787 4802
4788 return 0; 4803 return 0;
4789} 4804}
4790 4805
4791static void snd_hdsp_initialize_channels(struct hdsp *hdsp) 4806static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4792{ 4807{
4793 int status, aebi_channels, aebo_channels; 4808 int status, aebi_channels, aebo_channels;
4794 4809
4795 switch (hdsp->io_type) { 4810 switch (hdsp->io_type) {
4796 case Digiface: 4811 case Digiface:
4797 hdsp->card_name = "RME Hammerfall DSP + Digiface"; 4812 hdsp->card_name = "RME Hammerfall DSP + Digiface";
@@ -4804,7 +4819,7 @@ static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4804 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; 4819 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS;
4805 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; 4820 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS;
4806 break; 4821 break;
4807 4822
4808 case H9632: 4823 case H9632:
4809 status = hdsp_read(hdsp, HDSP_statusRegister); 4824 status = hdsp_read(hdsp, HDSP_statusRegister);
4810 /* HDSP_AEBx bits are low when AEB are connected */ 4825 /* HDSP_AEBx bits are low when AEB are connected */
@@ -4824,7 +4839,7 @@ static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4824 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; 4839 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS;
4825 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; 4840 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS;
4826 break; 4841 break;
4827 4842
4828 default: 4843 default:
4829 /* should never get here */ 4844 /* should never get here */
4830 break; 4845 break;
@@ -4840,12 +4855,12 @@ static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp)
4840static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) 4855static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp)
4841{ 4856{
4842 int err; 4857 int err;
4843 4858
4844 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { 4859 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
4845 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n"); 4860 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
4846 return err; 4861 return err;
4847 } 4862 }
4848 4863
4849 4864
4850 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { 4865 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
4851 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n"); 4866 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n");
@@ -4876,19 +4891,19 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
4876 snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n"); 4891 snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n");
4877 return err; 4892 return err;
4878 } 4893 }
4879 4894
4880 if (!(hdsp->state & HDSP_InitializationComplete)) { 4895 if (!(hdsp->state & HDSP_InitializationComplete)) {
4881 strcpy(card->shortname, "Hammerfall DSP"); 4896 strcpy(card->shortname, "Hammerfall DSP");
4882 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 4897 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
4883 hdsp->port, hdsp->irq); 4898 hdsp->port, hdsp->irq);
4884 4899
4885 if ((err = snd_card_register(card)) < 0) { 4900 if ((err = snd_card_register(card)) < 0) {
4886 snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n"); 4901 snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
4887 return err; 4902 return err;
4888 } 4903 }
4889 hdsp->state |= HDSP_InitializationComplete; 4904 hdsp->state |= HDSP_InitializationComplete;
4890 } 4905 }
4891 4906
4892 return 0; 4907 return 0;
4893} 4908}
4894 4909
@@ -4899,7 +4914,7 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4899 const char *fwfile; 4914 const char *fwfile;
4900 const struct firmware *fw; 4915 const struct firmware *fw;
4901 int err; 4916 int err;
4902 4917
4903 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) 4918 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
4904 return 0; 4919 return 0;
4905 if (hdsp->io_type == Undefined) { 4920 if (hdsp->io_type == Undefined) {
@@ -4908,7 +4923,7 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4908 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) 4923 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
4909 return 0; 4924 return 0;
4910 } 4925 }
4911 4926
4912 /* caution: max length of firmware filename is 30! */ 4927 /* caution: max length of firmware filename is 30! */
4913 switch (hdsp->io_type) { 4928 switch (hdsp->io_type) {
4914 case Multiface: 4929 case Multiface:
@@ -4942,12 +4957,12 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4942 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache)); 4957 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache));
4943 4958
4944 release_firmware(fw); 4959 release_firmware(fw);
4945 4960
4946 hdsp->state |= HDSP_FirmwareCached; 4961 hdsp->state |= HDSP_FirmwareCached;
4947 4962
4948 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) 4963 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
4949 return err; 4964 return err;
4950 4965
4951 if (!(hdsp->state & HDSP_InitializationComplete)) { 4966 if (!(hdsp->state & HDSP_InitializationComplete)) {
4952 if ((err = snd_hdsp_enable_io(hdsp)) < 0) 4967 if ((err = snd_hdsp_enable_io(hdsp)) < 0)
4953 return err; 4968 return err;
@@ -4994,14 +5009,14 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
4994 hdsp->max_channels = 26; 5009 hdsp->max_channels = 26;
4995 5010
4996 hdsp->card = card; 5011 hdsp->card = card;
4997 5012
4998 spin_lock_init(&hdsp->lock); 5013 spin_lock_init(&hdsp->lock);
4999 5014
5000 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp); 5015 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp);
5001 5016
5002 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); 5017 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev);
5003 hdsp->firmware_rev &= 0xff; 5018 hdsp->firmware_rev &= 0xff;
5004 5019
5005 /* From Martin Bjoernsen : 5020 /* From Martin Bjoernsen :
5006 "It is important that the card's latency timer register in 5021 "It is important that the card's latency timer register in
5007 the PCI configuration space is set to a value much larger 5022 the PCI configuration space is set to a value much larger
@@ -5010,7 +5025,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5010 to its maximum 255 to avoid problems with some computers." 5025 to its maximum 255 to avoid problems with some computers."
5011 */ 5026 */
5012 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); 5027 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF);
5013 5028
5014 strcpy(card->driver, "H-DSP"); 5029 strcpy(card->driver, "H-DSP");
5015 strcpy(card->mixername, "Xilinx FPGA"); 5030 strcpy(card->mixername, "Xilinx FPGA");
5016 5031
@@ -5024,7 +5039,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5024 } else { 5039 } else {
5025 hdsp->card_name = "RME HDSP 9632"; 5040 hdsp->card_name = "RME HDSP 9632";
5026 hdsp->max_channels = 16; 5041 hdsp->max_channels = 16;
5027 is_9632 = 1; 5042 is_9632 = 1;
5028 } 5043 }
5029 5044
5030 if ((err = pci_enable_device(pci)) < 0) 5045 if ((err = pci_enable_device(pci)) < 0)
@@ -5053,12 +5068,12 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5053 5068
5054 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) 5069 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
5055 return err; 5070 return err;
5056 5071
5057 if (!is_9652 && !is_9632) { 5072 if (!is_9652 && !is_9632) {
5058 /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ 5073 /* we wait a maximum of 10 seconds to let freshly
5059 ssleep(2); 5074 * inserted cardbus cards do their hardware init */
5075 err = hdsp_wait_for_iobox(hdsp, 1000, 10);
5060 5076
5061 err = hdsp_check_for_iobox(hdsp);
5062 if (err < 0) 5077 if (err < 0)
5063 return err; 5078 return err;
5064 5079
@@ -5080,35 +5095,35 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5080 return err; 5095 return err;
5081 return 0; 5096 return 0;
5082 } else { 5097 } else {
5083 snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n"); 5098 snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");
5084 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) 5099 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
5085 hdsp->io_type = Multiface; 5100 hdsp->io_type = Multiface;
5086 else 5101 else
5087 hdsp->io_type = Digiface; 5102 hdsp->io_type = Digiface;
5088 } 5103 }
5089 } 5104 }
5090 5105
5091 if ((err = snd_hdsp_enable_io(hdsp)) != 0) 5106 if ((err = snd_hdsp_enable_io(hdsp)) != 0)
5092 return err; 5107 return err;
5093 5108
5094 if (is_9652) 5109 if (is_9652)
5095 hdsp->io_type = H9652; 5110 hdsp->io_type = H9652;
5096 5111
5097 if (is_9632) 5112 if (is_9632)
5098 hdsp->io_type = H9632; 5113 hdsp->io_type = H9632;
5099 5114
5100 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) 5115 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
5101 return err; 5116 return err;
5102 5117
5103 snd_hdsp_initialize_channels(hdsp); 5118 snd_hdsp_initialize_channels(hdsp);
5104 snd_hdsp_initialize_midi_flush(hdsp); 5119 snd_hdsp_initialize_midi_flush(hdsp);
5105 5120
5106 hdsp->state |= HDSP_FirmwareLoaded; 5121 hdsp->state |= HDSP_FirmwareLoaded;
5107 5122
5108 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) 5123 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0)
5109 return err; 5124 return err;
5110 5125
5111 return 0; 5126 return 0;
5112} 5127}
5113 5128
5114static int snd_hdsp_free(struct hdsp *hdsp) 5129static int snd_hdsp_free(struct hdsp *hdsp)
@@ -5124,13 +5139,13 @@ static int snd_hdsp_free(struct hdsp *hdsp)
5124 free_irq(hdsp->irq, (void *)hdsp); 5139 free_irq(hdsp->irq, (void *)hdsp);
5125 5140
5126 snd_hdsp_free_buffers(hdsp); 5141 snd_hdsp_free_buffers(hdsp);
5127 5142
5128 if (hdsp->iobase) 5143 if (hdsp->iobase)
5129 iounmap(hdsp->iobase); 5144 iounmap(hdsp->iobase);
5130 5145
5131 if (hdsp->port) 5146 if (hdsp->port)
5132 pci_release_regions(hdsp->pci); 5147 pci_release_regions(hdsp->pci);
5133 5148
5134 pci_disable_device(hdsp->pci); 5149 pci_disable_device(hdsp->pci);
5135 return 0; 5150 return 0;
5136} 5151}
@@ -5175,7 +5190,7 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci,
5175 } 5190 }
5176 5191
5177 strcpy(card->shortname, "Hammerfall DSP"); 5192 strcpy(card->shortname, "Hammerfall DSP");
5178 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 5193 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
5179 hdsp->port, hdsp->irq); 5194 hdsp->port, hdsp->irq);
5180 5195
5181 if ((err = snd_card_register(card)) < 0) { 5196 if ((err = snd_card_register(card)) < 0) {
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index d4b4e0d0fee8..bac2dc0c5d85 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -4100,13 +4100,6 @@ static int snd_hdspm_capture_release(struct snd_pcm_substream *substream)
4100 return 0; 4100 return 0;
4101} 4101}
4102 4102
4103static int snd_hdspm_hwdep_dummy_op(struct snd_hwdep * hw, struct file *file)
4104{
4105 /* we have nothing to initialize but the call is required */
4106 return 0;
4107}
4108
4109
4110static int snd_hdspm_hwdep_ioctl(struct snd_hwdep * hw, struct file *file, 4103static int snd_hdspm_hwdep_ioctl(struct snd_hwdep * hw, struct file *file,
4111 unsigned int cmd, unsigned long arg) 4104 unsigned int cmd, unsigned long arg)
4112{ 4105{
@@ -4213,9 +4206,7 @@ static int __devinit snd_hdspm_create_hwdep(struct snd_card *card,
4213 hw->private_data = hdspm; 4206 hw->private_data = hdspm;
4214 strcpy(hw->name, "HDSPM hwdep interface"); 4207 strcpy(hw->name, "HDSPM hwdep interface");
4215 4208
4216 hw->ops.open = snd_hdspm_hwdep_dummy_op;
4217 hw->ops.ioctl = snd_hdspm_hwdep_ioctl; 4209 hw->ops.ioctl = snd_hdspm_hwdep_ioctl;
4218 hw->ops.release = snd_hdspm_hwdep_dummy_op;
4219 4210
4220 return 0; 4211 return 0;
4221} 4212}
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index baf6d8e3dabc..1a5ff0611072 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1300,7 +1300,7 @@ static int __devinit sis_chip_create(struct snd_card *card,
1300 if (rc) 1300 if (rc)
1301 goto error_out; 1301 goto error_out;
1302 1302
1303 if (pci_set_dma_mask(pci, DMA_30BIT_MASK) < 0) { 1303 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
1304 printk(KERN_ERR "sis7019: architecture does not support " 1304 printk(KERN_ERR "sis7019: architecture does not support "
1305 "30-bit PCI busmaster DMA"); 1305 "30-bit PCI busmaster DMA");
1306 goto error_out_enabled; 1306 goto error_out_enabled;
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index c5601b0ad7cc..7dc60ad4772e 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -273,7 +273,8 @@ static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic,
273 outl(count, sonic->dmaa_port + SV_DMA_COUNT0); 273 outl(count, sonic->dmaa_port + SV_DMA_COUNT0);
274 outb(0x18, sonic->dmaa_port + SV_DMA_MODE); 274 outb(0x18, sonic->dmaa_port + SV_DMA_MODE);
275#if 0 275#if 0
276 printk("program dmaa: addr = 0x%x, paddr = 0x%x\n", addr, inl(sonic->dmaa_port + SV_DMA_ADDR0)); 276 printk(KERN_DEBUG "program dmaa: addr = 0x%x, paddr = 0x%x\n",
277 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
277#endif 278#endif
278} 279}
279 280
@@ -288,7 +289,8 @@ static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic,
288 outl(count, sonic->dmac_port + SV_DMA_COUNT0); 289 outl(count, sonic->dmac_port + SV_DMA_COUNT0);
289 outb(0x14, sonic->dmac_port + SV_DMA_MODE); 290 outb(0x14, sonic->dmac_port + SV_DMA_MODE);
290#if 0 291#if 0
291 printk("program dmac: addr = 0x%x, paddr = 0x%x\n", addr, inl(sonic->dmac_port + SV_DMA_ADDR0)); 292 printk(KERN_DEBUG "program dmac: addr = 0x%x, paddr = 0x%x\n",
293 addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
292#endif 294#endif
293} 295}
294 296
@@ -355,71 +357,104 @@ static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char
355#if 0 357#if 0
356static void snd_sonicvibes_debug(struct sonicvibes * sonic) 358static void snd_sonicvibes_debug(struct sonicvibes * sonic)
357{ 359{
358 printk("SV REGS: INDEX = 0x%02x ", inb(SV_REG(sonic, INDEX))); 360 printk(KERN_DEBUG
361 "SV REGS: INDEX = 0x%02x ", inb(SV_REG(sonic, INDEX)));
359 printk(" STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS))); 362 printk(" STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS)));
360 printk(" 0x00: left input = 0x%02x ", snd_sonicvibes_in(sonic, 0x00)); 363 printk(KERN_DEBUG
364 " 0x00: left input = 0x%02x ", snd_sonicvibes_in(sonic, 0x00));
361 printk(" 0x20: synth rate low = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20)); 365 printk(" 0x20: synth rate low = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20));
362 printk(" 0x01: right input = 0x%02x ", snd_sonicvibes_in(sonic, 0x01)); 366 printk(KERN_DEBUG
367 " 0x01: right input = 0x%02x ", snd_sonicvibes_in(sonic, 0x01));
363 printk(" 0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21)); 368 printk(" 0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21));
364 printk(" 0x02: left AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x02)); 369 printk(KERN_DEBUG
370 " 0x02: left AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x02));
365 printk(" 0x22: ADC clock = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22)); 371 printk(" 0x22: ADC clock = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22));
366 printk(" 0x03: right AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x03)); 372 printk(KERN_DEBUG
373 " 0x03: right AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x03));
367 printk(" 0x23: ADC alt rate = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23)); 374 printk(" 0x23: ADC alt rate = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23));
368 printk(" 0x04: left CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x04)); 375 printk(KERN_DEBUG
376 " 0x04: left CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x04));
369 printk(" 0x24: ADC pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24)); 377 printk(" 0x24: ADC pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24));
370 printk(" 0x05: right CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x05)); 378 printk(KERN_DEBUG
379 " 0x05: right CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x05));
371 printk(" 0x25: ADC pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25)); 380 printk(" 0x25: ADC pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25));
372 printk(" 0x06: left line = 0x%02x ", snd_sonicvibes_in(sonic, 0x06)); 381 printk(KERN_DEBUG
382 " 0x06: left line = 0x%02x ", snd_sonicvibes_in(sonic, 0x06));
373 printk(" 0x26: Synth pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26)); 383 printk(" 0x26: Synth pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26));
374 printk(" 0x07: right line = 0x%02x ", snd_sonicvibes_in(sonic, 0x07)); 384 printk(KERN_DEBUG
385 " 0x07: right line = 0x%02x ", snd_sonicvibes_in(sonic, 0x07));
375 printk(" 0x27: Synth pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27)); 386 printk(" 0x27: Synth pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27));
376 printk(" 0x08: MIC = 0x%02x ", snd_sonicvibes_in(sonic, 0x08)); 387 printk(KERN_DEBUG
388 " 0x08: MIC = 0x%02x ", snd_sonicvibes_in(sonic, 0x08));
377 printk(" 0x28: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28)); 389 printk(" 0x28: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28));
378 printk(" 0x09: Game port = 0x%02x ", snd_sonicvibes_in(sonic, 0x09)); 390 printk(KERN_DEBUG
391 " 0x09: Game port = 0x%02x ", snd_sonicvibes_in(sonic, 0x09));
379 printk(" 0x29: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29)); 392 printk(" 0x29: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29));
380 printk(" 0x0a: left synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0a)); 393 printk(KERN_DEBUG
394 " 0x0a: left synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0a));
381 printk(" 0x2a: MPU401 = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a)); 395 printk(" 0x2a: MPU401 = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a));
382 printk(" 0x0b: right synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0b)); 396 printk(KERN_DEBUG
397 " 0x0b: right synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0b));
383 printk(" 0x2b: drive ctrl = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b)); 398 printk(" 0x2b: drive ctrl = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b));
384 printk(" 0x0c: left AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0c)); 399 printk(KERN_DEBUG
400 " 0x0c: left AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0c));
385 printk(" 0x2c: SRS space = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c)); 401 printk(" 0x2c: SRS space = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c));
386 printk(" 0x0d: right AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0d)); 402 printk(KERN_DEBUG
403 " 0x0d: right AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0d));
387 printk(" 0x2d: SRS center = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d)); 404 printk(" 0x2d: SRS center = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d));
388 printk(" 0x0e: left analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0e)); 405 printk(KERN_DEBUG
406 " 0x0e: left analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0e));
389 printk(" 0x2e: wave source = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e)); 407 printk(" 0x2e: wave source = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e));
390 printk(" 0x0f: right analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0f)); 408 printk(KERN_DEBUG
409 " 0x0f: right analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0f));
391 printk(" 0x2f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f)); 410 printk(" 0x2f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f));
392 printk(" 0x10: left PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x10)); 411 printk(KERN_DEBUG
412 " 0x10: left PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x10));
393 printk(" 0x30: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30)); 413 printk(" 0x30: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30));
394 printk(" 0x11: right PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x11)); 414 printk(KERN_DEBUG
415 " 0x11: right PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x11));
395 printk(" 0x31: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31)); 416 printk(" 0x31: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31));
396 printk(" 0x12: DMA data format = 0x%02x ", snd_sonicvibes_in(sonic, 0x12)); 417 printk(KERN_DEBUG
418 " 0x12: DMA data format = 0x%02x ", snd_sonicvibes_in(sonic, 0x12));
397 printk(" 0x32: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32)); 419 printk(" 0x32: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32));
398 printk(" 0x13: P/C enable = 0x%02x ", snd_sonicvibes_in(sonic, 0x13)); 420 printk(KERN_DEBUG
421 " 0x13: P/C enable = 0x%02x ", snd_sonicvibes_in(sonic, 0x13));
399 printk(" 0x33: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33)); 422 printk(" 0x33: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33));
400 printk(" 0x14: U/D button = 0x%02x ", snd_sonicvibes_in(sonic, 0x14)); 423 printk(KERN_DEBUG
424 " 0x14: U/D button = 0x%02x ", snd_sonicvibes_in(sonic, 0x14));
401 printk(" 0x34: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34)); 425 printk(" 0x34: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34));
402 printk(" 0x15: revision = 0x%02x ", snd_sonicvibes_in(sonic, 0x15)); 426 printk(KERN_DEBUG
427 " 0x15: revision = 0x%02x ", snd_sonicvibes_in(sonic, 0x15));
403 printk(" 0x35: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35)); 428 printk(" 0x35: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35));
404 printk(" 0x16: ADC output ctrl = 0x%02x ", snd_sonicvibes_in(sonic, 0x16)); 429 printk(KERN_DEBUG
430 " 0x16: ADC output ctrl = 0x%02x ", snd_sonicvibes_in(sonic, 0x16));
405 printk(" 0x36: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36)); 431 printk(" 0x36: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36));
406 printk(" 0x17: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x17)); 432 printk(KERN_DEBUG
433 " 0x17: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x17));
407 printk(" 0x37: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37)); 434 printk(" 0x37: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37));
408 printk(" 0x18: DMA A upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x18)); 435 printk(KERN_DEBUG
436 " 0x18: DMA A upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x18));
409 printk(" 0x38: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38)); 437 printk(" 0x38: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38));
410 printk(" 0x19: DMA A lower cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x19)); 438 printk(KERN_DEBUG
439 " 0x19: DMA A lower cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x19));
411 printk(" 0x39: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39)); 440 printk(" 0x39: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39));
412 printk(" 0x1a: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1a)); 441 printk(KERN_DEBUG
442 " 0x1a: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1a));
413 printk(" 0x3a: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a)); 443 printk(" 0x3a: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a));
414 printk(" 0x1b: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1b)); 444 printk(KERN_DEBUG
445 " 0x1b: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1b));
415 printk(" 0x3b: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b)); 446 printk(" 0x3b: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b));
416 printk(" 0x1c: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1c)); 447 printk(KERN_DEBUG
448 " 0x1c: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1c));
417 printk(" 0x3c: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c)); 449 printk(" 0x3c: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c));
418 printk(" 0x1d: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1d)); 450 printk(KERN_DEBUG
451 " 0x1d: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1d));
419 printk(" 0x3d: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d)); 452 printk(" 0x3d: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d));
420 printk(" 0x1e: PCM rate low = 0x%02x ", snd_sonicvibes_in(sonic, 0x1e)); 453 printk(KERN_DEBUG
454 " 0x1e: PCM rate low = 0x%02x ", snd_sonicvibes_in(sonic, 0x1e));
421 printk(" 0x3e: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e)); 455 printk(" 0x3e: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e));
422 printk(" 0x1f: PCM rate high = 0x%02x ", snd_sonicvibes_in(sonic, 0x1f)); 456 printk(KERN_DEBUG
457 " 0x1f: PCM rate high = 0x%02x ", snd_sonicvibes_in(sonic, 0x1f));
423 printk(" 0x3f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f)); 458 printk(" 0x3f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f));
424} 459}
425 460
@@ -476,8 +511,8 @@ static void snd_sonicvibes_pll(unsigned int rate,
476 *res_m = m; 511 *res_m = m;
477 *res_n = n; 512 *res_n = n;
478#if 0 513#if 0
479 printk("metric = %i, xm = %i, xn = %i\n", metric, xm, xn); 514 printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
480 printk("pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n); 515 printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
481#endif 516#endif
482} 517}
483 518
@@ -1229,8 +1264,8 @@ static int __devinit snd_sonicvibes_create(struct snd_card *card,
1229 if ((err = pci_enable_device(pci)) < 0) 1264 if ((err = pci_enable_device(pci)) < 0)
1230 return err; 1265 return err;
1231 /* check, if we can restrict PCI DMA transfers to 24 bits */ 1266 /* check, if we can restrict PCI DMA transfers to 24 bits */
1232 if (pci_set_dma_mask(pci, DMA_24BIT_MASK) < 0 || 1267 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
1233 pci_set_consistent_dma_mask(pci, DMA_24BIT_MASK) < 0) { 1268 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
1234 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 1269 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
1235 pci_disable_device(pci); 1270 pci_disable_device(pci);
1236 return -ENXIO; 1271 return -ENXIO;
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index c612b435ca2b..6d943f6f6b70 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -68,40 +68,40 @@ static void snd_trident_print_voice_regs(struct snd_trident *trident, int voice)
68{ 68{
69 unsigned int val, tmp; 69 unsigned int val, tmp;
70 70
71 printk("Trident voice %i:\n", voice); 71 printk(KERN_DEBUG "Trident voice %i:\n", voice);
72 outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR)); 72 outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR));
73 val = inl(TRID_REG(trident, CH_LBA)); 73 val = inl(TRID_REG(trident, CH_LBA));
74 printk("LBA: 0x%x\n", val); 74 printk(KERN_DEBUG "LBA: 0x%x\n", val);
75 val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); 75 val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
76 printk("GVSel: %i\n", val >> 31); 76 printk(KERN_DEBUG "GVSel: %i\n", val >> 31);
77 printk("Pan: 0x%x\n", (val >> 24) & 0x7f); 77 printk(KERN_DEBUG "Pan: 0x%x\n", (val >> 24) & 0x7f);
78 printk("Vol: 0x%x\n", (val >> 16) & 0xff); 78 printk(KERN_DEBUG "Vol: 0x%x\n", (val >> 16) & 0xff);
79 printk("CTRL: 0x%x\n", (val >> 12) & 0x0f); 79 printk(KERN_DEBUG "CTRL: 0x%x\n", (val >> 12) & 0x0f);
80 printk("EC: 0x%x\n", val & 0x0fff); 80 printk(KERN_DEBUG "EC: 0x%x\n", val & 0x0fff);
81 if (trident->device != TRIDENT_DEVICE_ID_NX) { 81 if (trident->device != TRIDENT_DEVICE_ID_NX) {
82 val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS)); 82 val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS));
83 printk("CSO: 0x%x\n", val >> 16); 83 printk(KERN_DEBUG "CSO: 0x%x\n", val >> 16);
84 printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff); 84 printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff);
85 printk("FMS: 0x%x\n", val & 0x0f); 85 printk(KERN_DEBUG "FMS: 0x%x\n", val & 0x0f);
86 val = inl(TRID_REG(trident, CH_DX_ESO_DELTA)); 86 val = inl(TRID_REG(trident, CH_DX_ESO_DELTA));
87 printk("ESO: 0x%x\n", val >> 16); 87 printk(KERN_DEBUG "ESO: 0x%x\n", val >> 16);
88 printk("Delta: 0x%x\n", val & 0xffff); 88 printk(KERN_DEBUG "Delta: 0x%x\n", val & 0xffff);
89 val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL)); 89 val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL));
90 } else { // TRIDENT_DEVICE_ID_NX 90 } else { // TRIDENT_DEVICE_ID_NX
91 val = inl(TRID_REG(trident, CH_NX_DELTA_CSO)); 91 val = inl(TRID_REG(trident, CH_NX_DELTA_CSO));
92 tmp = (val >> 24) & 0xff; 92 tmp = (val >> 24) & 0xff;
93 printk("CSO: 0x%x\n", val & 0x00ffffff); 93 printk(KERN_DEBUG "CSO: 0x%x\n", val & 0x00ffffff);
94 val = inl(TRID_REG(trident, CH_NX_DELTA_ESO)); 94 val = inl(TRID_REG(trident, CH_NX_DELTA_ESO));
95 tmp |= (val >> 16) & 0xff00; 95 tmp |= (val >> 16) & 0xff00;
96 printk("Delta: 0x%x\n", tmp); 96 printk(KERN_DEBUG "Delta: 0x%x\n", tmp);
97 printk("ESO: 0x%x\n", val & 0x00ffffff); 97 printk(KERN_DEBUG "ESO: 0x%x\n", val & 0x00ffffff);
98 val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL)); 98 val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL));
99 printk("Alpha: 0x%x\n", val >> 20); 99 printk(KERN_DEBUG "Alpha: 0x%x\n", val >> 20);
100 printk("FMS: 0x%x\n", (val >> 16) & 0x0f); 100 printk(KERN_DEBUG "FMS: 0x%x\n", (val >> 16) & 0x0f);
101 } 101 }
102 printk("FMC: 0x%x\n", (val >> 14) & 3); 102 printk(KERN_DEBUG "FMC: 0x%x\n", (val >> 14) & 3);
103 printk("RVol: 0x%x\n", (val >> 7) & 0x7f); 103 printk(KERN_DEBUG "RVol: 0x%x\n", (val >> 7) & 0x7f);
104 printk("CVol: 0x%x\n", val & 0x7f); 104 printk(KERN_DEBUG "CVol: 0x%x\n", val & 0x7f);
105} 105}
106#endif 106#endif
107 107
@@ -496,12 +496,17 @@ void snd_trident_write_voice_regs(struct snd_trident * trident,
496 outl(regs[4], TRID_REG(trident, CH_START + 16)); 496 outl(regs[4], TRID_REG(trident, CH_START + 16));
497 497
498#if 0 498#if 0
499 printk("written %i channel:\n", voice->number); 499 printk(KERN_DEBUG "written %i channel:\n", voice->number);
500 printk(" regs[0] = 0x%x/0x%x\n", regs[0], inl(TRID_REG(trident, CH_START + 0))); 500 printk(KERN_DEBUG " regs[0] = 0x%x/0x%x\n",
501 printk(" regs[1] = 0x%x/0x%x\n", regs[1], inl(TRID_REG(trident, CH_START + 4))); 501 regs[0], inl(TRID_REG(trident, CH_START + 0)));
502 printk(" regs[2] = 0x%x/0x%x\n", regs[2], inl(TRID_REG(trident, CH_START + 8))); 502 printk(KERN_DEBUG " regs[1] = 0x%x/0x%x\n",
503 printk(" regs[3] = 0x%x/0x%x\n", regs[3], inl(TRID_REG(trident, CH_START + 12))); 503 regs[1], inl(TRID_REG(trident, CH_START + 4)));
504 printk(" regs[4] = 0x%x/0x%x\n", regs[4], inl(TRID_REG(trident, CH_START + 16))); 504 printk(KERN_DEBUG " regs[2] = 0x%x/0x%x\n",
505 regs[2], inl(TRID_REG(trident, CH_START + 8)));
506 printk(KERN_DEBUG " regs[3] = 0x%x/0x%x\n",
507 regs[3], inl(TRID_REG(trident, CH_START + 12)));
508 printk(KERN_DEBUG " regs[4] = 0x%x/0x%x\n",
509 regs[4], inl(TRID_REG(trident, CH_START + 16)));
505#endif 510#endif
506} 511}
507 512
@@ -583,7 +588,7 @@ static void snd_trident_write_vol_reg(struct snd_trident * trident,
583 outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2)); 588 outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2));
584 break; 589 break;
585 case TRIDENT_DEVICE_ID_SI7018: 590 case TRIDENT_DEVICE_ID_SI7018:
586 // printk("voice->Vol = 0x%x\n", voice->Vol); 591 /* printk(KERN_DEBUG "voice->Vol = 0x%x\n", voice->Vol); */
587 outw((voice->CTRL << 12) | voice->Vol, 592 outw((voice->CTRL << 12) | voice->Vol,
588 TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); 593 TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
589 break; 594 break;
@@ -3554,8 +3559,8 @@ int __devinit snd_trident_create(struct snd_card *card,
3554 if ((err = pci_enable_device(pci)) < 0) 3559 if ((err = pci_enable_device(pci)) < 0)
3555 return err; 3560 return err;
3556 /* check, if we can restrict PCI DMA transfers to 30 bits */ 3561 /* check, if we can restrict PCI DMA transfers to 30 bits */
3557 if (pci_set_dma_mask(pci, DMA_30BIT_MASK) < 0 || 3562 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
3558 pci_set_consistent_dma_mask(pci, DMA_30BIT_MASK) < 0) { 3563 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
3559 snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n"); 3564 snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n");
3560 pci_disable_device(pci); 3565 pci_disable_device(pci);
3561 return -ENXIO; 3566 return -ENXIO;
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index d8705547dae1..809b233dd4a3 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -466,7 +466,10 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
466 flag = VIA_TBL_BIT_FLAG; /* period boundary */ 466 flag = VIA_TBL_BIT_FLAG; /* period boundary */
467 } else 467 } else
468 flag = 0; /* period continues to the next */ 468 flag = 0; /* period continues to the next */
469 // printk("via: tbl %d: at %d size %d (rest %d)\n", idx, ofs, r, rest); 469 /*
470 printk(KERN_DEBUG "via: tbl %d: at %d size %d "
471 "(rest %d)\n", idx, ofs, r, rest);
472 */
470 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); 473 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
471 dev->idx_table[idx].offset = ofs; 474 dev->idx_table[idx].offset = ofs;
472 dev->idx_table[idx].size = r; 475 dev->idx_table[idx].size = r;
@@ -2360,14 +2363,14 @@ static struct snd_pci_quirk dxs_whitelist[] __devinitdata = {
2360 SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), 2363 SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K),
2361 SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), 2364 SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA),
2362 SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA), 2365 SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA),
2363 SND_PCI_QUIRK(0x1019, 0, "ESC K8", VIA_DXS_SRC), 2366 SND_PCI_QUIRK_VENDOR(0x1019, "ESC K8", VIA_DXS_SRC),
2364 SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC), 2367 SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC),
2365 SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA), 2368 SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA),
2366 SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC), 2369 SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC),
2367 SND_PCI_QUIRK(0x1043, 0, "ASUS A7/A8", VIA_DXS_NO_VRA), 2370 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS A7/A8", VIA_DXS_NO_VRA),
2368 SND_PCI_QUIRK(0x1071, 0, "Diverse Notebook", VIA_DXS_NO_VRA), 2371 SND_PCI_QUIRK_VENDOR(0x1071, "Diverse Notebook", VIA_DXS_NO_VRA),
2369 SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE), 2372 SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE),
2370 SND_PCI_QUIRK(0x1106, 0, "ASRock", VIA_DXS_SRC), 2373 SND_PCI_QUIRK_VENDOR(0x1106, "ASRock", VIA_DXS_SRC),
2371 SND_PCI_QUIRK(0x1297, 0xa231, "Shuttle AK31v2", VIA_DXS_SRC), 2374 SND_PCI_QUIRK(0x1297, 0xa231, "Shuttle AK31v2", VIA_DXS_SRC),
2372 SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_SRC), 2375 SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_SRC),
2373 SND_PCI_QUIRK(0x1297, 0xc160, "Shuttle Sk41G", VIA_DXS_SRC), 2376 SND_PCI_QUIRK(0x1297, 0xc160, "Shuttle Sk41G", VIA_DXS_SRC),
@@ -2375,7 +2378,7 @@ static struct snd_pci_quirk dxs_whitelist[] __devinitdata = {
2375 SND_PCI_QUIRK(0x1462, 0x3800, "MSI KT266", VIA_DXS_ENABLE), 2378 SND_PCI_QUIRK(0x1462, 0x3800, "MSI KT266", VIA_DXS_ENABLE),
2376 SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE), 2379 SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE),
2377 SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE), 2380 SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE),
2378 SND_PCI_QUIRK(0x1462, 0, "MSI Mobo", VIA_DXS_SRC), 2381 SND_PCI_QUIRK_VENDOR(0x1462, "MSI Mobo", VIA_DXS_SRC),
2379 SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE), 2382 SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE),
2380 SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE), 2383 SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE),
2381 SND_PCI_QUIRK(0x147b, 0x1413, "ABIT KV8 Pro", VIA_DXS_ENABLE), 2384 SND_PCI_QUIRK(0x147b, 0x1413, "ABIT KV8 Pro", VIA_DXS_ENABLE),
@@ -2389,11 +2392,11 @@ static struct snd_pci_quirk dxs_whitelist[] __devinitdata = {
2389 SND_PCI_QUIRK(0x161f, 0x2032, "m680x machines", VIA_DXS_48K), 2392 SND_PCI_QUIRK(0x161f, 0x2032, "m680x machines", VIA_DXS_48K),
2390 SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE), 2393 SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE),
2391 SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE), 2394 SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE),
2392 SND_PCI_QUIRK(0x1695, 0, "EPoX mobo", VIA_DXS_SRC), 2395 SND_PCI_QUIRK_VENDOR(0x1695, "EPoX mobo", VIA_DXS_SRC),
2393 SND_PCI_QUIRK(0x16f3, 0, "Jetway K8", VIA_DXS_SRC), 2396 SND_PCI_QUIRK_VENDOR(0x16f3, "Jetway K8", VIA_DXS_SRC),
2394 SND_PCI_QUIRK(0x1734, 0, "FSC Laptop", VIA_DXS_SRC), 2397 SND_PCI_QUIRK_VENDOR(0x1734, "FSC Laptop", VIA_DXS_SRC),
2395 SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA), 2398 SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA),
2396 SND_PCI_QUIRK(0x1849, 0, "ASRock mobo", VIA_DXS_SRC), 2399 SND_PCI_QUIRK_VENDOR(0x1849, "ASRock mobo", VIA_DXS_SRC),
2397 SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8", VIA_DXS_NO_VRA), 2400 SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8", VIA_DXS_NO_VRA),
2398 SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC), 2401 SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC),
2399 { } /* terminator */ 2402 { } /* terminator */
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index c086b762c150..0d54e3503c1e 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -328,7 +328,10 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
328 flag = VIA_TBL_BIT_FLAG; /* period boundary */ 328 flag = VIA_TBL_BIT_FLAG; /* period boundary */
329 } else 329 } else
330 flag = 0; /* period continues to the next */ 330 flag = 0; /* period continues to the next */
331 // printk("via: tbl %d: at %d size %d (rest %d)\n", idx, ofs, r, rest); 331 /*
332 printk(KERN_DEBUG "via: tbl %d: at %d size %d "
333 "(rest %d)\n", idx, ofs, r, rest);
334 */
332 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); 335 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
333 dev->idx_table[idx].offset = ofs; 336 dev->idx_table[idx].offset = ofs;
334 dev->idx_table[idx].size = r; 337 dev->idx_table[idx].size = r;
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c
index 7e87f398ff0b..c0efe4491116 100644
--- a/sound/pci/vx222/vx222_ops.c
+++ b/sound/pci/vx222/vx222_ops.c
@@ -107,7 +107,9 @@ static unsigned char vx2_inb(struct vx_core *chip, int offset)
107static void vx2_outb(struct vx_core *chip, int offset, unsigned char val) 107static void vx2_outb(struct vx_core *chip, int offset, unsigned char val)
108{ 108{
109 outb(val, vx2_reg_addr(chip, offset)); 109 outb(val, vx2_reg_addr(chip, offset));
110 //printk("outb: %x -> %x\n", val, vx2_reg_addr(chip, offset)); 110 /*
111 printk(KERN_DEBUG "outb: %x -> %x\n", val, vx2_reg_addr(chip, offset));
112 */
111} 113}
112 114
113/** 115/**
@@ -126,7 +128,9 @@ static unsigned int vx2_inl(struct vx_core *chip, int offset)
126 */ 128 */
127static void vx2_outl(struct vx_core *chip, int offset, unsigned int val) 129static void vx2_outl(struct vx_core *chip, int offset, unsigned int val)
128{ 130{
129 // printk("outl: %x -> %x\n", val, vx2_reg_addr(chip, offset)); 131 /*
132 printk(KERN_DEBUG "outl: %x -> %x\n", val, vx2_reg_addr(chip, offset));
133 */
130 outl(val, vx2_reg_addr(chip, offset)); 134 outl(val, vx2_reg_addr(chip, offset));
131} 135}
132 136
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 90d0d62bd0b4..2f0925236a1b 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -318,7 +318,12 @@ static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_
318 ypcm->period_pos += delta; 318 ypcm->period_pos += delta;
319 ypcm->last_pos = pos; 319 ypcm->last_pos = pos;
320 if (ypcm->period_pos >= ypcm->period_size) { 320 if (ypcm->period_pos >= ypcm->period_size) {
321 // printk("done - active_bank = 0x%x, start = 0x%x\n", chip->active_bank, voice->bank[chip->active_bank].start); 321 /*
322 printk(KERN_DEBUG
323 "done - active_bank = 0x%x, start = 0x%x\n",
324 chip->active_bank,
325 voice->bank[chip->active_bank].start);
326 */
322 ypcm->period_pos %= ypcm->period_size; 327 ypcm->period_pos %= ypcm->period_size;
323 spin_unlock(&chip->reg_lock); 328 spin_unlock(&chip->reg_lock);
324 snd_pcm_period_elapsed(ypcm->substream); 329 snd_pcm_period_elapsed(ypcm->substream);
@@ -366,7 +371,12 @@ static void snd_ymfpci_pcm_capture_interrupt(struct snd_pcm_substream *substream
366 ypcm->last_pos = pos; 371 ypcm->last_pos = pos;
367 if (ypcm->period_pos >= ypcm->period_size) { 372 if (ypcm->period_pos >= ypcm->period_size) {
368 ypcm->period_pos %= ypcm->period_size; 373 ypcm->period_pos %= ypcm->period_size;
369 // printk("done - active_bank = 0x%x, start = 0x%x\n", chip->active_bank, voice->bank[chip->active_bank].start); 374 /*
375 printk(KERN_DEBUG
376 "done - active_bank = 0x%x, start = 0x%x\n",
377 chip->active_bank,
378 voice->bank[chip->active_bank].start);
379 */
370 spin_unlock(&chip->reg_lock); 380 spin_unlock(&chip->reg_lock);
371 snd_pcm_period_elapsed(substream); 381 snd_pcm_period_elapsed(substream);
372 spin_lock(&chip->reg_lock); 382 spin_lock(&chip->reg_lock);
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
index dfa40b0ed86d..5d2afa0b0ce4 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
@@ -82,14 +82,21 @@ static void pdacf_ak4117_write(void *private_data, unsigned char reg, unsigned c
82#if 0 82#if 0
83void pdacf_dump(struct snd_pdacf *chip) 83void pdacf_dump(struct snd_pdacf *chip)
84{ 84{
85 printk("PDAUDIOCF DUMP (0x%lx):\n", chip->port); 85 printk(KERN_DEBUG "PDAUDIOCF DUMP (0x%lx):\n", chip->port);
86 printk("WPD : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_WDP)); 86 printk(KERN_DEBUG "WPD : 0x%x\n",
87 printk("RDP : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_RDP)); 87 inw(chip->port + PDAUDIOCF_REG_WDP));
88 printk("TCR : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_TCR)); 88 printk(KERN_DEBUG "RDP : 0x%x\n",
89 printk("SCR : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_SCR)); 89 inw(chip->port + PDAUDIOCF_REG_RDP));
90 printk("ISR : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_ISR)); 90 printk(KERN_DEBUG "TCR : 0x%x\n",
91 printk("IER : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_IER)); 91 inw(chip->port + PDAUDIOCF_REG_TCR));
92 printk("AK_IFR : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_AK_IFR)); 92 printk(KERN_DEBUG "SCR : 0x%x\n",
93 inw(chip->port + PDAUDIOCF_REG_SCR));
94 printk(KERN_DEBUG "ISR : 0x%x\n",
95 inw(chip->port + PDAUDIOCF_REG_ISR));
96 printk(KERN_DEBUG "IER : 0x%x\n",
97 inw(chip->port + PDAUDIOCF_REG_IER));
98 printk(KERN_DEBUG "AK_IFR : 0x%x\n",
99 inw(chip->port + PDAUDIOCF_REG_AK_IFR));
93} 100}
94#endif 101#endif
95 102
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c b/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c
index ea903c8e90dd..dcd32201bc8c 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c
@@ -269,7 +269,7 @@ void pdacf_tasklet(unsigned long private_data)
269 269
270 rdp = inw(chip->port + PDAUDIOCF_REG_RDP); 270 rdp = inw(chip->port + PDAUDIOCF_REG_RDP);
271 wdp = inw(chip->port + PDAUDIOCF_REG_WDP); 271 wdp = inw(chip->port + PDAUDIOCF_REG_WDP);
272 // printk("TASKLET: rdp = %x, wdp = %x\n", rdp, wdp); 272 /* printk(KERN_DEBUG "TASKLET: rdp = %x, wdp = %x\n", rdp, wdp); */
273 size = wdp - rdp; 273 size = wdp - rdp;
274 if (size < 0) 274 if (size < 0)
275 size += 0x10000; 275 size += 0x10000;
@@ -321,5 +321,5 @@ void pdacf_tasklet(unsigned long private_data)
321 spin_lock(&chip->reg_lock); 321 spin_lock(&chip->reg_lock);
322 } 322 }
323 spin_unlock(&chip->reg_lock); 323 spin_unlock(&chip->reg_lock);
324 // printk("TASKLET: end\n"); 324 /* printk(KERN_DEBUG "TASKLET: end\n"); */
325} 325}
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
index 01066c95580e..d057e6489643 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
@@ -240,7 +240,8 @@ static int pdacf_pcm_prepare(struct snd_pcm_substream *subs)
240static struct snd_pcm_hardware pdacf_pcm_capture_hw = { 240static struct snd_pcm_hardware pdacf_pcm_capture_hw = {
241 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 241 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
242 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | 242 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
243 SNDRV_PCM_INFO_MMAP_VALID), 243 SNDRV_PCM_INFO_MMAP_VALID |
244 SNDRV_PCM_INFO_BATCH),
244 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | 245 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
245 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | 246 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |
246 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE, 247 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE,
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig
index 777de2b17178..bd2338ab2ced 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -13,6 +13,7 @@ config SND_POWERMAC
13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" 13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
14 depends on I2C && INPUT && PPC_PMAC 14 depends on I2C && INPUT && PPC_PMAC
15 select SND_PCM 15 select SND_PCM
16 select SND_VMASTER
16 help 17 help
17 Say Y here to include support for the integrated sound device. 18 Say Y here to include support for the integrated sound device.
18 19
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c
index 7bd33e6552ab..80df9b1f651e 100644
--- a/sound/ppc/awacs.c
+++ b/sound/ppc/awacs.c
@@ -608,9 +608,12 @@ static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] __initdata = {
608 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0), 608 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0),
609}; 609};
610 610
611static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = { 611static struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] __initdata = {
612 AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), 612 AWACS_VOLUME("Line out Playback Volume", 2, 6, 1),
613 AWACS_VOLUME("Master Playback Volume", 5, 6, 1), 613};
614
615static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = {
616 AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
614 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), 617 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
615}; 618};
616 619
@@ -627,6 +630,10 @@ static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] __initdata = {
627 AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), 630 AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0),
628}; 631};
629 632
633static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] __initdata = {
634 AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1),
635};
636
630static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = { 637static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = {
631 AWACS_VOLUME("Master Playback Volume", 2, 6, 1), 638 AWACS_VOLUME("Master Playback Volume", 2, 6, 1),
632 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), 639 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
@@ -645,12 +652,19 @@ static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __initdata = {
645 AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), 652 AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0),
646}; 653};
647 654
655static struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] __initdata = {
656 AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
657};
658
648static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata = 659static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata =
649AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); 660AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1);
650 661
651static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __initdata = 662static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __initdata =
652AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1); 663AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1);
653 664
665static struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 __initdata =
666AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1);
667
654static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = { 668static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = {
655 AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0), 669 AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
656}; 670};
@@ -766,12 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
766} 780}
767#endif /* CONFIG_PM */ 781#endif /* CONFIG_PM */
768 782
769#define IS_PM7500 (machine_is_compatible("AAPL,7500")) 783#define IS_PM7500 (machine_is_compatible("AAPL,7500") \
784 || machine_is_compatible("AAPL,8500") \
785 || machine_is_compatible("AAPL,9500"))
786#define IS_PM5500 (machine_is_compatible("AAPL,e411"))
770#define IS_BEIGE (machine_is_compatible("AAPL,Gossamer")) 787#define IS_BEIGE (machine_is_compatible("AAPL,Gossamer"))
771#define IS_IMAC1 (machine_is_compatible("PowerMac2,1")) 788#define IS_IMAC1 (machine_is_compatible("PowerMac2,1"))
772#define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \ 789#define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \
773 || machine_is_compatible("PowerMac4,1")) 790 || machine_is_compatible("PowerMac4,1"))
774#define IS_G4AGP (machine_is_compatible("PowerMac3,1")) 791#define IS_G4AGP (machine_is_compatible("PowerMac3,1"))
792#define IS_LOMBARD (machine_is_compatible("PowerBook1,1"))
775 793
776static int imac1, imac2; 794static int imac1, imac2;
777 795
@@ -858,10 +876,14 @@ int __init
858snd_pmac_awacs_init(struct snd_pmac *chip) 876snd_pmac_awacs_init(struct snd_pmac *chip)
859{ 877{
860 int pm7500 = IS_PM7500; 878 int pm7500 = IS_PM7500;
879 int pm5500 = IS_PM5500;
861 int beige = IS_BEIGE; 880 int beige = IS_BEIGE;
862 int g4agp = IS_G4AGP; 881 int g4agp = IS_G4AGP;
882 int lombard = IS_LOMBARD;
863 int imac; 883 int imac;
864 int err, vol; 884 int err, vol;
885 struct snd_kcontrol *vmaster_sw, *vmaster_vol;
886 struct snd_kcontrol *master_vol, *speaker_vol;
865 887
866 imac1 = IS_IMAC1; 888 imac1 = IS_IMAC1;
867 imac2 = IS_IMAC2; 889 imac2 = IS_IMAC2;
@@ -915,7 +937,7 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
915 /* set headphone-jack detection bit */ 937 /* set headphone-jack detection bit */
916 switch (chip->model) { 938 switch (chip->model) {
917 case PMAC_AWACS: 939 case PMAC_AWACS:
918 chip->hp_stat_mask = pm7500 ? MASK_HDPCONN 940 chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN
919 : MASK_LOCONN; 941 : MASK_LOCONN;
920 break; 942 break;
921 case PMAC_SCREAMER: 943 case PMAC_SCREAMER:
@@ -954,7 +976,7 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
954 return err; 976 return err;
955 if (beige || g4agp) 977 if (beige || g4agp)
956 ; 978 ;
957 else if (chip->model == PMAC_SCREAMER) 979 else if (chip->model == PMAC_SCREAMER || pm5500)
958 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2), 980 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2),
959 snd_pmac_screamer_mixers2); 981 snd_pmac_screamer_mixers2);
960 else if (!pm7500) 982 else if (!pm7500)
@@ -962,19 +984,35 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
962 snd_pmac_awacs_mixers2); 984 snd_pmac_awacs_mixers2);
963 if (err < 0) 985 if (err < 0)
964 return err; 986 return err;
987 if (pm5500) {
988 err = build_mixers(chip,
989 ARRAY_SIZE(snd_pmac_awacs_mixers2_pmac5500),
990 snd_pmac_awacs_mixers2_pmac5500);
991 if (err < 0)
992 return err;
993 }
965 if (pm7500) 994 if (pm7500)
966 err = build_mixers(chip, 995 err = build_mixers(chip,
967 ARRAY_SIZE(snd_pmac_awacs_mixers_pmac7500), 996 ARRAY_SIZE(snd_pmac_awacs_mixers_pmac7500),
968 snd_pmac_awacs_mixers_pmac7500); 997 snd_pmac_awacs_mixers_pmac7500);
998 else if (pm5500)
999 err = snd_ctl_add(chip->card,
1000 (master_vol = snd_ctl_new1(snd_pmac_awacs_mixers_pmac5500,
1001 chip)));
969 else if (beige) 1002 else if (beige)
970 err = build_mixers(chip, 1003 err = build_mixers(chip,
971 ARRAY_SIZE(snd_pmac_screamer_mixers_beige), 1004 ARRAY_SIZE(snd_pmac_screamer_mixers_beige),
972 snd_pmac_screamer_mixers_beige); 1005 snd_pmac_screamer_mixers_beige);
973 else if (imac) 1006 else if (imac || lombard) {
1007 err = snd_ctl_add(chip->card,
1008 (master_vol = snd_ctl_new1(snd_pmac_screamer_mixers_lo,
1009 chip)));
1010 if (err < 0)
1011 return err;
974 err = build_mixers(chip, 1012 err = build_mixers(chip,
975 ARRAY_SIZE(snd_pmac_screamer_mixers_imac), 1013 ARRAY_SIZE(snd_pmac_screamer_mixers_imac),
976 snd_pmac_screamer_mixers_imac); 1014 snd_pmac_screamer_mixers_imac);
977 else if (g4agp) 1015 } else if (g4agp)
978 err = build_mixers(chip, 1016 err = build_mixers(chip,
979 ARRAY_SIZE(snd_pmac_screamer_mixers_g4agp), 1017 ARRAY_SIZE(snd_pmac_screamer_mixers_g4agp),
980 snd_pmac_screamer_mixers_g4agp); 1018 snd_pmac_screamer_mixers_g4agp);
@@ -984,8 +1022,10 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
984 snd_pmac_awacs_mixers_pmac); 1022 snd_pmac_awacs_mixers_pmac);
985 if (err < 0) 1023 if (err < 0)
986 return err; 1024 return err;
987 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp) 1025 chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard)
988 ? &snd_pmac_awacs_master_sw_imac 1026 ? &snd_pmac_awacs_master_sw_imac
1027 : pm5500
1028 ? &snd_pmac_awacs_master_sw_pmac5500
989 : &snd_pmac_awacs_master_sw, chip); 1029 : &snd_pmac_awacs_master_sw, chip);
990 err = snd_ctl_add(chip->card, chip->master_sw_ctl); 1030 err = snd_ctl_add(chip->card, chip->master_sw_ctl);
991 if (err < 0) 1031 if (err < 0)
@@ -1017,8 +1057,9 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
1017#endif /* PMAC_AMP_AVAIL */ 1057#endif /* PMAC_AMP_AVAIL */
1018 { 1058 {
1019 /* route A = headphone, route C = speaker */ 1059 /* route A = headphone, route C = speaker */
1020 err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol), 1060 err = snd_ctl_add(chip->card,
1021 snd_pmac_awacs_speaker_vol); 1061 (speaker_vol = snd_ctl_new1(snd_pmac_awacs_speaker_vol,
1062 chip)));
1022 if (err < 0) 1063 if (err < 0)
1023 return err; 1064 return err;
1024 chip->speaker_sw_ctl = snd_ctl_new1(imac1 1065 chip->speaker_sw_ctl = snd_ctl_new1(imac1
@@ -1031,6 +1072,33 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
1031 return err; 1072 return err;
1032 } 1073 }
1033 1074
1075 if (pm5500 || imac || lombard) {
1076 vmaster_sw = snd_ctl_make_virtual_master(
1077 "Master Playback Switch", (unsigned int *) NULL);
1078 err = snd_ctl_add_slave_uncached(vmaster_sw,
1079 chip->master_sw_ctl);
1080 if (err < 0)
1081 return err;
1082 err = snd_ctl_add_slave_uncached(vmaster_sw,
1083 chip->speaker_sw_ctl);
1084 if (err < 0)
1085 return err;
1086 err = snd_ctl_add(chip->card, vmaster_sw);
1087 if (err < 0)
1088 return err;
1089 vmaster_vol = snd_ctl_make_virtual_master(
1090 "Master Playback Volume", (unsigned int *) NULL);
1091 err = snd_ctl_add_slave(vmaster_vol, master_vol);
1092 if (err < 0)
1093 return err;
1094 err = snd_ctl_add_slave(vmaster_vol, speaker_vol);
1095 if (err < 0)
1096 return err;
1097 err = snd_ctl_add(chip->card, vmaster_vol);
1098 if (err < 0)
1099 return err;
1100 }
1101
1034 if (beige || g4agp) 1102 if (beige || g4agp)
1035 err = build_mixers(chip, 1103 err = build_mixers(chip,
1036 ARRAY_SIZE(snd_pmac_screamer_mic_boost_beige), 1104 ARRAY_SIZE(snd_pmac_screamer_mic_boost_beige),
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c
index f860d39af36b..45a76297c38d 100644
--- a/sound/ppc/burgundy.c
+++ b/sound/ppc/burgundy.c
@@ -35,7 +35,7 @@ snd_pmac_burgundy_busy_wait(struct snd_pmac *chip)
35 int timeout = 50; 35 int timeout = 50;
36 while ((in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) && timeout--) 36 while ((in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) && timeout--)
37 udelay(1); 37 udelay(1);
38 if (! timeout) 38 if (timeout < 0)
39 printk(KERN_DEBUG "burgundy_busy_wait: timeout\n"); 39 printk(KERN_DEBUG "burgundy_busy_wait: timeout\n");
40} 40}
41 41
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c
index 8a5b29031933..f8d478c2da62 100644
--- a/sound/ppc/daca.c
+++ b/sound/ppc/daca.c
@@ -82,7 +82,7 @@ static int daca_set_volume(struct pmac_daca *mix)
82 data[1] |= mix->deemphasis ? 0x40 : 0; 82 data[1] |= mix->deemphasis ? 0x40 : 0;
83 if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL, 83 if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL,
84 2, data) < 0) { 84 2, data) < 0) {
85 snd_printk("failed to set volume \n"); 85 snd_printk(KERN_ERR "failed to set volume \n");
86 return -EINVAL; 86 return -EINVAL;
87 } 87 }
88 return 0; 88 return 0;
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c
index 6ff99ed77516..a5afb2682e7f 100644
--- a/sound/ppc/keywest.c
+++ b/sound/ppc/keywest.c
@@ -33,26 +33,25 @@
33static struct pmac_keywest *keywest_ctx; 33static struct pmac_keywest *keywest_ctx;
34 34
35 35
36static int keywest_attach_adapter(struct i2c_adapter *adapter);
37static int keywest_detach_client(struct i2c_client *client);
38
39struct i2c_driver keywest_driver = {
40 .driver = {
41 .name = "PMac Keywest Audio",
42 },
43 .attach_adapter = &keywest_attach_adapter,
44 .detach_client = &keywest_detach_client,
45};
46
47
48#ifndef i2c_device_name 36#ifndef i2c_device_name
49#define i2c_device_name(x) ((x)->name) 37#define i2c_device_name(x) ((x)->name)
50#endif 38#endif
51 39
40static int keywest_probe(struct i2c_client *client,
41 const struct i2c_device_id *id)
42{
43 i2c_set_clientdata(client, keywest_ctx);
44 return 0;
45}
46
47/*
48 * This is kind of a hack, best would be to turn powermac to fixed i2c
49 * bus numbers and declare the sound device as part of platform
50 * initialization
51 */
52static int keywest_attach_adapter(struct i2c_adapter *adapter) 52static int keywest_attach_adapter(struct i2c_adapter *adapter)
53{ 53{
54 int err; 54 struct i2c_board_info info;
55 struct i2c_client *new_client;
56 55
57 if (! keywest_ctx) 56 if (! keywest_ctx)
58 return -EINVAL; 57 return -EINVAL;
@@ -60,46 +59,47 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
60 if (strncmp(i2c_device_name(adapter), "mac-io", 6)) 59 if (strncmp(i2c_device_name(adapter), "mac-io", 6))
61 return 0; /* ignored */ 60 return 0; /* ignored */
62 61
63 new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 62 memset(&info, 0, sizeof(struct i2c_board_info));
64 if (! new_client) 63 strlcpy(info.type, "keywest", I2C_NAME_SIZE);
65 return -ENOMEM; 64 info.addr = keywest_ctx->addr;
66 65 keywest_ctx->client = i2c_new_device(adapter, &info);
67 new_client->addr = keywest_ctx->addr;
68 i2c_set_clientdata(new_client, keywest_ctx);
69 new_client->adapter = adapter;
70 new_client->driver = &keywest_driver;
71 new_client->flags = 0;
72
73 strcpy(i2c_device_name(new_client), keywest_ctx->name);
74 keywest_ctx->client = new_client;
75 66
76 /* Tell the i2c layer a new client has arrived */ 67 /*
77 if (i2c_attach_client(new_client)) { 68 * Let i2c-core delete that device on driver removal.
78 snd_printk(KERN_ERR "tumbler: cannot attach i2c client\n"); 69 * This is safe because i2c-core holds the core_lock mutex for us.
79 err = -ENODEV; 70 */
80 goto __err; 71 list_add_tail(&keywest_ctx->client->detected,
81 } 72 &keywest_ctx->client->driver->clients);
82
83 return 0; 73 return 0;
84
85 __err:
86 kfree(new_client);
87 keywest_ctx->client = NULL;
88 return err;
89} 74}
90 75
91static int keywest_detach_client(struct i2c_client *client) 76static int keywest_remove(struct i2c_client *client)
92{ 77{
78 i2c_set_clientdata(client, NULL);
93 if (! keywest_ctx) 79 if (! keywest_ctx)
94 return 0; 80 return 0;
95 if (client == keywest_ctx->client) 81 if (client == keywest_ctx->client)
96 keywest_ctx->client = NULL; 82 keywest_ctx->client = NULL;
97 83
98 i2c_detach_client(client);
99 kfree(client);
100 return 0; 84 return 0;
101} 85}
102 86
87
88static const struct i2c_device_id keywest_i2c_id[] = {
89 { "keywest", 0 },
90 { }
91};
92
93struct i2c_driver keywest_driver = {
94 .driver = {
95 .name = "PMac Keywest Audio",
96 },
97 .attach_adapter = keywest_attach_adapter,
98 .probe = keywest_probe,
99 .remove = keywest_remove,
100 .id_table = keywest_i2c_id,
101};
102
103/* exported */ 103/* exported */
104void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) 104void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c)
105{ 105{
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index af76ee862d27..9b4e9c316695 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -299,7 +299,7 @@ static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec,
299 case SNDRV_PCM_TRIGGER_SUSPEND: 299 case SNDRV_PCM_TRIGGER_SUSPEND:
300 spin_lock(&chip->reg_lock); 300 spin_lock(&chip->reg_lock);
301 rec->running = 0; 301 rec->running = 0;
302 /*printk("stopped!!\n");*/ 302 /*printk(KERN_DEBUG "stopped!!\n");*/
303 snd_pmac_dma_stop(rec); 303 snd_pmac_dma_stop(rec);
304 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) 304 for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
305 out_le16(&cp->command, DBDMA_STOP); 305 out_le16(&cp->command, DBDMA_STOP);
@@ -334,7 +334,7 @@ static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip,
334 } 334 }
335#endif 335#endif
336 count += rec->cur_period * rec->period_size; 336 count += rec->cur_period * rec->period_size;
337 /*printk("pointer=%d\n", count);*/ 337 /*printk(KERN_DEBUG "pointer=%d\n", count);*/
338 return bytes_to_frames(subs->runtime, count); 338 return bytes_to_frames(subs->runtime, count);
339} 339}
340 340
@@ -486,7 +486,7 @@ static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec)
486 if (! (stat & ACTIVE)) 486 if (! (stat & ACTIVE))
487 break; 487 break;
488 488
489 /*printk("update frag %d\n", rec->cur_period);*/ 489 /*printk(KERN_DEBUG "update frag %d\n", rec->cur_period);*/
490 st_le16(&cp->xfer_status, 0); 490 st_le16(&cp->xfer_status, 0);
491 st_le16(&cp->req_count, rec->period_size); 491 st_le16(&cp->req_count, rec->period_size);
492 /*st_le16(&cp->res_count, 0);*/ 492 /*st_le16(&cp->res_count, 0);*/
@@ -806,7 +806,7 @@ snd_pmac_ctrl_intr(int irq, void *devid)
806 struct snd_pmac *chip = devid; 806 struct snd_pmac *chip = devid;
807 int ctrl = in_le32(&chip->awacs->control); 807 int ctrl = in_le32(&chip->awacs->control);
808 808
809 /*printk("pmac: control interrupt.. 0x%x\n", ctrl);*/ 809 /*printk(KERN_DEBUG "pmac: control interrupt.. 0x%x\n", ctrl);*/
810 if (ctrl & MASK_PORTCHG) { 810 if (ctrl & MASK_PORTCHG) {
811 /* do something when headphone is plugged/unplugged? */ 811 /* do something when headphone is plugged/unplugged? */
812 if (chip->update_automute) 812 if (chip->update_automute)
@@ -1033,7 +1033,8 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
1033 } 1033 }
1034 if (of_device_is_compatible(sound, "tumbler")) { 1034 if (of_device_is_compatible(sound, "tumbler")) {
1035 chip->model = PMAC_TUMBLER; 1035 chip->model = PMAC_TUMBLER;
1036 chip->can_capture = machine_is_compatible("PowerMac4,2"); 1036 chip->can_capture = machine_is_compatible("PowerMac4,2")
1037 || machine_is_compatible("PowerBook4,1");
1037 chip->can_duplex = 0; 1038 chip->can_duplex = 0;
1038 // chip->can_byte_swap = 0; /* FIXME: check this */ 1039 // chip->can_byte_swap = 0; /* FIXME: check this */
1039 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); 1040 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index 2e18ed0ea899..a2b69b8cff43 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -51,7 +51,7 @@ static struct platform_device *device;
51/* 51/*
52 */ 52 */
53 53
54static int __init snd_pmac_probe(struct platform_device *devptr) 54static int __devinit snd_pmac_probe(struct platform_device *devptr)
55{ 55{
56 struct snd_card *card; 56 struct snd_card *card;
57 struct snd_pmac *chip; 57 struct snd_pmac *chip;
@@ -110,7 +110,7 @@ static int __init snd_pmac_probe(struct platform_device *devptr)
110 goto __error; 110 goto __error;
111 break; 111 break;
112 default: 112 default:
113 snd_printk("unsupported hardware %d\n", chip->model); 113 snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model);
114 err = -EINVAL; 114 err = -EINVAL;
115 goto __error; 115 goto __error;
116 } 116 }
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
index ef2c3f417175..f361c26506aa 100644
--- a/sound/ppc/snd_ps3.c
+++ b/sound/ppc/snd_ps3.c
@@ -477,7 +477,7 @@ static int snd_ps3_pcm_prepare(struct snd_pcm_substream *substream)
477 card->dma_start_bus_addr[SND_PS3_CH_R] = 477 card->dma_start_bus_addr[SND_PS3_CH_R] =
478 runtime->dma_addr + (runtime->dma_bytes / 2); 478 runtime->dma_addr + (runtime->dma_bytes / 2);
479 479
480 pr_debug("%s: vaddr=%p bus=%#lx\n", __func__, 480 pr_debug("%s: vaddr=%p bus=%#llx\n", __func__,
481 card->dma_start_vaddr[SND_PS3_CH_L], 481 card->dma_start_vaddr[SND_PS3_CH_L],
482 card->dma_start_bus_addr[SND_PS3_CH_L]); 482 card->dma_start_bus_addr[SND_PS3_CH_L]);
483 483
@@ -1028,7 +1028,7 @@ static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
1028 pr_info("%s: nullbuffer alloc failed\n", __func__); 1028 pr_info("%s: nullbuffer alloc failed\n", __func__);
1029 goto clean_preallocate; 1029 goto clean_preallocate;
1030 } 1030 }
1031 pr_debug("%s: null vaddr=%p dma=%#lx\n", __func__, 1031 pr_debug("%s: null vaddr=%p dma=%#llx\n", __func__,
1032 the_card.null_buffer_start_vaddr, 1032 the_card.null_buffer_start_vaddr,
1033 the_card.null_buffer_start_dma_addr); 1033 the_card.null_buffer_start_dma_addr);
1034 /* set default sample rate/word width */ 1034 /* set default sample rate/word width */
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 3eb223385416..40222fcc0878 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -41,7 +41,7 @@
41#undef DEBUG 41#undef DEBUG
42 42
43#ifdef DEBUG 43#ifdef DEBUG
44#define DBG(fmt...) printk(fmt) 44#define DBG(fmt...) printk(KERN_DEBUG fmt)
45#else 45#else
46#define DBG(fmt...) 46#define DBG(fmt...)
47#endif 47#endif
@@ -240,7 +240,7 @@ static int tumbler_set_master_volume(struct pmac_tumbler *mix)
240 240
241 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_VOL, 6, 241 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_VOL, 6,
242 block) < 0) { 242 block) < 0) {
243 snd_printk("failed to set volume \n"); 243 snd_printk(KERN_ERR "failed to set volume \n");
244 return -EINVAL; 244 return -EINVAL;
245 } 245 }
246 return 0; 246 return 0;
@@ -350,7 +350,7 @@ static int tumbler_set_drc(struct pmac_tumbler *mix)
350 350
351 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC, 351 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
352 2, val) < 0) { 352 2, val) < 0) {
353 snd_printk("failed to set DRC\n"); 353 snd_printk(KERN_ERR "failed to set DRC\n");
354 return -EINVAL; 354 return -EINVAL;
355 } 355 }
356 return 0; 356 return 0;
@@ -386,7 +386,7 @@ static int snapper_set_drc(struct pmac_tumbler *mix)
386 386
387 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC, 387 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
388 6, val) < 0) { 388 6, val) < 0) {
389 snd_printk("failed to set DRC\n"); 389 snd_printk(KERN_ERR "failed to set DRC\n");
390 return -EINVAL; 390 return -EINVAL;
391 } 391 }
392 return 0; 392 return 0;
@@ -506,7 +506,8 @@ static int tumbler_set_mono_volume(struct pmac_tumbler *mix,
506 block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff; 506 block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff;
507 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, info->reg, 507 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, info->reg,
508 info->bytes, block) < 0) { 508 info->bytes, block) < 0) {
509 snd_printk("failed to set mono volume %d\n", info->index); 509 snd_printk(KERN_ERR "failed to set mono volume %d\n",
510 info->index);
510 return -EINVAL; 511 return -EINVAL;
511 } 512 }
512 return 0; 513 return 0;
@@ -643,7 +644,7 @@ static int snapper_set_mix_vol1(struct pmac_tumbler *mix, int idx, int ch, int r
643 } 644 }
644 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, reg, 645 if (i2c_smbus_write_i2c_block_data(mix->i2c.client, reg,
645 9, block) < 0) { 646 9, block) < 0) {
646 snd_printk("failed to set mono volume %d\n", reg); 647 snd_printk(KERN_ERR "failed to set mono volume %d\n", reg);
647 return -EINVAL; 648 return -EINVAL;
648 } 649 }
649 return 0; 650 return 0;
diff --git a/sound/sh/Kconfig b/sound/sh/Kconfig
index cfc143985802..aed0f90c3919 100644
--- a/sound/sh/Kconfig
+++ b/sound/sh/Kconfig
@@ -15,6 +15,7 @@ config SND_AICA
15 tristate "Dreamcast Yamaha AICA sound" 15 tristate "Dreamcast Yamaha AICA sound"
16 depends on SH_DREAMCAST 16 depends on SH_DREAMCAST
17 select SND_PCM 17 select SND_PCM
18 select G2_DMA
18 help 19 help
19 ALSA Sound driver for the SEGA Dreamcast console. 20 ALSA Sound driver for the SEGA Dreamcast console.
20 21
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index f551233c5a08..583a3693df75 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -565,7 +565,7 @@ static int load_aica_firmware(void)
565 err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev); 565 err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev);
566 if (unlikely(err)) 566 if (unlikely(err))
567 return err; 567 return err;
568 /* write firware into memory */ 568 /* write firmware into memory */
569 spu_disable(); 569 spu_disable();
570 spu_memload(0, fw_entry->data, fw_entry->size); 570 spu_memload(0, fw_entry->data, fw_entry->size);
571 spu_enable(); 571 spu_enable();
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c
index 30490a259148..594c6c5b7838 100644
--- a/sound/soc/au1x/dbdma2.c
+++ b/sound/soc/au1x/dbdma2.c
@@ -82,7 +82,7 @@ static struct au1xpsc_audio_dmadata *au1xpsc_audio_pcmdma[2];
82/* PCM hardware DMA capabilities - platform specific */ 82/* PCM hardware DMA capabilities - platform specific */
83static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { 83static const struct snd_pcm_hardware au1xpsc_pcm_hardware = {
84 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 84 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
85 SNDRV_PCM_INFO_INTERLEAVED, 85 SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH,
86 .formats = AU1XPSC_PCM_FMTS, 86 .formats = AU1XPSC_PCM_FMTS,
87 .period_bytes_min = AU1XPSC_PERIOD_MIN_BYTES, 87 .period_bytes_min = AU1XPSC_PERIOD_MIN_BYTES,
88 .period_bytes_max = 4096 * 1024 - 1, 88 .period_bytes_max = 4096 * 1024 - 1,
diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig
index 0a2f8f9eff53..811596f4c092 100644
--- a/sound/soc/blackfin/Kconfig
+++ b/sound/soc/blackfin/Kconfig
@@ -42,7 +42,7 @@ config SND_BF5XX_AC97
42 You will also need to select the audio interfaces to support below. 42 You will also need to select the audio interfaces to support below.
43 43
44 Note: 44 Note:
45 AC97 codecs which do not implment the slot-16 mode will not function 45 AC97 codecs which do not implement the slot-16 mode will not function
46 properly with this driver. This driver is known to work with the 46 properly with this driver. This driver is known to work with the
47 Analog Devices line of AC97 codecs. 47 Analog Devices line of AC97 codecs.
48 48
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
index 8cfed1a5dcbe..cf0dfb7ca221 100644
--- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
+++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
@@ -413,7 +413,7 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
413 sport_done(sport_handle); 413 sport_done(sport_handle);
414} 414}
415 415
416static u64 bf5xx_pcm_dmamask = DMA_32BIT_MASK; 416static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
417 417
418int bf5xx_pcm_ac97_new(struct snd_card *card, struct snd_soc_dai *dai, 418int bf5xx_pcm_ac97_new(struct snd_card *card, struct snd_soc_dai *dai,
419 struct snd_pcm *pcm) 419 struct snd_pcm *pcm)
@@ -424,7 +424,7 @@ int bf5xx_pcm_ac97_new(struct snd_card *card, struct snd_soc_dai *dai,
424 if (!card->dev->dma_mask) 424 if (!card->dev->dma_mask)
425 card->dev->dma_mask = &bf5xx_pcm_dmamask; 425 card->dev->dma_mask = &bf5xx_pcm_dmamask;
426 if (!card->dev->coherent_dma_mask) 426 if (!card->dev->coherent_dma_mask)
427 card->dev->coherent_dma_mask = DMA_32BIT_MASK; 427 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
428 428
429 if (dai->playback.channels_min) { 429 if (dai->playback.channels_min) {
430 ret = bf5xx_pcm_preallocate_dma_buffer(pcm, 430 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
index 1318c4f627b7..62fbb8459569 100644
--- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
+++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
@@ -245,7 +245,7 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
245 sport_done(sport_handle); 245 sport_done(sport_handle);
246} 246}
247 247
248static u64 bf5xx_pcm_dmamask = DMA_32BIT_MASK; 248static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
249 249
250int bf5xx_pcm_i2s_new(struct snd_card *card, struct snd_soc_dai *dai, 250int bf5xx_pcm_i2s_new(struct snd_card *card, struct snd_soc_dai *dai,
251 struct snd_pcm *pcm) 251 struct snd_pcm *pcm)
@@ -256,7 +256,7 @@ int bf5xx_pcm_i2s_new(struct snd_card *card, struct snd_soc_dai *dai,
256 if (!card->dev->dma_mask) 256 if (!card->dev->dma_mask)
257 card->dev->dma_mask = &bf5xx_pcm_dmamask; 257 card->dev->dma_mask = &bf5xx_pcm_dmamask;
258 if (!card->dev->coherent_dma_mask) 258 if (!card->dev->coherent_dma_mask)
259 card->dev->coherent_dma_mask = DMA_32BIT_MASK; 259 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
260 260
261 if (dai->playback.channels_min) { 261 if (dai->playback.channels_min) {
262 ret = bf5xx_pcm_preallocate_dma_buffer(pcm, 262 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c
index 3aa729df27b5..1111c710118a 100644
--- a/sound/soc/fsl/mpc5200_psc_i2s.c
+++ b/sound/soc/fsl/mpc5200_psc_i2s.c
@@ -504,7 +504,8 @@ static struct snd_soc_dai psc_i2s_dai_template = {
504 504
505static const struct snd_pcm_hardware psc_i2s_pcm_hardware = { 505static const struct snd_pcm_hardware psc_i2s_pcm_hardware = {
506 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 506 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
507 SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER, 507 SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
508 SNDRV_PCM_INFO_BATCH,
508 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | 509 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |
509 SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE, 510 SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE,
510 .rate_min = 8000, 511 .rate_min = 8000,
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index b078ed537bc3..07cf7f46b584 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -328,7 +328,7 @@ int omap_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
328 if (!card->dev->dma_mask) 328 if (!card->dev->dma_mask)
329 card->dev->dma_mask = &omap_pcm_dmamask; 329 card->dev->dma_mask = &omap_pcm_dmamask;
330 if (!card->dev->coherent_dma_mask) 330 if (!card->dev->coherent_dma_mask)
331 card->dev->coherent_dma_mask = DMA_32BIT_MASK; 331 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
332 332
333 if (dai->playback.channels_min) { 333 if (dai->playback.channels_min) {
334 ret = omap_pcm_preallocate_dma_buffer(pcm, 334 ret = omap_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 02263e5d8f03..d5be2b30cda5 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -26,8 +26,6 @@
26#include <sound/soc-dapm.h> 26#include <sound/soc-dapm.h>
27 27
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29#include <mach/pxa-regs.h>
30#include <mach/hardware.h>
31#include <mach/corgi.h> 29#include <mach/corgi.h>
32#include <mach/audio.h> 30#include <mach/audio.h>
33 31
diff --git a/sound/soc/pxa/em-x270.c b/sound/soc/pxa/em-x270.c
index fe4a729ea648..949be9c2a01b 100644
--- a/sound/soc/pxa/em-x270.c
+++ b/sound/soc/pxa/em-x270.c
@@ -29,8 +29,6 @@
29#include <sound/soc-dapm.h> 29#include <sound/soc-dapm.h>
30 30
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32#include <mach/pxa-regs.h>
33#include <mach/hardware.h>
34#include <mach/audio.h> 32#include <mach/audio.h>
35 33
36#include "../codecs/wm9712.h" 34#include "../codecs/wm9712.h"
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
index 48a73f64500b..44fcc4e01e08 100644
--- a/sound/soc/pxa/palm27x.c
+++ b/sound/soc/pxa/palm27x.c
@@ -200,7 +200,7 @@ static struct snd_soc_device palm27x_snd_devdata = {
200 200
201static struct platform_device *palm27x_snd_device; 201static struct platform_device *palm27x_snd_device;
202 202
203static int __init palm27x_asoc_init(void) 203static int palm27x_asoc_probe(struct platform_device *pdev)
204{ 204{
205 int ret; 205 int ret;
206 206
@@ -208,6 +208,10 @@ static int __init palm27x_asoc_init(void)
208 machine_is_palmld())) 208 machine_is_palmld()))
209 return -ENODEV; 209 return -ENODEV;
210 210
211 if (pdev->dev.platform_data)
212 palm27x_ep_gpio = ((struct palm27x_asoc_info *)
213 (pdev->dev.platform_data))->jack_gpio;
214
211 ret = gpio_request(palm27x_ep_gpio, "Headphone Jack"); 215 ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
212 if (ret) 216 if (ret)
213 return ret; 217 return ret;
@@ -245,16 +249,31 @@ err_alloc:
245 return ret; 249 return ret;
246} 250}
247 251
248static void __exit palm27x_asoc_exit(void) 252static int __devexit palm27x_asoc_remove(struct platform_device *pdev)
249{ 253{
250 free_irq(gpio_to_irq(palm27x_ep_gpio), NULL); 254 free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
251 gpio_free(palm27x_ep_gpio); 255 gpio_free(palm27x_ep_gpio);
252 platform_device_unregister(palm27x_snd_device); 256 platform_device_unregister(palm27x_snd_device);
257 return 0;
253} 258}
254 259
255void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data) 260static struct platform_driver palm27x_wm9712_driver = {
261 .probe = palm27x_asoc_probe,
262 .remove = __devexit_p(palm27x_asoc_remove),
263 .driver = {
264 .name = "palm27x-asoc",
265 .owner = THIS_MODULE,
266 },
267};
268
269static int __init palm27x_asoc_init(void)
270{
271 return platform_driver_register(&palm27x_wm9712_driver);
272}
273
274static void __exit palm27x_asoc_exit(void)
256{ 275{
257 palm27x_ep_gpio = data->jack_gpio; 276 platform_driver_unregister(&palm27x_wm9712_driver);
258} 277}
259 278
260module_init(palm27x_asoc_init); 279module_init(palm27x_asoc_init);
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index ef7c6c8dc8f1..a51058f66747 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -27,8 +27,6 @@
27 27
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29#include <asm/hardware/locomo.h> 29#include <asm/hardware/locomo.h>
30#include <mach/pxa-regs.h>
31#include <mach/hardware.h>
32#include <mach/poodle.h> 30#include <mach/poodle.h>
33#include <mach/audio.h> 31#include <mach/audio.h>
34 32
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 74ff69e3ce34..286be31545df 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -30,7 +30,7 @@
30#include <sound/pxa2xx-lib.h> 30#include <sound/pxa2xx-lib.h>
31 31
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/pxa-regs.h> 33#include <mach/dma.h>
34#include <mach/regs-ssp.h> 34#include <mach/regs-ssp.h>
35#include <mach/audio.h> 35#include <mach/audio.h>
36#include <mach/ssp.h> 36#include <mach/ssp.h>
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 01c21c6cdbbc..d9c94d71fa61 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -20,8 +20,8 @@
20#include <sound/pxa2xx-lib.h> 20#include <sound/pxa2xx-lib.h>
21 21
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <mach/pxa-regs.h>
24#include <mach/regs-ac97.h> 23#include <mach/regs-ac97.h>
24#include <mach/dma.h>
25 25
26#include "pxa2xx-pcm.h" 26#include "pxa2xx-pcm.h"
27#include "pxa2xx-ac97.h" 27#include "pxa2xx-ac97.h"
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index e6c24408c5f9..2f4b6e489b78 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -24,7 +24,7 @@
24#include <sound/pxa2xx-lib.h> 24#include <sound/pxa2xx-lib.h>
25 25
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/pxa-regs.h> 27#include <mach/dma.h>
28#include <mach/audio.h> 28#include <mach/audio.h>
29 29
30#include "pxa2xx-pcm.h" 30#include "pxa2xx-pcm.h"
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index 53b9fb127a6d..d38e39575f51 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -81,7 +81,7 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
81 .mmap = pxa2xx_pcm_mmap, 81 .mmap = pxa2xx_pcm_mmap,
82}; 82};
83 83
84static u64 pxa2xx_pcm_dmamask = DMA_32BIT_MASK; 84static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32);
85 85
86static int pxa2xx_soc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai, 86static int pxa2xx_soc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
87 struct snd_pcm *pcm) 87 struct snd_pcm *pcm)
@@ -91,7 +91,7 @@ static int pxa2xx_soc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
91 if (!card->dev->dma_mask) 91 if (!card->dev->dma_mask)
92 card->dev->dma_mask = &pxa2xx_pcm_dmamask; 92 card->dev->dma_mask = &pxa2xx_pcm_dmamask;
93 if (!card->dev->coherent_dma_mask) 93 if (!card->dev->coherent_dma_mask)
94 card->dev->coherent_dma_mask = DMA_32BIT_MASK; 94 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
95 95
96 if (dai->playback.channels_min) { 96 if (dai->playback.channels_min) {
97 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 97 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index 6ca9f53080c6..c4cd2acaacb4 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -26,8 +26,6 @@
26#include <sound/soc-dapm.h> 26#include <sound/soc-dapm.h>
27 27
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29#include <mach/pxa-regs.h>
30#include <mach/hardware.h>
31#include <mach/spitz.h> 29#include <mach/spitz.h>
32#include "../codecs/wm8750.h" 30#include "../codecs/wm8750.h"
33#include "pxa2xx-pcm.h" 31#include "pxa2xx-pcm.h"
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index fc781374b1bf..dbbd3e9d1637 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -30,8 +30,6 @@
30 30
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32#include <mach/tosa.h> 32#include <mach/tosa.h>
33#include <mach/pxa-regs.h>
34#include <mach/hardware.h>
35#include <mach/audio.h> 33#include <mach/audio.h>
36 34
37#include "../codecs/wm9712.h" 35#include "../codecs/wm9712.h"
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index a9d68fa2b34a..169ddad31575 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -419,7 +419,7 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
419 } 419 }
420} 420}
421 421
422static u64 s3c24xx_pcm_dmamask = DMA_32BIT_MASK; 422static u64 s3c24xx_pcm_dmamask = DMA_BIT_MASK(32);
423 423
424static int s3c24xx_pcm_new(struct snd_card *card, 424static int s3c24xx_pcm_new(struct snd_card *card,
425 struct snd_soc_dai *dai, struct snd_pcm *pcm) 425 struct snd_soc_dai *dai, struct snd_pcm *pcm)
diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
index 0dad3a0bb920..baddb1242c71 100644
--- a/sound/soc/sh/dma-sh7760.c
+++ b/sound/soc/sh/dma-sh7760.c
@@ -103,7 +103,8 @@ static struct snd_pcm_hardware camelot_pcm_hardware = {
103 .info = (SNDRV_PCM_INFO_MMAP | 103 .info = (SNDRV_PCM_INFO_MMAP |
104 SNDRV_PCM_INFO_INTERLEAVED | 104 SNDRV_PCM_INFO_INTERLEAVED |
105 SNDRV_PCM_INFO_BLOCK_TRANSFER | 105 SNDRV_PCM_INFO_BLOCK_TRANSFER |
106 SNDRV_PCM_INFO_MMAP_VALID), 106 SNDRV_PCM_INFO_MMAP_VALID |
107 SNDRV_PCM_INFO_BATCH),
107 .formats = DMABRG_FMTS, 108 .formats = DMABRG_FMTS,
108 .rates = DMABRG_RATES, 109 .rates = DMABRG_RATES,
109 .rate_min = 8000, 110 .rate_min = 8000,
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index ba38912614b4..574af56ba8a6 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -954,7 +954,8 @@ static int __devinit snd_amd7930_create(struct snd_card *card,
954 amd->regs = of_ioremap(&op->resource[0], 0, 954 amd->regs = of_ioremap(&op->resource[0], 0,
955 resource_size(&op->resource[0]), "amd7930"); 955 resource_size(&op->resource[0]), "amd7930");
956 if (!amd->regs) { 956 if (!amd->regs) {
957 snd_printk("amd7930-%d: Unable to map chip registers.\n", dev); 957 snd_printk(KERN_ERR
958 "amd7930-%d: Unable to map chip registers.\n", dev);
958 return -EIO; 959 return -EIO;
959 } 960 }
960 961
@@ -962,7 +963,7 @@ static int __devinit snd_amd7930_create(struct snd_card *card,
962 963
963 if (request_irq(irq, snd_amd7930_interrupt, 964 if (request_irq(irq, snd_amd7930_interrupt,
964 IRQF_DISABLED | IRQF_SHARED, "amd7930", amd)) { 965 IRQF_DISABLED | IRQF_SHARED, "amd7930", amd)) {
965 snd_printk("amd7930-%d: Unable to grab IRQ %d\n", 966 snd_printk(KERN_ERR "amd7930-%d: Unable to grab IRQ %d\n",
966 dev, irq); 967 dev, irq);
967 snd_amd7930_free(amd); 968 snd_amd7930_free(amd);
968 return -EBUSY; 969 return -EBUSY;
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 7d93fa705ccf..8d13d933087d 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -703,7 +703,7 @@ static int snd_cs4231_timer_stop(struct snd_timer *timer)
703 return 0; 703 return 0;
704} 704}
705 705
706static void __init snd_cs4231_init(struct snd_cs4231 *chip) 706static void __devinit snd_cs4231_init(struct snd_cs4231 *chip)
707{ 707{
708 unsigned long flags; 708 unsigned long flags;
709 709
@@ -1020,7 +1020,7 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(
1020 return bytes_to_frames(substream->runtime, ptr); 1020 return bytes_to_frames(substream->runtime, ptr);
1021} 1021}
1022 1022
1023static int __init snd_cs4231_probe(struct snd_cs4231 *chip) 1023static int __devinit snd_cs4231_probe(struct snd_cs4231 *chip)
1024{ 1024{
1025 unsigned long flags; 1025 unsigned long flags;
1026 int i; 1026 int i;
@@ -1219,7 +1219,7 @@ static struct snd_pcm_ops snd_cs4231_capture_ops = {
1219 .pointer = snd_cs4231_capture_pointer, 1219 .pointer = snd_cs4231_capture_pointer,
1220}; 1220};
1221 1221
1222static int __init snd_cs4231_pcm(struct snd_card *card) 1222static int __devinit snd_cs4231_pcm(struct snd_card *card)
1223{ 1223{
1224 struct snd_cs4231 *chip = card->private_data; 1224 struct snd_cs4231 *chip = card->private_data;
1225 struct snd_pcm *pcm; 1225 struct snd_pcm *pcm;
@@ -1248,7 +1248,7 @@ static int __init snd_cs4231_pcm(struct snd_card *card)
1248 return 0; 1248 return 0;
1249} 1249}
1250 1250
1251static int __init snd_cs4231_timer(struct snd_card *card) 1251static int __devinit snd_cs4231_timer(struct snd_card *card)
1252{ 1252{
1253 struct snd_cs4231 *chip = card->private_data; 1253 struct snd_cs4231 *chip = card->private_data;
1254 struct snd_timer *timer; 1254 struct snd_timer *timer;
@@ -1499,7 +1499,7 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol,
1499 .private_value = (left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | \ 1499 .private_value = (left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | \
1500 ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22) } 1500 ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22) }
1501 1501
1502static struct snd_kcontrol_new snd_cs4231_controls[] __initdata = { 1502static struct snd_kcontrol_new snd_cs4231_controls[] __devinitdata = {
1503CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, 1503CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT,
1504 CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), 1504 CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
1505CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, 1505CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT,
@@ -1538,7 +1538,7 @@ CS4231_SINGLE("Line Out Switch", 0, CS4231_PIN_CTRL, 6, 1, 1),
1538CS4231_SINGLE("Headphone Out Switch", 0, CS4231_PIN_CTRL, 7, 1, 1) 1538CS4231_SINGLE("Headphone Out Switch", 0, CS4231_PIN_CTRL, 7, 1, 1)
1539}; 1539};
1540 1540
1541static int __init snd_cs4231_mixer(struct snd_card *card) 1541static int __devinit snd_cs4231_mixer(struct snd_card *card)
1542{ 1542{
1543 struct snd_cs4231 *chip = card->private_data; 1543 struct snd_cs4231 *chip = card->private_data;
1544 int err, idx; 1544 int err, idx;
@@ -1559,7 +1559,7 @@ static int __init snd_cs4231_mixer(struct snd_card *card)
1559 1559
1560static int dev; 1560static int dev;
1561 1561
1562static int __init cs4231_attach_begin(struct snd_card **rcard) 1562static int __devinit cs4231_attach_begin(struct snd_card **rcard)
1563{ 1563{
1564 struct snd_card *card; 1564 struct snd_card *card;
1565 struct snd_cs4231 *chip; 1565 struct snd_cs4231 *chip;
@@ -1590,7 +1590,7 @@ static int __init cs4231_attach_begin(struct snd_card **rcard)
1590 return 0; 1590 return 0;
1591} 1591}
1592 1592
1593static int __init cs4231_attach_finish(struct snd_card *card) 1593static int __devinit cs4231_attach_finish(struct snd_card *card)
1594{ 1594{
1595 struct snd_cs4231 *chip = card->private_data; 1595 struct snd_cs4231 *chip = card->private_data;
1596 int err; 1596 int err;
@@ -1794,9 +1794,9 @@ static struct snd_device_ops snd_cs4231_sbus_dev_ops = {
1794 .dev_free = snd_cs4231_sbus_dev_free, 1794 .dev_free = snd_cs4231_sbus_dev_free,
1795}; 1795};
1796 1796
1797static int __init snd_cs4231_sbus_create(struct snd_card *card, 1797static int __devinit snd_cs4231_sbus_create(struct snd_card *card,
1798 struct of_device *op, 1798 struct of_device *op,
1799 int dev) 1799 int dev)
1800{ 1800{
1801 struct snd_cs4231 *chip = card->private_data; 1801 struct snd_cs4231 *chip = card->private_data;
1802 int err; 1802 int err;
@@ -1960,9 +1960,9 @@ static struct snd_device_ops snd_cs4231_ebus_dev_ops = {
1960 .dev_free = snd_cs4231_ebus_dev_free, 1960 .dev_free = snd_cs4231_ebus_dev_free,
1961}; 1961};
1962 1962
1963static int __init snd_cs4231_ebus_create(struct snd_card *card, 1963static int __devinit snd_cs4231_ebus_create(struct snd_card *card,
1964 struct of_device *op, 1964 struct of_device *op,
1965 int dev) 1965 int dev)
1966{ 1966{
1967 struct snd_cs4231 *chip = card->private_data; 1967 struct snd_cs4231 *chip = card->private_data;
1968 int err; 1968 int err;
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index af95ff1e126c..1d2e51b3f918 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -1975,7 +1975,8 @@ static struct snd_pcm_hardware snd_dbri_pcm_hw = {
1975 .info = SNDRV_PCM_INFO_MMAP | 1975 .info = SNDRV_PCM_INFO_MMAP |
1976 SNDRV_PCM_INFO_INTERLEAVED | 1976 SNDRV_PCM_INFO_INTERLEAVED |
1977 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1977 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1978 SNDRV_PCM_INFO_MMAP_VALID, 1978 SNDRV_PCM_INFO_MMAP_VALID |
1979 SNDRV_PCM_INFO_BATCH,
1979 .formats = SNDRV_PCM_FMTBIT_MU_LAW | 1980 .formats = SNDRV_PCM_FMTBIT_MU_LAW |
1980 SNDRV_PCM_FMTBIT_A_LAW | 1981 SNDRV_PCM_FMTBIT_A_LAW |
1981 SNDRV_PCM_FMTBIT_U8 | 1982 SNDRV_PCM_FMTBIT_U8 |
diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c
index 0a5391436add..ff0b2a8fd25b 100644
--- a/sound/synth/emux/emux_hwdep.c
+++ b/sound/synth/emux/emux_hwdep.c
@@ -24,25 +24,6 @@
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include "emux_voice.h" 25#include "emux_voice.h"
26 26
27/*
28 * open the hwdep device
29 */
30static int
31snd_emux_hwdep_open(struct snd_hwdep *hw, struct file *file)
32{
33 return 0;
34}
35
36
37/*
38 * close the device
39 */
40static int
41snd_emux_hwdep_release(struct snd_hwdep *hw, struct file *file)
42{
43 return 0;
44}
45
46 27
47#define TMP_CLIENT_ID 0x1001 28#define TMP_CLIENT_ID 0x1001
48 29
@@ -146,8 +127,6 @@ snd_emux_init_hwdep(struct snd_emux *emu)
146 emu->hwdep = hw; 127 emu->hwdep = hw;
147 strcpy(hw->name, SNDRV_EMUX_HWDEP_NAME); 128 strcpy(hw->name, SNDRV_EMUX_HWDEP_NAME);
148 hw->iface = SNDRV_HWDEP_IFACE_EMUX_WAVETABLE; 129 hw->iface = SNDRV_HWDEP_IFACE_EMUX_WAVETABLE;
149 hw->ops.open = snd_emux_hwdep_open;
150 hw->ops.release = snd_emux_hwdep_release;
151 hw->ops.ioctl = snd_emux_hwdep_ioctl; 130 hw->ops.ioctl = snd_emux_hwdep_ioctl;
152 hw->exclusive = 1; 131 hw->exclusive = 1;
153 hw->private_data = emu; 132 hw->private_data = emu;
diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c
index 5c47b6c09264..87e42206c4ef 100644
--- a/sound/synth/emux/emux_oss.c
+++ b/sound/synth/emux/emux_oss.c
@@ -132,7 +132,7 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
132 p = snd_emux_create_port(emu, tmpname, 32, 132 p = snd_emux_create_port(emu, tmpname, 32,
133 1, &callback); 133 1, &callback);
134 if (p == NULL) { 134 if (p == NULL) {
135 snd_printk("can't create port\n"); 135 snd_printk(KERN_ERR "can't create port\n");
136 snd_emux_dec_count(emu); 136 snd_emux_dec_count(emu);
137 mutex_unlock(&emu->register_mutex); 137 mutex_unlock(&emu->register_mutex);
138 return -ENOMEM; 138 return -ENOMEM;
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index 335aa2ce2574..ca5f7effb4df 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -74,15 +74,15 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index)
74 emu->client = snd_seq_create_kernel_client(card, index, 74 emu->client = snd_seq_create_kernel_client(card, index,
75 "%s WaveTable", emu->name); 75 "%s WaveTable", emu->name);
76 if (emu->client < 0) { 76 if (emu->client < 0) {
77 snd_printk("can't create client\n"); 77 snd_printk(KERN_ERR "can't create client\n");
78 return -ENODEV; 78 return -ENODEV;
79 } 79 }
80 80
81 if (emu->num_ports < 0) { 81 if (emu->num_ports < 0) {
82 snd_printk("seqports must be greater than zero\n"); 82 snd_printk(KERN_WARNING "seqports must be greater than zero\n");
83 emu->num_ports = 1; 83 emu->num_ports = 1;
84 } else if (emu->num_ports >= SNDRV_EMUX_MAX_PORTS) { 84 } else if (emu->num_ports >= SNDRV_EMUX_MAX_PORTS) {
85 snd_printk("too many ports." 85 snd_printk(KERN_WARNING "too many ports."
86 "limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS); 86 "limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS);
87 emu->num_ports = SNDRV_EMUX_MAX_PORTS; 87 emu->num_ports = SNDRV_EMUX_MAX_PORTS;
88 } 88 }
@@ -100,7 +100,7 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index)
100 p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS, 100 p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS,
101 0, &pinfo); 101 0, &pinfo);
102 if (p == NULL) { 102 if (p == NULL) {
103 snd_printk("can't create port\n"); 103 snd_printk(KERN_ERR "can't create port\n");
104 return -ENOMEM; 104 return -ENOMEM;
105 } 105 }
106 106
@@ -147,12 +147,12 @@ snd_emux_create_port(struct snd_emux *emu, char *name,
147 147
148 /* Allocate structures for this channel */ 148 /* Allocate structures for this channel */
149 if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) { 149 if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) {
150 snd_printk("no memory\n"); 150 snd_printk(KERN_ERR "no memory\n");
151 return NULL; 151 return NULL;
152 } 152 }
153 p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL); 153 p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL);
154 if (p->chset.channels == NULL) { 154 if (p->chset.channels == NULL) {
155 snd_printk("no memory\n"); 155 snd_printk(KERN_ERR "no memory\n");
156 kfree(p); 156 kfree(p);
157 return NULL; 157 return NULL;
158 } 158 }
@@ -376,12 +376,12 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card)
376 goto __error; 376 goto __error;
377 } 377 }
378 emu->vmidi[i] = rmidi; 378 emu->vmidi[i] = rmidi;
379 //snd_printk("virmidi %d ok\n", i); 379 /* snd_printk(KERN_DEBUG "virmidi %d ok\n", i); */
380 } 380 }
381 return 0; 381 return 0;
382 382
383__error: 383__error:
384 //snd_printk("error init..\n"); 384 /* snd_printk(KERN_DEBUG "error init..\n"); */
385 snd_emux_delete_virmidi(emu); 385 snd_emux_delete_virmidi(emu);
386 return -ENOMEM; 386 return -ENOMEM;
387} 387}
diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c
index 2cc6f6f79065..3e921b386fd5 100644
--- a/sound/synth/emux/emux_synth.c
+++ b/sound/synth/emux/emux_synth.c
@@ -956,7 +956,8 @@ void snd_emux_lock_voice(struct snd_emux *emu, int voice)
956 if (emu->voices[voice].state == SNDRV_EMUX_ST_OFF) 956 if (emu->voices[voice].state == SNDRV_EMUX_ST_OFF)
957 emu->voices[voice].state = SNDRV_EMUX_ST_LOCKED; 957 emu->voices[voice].state = SNDRV_EMUX_ST_LOCKED;
958 else 958 else
959 snd_printk("invalid voice for lock %d (state = %x)\n", 959 snd_printk(KERN_WARNING
960 "invalid voice for lock %d (state = %x)\n",
960 voice, emu->voices[voice].state); 961 voice, emu->voices[voice].state);
961 spin_unlock_irqrestore(&emu->voice_lock, flags); 962 spin_unlock_irqrestore(&emu->voice_lock, flags);
962} 963}
@@ -973,7 +974,8 @@ void snd_emux_unlock_voice(struct snd_emux *emu, int voice)
973 if (emu->voices[voice].state == SNDRV_EMUX_ST_LOCKED) 974 if (emu->voices[voice].state == SNDRV_EMUX_ST_LOCKED)
974 emu->voices[voice].state = SNDRV_EMUX_ST_OFF; 975 emu->voices[voice].state = SNDRV_EMUX_ST_OFF;
975 else 976 else
976 snd_printk("invalid voice for unlock %d (state = %x)\n", 977 snd_printk(KERN_WARNING
978 "invalid voice for unlock %d (state = %x)\n",
977 voice, emu->voices[voice].state); 979 voice, emu->voices[voice].state);
978 spin_unlock_irqrestore(&emu->voice_lock, flags); 980 spin_unlock_irqrestore(&emu->voice_lock, flags);
979} 981}
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 36d53bd317ed..63c8f45c0c22 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -133,7 +133,7 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
133 int rc; 133 int rc;
134 134
135 if (count < (long)sizeof(patch)) { 135 if (count < (long)sizeof(patch)) {
136 snd_printk("patch record too small %ld\n", count); 136 snd_printk(KERN_ERR "patch record too small %ld\n", count);
137 return -EINVAL; 137 return -EINVAL;
138 } 138 }
139 if (copy_from_user(&patch, data, sizeof(patch))) 139 if (copy_from_user(&patch, data, sizeof(patch)))
@@ -143,15 +143,16 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
143 data += sizeof(patch); 143 data += sizeof(patch);
144 144
145 if (patch.key != SNDRV_OSS_SOUNDFONT_PATCH) { 145 if (patch.key != SNDRV_OSS_SOUNDFONT_PATCH) {
146 snd_printk("'The wrong kind of patch' %x\n", patch.key); 146 snd_printk(KERN_ERR "The wrong kind of patch %x\n", patch.key);
147 return -EINVAL; 147 return -EINVAL;
148 } 148 }
149 if (count < patch.len) { 149 if (count < patch.len) {
150 snd_printk("Patch too short %ld, need %d\n", count, patch.len); 150 snd_printk(KERN_ERR "Patch too short %ld, need %d\n",
151 count, patch.len);
151 return -EINVAL; 152 return -EINVAL;
152 } 153 }
153 if (patch.len < 0) { 154 if (patch.len < 0) {
154 snd_printk("poor length %d\n", patch.len); 155 snd_printk(KERN_ERR "poor length %d\n", patch.len);
155 return -EINVAL; 156 return -EINVAL;
156 } 157 }
157 158
@@ -195,7 +196,8 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
195 case SNDRV_SFNT_REMOVE_INFO: 196 case SNDRV_SFNT_REMOVE_INFO:
196 /* patch must be opened */ 197 /* patch must be opened */
197 if (!sflist->currsf) { 198 if (!sflist->currsf) {
198 snd_printk("soundfont: remove_info: patch not opened\n"); 199 snd_printk(KERN_ERR "soundfont: remove_info: "
200 "patch not opened\n");
199 rc = -EINVAL; 201 rc = -EINVAL;
200 } else { 202 } else {
201 int bank, instr; 203 int bank, instr;
@@ -531,7 +533,7 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
531 return -EINVAL; 533 return -EINVAL;
532 534
533 if (count < (long)sizeof(hdr)) { 535 if (count < (long)sizeof(hdr)) {
534 printk("Soundfont error: invalid patch zone length\n"); 536 printk(KERN_ERR "Soundfont error: invalid patch zone length\n");
535 return -EINVAL; 537 return -EINVAL;
536 } 538 }
537 if (copy_from_user((char*)&hdr, data, sizeof(hdr))) 539 if (copy_from_user((char*)&hdr, data, sizeof(hdr)))
@@ -541,12 +543,14 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
541 count -= sizeof(hdr); 543 count -= sizeof(hdr);
542 544
543 if (hdr.nvoices <= 0 || hdr.nvoices >= 100) { 545 if (hdr.nvoices <= 0 || hdr.nvoices >= 100) {
544 printk("Soundfont error: Illegal voice number %d\n", hdr.nvoices); 546 printk(KERN_ERR "Soundfont error: Illegal voice number %d\n",
547 hdr.nvoices);
545 return -EINVAL; 548 return -EINVAL;
546 } 549 }
547 550
548 if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) { 551 if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) {
549 printk("Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n", 552 printk(KERN_ERR "Soundfont Error: "
553 "patch length(%ld) is smaller than nvoices(%d)\n",
550 count, hdr.nvoices); 554 count, hdr.nvoices);
551 return -EINVAL; 555 return -EINVAL;
552 } 556 }
@@ -952,7 +956,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
952 int rc; 956 int rc;
953 957
954 if (count < (long)sizeof(patch)) { 958 if (count < (long)sizeof(patch)) {
955 snd_printk("patch record too small %ld\n", count); 959 snd_printk(KERN_ERR "patch record too small %ld\n", count);
956 return -EINVAL; 960 return -EINVAL;
957 } 961 }
958 if (copy_from_user(&patch, data, sizeof(patch))) 962 if (copy_from_user(&patch, data, sizeof(patch)))
@@ -1034,7 +1038,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
1034 /* panning position; -128 - 127 => 0-127 */ 1038 /* panning position; -128 - 127 => 0-127 */
1035 zone->v.pan = (patch.panning + 128) / 2; 1039 zone->v.pan = (patch.panning + 128) / 2;
1036#if 0 1040#if 0
1037 snd_printk("gus: basefrq=%d (ofs=%d) root=%d,tune=%d, range:%d-%d\n", 1041 snd_printk(KERN_DEBUG
1042 "gus: basefrq=%d (ofs=%d) root=%d,tune=%d, range:%d-%d\n",
1038 (int)patch.base_freq, zone->v.rate_offset, 1043 (int)patch.base_freq, zone->v.rate_offset,
1039 zone->v.root, zone->v.tune, zone->v.low, zone->v.high); 1044 zone->v.root, zone->v.tune, zone->v.low, zone->v.high);
1040#endif 1045#endif
@@ -1068,7 +1073,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
1068 zone->v.parm.volrelease = 0x8000 | snd_sf_calc_parm_decay(release); 1073 zone->v.parm.volrelease = 0x8000 | snd_sf_calc_parm_decay(release);
1069 zone->v.attenuation = calc_gus_attenuation(patch.env_offset[0]); 1074 zone->v.attenuation = calc_gus_attenuation(patch.env_offset[0]);
1070#if 0 1075#if 0
1071 snd_printk("gus: atkhld=%x, dcysus=%x, volrel=%x, att=%d\n", 1076 snd_printk(KERN_DEBUG
1077 "gus: atkhld=%x, dcysus=%x, volrel=%x, att=%d\n",
1072 zone->v.parm.volatkhld, 1078 zone->v.parm.volatkhld,
1073 zone->v.parm.voldcysus, 1079 zone->v.parm.voldcysus,
1074 zone->v.parm.volrelease, 1080 zone->v.parm.volrelease,
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index 4f0eac9bff1e..523aec188ccf 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -48,7 +48,10 @@ config SND_USB_CAIAQ
48 * Native Instruments Kore Controller 48 * Native Instruments Kore Controller
49 * Native Instruments Kore Controller 2 49 * Native Instruments Kore Controller 2
50 * Native Instruments Audio Kontrol 1 50 * Native Instruments Audio Kontrol 1
51 * Native Instruments Audio 4 DJ
51 * Native Instruments Audio 8 DJ 52 * Native Instruments Audio 8 DJ
53 * Native Instruments Guitar Rig Session I/O
54 * Native Instruments Guitar Rig mobile
52 55
53 To compile this driver as a module, choose M here: the module 56 To compile this driver as a module, choose M here: the module
54 will be called snd-usb-caiaq. 57 will be called snd-usb-caiaq.
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile
index 23dadd5a11cd..388999653aaa 100644
--- a/sound/usb/caiaq/Makefile
+++ b/sound/usb/caiaq/Makefile
@@ -1,4 +1,4 @@
1snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o 1snd-usb-caiaq-y := device.o audio.o midi.o control.o
2snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o 2snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += input.o
3 3
4obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o 4obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/audio.c
index b3a603325835..b13ce767ac72 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -16,20 +16,14 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/spinlock.h>
19#include <linux/init.h> 20#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/interrupt.h>
23#include <linux/usb.h> 21#include <linux/usb.h>
24#include <linux/spinlock.h>
25#include <sound/core.h> 22#include <sound/core.h>
26#include <sound/initval.h>
27#include <sound/pcm.h> 23#include <sound/pcm.h>
28#include <sound/rawmidi.h>
29#include <linux/input.h>
30 24
31#include "caiaq-device.h" 25#include "device.h"
32#include "caiaq-audio.h" 26#include "audio.h"
33 27
34#define N_URBS 32 28#define N_URBS 32
35#define CLOCK_DRIFT_TOLERANCE 5 29#define CLOCK_DRIFT_TOLERANCE 5
@@ -114,6 +108,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
114 dev->output_panic = 0; 108 dev->output_panic = 0;
115 dev->first_packet = 1; 109 dev->first_packet = 1;
116 dev->streaming = 1; 110 dev->streaming = 1;
111 dev->warned = 0;
117 112
118 for (i = 0; i < N_URBS; i++) { 113 for (i = 0; i < N_URBS; i++) {
119 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); 114 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
@@ -200,11 +195,14 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
200 195
201 debug("%s(%p)\n", __func__, substream); 196 debug("%s(%p)\n", __func__, substream);
202 197
203 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 198 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
199 dev->period_out_count[index] = BYTES_PER_SAMPLE + 1;
204 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; 200 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1;
205 else 201 } else {
202 dev->period_in_count[index] = BYTES_PER_SAMPLE;
206 dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE; 203 dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE;
207 204 }
205
208 if (dev->streaming) 206 if (dev->streaming)
209 return 0; 207 return 0;
210 208
@@ -305,8 +303,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev,
305 if (!sub) 303 if (!sub)
306 continue; 304 continue;
307 305
308 pb = frames_to_bytes(sub->runtime, 306 pb = snd_pcm_lib_period_bytes(sub);
309 sub->runtime->period_size);
310 cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 307 cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
311 &dev->period_out_count[stream] : 308 &dev->period_out_count[stream] :
312 &dev->period_in_count[stream]; 309 &dev->period_in_count[stream];
@@ -376,6 +373,9 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
376 373
377 for (stream = 0; stream < dev->n_streams; stream++, i++) { 374 for (stream = 0; stream < dev->n_streams; stream++, i++) {
378 sub = dev->sub_capture[stream]; 375 sub = dev->sub_capture[stream];
376 if (dev->input_panic)
377 usb_buf[i] = 0;
378
379 if (sub) { 379 if (sub) {
380 struct snd_pcm_runtime *rt = sub->runtime; 380 struct snd_pcm_runtime *rt = sub->runtime;
381 char *audio_buf = rt->dma_area; 381 char *audio_buf = rt->dma_area;
@@ -397,6 +397,9 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
397 if (!dev->streaming) 397 if (!dev->streaming)
398 return; 398 return;
399 399
400 if (iso->actual_length < dev->bpp)
401 return;
402
400 switch (dev->spec.data_alignment) { 403 switch (dev->spec.data_alignment) {
401 case 0: 404 case 0:
402 read_in_urb_mode0(dev, urb, iso); 405 read_in_urb_mode0(dev, urb, iso);
@@ -406,10 +409,11 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
406 break; 409 break;
407 } 410 }
408 411
409 if (dev->input_panic || dev->output_panic) { 412 if ((dev->input_panic || dev->output_panic) && !dev->warned) {
410 debug("streaming error detected %s %s\n", 413 debug("streaming error detected %s %s\n",
411 dev->input_panic ? "(input)" : "", 414 dev->input_panic ? "(input)" : "",
412 dev->output_panic ? "(output)" : ""); 415 dev->output_panic ? "(output)" : "");
416 dev->warned = 1;
413 } 417 }
414} 418}
415 419
@@ -638,9 +642,10 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
638 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 642 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
639 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 643 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
640 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): 644 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO):
641 dev->samplerates |= SNDRV_PCM_RATE_88200; 645 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE):
642 dev->samplerates |= SNDRV_PCM_RATE_192000; 646 dev->samplerates |= SNDRV_PCM_RATE_192000;
643 break; 647 /* fall thru */
648 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
644 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 649 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
645 dev->samplerates |= SNDRV_PCM_RATE_88200; 650 dev->samplerates |= SNDRV_PCM_RATE_88200;
646 break; 651 break;
diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/audio.h
index 8ab1f8d9529e..8ab1f8d9529e 100644
--- a/sound/usb/caiaq/caiaq-audio.h
+++ b/sound/usb/caiaq/audio.h
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/control.c
index ccd763dd7167..537102ba6b9d 100644
--- a/sound/usb/caiaq/caiaq-control.c
+++ b/sound/usb/caiaq/control.c
@@ -18,17 +18,13 @@
18 */ 18 */
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/usb.h> 21#include <linux/usb.h>
22#include <sound/control.h>
23#include <sound/core.h> 23#include <sound/core.h>
24#include <sound/initval.h>
25#include <sound/pcm.h> 24#include <sound/pcm.h>
26#include <sound/rawmidi.h>
27#include <sound/control.h>
28#include <linux/input.h>
29 25
30#include "caiaq-device.h" 26#include "device.h"
31#include "caiaq-control.h" 27#include "control.h"
32 28
33#define CNT_INTVAL 0x10000 29#define CNT_INTVAL 0x10000
34 30
@@ -39,12 +35,12 @@ static int control_info(struct snd_kcontrol *kcontrol,
39 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 35 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
40 int pos = kcontrol->private_value; 36 int pos = kcontrol->private_value;
41 int is_intval = pos & CNT_INTVAL; 37 int is_intval = pos & CNT_INTVAL;
38 unsigned int id = dev->chip.usb_id;
42 39
43 uinfo->count = 1; 40 uinfo->count = 1;
44 pos &= ~CNT_INTVAL; 41 pos &= ~CNT_INTVAL;
45 42
46 if (dev->chip.usb_id == 43 if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)
47 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)
48 && (pos == 0)) { 44 && (pos == 0)) {
49 /* current input mode of A8DJ */ 45 /* current input mode of A8DJ */
50 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 46 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -53,6 +49,15 @@ static int control_info(struct snd_kcontrol *kcontrol,
53 return 0; 49 return 0;
54 } 50 }
55 51
52 if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)
53 && (pos == 0)) {
54 /* current input mode of A4DJ */
55 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
56 uinfo->value.integer.min = 0;
57 uinfo->value.integer.max = 1;
58 return 0;
59 }
60
56 if (is_intval) { 61 if (is_intval) {
57 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 62 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
58 uinfo->value.integer.min = 0; 63 uinfo->value.integer.min = 0;
@@ -73,6 +78,14 @@ static int control_get(struct snd_kcontrol *kcontrol,
73 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 78 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
74 int pos = kcontrol->private_value; 79 int pos = kcontrol->private_value;
75 80
81 if (dev->chip.usb_id ==
82 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
83 /* A4DJ has only one control */
84 /* do not expose hardware input mode 0 */
85 ucontrol->value.integer.value[0] = dev->control_state[0] - 1;
86 return 0;
87 }
88
76 if (pos & CNT_INTVAL) 89 if (pos & CNT_INTVAL)
77 ucontrol->value.integer.value[0] 90 ucontrol->value.integer.value[0]
78 = dev->control_state[pos & ~CNT_INTVAL]; 91 = dev->control_state[pos & ~CNT_INTVAL];
@@ -90,10 +103,20 @@ static int control_put(struct snd_kcontrol *kcontrol,
90 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 103 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
91 int pos = kcontrol->private_value; 104 int pos = kcontrol->private_value;
92 105
106 if (dev->chip.usb_id ==
107 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
108 /* A4DJ has only one control */
109 /* do not expose hardware input mode 0 */
110 dev->control_state[0] = ucontrol->value.integer.value[0] + 1;
111 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
112 dev->control_state, sizeof(dev->control_state));
113 return 1;
114 }
115
93 if (pos & CNT_INTVAL) { 116 if (pos & CNT_INTVAL) {
94 dev->control_state[pos & ~CNT_INTVAL] 117 dev->control_state[pos & ~CNT_INTVAL]
95 = ucontrol->value.integer.value[0]; 118 = ucontrol->value.integer.value[0];
96 snd_usb_caiaq_send_command(dev, EP1_CMD_DIMM_LEDS, 119 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
97 dev->control_state, sizeof(dev->control_state)); 120 dev->control_state, sizeof(dev->control_state));
98 } else { 121 } else {
99 if (ucontrol->value.integer.value[0]) 122 if (ucontrol->value.integer.value[0])
@@ -243,10 +266,13 @@ static struct caiaq_controller a8dj_controller[] = {
243 { "GND lift for TC Vinyl mode", 24 + 0 }, 266 { "GND lift for TC Vinyl mode", 24 + 0 },
244 { "GND lift for TC CD/Line mode", 24 + 1 }, 267 { "GND lift for TC CD/Line mode", 24 + 1 },
245 { "GND lift for phono mode", 24 + 2 }, 268 { "GND lift for phono mode", 24 + 2 },
246 { "GND lift for TC Vinyl mode", 24 + 3 },
247 { "Software lock", 40 } 269 { "Software lock", 40 }
248}; 270};
249 271
272static struct caiaq_controller a4dj_controller[] = {
273 { "Current input mode", 0 | CNT_INTVAL }
274};
275
250static int __devinit add_controls(struct caiaq_controller *c, int num, 276static int __devinit add_controls(struct caiaq_controller *c, int num,
251 struct snd_usb_caiaqdev *dev) 277 struct snd_usb_caiaqdev *dev)
252{ 278{
@@ -295,6 +321,10 @@ int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
295 ret = add_controls(a8dj_controller, 321 ret = add_controls(a8dj_controller,
296 ARRAY_SIZE(a8dj_controller), dev); 322 ARRAY_SIZE(a8dj_controller), dev);
297 break; 323 break;
324 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
325 ret = add_controls(a4dj_controller,
326 ARRAY_SIZE(a4dj_controller), dev);
327 break;
298 } 328 }
299 329
300 return ret; 330 return ret;
diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/control.h
index 2e7ab1aa4fb3..2e7ab1aa4fb3 100644
--- a/sound/usb/caiaq/caiaq-control.h
+++ b/sound/usb/caiaq/control.h
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/device.c
index 09aed2363cc9..515de1cd2a3e 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/device.c
@@ -19,38 +19,33 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/ 20*/
21 21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
25#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/input.h>
28#include <linux/spinlock.h>
29#include <sound/core.h>
30#include <sound/initval.h> 27#include <sound/initval.h>
28#include <sound/core.h>
31#include <sound/pcm.h> 29#include <sound/pcm.h>
32#include <sound/rawmidi.h>
33#include <sound/control.h>
34
35#include "caiaq-device.h"
36#include "caiaq-audio.h"
37#include "caiaq-midi.h"
38#include "caiaq-control.h"
39 30
40#ifdef CONFIG_SND_USB_CAIAQ_INPUT 31#include "device.h"
41#include "caiaq-input.h" 32#include "audio.h"
42#endif 33#include "midi.h"
34#include "control.h"
35#include "input.h"
43 36
44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.10"); 38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14");
46MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
48 "{Native Instruments, RigKontrol3}," 41 "{Native Instruments, RigKontrol3},"
49 "{Native Instruments, Kore Controller}," 42 "{Native Instruments, Kore Controller},"
50 "{Native Instruments, Kore Controller 2}," 43 "{Native Instruments, Kore Controller 2},"
51 "{Native Instruments, Audio Kontrol 1}," 44 "{Native Instruments, Audio Kontrol 1},"
45 "{Native Instruments, Audio 4 DJ},"
52 "{Native Instruments, Audio 8 DJ}," 46 "{Native Instruments, Audio 8 DJ},"
53 "{Native Instruments, Session I/O}}"); 47 "{Native Instruments, Session I/O},"
48 "{Native Instruments, GuitarRig mobile}");
54 49
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
56static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 51static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
@@ -116,6 +111,16 @@ static struct usb_device_id snd_usb_id_table[] = {
116 .idVendor = USB_VID_NATIVEINSTRUMENTS, 111 .idVendor = USB_VID_NATIVEINSTRUMENTS,
117 .idProduct = USB_PID_SESSIONIO 112 .idProduct = USB_PID_SESSIONIO
118 }, 113 },
114 {
115 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
116 .idVendor = USB_VID_NATIVEINSTRUMENTS,
117 .idProduct = USB_PID_GUITARRIGMOBILE
118 },
119 {
120 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
121 .idVendor = USB_VID_NATIVEINSTRUMENTS,
122 .idProduct = USB_PID_AUDIO4DJ
123 },
119 { /* terminator */ } 124 { /* terminator */ }
120}; 125};
121 126
@@ -239,6 +244,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
239 244
240 if (dev->audio_parm_answer != 1) 245 if (dev->audio_parm_answer != 1)
241 debug("unable to set the device's audio params\n"); 246 debug("unable to set the device's audio params\n");
247 else
248 dev->bpp = bpp;
242 249
243 return dev->audio_parm_answer == 1 ? 0 : -EINVAL; 250 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
244} 251}
@@ -300,6 +307,12 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
300 } 307 }
301 308
302 break; 309 break;
310 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
311 /* Audio 4 DJ - default input mode to phono */
312 dev->control_state[0] = 2;
313 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
314 dev->control_state, 1);
315 break;
303 } 316 }
304 317
305 if (dev->spec.num_analog_audio_out + 318 if (dev->spec.num_analog_audio_out +
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/device.h
index ab56e738c5fc..4cce1ad7493d 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/device.h
@@ -10,8 +10,10 @@
10#define USB_PID_KORECONTROLLER 0x4711 10#define USB_PID_KORECONTROLLER 0x4711
11#define USB_PID_KORECONTROLLER2 0x4712 11#define USB_PID_KORECONTROLLER2 0x4712
12#define USB_PID_AK1 0x0815 12#define USB_PID_AK1 0x0815
13#define USB_PID_AUDIO4DJ 0x0839
13#define USB_PID_AUDIO8DJ 0x1978 14#define USB_PID_AUDIO8DJ 0x1978
14#define USB_PID_SESSIONIO 0x1915 15#define USB_PID_SESSIONIO 0x1915
16#define USB_PID_GUITARRIGMOBILE 0x0d8d
15 17
16#define EP1_BUFSIZE 64 18#define EP1_BUFSIZE 64
17#define CAIAQ_USB_STR_LEN 0xff 19#define CAIAQ_USB_STR_LEN 0xff
@@ -87,9 +89,9 @@ struct snd_usb_caiaqdev {
87 int audio_out_buf_pos[MAX_STREAMS]; 89 int audio_out_buf_pos[MAX_STREAMS];
88 int period_in_count[MAX_STREAMS]; 90 int period_in_count[MAX_STREAMS];
89 int period_out_count[MAX_STREAMS]; 91 int period_out_count[MAX_STREAMS];
90 int input_panic, output_panic; 92 int input_panic, output_panic, warned;
91 char *audio_in_buf, *audio_out_buf; 93 char *audio_in_buf, *audio_out_buf;
92 unsigned int samplerates; 94 unsigned int samplerates, bpp;
93 95
94 struct snd_pcm_substream *sub_playback[MAX_STREAMS]; 96 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
95 struct snd_pcm_substream *sub_capture[MAX_STREAMS]; 97 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/input.c
index f743847a5e5a..a48d309bd94c 100644
--- a/sound/usb/caiaq/caiaq-input.c
+++ b/sound/usb/caiaq/input.c
@@ -17,17 +17,12 @@
17*/ 17*/
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/input.h>
23#include <linux/usb.h> 20#include <linux/usb.h>
24#include <linux/usb/input.h> 21#include <linux/usb/input.h>
25#include <linux/spinlock.h>
26#include <sound/core.h>
27#include <sound/rawmidi.h>
28#include <sound/pcm.h> 22#include <sound/pcm.h>
29#include "caiaq-device.h" 23
30#include "caiaq-input.h" 24#include "device.h"
25#include "input.h"
31 26
32static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; 27static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A };
33static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, 28static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4,
diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/input.h
index ced535577864..ced535577864 100644
--- a/sound/usb/caiaq/caiaq-input.h
+++ b/sound/usb/caiaq/input.h
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/midi.c
index f19fd360c936..8fa8cd88d763 100644
--- a/sound/usb/caiaq/caiaq-midi.c
+++ b/sound/usb/caiaq/midi.c
@@ -16,20 +16,13 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/interrupt.h>
23#include <linux/usb.h> 19#include <linux/usb.h>
24#include <linux/input.h>
25#include <linux/spinlock.h>
26#include <sound/core.h>
27#include <sound/rawmidi.h> 20#include <sound/rawmidi.h>
21#include <sound/core.h>
28#include <sound/pcm.h> 22#include <sound/pcm.h>
29 23
30#include "caiaq-device.h" 24#include "device.h"
31#include "caiaq-midi.h" 25#include "midi.h"
32
33 26
34static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) 27static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream)
35{ 28{
diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/midi.h
index 9d16db027fc3..9d16db027fc3 100644
--- a/sound/usb/caiaq/caiaq-midi.h
+++ b/sound/usb/caiaq/midi.h
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index eec32e1a3020..823296d7d578 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(ignore_ctl_error,
107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ 107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
108#define MAX_URBS 8 108#define MAX_URBS 8
109#define SYNC_URBS 4 /* always four urbs for sync */ 109#define SYNC_URBS 4 /* always four urbs for sync */
110#define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ 110#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */
111 111
112struct audioformat { 112struct audioformat {
113 struct list_head list; 113 struct list_head list;
@@ -121,6 +121,7 @@ struct audioformat {
121 unsigned char attributes; /* corresponding attributes of cs endpoint */ 121 unsigned char attributes; /* corresponding attributes of cs endpoint */
122 unsigned char endpoint; /* endpoint */ 122 unsigned char endpoint; /* endpoint */
123 unsigned char ep_attr; /* endpoint attributes */ 123 unsigned char ep_attr; /* endpoint attributes */
124 unsigned char datainterval; /* log_2 of data packet interval */
124 unsigned int maxpacksize; /* max. packet size */ 125 unsigned int maxpacksize; /* max. packet size */
125 unsigned int rates; /* rate bitmasks */ 126 unsigned int rates; /* rate bitmasks */
126 unsigned int rate_min, rate_max; /* min/max rates */ 127 unsigned int rate_min, rate_max; /* min/max rates */
@@ -170,7 +171,6 @@ struct snd_usb_substream {
170 unsigned int curframesize; /* current packet size in frames (for capture) */ 171 unsigned int curframesize; /* current packet size in frames (for capture) */
171 unsigned int fill_max: 1; /* fill max packet size always */ 172 unsigned int fill_max: 1; /* fill max packet size always */
172 unsigned int fmt_type; /* USB audio format type (1-3) */ 173 unsigned int fmt_type; /* USB audio format type (1-3) */
173 unsigned int packs_per_ms; /* packets per millisecond (for playback) */
174 174
175 unsigned int running: 1; /* running status */ 175 unsigned int running: 1; /* running status */
176 176
@@ -525,7 +525,7 @@ static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
525/* 525/*
526 * Prepare urb for streaming before playback starts or when paused. 526 * Prepare urb for streaming before playback starts or when paused.
527 * 527 *
528 * We don't have any data, so we send a frame of silence. 528 * We don't have any data, so we send silence.
529 */ 529 */
530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, 530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
531 struct snd_pcm_runtime *runtime, 531 struct snd_pcm_runtime *runtime,
@@ -537,13 +537,13 @@ static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
537 537
538 offs = 0; 538 offs = 0;
539 urb->dev = ctx->subs->dev; 539 urb->dev = ctx->subs->dev;
540 urb->number_of_packets = subs->packs_per_ms; 540 for (i = 0; i < ctx->packets; ++i) {
541 for (i = 0; i < subs->packs_per_ms; ++i) {
542 counts = snd_usb_audio_next_packet_size(subs); 541 counts = snd_usb_audio_next_packet_size(subs);
543 urb->iso_frame_desc[i].offset = offs * stride; 542 urb->iso_frame_desc[i].offset = offs * stride;
544 urb->iso_frame_desc[i].length = counts * stride; 543 urb->iso_frame_desc[i].length = counts * stride;
545 offs += counts; 544 offs += counts;
546 } 545 }
546 urb->number_of_packets = ctx->packets;
547 urb->transfer_buffer_length = offs * stride; 547 urb->transfer_buffer_length = offs * stride;
548 memset(urb->transfer_buffer, 548 memset(urb->transfer_buffer,
549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0, 549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0,
@@ -607,9 +607,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
607 break; 607 break;
608 } 608 }
609 } 609 }
610 /* finish at the frame boundary at/after the period boundary */ 610 if (period_elapsed) /* finish at the period boundary */
611 if (period_elapsed &&
612 (i & (subs->packs_per_ms - 1)) == subs->packs_per_ms - 1)
613 break; 611 break;
614 } 612 }
615 if (subs->hwptr_done + offs > runtime->buffer_size) { 613 if (subs->hwptr_done + offs > runtime->buffer_size) {
@@ -1034,9 +1032,9 @@ static void release_substream_urbs(struct snd_usb_substream *subs, int force)
1034static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, 1032static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes,
1035 unsigned int rate, unsigned int frame_bits) 1033 unsigned int rate, unsigned int frame_bits)
1036{ 1034{
1037 unsigned int maxsize, n, i; 1035 unsigned int maxsize, i;
1038 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK; 1036 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
1039 unsigned int npacks[MAX_URBS], urb_packs, total_packs, packs_per_ms; 1037 unsigned int urb_packs, total_packs, packs_per_ms;
1040 1038
1041 /* calculate the frequency in 16.16 format */ 1039 /* calculate the frequency in 16.16 format */
1042 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 1040 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
@@ -1067,11 +1065,9 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1067 packs_per_ms = 8 >> subs->datainterval; 1065 packs_per_ms = 8 >> subs->datainterval;
1068 else 1066 else
1069 packs_per_ms = 1; 1067 packs_per_ms = 1;
1070 subs->packs_per_ms = packs_per_ms;
1071 1068
1072 if (is_playback) { 1069 if (is_playback) {
1073 urb_packs = nrpacks; 1070 urb_packs = max(nrpacks, 1);
1074 urb_packs = max(urb_packs, (unsigned int)MIN_PACKS_URB);
1075 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS); 1071 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS);
1076 } else 1072 } else
1077 urb_packs = 1; 1073 urb_packs = 1;
@@ -1079,7 +1075,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1079 1075
1080 /* decide how many packets to be used */ 1076 /* decide how many packets to be used */
1081 if (is_playback) { 1077 if (is_playback) {
1082 unsigned int minsize; 1078 unsigned int minsize, maxpacks;
1083 /* determine how small a packet can be */ 1079 /* determine how small a packet can be */
1084 minsize = (subs->freqn >> (16 - subs->datainterval)) 1080 minsize = (subs->freqn >> (16 - subs->datainterval))
1085 * (frame_bits >> 3); 1081 * (frame_bits >> 3);
@@ -1088,13 +1084,17 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1088 minsize -= minsize >> 3; 1084 minsize -= minsize >> 3;
1089 minsize = max(minsize, 1u); 1085 minsize = max(minsize, 1u);
1090 total_packs = (period_bytes + minsize - 1) / minsize; 1086 total_packs = (period_bytes + minsize - 1) / minsize;
1091 /* round up to multiple of packs_per_ms */
1092 total_packs = (total_packs + packs_per_ms - 1)
1093 & ~(packs_per_ms - 1);
1094 /* we need at least two URBs for queueing */ 1087 /* we need at least two URBs for queueing */
1095 if (total_packs < 2 * MIN_PACKS_URB * packs_per_ms) 1088 if (total_packs < 2) {
1096 total_packs = 2 * MIN_PACKS_URB * packs_per_ms; 1089 total_packs = 2;
1090 } else {
1091 /* and we don't want too long a queue either */
1092 maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2);
1093 total_packs = min(total_packs, maxpacks);
1094 }
1097 } else { 1095 } else {
1096 while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
1097 urb_packs >>= 1;
1098 total_packs = MAX_URBS * urb_packs; 1098 total_packs = MAX_URBS * urb_packs;
1099 } 1099 }
1100 subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; 1100 subs->nurbs = (total_packs + urb_packs - 1) / urb_packs;
@@ -1102,31 +1102,11 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1102 /* too much... */ 1102 /* too much... */
1103 subs->nurbs = MAX_URBS; 1103 subs->nurbs = MAX_URBS;
1104 total_packs = MAX_URBS * urb_packs; 1104 total_packs = MAX_URBS * urb_packs;
1105 } 1105 } else if (subs->nurbs < 2) {
1106 n = total_packs;
1107 for (i = 0; i < subs->nurbs; i++) {
1108 npacks[i] = n > urb_packs ? urb_packs : n;
1109 n -= urb_packs;
1110 }
1111 if (subs->nurbs <= 1) {
1112 /* too little - we need at least two packets 1106 /* too little - we need at least two packets
1113 * to ensure contiguous playback/capture 1107 * to ensure contiguous playback/capture
1114 */ 1108 */
1115 subs->nurbs = 2; 1109 subs->nurbs = 2;
1116 npacks[0] = (total_packs + 1) / 2;
1117 npacks[1] = total_packs - npacks[0];
1118 } else if (npacks[subs->nurbs-1] < MIN_PACKS_URB * packs_per_ms) {
1119 /* the last packet is too small.. */
1120 if (subs->nurbs > 2) {
1121 /* merge to the first one */
1122 npacks[0] += npacks[subs->nurbs - 1];
1123 subs->nurbs--;
1124 } else {
1125 /* divide to two */
1126 subs->nurbs = 2;
1127 npacks[0] = (total_packs + 1) / 2;
1128 npacks[1] = total_packs - npacks[0];
1129 }
1130 } 1110 }
1131 1111
1132 /* allocate and initialize data urbs */ 1112 /* allocate and initialize data urbs */
@@ -1134,7 +1114,8 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1134 struct snd_urb_ctx *u = &subs->dataurb[i]; 1114 struct snd_urb_ctx *u = &subs->dataurb[i];
1135 u->index = i; 1115 u->index = i;
1136 u->subs = subs; 1116 u->subs = subs;
1137 u->packets = npacks[i]; 1117 u->packets = (i + 1) * total_packs / subs->nurbs
1118 - i * total_packs / subs->nurbs;
1138 u->buffer_size = maxsize * u->packets; 1119 u->buffer_size = maxsize * u->packets;
1139 if (subs->fmt_type == USB_FORMAT_TYPE_II) 1120 if (subs->fmt_type == USB_FORMAT_TYPE_II)
1140 u->packets++; /* for transfer delimiter */ 1121 u->packets++; /* for transfer delimiter */
@@ -1292,14 +1273,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
1292 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1273 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
1293 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1274 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
1294 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1275 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1295 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n", 1276 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
1296 dev->devnum, iface, fmt->altsetting, rate, ep); 1277 dev->devnum, iface, fmt->altsetting, rate, ep);
1297 return err; 1278 return err;
1298 } 1279 }
1299 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, 1280 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
1300 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, 1281 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
1301 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1282 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1302 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n", 1283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
1303 dev->devnum, iface, fmt->altsetting, ep); 1284 dev->devnum, iface, fmt->altsetting, ep);
1304 return 0; /* some devices don't support reading */ 1285 return 0; /* some devices don't support reading */
1305 } 1286 }
@@ -1365,12 +1346,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1365 subs->datapipe = usb_sndisocpipe(dev, ep); 1346 subs->datapipe = usb_sndisocpipe(dev, ep);
1366 else 1347 else
1367 subs->datapipe = usb_rcvisocpipe(dev, ep); 1348 subs->datapipe = usb_rcvisocpipe(dev, ep);
1368 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH && 1349 subs->datainterval = fmt->datainterval;
1369 get_endpoint(alts, 0)->bInterval >= 1 &&
1370 get_endpoint(alts, 0)->bInterval <= 4)
1371 subs->datainterval = get_endpoint(alts, 0)->bInterval - 1;
1372 else
1373 subs->datainterval = 0;
1374 subs->syncpipe = subs->syncinterval = 0; 1350 subs->syncpipe = subs->syncinterval = 0;
1375 subs->maxpacksize = fmt->maxpacksize; 1351 subs->maxpacksize = fmt->maxpacksize;
1376 subs->fill_max = 0; 1352 subs->fill_max = 0;
@@ -1431,9 +1407,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1431 subs->cur_audiofmt = fmt; 1407 subs->cur_audiofmt = fmt;
1432 1408
1433#if 0 1409#if 0
1434 printk("setting done: format = %d, rate = %d..%d, channels = %d\n", 1410 printk(KERN_DEBUG
1411 "setting done: format = %d, rate = %d..%d, channels = %d\n",
1435 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels); 1412 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels);
1436 printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n", 1413 printk(KERN_DEBUG
1414 " datapipe = 0x%0x, syncpipe = 0x%0x\n",
1437 subs->datapipe, subs->syncpipe); 1415 subs->datapipe, subs->syncpipe);
1438#endif 1416#endif
1439 1417
@@ -1468,7 +1446,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
1468 channels = params_channels(hw_params); 1446 channels = params_channels(hw_params);
1469 fmt = find_format(subs, format, rate, channels); 1447 fmt = find_format(subs, format, rate, channels);
1470 if (!fmt) { 1448 if (!fmt) {
1471 snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n", 1449 snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
1472 format, rate, channels); 1450 format, rate, channels);
1473 return -EINVAL; 1451 return -EINVAL;
1474 } 1452 }
@@ -1581,11 +1559,15 @@ static struct snd_pcm_hardware snd_usb_hardware =
1581#define hwc_debug(fmt, args...) /**/ 1559#define hwc_debug(fmt, args...) /**/
1582#endif 1560#endif
1583 1561
1584static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audioformat *fp) 1562static int hw_check_valid_format(struct snd_usb_substream *subs,
1563 struct snd_pcm_hw_params *params,
1564 struct audioformat *fp)
1585{ 1565{
1586 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 1566 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
1587 struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 1567 struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
1588 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1568 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
1569 struct snd_interval *pt = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME);
1570 unsigned int ptime;
1589 1571
1590 /* check the format */ 1572 /* check the format */
1591 if (!snd_mask_test(fmts, fp->format)) { 1573 if (!snd_mask_test(fmts, fp->format)) {
@@ -1606,6 +1588,14 @@ static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audiof
1606 hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); 1588 hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min);
1607 return 0; 1589 return 0;
1608 } 1590 }
1591 /* check whether the period time is >= the data packet interval */
1592 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) {
1593 ptime = 125 * (1 << fp->datainterval);
1594 if (ptime > pt->max || (ptime == pt->max && pt->openmax)) {
1595 hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max);
1596 return 0;
1597 }
1598 }
1609 return 1; 1599 return 1;
1610} 1600}
1611 1601
@@ -1624,7 +1614,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
1624 list_for_each(p, &subs->fmt_list) { 1614 list_for_each(p, &subs->fmt_list) {
1625 struct audioformat *fp; 1615 struct audioformat *fp;
1626 fp = list_entry(p, struct audioformat, list); 1616 fp = list_entry(p, struct audioformat, list);
1627 if (!hw_check_valid_format(params, fp)) 1617 if (!hw_check_valid_format(subs, params, fp))
1628 continue; 1618 continue;
1629 if (changed++) { 1619 if (changed++) {
1630 if (rmin > fp->rate_min) 1620 if (rmin > fp->rate_min)
@@ -1678,7 +1668,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
1678 list_for_each(p, &subs->fmt_list) { 1668 list_for_each(p, &subs->fmt_list) {
1679 struct audioformat *fp; 1669 struct audioformat *fp;
1680 fp = list_entry(p, struct audioformat, list); 1670 fp = list_entry(p, struct audioformat, list);
1681 if (!hw_check_valid_format(params, fp)) 1671 if (!hw_check_valid_format(subs, params, fp))
1682 continue; 1672 continue;
1683 if (changed++) { 1673 if (changed++) {
1684 if (rmin > fp->channels) 1674 if (rmin > fp->channels)
@@ -1731,7 +1721,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1731 list_for_each(p, &subs->fmt_list) { 1721 list_for_each(p, &subs->fmt_list) {
1732 struct audioformat *fp; 1722 struct audioformat *fp;
1733 fp = list_entry(p, struct audioformat, list); 1723 fp = list_entry(p, struct audioformat, list);
1734 if (!hw_check_valid_format(params, fp)) 1724 if (!hw_check_valid_format(subs, params, fp))
1735 continue; 1725 continue;
1736 fbits |= (1ULL << fp->format); 1726 fbits |= (1ULL << fp->format);
1737 } 1727 }
@@ -1749,95 +1739,42 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1749 return changed; 1739 return changed;
1750} 1740}
1751 1741
1752#define MAX_MASK 64 1742static int hw_rule_period_time(struct snd_pcm_hw_params *params,
1753 1743 struct snd_pcm_hw_rule *rule)
1754/*
1755 * check whether the registered audio formats need special hw-constraints
1756 */
1757static int check_hw_params_convention(struct snd_usb_substream *subs)
1758{ 1744{
1759 int i; 1745 struct snd_usb_substream *subs = rule->private;
1760 u32 *channels; 1746 struct audioformat *fp;
1761 u32 *rates; 1747 struct snd_interval *it;
1762 u32 cmaster, rmaster; 1748 unsigned char min_datainterval;
1763 u32 rate_min = 0, rate_max = 0; 1749 unsigned int pmin;
1764 struct list_head *p; 1750 int changed;
1765 int err = 1;
1766
1767 channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1768 rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1769 if (!channels || !rates) {
1770 err = -ENOMEM;
1771 goto __out;
1772 }
1773 1751
1774 list_for_each(p, &subs->fmt_list) { 1752 it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME);
1775 struct audioformat *f; 1753 hwc_debug("hw_rule_period_time: (%u,%u)\n", it->min, it->max);
1776 f = list_entry(p, struct audioformat, list); 1754 min_datainterval = 0xff;
1777 /* unconventional channels? */ 1755 list_for_each_entry(fp, &subs->fmt_list, list) {
1778 if (f->channels > 32) 1756 if (!hw_check_valid_format(subs, params, fp))
1779 goto __out;
1780 /* continuous rate min/max matches? */
1781 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
1782 if (rate_min && f->rate_min != rate_min)
1783 goto __out;
1784 if (rate_max && f->rate_max != rate_max)
1785 goto __out;
1786 rate_min = f->rate_min;
1787 rate_max = f->rate_max;
1788 }
1789 /* combination of continuous rates and fixed rates? */
1790 if (rates[f->format] & SNDRV_PCM_RATE_CONTINUOUS) {
1791 if (f->rates != rates[f->format])
1792 goto __out;
1793 }
1794 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
1795 if (rates[f->format] && rates[f->format] != f->rates)
1796 goto __out;
1797 }
1798 channels[f->format] |= (1 << f->channels);
1799 rates[f->format] |= f->rates;
1800 /* needs knot? */
1801 if (f->rates & SNDRV_PCM_RATE_KNOT)
1802 goto __out;
1803 }
1804 /* check whether channels and rates match for all formats */
1805 cmaster = rmaster = 0;
1806 for (i = 0; i < MAX_MASK; i++) {
1807 if (cmaster != channels[i] && cmaster && channels[i])
1808 goto __out;
1809 if (rmaster != rates[i] && rmaster && rates[i])
1810 goto __out;
1811 if (channels[i])
1812 cmaster = channels[i];
1813 if (rates[i])
1814 rmaster = rates[i];
1815 }
1816 /* check whether channels match for all distinct rates */
1817 memset(channels, 0, MAX_MASK * sizeof(u32));
1818 list_for_each(p, &subs->fmt_list) {
1819 struct audioformat *f;
1820 f = list_entry(p, struct audioformat, list);
1821 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS)
1822 continue; 1757 continue;
1823 for (i = 0; i < 32; i++) { 1758 min_datainterval = min(min_datainterval, fp->datainterval);
1824 if (f->rates & (1 << i)) 1759 }
1825 channels[i] |= (1 << f->channels); 1760 if (min_datainterval == 0xff) {
1826 } 1761 hwc_debug(" --> get emtpy\n");
1762 it->empty = 1;
1763 return -EINVAL;
1827 } 1764 }
1828 cmaster = 0; 1765 pmin = 125 * (1 << min_datainterval);
1829 for (i = 0; i < 32; i++) { 1766 changed = 0;
1830 if (cmaster != channels[i] && cmaster && channels[i]) 1767 if (it->min < pmin) {
1831 goto __out; 1768 it->min = pmin;
1832 if (channels[i]) 1769 it->openmin = 0;
1833 cmaster = channels[i]; 1770 changed = 1;
1834 } 1771 }
1835 err = 0; 1772 if (snd_interval_checkempty(it)) {
1836 1773 it->empty = 1;
1837 __out: 1774 return -EINVAL;
1838 kfree(channels); 1775 }
1839 kfree(rates); 1776 hwc_debug(" --> (%u,%u) (changed = %d)\n", it->min, it->max, changed);
1840 return err; 1777 return changed;
1841} 1778}
1842 1779
1843/* 1780/*
@@ -1885,6 +1822,8 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
1885static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) 1822static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs)
1886{ 1823{
1887 struct list_head *p; 1824 struct list_head *p;
1825 unsigned int pt, ptmin;
1826 int param_period_time_if_needed;
1888 int err; 1827 int err;
1889 1828
1890 runtime->hw.formats = subs->formats; 1829 runtime->hw.formats = subs->formats;
@@ -1894,6 +1833,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1894 runtime->hw.channels_min = 256; 1833 runtime->hw.channels_min = 256;
1895 runtime->hw.channels_max = 0; 1834 runtime->hw.channels_max = 0;
1896 runtime->hw.rates = 0; 1835 runtime->hw.rates = 0;
1836 ptmin = UINT_MAX;
1897 /* check min/max rates and channels */ 1837 /* check min/max rates and channels */
1898 list_for_each(p, &subs->fmt_list) { 1838 list_for_each(p, &subs->fmt_list) {
1899 struct audioformat *fp; 1839 struct audioformat *fp;
@@ -1912,42 +1852,54 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1912 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = 1852 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max =
1913 fp->frame_size; 1853 fp->frame_size;
1914 } 1854 }
1855 pt = 125 * (1 << fp->datainterval);
1856 ptmin = min(ptmin, pt);
1915 } 1857 }
1916 1858
1917 /* set the period time minimum 1ms */ 1859 param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME;
1918 /* FIXME: high-speed mode allows 125us minimum period, but many parts 1860 if (snd_usb_get_speed(subs->dev) != USB_SPEED_HIGH)
1919 * in the current code assume the 1ms period. 1861 /* full speed devices have fixed data packet interval */
1920 */ 1862 ptmin = 1000;
1863 if (ptmin == 1000)
1864 /* if period time doesn't go below 1 ms, no rules needed */
1865 param_period_time_if_needed = -1;
1921 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1866 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1922 1000 * MIN_PACKS_URB, 1867 ptmin, UINT_MAX);
1923 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1868
1924 1869 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
1925 err = check_hw_params_convention(subs); 1870 hw_rule_rate, subs,
1926 if (err < 0) 1871 SNDRV_PCM_HW_PARAM_FORMAT,
1872 SNDRV_PCM_HW_PARAM_CHANNELS,
1873 param_period_time_if_needed,
1874 -1)) < 0)
1927 return err; 1875 return err;
1928 else if (err) { 1876 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1929 hwc_debug("setting extra hw constraints...\n"); 1877 hw_rule_channels, subs,
1930 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 1878 SNDRV_PCM_HW_PARAM_FORMAT,
1931 hw_rule_rate, subs, 1879 SNDRV_PCM_HW_PARAM_RATE,
1932 SNDRV_PCM_HW_PARAM_FORMAT, 1880 param_period_time_if_needed,
1933 SNDRV_PCM_HW_PARAM_CHANNELS, 1881 -1)) < 0)
1934 -1)) < 0) 1882 return err;
1935 return err; 1883 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT,
1936 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 1884 hw_rule_format, subs,
1937 hw_rule_channels, subs, 1885 SNDRV_PCM_HW_PARAM_RATE,
1938 SNDRV_PCM_HW_PARAM_FORMAT, 1886 SNDRV_PCM_HW_PARAM_CHANNELS,
1939 SNDRV_PCM_HW_PARAM_RATE, 1887 param_period_time_if_needed,
1940 -1)) < 0) 1888 -1)) < 0)
1941 return err; 1889 return err;
1942 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, 1890 if (param_period_time_if_needed >= 0) {
1943 hw_rule_format, subs, 1891 err = snd_pcm_hw_rule_add(runtime, 0,
1944 SNDRV_PCM_HW_PARAM_RATE, 1892 SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1945 SNDRV_PCM_HW_PARAM_CHANNELS, 1893 hw_rule_period_time, subs,
1946 -1)) < 0) 1894 SNDRV_PCM_HW_PARAM_FORMAT,
1947 return err; 1895 SNDRV_PCM_HW_PARAM_CHANNELS,
1948 if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) 1896 SNDRV_PCM_HW_PARAM_RATE,
1897 -1);
1898 if (err < 0)
1949 return err; 1899 return err;
1950 } 1900 }
1901 if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0)
1902 return err;
1951 return 0; 1903 return 0;
1952} 1904}
1953 1905
@@ -2160,7 +2112,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2160 fp = list_entry(p, struct audioformat, list); 2112 fp = list_entry(p, struct audioformat, list);
2161 snd_iprintf(buffer, " Interface %d\n", fp->iface); 2113 snd_iprintf(buffer, " Interface %d\n", fp->iface);
2162 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 2114 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
2163 snd_iprintf(buffer, " Format: 0x%x\n", fp->format); 2115 snd_iprintf(buffer, " Format: %#x (%d bits)\n",
2116 fp->format, snd_pcm_format_width(fp->format));
2164 snd_iprintf(buffer, " Channels: %d\n", fp->channels); 2117 snd_iprintf(buffer, " Channels: %d\n", fp->channels);
2165 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2118 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2166 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2119 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2179,8 +2132,11 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2179 } 2132 }
2180 snd_iprintf(buffer, "\n"); 2133 snd_iprintf(buffer, "\n");
2181 } 2134 }
2135 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
2136 snd_iprintf(buffer, " Data packet interval: %d us\n",
2137 125 * (1 << fp->datainterval));
2182 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 2138 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
2183 // snd_iprintf(buffer, " EP Attribute = 0x%x\n", fp->attributes); 2139 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
2184 } 2140 }
2185} 2141}
2186 2142
@@ -2524,7 +2480,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2524 * build the rate table and bitmap flags 2480 * build the rate table and bitmap flags
2525 */ 2481 */
2526 int r, idx; 2482 int r, idx;
2527 unsigned int nonzero_rates = 0;
2528 2483
2529 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 2484 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
2530 if (fp->rate_table == NULL) { 2485 if (fp->rate_table == NULL) {
@@ -2532,24 +2487,27 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2532 return -1; 2487 return -1;
2533 } 2488 }
2534 2489
2535 fp->nr_rates = nr_rates; 2490 fp->nr_rates = 0;
2536 fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); 2491 fp->rate_min = fp->rate_max = 0;
2537 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { 2492 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
2538 unsigned int rate = combine_triple(&fmt[idx]); 2493 unsigned int rate = combine_triple(&fmt[idx]);
2494 if (!rate)
2495 continue;
2539 /* C-Media CM6501 mislabels its 96 kHz altsetting */ 2496 /* C-Media CM6501 mislabels its 96 kHz altsetting */
2540 if (rate == 48000 && nr_rates == 1 && 2497 if (rate == 48000 && nr_rates == 1 &&
2541 chip->usb_id == USB_ID(0x0d8c, 0x0201) && 2498 (chip->usb_id == USB_ID(0x0d8c, 0x0201) ||
2499 chip->usb_id == USB_ID(0x0d8c, 0x0102)) &&
2542 fp->altsetting == 5 && fp->maxpacksize == 392) 2500 fp->altsetting == 5 && fp->maxpacksize == 392)
2543 rate = 96000; 2501 rate = 96000;
2544 fp->rate_table[r] = rate; 2502 fp->rate_table[fp->nr_rates] = rate;
2545 nonzero_rates |= rate; 2503 if (!fp->rate_min || rate < fp->rate_min)
2546 if (rate < fp->rate_min)
2547 fp->rate_min = rate; 2504 fp->rate_min = rate;
2548 else if (rate > fp->rate_max) 2505 if (!fp->rate_max || rate > fp->rate_max)
2549 fp->rate_max = rate; 2506 fp->rate_max = rate;
2550 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 2507 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
2508 fp->nr_rates++;
2551 } 2509 }
2552 if (!nonzero_rates) { 2510 if (!fp->nr_rates) {
2553 hwc_debug("All rates were zero. Skipping format!\n"); 2511 hwc_debug("All rates were zero. Skipping format!\n");
2554 return -1; 2512 return -1;
2555 } 2513 }
@@ -2619,7 +2577,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
2619 fp->format = SNDRV_PCM_FORMAT_MPEG; 2577 fp->format = SNDRV_PCM_FORMAT_MPEG;
2620 break; 2578 break;
2621 default: 2579 default:
2622 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", 2580 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected. processed as MPEG.\n",
2623 chip->dev->devnum, fp->iface, fp->altsetting, format); 2581 chip->dev->devnum, fp->iface, fp->altsetting, format);
2624 fp->format = SNDRV_PCM_FORMAT_MPEG; 2582 fp->format = SNDRV_PCM_FORMAT_MPEG;
2625 break; 2583 break;
@@ -2670,6 +2628,17 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp
2670 return 0; 2628 return 0;
2671} 2629}
2672 2630
2631static unsigned char parse_datainterval(struct snd_usb_audio *chip,
2632 struct usb_host_interface *alts)
2633{
2634 if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH &&
2635 get_endpoint(alts, 0)->bInterval >= 1 &&
2636 get_endpoint(alts, 0)->bInterval <= 4)
2637 return get_endpoint(alts, 0)->bInterval - 1;
2638 else
2639 return 0;
2640}
2641
2673static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 2642static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
2674 int iface, int altno); 2643 int iface, int altno);
2675static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) 2644static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
@@ -2775,6 +2744,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2775 fp->altset_idx = i; 2744 fp->altset_idx = i;
2776 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 2745 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
2777 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2746 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
2747 fp->datainterval = parse_datainterval(chip, alts);
2778 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2748 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2779 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) 2749 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH)
2780 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 2750 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
@@ -2817,7 +2787,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2817 continue; 2787 continue;
2818 } 2788 }
2819 2789
2820 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint); 2790 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
2821 err = add_audio_endpoint(chip, stream, fp); 2791 err = add_audio_endpoint(chip, stream, fp);
2822 if (err < 0) { 2792 if (err < 0) {
2823 kfree(fp->rate_table); 2793 kfree(fp->rate_table);
@@ -2966,6 +2936,8 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
2966 return -EINVAL; 2936 return -EINVAL;
2967 } 2937 }
2968 alts = &iface->altsetting[fp->altset_idx]; 2938 alts = &iface->altsetting[fp->altset_idx];
2939 fp->datainterval = parse_datainterval(chip, alts);
2940 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2969 usb_set_interface(chip->dev, fp->iface, 0); 2941 usb_set_interface(chip->dev, fp->iface, 0);
2970 init_usb_pitch(chip->dev, fp->iface, alts, fp); 2942 init_usb_pitch(chip->dev, fp->iface, alts, fp);
2971 init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); 2943 init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max);
@@ -3059,6 +3031,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
3059 fp->iface = altsd->bInterfaceNumber; 3031 fp->iface = altsd->bInterfaceNumber;
3060 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3032 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3061 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3033 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3034 fp->datainterval = 0;
3062 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3035 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3063 3036
3064 switch (fp->maxpacksize) { 3037 switch (fp->maxpacksize) {
@@ -3126,6 +3099,7 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip,
3126 fp->iface = altsd->bInterfaceNumber; 3099 fp->iface = altsd->bInterfaceNumber;
3127 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3100 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3128 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3101 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3102 fp->datainterval = parse_datainterval(chip, alts);
3129 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3103 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3130 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); 3104 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]);
3131 3105
@@ -3178,6 +3152,7 @@ static int create_ua101_quirk(struct snd_usb_audio *chip,
3178 fp->iface = altsd->bInterfaceNumber; 3152 fp->iface = altsd->bInterfaceNumber;
3179 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3153 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3180 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3154 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3155 fp->datainterval = parse_datainterval(chip, alts);
3181 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3156 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3182 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); 3157 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]);
3183 3158
@@ -3763,7 +3738,7 @@ static int usb_audio_resume(struct usb_interface *intf)
3763 3738
3764static int __init snd_usb_audio_init(void) 3739static int __init snd_usb_audio_init(void)
3765{ 3740{
3766 if (nrpacks < MIN_PACKS_URB || nrpacks > MAX_PACKS) { 3741 if (nrpacks < 1 || nrpacks > MAX_PACKS) {
3767 printk(KERN_WARNING "invalid nrpacks value.\n"); 3742 printk(KERN_WARNING "invalid nrpacks value.\n");
3768 return -EINVAL; 3743 return -EINVAL;
3769 } 3744 }
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 320641ab5be7..26bad373fe65 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1625,6 +1625,7 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
1625 } 1625 }
1626 1626
1627 ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1627 ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
1628 ep_info.out_interval = 0;
1628 ep_info.out_cables = endpoint->out_cables & 0x5555; 1629 ep_info.out_cables = endpoint->out_cables & 0x5555;
1629 err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); 1630 err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]);
1630 if (err < 0) 1631 if (err < 0)
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 00397c8a765b..ecb58e7a6245 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -66,6 +66,7 @@ static const struct rc_config {
66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ 66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ 67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ 68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
69 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
69}; 70};
70 71
71struct usb_mixer_interface { 72struct usb_mixer_interface {
@@ -78,7 +79,6 @@ struct usb_mixer_interface {
78 79
79 /* Sound Blaster remote control stuff */ 80 /* Sound Blaster remote control stuff */
80 const struct rc_config *rc_cfg; 81 const struct rc_config *rc_cfg;
81 unsigned long rc_hwdep_open;
82 u32 rc_code; 82 u32 rc_code;
83 wait_queue_head_t rc_waitq; 83 wait_queue_head_t rc_waitq;
84 struct urb *rc_urb; 84 struct urb *rc_urb;
@@ -110,6 +110,8 @@ struct mixer_build {
110 const struct usbmix_selector_map *selector_map; 110 const struct usbmix_selector_map *selector_map;
111}; 111};
112 112
113#define MAX_CHANNELS 10 /* max logical channels */
114
113struct usb_mixer_elem_info { 115struct usb_mixer_elem_info {
114 struct usb_mixer_interface *mixer; 116 struct usb_mixer_interface *mixer;
115 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ 117 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */
@@ -120,6 +122,8 @@ struct usb_mixer_elem_info {
120 int channels; 122 int channels;
121 int val_type; 123 int val_type;
122 int min, max, res; 124 int min, max, res;
125 int cached;
126 int cache_val[MAX_CHANNELS];
123 u8 initialized; 127 u8 initialized;
124}; 128};
125 129
@@ -181,8 +185,6 @@ enum {
181 USB_PROC_DCR_RELEASE = 6, 185 USB_PROC_DCR_RELEASE = 6,
182}; 186};
183 187
184#define MAX_CHANNELS 10 /* max logical channels */
185
186 188
187/* 189/*
188 * manual mapping of mixer names 190 * manual mapping of mixer names
@@ -219,7 +221,10 @@ static int check_ignored_ctl(struct mixer_build *state, int unitid, int control)
219 for (p = state->map; p->id; p++) { 221 for (p = state->map; p->id; p++) {
220 if (p->id == unitid && ! p->name && 222 if (p->id == unitid && ! p->name &&
221 (! control || ! p->control || control == p->control)) { 223 (! control || ! p->control || control == p->control)) {
222 // printk("ignored control %d:%d\n", unitid, control); 224 /*
225 printk(KERN_DEBUG "ignored control %d:%d\n",
226 unitid, control);
227 */
223 return 1; 228 return 1;
224 } 229 }
225 } 230 }
@@ -376,11 +381,35 @@ static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *
376} 381}
377 382
378/* channel = 0: master, 1 = first channel */ 383/* channel = 0: master, 1 = first channel */
379static inline int get_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int *value) 384static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval,
385 int channel, int *value)
380{ 386{
381 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); 387 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value);
382} 388}
383 389
390static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
391 int channel, int index, int *value)
392{
393 int err;
394
395 if (cval->cached & (1 << channel)) {
396 *value = cval->cache_val[index];
397 return 0;
398 }
399 err = get_cur_mix_raw(cval, channel, value);
400 if (err < 0) {
401 if (!cval->mixer->ignore_ctl_error)
402 snd_printd(KERN_ERR "cannot get current value for "
403 "control %d ch %d: err = %d\n",
404 cval->control, channel, err);
405 return err;
406 }
407 cval->cached |= 1 << channel;
408 cval->cache_val[index] = *value;
409 return 0;
410}
411
412
384/* 413/*
385 * set a mixer value 414 * set a mixer value
386 */ 415 */
@@ -412,9 +441,17 @@ static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int v
412 return set_ctl_value(cval, SET_CUR, validx, value); 441 return set_ctl_value(cval, SET_CUR, validx, value);
413} 442}
414 443
415static inline int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int value) 444static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
445 int index, int value)
416{ 446{
417 return set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, value); 447 int err;
448 err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel,
449 value);
450 if (err < 0)
451 return err;
452 cval->cached |= 1 << channel;
453 cval->cache_val[index] = value;
454 return 0;
418} 455}
419 456
420/* 457/*
@@ -718,7 +755,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
718 if (cval->min + cval->res < cval->max) { 755 if (cval->min + cval->res < cval->max) {
719 int last_valid_res = cval->res; 756 int last_valid_res = cval->res;
720 int saved, test, check; 757 int saved, test, check;
721 get_cur_mix_value(cval, minchn, &saved); 758 get_cur_mix_raw(cval, minchn, &saved);
722 for (;;) { 759 for (;;) {
723 test = saved; 760 test = saved;
724 if (test < cval->max) 761 if (test < cval->max)
@@ -726,8 +763,8 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
726 else 763 else
727 test -= cval->res; 764 test -= cval->res;
728 if (test < cval->min || test > cval->max || 765 if (test < cval->min || test > cval->max ||
729 set_cur_mix_value(cval, minchn, test) || 766 set_cur_mix_value(cval, minchn, 0, test) ||
730 get_cur_mix_value(cval, minchn, &check)) { 767 get_cur_mix_raw(cval, minchn, &check)) {
731 cval->res = last_valid_res; 768 cval->res = last_valid_res;
732 break; 769 break;
733 } 770 }
@@ -735,7 +772,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
735 break; 772 break;
736 cval->res *= 2; 773 cval->res *= 2;
737 } 774 }
738 set_cur_mix_value(cval, minchn, saved); 775 set_cur_mix_value(cval, minchn, 0, saved);
739 } 776 }
740 777
741 cval->initialized = 1; 778 cval->initialized = 1;
@@ -775,35 +812,25 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
775 struct usb_mixer_elem_info *cval = kcontrol->private_data; 812 struct usb_mixer_elem_info *cval = kcontrol->private_data;
776 int c, cnt, val, err; 813 int c, cnt, val, err;
777 814
815 ucontrol->value.integer.value[0] = cval->min;
778 if (cval->cmask) { 816 if (cval->cmask) {
779 cnt = 0; 817 cnt = 0;
780 for (c = 0; c < MAX_CHANNELS; c++) { 818 for (c = 0; c < MAX_CHANNELS; c++) {
781 if (cval->cmask & (1 << c)) { 819 if (!(cval->cmask & (1 << c)))
782 err = get_cur_mix_value(cval, c + 1, &val); 820 continue;
783 if (err < 0) { 821 err = get_cur_mix_value(cval, c + 1, cnt, &val);
784 if (cval->mixer->ignore_ctl_error) { 822 if (err < 0)
785 ucontrol->value.integer.value[0] = cval->min; 823 return cval->mixer->ignore_ctl_error ? 0 : err;
786 return 0; 824 val = get_relative_value(cval, val);
787 } 825 ucontrol->value.integer.value[cnt] = val;
788 snd_printd(KERN_ERR "cannot get current value for control %d ch %d: err = %d\n", cval->control, c + 1, err); 826 cnt++;
789 return err;
790 }
791 val = get_relative_value(cval, val);
792 ucontrol->value.integer.value[cnt] = val;
793 cnt++;
794 }
795 } 827 }
828 return 0;
796 } else { 829 } else {
797 /* master channel */ 830 /* master channel */
798 err = get_cur_mix_value(cval, 0, &val); 831 err = get_cur_mix_value(cval, 0, 0, &val);
799 if (err < 0) { 832 if (err < 0)
800 if (cval->mixer->ignore_ctl_error) { 833 return cval->mixer->ignore_ctl_error ? 0 : err;
801 ucontrol->value.integer.value[0] = cval->min;
802 return 0;
803 }
804 snd_printd(KERN_ERR "cannot get current value for control %d master ch: err = %d\n", cval->control, err);
805 return err;
806 }
807 val = get_relative_value(cval, val); 834 val = get_relative_value(cval, val);
808 ucontrol->value.integer.value[0] = val; 835 ucontrol->value.integer.value[0] = val;
809 } 836 }
@@ -820,34 +847,28 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 if (cval->cmask) { 847 if (cval->cmask) {
821 cnt = 0; 848 cnt = 0;
822 for (c = 0; c < MAX_CHANNELS; c++) { 849 for (c = 0; c < MAX_CHANNELS; c++) {
823 if (cval->cmask & (1 << c)) { 850 if (!(cval->cmask & (1 << c)))
824 err = get_cur_mix_value(cval, c + 1, &oval); 851 continue;
825 if (err < 0) { 852 err = get_cur_mix_value(cval, c + 1, cnt, &oval);
826 if (cval->mixer->ignore_ctl_error) 853 if (err < 0)
827 return 0; 854 return cval->mixer->ignore_ctl_error ? 0 : err;
828 return err; 855 val = ucontrol->value.integer.value[cnt];
829 } 856 val = get_abs_value(cval, val);
830 val = ucontrol->value.integer.value[cnt]; 857 if (oval != val) {
831 val = get_abs_value(cval, val); 858 set_cur_mix_value(cval, c + 1, cnt, val);
832 if (oval != val) { 859 changed = 1;
833 set_cur_mix_value(cval, c + 1, val);
834 changed = 1;
835 }
836 get_cur_mix_value(cval, c + 1, &val);
837 cnt++;
838 } 860 }
861 cnt++;
839 } 862 }
840 } else { 863 } else {
841 /* master channel */ 864 /* master channel */
842 err = get_cur_mix_value(cval, 0, &oval); 865 err = get_cur_mix_value(cval, 0, 0, &oval);
843 if (err < 0 && cval->mixer->ignore_ctl_error)
844 return 0;
845 if (err < 0) 866 if (err < 0)
846 return err; 867 return cval->mixer->ignore_ctl_error ? 0 : err;
847 val = ucontrol->value.integer.value[0]; 868 val = ucontrol->value.integer.value[0];
848 val = get_abs_value(cval, val); 869 val = get_abs_value(cval, val);
849 if (val != oval) { 870 if (val != oval) {
850 set_cur_mix_value(cval, 0, val); 871 set_cur_mix_value(cval, 0, 0, val);
851 changed = 1; 872 changed = 1;
852 } 873 }
853 } 874 }
@@ -1706,7 +1727,8 @@ static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer,
1706 break; 1727 break;
1707 /* live24ext: 4 = line-in jack */ 1728 /* live24ext: 4 = line-in jack */
1708 case 3: /* hp-out jack (may actuate Mute) */ 1729 case 3: /* hp-out jack (may actuate Mute) */
1709 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1730 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1731 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1710 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); 1732 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1711 break; 1733 break;
1712 default: 1734 default:
@@ -1797,24 +1819,6 @@ static void snd_usb_soundblaster_remote_complete(struct urb *urb)
1797 wake_up(&mixer->rc_waitq); 1819 wake_up(&mixer->rc_waitq);
1798} 1820}
1799 1821
1800static int snd_usb_sbrc_hwdep_open(struct snd_hwdep *hw, struct file *file)
1801{
1802 struct usb_mixer_interface *mixer = hw->private_data;
1803
1804 if (test_and_set_bit(0, &mixer->rc_hwdep_open))
1805 return -EBUSY;
1806 return 0;
1807}
1808
1809static int snd_usb_sbrc_hwdep_release(struct snd_hwdep *hw, struct file *file)
1810{
1811 struct usb_mixer_interface *mixer = hw->private_data;
1812
1813 clear_bit(0, &mixer->rc_hwdep_open);
1814 smp_mb__after_clear_bit();
1815 return 0;
1816}
1817
1818static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, 1822static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
1819 long count, loff_t *offset) 1823 long count, loff_t *offset)
1820{ 1824{
@@ -1867,9 +1871,8 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
1867 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; 1871 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
1868 hwdep->private_data = mixer; 1872 hwdep->private_data = mixer;
1869 hwdep->ops.read = snd_usb_sbrc_hwdep_read; 1873 hwdep->ops.read = snd_usb_sbrc_hwdep_read;
1870 hwdep->ops.open = snd_usb_sbrc_hwdep_open;
1871 hwdep->ops.release = snd_usb_sbrc_hwdep_release;
1872 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; 1874 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
1875 hwdep->exclusive = 1;
1873 1876
1874 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); 1877 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
1875 if (!mixer->rc_urb) 1878 if (!mixer->rc_urb)
@@ -1956,8 +1959,9 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
1956 int i, err; 1959 int i, err;
1957 1960
1958 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { 1961 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
1959 if (i > 1 && /* Live24ext has 2 LEDs only */ 1962 if (i > 1 && /* Live24ext has 2 LEDs only */
1960 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1963 (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1964 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
1961 break; 1965 break;
1962 err = snd_ctl_add(mixer->chip->card, 1966 err = snd_ctl_add(mixer->chip->card,
1963 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); 1967 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
@@ -1994,7 +1998,8 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
1994 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); 1998 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
1995 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) 1999 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
1996 jacks = jacks_audigy2nx; 2000 jacks = jacks_audigy2nx;
1997 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 2001 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2002 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1998 jacks = jacks_live24ext; 2003 jacks = jacks_live24ext;
1999 else 2004 else
2000 return; 2005 return;
@@ -2044,7 +2049,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2044 goto _error; 2049 goto _error;
2045 2050
2046 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || 2051 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) ||
2047 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) { 2052 mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2053 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) {
2048 struct snd_info_entry *entry; 2054 struct snd_info_entry *entry;
2049 2055
2050 if ((err = snd_audigy2nx_controls_create(mixer)) < 0) 2056 if ((err = snd_audigy2nx_controls_create(mixer)) < 0)
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index d755be0ad811..3e5d66cf1f5a 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -261,6 +261,22 @@ static struct usbmix_name_map aureon_51_2_map[] = {
261 {} /* terminator */ 261 {} /* terminator */
262}; 262};
263 263
264static struct usbmix_name_map scratch_live_map[] = {
265 /* 1: IT Line 1 (USB streaming) */
266 /* 2: OT Line 1 (Speaker) */
267 /* 3: IT Line 1 (Line connector) */
268 { 4, "Line 1 In" }, /* FU */
269 /* 5: OT Line 1 (USB streaming) */
270 /* 6: IT Line 2 (USB streaming) */
271 /* 7: OT Line 2 (Speaker) */
272 /* 8: IT Line 2 (Line connector) */
273 { 9, "Line 2 In" }, /* FU */
274 /* 10: OT Line 2 (USB streaming) */
275 /* 11: IT Mic (Line connector) */
276 /* 12: OT Mic (USB streaming) */
277 { 0 } /* terminator */
278};
279
264/* 280/*
265 * Control map entries 281 * Control map entries
266 */ 282 */
@@ -285,6 +301,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
285 .map = live24ext_map, 301 .map = live24ext_map,
286 }, 302 },
287 { 303 {
304 .id = USB_ID(0x041e, 0x3048),
305 .map = audigy2nx_map,
306 .selector_map = audigy2nx_selectors,
307 },
308 {
288 /* Hercules DJ Console (Windows Edition) */ 309 /* Hercules DJ Console (Windows Edition) */
289 .id = USB_ID(0x06f8, 0xb000), 310 .id = USB_ID(0x06f8, 0xb000),
290 .ignore_ctl_error = 1, 311 .ignore_ctl_error = 1,
@@ -311,6 +332,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
311 .id = USB_ID(0x0ccd, 0x0028), 332 .id = USB_ID(0x0ccd, 0x0028),
312 .map = aureon_51_2_map, 333 .map = aureon_51_2_map,
313 }, 334 },
335 {
336 .id = USB_ID(0x13e5, 0x0001),
337 .map = scratch_live_map,
338 .ignore_ctl_error = 1,
339 },
314 { 0 } /* terminator */ 340 { 0 } /* terminator */
315}; 341};
316 342
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 92115755d98e..647ef5029651 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -39,6 +39,16 @@
39 .idProduct = prod, \ 39 .idProduct = prod, \
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* Creative/Toshiba Multimedia Center SB-0500 */
43{
44 USB_DEVICE(0x041e, 0x3048),
45 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
46 .vendor_name = "Toshiba",
47 .product_name = "SB-0500",
48 .ifnum = QUIRK_NO_INTERFACE
49 }
50},
51
42/* Creative/E-Mu devices */ 52/* Creative/E-Mu devices */
43{ 53{
44 USB_DEVICE(0x041e, 0x3010), 54 USB_DEVICE(0x041e, 0x3010),
@@ -128,6 +138,14 @@
128 .bInterfaceClass = USB_CLASS_AUDIO, 138 .bInterfaceClass = USB_CLASS_AUDIO,
129 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 139 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
130}, 140},
141{
142 USB_DEVICE(0x046d, 0x0990),
143 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
144 .vendor_name = "Logitech, Inc.",
145 .product_name = "QuickCam Pro 9000",
146 .ifnum = QUIRK_NO_INTERFACE
147 }
148},
131 149
132/* 150/*
133 * Yamaha devices 151 * Yamaha devices
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 98276aafefe6..a5aae9d67f31 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
349 if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) 349 if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS)
350 return -ENOTTY; 350 return -ENOTTY;
351 351
352 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 352 cfg = memdup_user((void *)arg, sizeof(*cfg));
353 if (!cfg) 353 if (IS_ERR(cfg))
354 return -ENOMEM; 354 return PTR_ERR(cfg);
355 355
356 if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) {
357 err = -EFAULT;
358 goto free;
359 }
360 if (cfg->version != USB_STREAM_INTERFACE_VERSION) { 356 if (cfg->version != USB_STREAM_INTERFACE_VERSION) {
361 err = -ENXIO; 357 err = -ENXIO;
362 goto free; 358 goto free;
@@ -478,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
478 return true; 474 return true;
479} 475}
480 476
477static void snd_us122l_free(struct snd_card *card)
478{
479 struct us122l *us122l = US122L(card);
480 int index = us122l->chip.index;
481 if (index >= 0 && index < SNDRV_CARDS)
482 snd_us122l_card_used[index] = 0;
483}
484
481static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) 485static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
482{ 486{
483 int dev; 487 int dev;
@@ -494,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
494 if (err < 0) 498 if (err < 0)
495 return err; 499 return err;
496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 500 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
497 501 card->private_free = snd_us122l_free;
498 US122L(card)->chip.dev = device; 502 US122L(card)->chip.dev = device;
499 US122L(card)->chip.card = card; 503 US122L(card)->chip.card = card;
500 mutex_init(&US122L(card)->mutex); 504 mutex_init(&US122L(card)->mutex);
@@ -588,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
588 } 592 }
589 593
590 usb_put_intf(intf); 594 usb_put_intf(intf);
591 usb_put_dev(US122L(card)->chip.dev); 595 usb_put_dev(us122l->chip.dev);
592 596
593 while (atomic_read(&us122l->mmap_count)) 597 while (atomic_read(&us122l->mmap_count))
594 msleep(500); 598 msleep(500);
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 1558a5c4094f..f3d8f71265dd 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -30,9 +30,6 @@
30#include "usbusx2y.h" 30#include "usbusx2y.h"
31#include "usX2Yhwdep.h" 31#include "usX2Yhwdep.h"
32 32
33int usX2Y_hwdep_pcm_new(struct snd_card *card);
34
35
36static int snd_us428ctls_vm_fault(struct vm_area_struct *area, 33static int snd_us428ctls_vm_fault(struct vm_area_struct *area,
37 struct vm_fault *vmf) 34 struct vm_fault *vmf)
38{ 35{
@@ -106,16 +103,6 @@ static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file,
106} 103}
107 104
108 105
109static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file)
110{
111 return 0;
112}
113
114static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file)
115{
116 return 0;
117}
118
119static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, 106static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw,
120 struct snd_hwdep_dsp_status *info) 107 struct snd_hwdep_dsp_status *info)
121{ 108{
@@ -216,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
216 203
217 if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { 204 if (access_ok(VERIFY_READ, dsp->image, dsp->length)) {
218 struct usb_device* dev = priv->chip.dev; 205 struct usb_device* dev = priv->chip.dev;
219 char *buf = kmalloc(dsp->length, GFP_KERNEL); 206 char *buf;
220 if (!buf) 207
221 return -ENOMEM; 208 buf = memdup_user(dsp->image, dsp->length);
222 if (copy_from_user(buf, dsp->image, dsp->length)) { 209 if (IS_ERR(buf))
223 kfree(buf); 210 return PTR_ERR(buf);
224 return -EFAULT; 211
225 }
226 err = usb_set_interface(dev, 0, 1); 212 err = usb_set_interface(dev, 0, 1);
227 if (err) 213 if (err)
228 snd_printk(KERN_ERR "usb_set_interface error \n"); 214 snd_printk(KERN_ERR "usb_set_interface error \n");
@@ -267,8 +253,6 @@ int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device)
267 253
268 hw->iface = SNDRV_HWDEP_IFACE_USX2Y; 254 hw->iface = SNDRV_HWDEP_IFACE_USX2Y;
269 hw->private_data = usX2Y(card); 255 hw->private_data = usX2Y(card);
270 hw->ops.open = snd_usX2Y_hwdep_open;
271 hw->ops.release = snd_usX2Y_hwdep_release;
272 hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; 256 hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status;
273 hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; 257 hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load;
274 hw->ops.mmap = snd_us428ctls_mmap; 258 hw->ops.mmap = snd_us428ctls_mmap;
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index 70b96355ca4c..12ae0340adc0 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -33,32 +33,26 @@ static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk)
33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) 33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb)
34{ 34{
35 struct usb_stream *s = sk->s; 35 struct usb_stream *s = sk->s;
36 unsigned l = 0; 36 int pack, lb = 0;
37 int pack; 37
38 38 for (pack = 0; pack < sk->n_o_ps; pack++) {
39 urb->iso_frame_desc[0].offset = 0; 39 int l = usb_stream_next_packet_size(sk);
40 urb->iso_frame_desc[0].length = usb_stream_next_packet_size(sk); 40 if (s->idle_outsize + lb + l > s->period_size)
41 sk->out_phase = sk->out_phase_peeked;
42 urb->transfer_buffer_length = urb->iso_frame_desc[0].length;
43
44 for (pack = 1; pack < sk->n_o_ps; pack++) {
45 l = usb_stream_next_packet_size(sk);
46 if (s->idle_outsize + urb->transfer_buffer_length + l >
47 s->period_size)
48 goto check; 41 goto check;
49 42
50 sk->out_phase = sk->out_phase_peeked; 43 sk->out_phase = sk->out_phase_peeked;
51 urb->iso_frame_desc[pack].offset = urb->transfer_buffer_length; 44 urb->iso_frame_desc[pack].offset = lb;
52 urb->iso_frame_desc[pack].length = l; 45 urb->iso_frame_desc[pack].length = l;
53 urb->transfer_buffer_length += l; 46 lb += l;
54 } 47 }
55 snd_printdd(KERN_DEBUG "%i\n", urb->transfer_buffer_length); 48 snd_printdd(KERN_DEBUG "%i\n", lb);
56 49
57check: 50check:
58 urb->number_of_packets = pack; 51 urb->number_of_packets = pack;
59 s->idle_outsize += urb->transfer_buffer_length - s->period_size; 52 urb->transfer_buffer_length = lb;
53 s->idle_outsize += lb - s->period_size;
60 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, 54 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize,
61 urb->transfer_buffer_length, s->period_size); 55 lb, s->period_size);
62} 56}
63 57
64static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, 58static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
@@ -282,21 +276,20 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
282 struct usb_stream *s = sk->s; 276 struct usb_stream *s = sk->s;
283 struct urb *io; 277 struct urb *io;
284 struct usb_iso_packet_descriptor *id, *od; 278 struct usb_iso_packet_descriptor *id, *od;
285 int p, l = 0; 279 int p = 0, lb = 0, l = 0;
286 280
287 io = sk->idle_outurb; 281 io = sk->idle_outurb;
288 od = io->iso_frame_desc; 282 od = io->iso_frame_desc;
289 io->transfer_buffer_length = 0;
290 283
291 for (p = 0; s->sync_packet < 0; ++p, ++s->sync_packet) { 284 for (; s->sync_packet < 0; ++p, ++s->sync_packet) {
292 struct urb *ii = sk->completed_inurb; 285 struct urb *ii = sk->completed_inurb;
293 id = ii->iso_frame_desc + 286 id = ii->iso_frame_desc +
294 ii->number_of_packets + s->sync_packet; 287 ii->number_of_packets + s->sync_packet;
295 l = id->actual_length; 288 l = id->actual_length;
296 289
297 od[p].length = l; 290 od[p].length = l;
298 od[p].offset = io->transfer_buffer_length; 291 od[p].offset = lb;
299 io->transfer_buffer_length += l; 292 lb += l;
300 } 293 }
301 294
302 for (; 295 for (;
@@ -304,38 +297,38 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
304 ++p, ++s->sync_packet) { 297 ++p, ++s->sync_packet) {
305 l = inurb->iso_frame_desc[s->sync_packet].actual_length; 298 l = inurb->iso_frame_desc[s->sync_packet].actual_length;
306 299
307 if (s->idle_outsize + io->transfer_buffer_length + l > 300 if (s->idle_outsize + lb + l > s->period_size)
308 s->period_size)
309 goto check_ok; 301 goto check_ok;
310 302
311 od[p].length = l; 303 od[p].length = l;
312 od[p].offset = io->transfer_buffer_length; 304 od[p].offset = lb;
313 io->transfer_buffer_length += l; 305 lb += l;
314 } 306 }
315 307
316check_ok: 308check_ok:
317 s->sync_packet -= inurb->number_of_packets; 309 s->sync_packet -= inurb->number_of_packets;
318 if (s->sync_packet < -2 || s->sync_packet > 0) { 310 if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) {
319 snd_printk(KERN_WARNING "invalid sync_packet = %i;" 311 snd_printk(KERN_WARNING "invalid sync_packet = %i;"
320 " p=%i nop=%i %i %x %x %x > %x\n", 312 " p=%i nop=%i %i %x %x %x > %x\n",
321 s->sync_packet, p, inurb->number_of_packets, 313 s->sync_packet, p, inurb->number_of_packets,
322 s->idle_outsize + io->transfer_buffer_length + l, 314 s->idle_outsize + lb + l,
323 s->idle_outsize, io->transfer_buffer_length, l, 315 s->idle_outsize, lb, l,
324 s->period_size); 316 s->period_size);
325 return -1; 317 return -1;
326 } 318 }
327 if (io->transfer_buffer_length % s->cfg.frame_size) { 319 if (unlikely(lb % s->cfg.frame_size)) {
328 snd_printk(KERN_WARNING"invalid outsize = %i\n", 320 snd_printk(KERN_WARNING"invalid outsize = %i\n",
329 io->transfer_buffer_length); 321 lb);
330 return -1; 322 return -1;
331 } 323 }
332 s->idle_outsize += io->transfer_buffer_length - s->period_size; 324 s->idle_outsize += lb - s->period_size;
333 io->number_of_packets = p; 325 io->number_of_packets = p;
334 if (s->idle_outsize > 0) { 326 io->transfer_buffer_length = lb;
335 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); 327 if (s->idle_outsize <= 0)
336 return -1; 328 return 0;
337 } 329
338 return 0; 330 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize);
331 return -1;
339} 332}
340 333
341static void prepare_inurb(int number_of_packets, struct urb *iu) 334static void prepare_inurb(int number_of_packets, struct urb *iu)
@@ -557,7 +550,7 @@ static void stream_start(struct usb_stream_kernel *sk,
557 s->idle_insize -= max_diff - max_diff_0; 550 s->idle_insize -= max_diff - max_diff_0;
558 s->idle_insize += urb_size - s->period_size; 551 s->idle_insize += urb_size - s->period_size;
559 if (s->idle_insize < 0) { 552 if (s->idle_insize < 0) {
560 snd_printk("%i %i %i\n", 553 snd_printk(KERN_WARNING "%i %i %i\n",
561 s->idle_insize, urb_size, s->period_size); 554 s->idle_insize, urb_size, s->period_size);
562 return; 555 return;
563 } else if (s->idle_insize == 0) { 556 } else if (s->idle_insize == 0) {
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index af8b84954054..5ce0da23ee96 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -227,9 +227,9 @@ static void i_usX2Y_In04Int(struct urb *urb)
227 227
228 if (usX2Y->US04) { 228 if (usX2Y->US04) {
229 if (0 == usX2Y->US04->submitted) 229 if (0 == usX2Y->US04->submitted)
230 do 230 do {
231 err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC); 231 err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC);
232 while (!err && usX2Y->US04->submitted < usX2Y->US04->len); 232 } while (!err && usX2Y->US04->submitted < usX2Y->US04->len);
233 } else 233 } else
234 if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) { 234 if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) {
235 if (us428ctls->p4outLast != us428ctls->p4outSent) { 235 if (us428ctls->p4outLast != us428ctls->p4outSent) {
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 9a608fa85155..dd1ab6177840 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -870,7 +870,8 @@ static struct snd_pcm_hardware snd_usX2Y_2c =
870{ 870{
871 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 871 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
872 SNDRV_PCM_INFO_BLOCK_TRANSFER | 872 SNDRV_PCM_INFO_BLOCK_TRANSFER |
873 SNDRV_PCM_INFO_MMAP_VALID), 873 SNDRV_PCM_INFO_MMAP_VALID |
874 SNDRV_PCM_INFO_BATCH),
874 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, 875 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE,
875 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, 876 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
876 .rate_min = 44100, 877 .rate_min = 44100,
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.h b/sound/usb/usx2y/usx2yhwdeppcm.h
index c3382fdc386b..9c4fb84b2aa0 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.h
+++ b/sound/usb/usx2y/usx2yhwdeppcm.h
@@ -18,3 +18,5 @@ struct snd_usX2Y_hwdep_pcm_shm {
18 volatile unsigned captured_iso_frames; 18 volatile unsigned captured_iso_frames;
19 int capture_iso_start; 19 int capture_iso_start;
20}; 20};
21
22int usX2Y_hwdep_pcm_new(struct snd_card *card);