aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/Kconfig3
-rw-r--r--sound/Makefile2
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-onyx.c8
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.c4
-rw-r--r--sound/aoa/soundbus/core.c2
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-core.c5
-rw-r--r--sound/aoa/soundbus/soundbus.h2
-rw-r--r--sound/arm/pxa2xx-ac97.c2
-rw-r--r--sound/arm/sa11xx-uda1341.c2
-rw-r--r--sound/core/Kconfig2
-rw-r--r--sound/core/pcm_native.c32
-rw-r--r--sound/core/rtctimer.c3
-rw-r--r--sound/core/seq/seq_instr.c6
-rw-r--r--sound/core/seq/seq_virmidi.c3
-rw-r--r--sound/core/sound.c3
-rw-r--r--sound/core/timer.c27
-rw-r--r--sound/drivers/dummy.c2
-rw-r--r--sound/drivers/mpu401/mpu401.c14
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c18
-rw-r--r--sound/drivers/mts64.c6
-rw-r--r--sound/drivers/portman2x4.c6
-rw-r--r--sound/drivers/serial-u16550.c2
-rw-r--r--sound/drivers/virmidi.c2
-rw-r--r--sound/drivers/vx/vx_hwdep.c14
-rw-r--r--sound/i2c/other/ak4114.c114
-rw-r--r--sound/i2c/other/ak4xxx-adda.c24
-rw-r--r--sound/isa/Kconfig54
-rw-r--r--sound/isa/ad1816a/ad1816a.c8
-rw-r--r--sound/isa/ad1848/ad1848.c167
-rw-r--r--sound/isa/ad1848/ad1848_lib.c4
-rw-r--r--sound/isa/adlib.c122
-rw-r--r--sound/isa/cmi8330.c124
-rw-r--r--sound/isa/cs423x/cs4231.c213
-rw-r--r--sound/isa/cs423x/cs4231_lib.c4
-rw-r--r--sound/isa/cs423x/cs4236.c143
-rw-r--r--sound/isa/es1688/es1688.c251
-rw-r--r--sound/isa/es18xx.c123
-rw-r--r--sound/isa/gus/gusclassic.c292
-rw-r--r--sound/isa/gus/gusextreme.c379
-rw-r--r--sound/isa/gus/gusmax.c71
-rw-r--r--sound/isa/gus/interwave.c108
-rw-r--r--sound/isa/opl3sa2.c136
-rw-r--r--sound/isa/opti9xx/miro.c80
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c109
-rw-r--r--sound/isa/sb/Makefile15
-rw-r--r--sound/isa/sb/sb16.c122
-rw-r--r--sound/isa/sb/sb16_csp.c30
-rw-r--r--sound/isa/sb/sb16_main.c10
-rw-r--r--sound/isa/sb/sb8.c90
-rw-r--r--sound/isa/sb/sb_common.c5
-rw-r--r--sound/isa/sb/sb_mixer.c3
-rw-r--r--sound/isa/sgalaxy.c107
-rw-r--r--sound/isa/sscape.c140
-rw-r--r--sound/isa/wavefront/wavefront.c119
-rw-r--r--sound/isa/wavefront/wavefront_fx.c23
-rw-r--r--sound/isa/wavefront/wavefront_synth.c2
-rw-r--r--sound/oss/Kconfig80
-rw-r--r--sound/oss/Makefile13
-rw-r--r--sound/oss/ac97.c432
-rw-r--r--sound/oss/ac97.h201
-rw-r--r--sound/oss/aci.c712
-rw-r--r--sound/oss/aci.h57
-rw-r--r--sound/oss/ad1816.c1368
-rw-r--r--sound/oss/ad1889.c1101
-rw-r--r--sound/oss/ad1889.h135
-rw-r--r--sound/oss/adlib_card.c73
-rw-r--r--sound/oss/cs461x.h1691
-rw-r--r--sound/oss/cs461x_image.h322
-rw-r--r--sound/oss/cs46xx.c5444
-rw-r--r--sound/oss/cs46xx_wrapper-24.h56
-rw-r--r--sound/oss/cs46xxpm.h70
-rw-r--r--sound/oss/emu10k1/8010.h737
-rw-r--r--sound/oss/emu10k1/Makefile17
-rw-r--r--sound/oss/emu10k1/audio.c1595
-rw-r--r--sound/oss/emu10k1/audio.h44
-rw-r--r--sound/oss/emu10k1/cardmi.c832
-rw-r--r--sound/oss/emu10k1/cardmi.h97
-rw-r--r--sound/oss/emu10k1/cardmo.c229
-rw-r--r--sound/oss/emu10k1/cardmo.h62
-rw-r--r--sound/oss/emu10k1/cardwi.c384
-rw-r--r--sound/oss/emu10k1/cardwi.h91
-rw-r--r--sound/oss/emu10k1/cardwo.c643
-rw-r--r--sound/oss/emu10k1/cardwo.h90
-rw-r--r--sound/oss/emu10k1/ecard.c157
-rw-r--r--sound/oss/emu10k1/ecard.h113
-rw-r--r--sound/oss/emu10k1/efxmgr.c220
-rw-r--r--sound/oss/emu10k1/efxmgr.h270
-rw-r--r--sound/oss/emu10k1/emuadxmg.c104
-rw-r--r--sound/oss/emu10k1/hwaccess.c507
-rw-r--r--sound/oss/emu10k1/hwaccess.h247
-rw-r--r--sound/oss/emu10k1/icardmid.h163
-rw-r--r--sound/oss/emu10k1/icardwav.h53
-rw-r--r--sound/oss/emu10k1/irqmgr.c113
-rw-r--r--sound/oss/emu10k1/irqmgr.h52
-rw-r--r--sound/oss/emu10k1/main.c1471
-rw-r--r--sound/oss/emu10k1/midi.c614
-rw-r--r--sound/oss/emu10k1/midi.h78
-rw-r--r--sound/oss/emu10k1/mixer.c690
-rw-r--r--sound/oss/emu10k1/passthrough.c240
-rw-r--r--sound/oss/emu10k1/passthrough.h99
-rw-r--r--sound/oss/emu10k1/recmgr.c147
-rw-r--r--sound/oss/emu10k1/recmgr.h48
-rw-r--r--sound/oss/emu10k1/timer.c176
-rw-r--r--sound/oss/emu10k1/timer.h54
-rw-r--r--sound/oss/emu10k1/voicemgr.c398
-rw-r--r--sound/oss/emu10k1/voicemgr.h103
-rw-r--r--sound/oss/es1371.c4
-rw-r--r--sound/oss/mpu401.c7
-rw-r--r--sound/oss/nm256.h292
-rw-r--r--sound/oss/nm256_audio.c1662
-rw-r--r--sound/oss/nm256_coeff.h4697
-rw-r--r--sound/oss/opl3.c14
-rw-r--r--sound/oss/opl3.h5
-rw-r--r--sound/oss/opl3sa2.c1020
-rw-r--r--sound/oss/pas2_pcm.c2
-rw-r--r--sound/oss/sb_card.c2
-rw-r--r--sound/oss/trident.c371
-rw-r--r--sound/pci/Kconfig44
-rw-r--r--sound/pci/Makefile2
-rw-r--r--sound/pci/ac97/Makefile2
-rw-r--r--sound/pci/ac97/ac97_codec.c45
-rw-r--r--sound/pci/ac97/ac97_local.h55
-rw-r--r--sound/pci/ac97/ac97_patch.c199
-rw-r--r--sound/pci/ac97/ac97_patch.h110
-rw-r--r--sound/pci/ac97/ac97_pcm.c1
-rw-r--r--sound/pci/ali5451/ali5451.c878
-rw-r--r--sound/pci/als300.c7
-rw-r--r--sound/pci/atiixp.c6
-rw-r--r--sound/pci/atiixp_modem.c5
-rw-r--r--sound/pci/au88x0/au88x0.c6
-rw-r--r--sound/pci/au88x0/au88x0_sb.h40
-rw-r--r--sound/pci/azt3328.c34
-rw-r--r--sound/pci/azt3328.h4
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106.h1
-rw-r--r--sound/pci/ca0106/ca0106_main.c28
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c79
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.h3
-rw-r--r--sound/pci/cs46xx/dsp_spos.c170
-rw-r--r--sound/pci/cs46xx/imgs/cwcemb80.h1607
-rw-r--r--sound/pci/cs5530.c306
-rw-r--r--sound/pci/echoaudio/darla20.c2
-rw-r--r--sound/pci/echoaudio/darla24.c2
-rw-r--r--sound/pci/echoaudio/echo3g.c4
-rw-r--r--sound/pci/echoaudio/echoaudio.c4
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c4
-rw-r--r--sound/pci/echoaudio/gina20.c2
-rw-r--r--sound/pci/echoaudio/gina24.c6
-rw-r--r--sound/pci/echoaudio/indigo.c3
-rw-r--r--sound/pci/echoaudio/indigodj.c3
-rw-r--r--sound/pci/echoaudio/indigoio.c3
-rw-r--r--sound/pci/echoaudio/layla20.c3
-rw-r--r--sound/pci/echoaudio/layla24.c6
-rw-r--r--sound/pci/echoaudio/mia.c3
-rw-r--r--sound/pci/echoaudio/mona.c9
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c141
-rw-r--r--sound/pci/emu10k1/emu10k1x.c2
-rw-r--r--sound/pci/emu10k1/emufx.c78
-rw-r--r--sound/pci/emu10k1/emumixer.c16
-rw-r--r--sound/pci/emu10k1/emupcm.c39
-rw-r--r--sound/pci/emu10k1/p16v.c4
-rw-r--r--sound/pci/ens1370.c16
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/fm801.c4
-rw-r--r--sound/pci/hda/Makefile9
-rw-r--r--sound/pci/hda/hda_codec.c745
-rw-r--r--sound/pci/hda/hda_codec.h2
-rw-r--r--sound/pci/hda/hda_generic.c2
-rw-r--r--sound/pci/hda/hda_intel.c84
-rw-r--r--sound/pci/hda/hda_local.h14
-rw-r--r--sound/pci/hda/hda_proc.c6
-rw-r--r--sound/pci/hda/patch_analog.c715
-rw-r--r--sound/pci/hda/patch_atihdmi.c18
-rw-r--r--sound/pci/hda/patch_cmedia.c14
-rw-r--r--sound/pci/hda/patch_conexant.c360
-rw-r--r--sound/pci/hda/patch_realtek.c3697
-rw-r--r--sound/pci/hda/patch_si3054.c6
-rw-r--r--sound/pci/hda/patch_sigmatel.c466
-rw-r--r--sound/pci/hda/patch_via.c14
-rw-r--r--sound/pci/ice1712/amp.c2
-rw-r--r--sound/pci/ice1712/amp.h2
-rw-r--r--sound/pci/ice1712/aureon.c18
-rw-r--r--sound/pci/ice1712/aureon.h2
-rw-r--r--sound/pci/ice1712/delta.c34
-rw-r--r--sound/pci/ice1712/delta.h6
-rw-r--r--sound/pci/ice1712/ews.c24
-rw-r--r--sound/pci/ice1712/ews.h2
-rw-r--r--sound/pci/ice1712/hoontech.c6
-rw-r--r--sound/pci/ice1712/hoontech.h2
-rw-r--r--sound/pci/ice1712/ice1712.c50
-rw-r--r--sound/pci/ice1712/ice1712.h3
-rw-r--r--sound/pci/ice1712/ice1724.c47
-rw-r--r--sound/pci/ice1712/juli.c24
-rw-r--r--sound/pci/ice1712/juli.h2
-rw-r--r--sound/pci/ice1712/phase.c14
-rw-r--r--sound/pci/ice1712/phase.h2
-rw-r--r--sound/pci/ice1712/pontis.c6
-rw-r--r--sound/pci/ice1712/pontis.h2
-rw-r--r--sound/pci/ice1712/prodigy192.c360
-rw-r--r--sound/pci/ice1712/prodigy192.h10
-rw-r--r--sound/pci/ice1712/revo.c33
-rw-r--r--sound/pci/ice1712/revo.h2
-rw-r--r--sound/pci/ice1712/vt1720_mobo.c6
-rw-r--r--sound/pci/ice1712/vt1720_mobo.h2
-rw-r--r--sound/pci/ice1712/wtm.c2
-rw-r--r--sound/pci/intel8x0.c40
-rw-r--r--sound/pci/korg1212/korg1212.c25
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/mixart/mixart_hwdep.c4
-rw-r--r--sound/pci/nm256/nm256.c3
-rw-r--r--sound/pci/pcxhr/pcxhr.c28
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c6
-rw-r--r--sound/pci/riptide/riptide.c1
-rw-r--r--sound/pci/rme32.c7
-rw-r--r--sound/pci/rme9652/hdsp.c99
-rw-r--r--sound/pci/rme9652/hdspm.c185
-rw-r--r--sound/pci/rme9652/rme9652.c10
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c18
-rw-r--r--sound/pci/via82xx_modem.c8
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c57
-rw-r--r--sound/pcmcia/vx/vxpocket.c2
-rw-r--r--sound/ppc/Kconfig20
-rw-r--r--sound/ppc/Makefile3
-rw-r--r--sound/ppc/beep.c10
-rw-r--r--sound/ppc/pmac.c8
-rw-r--r--sound/ppc/snd_ps3.c1125
-rw-r--r--sound/ppc/snd_ps3.h135
-rw-r--r--sound/ppc/snd_ps3_reg.h891
-rw-r--r--sound/sh/Kconfig14
-rw-r--r--sound/sh/Makefile8
-rw-r--r--sound/sh/aica.c665
-rw-r--r--sound/sh/aica.h81
-rw-r--r--sound/soc/Kconfig19
-rw-r--r--sound/soc/Makefile2
-rw-r--r--sound/soc/at91/Kconfig10
-rw-r--r--sound/soc/at91/Makefile4
-rw-r--r--sound/soc/at91/at91-ssc.c (renamed from sound/soc/at91/at91-i2s.c)259
-rw-r--r--sound/soc/at91/at91-ssc.h (renamed from sound/soc/at91/at91-i2s.h)14
-rw-r--r--sound/soc/at91/eti_b1_wm8731.c8
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ac97.c4
-rw-r--r--sound/soc/codecs/ac97.h1
-rw-r--r--sound/soc/codecs/wm8750.c2
-rw-r--r--sound/soc/codecs/wm8753.c1811
-rw-r--r--sound/soc/codecs/wm8753.h126
-rw-r--r--sound/soc/codecs/wm9712.c8
-rw-r--r--sound/soc/pxa/Kconfig4
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c2
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.h2
-rw-r--r--sound/soc/pxa/pxa2xx-i2s.h2
-rw-r--r--sound/soc/s3c24xx/Kconfig37
-rw-r--r--sound/soc/s3c24xx/Makefile15
-rw-r--r--sound/soc/s3c24xx/lm4857.h32
-rw-r--r--sound/soc/s3c24xx/neo1973_wm8753.c670
-rw-r--r--sound/soc/s3c24xx/s3c2443-ac97.c401
-rw-r--r--sound/soc/s3c24xx/s3c24xx-ac97.h25
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c441
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.h37
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c470
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.h31
-rw-r--r--sound/soc/s3c24xx/smdk2443_wm9710.c85
-rw-r--r--sound/soc/sh/Kconfig38
-rw-r--r--sound/soc/sh/Makefile14
-rw-r--r--sound/soc/sh/dma-sh7760.c354
-rw-r--r--sound/soc/sh/hac.c322
-rw-r--r--sound/soc/sh/sh7760-ac97.c92
-rw-r--r--sound/soc/sh/ssi.c400
-rw-r--r--sound/soc/soc-core.c18
-rw-r--r--sound/soc/soc-dapm.c6
-rw-r--r--sound/sound_firmware.c1
-rw-r--r--sound/sparc/cs4231.c4
-rw-r--r--sound/sparc/dbri.c2
-rw-r--r--sound/usb/Kconfig28
-rw-r--r--sound/usb/Makefile2
-rw-r--r--sound/usb/caiaq/Makefile3
-rw-r--r--sound/usb/caiaq/caiaq-audio.c707
-rw-r--r--sound/usb/caiaq/caiaq-audio.h7
-rw-r--r--sound/usb/caiaq/caiaq-device.c436
-rw-r--r--sound/usb/caiaq/caiaq-device.h116
-rw-r--r--sound/usb/caiaq/caiaq-input.c246
-rw-r--r--sound/usb/caiaq/caiaq-input.h8
-rw-r--r--sound/usb/caiaq/caiaq-midi.c177
-rw-r--r--sound/usb/caiaq/caiaq-midi.h8
-rw-r--r--sound/usb/usbaudio.c25
-rw-r--r--sound/usb/usbmidi.c58
-rw-r--r--sound/usb/usbmixer.c2
-rw-r--r--sound/usb/usbquirks.h104
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c7
291 files changed, 19717 insertions, 36440 deletions
diff --git a/sound/Kconfig b/sound/Kconfig
index 97532bbc2cc..e48b9b37d22 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -2,6 +2,7 @@
2# 2#
3 3
4menu "Sound" 4menu "Sound"
5 depends on HAS_IOMEM
5 6
6config SOUND 7config SOUND
7 tristate "Sound card support" 8 tristate "Sound card support"
@@ -64,6 +65,8 @@ source "sound/arm/Kconfig"
64 65
65source "sound/mips/Kconfig" 66source "sound/mips/Kconfig"
66 67
68source "sound/sh/Kconfig"
69
67# the following will depend on the order of config. 70# the following will depend on the order of config.
68# here assuming USB is defined before ALSA 71# here assuming USB is defined before ALSA
69source "sound/usb/Kconfig" 72source "sound/usb/Kconfig"
diff --git a/sound/Makefile b/sound/Makefile
index b7c7fb7c24c..3ead922bd9c 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -5,7 +5,7 @@ obj-$(CONFIG_SOUND) += soundcore.o
5obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o 5obj-$(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/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/ 8obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/
9obj-$(CONFIG_SND_AOA) += aoa/ 9obj-$(CONFIG_SND_AOA) += aoa/
10 10
11# This one must be compilable even if sound is configured out 11# This one must be compilable even if sound is configured out
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c b/sound/aoa/codecs/snd-aoa-codec-onyx.c
index e91f9f66f39..028852374f2 100644
--- a/sound/aoa/codecs/snd-aoa-codec-onyx.c
+++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c
@@ -661,7 +661,7 @@ static struct transfer_info onyx_transfers[] = {
661 .tag = 2, 661 .tag = 2,
662 }, 662 },
663#ifdef SNDRV_PCM_FMTBIT_COMPRESSED_16BE 663#ifdef SNDRV_PCM_FMTBIT_COMPRESSED_16BE
664Once alsa gets supports for this kind of thing we can add it... 664 /* Once alsa gets supports for this kind of thing we can add it... */
665 { 665 {
666 /* digital compressed output */ 666 /* digital compressed output */
667 .formats = SNDRV_PCM_FMTBIT_COMPRESSED_16BE, 667 .formats = SNDRV_PCM_FMTBIT_COMPRESSED_16BE,
@@ -713,7 +713,7 @@ static int onyx_prepare(struct codec_info_item *cii,
713 if (substream->runtime->format == SNDRV_PCM_FMTBIT_COMPRESSED_16BE) { 713 if (substream->runtime->format == SNDRV_PCM_FMTBIT_COMPRESSED_16BE) {
714 /* mute and lock analog output */ 714 /* mute and lock analog output */
715 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v); 715 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
716 if (onyx_write_register(onyx 716 if (onyx_write_register(onyx,
717 ONYX_REG_DAC_CONTROL, 717 ONYX_REG_DAC_CONTROL,
718 v | ONYX_MUTE_RIGHT | ONYX_MUTE_LEFT)) 718 v | ONYX_MUTE_RIGHT | ONYX_MUTE_LEFT))
719 goto out_unlock; 719 goto out_unlock;
@@ -1018,7 +1018,7 @@ static int onyx_create(struct i2c_adapter *adapter,
1018 onyx->i2c.driver = &onyx_driver; 1018 onyx->i2c.driver = &onyx_driver;
1019 onyx->i2c.adapter = adapter; 1019 onyx->i2c.adapter = adapter;
1020 onyx->i2c.addr = addr & 0x7f; 1020 onyx->i2c.addr = addr & 0x7f;
1021 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE-1); 1021 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE);
1022 1022
1023 if (i2c_attach_client(&onyx->i2c)) { 1023 if (i2c_attach_client(&onyx->i2c)) {
1024 printk(KERN_ERR PFX "failed to attach to i2c\n"); 1024 printk(KERN_ERR PFX "failed to attach to i2c\n");
@@ -1033,7 +1033,7 @@ static int onyx_create(struct i2c_adapter *adapter,
1033 goto fail; 1033 goto fail;
1034 } 1034 }
1035 1035
1036 strlcpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN-1); 1036 strlcpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN);
1037 onyx->codec.owner = THIS_MODULE; 1037 onyx->codec.owner = THIS_MODULE;
1038 onyx->codec.init = onyx_init_codec; 1038 onyx->codec.init = onyx_init_codec;
1039 onyx->codec.exit = onyx_exit_codec; 1039 onyx->codec.exit = onyx_exit_codec;
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c
index 041fe52cbf2..2f771f57c76 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.c
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.c
@@ -899,14 +899,14 @@ static int tas_create(struct i2c_adapter *adapter,
899 tas->i2c.addr = addr; 899 tas->i2c.addr = addr;
900 /* seems that half is a saner default */ 900 /* seems that half is a saner default */
901 tas->drc_range = TAS3004_DRC_MAX / 2; 901 tas->drc_range = TAS3004_DRC_MAX / 2;
902 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE-1); 902 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE);
903 903
904 if (i2c_attach_client(&tas->i2c)) { 904 if (i2c_attach_client(&tas->i2c)) {
905 printk(KERN_ERR PFX "failed to attach to i2c\n"); 905 printk(KERN_ERR PFX "failed to attach to i2c\n");
906 goto fail; 906 goto fail;
907 } 907 }
908 908
909 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN-1); 909 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
910 tas->codec.owner = THIS_MODULE; 910 tas->codec.owner = THIS_MODULE;
911 tas->codec.init = tas_init_codec; 911 tas->codec.init = tas_init_codec;
912 tas->codec.exit = tas_exit_codec; 912 tas->codec.exit = tas_exit_codec;
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index 8b2e9b905cd..64d16391433 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -163,8 +163,6 @@ static int soundbus_device_resume(struct device * dev)
163 163
164#endif /* CONFIG_PM */ 164#endif /* CONFIG_PM */
165 165
166extern struct device_attribute soundbus_dev_attrs[];
167
168static struct bus_type soundbus_bus_type = { 166static struct bus_type soundbus_bus_type = {
169 .name = "aoa-soundbus", 167 .name = "aoa-soundbus",
170 .probe = soundbus_probe, 168 .probe = soundbus_probe,
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-core.c b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
index 0fccdbf5166..efb9441b3ac 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-core.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
@@ -23,9 +23,6 @@
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>"); 24MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
25MODULE_DESCRIPTION("Apple Soundbus: I2S support"); 25MODULE_DESCRIPTION("Apple Soundbus: I2S support");
26/* for auto-loading, declare that we handle this weird
27 * string that macio puts into the relevant device */
28MODULE_ALIAS("of:Ni2sTi2sC");
29 26
30static int force; 27static int force;
31module_param(force, int, 0444); 28module_param(force, int, 0444);
@@ -37,6 +34,8 @@ static struct of_device_id i2sbus_match[] = {
37 { } 34 { }
38}; 35};
39 36
37MODULE_DEVICE_TABLE(of, i2sbus_match);
38
40static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev, 39static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev,
41 struct dbdma_command_mem *r, 40 struct dbdma_command_mem *r,
42 int numcmds) 41 int numcmds)
diff --git a/sound/aoa/soundbus/soundbus.h b/sound/aoa/soundbus/soundbus.h
index 5c27297835d..622cd37a011 100644
--- a/sound/aoa/soundbus/soundbus.h
+++ b/sound/aoa/soundbus/soundbus.h
@@ -199,4 +199,6 @@ struct soundbus_driver {
199extern int soundbus_register_driver(struct soundbus_driver *drv); 199extern int soundbus_register_driver(struct soundbus_driver *drv);
200extern void soundbus_unregister_driver(struct soundbus_driver *drv); 200extern void soundbus_unregister_driver(struct soundbus_driver *drv);
201 201
202extern struct device_attribute soundbus_dev_attrs[];
203
202#endif /* __SOUNDBUS_H */ 204#endif /* __SOUNDBUS_H */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 19c65a8d86a..7bc2767e158 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -361,7 +361,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
361 err: 361 err:
362 if (card) 362 if (card)
363 snd_card_free(card); 363 snd_card_free(card);
364 if (CKEN & CKEN_AC97) { 364 if (CKEN & (1 << CKEN_AC97)) {
365 GCR |= GCR_ACLINK_OFF; 365 GCR |= GCR_ACLINK_OFF;
366 free_irq(IRQ_AC97, NULL); 366 free_irq(IRQ_AC97, NULL);
367 pxa_set_cken(CKEN_AC97, 0); 367 pxa_set_cken(CKEN_AC97, 0);
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index c7e1b264619..e7ed868fa7c 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -987,7 +987,7 @@ static int __init sa11xx_uda1341_init(void)
987 if (platform_get_drvdata(device)) 987 if (platform_get_drvdata(device))
988 return 0; 988 return 0;
989 platform_device_unregister(device); 989 platform_device_unregister(device);
990 err = -ENODEV 990 err = -ENODEV;
991 } else 991 } else
992 err = PTR_ERR(device); 992 err = PTR_ERR(device);
993 platform_driver_unregister(&sa11xx_uda1341_driver); 993 platform_driver_unregister(&sa11xx_uda1341_driver);
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index b2927523d79..829ca38b595 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -146,7 +146,7 @@ config SND_VERBOSE_PROCFS
146 default y 146 default y
147 help 147 help
148 Say Y here to include code for verbose procfs contents (provides 148 Say Y here to include code for verbose procfs contents (provides
149 usefull information to developers when a problem occurs). On the 149 useful information to developers when a problem occurs). On the
150 other side, it makes the ALSA subsystem larger. 150 other side, it makes the ALSA subsystem larger.
151 151
152config SND_VERBOSE_PRINTK 152config SND_VERBOSE_PRINTK
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 905234817c8..59b29cd482a 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -712,26 +712,23 @@ static int snd_pcm_action_group(struct action_ops *ops,
712 struct snd_pcm_substream *substream, 712 struct snd_pcm_substream *substream,
713 int state, int do_lock) 713 int state, int do_lock)
714{ 714{
715 struct list_head *pos;
716 struct snd_pcm_substream *s = NULL; 715 struct snd_pcm_substream *s = NULL;
717 struct snd_pcm_substream *s1; 716 struct snd_pcm_substream *s1;
718 int res = 0; 717 int res = 0;
719 718
720 snd_pcm_group_for_each(pos, substream) { 719 snd_pcm_group_for_each_entry(s, substream) {
721 s = snd_pcm_group_substream_entry(pos);
722 if (do_lock && s != substream) 720 if (do_lock && s != substream)
723 spin_lock(&s->self_group.lock); 721 spin_lock_nested(&s->self_group.lock,
722 SINGLE_DEPTH_NESTING);
724 res = ops->pre_action(s, state); 723 res = ops->pre_action(s, state);
725 if (res < 0) 724 if (res < 0)
726 goto _unlock; 725 goto _unlock;
727 } 726 }
728 snd_pcm_group_for_each(pos, substream) { 727 snd_pcm_group_for_each_entry(s, substream) {
729 s = snd_pcm_group_substream_entry(pos);
730 res = ops->do_action(s, state); 728 res = ops->do_action(s, state);
731 if (res < 0) { 729 if (res < 0) {
732 if (ops->undo_action) { 730 if (ops->undo_action) {
733 snd_pcm_group_for_each(pos, substream) { 731 snd_pcm_group_for_each_entry(s1, substream) {
734 s1 = snd_pcm_group_substream_entry(pos);
735 if (s1 == s) /* failed stream */ 732 if (s1 == s) /* failed stream */
736 break; 733 break;
737 ops->undo_action(s1, state); 734 ops->undo_action(s1, state);
@@ -741,15 +738,13 @@ static int snd_pcm_action_group(struct action_ops *ops,
741 goto _unlock; 738 goto _unlock;
742 } 739 }
743 } 740 }
744 snd_pcm_group_for_each(pos, substream) { 741 snd_pcm_group_for_each_entry(s, substream) {
745 s = snd_pcm_group_substream_entry(pos);
746 ops->post_action(s, state); 742 ops->post_action(s, state);
747 } 743 }
748 _unlock: 744 _unlock:
749 if (do_lock) { 745 if (do_lock) {
750 /* unlock streams */ 746 /* unlock streams */
751 snd_pcm_group_for_each(pos, substream) { 747 snd_pcm_group_for_each_entry(s1, substream) {
752 s1 = snd_pcm_group_substream_entry(pos);
753 if (s1 != substream) 748 if (s1 != substream)
754 spin_unlock(&s1->self_group.lock); 749 spin_unlock(&s1->self_group.lock);
755 if (s1 == s) /* end */ 750 if (s1 == s) /* end */
@@ -1438,7 +1433,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1438{ 1433{
1439 struct snd_card *card; 1434 struct snd_card *card;
1440 struct snd_pcm_runtime *runtime; 1435 struct snd_pcm_runtime *runtime;
1441 struct list_head *pos; 1436 struct snd_pcm_substream *s;
1442 int result = 0; 1437 int result = 0;
1443 int i, num_drecs; 1438 int i, num_drecs;
1444 struct drain_rec *drec, drec_tmp, *d; 1439 struct drain_rec *drec, drec_tmp, *d;
@@ -1473,8 +1468,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1473 1468
1474 /* count only playback streams */ 1469 /* count only playback streams */
1475 num_drecs = 0; 1470 num_drecs = 0;
1476 snd_pcm_group_for_each(pos, substream) { 1471 snd_pcm_group_for_each_entry(s, substream) {
1477 struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos);
1478 runtime = s->runtime; 1472 runtime = s->runtime;
1479 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1473 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1480 d = &drec[num_drecs++]; 1474 d = &drec[num_drecs++];
@@ -1493,7 +1487,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1493 1487
1494 snd_pcm_stream_lock_irq(substream); 1488 snd_pcm_stream_lock_irq(substream);
1495 /* resume pause */ 1489 /* resume pause */
1496 if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) 1490 if (substream->runtime->status->state == SNDRV_PCM_STATE_PAUSED)
1497 snd_pcm_pause(substream, 0); 1491 snd_pcm_pause(substream, 0);
1498 1492
1499 /* pre-start/stop - all running streams are changed to DRAINING state */ 1493 /* pre-start/stop - all running streams are changed to DRAINING state */
@@ -1674,7 +1668,7 @@ static void relink_to_local(struct snd_pcm_substream *substream)
1674 1668
1675static int snd_pcm_unlink(struct snd_pcm_substream *substream) 1669static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1676{ 1670{
1677 struct list_head *pos; 1671 struct snd_pcm_substream *s;
1678 int res = 0; 1672 int res = 0;
1679 1673
1680 down_write(&snd_pcm_link_rwsem); 1674 down_write(&snd_pcm_link_rwsem);
@@ -1686,8 +1680,8 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1686 list_del(&substream->link_list); 1680 list_del(&substream->link_list);
1687 substream->group->count--; 1681 substream->group->count--;
1688 if (substream->group->count == 1) { /* detach the last stream, too */ 1682 if (substream->group->count == 1) { /* detach the last stream, too */
1689 snd_pcm_group_for_each(pos, substream) { 1683 snd_pcm_group_for_each_entry(s, substream) {
1690 relink_to_local(snd_pcm_group_substream_entry(pos)); 1684 relink_to_local(s);
1691 break; 1685 break;
1692 } 1686 }
1693 kfree(substream->group); 1687 kfree(substream->group);
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c
index 9f7b32e1ccd..7cd5e8f5d4c 100644
--- a/sound/core/rtctimer.c
+++ b/sound/core/rtctimer.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/log2.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/timer.h> 29#include <sound/timer.h>
29 30
@@ -129,7 +130,7 @@ static int __init rtctimer_init(void)
129 struct snd_timer *timer; 130 struct snd_timer *timer;
130 131
131 if (rtctimer_freq < 2 || rtctimer_freq > 8192 || 132 if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
132 (rtctimer_freq & (rtctimer_freq - 1)) != 0) { 133 !is_power_of_2(rtctimer_freq)) {
133 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", 134 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n",
134 rtctimer_freq); 135 rtctimer_freq);
135 return -EINVAL; 136 return -EINVAL;
diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c
index f30d171b6d9..5efe6523a58 100644
--- a/sound/core/seq/seq_instr.c
+++ b/sound/core/seq/seq_instr.c
@@ -109,7 +109,7 @@ void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list_ptr)
109 spin_lock_irqsave(&list->lock, flags); 109 spin_lock_irqsave(&list->lock, flags);
110 while (instr->use) { 110 while (instr->use) {
111 spin_unlock_irqrestore(&list->lock, flags); 111 spin_unlock_irqrestore(&list->lock, flags);
112 schedule_timeout_interruptible(1); 112 schedule_timeout(1);
113 spin_lock_irqsave(&list->lock, flags); 113 spin_lock_irqsave(&list->lock, flags);
114 } 114 }
115 spin_unlock_irqrestore(&list->lock, flags); 115 spin_unlock_irqrestore(&list->lock, flags);
@@ -199,7 +199,7 @@ int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list,
199 instr = flist; 199 instr = flist;
200 flist = instr->next; 200 flist = instr->next;
201 while (instr->use) 201 while (instr->use)
202 schedule_timeout_interruptible(1); 202 schedule_timeout(1);
203 if (snd_seq_instr_free(instr, atomic)<0) 203 if (snd_seq_instr_free(instr, atomic)<0)
204 snd_printk(KERN_WARNING "instrument free problem\n"); 204 snd_printk(KERN_WARNING "instrument free problem\n");
205 instr = next; 205 instr = next;
@@ -555,7 +555,7 @@ static int instr_free(struct snd_seq_kinstr_ops *ops,
555 SNDRV_SEQ_INSTR_NOTIFY_REMOVE); 555 SNDRV_SEQ_INSTR_NOTIFY_REMOVE);
556 while (instr->use) { 556 while (instr->use) {
557 spin_unlock_irqrestore(&list->lock, flags); 557 spin_unlock_irqrestore(&list->lock, flags);
558 schedule_timeout_interruptible(1); 558 schedule_timeout(1);
559 spin_lock_irqsave(&list->lock, flags); 559 spin_lock_irqsave(&list->lock, flags);
560 } 560 }
561 spin_unlock_irqrestore(&list->lock, flags); 561 spin_unlock_irqrestore(&list->lock, flags);
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 061a7c61402..e11790f6deb 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -363,7 +363,7 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev)
363 if (rdev->client >= 0) 363 if (rdev->client >= 0)
364 return 0; 364 return 0;
365 365
366 pinfo = kmalloc(sizeof(*pinfo), GFP_KERNEL); 366 pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL);
367 if (!pinfo) { 367 if (!pinfo) {
368 err = -ENOMEM; 368 err = -ENOMEM;
369 goto __error; 369 goto __error;
@@ -380,7 +380,6 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev)
380 rdev->client = client; 380 rdev->client = client;
381 381
382 /* create a port */ 382 /* create a port */
383 memset(pinfo, 0, sizeof(*pinfo));
384 pinfo->addr.client = client; 383 pinfo->addr.client = client;
385 sprintf(pinfo->name, "VirMIDI %d-%d", rdev->card->number, rdev->device); 384 sprintf(pinfo->name, "VirMIDI %d-%d", rdev->card->number, rdev->device);
386 /* set all capabilities */ 385 /* set all capabilities */
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 70600df94d6..8dc7a3b32b9 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -446,8 +446,7 @@ static void __exit alsa_sound_exit(void)
446{ 446{
447 snd_info_minor_unregister(); 447 snd_info_minor_unregister();
448 snd_info_done(); 448 snd_info_done();
449 if (unregister_chrdev(major, "alsa") != 0) 449 unregister_chrdev(major, "alsa");
450 snd_printk(KERN_ERR "unable to unregister major device number %d\n", major);
451} 450}
452 451
453module_init(alsa_sound_init) 452module_init(alsa_sound_init)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 67520b3c004..f2bbacedd56 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1549,9 +1549,11 @@ static int snd_timer_user_info(struct file *file,
1549 int err = 0; 1549 int err = 0;
1550 1550
1551 tu = file->private_data; 1551 tu = file->private_data;
1552 snd_assert(tu->timeri != NULL, return -ENXIO); 1552 if (!tu->timeri)
1553 return -EBADFD;
1553 t = tu->timeri->timer; 1554 t = tu->timeri->timer;
1554 snd_assert(t != NULL, return -ENXIO); 1555 if (!t)
1556 return -EBADFD;
1555 1557
1556 info = kzalloc(sizeof(*info), GFP_KERNEL); 1558 info = kzalloc(sizeof(*info), GFP_KERNEL);
1557 if (! info) 1559 if (! info)
@@ -1579,9 +1581,11 @@ static int snd_timer_user_params(struct file *file,
1579 int err; 1581 int err;
1580 1582
1581 tu = file->private_data; 1583 tu = file->private_data;
1582 snd_assert(tu->timeri != NULL, return -ENXIO); 1584 if (!tu->timeri)
1585 return -EBADFD;
1583 t = tu->timeri->timer; 1586 t = tu->timeri->timer;
1584 snd_assert(t != NULL, return -ENXIO); 1587 if (!t)
1588 return -EBADFD;
1585 if (copy_from_user(&params, _params, sizeof(params))) 1589 if (copy_from_user(&params, _params, sizeof(params)))
1586 return -EFAULT; 1590 return -EFAULT;
1587 if (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE) && params.ticks < 1) { 1591 if (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE) && params.ticks < 1) {
@@ -1675,7 +1679,8 @@ static int snd_timer_user_status(struct file *file,
1675 struct snd_timer_status status; 1679 struct snd_timer_status status;
1676 1680
1677 tu = file->private_data; 1681 tu = file->private_data;
1678 snd_assert(tu->timeri != NULL, return -ENXIO); 1682 if (!tu->timeri)
1683 return -EBADFD;
1679 memset(&status, 0, sizeof(status)); 1684 memset(&status, 0, sizeof(status));
1680 status.tstamp = tu->tstamp; 1685 status.tstamp = tu->tstamp;
1681 status.resolution = snd_timer_resolution(tu->timeri); 1686 status.resolution = snd_timer_resolution(tu->timeri);
@@ -1695,7 +1700,8 @@ static int snd_timer_user_start(struct file *file)
1695 struct snd_timer_user *tu; 1700 struct snd_timer_user *tu;
1696 1701
1697 tu = file->private_data; 1702 tu = file->private_data;
1698 snd_assert(tu->timeri != NULL, return -ENXIO); 1703 if (!tu->timeri)
1704 return -EBADFD;
1699 snd_timer_stop(tu->timeri); 1705 snd_timer_stop(tu->timeri);
1700 tu->timeri->lost = 0; 1706 tu->timeri->lost = 0;
1701 tu->last_resolution = 0; 1707 tu->last_resolution = 0;
@@ -1708,7 +1714,8 @@ static int snd_timer_user_stop(struct file *file)
1708 struct snd_timer_user *tu; 1714 struct snd_timer_user *tu;
1709 1715
1710 tu = file->private_data; 1716 tu = file->private_data;
1711 snd_assert(tu->timeri != NULL, return -ENXIO); 1717 if (!tu->timeri)
1718 return -EBADFD;
1712 return (err = snd_timer_stop(tu->timeri)) < 0 ? err : 0; 1719 return (err = snd_timer_stop(tu->timeri)) < 0 ? err : 0;
1713} 1720}
1714 1721
@@ -1718,7 +1725,8 @@ static int snd_timer_user_continue(struct file *file)
1718 struct snd_timer_user *tu; 1725 struct snd_timer_user *tu;
1719 1726
1720 tu = file->private_data; 1727 tu = file->private_data;
1721 snd_assert(tu->timeri != NULL, return -ENXIO); 1728 if (!tu->timeri)
1729 return -EBADFD;
1722 tu->timeri->lost = 0; 1730 tu->timeri->lost = 0;
1723 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; 1731 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0;
1724} 1732}
@@ -1729,7 +1737,8 @@ static int snd_timer_user_pause(struct file *file)
1729 struct snd_timer_user *tu; 1737 struct snd_timer_user *tu;
1730 1738
1731 tu = file->private_data; 1739 tu = file->private_data;
1732 snd_assert(tu->timeri != NULL, return -ENXIO); 1740 if (!tu->timeri)
1741 return -EBADFD;
1733 return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0; 1742 return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0;
1734} 1743}
1735 1744
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a0f28f51fc7..4360ae9de19 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -659,7 +659,7 @@ static struct platform_driver snd_dummy_driver = {
659 }, 659 },
660}; 660};
661 661
662static void __init_or_module snd_dummy_unregister_all(void) 662static void snd_dummy_unregister_all(void)
663{ 663{
664 int i; 664 int i;
665 665
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index 2de181ad0b0..67c6e974541 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -42,6 +42,7 @@ static int pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
42#endif 42#endif
43static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ 43static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */
44static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ 44static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */
45static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
45 46
46module_param_array(index, int, NULL, 0444); 47module_param_array(index, int, NULL, 0444);
47MODULE_PARM_DESC(index, "Index value for MPU-401 device."); 48MODULE_PARM_DESC(index, "Index value for MPU-401 device.");
@@ -57,6 +58,8 @@ module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for MPU-401 device."); 58MODULE_PARM_DESC(port, "Port # for MPU-401 device.");
58module_param_array(irq, int, NULL, 0444); 59module_param_array(irq, int, NULL, 0444);
59MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); 60MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
61module_param_array(uart_enter, bool, NULL, 0444);
62MODULE_PARM_DESC(uart_enter, "Issue UART_ENTER command at open.");
60 63
61static struct platform_device *platform_devices[SNDRV_CARDS]; 64static struct platform_device *platform_devices[SNDRV_CARDS];
62static int pnp_registered; 65static int pnp_registered;
@@ -80,10 +83,11 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
80 strcat(card->longname, "polled"); 83 strcat(card->longname, "polled");
81 } 84 }
82 85
83 if ((err = snd_mpu401_uart_new(card, 0, 86 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev],
84 MPU401_HW_MPU401, 87 uart_enter[dev] ? 0 : MPU401_INFO_UART_ONLY,
85 port[dev], 0, 88 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0,
86 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) { 89 NULL);
90 if (err < 0) {
87 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); 91 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
88 goto _err; 92 goto _err;
89 } 93 }
@@ -224,7 +228,7 @@ static struct pnp_driver snd_mpu401_pnp_driver = {
224static struct pnp_driver snd_mpu401_pnp_driver; 228static struct pnp_driver snd_mpu401_pnp_driver;
225#endif 229#endif
226 230
227static void __init_or_module snd_mpu401_unregister_all(void) 231static void snd_mpu401_unregister_all(void)
228{ 232{
229 int i; 233 int i;
230 234
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 3daa9fa56c0..85aedc348e2 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -266,6 +266,16 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
266 return 0; 266 return 0;
267} 267}
268 268
269static int snd_mpu401_do_reset(struct snd_mpu401 *mpu)
270{
271 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
272 return -EIO;
273 if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) &&
274 snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
275 return -EIO;
276 return 0;
277}
278
269/* 279/*
270 * input/output open/close - protected by open_mutex in rawmidi.c 280 * input/output open/close - protected by open_mutex in rawmidi.c
271 */ 281 */
@@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream)
278 if (mpu->open_input && (err = mpu->open_input(mpu)) < 0) 288 if (mpu->open_input && (err = mpu->open_input(mpu)) < 0)
279 return err; 289 return err;
280 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) { 290 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) {
281 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) 291 if (snd_mpu401_do_reset(mpu) < 0)
282 goto error_out;
283 if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
284 goto error_out; 292 goto error_out;
285 } 293 }
286 mpu->substream_input = substream; 294 mpu->substream_input = substream;
@@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream)
302 if (mpu->open_output && (err = mpu->open_output(mpu)) < 0) 310 if (mpu->open_output && (err = mpu->open_output(mpu)) < 0)
303 return err; 311 return err;
304 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { 312 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
305 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) 313 if (snd_mpu401_do_reset(mpu) < 0)
306 goto error_out;
307 if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
308 goto error_out; 314 goto error_out;
309 } 315 }
310 mpu->substream_output = substream; 316 mpu->substream_output = substream;
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index 6c9f4c9bfeb..2025db5947a 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -892,13 +892,13 @@ static void __devinit snd_mts64_attach(struct parport *p)
892 struct platform_device *device; 892 struct platform_device *device;
893 893
894 device = platform_device_alloc(PLATFORM_DRIVER, device_count); 894 device = platform_device_alloc(PLATFORM_DRIVER, device_count);
895 if (!device) 895 if (!device)
896 return; 896 return;
897 897
898 /* Temporary assignment to forward the parport */ 898 /* Temporary assignment to forward the parport */
899 platform_set_drvdata(device, p); 899 platform_set_drvdata(device, p);
900 900
901 if (platform_device_register(device) < 0) { 901 if (platform_device_add(device) < 0) {
902 platform_device_put(device); 902 platform_device_put(device);
903 return; 903 return;
904 } 904 }
@@ -1048,7 +1048,7 @@ static struct platform_driver snd_mts64_driver = {
1048/********************************************************************* 1048/*********************************************************************
1049 * module init stuff 1049 * module init stuff
1050 *********************************************************************/ 1050 *********************************************************************/
1051static void __init_or_module snd_mts64_unregister_all(void) 1051static void snd_mts64_unregister_all(void)
1052{ 1052{
1053 int i; 1053 int i;
1054 1054
diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
index b2d0ba4bd18..0eb9b5cebfc 100644
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -676,13 +676,13 @@ static void __devinit snd_portman_attach(struct parport *p)
676 struct platform_device *device; 676 struct platform_device *device;
677 677
678 device = platform_device_alloc(PLATFORM_DRIVER, device_count); 678 device = platform_device_alloc(PLATFORM_DRIVER, device_count);
679 if (!device) 679 if (!device)
680 return; 680 return;
681 681
682 /* Temporary assignment to forward the parport */ 682 /* Temporary assignment to forward the parport */
683 platform_set_drvdata(device, p); 683 platform_set_drvdata(device, p);
684 684
685 if (platform_device_register(device) < 0) { 685 if (platform_device_add(device) < 0) {
686 platform_device_put(device); 686 platform_device_put(device);
687 return; 687 return;
688 } 688 }
@@ -833,7 +833,7 @@ static struct platform_driver snd_portman_driver = {
833/********************************************************************* 833/*********************************************************************
834 * module init stuff 834 * module init stuff
835 *********************************************************************/ 835 *********************************************************************/
836static void __init_or_module snd_portman_unregister_all(void) 836static void snd_portman_unregister_all(void)
837{ 837{
838 int i; 838 int i;
839 839
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 838a4277929..d3e6a20edd3 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -998,7 +998,7 @@ static struct platform_driver snd_serial_driver = {
998 }, 998 },
999}; 999};
1000 1000
1001static void __init_or_module snd_serial_unregister_all(void) 1001static void snd_serial_unregister_all(void)
1002{ 1002{
1003 int i; 1003 int i;
1004 1004
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
index 46f3d348606..915c86773c2 100644
--- a/sound/drivers/virmidi.c
+++ b/sound/drivers/virmidi.c
@@ -145,7 +145,7 @@ static struct platform_driver snd_virmidi_driver = {
145 }, 145 },
146}; 146};
147 147
148static void __init_or_module snd_virmidi_unregister_all(void) 148static void snd_virmidi_unregister_all(void)
149{ 149{
150 int i; 150 int i;
151 151
diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c
index e1920af4501..9a8154c9416 100644
--- a/sound/drivers/vx/vx_hwdep.c
+++ b/sound/drivers/vx/vx_hwdep.c
@@ -30,6 +30,20 @@
30 30
31#ifdef SND_VX_FW_LOADER 31#ifdef SND_VX_FW_LOADER
32 32
33MODULE_FIRMWARE("vx/bx_1_vxp.b56");
34MODULE_FIRMWARE("vx/bx_1_vp4.b56");
35MODULE_FIRMWARE("vx/x1_1_vx2.xlx");
36MODULE_FIRMWARE("vx/x1_2_v22.xlx");
37MODULE_FIRMWARE("vx/x1_1_vxp.xlx");
38MODULE_FIRMWARE("vx/x1_1_vp4.xlx");
39MODULE_FIRMWARE("vx/bd56002.boot");
40MODULE_FIRMWARE("vx/bd563v2.boot");
41MODULE_FIRMWARE("vx/bd563s3.boot");
42MODULE_FIRMWARE("vx/l_1_vx2.d56");
43MODULE_FIRMWARE("vx/l_1_v22.d56");
44MODULE_FIRMWARE("vx/l_1_vxp.d56");
45MODULE_FIRMWARE("vx/l_1_vp4.d56");
46
33int snd_vx_setup_firmware(struct vx_core *chip) 47int snd_vx_setup_firmware(struct vx_core *chip)
34{ 48{
35 static char *fw_files[VX_TYPE_NUMS][4] = { 49 static char *fw_files[VX_TYPE_NUMS][4] = {
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index adbfd5884d0..1efb973137a 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -36,6 +36,7 @@ MODULE_LICENSE("GPL");
36#define AK4114_ADDR 0x00 /* fixed address */ 36#define AK4114_ADDR 0x00 /* fixed address */
37 37
38static void ak4114_stats(struct work_struct *work); 38static void ak4114_stats(struct work_struct *work);
39static void ak4114_init_regs(struct ak4114 *chip);
39 40
40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val) 41static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val)
41{ 42{
@@ -105,7 +106,7 @@ int snd_ak4114_create(struct snd_card *card,
105 for (reg = 0; reg < 5; reg++) 106 for (reg = 0; reg < 5; reg++)
106 chip->txcsb[reg] = txcsb[reg]; 107 chip->txcsb[reg] = txcsb[reg];
107 108
108 snd_ak4114_reinit(chip); 109 ak4114_init_regs(chip);
109 110
110 chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT); 111 chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
111 chip->rcs1 = reg_read(chip, AK4114_REG_RCS1); 112 chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);
@@ -131,13 +132,10 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char
131 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val); 132 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val);
132} 133}
133 134
134void snd_ak4114_reinit(struct ak4114 *chip) 135static void ak4114_init_regs(struct ak4114 *chip)
135{ 136{
136 unsigned char old = chip->regmap[AK4114_REG_PWRDN], reg; 137 unsigned char old = chip->regmap[AK4114_REG_PWRDN], reg;
137 138
138 chip->init = 1;
139 mb();
140 flush_scheduled_work();
141 /* bring the chip to reset state and powerdown state */ 139 /* bring the chip to reset state and powerdown state */
142 reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN)); 140 reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN));
143 udelay(200); 141 udelay(200);
@@ -150,9 +148,18 @@ void snd_ak4114_reinit(struct ak4114 *chip)
150 reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]); 148 reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]);
151 /* release powerdown, everything is initialized now */ 149 /* release powerdown, everything is initialized now */
152 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN); 150 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN);
151}
152
153void snd_ak4114_reinit(struct ak4114 *chip)
154{
155 chip->init = 1;
156 mb();
157 flush_scheduled_work();
158 ak4114_init_regs(chip);
153 /* bring up statistics / event queing */ 159 /* bring up statistics / event queing */
154 chip->init = 0; 160 chip->init = 0;
155 schedule_delayed_work(&chip->work, HZ / 10); 161 if (chip->kctls[0])
162 schedule_delayed_work(&chip->work, HZ / 10);
156} 163}
157 164
158static unsigned int external_rate(unsigned char rcs1) 165static unsigned int external_rate(unsigned char rcs1)
@@ -428,7 +435,7 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
428 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 435 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
429 .info = snd_ak4114_in_bit_info, 436 .info = snd_ak4114_in_bit_info,
430 .get = snd_ak4114_in_bit_get, 437 .get = snd_ak4114_in_bit_get,
431 .private_value = (6<<8) | AK4114_REG_RCS1, 438 .private_value = (6<<8) | AK4114_REG_RCS0,
432}, 439},
433{ 440{
434 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 441 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -436,7 +443,15 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
436 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 443 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
437 .info = snd_ak4114_in_bit_info, 444 .info = snd_ak4114_in_bit_info,
438 .get = snd_ak4114_in_bit_get, 445 .get = snd_ak4114_in_bit_get,
439 .private_value = (3<<8) | AK4114_REG_RCS1, 446 .private_value = (3<<8) | AK4114_REG_RCS0,
447},
448{
449 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
450 .name = "IEC958 PPL Lock Status",
451 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
452 .info = snd_ak4114_in_bit_info,
453 .get = snd_ak4114_in_bit_get,
454 .private_value = (1<<31) | (4<<8) | AK4114_REG_RCS0,
440} 455}
441}; 456};
442 457
@@ -455,7 +470,7 @@ int snd_ak4114_build(struct ak4114 *ak4114,
455 kctl = snd_ctl_new1(&snd_ak4114_iec958_controls[idx], ak4114); 470 kctl = snd_ctl_new1(&snd_ak4114_iec958_controls[idx], ak4114);
456 if (kctl == NULL) 471 if (kctl == NULL)
457 return -ENOMEM; 472 return -ENOMEM;
458 if (!strstr(kctl->id.name, "Playback")) { 473 if (strstr(kctl->id.name, "Playback")) {
459 if (ply_substream == NULL) { 474 if (ply_substream == NULL) {
460 snd_ctl_free_one(kctl); 475 snd_ctl_free_one(kctl);
461 ak4114->kctls[idx] = NULL; 476 ak4114->kctls[idx] = NULL;
@@ -472,9 +487,58 @@ int snd_ak4114_build(struct ak4114 *ak4114,
472 return err; 487 return err;
473 ak4114->kctls[idx] = kctl; 488 ak4114->kctls[idx] = kctl;
474 } 489 }
490 /* trigger workq */
491 schedule_delayed_work(&ak4114->work, HZ / 10);
475 return 0; 492 return 0;
476} 493}
477 494
495/* notify kcontrols if any parameters are changed */
496static void ak4114_notify(struct ak4114 *ak4114,
497 unsigned char rcs0, unsigned char rcs1,
498 unsigned char c0, unsigned char c1)
499{
500 if (!ak4114->kctls[0])
501 return;
502
503 if (rcs0 & AK4114_PAR)
504 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
505 &ak4114->kctls[0]->id);
506 if (rcs0 & AK4114_V)
507 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
508 &ak4114->kctls[1]->id);
509 if (rcs1 & AK4114_CCRC)
510 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
511 &ak4114->kctls[2]->id);
512 if (rcs1 & AK4114_QCRC)
513 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
514 &ak4114->kctls[3]->id);
515
516 /* rate change */
517 if (c1 & 0xf0)
518 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
519 &ak4114->kctls[4]->id);
520
521 if ((c0 & AK4114_PEM) | (c0 & AK4114_CINT))
522 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
523 &ak4114->kctls[9]->id);
524 if (c0 & AK4114_QINT)
525 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
526 &ak4114->kctls[10]->id);
527
528 if (c0 & AK4114_AUDION)
529 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
530 &ak4114->kctls[11]->id);
531 if (c0 & AK4114_AUTO)
532 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
533 &ak4114->kctls[12]->id);
534 if (c0 & AK4114_DTSCD)
535 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
536 &ak4114->kctls[13]->id);
537 if (c0 & AK4114_UNLCK)
538 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
539 &ak4114->kctls[14]->id);
540}
541
478int snd_ak4114_external_rate(struct ak4114 *ak4114) 542int snd_ak4114_external_rate(struct ak4114 *ak4114)
479{ 543{
480 unsigned char rcs1; 544 unsigned char rcs1;
@@ -511,31 +575,7 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
511 ak4114->rcs1 = rcs1; 575 ak4114->rcs1 = rcs1;
512 spin_unlock_irqrestore(&ak4114->lock, _flags); 576 spin_unlock_irqrestore(&ak4114->lock, _flags);
513 577
514 if (rcs0 & AK4114_PAR) 578 ak4114_notify(ak4114, rcs0, rcs1, c0, c1);
515 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[0]->id);
516 if (rcs0 & AK4114_V)
517 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[1]->id);
518 if (rcs1 & AK4114_CCRC)
519 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[2]->id);
520 if (rcs1 & AK4114_QCRC)
521 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[3]->id);
522
523 /* rate change */
524 if (c1 & 0xf0)
525 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[4]->id);
526
527 if ((c0 & AK4114_PEM) | (c0 & AK4114_CINT))
528 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[9]->id);
529 if (c0 & AK4114_QINT)
530 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[10]->id);
531
532 if (c0 & AK4114_AUDION)
533 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[11]->id);
534 if (c0 & AK4114_AUTO)
535 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[12]->id);
536 if (c0 & AK4114_DTSCD)
537 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[13]->id);
538
539 if (ak4114->change_callback && (c0 | c1) != 0) 579 if (ak4114->change_callback && (c0 | c1) != 0)
540 ak4114->change_callback(ak4114, c0, c1); 580 ak4114->change_callback(ak4114, c0, c1);
541 581
@@ -558,9 +598,9 @@ static void ak4114_stats(struct work_struct *work)
558{ 598{
559 struct ak4114 *chip = container_of(work, struct ak4114, work.work); 599 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
560 600
561 if (chip->init) 601 if (!chip->init)
562 return; 602 snd_ak4114_check_rate_and_errors(chip, 0);
563 snd_ak4114_check_rate_and_errors(chip, 0); 603
564 schedule_delayed_work(&chip->work, HZ / 10); 604 schedule_delayed_work(&chip->work, HZ / 10);
565} 605}
566 606
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c
index 8805110017a..fd335159f84 100644
--- a/sound/i2c/other/ak4xxx-adda.c
+++ b/sound/i2c/other/ak4xxx-adda.c
@@ -481,8 +481,8 @@ static int ak4xxx_switch_get(struct snd_kcontrol *kcontrol,
481 int addr = AK_GET_ADDR(kcontrol->private_value); 481 int addr = AK_GET_ADDR(kcontrol->private_value);
482 int shift = AK_GET_SHIFT(kcontrol->private_value); 482 int shift = AK_GET_SHIFT(kcontrol->private_value);
483 int invert = AK_GET_INVERT(kcontrol->private_value); 483 int invert = AK_GET_INVERT(kcontrol->private_value);
484 unsigned char val = snd_akm4xxx_get(ak, chip, addr); 484 /* we observe the (1<<shift) bit only */
485 485 unsigned char val = snd_akm4xxx_get(ak, chip, addr) & (1<<shift);
486 if (invert) 486 if (invert)
487 val = ! val; 487 val = ! val;
488 ucontrol->value.integer.value[0] = (val & (1<<shift)) != 0; 488 ucontrol->value.integer.value[0] = (val & (1<<shift)) != 0;
@@ -585,6 +585,26 @@ static int build_dac_controls(struct snd_akm4xxx *ak)
585 585
586 mixer_ch = 0; 586 mixer_ch = 0;
587 for (idx = 0; idx < ak->num_dacs; ) { 587 for (idx = 0; idx < ak->num_dacs; ) {
588 /* mute control for Revolution 7.1 - AK4381 */
589 if (ak->type == SND_AK4381
590 && ak->dac_info[mixer_ch].switch_name) {
591 memset(&knew, 0, sizeof(knew));
592 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
593 knew.count = 1;
594 knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
595 knew.name = ak->dac_info[mixer_ch].switch_name;
596 knew.info = ak4xxx_switch_info;
597 knew.get = ak4xxx_switch_get;
598 knew.put = ak4xxx_switch_put;
599 knew.access = 0;
600 /* register 1, bit 0 (SMUTE): 0 = normal operation,
601 1 = mute */
602 knew.private_value =
603 AK_COMPOSE(idx/2, 1, 0, 0) | AK_INVERT;
604 err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
605 if (err < 0)
606 return err;
607 }
588 memset(&knew, 0, sizeof(knew)); 608 memset(&knew, 0, sizeof(knew));
589 if (! ak->dac_info || ! ak->dac_info[mixer_ch].name) { 609 if (! ak->dac_info || ! ak->dac_info[mixer_ch].name) {
590 knew.name = "DAC Volume"; 610 knew.name = "DAC Volume";
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 4e3a9729f56..ea5084abe60 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -1,8 +1,5 @@
1# ALSA ISA drivers 1# ALSA ISA drivers
2 2
3menu "ISA devices"
4 depends on SND!=n && ISA && ISA_DMA_API
5
6config SND_AD1848_LIB 3config SND_AD1848_LIB
7 tristate 4 tristate
8 select SND_PCM 5 select SND_PCM
@@ -11,6 +8,22 @@ config SND_CS4231_LIB
11 tristate 8 tristate
12 select SND_PCM 9 select SND_PCM
13 10
11config SND_SB_COMMON
12 tristate
13
14config SND_SB8_DSP
15 tristate
16 select SND_PCM
17 select SND_SB_COMMON
18
19config SND_SB16_DSP
20 tristate
21 select SND_PCM
22 select SND_SB_COMMON
23
24menu "ISA devices"
25 depends on SND!=n && ISA && ISA_DMA_API
26
14config SND_ADLIB 27config SND_ADLIB
15 tristate "AdLib FM card" 28 tristate "AdLib FM card"
16 depends on SND 29 depends on SND
@@ -55,7 +68,7 @@ config SND_ALS100
55 select ISAPNP 68 select ISAPNP
56 select SND_OPL3_LIB 69 select SND_OPL3_LIB
57 select SND_MPU401_UART 70 select SND_MPU401_UART
58 select SND_PCM 71 select SND_SB16_DSP
59 help 72 help
60 Say Y here to include support for soundcards based on Avance 73 Say Y here to include support for soundcards based on Avance
61 Logic ALS100, ALS110, ALS120 and ALS200 chips. 74 Logic ALS100, ALS110, ALS120 and ALS200 chips.
@@ -81,6 +94,7 @@ config SND_CMI8330
81 tristate "C-Media CMI8330" 94 tristate "C-Media CMI8330"
82 depends on SND 95 depends on SND
83 select SND_AD1848_LIB 96 select SND_AD1848_LIB
97 select SND_SB16_DSP
84 help 98 help
85 Say Y here to include support for soundcards based on the 99 Say Y here to include support for soundcards based on the
86 C-Media CMI8330 chip. 100 C-Media CMI8330 chip.
@@ -132,7 +146,7 @@ config SND_DT019X
132 select ISAPNP 146 select ISAPNP
133 select SND_OPL3_LIB 147 select SND_OPL3_LIB
134 select SND_MPU401_UART 148 select SND_MPU401_UART
135 select SND_PCM 149 select SND_SB16_DSP
136 help 150 help
137 Say Y here to include support for soundcards based on the 151 Say Y here to include support for soundcards based on the
138 Diamond Technologies DT-019X or Avance Logic ALS-007 chips. 152 Diamond Technologies DT-019X or Avance Logic ALS-007 chips.
@@ -145,7 +159,7 @@ config SND_ES968
145 depends on SND && PNP && ISA 159 depends on SND && PNP && ISA
146 select ISAPNP 160 select ISAPNP
147 select SND_MPU401_UART 161 select SND_MPU401_UART
148 select SND_PCM 162 select SND_SB8_DSP
149 help 163 help
150 Say Y here to include support for ESS AudioDrive ES968 chips. 164 Say Y here to include support for ESS AudioDrive ES968 chips.
151 165
@@ -321,7 +335,7 @@ config SND_SB8
321 depends on SND 335 depends on SND
322 select SND_OPL3_LIB 336 select SND_OPL3_LIB
323 select SND_RAWMIDI 337 select SND_RAWMIDI
324 select SND_PCM 338 select SND_SB8_DSP
325 help 339 help
326 Say Y here to include support for Creative Sound Blaster 1.0/ 340 Say Y here to include support for Creative Sound Blaster 1.0/
327 2.0/Pro (8-bit) or 100% compatible soundcards. 341 2.0/Pro (8-bit) or 100% compatible soundcards.
@@ -334,7 +348,7 @@ config SND_SB16
334 depends on SND 348 depends on SND
335 select SND_OPL3_LIB 349 select SND_OPL3_LIB
336 select SND_MPU401_UART 350 select SND_MPU401_UART
337 select SND_PCM 351 select SND_SB16_DSP
338 help 352 help
339 Say Y here to include support for Sound Blaster 16 soundcards 353 Say Y here to include support for Sound Blaster 16 soundcards
340 (including the Plug and Play version). 354 (including the Plug and Play version).
@@ -347,7 +361,7 @@ config SND_SBAWE
347 depends on SND 361 depends on SND
348 select SND_OPL3_LIB 362 select SND_OPL3_LIB
349 select SND_MPU401_UART 363 select SND_MPU401_UART
350 select SND_PCM 364 select SND_SB16_DSP
351 help 365 help
352 Say Y here to include support for Sound Blaster AWE soundcards 366 Say Y here to include support for Sound Blaster AWE soundcards
353 (including the Plug and Play version). 367 (including the Plug and Play version).
@@ -358,12 +372,21 @@ config SND_SBAWE
358config SND_SB16_CSP 372config SND_SB16_CSP
359 bool "Sound Blaster 16/AWE CSP support" 373 bool "Sound Blaster 16/AWE CSP support"
360 depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC) 374 depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC)
361 select FW_LOADER 375 select FW_LOADER if !SND_SB16_CSP_FIRMWARE_IN_KERNEL
362 help 376 help
363 Say Y here to include support for the CSP core. This special 377 Say Y here to include support for the CSP core. This special
364 coprocessor can do variable tasks like various compression and 378 coprocessor can do variable tasks like various compression and
365 decompression algorithms. 379 decompression algorithms.
366 380
381config SND_SB16_CSP_FIRMWARE_IN_KERNEL
382 bool "In-kernel firmware for SB16 CSP"
383 depends on SND_SB16_CSP
384 default y
385 help
386 Say Y here to include the static firmware built in the kernel
387 for the SB16 CSP controller. If you choose N here, you need
388 to install the firmware files from the alsa-firmware package.
389
367config SND_SGALAXY 390config SND_SGALAXY
368 tristate "Aztech Sound Galaxy" 391 tristate "Aztech Sound Galaxy"
369 depends on SND 392 depends on SND
@@ -391,7 +414,7 @@ config SND_SSCAPE
391config SND_WAVEFRONT 414config SND_WAVEFRONT
392 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" 415 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
393 depends on SND 416 depends on SND
394 select FW_LOADER 417 select FW_LOADER if !SND_WAVEFRONT_FIRMWARE_IN_KERNEL
395 select SND_OPL3_LIB 418 select SND_OPL3_LIB
396 select SND_MPU401_UART 419 select SND_MPU401_UART
397 select SND_CS4231_LIB 420 select SND_CS4231_LIB
@@ -402,4 +425,13 @@ config SND_WAVEFRONT
402 To compile this driver as a module, choose M here: the module 425 To compile this driver as a module, choose M here: the module
403 will be called snd-wavefront. 426 will be called snd-wavefront.
404 427
428config SND_WAVEFRONT_FIRMWARE_IN_KERNEL
429 bool "In-kernel firmware for Wavefront"
430 depends on SND_WAVEFRONT
431 default y
432 help
433 Say Y here to include the static firmware built in the kernel
434 for the Wavefront driver. If you choose N here, you need to
435 install the firmware files from the alsa-firmware package.
436
405endmenu 437endmenu
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 59034507175..fc88a31da6f 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -129,8 +129,8 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar
129 } 129 }
130 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); 130 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL);
131 if (acard->devmpu == NULL) { 131 if (acard->devmpu == NULL) {
132 kfree(cfg); 132 mpu_port[dev] = -1;
133 return -EBUSY; 133 snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n");
134 } 134 }
135 135
136 pdev = acard->dev; 136 pdev = acard->dev;
@@ -162,6 +162,10 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar
162 dma2[dev] = pnp_dma(pdev, 1); 162 dma2[dev] = pnp_dma(pdev, 1);
163 irq[dev] = pnp_irq(pdev, 0); 163 irq[dev] = pnp_irq(pdev, 0);
164 164
165 if (acard->devmpu == NULL) {
166 kfree(cfg);
167 return 0;
168 }
165 pdev = acard->devmpu; 169 pdev = acard->devmpu;
166 pnp_init_resource_table(cfg); 170 pnp_init_resource_table(cfg);
167 171
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 74e501dea8b..d09a7fa8654 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/time.h> 28#include <linux/time.h>
29#include <linux/wait.h> 29#include <linux/wait.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
@@ -32,8 +32,11 @@
32#include <sound/ad1848.h> 32#include <sound/ad1848.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34 34
35#define CRD_NAME "Generic AD1848/AD1847/CS4248"
36#define DEV_NAME "ad1848"
37
38MODULE_DESCRIPTION(CRD_NAME);
35MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("AD1848/AD1847/CS4248");
37MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
38MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848}," 41MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848},"
39 "{Analog Devices,AD1847}," 42 "{Analog Devices,AD1847},"
@@ -48,95 +51,98 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
48static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */ 51static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */
49 52
50module_param_array(index, int, NULL, 0444); 53module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for AD1848 soundcard."); 54MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
52module_param_array(id, charp, NULL, 0444); 55module_param_array(id, charp, NULL, 0444);
53MODULE_PARM_DESC(id, "ID string for AD1848 soundcard."); 56MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
54module_param_array(enable, bool, NULL, 0444); 57module_param_array(enable, bool, NULL, 0444);
55MODULE_PARM_DESC(enable, "Enable AD1848 soundcard."); 58MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
56module_param_array(port, long, NULL, 0444); 59module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for AD1848 driver."); 60MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
58module_param_array(irq, int, NULL, 0444); 61module_param_array(irq, int, NULL, 0444);
59MODULE_PARM_DESC(irq, "IRQ # for AD1848 driver."); 62MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
60module_param_array(dma1, int, NULL, 0444); 63module_param_array(dma1, int, NULL, 0444);
61MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); 64MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
62module_param_array(thinkpad, bool, NULL, 0444); 65module_param_array(thinkpad, bool, NULL, 0444);
63MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); 66MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
64 67
65static struct platform_device *devices[SNDRV_CARDS]; 68static int __devinit snd_ad1848_match(struct device *dev, unsigned int n)
69{
70 if (!enable[n])
71 return 0;
66 72
73 if (port[n] == SNDRV_AUTO_PORT) {
74 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
75 return 0;
76 }
77 if (irq[n] == SNDRV_AUTO_IRQ) {
78 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id);
79 return 0;
80 }
81 if (dma1[n] == SNDRV_AUTO_DMA) {
82 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id);
83 return 0;
84 }
85 return 1;
86}
67 87
68static int __devinit snd_ad1848_probe(struct platform_device *pdev) 88static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
69{ 89{
70 int dev = pdev->id;
71 struct snd_card *card; 90 struct snd_card *card;
72 struct snd_ad1848 *chip; 91 struct snd_ad1848 *chip;
73 struct snd_pcm *pcm; 92 struct snd_pcm *pcm;
74 int err; 93 int error;
75 94
76 if (port[dev] == SNDRV_AUTO_PORT) { 95 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
77 snd_printk(KERN_ERR "ad1848: specify port\n"); 96 if (!card)
78 return -EINVAL; 97 return -EINVAL;
79 }
80 if (irq[dev] == SNDRV_AUTO_IRQ) {
81 snd_printk(KERN_ERR "ad1848: specify irq\n");
82 return -EINVAL;
83 }
84 if (dma1[dev] == SNDRV_AUTO_DMA) {
85 snd_printk(KERN_ERR "ad1848: specify dma1\n");
86 return -EINVAL;
87 }
88 98
89 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 99 error = snd_ad1848_create(card, port[n], irq[n], dma1[n],
90 if (card == NULL) 100 thinkpad[n] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip);
91 return -ENOMEM; 101 if (error < 0)
102 goto out;
92 103
93 if ((err = snd_ad1848_create(card, port[dev],
94 irq[dev],
95 dma1[dev],
96 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT,
97 &chip)) < 0)
98 goto _err;
99 card->private_data = chip; 104 card->private_data = chip;
100 105
101 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) 106 error = snd_ad1848_pcm(chip, 0, &pcm);
102 goto _err; 107 if (error < 0)
108 goto out;
103 109
104 if ((err = snd_ad1848_mixer(chip)) < 0) 110 error = snd_ad1848_mixer(chip);
105 goto _err; 111 if (error < 0)
112 goto out;
106 113
107 strcpy(card->driver, "AD1848"); 114 strcpy(card->driver, "AD1848");
108 strcpy(card->shortname, pcm->name); 115 strcpy(card->shortname, pcm->name);
109 116
110 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 117 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
111 pcm->name, chip->port, irq[dev], dma1[dev]); 118 pcm->name, chip->port, irq[n], dma1[n]);
112 119 if (thinkpad[n])
113 if (thinkpad[dev])
114 strcat(card->longname, " [Thinkpad]"); 120 strcat(card->longname, " [Thinkpad]");
115 121
116 snd_card_set_dev(card, &pdev->dev); 122 snd_card_set_dev(card, dev);
117 123
118 if ((err = snd_card_register(card)) < 0) 124 error = snd_card_register(card);
119 goto _err; 125 if (error < 0)
126 goto out;
120 127
121 platform_set_drvdata(pdev, card); 128 dev_set_drvdata(dev, card);
122 return 0; 129 return 0;
123 130
124 _err: 131out: snd_card_free(card);
125 snd_card_free(card); 132 return error;
126 return err;
127} 133}
128 134
129static int __devexit snd_ad1848_remove(struct platform_device *devptr) 135static int __devexit snd_ad1848_remove(struct device *dev, unsigned int n)
130{ 136{
131 snd_card_free(platform_get_drvdata(devptr)); 137 snd_card_free(dev_get_drvdata(dev));
132 platform_set_drvdata(devptr, NULL); 138 dev_set_drvdata(dev, NULL);
133 return 0; 139 return 0;
134} 140}
135 141
136#ifdef CONFIG_PM 142#ifdef CONFIG_PM
137static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state) 143static int snd_ad1848_suspend(struct device *dev, unsigned int n, pm_message_t state)
138{ 144{
139 struct snd_card *card = platform_get_drvdata(pdev); 145 struct snd_card *card = dev_get_drvdata(dev);
140 struct snd_ad1848 *chip = card->private_data; 146 struct snd_ad1848 *chip = card->private_data;
141 147
142 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 148 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -144,9 +150,9 @@ static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state)
144 return 0; 150 return 0;
145} 151}
146 152
147static int snd_ad1848_resume(struct platform_device *pdev) 153static int snd_ad1848_resume(struct device *dev, unsigned int n)
148{ 154{
149 struct snd_card *card = platform_get_drvdata(pdev); 155 struct snd_card *card = dev_get_drvdata(dev);
150 struct snd_ad1848 *chip = card->private_data; 156 struct snd_ad1848 *chip = card->private_data;
151 157
152 chip->resume(chip); 158 chip->resume(chip);
@@ -155,9 +161,8 @@ static int snd_ad1848_resume(struct platform_device *pdev)
155} 161}
156#endif 162#endif
157 163
158#define SND_AD1848_DRIVER "snd_ad1848" 164static struct isa_driver snd_ad1848_driver = {
159 165 .match = snd_ad1848_match,
160static struct platform_driver snd_ad1848_driver = {
161 .probe = snd_ad1848_probe, 166 .probe = snd_ad1848_probe,
162 .remove = __devexit_p(snd_ad1848_remove), 167 .remove = __devexit_p(snd_ad1848_remove),
163#ifdef CONFIG_PM 168#ifdef CONFIG_PM
@@ -165,57 +170,19 @@ static struct platform_driver snd_ad1848_driver = {
165 .resume = snd_ad1848_resume, 170 .resume = snd_ad1848_resume,
166#endif 171#endif
167 .driver = { 172 .driver = {
168 .name = SND_AD1848_DRIVER 173 .name = DEV_NAME
169 }, 174 }
170}; 175};
171 176
172static void __init_or_module snd_ad1848_unregister_all(void)
173{
174 int i;
175
176 for (i = 0; i < ARRAY_SIZE(devices); ++i)
177 platform_device_unregister(devices[i]);
178 platform_driver_unregister(&snd_ad1848_driver);
179}
180
181static int __init alsa_card_ad1848_init(void) 177static int __init alsa_card_ad1848_init(void)
182{ 178{
183 int i, cards, err; 179 return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS);
184
185 err = platform_driver_register(&snd_ad1848_driver);
186 if (err < 0)
187 return err;
188
189 cards = 0;
190 for (i = 0; i < SNDRV_CARDS; i++) {
191 struct platform_device *device;
192 if (! enable[i])
193 continue;
194 device = platform_device_register_simple(SND_AD1848_DRIVER,
195 i, NULL, 0);
196 if (IS_ERR(device))
197 continue;
198 if (!platform_get_drvdata(device)) {
199 platform_device_unregister(device);
200 continue;
201 }
202 devices[i] = device;
203 cards++;
204 }
205 if (!cards) {
206#ifdef MODULE
207 printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
208#endif
209 snd_ad1848_unregister_all();
210 return -ENODEV;
211 }
212 return 0;
213} 180}
214 181
215static void __exit alsa_card_ad1848_exit(void) 182static void __exit alsa_card_ad1848_exit(void)
216{ 183{
217 snd_ad1848_unregister_all(); 184 isa_unregister_driver(&snd_ad1848_driver);
218} 185}
219 186
220module_init(alsa_card_ad1848_init) 187module_init(alsa_card_ad1848_init);
221module_exit(alsa_card_ad1848_exit) 188module_exit(alsa_card_ad1848_exit);
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 8094282c2ae..1bc2e3fd572 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -245,7 +245,7 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip)
245 snd_printk(KERN_ERR "mce_down - auto calibration time out (2)\n"); 245 snd_printk(KERN_ERR "mce_down - auto calibration time out (2)\n");
246 return; 246 return;
247 } 247 }
248 time = schedule_timeout_interruptible(time); 248 time = schedule_timeout(time);
249 spin_lock_irqsave(&chip->reg_lock, flags); 249 spin_lock_irqsave(&chip->reg_lock, flags);
250 } 250 }
251#if 0 251#if 0
@@ -258,7 +258,7 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip)
258 snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n"); 258 snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n");
259 return; 259 return;
260 } 260 }
261 time = schedule_timeout_interruptible(time); 261 time = schedule_timeout(time);
262 spin_lock_irqsave(&chip->reg_lock, flags); 262 spin_lock_irqsave(&chip->reg_lock, flags);
263 } 263 }
264 spin_unlock_irqrestore(&chip->reg_lock, flags); 264 spin_unlock_irqrestore(&chip->reg_lock, flags);
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index 1124344ed94..d68720724c9 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -5,13 +5,13 @@
5#include <sound/driver.h> 5#include <sound/driver.h>
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/platform_device.h> 8#include <linux/isa.h>
9#include <sound/core.h> 9#include <sound/core.h>
10#include <sound/initval.h> 10#include <sound/initval.h>
11#include <sound/opl3.h> 11#include <sound/opl3.h>
12 12
13#define CRD_NAME "AdLib FM" 13#define CRD_NAME "AdLib FM"
14#define DRV_NAME "snd_adlib" 14#define DEV_NAME "adlib"
15 15
16MODULE_DESCRIPTION(CRD_NAME); 16MODULE_DESCRIPTION(CRD_NAME);
17MODULE_AUTHOR("Rene Herman"); 17MODULE_AUTHOR("Rene Herman");
@@ -31,133 +31,99 @@ MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
31module_param_array(port, long, NULL, 0444); 31module_param_array(port, long, NULL, 0444);
32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); 32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
33 33
34static struct platform_device *devices[SNDRV_CARDS]; 34static int __devinit snd_adlib_match(struct device *dev, unsigned int n)
35{
36 if (!enable[n])
37 return 0;
38
39 if (port[n] == SNDRV_AUTO_PORT) {
40 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
41 return 0;
42 }
43 return 1;
44}
35 45
36static void snd_adlib_free(struct snd_card *card) 46static void snd_adlib_free(struct snd_card *card)
37{ 47{
38 release_and_free_resource(card->private_data); 48 release_and_free_resource(card->private_data);
39} 49}
40 50
41static int __devinit snd_adlib_probe(struct platform_device *device) 51static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
42{ 52{
43 struct snd_card *card; 53 struct snd_card *card;
44 struct snd_opl3 *opl3; 54 struct snd_opl3 *opl3;
55 int error;
45 56
46 int error, i = device->id; 57 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
47
48 if (port[i] == SNDRV_AUTO_PORT) {
49 snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
50 error = -EINVAL;
51 goto out0;
52 }
53
54 card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
55 if (!card) { 58 if (!card) {
56 snd_printk(KERN_ERR DRV_NAME ": could not create card\n"); 59 snd_printk(KERN_ERR "%s: could not create card\n", dev->bus_id);
57 error = -EINVAL; 60 return -EINVAL;
58 goto out0;
59 } 61 }
60 62
61 card->private_data = request_region(port[i], 4, CRD_NAME); 63 card->private_data = request_region(port[n], 4, CRD_NAME);
62 if (!card->private_data) { 64 if (!card->private_data) {
63 snd_printk(KERN_ERR DRV_NAME ": could not grab ports\n"); 65 snd_printk(KERN_ERR "%s: could not grab ports\n", dev->bus_id);
64 error = -EBUSY; 66 error = -EBUSY;
65 goto out1; 67 goto out;
66 } 68 }
67 card->private_free = snd_adlib_free; 69 card->private_free = snd_adlib_free;
68 70
69 error = snd_opl3_create(card, port[i], port[i] + 2, OPL3_HW_AUTO, 1, &opl3); 71 strcpy(card->driver, DEV_NAME);
72 strcpy(card->shortname, CRD_NAME);
73 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
74
75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
70 if (error < 0) { 76 if (error < 0) {
71 snd_printk(KERN_ERR DRV_NAME ": could not create OPL\n"); 77 snd_printk(KERN_ERR "%s: could not create OPL\n", dev->bus_id);
72 goto out1; 78 goto out;
73 } 79 }
74 80
75 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); 81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
76 if (error < 0) { 82 if (error < 0) {
77 snd_printk(KERN_ERR DRV_NAME ": could not create FM\n"); 83 snd_printk(KERN_ERR "%s: could not create FM\n", dev->bus_id);
78 goto out1; 84 goto out;
79 } 85 }
80 86
81 strcpy(card->driver, DRV_NAME); 87 snd_card_set_dev(card, dev);
82 strcpy(card->shortname, CRD_NAME);
83 sprintf(card->longname, CRD_NAME " at %#lx", port[i]);
84
85 snd_card_set_dev(card, &device->dev);
86 88
87 error = snd_card_register(card); 89 error = snd_card_register(card);
88 if (error < 0) { 90 if (error < 0) {
89 snd_printk(KERN_ERR DRV_NAME ": could not register card\n"); 91 snd_printk(KERN_ERR "%s: could not register card\n", dev->bus_id);
90 goto out1; 92 goto out;
91 } 93 }
92 94
93 platform_set_drvdata(device, card); 95 dev_set_drvdata(dev, card);
94 return 0; 96 return 0;
95 97
96out1: snd_card_free(card); 98out: snd_card_free(card);
97out0: return error; 99 return error;
98} 100}
99 101
100static int __devexit snd_adlib_remove(struct platform_device *device) 102static int __devexit snd_adlib_remove(struct device *dev, unsigned int n)
101{ 103{
102 snd_card_free(platform_get_drvdata(device)); 104 snd_card_free(dev_get_drvdata(dev));
103 platform_set_drvdata(device, NULL); 105 dev_set_drvdata(dev, NULL);
104 return 0; 106 return 0;
105} 107}
106 108
107static struct platform_driver snd_adlib_driver = { 109static struct isa_driver snd_adlib_driver = {
110 .match = snd_adlib_match,
108 .probe = snd_adlib_probe, 111 .probe = snd_adlib_probe,
109 .remove = __devexit_p(snd_adlib_remove), 112 .remove = __devexit_p(snd_adlib_remove),
110 113
111 .driver = { 114 .driver = {
112 .name = DRV_NAME 115 .name = DEV_NAME
113 } 116 }
114}; 117};
115 118
116static int __init alsa_card_adlib_init(void) 119static int __init alsa_card_adlib_init(void)
117{ 120{
118 int i, cards; 121 return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
119
120 if (platform_driver_register(&snd_adlib_driver) < 0) {
121 snd_printk(KERN_ERR DRV_NAME ": could not register driver\n");
122 return -ENODEV;
123 }
124
125 for (cards = 0, i = 0; i < SNDRV_CARDS; i++) {
126 struct platform_device *device;
127
128 if (!enable[i])
129 continue;
130
131 device = platform_device_register_simple(DRV_NAME, i, NULL, 0);
132 if (IS_ERR(device))
133 continue;
134
135 if (!platform_get_drvdata(device)) {
136 platform_device_unregister(device);
137 continue;
138 }
139
140 devices[i] = device;
141 cards++;
142 }
143
144 if (!cards) {
145#ifdef MODULE
146 printk(KERN_ERR CRD_NAME " soundcard not found or device busy\n");
147#endif
148 platform_driver_unregister(&snd_adlib_driver);
149 return -ENODEV;
150 }
151 return 0;
152} 122}
153 123
154static void __exit alsa_card_adlib_exit(void) 124static void __exit alsa_card_adlib_exit(void)
155{ 125{
156 int i; 126 isa_unregister_driver(&snd_adlib_driver);
157
158 for (i = 0; i < SNDRV_CARDS; i++)
159 platform_device_unregister(devices[i]);
160 platform_driver_unregister(&snd_adlib_driver);
161} 127}
162 128
163module_init(alsa_card_adlib_init); 129module_init(alsa_card_adlib_init);
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index c09a8009d2f..f471f8ad688 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -46,7 +46,7 @@
46#include <sound/driver.h> 46#include <sound/driver.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/platform_device.h> 49#include <linux/isa.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/pnp.h> 51#include <linux/pnp.h>
52#include <linux/moduleparam.h> 52#include <linux/moduleparam.h>
@@ -108,8 +108,8 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver.");
108module_param_array(wssdma, int, NULL, 0444); 108module_param_array(wssdma, int, NULL, 0444);
109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
110 110
111static struct platform_device *platform_devices[SNDRV_CARDS];
112#ifdef CONFIG_PNP 111#ifdef CONFIG_PNP
112static int isa_registered;
113static int pnp_registered; 113static int pnp_registered;
114#endif 114#endif
115 115
@@ -547,70 +547,78 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
547 return snd_card_register(card); 547 return snd_card_register(card);
548} 548}
549 549
550static int __devinit snd_cmi8330_nonpnp_probe(struct platform_device *pdev) 550static int __devinit snd_cmi8330_isa_match(struct device *pdev,
551 unsigned int dev)
551{ 552{
552 struct snd_card *card; 553 if (!enable[dev] || is_isapnp_selected(dev))
553 int err; 554 return 0;
554 int dev = pdev->id;
555
556 if (wssport[dev] == SNDRV_AUTO_PORT) { 555 if (wssport[dev] == SNDRV_AUTO_PORT) {
557 snd_printk(KERN_ERR PFX "specify wssport\n"); 556 snd_printk(KERN_ERR PFX "specify wssport\n");
558 return -EINVAL; 557 return 0;
559 } 558 }
560 if (sbport[dev] == SNDRV_AUTO_PORT) { 559 if (sbport[dev] == SNDRV_AUTO_PORT) {
561 snd_printk(KERN_ERR PFX "specify sbport\n"); 560 snd_printk(KERN_ERR PFX "specify sbport\n");
562 return -EINVAL; 561 return 0;
563 } 562 }
563 return 1;
564}
565
566static int __devinit snd_cmi8330_isa_probe(struct device *pdev,
567 unsigned int dev)
568{
569 struct snd_card *card;
570 int err;
564 571
565 card = snd_cmi8330_card_new(dev); 572 card = snd_cmi8330_card_new(dev);
566 if (! card) 573 if (! card)
567 return -ENOMEM; 574 return -ENOMEM;
568 snd_card_set_dev(card, &pdev->dev); 575 snd_card_set_dev(card, pdev);
569 if ((err = snd_cmi8330_probe(card, dev)) < 0) { 576 if ((err = snd_cmi8330_probe(card, dev)) < 0) {
570 snd_card_free(card); 577 snd_card_free(card);
571 return err; 578 return err;
572 } 579 }
573 platform_set_drvdata(pdev, card); 580 dev_set_drvdata(pdev, card);
574 return 0; 581 return 0;
575} 582}
576 583
577static int __devexit snd_cmi8330_nonpnp_remove(struct platform_device *devptr) 584static int __devexit snd_cmi8330_isa_remove(struct device *devptr,
585 unsigned int dev)
578{ 586{
579 snd_card_free(platform_get_drvdata(devptr)); 587 snd_card_free(dev_get_drvdata(devptr));
580 platform_set_drvdata(devptr, NULL); 588 dev_set_drvdata(devptr, NULL);
581 return 0; 589 return 0;
582} 590}
583 591
584#ifdef CONFIG_PM 592#ifdef CONFIG_PM
585static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 593static int snd_cmi8330_isa_suspend(struct device *dev, unsigned int n,
594 pm_message_t state)
586{ 595{
587 return snd_cmi8330_suspend(platform_get_drvdata(dev)); 596 return snd_cmi8330_suspend(dev_get_drvdata(dev));
588} 597}
589 598
590static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) 599static int snd_cmi8330_isa_resume(struct device *dev, unsigned int n)
591{ 600{
592 return snd_cmi8330_resume(platform_get_drvdata(dev)); 601 return snd_cmi8330_resume(dev_get_drvdata(dev));
593} 602}
594#endif 603#endif
595 604
596#define CMI8330_DRIVER "snd_cmi8330" 605#define DEV_NAME "cmi8330"
597 606
598static struct platform_driver snd_cmi8330_driver = { 607static struct isa_driver snd_cmi8330_driver = {
599 .probe = snd_cmi8330_nonpnp_probe, 608 .match = snd_cmi8330_isa_match,
600 .remove = __devexit_p(snd_cmi8330_nonpnp_remove), 609 .probe = snd_cmi8330_isa_probe,
610 .remove = __devexit_p(snd_cmi8330_isa_remove),
601#ifdef CONFIG_PM 611#ifdef CONFIG_PM
602 .suspend = snd_cmi8330_nonpnp_suspend, 612 .suspend = snd_cmi8330_isa_suspend,
603 .resume = snd_cmi8330_nonpnp_resume, 613 .resume = snd_cmi8330_isa_resume,
604#endif 614#endif
605 .driver = { 615 .driver = {
606 .name = CMI8330_DRIVER 616 .name = DEV_NAME
607 }, 617 },
608}; 618};
609 619
610 620
611#ifdef CONFIG_PNP 621#ifdef CONFIG_PNP
612static unsigned int __devinitdata cmi8330_pnp_devices;
613
614static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, 622static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
615 const struct pnp_card_device_id *pid) 623 const struct pnp_card_device_id *pid)
616{ 624{
@@ -640,7 +648,6 @@ static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
640 } 648 }
641 pnp_set_card_drvdata(pcard, card); 649 pnp_set_card_drvdata(pcard, card);
642 dev++; 650 dev++;
643 cmi8330_pnp_devices++;
644 return 0; 651 return 0;
645} 652}
646 653
@@ -675,63 +682,34 @@ static struct pnp_card_driver cmi8330_pnpc_driver = {
675}; 682};
676#endif /* CONFIG_PNP */ 683#endif /* CONFIG_PNP */
677 684
678static void __init_or_module snd_cmi8330_unregister_all(void)
679{
680 int i;
681
682#ifdef CONFIG_PNP
683 if (pnp_registered)
684 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
685#endif
686 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
687 platform_device_unregister(platform_devices[i]);
688 platform_driver_unregister(&snd_cmi8330_driver);
689}
690
691static int __init alsa_card_cmi8330_init(void) 685static int __init alsa_card_cmi8330_init(void)
692{ 686{
693 int i, err, cards = 0; 687 int err;
694
695 if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0)
696 return err;
697
698 for (i = 0; i < SNDRV_CARDS; i++) {
699 struct platform_device *device;
700 if (! enable[i] || is_isapnp_selected(i))
701 continue;
702 device = platform_device_register_simple(CMI8330_DRIVER,
703 i, NULL, 0);
704 if (IS_ERR(device))
705 continue;
706 if (!platform_get_drvdata(device)) {
707 platform_device_unregister(device);
708 continue;
709 }
710 platform_devices[i] = device;
711 cards++;
712 }
713 688
689 err = isa_register_driver(&snd_cmi8330_driver, SNDRV_CARDS);
714#ifdef CONFIG_PNP 690#ifdef CONFIG_PNP
691 if (!err)
692 isa_registered = 1;
693
715 err = pnp_register_card_driver(&cmi8330_pnpc_driver); 694 err = pnp_register_card_driver(&cmi8330_pnpc_driver);
716 if (!err) { 695 if (!err)
717 pnp_registered = 1; 696 pnp_registered = 1;
718 cards += cmi8330_pnp_devices;
719 }
720#endif
721 697
722 if (!cards) { 698 if (isa_registered)
723#ifdef MODULE 699 err = 0;
724 snd_printk(KERN_ERR "CMI8330 not found or device busy\n");
725#endif 700#endif
726 snd_cmi8330_unregister_all(); 701 return err;
727 return -ENODEV;
728 }
729 return 0;
730} 702}
731 703
732static void __exit alsa_card_cmi8330_exit(void) 704static void __exit alsa_card_cmi8330_exit(void)
733{ 705{
734 snd_cmi8330_unregister_all(); 706#ifdef CONFIG_PNP
707 if (pnp_registered)
708 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
709
710 if (isa_registered)
711#endif
712 isa_unregister_driver(&snd_cmi8330_driver);
735} 713}
736 714
737module_init(alsa_card_cmi8330_init) 715module_init(alsa_card_cmi8330_init)
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 696a5c86bcf..ac404113415 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -23,7 +23,7 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/platform_device.h> 26#include <linux/isa.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
@@ -32,8 +32,11 @@
32#include <sound/mpu401.h> 32#include <sound/mpu401.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34 34
35#define CRD_NAME "Generic CS4231"
36#define DEV_NAME "cs4231"
37
38MODULE_DESCRIPTION(CRD_NAME);
35MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("Generic CS4231");
37MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
38MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}"); 41MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}");
39 42
@@ -48,132 +51,136 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
48static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 51static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
49 52
50module_param_array(index, int, NULL, 0444); 53module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for CS4231 soundcard."); 54MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
52module_param_array(id, charp, NULL, 0444); 55module_param_array(id, charp, NULL, 0444);
53MODULE_PARM_DESC(id, "ID string for CS4231 soundcard."); 56MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
54module_param_array(enable, bool, NULL, 0444); 57module_param_array(enable, bool, NULL, 0444);
55MODULE_PARM_DESC(enable, "Enable CS4231 soundcard."); 58MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
56module_param_array(port, long, NULL, 0444); 59module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for CS4231 driver."); 60MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
58module_param_array(mpu_port, long, NULL, 0444); 61module_param_array(mpu_port, long, NULL, 0444);
59MODULE_PARM_DESC(mpu_port, "MPU-401 port # for CS4231 driver."); 62MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
60module_param_array(irq, int, NULL, 0444); 63module_param_array(irq, int, NULL, 0444);
61MODULE_PARM_DESC(irq, "IRQ # for CS4231 driver."); 64MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
62module_param_array(mpu_irq, int, NULL, 0444); 65module_param_array(mpu_irq, int, NULL, 0444);
63MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for CS4231 driver."); 66MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
64module_param_array(dma1, int, NULL, 0444); 67module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); 68MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
66module_param_array(dma2, int, NULL, 0444); 69module_param_array(dma2, int, NULL, 0444);
67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); 70MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
68 71
69static struct platform_device *devices[SNDRV_CARDS]; 72static int __devinit snd_cs4231_match(struct device *dev, unsigned int n)
73{
74 if (!enable[n])
75 return 0;
70 76
77 if (port[n] == SNDRV_AUTO_PORT) {
78 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
79 return 0;
80 }
81 if (irq[n] == SNDRV_AUTO_IRQ) {
82 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id);
83 return 0;
84 }
85 if (dma1[n] == SNDRV_AUTO_DMA) {
86 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id);
87 return 0;
88 }
89 return 1;
90}
71 91
72static int __init snd_cs4231_probe(struct platform_device *pdev) 92static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
73{ 93{
74 int dev = pdev->id;
75 struct snd_card *card; 94 struct snd_card *card;
76 struct snd_pcm *pcm;
77 struct snd_cs4231 *chip; 95 struct snd_cs4231 *chip;
78 int err; 96 struct snd_pcm *pcm;
97 int error;
79 98
80 if (port[dev] == SNDRV_AUTO_PORT) { 99 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
81 snd_printk(KERN_ERR "specify port\n"); 100 if (!card)
82 return -EINVAL;
83 }
84 if (irq[dev] == SNDRV_AUTO_IRQ) {
85 snd_printk(KERN_ERR "specify irq\n");
86 return -EINVAL;
87 }
88 if (dma1[dev] == SNDRV_AUTO_DMA) {
89 snd_printk(KERN_ERR "specify dma1\n");
90 return -EINVAL; 101 return -EINVAL;
91 } 102
92 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 103 error = snd_cs4231_create(card, port[n], -1, irq[n], dma1[n], dma2[n],
93 if (card == NULL) 104 CS4231_HW_DETECT, 0, &chip);
94 return -ENOMEM; 105 if (error < 0)
95 if ((err = snd_cs4231_create(card, port[dev], -1, 106 goto out;
96 irq[dev], 107
97 dma1[dev],
98 dma2[dev],
99 CS4231_HW_DETECT,
100 0, &chip)) < 0)
101 goto _err;
102 card->private_data = chip; 108 card->private_data = chip;
103 109
104 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) 110 error = snd_cs4231_pcm(chip, 0, &pcm);
105 goto _err; 111 if (error < 0)
112 goto out;
106 113
107 strcpy(card->driver, "CS4231"); 114 strcpy(card->driver, "CS4231");
108 strcpy(card->shortname, pcm->name); 115 strcpy(card->shortname, pcm->name);
116
109 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 117 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
110 pcm->name, chip->port, irq[dev], dma1[dev]); 118 pcm->name, chip->port, irq[n], dma1[n]);
111 if (dma2[dev] >= 0) 119 if (dma2[n] >= 0)
112 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 120 sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);
113 121
114 if ((err = snd_cs4231_mixer(chip)) < 0) 122 error = snd_cs4231_mixer(chip);
115 goto _err; 123 if (error < 0)
116 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) 124 goto out;
117 goto _err; 125
118 126 error = snd_cs4231_timer(chip, 0, NULL);
119 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 127 if (error < 0)
120 if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 128 goto out;
121 mpu_irq[dev] = -1; 129
130 if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) {
131 if (mpu_irq[n] == SNDRV_AUTO_IRQ)
132 mpu_irq[n] = -1;
122 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, 133 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
123 mpu_port[dev], 0, 134 mpu_port[n], 0, mpu_irq[n],
124 mpu_irq[dev], 135 mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
125 mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
126 NULL) < 0) 136 NULL) < 0)
127 printk(KERN_WARNING "cs4231: MPU401 not detected\n"); 137 printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id);
128 } 138 }
129 139
130 snd_card_set_dev(card, &pdev->dev); 140 snd_card_set_dev(card, dev);
131 141
132 if ((err = snd_card_register(card)) < 0) 142 error = snd_card_register(card);
133 goto _err; 143 if (error < 0)
144 goto out;
134 145
135 platform_set_drvdata(pdev, card); 146 dev_set_drvdata(dev, card);
136 return 0; 147 return 0;
137 148
138 _err: 149out: snd_card_free(card);
139 snd_card_free(card); 150 return error;
140 return err;
141} 151}
142 152
143static int __devexit snd_cs4231_remove(struct platform_device *devptr) 153static int __devexit snd_cs4231_remove(struct device *dev, unsigned int n)
144{ 154{
145 snd_card_free(platform_get_drvdata(devptr)); 155 snd_card_free(dev_get_drvdata(dev));
146 platform_set_drvdata(devptr, NULL); 156 dev_set_drvdata(dev, NULL);
147 return 0; 157 return 0;
148} 158}
149 159
150#ifdef CONFIG_PM 160#ifdef CONFIG_PM
151static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) 161static int snd_cs4231_suspend(struct device *dev, unsigned int n, pm_message_t state)
152{ 162{
153 struct snd_card *card; 163 struct snd_card *card = dev_get_drvdata(dev);
154 struct snd_cs4231 *chip; 164 struct snd_cs4231 *chip = card->private_data;
155 card = platform_get_drvdata(dev); 165
156 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 166 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
157 chip = card->private_data;
158 chip->suspend(chip); 167 chip->suspend(chip);
159 return 0; 168 return 0;
160} 169}
161 170
162static int snd_cs4231_resume(struct platform_device *dev) 171static int snd_cs4231_resume(struct device *dev, unsigned int n)
163{ 172{
164 struct snd_card *card; 173 struct snd_card *card = dev_get_drvdata(dev);
165 struct snd_cs4231 *chip; 174 struct snd_cs4231 *chip = card->private_data;
166 card = platform_get_drvdata(dev); 175
167 chip = card->private_data;
168 chip->resume(chip); 176 chip->resume(chip);
169 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 177 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
170 return 0; 178 return 0;
171} 179}
172#endif 180#endif
173 181
174#define SND_CS4231_DRIVER "snd_cs4231" 182static struct isa_driver snd_cs4231_driver = {
175 183 .match = snd_cs4231_match,
176static struct platform_driver snd_cs4231_driver = {
177 .probe = snd_cs4231_probe, 184 .probe = snd_cs4231_probe,
178 .remove = __devexit_p(snd_cs4231_remove), 185 .remove = __devexit_p(snd_cs4231_remove),
179#ifdef CONFIG_PM 186#ifdef CONFIG_PM
@@ -181,57 +188,19 @@ static struct platform_driver snd_cs4231_driver = {
181 .resume = snd_cs4231_resume, 188 .resume = snd_cs4231_resume,
182#endif 189#endif
183 .driver = { 190 .driver = {
184 .name = SND_CS4231_DRIVER 191 .name = DEV_NAME
185 }, 192 }
186}; 193};
187 194
188static void __init_or_module snd_cs4231_unregister_all(void)
189{
190 int i;
191
192 for (i = 0; i < ARRAY_SIZE(devices); ++i)
193 platform_device_unregister(devices[i]);
194 platform_driver_unregister(&snd_cs4231_driver);
195}
196
197static int __init alsa_card_cs4231_init(void) 195static int __init alsa_card_cs4231_init(void)
198{ 196{
199 int i, cards, err; 197 return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
200
201 err = platform_driver_register(&snd_cs4231_driver);
202 if (err < 0)
203 return err;
204
205 cards = 0;
206 for (i = 0; i < SNDRV_CARDS; i++) {
207 struct platform_device *device;
208 if (! enable[i])
209 continue;
210 device = platform_device_register_simple(SND_CS4231_DRIVER,
211 i, NULL, 0);
212 if (IS_ERR(device))
213 continue;
214 if (!platform_get_drvdata(device)) {
215 platform_device_unregister(device);
216 continue;
217 }
218 devices[i] = device;
219 cards++;
220 }
221 if (!cards) {
222#ifdef MODULE
223 printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
224#endif
225 snd_cs4231_unregister_all();
226 return -ENODEV;
227 }
228 return 0;
229} 198}
230 199
231static void __exit alsa_card_cs4231_exit(void) 200static void __exit alsa_card_cs4231_exit(void)
232{ 201{
233 snd_cs4231_unregister_all(); 202 isa_unregister_driver(&snd_cs4231_driver);
234} 203}
235 204
236module_init(alsa_card_cs4231_init) 205module_init(alsa_card_cs4231_init);
237module_exit(alsa_card_cs4231_exit) 206module_exit(alsa_card_cs4231_exit);
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 75c7c5f0198..914d77b61b0 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -405,7 +405,6 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); 405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
406 int result = 0; 406 int result = 0;
407 unsigned int what; 407 unsigned int what;
408 struct list_head *pos;
409 struct snd_pcm_substream *s; 408 struct snd_pcm_substream *s;
410 int do_start; 409 int do_start;
411 410
@@ -425,8 +424,7 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
425 } 424 }
426 425
427 what = 0; 426 what = 0;
428 snd_pcm_group_for_each(pos, substream) { 427 snd_pcm_group_for_each_entry(s, substream) {
429 s = snd_pcm_group_substream_entry(pos);
430 if (s == chip->playback_substream) { 428 if (s == chip->playback_substream) {
431 what |= CS4231_PLAYBACK_ENABLE; 429 what |= CS4231_PLAYBACK_ENABLE;
432 snd_pcm_trigger_done(s, substream); 430 snd_pcm_trigger_done(s, substream);
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 07ffd5c22e8..1a14f33b6ab 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pnp.h> 27#include <linux/pnp.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -75,10 +75,10 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
75 75
76#ifdef CS4232 76#ifdef CS4232
77#define IDENT "CS4232" 77#define IDENT "CS4232"
78#define CS423X_DRIVER "snd_cs4232" 78#define DEV_NAME "cs4232"
79#else 79#else
80#define IDENT "CS4236+" 80#define IDENT "CS4236+"
81#define CS423X_DRIVER "snd_cs4236" 81#define DEV_NAME "cs4236"
82#endif 82#endif
83 83
84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
@@ -126,14 +126,13 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
126module_param_array(dma2, int, NULL, 0444); 126module_param_array(dma2, int, NULL, 0444);
127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
128 128
129static struct platform_device *platform_devices[SNDRV_CARDS];
130#ifdef CONFIG_PNP 129#ifdef CONFIG_PNP
130static int isa_registered;
131static int pnpc_registered; 131static int pnpc_registered;
132#ifdef CS4232 132#ifdef CS4232
133static int pnp_registered; 133static int pnp_registered;
134#endif 134#endif
135#endif /* CONFIG_PNP */ 135#endif /* CONFIG_PNP */
136static unsigned int snd_cs423x_devices;
137 136
138struct snd_card_cs4236 { 137struct snd_card_cs4236 {
139 struct snd_cs4231 *chip; 138 struct snd_cs4231 *chip;
@@ -542,38 +541,55 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
542 return snd_card_register(card); 541 return snd_card_register(card);
543} 542}
544 543
545static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) 544static int __devinit snd_cs423x_isa_match(struct device *pdev,
545 unsigned int dev)
546{ 546{
547 int dev = pdev->id; 547 if (!enable[dev] || is_isapnp_selected(dev))
548 struct snd_card *card; 548 return 0;
549 int err;
550 549
551 if (port[dev] == SNDRV_AUTO_PORT) { 550 if (port[dev] == SNDRV_AUTO_PORT) {
552 snd_printk(KERN_ERR "specify port\n"); 551 snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id);
553 return -EINVAL; 552 return 0;
554 } 553 }
555 if (cport[dev] == SNDRV_AUTO_PORT) { 554 if (cport[dev] == SNDRV_AUTO_PORT) {
556 snd_printk(KERN_ERR "specify cport\n"); 555 snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id);
557 return -EINVAL; 556 return 0;
557 }
558 if (irq[dev] == SNDRV_AUTO_IRQ) {
559 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
560 return 0;
558 } 561 }
562 if (dma1[dev] == SNDRV_AUTO_DMA) {
563 snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id);
564 return 0;
565 }
566 return 1;
567}
568
569static int __devinit snd_cs423x_isa_probe(struct device *pdev,
570 unsigned int dev)
571{
572 struct snd_card *card;
573 int err;
559 574
560 card = snd_cs423x_card_new(dev); 575 card = snd_cs423x_card_new(dev);
561 if (! card) 576 if (! card)
562 return -ENOMEM; 577 return -ENOMEM;
563 snd_card_set_dev(card, &pdev->dev); 578 snd_card_set_dev(card, pdev);
564 if ((err = snd_cs423x_probe(card, dev)) < 0) { 579 if ((err = snd_cs423x_probe(card, dev)) < 0) {
565 snd_card_free(card); 580 snd_card_free(card);
566 return err; 581 return err;
567 } 582 }
568 583
569 platform_set_drvdata(pdev, card); 584 dev_set_drvdata(pdev, card);
570 return 0; 585 return 0;
571} 586}
572 587
573static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) 588static int __devexit snd_cs423x_isa_remove(struct device *pdev,
589 unsigned int dev)
574{ 590{
575 snd_card_free(platform_get_drvdata(devptr)); 591 snd_card_free(dev_get_drvdata(pdev));
576 platform_set_drvdata(devptr, NULL); 592 dev_set_drvdata(pdev, NULL);
577 return 0; 593 return 0;
578} 594}
579 595
@@ -594,26 +610,28 @@ static int snd_cs423x_resume(struct snd_card *card)
594 return 0; 610 return 0;
595} 611}
596 612
597static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 613static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
614 pm_message_t state)
598{ 615{
599 return snd_cs423x_suspend(platform_get_drvdata(dev)); 616 return snd_cs423x_suspend(dev_get_drvdata(dev));
600} 617}
601 618
602static int snd_cs423x_nonpnp_resume(struct platform_device *dev) 619static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
603{ 620{
604 return snd_cs423x_resume(platform_get_drvdata(dev)); 621 return snd_cs423x_resume(dev_get_drvdata(dev));
605} 622}
606#endif 623#endif
607 624
608static struct platform_driver cs423x_nonpnp_driver = { 625static struct isa_driver cs423x_isa_driver = {
609 .probe = snd_cs423x_nonpnp_probe, 626 .match = snd_cs423x_isa_match,
610 .remove = __devexit_p(snd_cs423x_nonpnp_remove), 627 .probe = snd_cs423x_isa_probe,
628 .remove = __devexit_p(snd_cs423x_isa_remove),
611#ifdef CONFIG_PM 629#ifdef CONFIG_PM
612 .suspend = snd_cs423x_nonpnp_suspend, 630 .suspend = snd_cs423x_isa_suspend,
613 .resume = snd_cs423x_nonpnp_resume, 631 .resume = snd_cs423x_isa_resume,
614#endif 632#endif
615 .driver = { 633 .driver = {
616 .name = CS423X_DRIVER 634 .name = DEV_NAME
617 }, 635 },
618}; 636};
619 637
@@ -651,7 +669,6 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
651 } 669 }
652 pnp_set_drvdata(pdev, card); 670 pnp_set_drvdata(pdev, card);
653 dev++; 671 dev++;
654 snd_cs423x_devices++;
655 return 0; 672 return 0;
656} 673}
657 674
@@ -715,7 +732,6 @@ static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
715 } 732 }
716 pnp_set_card_drvdata(pcard, card); 733 pnp_set_card_drvdata(pcard, card);
717 dev++; 734 dev++;
718 snd_cs423x_devices++;
719 return 0; 735 return 0;
720} 736}
721 737
@@ -750,46 +766,14 @@ static struct pnp_card_driver cs423x_pnpc_driver = {
750}; 766};
751#endif /* CONFIG_PNP */ 767#endif /* CONFIG_PNP */
752 768
753static void __init_or_module snd_cs423x_unregister_all(void)
754{
755 int i;
756
757#ifdef CONFIG_PNP
758 if (pnpc_registered)
759 pnp_unregister_card_driver(&cs423x_pnpc_driver);
760#ifdef CS4232
761 if (pnp_registered)
762 pnp_unregister_driver(&cs4232_pnp_driver);
763#endif
764#endif /* CONFIG_PNP */
765 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
766 platform_device_unregister(platform_devices[i]);
767 platform_driver_unregister(&cs423x_nonpnp_driver);
768}
769
770static int __init alsa_card_cs423x_init(void) 769static int __init alsa_card_cs423x_init(void)
771{ 770{
772 int i, err; 771 int err;
773
774 if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0)
775 return err;
776 772
777 for (i = 0; i < SNDRV_CARDS; i++) { 773 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
778 struct platform_device *device;
779 if (! enable[i] || is_isapnp_selected(i))
780 continue;
781 device = platform_device_register_simple(CS423X_DRIVER,
782 i, NULL, 0);
783 if (IS_ERR(device))
784 continue;
785 if (!platform_get_drvdata(device)) {
786 platform_device_unregister(device);
787 continue;
788 }
789 platform_devices[i] = device;
790 snd_cs423x_devices++;
791 }
792#ifdef CONFIG_PNP 774#ifdef CONFIG_PNP
775 if (!err)
776 isa_registered = 1;
793#ifdef CS4232 777#ifdef CS4232
794 err = pnp_register_driver(&cs4232_pnp_driver); 778 err = pnp_register_driver(&cs4232_pnp_driver);
795 if (!err) 779 if (!err)
@@ -798,21 +782,28 @@ static int __init alsa_card_cs423x_init(void)
798 err = pnp_register_card_driver(&cs423x_pnpc_driver); 782 err = pnp_register_card_driver(&cs423x_pnpc_driver);
799 if (!err) 783 if (!err)
800 pnpc_registered = 1; 784 pnpc_registered = 1;
801#endif /* CONFIG_PNP */ 785#ifdef CS4232
802 786 if (pnp_registered)
803 if (!snd_cs423x_devices) { 787 err = 0;
804#ifdef MODULE
805 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
806#endif 788#endif
807 snd_cs423x_unregister_all(); 789 if (isa_registered)
808 return -ENODEV; 790 err = 0;
809 } 791#endif
810 return 0; 792 return err;
811} 793}
812 794
813static void __exit alsa_card_cs423x_exit(void) 795static void __exit alsa_card_cs423x_exit(void)
814{ 796{
815 snd_cs423x_unregister_all(); 797#ifdef CONFIG_PNP
798 if (pnpc_registered)
799 pnp_unregister_card_driver(&cs423x_pnpc_driver);
800#ifdef CS4232
801 if (pnp_registered)
802 pnp_unregister_driver(&cs4232_pnp_driver);
803#endif
804 if (isa_registered)
805#endif
806 isa_unregister_driver(&cs423x_isa_driver);
816} 807}
817 808
818module_init(alsa_card_cs423x_init) 809module_init(alsa_card_cs423x_init)
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 65f97ff4eef..edc398712e8 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -35,8 +35,11 @@
35#define SNDRV_LEGACY_FIND_FREE_DMA 35#define SNDRV_LEGACY_FIND_FREE_DMA
36#include <sound/initval.h> 36#include <sound/initval.h>
37 37
38#define CRD_NAME "Generic ESS ES1688/ES688 AudioDrive"
39#define DEV_NAME "es1688"
40
41MODULE_DESCRIPTION(CRD_NAME);
38MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
39MODULE_DESCRIPTION("ESS ESx688 AudioDrive");
40MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
41MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100}," 44MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
42 "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102}," 45 "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102},"
@@ -53,189 +56,157 @@ static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
53static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */ 56static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
54 57
55module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for ESx688 soundcard."); 59MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
57module_param_array(id, charp, NULL, 0444); 60module_param_array(id, charp, NULL, 0444);
58MODULE_PARM_DESC(id, "ID string for ESx688 soundcard."); 61MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
59module_param_array(enable, bool, NULL, 0444); 62module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable ESx688 soundcard."); 63MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
61module_param_array(port, long, NULL, 0444); 64module_param_array(port, long, NULL, 0444);
62MODULE_PARM_DESC(port, "Port # for ESx688 driver."); 65MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
63module_param_array(mpu_port, long, NULL, 0444); 66module_param_array(mpu_port, long, NULL, 0444);
64MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ESx688 driver."); 67MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
65module_param_array(irq, int, NULL, 0444); 68module_param_array(irq, int, NULL, 0444);
66MODULE_PARM_DESC(irq, "IRQ # for ESx688 driver."); 69MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
67module_param_array(mpu_irq, int, NULL, 0444); 70module_param_array(mpu_irq, int, NULL, 0444);
68MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); 71MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
69module_param_array(dma8, int, NULL, 0444); 72module_param_array(dma8, int, NULL, 0444);
70MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); 73MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
71
72static struct platform_device *devices[SNDRV_CARDS];
73 74
74#define PFX "es1688: " 75static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
76{
77 return enable[n];
78}
75 79
76static int __devinit snd_es1688_probe(struct platform_device *pdev) 80static int __devinit snd_es1688_legacy_create(struct snd_card *card,
81 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
77{ 82{
78 int dev = pdev->id; 83 static long possible_ports[] = {0x220, 0x240, 0x260};
79 static int possible_irqs[] = {5, 9, 10, 7, -1}; 84 static int possible_irqs[] = {5, 9, 10, 7, -1};
80 static int possible_dmas[] = {1, 3, 0, -1}; 85 static int possible_dmas[] = {1, 3, 0, -1};
81 int xirq, xdma, xmpu_irq; 86
82 struct snd_card *card; 87 int i, error;
83 struct snd_es1688 *chip; 88
84 struct snd_opl3 *opl3; 89 if (irq[n] == SNDRV_AUTO_IRQ) {
85 struct snd_pcm *pcm; 90 irq[n] = snd_legacy_find_free_irq(possible_irqs);
86 int err; 91 if (irq[n] < 0) {
87 92 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n",
88 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 93 dev->bus_id);
89 if (card == NULL) 94 return -EBUSY;
90 return -ENOMEM;
91
92 xirq = irq[dev];
93 if (xirq == SNDRV_AUTO_IRQ) {
94 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
95 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
96 err = -EBUSY;
97 goto _err;
98 } 95 }
99 } 96 }
100 xmpu_irq = mpu_irq[dev]; 97 if (dma8[n] == SNDRV_AUTO_DMA) {
101 xdma = dma8[dev]; 98 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
102 if (xdma == SNDRV_AUTO_DMA) { 99 if (dma8[n] < 0) {
103 if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) { 100 snd_printk(KERN_ERR "%s: unable to find a free DMA\n",
104 snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); 101 dev->bus_id);
105 err = -EBUSY; 102 return -EBUSY;
106 goto _err;
107 } 103 }
108 } 104 }
109 105
110 if (port[dev] != SNDRV_AUTO_PORT) { 106 if (port[n] != SNDRV_AUTO_PORT)
111 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], 107 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
112 xirq, xmpu_irq, xdma, 108 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
113 ES1688_HW_AUTO, &chip)) < 0) 109
114 goto _err; 110 i = 0;
115 } else { 111 do {
116 /* auto-probe legacy ports */ 112 port[n] = possible_ports[i];
117 static unsigned long possible_ports[] = { 113 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
118 0x220, 0x240, 0x260, 114 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
119 }; 115 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
120 int i; 116
121 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 117 return error;
122 err = snd_es1688_create(card, possible_ports[i], 118}
123 mpu_port[dev], 119
124 xirq, xmpu_irq, xdma, 120static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
125 ES1688_HW_AUTO, &chip); 121{
126 if (err >= 0) { 122 struct snd_card *card;
127 port[dev] = possible_ports[i]; 123 struct snd_es1688 *chip;
128 break; 124 struct snd_opl3 *opl3;
129 } 125 struct snd_pcm *pcm;
130 } 126 int error;
131 if (i >= ARRAY_SIZE(possible_ports)) 127
132 goto _err; 128 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
133 } 129 if (!card)
130 return -EINVAL;
131
132 error = snd_es1688_legacy_create(card, dev, n, &chip);
133 if (error < 0)
134 goto out;
134 135
135 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) 136 error = snd_es1688_pcm(chip, 0, &pcm);
136 goto _err; 137 if (error < 0)
138 goto out;
137 139
138 if ((err = snd_es1688_mixer(chip)) < 0) 140 error = snd_es1688_mixer(chip);
139 goto _err; 141 if (error < 0)
142 goto out;
140 143
141 strcpy(card->driver, "ES1688"); 144 strcpy(card->driver, "ES1688");
142 strcpy(card->shortname, pcm->name); 145 strcpy(card->shortname, pcm->name);
143 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma); 146 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
144 147 chip->port, chip->irq, chip->dma8);
145 if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) { 148
146 printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->port); 149 if (snd_opl3_create(card, chip->port, chip->port + 2,
147 } else { 150 OPL3_HW_OPL3, 0, &opl3) < 0)
148 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) 151 printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n",
149 goto _err; 152 dev->bus_id, chip->port);
153 else {
154 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
155 if (error < 0)
156 goto out;
150 } 157 }
151 158
152 if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) { 159 if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ &&
153 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, 160 chip->mpu_port > 0) {
154 chip->mpu_port, 0, 161 error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
155 xmpu_irq, 162 chip->mpu_port, 0,
156 IRQF_DISABLED, 163 mpu_irq[n], IRQF_DISABLED, NULL);
157 NULL)) < 0) 164 if (error < 0)
158 goto _err; 165 goto out;
159 } 166 }
160 167
161 snd_card_set_dev(card, &pdev->dev); 168 snd_card_set_dev(card, dev);
162 169
163 if ((err = snd_card_register(card)) < 0) 170 error = snd_card_register(card);
164 goto _err; 171 if (error < 0)
172 goto out;
165 173
166 platform_set_drvdata(pdev, card); 174 dev_set_drvdata(dev, card);
167 return 0; 175 return 0;
168 176
169 _err: 177out: snd_card_free(card);
170 snd_card_free(card); 178 return error;
171 return err;
172} 179}
173 180
174static int __devexit snd_es1688_remove(struct platform_device *devptr) 181static int __devexit snd_es1688_remove(struct device *dev, unsigned int n)
175{ 182{
176 snd_card_free(platform_get_drvdata(devptr)); 183 snd_card_free(dev_get_drvdata(dev));
177 platform_set_drvdata(devptr, NULL); 184 dev_set_drvdata(dev, NULL);
178 return 0; 185 return 0;
179} 186}
180 187
181#define ES1688_DRIVER "snd_es1688" 188static struct isa_driver snd_es1688_driver = {
182 189 .match = snd_es1688_match,
183static struct platform_driver snd_es1688_driver = {
184 .probe = snd_es1688_probe, 190 .probe = snd_es1688_probe,
185 .remove = __devexit_p(snd_es1688_remove), 191 .remove = snd_es1688_remove,
186 /* FIXME: suspend/resume */ 192#if 0 /* FIXME */
193 .suspend = snd_es1688_suspend,
194 .resume = snd_es1688_resume,
195#endif
187 .driver = { 196 .driver = {
188 .name = ES1688_DRIVER 197 .name = DEV_NAME
189 }, 198 }
190}; 199};
191 200
192static void __init_or_module snd_es1688_unregister_all(void)
193{
194 int i;
195
196 for (i = 0; i < ARRAY_SIZE(devices); ++i)
197 platform_device_unregister(devices[i]);
198 platform_driver_unregister(&snd_es1688_driver);
199}
200
201static int __init alsa_card_es1688_init(void) 201static int __init alsa_card_es1688_init(void)
202{ 202{
203 int i, cards, err; 203 return isa_register_driver(&snd_es1688_driver, SNDRV_CARDS);
204
205 err = platform_driver_register(&snd_es1688_driver);
206 if (err < 0)
207 return err;
208
209 cards = 0;
210 for (i = 0; i < SNDRV_CARDS; i++) {
211 struct platform_device *device;
212 if (! enable[i])
213 continue;
214 device = platform_device_register_simple(ES1688_DRIVER,
215 i, NULL, 0);
216 if (IS_ERR(device))
217 continue;
218 if (!platform_get_drvdata(device)) {
219 platform_device_unregister(device);
220 continue;
221 }
222 devices[i] = device;
223 cards++;
224 }
225 if (!cards) {
226#ifdef MODULE
227 printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n");
228#endif
229 snd_es1688_unregister_all();
230 return -ENODEV;
231 }
232 return 0;
233} 204}
234 205
235static void __exit alsa_card_es1688_exit(void) 206static void __exit alsa_card_es1688_exit(void)
236{ 207{
237 snd_es1688_unregister_all(); 208 isa_unregister_driver(&snd_es1688_driver);
238} 209}
239 210
240module_init(alsa_card_es1688_init) 211module_init(alsa_card_es1688_init);
241module_exit(alsa_card_es1688_exit) 212module_exit(alsa_card_es1688_exit);
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 725c115ff97..f7732bf90be 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -80,7 +80,7 @@
80#include <sound/driver.h> 80#include <sound/driver.h>
81#include <linux/init.h> 81#include <linux/init.h>
82#include <linux/err.h> 82#include <linux/err.h>
83#include <linux/platform_device.h> 83#include <linux/isa.h>
84#include <linux/slab.h> 84#include <linux/slab.h>
85#include <linux/pnp.h> 85#include <linux/pnp.h>
86#include <linux/isapnp.h> 86#include <linux/isapnp.h>
@@ -2035,10 +2035,10 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver.");
2035module_param_array(dma2, int, NULL, 0444); 2035module_param_array(dma2, int, NULL, 0444);
2036MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); 2036MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
2037 2037
2038static struct platform_device *platform_devices[SNDRV_CARDS];
2039
2040#ifdef CONFIG_PNP 2038#ifdef CONFIG_PNP
2041static int pnp_registered, pnpc_registered; 2039static int isa_registered;
2040static int pnp_registered;
2041static int pnpc_registered;
2042 2042
2043static struct pnp_device_id snd_audiodrive_pnpbiosids[] = { 2043static struct pnp_device_id snd_audiodrive_pnpbiosids[] = {
2044 { .id = "ESS1869" }, 2044 { .id = "ESS1869" },
@@ -2237,7 +2237,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
2237 return snd_card_register(card); 2237 return snd_card_register(card);
2238} 2238}
2239 2239
2240static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) 2240static int __devinit snd_es18xx_isa_match(struct device *pdev, unsigned int dev)
2241{
2242 return enable[dev] && !is_isapnp_selected(dev);
2243}
2244
2245static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr)
2241{ 2246{
2242 struct snd_card *card; 2247 struct snd_card *card;
2243 int err; 2248 int err;
@@ -2245,18 +2250,17 @@ static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *d
2245 card = snd_es18xx_card_new(dev); 2250 card = snd_es18xx_card_new(dev);
2246 if (! card) 2251 if (! card)
2247 return -ENOMEM; 2252 return -ENOMEM;
2248 snd_card_set_dev(card, &devptr->dev); 2253 snd_card_set_dev(card, devptr);
2249 if ((err = snd_audiodrive_probe(card, dev)) < 0) { 2254 if ((err = snd_audiodrive_probe(card, dev)) < 0) {
2250 snd_card_free(card); 2255 snd_card_free(card);
2251 return err; 2256 return err;
2252 } 2257 }
2253 platform_set_drvdata(devptr, card); 2258 dev_set_drvdata(devptr, card);
2254 return 0; 2259 return 0;
2255} 2260}
2256 2261
2257static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) 2262static int __devinit snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
2258{ 2263{
2259 int dev = pdev->id;
2260 int err; 2264 int err;
2261 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; 2265 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2262 static int possible_dmas[] = {1, 0, 3, 5, -1}; 2266 static int possible_dmas[] = {1, 0, 3, 5, -1};
@@ -2281,13 +2285,13 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev)
2281 } 2285 }
2282 2286
2283 if (port[dev] != SNDRV_AUTO_PORT) { 2287 if (port[dev] != SNDRV_AUTO_PORT) {
2284 return snd_es18xx_nonpnp_probe1(dev, pdev); 2288 return snd_es18xx_isa_probe1(dev, pdev);
2285 } else { 2289 } else {
2286 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; 2290 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
2287 int i; 2291 int i;
2288 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 2292 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
2289 port[dev] = possible_ports[i]; 2293 port[dev] = possible_ports[i];
2290 err = snd_es18xx_nonpnp_probe1(dev, pdev); 2294 err = snd_es18xx_isa_probe1(dev, pdev);
2291 if (! err) 2295 if (! err)
2292 return 0; 2296 return 0;
2293 } 2297 }
@@ -2295,43 +2299,44 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev)
2295 } 2299 }
2296} 2300}
2297 2301
2298static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) 2302static int __devexit snd_es18xx_isa_remove(struct device *devptr,
2303 unsigned int dev)
2299{ 2304{
2300 snd_card_free(platform_get_drvdata(devptr)); 2305 snd_card_free(dev_get_drvdata(devptr));
2301 platform_set_drvdata(devptr, NULL); 2306 dev_set_drvdata(devptr, NULL);
2302 return 0; 2307 return 0;
2303} 2308}
2304 2309
2305#ifdef CONFIG_PM 2310#ifdef CONFIG_PM
2306static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 2311static int snd_es18xx_isa_suspend(struct device *dev, unsigned int n,
2312 pm_message_t state)
2307{ 2313{
2308 return snd_es18xx_suspend(platform_get_drvdata(dev), state); 2314 return snd_es18xx_suspend(dev_get_drvdata(dev), state);
2309} 2315}
2310 2316
2311static int snd_es18xx_nonpnp_resume(struct platform_device *dev) 2317static int snd_es18xx_isa_resume(struct device *dev, unsigned int n)
2312{ 2318{
2313 return snd_es18xx_resume(platform_get_drvdata(dev)); 2319 return snd_es18xx_resume(dev_get_drvdata(dev));
2314} 2320}
2315#endif 2321#endif
2316 2322
2317#define ES18XX_DRIVER "snd_es18xx" 2323#define DEV_NAME "es18xx"
2318 2324
2319static struct platform_driver snd_es18xx_nonpnp_driver = { 2325static struct isa_driver snd_es18xx_isa_driver = {
2320 .probe = snd_es18xx_nonpnp_probe, 2326 .match = snd_es18xx_isa_match,
2321 .remove = __devexit_p(snd_es18xx_nonpnp_remove), 2327 .probe = snd_es18xx_isa_probe,
2328 .remove = __devexit_p(snd_es18xx_isa_remove),
2322#ifdef CONFIG_PM 2329#ifdef CONFIG_PM
2323 .suspend = snd_es18xx_nonpnp_suspend, 2330 .suspend = snd_es18xx_isa_suspend,
2324 .resume = snd_es18xx_nonpnp_resume, 2331 .resume = snd_es18xx_isa_resume,
2325#endif 2332#endif
2326 .driver = { 2333 .driver = {
2327 .name = ES18XX_DRIVER 2334 .name = DEV_NAME
2328 }, 2335 },
2329}; 2336};
2330 2337
2331 2338
2332#ifdef CONFIG_PNP 2339#ifdef CONFIG_PNP
2333static unsigned int __devinitdata es18xx_pnp_devices;
2334
2335static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, 2340static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
2336 const struct pnp_device_id *id) 2341 const struct pnp_device_id *id)
2337{ 2342{
@@ -2362,7 +2367,6 @@ static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
2362 } 2367 }
2363 pnp_set_drvdata(pdev, card); 2368 pnp_set_drvdata(pdev, card);
2364 dev++; 2369 dev++;
2365 es18xx_pnp_devices++;
2366 return 0; 2370 return 0;
2367} 2371}
2368 2372
@@ -2424,7 +2428,6 @@ static int __devinit snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
2424 2428
2425 pnp_set_card_drvdata(pcard, card); 2429 pnp_set_card_drvdata(pcard, card);
2426 dev++; 2430 dev++;
2427 es18xx_pnp_devices++;
2428 return 0; 2431 return 0;
2429} 2432}
2430 2433
@@ -2460,67 +2463,39 @@ static struct pnp_card_driver es18xx_pnpc_driver = {
2460}; 2463};
2461#endif /* CONFIG_PNP */ 2464#endif /* CONFIG_PNP */
2462 2465
2463static void __init_or_module snd_es18xx_unregister_all(void)
2464{
2465 int i;
2466
2467#ifdef CONFIG_PNP
2468 if (pnpc_registered)
2469 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2470 if (pnp_registered)
2471 pnp_unregister_driver(&es18xx_pnp_driver);
2472#endif
2473 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
2474 platform_device_unregister(platform_devices[i]);
2475 platform_driver_unregister(&snd_es18xx_nonpnp_driver);
2476}
2477
2478static int __init alsa_card_es18xx_init(void) 2466static int __init alsa_card_es18xx_init(void)
2479{ 2467{
2480 int i, err, cards = 0; 2468 int err;
2481
2482 if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0)
2483 return err;
2484
2485 for (i = 0; i < SNDRV_CARDS; i++) {
2486 struct platform_device *device;
2487 if (! enable[i] || is_isapnp_selected(i))
2488 continue;
2489 device = platform_device_register_simple(ES18XX_DRIVER,
2490 i, NULL, 0);
2491 if (IS_ERR(device))
2492 continue;
2493 if (!platform_get_drvdata(device)) {
2494 platform_device_unregister(device);
2495 continue;
2496 }
2497 platform_devices[i] = device;
2498 cards++;
2499 }
2500 2469
2470 err = isa_register_driver(&snd_es18xx_isa_driver, SNDRV_CARDS);
2501#ifdef CONFIG_PNP 2471#ifdef CONFIG_PNP
2472 if (!err)
2473 isa_registered = 1;
2474
2502 err = pnp_register_driver(&es18xx_pnp_driver); 2475 err = pnp_register_driver(&es18xx_pnp_driver);
2503 if (!err) 2476 if (!err)
2504 pnp_registered = 1; 2477 pnp_registered = 1;
2478
2505 err = pnp_register_card_driver(&es18xx_pnpc_driver); 2479 err = pnp_register_card_driver(&es18xx_pnpc_driver);
2506 if (!err) 2480 if (!err)
2507 pnpc_registered = 1; 2481 pnpc_registered = 1;
2508 cards += es18xx_pnp_devices;
2509#endif
2510 2482
2511 if(!cards) { 2483 if (isa_registered || pnp_registered)
2512#ifdef MODULE 2484 err = 0;
2513 snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");
2514#endif 2485#endif
2515 snd_es18xx_unregister_all(); 2486 return err;
2516 return -ENODEV;
2517 }
2518 return 0;
2519} 2487}
2520 2488
2521static void __exit alsa_card_es18xx_exit(void) 2489static void __exit alsa_card_es18xx_exit(void)
2522{ 2490{
2523 snd_es18xx_unregister_all(); 2491#ifdef CONFIG_PNP
2492 if (pnpc_registered)
2493 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2494 if (pnp_registered)
2495 pnp_unregister_driver(&es18xx_pnp_driver);
2496 if (isa_registered)
2497#endif
2498 isa_unregister_driver(&snd_es18xx_isa_driver);
2524} 2499}
2525 2500
2526module_init(alsa_card_es18xx_init) 2501module_init(alsa_card_es18xx_init)
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index 0395e2e0dd0..8f23f433d49 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -33,8 +33,11 @@
33#define SNDRV_LEGACY_FIND_FREE_DMA 33#define SNDRV_LEGACY_FIND_FREE_DMA
34#include <sound/initval.h> 34#include <sound/initval.h>
35 35
36#define CRD_NAME "Gravis UltraSound Classic"
37#define DEV_NAME "gusclassic"
38
39MODULE_DESCRIPTION(CRD_NAME);
36MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
37MODULE_DESCRIPTION("Gravis UltraSound Classic");
38MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
39MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}"); 42MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}");
40 43
@@ -51,32 +54,80 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 54static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
52 55
53module_param_array(index, int, NULL, 0444); 56module_param_array(index, int, NULL, 0444);
54MODULE_PARM_DESC(index, "Index value for GUS Classic soundcard."); 57MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
55module_param_array(id, charp, NULL, 0444); 58module_param_array(id, charp, NULL, 0444);
56MODULE_PARM_DESC(id, "ID string for GUS Classic soundcard."); 59MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
57module_param_array(enable, bool, NULL, 0444); 60module_param_array(enable, bool, NULL, 0444);
58MODULE_PARM_DESC(enable, "Enable GUS Classic soundcard."); 61MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
59module_param_array(port, long, NULL, 0444); 62module_param_array(port, long, NULL, 0444);
60MODULE_PARM_DESC(port, "Port # for GUS Classic driver."); 63MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
61module_param_array(irq, int, NULL, 0444); 64module_param_array(irq, int, NULL, 0444);
62MODULE_PARM_DESC(irq, "IRQ # for GUS Classic driver."); 65MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
63module_param_array(dma1, int, NULL, 0444); 66module_param_array(dma1, int, NULL, 0444);
64MODULE_PARM_DESC(dma1, "DMA1 # for GUS Classic driver."); 67MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
65module_param_array(dma2, int, NULL, 0444); 68module_param_array(dma2, int, NULL, 0444);
66MODULE_PARM_DESC(dma2, "DMA2 # for GUS Classic driver."); 69MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
67module_param_array(joystick_dac, int, NULL, 0444); 70module_param_array(joystick_dac, int, NULL, 0444);
68MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Classic driver."); 71MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
69module_param_array(channels, int, NULL, 0444); 72module_param_array(channels, int, NULL, 0444);
70MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); 73MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
71module_param_array(pcm_channels, int, NULL, 0444); 74module_param_array(pcm_channels, int, NULL, 0444);
72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); 75MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
76
77static int __devinit snd_gusclassic_match(struct device *dev, unsigned int n)
78{
79 return enable[n];
80}
81
82static int __devinit snd_gusclassic_create(struct snd_card *card,
83 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
84{
85 static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260};
86 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
87 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
88
89 int i, error;
90
91 if (irq[n] == SNDRV_AUTO_IRQ) {
92 irq[n] = snd_legacy_find_free_irq(possible_irqs);
93 if (irq[n] < 0) {
94 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n",
95 dev->bus_id);
96 return -EBUSY;
97 }
98 }
99 if (dma1[n] == SNDRV_AUTO_DMA) {
100 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
101 if (dma1[n] < 0) {
102 snd_printk(KERN_ERR "%s: unable to find a free DMA1\n",
103 dev->bus_id);
104 return -EBUSY;
105 }
106 }
107 if (dma2[n] == SNDRV_AUTO_DMA) {
108 dma2[n] = snd_legacy_find_free_dma(possible_dmas);
109 if (dma2[n] < 0) {
110 snd_printk(KERN_ERR "%s: unable to find a free DMA2\n",
111 dev->bus_id);
112 return -EBUSY;
113 }
114 }
73 115
74static struct platform_device *devices[SNDRV_CARDS]; 116 if (port[n] != SNDRV_AUTO_PORT)
117 return snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
118 0, channels[n], pcm_channels[n], 0, rgus);
75 119
120 i = 0;
121 do {
122 port[n] = possible_ports[i];
123 error = snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
124 0, channels[n], pcm_channels[n], 0, rgus);
125 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
76 126
77#define PFX "gusclassic: " 127 return error;
128}
78 129
79static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus) 130static int __devinit snd_gusclassic_detect(struct snd_gus_card *gus)
80{ 131{
81 unsigned char d; 132 unsigned char d;
82 133
@@ -95,187 +146,104 @@ static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus)
95 return 0; 146 return 0;
96} 147}
97 148
98static void __devinit snd_gusclassic_init(int dev, struct snd_gus_card * gus) 149static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n)
99{
100 gus->equal_irq = 0;
101 gus->codec_flag = 0;
102 gus->max_flag = 0;
103 gus->joystick_dac = joystick_dac[dev];
104}
105
106static int __devinit snd_gusclassic_probe(struct platform_device *pdev)
107{ 150{
108 int dev = pdev->id;
109 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
110 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
111 int xirq, xdma1, xdma2;
112 struct snd_card *card; 151 struct snd_card *card;
113 struct snd_gus_card *gus = NULL; 152 struct snd_gus_card *gus;
114 int err; 153 int error;
115
116 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
117 if (card == NULL)
118 return -ENOMEM;
119 if (pcm_channels[dev] < 2)
120 pcm_channels[dev] = 2;
121
122 xirq = irq[dev];
123 if (xirq == SNDRV_AUTO_IRQ) {
124 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
125 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
126 err = -EBUSY;
127 goto _err;
128 }
129 }
130 xdma1 = dma1[dev];
131 if (xdma1 == SNDRV_AUTO_DMA) {
132 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
133 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
134 err = -EBUSY;
135 goto _err;
136 }
137 }
138 xdma2 = dma2[dev];
139 if (xdma2 == SNDRV_AUTO_DMA) {
140 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
141 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
142 err = -EBUSY;
143 goto _err;
144 }
145 }
146 154
147 if (port[dev] != SNDRV_AUTO_PORT) { 155 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
148 err = snd_gus_create(card, 156 if (!card)
149 port[dev], 157 return -EINVAL;
150 xirq, xdma1, xdma2,
151 0, channels[dev], pcm_channels[dev],
152 0, &gus);
153 } else {
154 /* auto-probe legacy ports */
155 static unsigned long possible_ports[] = {
156 0x220, 0x230, 0x240, 0x250, 0x260,
157 };
158 int i;
159 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
160 err = snd_gus_create(card,
161 possible_ports[i],
162 xirq, xdma1, xdma2,
163 0, channels[dev], pcm_channels[dev],
164 0, &gus);
165 if (err >= 0) {
166 port[dev] = possible_ports[i];
167 break;
168 }
169 }
170 }
171 if (err < 0)
172 goto _err;
173 158
174 if ((err = snd_gusclassic_detect(gus)) < 0) 159 if (pcm_channels[n] < 2)
175 goto _err; 160 pcm_channels[n] = 2;
176 161
177 snd_gusclassic_init(dev, gus); 162 error = snd_gusclassic_create(card, dev, n, &gus);
178 if ((err = snd_gus_initialize(gus)) < 0) 163 if (error < 0)
179 goto _err; 164 goto out;
180 165
166 error = snd_gusclassic_detect(gus);
167 if (error < 0)
168 goto out;
169
170 gus->joystick_dac = joystick_dac[n];
171
172 error = snd_gus_initialize(gus);
173 if (error < 0)
174 goto out;
175
176 error = -ENODEV;
181 if (gus->max_flag || gus->ess_flag) { 177 if (gus->max_flag || gus->ess_flag) {
182 snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); 178 snd_printk(KERN_ERR "%s: GUS Classic or ACE soundcard was "
183 err = -ENODEV; 179 "not detected at 0x%lx\n", dev->bus_id, gus->gf1.port);
184 goto _err; 180 goto out;
185 } 181 }
186 182
187 if ((err = snd_gf1_new_mixer(gus)) < 0) 183 error = snd_gf1_new_mixer(gus);
188 goto _err; 184 if (error < 0)
185 goto out;
189 186
190 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) 187 error = snd_gf1_pcm_new(gus, 0, 0, NULL);
191 goto _err; 188 if (error < 0)
189 goto out;
192 190
193 if (!gus->ace_flag) { 191 if (!gus->ace_flag) {
194 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) 192 error = snd_gf1_rawmidi_new(gus, 0, NULL);
195 goto _err; 193 if (error < 0)
194 goto out;
196 } 195 }
197 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
198 if (xdma2 >= 0)
199 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
200 196
201 snd_card_set_dev(card, &pdev->dev); 197 sprintf(card->longname + strlen(card->longname),
198 " at 0x%lx, irq %d, dma %d",
199 gus->gf1.port, gus->gf1.irq, gus->gf1.dma1);
202 200
203 if ((err = snd_card_register(card)) < 0) 201 if (gus->gf1.dma2 >= 0)
204 goto _err; 202 sprintf(card->longname + strlen(card->longname),
203 "&%d", gus->gf1.dma2);
205 204
206 platform_set_drvdata(pdev, card); 205 snd_card_set_dev(card, dev);
206
207 error = snd_card_register(card);
208 if (error < 0)
209 goto out;
210
211 dev_set_drvdata(dev, card);
207 return 0; 212 return 0;
208 213
209 _err: 214out: snd_card_free(card);
210 snd_card_free(card); 215 return error;
211 return err;
212} 216}
213 217
214static int __devexit snd_gusclassic_remove(struct platform_device *devptr) 218static int __devexit snd_gusclassic_remove(struct device *dev, unsigned int n)
215{ 219{
216 snd_card_free(platform_get_drvdata(devptr)); 220 snd_card_free(dev_get_drvdata(dev));
217 platform_set_drvdata(devptr, NULL); 221 dev_set_drvdata(dev, NULL);
218 return 0; 222 return 0;
219} 223}
220 224
221#define GUSCLASSIC_DRIVER "snd_gusclassic" 225static struct isa_driver snd_gusclassic_driver = {
222 226 .match = snd_gusclassic_match,
223static struct platform_driver snd_gusclassic_driver = {
224 .probe = snd_gusclassic_probe, 227 .probe = snd_gusclassic_probe,
225 .remove = __devexit_p(snd_gusclassic_remove), 228 .remove = __devexit_p(snd_gusclassic_remove),
226 /* FIXME: suspend/resume */ 229#if 0 /* FIXME */
230 .suspend = snd_gusclassic_suspend,
231 .remove = snd_gusclassic_remove,
232#endif
227 .driver = { 233 .driver = {
228 .name = GUSCLASSIC_DRIVER 234 .name = DEV_NAME
229 }, 235 }
230}; 236};
231 237
232static void __init_or_module snd_gusclassic_unregister_all(void)
233{
234 int i;
235
236 for (i = 0; i < ARRAY_SIZE(devices); ++i)
237 platform_device_unregister(devices[i]);
238 platform_driver_unregister(&snd_gusclassic_driver);
239}
240
241static int __init alsa_card_gusclassic_init(void) 238static int __init alsa_card_gusclassic_init(void)
242{ 239{
243 int i, cards, err; 240 return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS);
244
245 err = platform_driver_register(&snd_gusclassic_driver);
246 if (err < 0)
247 return err;
248
249 cards = 0;
250 for (i = 0; i < SNDRV_CARDS; i++) {
251 struct platform_device *device;
252 if (! enable[i])
253 continue;
254 device = platform_device_register_simple(GUSCLASSIC_DRIVER,
255 i, NULL, 0);
256 if (IS_ERR(device))
257 continue;
258 if (!platform_get_drvdata(device)) {
259 platform_device_unregister(device);
260 continue;
261 }
262 devices[i] = device;
263 cards++;
264 }
265 if (!cards) {
266#ifdef MODULE
267 printk(KERN_ERR "GUS Classic soundcard not found or device busy\n");
268#endif
269 snd_gusclassic_unregister_all();
270 return -ENODEV;
271 }
272 return 0;
273} 241}
274 242
275static void __exit alsa_card_gusclassic_exit(void) 243static void __exit alsa_card_gusclassic_exit(void)
276{ 244{
277 snd_gusclassic_unregister_all(); 245 isa_unregister_driver(&snd_gusclassic_driver);
278} 246}
279 247
280module_init(alsa_card_gusclassic_init) 248module_init(alsa_card_gusclassic_init);
281module_exit(alsa_card_gusclassic_exit) 249module_exit(alsa_card_gusclassic_exit);
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index 4f55fc3e66c..0aeaa6cf6cf 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -37,8 +37,11 @@
37#define SNDRV_LEGACY_FIND_FREE_DMA 37#define SNDRV_LEGACY_FIND_FREE_DMA
38#include <sound/initval.h> 38#include <sound/initval.h>
39 39
40#define CRD_NAME "Gravis UltraSound Extreme"
41#define DEV_NAME "gusextreme"
42
43MODULE_DESCRIPTION(CRD_NAME);
40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 44MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
41MODULE_DESCRIPTION("Gravis UltraSound Extreme");
42MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
43MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}"); 46MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}");
44 47
@@ -59,43 +62,107 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
59static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 62static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
60 63
61module_param_array(index, int, NULL, 0444); 64module_param_array(index, int, NULL, 0444);
62MODULE_PARM_DESC(index, "Index value for GUS Extreme soundcard."); 65MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
63module_param_array(id, charp, NULL, 0444); 66module_param_array(id, charp, NULL, 0444);
64MODULE_PARM_DESC(id, "ID string for GUS Extreme soundcard."); 67MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
65module_param_array(enable, bool, NULL, 0444); 68module_param_array(enable, bool, NULL, 0444);
66MODULE_PARM_DESC(enable, "Enable GUS Extreme soundcard."); 69MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
67module_param_array(port, long, NULL, 0444); 70module_param_array(port, long, NULL, 0444);
68MODULE_PARM_DESC(port, "Port # for GUS Extreme driver."); 71MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
69module_param_array(gf1_port, long, NULL, 0444); 72module_param_array(gf1_port, long, NULL, 0444);
70MODULE_PARM_DESC(gf1_port, "GF1 port # for GUS Extreme driver (optional)."); 73MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional).");
71module_param_array(mpu_port, long, NULL, 0444); 74module_param_array(mpu_port, long, NULL, 0444);
72MODULE_PARM_DESC(mpu_port, "MPU-401 port # for GUS Extreme driver."); 75MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
73module_param_array(irq, int, NULL, 0444); 76module_param_array(irq, int, NULL, 0444);
74MODULE_PARM_DESC(irq, "IRQ # for GUS Extreme driver."); 77MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
75module_param_array(mpu_irq, int, NULL, 0444); 78module_param_array(mpu_irq, int, NULL, 0444);
76MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for GUS Extreme driver."); 79MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
77module_param_array(gf1_irq, int, NULL, 0444); 80module_param_array(gf1_irq, int, NULL, 0444);
78MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for GUS Extreme driver."); 81MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver.");
79module_param_array(dma8, int, NULL, 0444); 82module_param_array(dma8, int, NULL, 0444);
80MODULE_PARM_DESC(dma8, "8-bit DMA # for GUS Extreme driver."); 83MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
81module_param_array(dma1, int, NULL, 0444); 84module_param_array(dma1, int, NULL, 0444);
82MODULE_PARM_DESC(dma1, "GF1 DMA # for GUS Extreme driver."); 85MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver.");
83module_param_array(joystick_dac, int, NULL, 0444); 86module_param_array(joystick_dac, int, NULL, 0444);
84MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Extreme driver."); 87MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
85module_param_array(channels, int, NULL, 0444); 88module_param_array(channels, int, NULL, 0444);
86MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); 89MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
87module_param_array(pcm_channels, int, NULL, 0444); 90module_param_array(pcm_channels, int, NULL, 0444);
88MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); 91MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
92
93static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n)
94{
95 return enable[n];
96}
97
98static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
99 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
100{
101 static long possible_ports[] = {0x220, 0x240, 0x260};
102 static int possible_irqs[] = {5, 9, 10, 7, -1};
103 static int possible_dmas[] = {1, 3, 0, -1};
104
105 int i, error;
106
107 if (irq[n] == SNDRV_AUTO_IRQ) {
108 irq[n] = snd_legacy_find_free_irq(possible_irqs);
109 if (irq[n] < 0) {
110 snd_printk(KERN_ERR "%s: unable to find a free IRQ "
111 "for ES1688\n", dev->bus_id);
112 return -EBUSY;
113 }
114 }
115 if (dma8[n] == SNDRV_AUTO_DMA) {
116 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
117 if (dma8[n] < 0) {
118 snd_printk(KERN_ERR "%s: unable to find a free DMA "
119 "for ES1688\n", dev->bus_id);
120 return -EBUSY;
121 }
122 }
89 123
90static struct platform_device *devices[SNDRV_CARDS]; 124 if (port[n] != SNDRV_AUTO_PORT)
125 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
126 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
91 127
128 i = 0;
129 do {
130 port[n] = possible_ports[i];
131 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
132 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
133 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
92 134
93#define PFX "gusextreme: " 135 return error;
136}
94 137
95static int __devinit snd_gusextreme_detect(int dev, 138static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card,
96 struct snd_card *card, 139 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
97 struct snd_gus_card * gus, 140{
98 struct snd_es1688 *es1688) 141 static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1};
142 static int possible_dmas[] = {5, 6, 7, 3, 1, -1};
143
144 if (gf1_irq[n] == SNDRV_AUTO_IRQ) {
145 gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs);
146 if (gf1_irq[n] < 0) {
147 snd_printk(KERN_ERR "%s: unable to find a free IRQ "
148 "for GF1\n", dev->bus_id);
149 return -EBUSY;
150 }
151 }
152 if (dma1[n] == SNDRV_AUTO_DMA) {
153 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
154 if (dma1[n] < 0) {
155 snd_printk(KERN_ERR "%s: unable to find a free DMA "
156 "for GF1\n", dev->bus_id);
157 return -EBUSY;
158 }
159 }
160 return snd_gus_create(card, gf1_port[n], gf1_irq[n], dma1[n], -1,
161 0, channels[n], pcm_channels[n], 0, rgus);
162}
163
164static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus,
165 struct snd_es1688 *es1688)
99{ 166{
100 unsigned long flags; 167 unsigned long flags;
101 unsigned char d; 168 unsigned char d;
@@ -117,12 +184,13 @@ static int __devinit snd_gusextreme_detect(int dev,
117 spin_lock_irqsave(&es1688->mixer_lock, flags); 184 spin_lock_irqsave(&es1688->mixer_lock, flags);
118 snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */ 185 snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */
119 spin_unlock_irqrestore(&es1688->mixer_lock, flags); 186 spin_unlock_irqrestore(&es1688->mixer_lock, flags);
187
120 spin_lock_irqsave(&es1688->reg_lock, flags); 188 spin_lock_irqsave(&es1688->reg_lock, flags);
121 outb(gf1_port[dev] & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); 189 outb(gus->gf1.port & 0x040 ? 2 : 0, ES1688P(es1688, INIT1));
122 outb(0, 0x201); 190 outb(0, 0x201);
123 outb(gf1_port[dev] & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); 191 outb(gus->gf1.port & 0x020 ? 2 : 0, ES1688P(es1688, INIT1));
124 outb(0, 0x201); 192 outb(0, 0x201);
125 outb(gf1_port[dev] & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); 193 outb(gus->gf1.port & 0x010 ? 3 : 1, ES1688P(es1688, INIT1));
126 spin_unlock_irqrestore(&es1688->reg_lock, flags); 194 spin_unlock_irqrestore(&es1688->reg_lock, flags);
127 195
128 udelay(100); 196 udelay(100);
@@ -139,253 +207,172 @@ static int __devinit snd_gusextreme_detect(int dev,
139 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); 207 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
140 return -EIO; 208 return -EIO;
141 } 209 }
142 return 0;
143}
144 210
145static void __devinit snd_gusextreme_init(int dev, struct snd_gus_card * gus) 211 return 0;
146{
147 gus->joystick_dac = joystick_dac[dev];
148} 212}
149 213
150static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) 214static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip)
151{ 215{
152 struct snd_card *card = chip->card; 216 struct snd_card *card = chip->card;
153 struct snd_ctl_elem_id id1, id2; 217 struct snd_ctl_elem_id id1, id2;
154 int err; 218 int error;
155 219
156 memset(&id1, 0, sizeof(id1)); 220 memset(&id1, 0, sizeof(id1));
157 memset(&id2, 0, sizeof(id2)); 221 memset(&id2, 0, sizeof(id2));
158 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 222 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
223
159 /* reassign AUX to SYNTHESIZER */ 224 /* reassign AUX to SYNTHESIZER */
160 strcpy(id1.name, "Aux Playback Volume"); 225 strcpy(id1.name, "Aux Playback Volume");
161 strcpy(id2.name, "Synth Playback Volume"); 226 strcpy(id2.name, "Synth Playback Volume");
162 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 227 error = snd_ctl_rename_id(card, &id1, &id2);
163 return err; 228 if (error < 0)
229 return error;
230
164 /* reassign Master Playback Switch to Synth Playback Switch */ 231 /* reassign Master Playback Switch to Synth Playback Switch */
165 strcpy(id1.name, "Master Playback Switch"); 232 strcpy(id1.name, "Master Playback Switch");
166 strcpy(id2.name, "Synth Playback Switch"); 233 strcpy(id2.name, "Synth Playback Switch");
167 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 234 error = snd_ctl_rename_id(card, &id1, &id2);
168 return err; 235 if (error < 0)
236 return error;
237
169 return 0; 238 return 0;
170} 239}
171 240
172static int __devinit snd_gusextreme_probe(struct platform_device *pdev) 241static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
173{ 242{
174 int dev = pdev->id;
175 static int possible_ess_irqs[] = {5, 9, 10, 7, -1};
176 static int possible_ess_dmas[] = {1, 3, 0, -1};
177 static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
178 static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1};
179 int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma;
180 struct snd_card *card; 243 struct snd_card *card;
181 struct snd_gus_card *gus; 244 struct snd_gus_card *gus;
182 struct snd_es1688 *es1688; 245 struct snd_es1688 *es1688;
183 struct snd_opl3 *opl3; 246 struct snd_opl3 *opl3;
184 int err; 247 int error;
185 248
186 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 249 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
187 if (card == NULL) 250 if (!card)
188 return -ENOMEM; 251 return -EINVAL;
189 252
190 xgf1_irq = gf1_irq[dev]; 253 if (mpu_port[n] == SNDRV_AUTO_PORT)
191 if (xgf1_irq == SNDRV_AUTO_IRQ) { 254 mpu_port[n] = 0;
192 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) {
193 snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n");
194 err = -EBUSY;
195 goto out;
196 }
197 }
198 xess_irq = irq[dev];
199 if (xess_irq == SNDRV_AUTO_IRQ) {
200 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) {
201 snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n");
202 err = -EBUSY;
203 goto out;
204 }
205 }
206 if (mpu_port[dev] == SNDRV_AUTO_PORT)
207 mpu_port[dev] = 0;
208 xmpu_irq = mpu_irq[dev];
209 if (xmpu_irq > 15)
210 xmpu_irq = -1;
211 xgf1_dma = dma1[dev];
212 if (xgf1_dma == SNDRV_AUTO_DMA) {
213 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) {
214 snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n");
215 err = -EBUSY;
216 goto out;
217 }
218 }
219 xess_dma = dma8[dev];
220 if (xess_dma == SNDRV_AUTO_DMA) {
221 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) {
222 snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n");
223 err = -EBUSY;
224 goto out;
225 }
226 }
227 255
228 if (port[dev] != SNDRV_AUTO_PORT) { 256 if (mpu_irq[n] > 15)
229 err = snd_es1688_create(card, port[dev], mpu_port[dev], 257 mpu_irq[n] = -1;
230 xess_irq, xmpu_irq, xess_dma, 258
231 ES1688_HW_1688, &es1688); 259 error = snd_gusextreme_es1688_create(card, dev, n, &es1688);
232 } else { 260 if (error < 0)
233 /* auto-probe legacy ports */
234 static unsigned long possible_ports[] = {0x220, 0x240, 0x260};
235 int i;
236 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
237 err = snd_es1688_create(card,
238 possible_ports[i],
239 mpu_port[dev],
240 xess_irq, xmpu_irq, xess_dma,
241 ES1688_HW_1688, &es1688);
242 if (err >= 0) {
243 port[dev] = possible_ports[i];
244 break;
245 }
246 }
247 }
248 if (err < 0)
249 goto out; 261 goto out;
250 262
251 if (gf1_port[dev] < 0) 263 if (gf1_port[n] < 0)
252 gf1_port[dev] = port[dev] + 0x20; 264 gf1_port[n] = es1688->port + 0x20;
253 if ((err = snd_gus_create(card, 265
254 gf1_port[dev], 266 error = snd_gusextreme_gus_card_create(card, dev, n, &gus);
255 xgf1_irq, 267 if (error < 0)
256 xgf1_dma,
257 -1,
258 0, channels[dev],
259 pcm_channels[dev], 0,
260 &gus)) < 0)
261 goto out; 268 goto out;
262 269
263 if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) 270 error = snd_gusextreme_detect(gus, es1688);
271 if (error < 0)
264 goto out; 272 goto out;
265 273
266 snd_gusextreme_init(dev, gus); 274 gus->joystick_dac = joystick_dac[n];
267 if ((err = snd_gus_initialize(gus)) < 0) 275
276 error = snd_gus_initialize(gus);
277 if (error < 0)
268 goto out; 278 goto out;
269 279
280 error = -ENODEV;
270 if (!gus->ess_flag) { 281 if (!gus->ess_flag) {
271 snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); 282 snd_printk(KERN_ERR "%s: GUS Extreme soundcard was not "
272 err = -ENODEV; 283 "detected at 0x%lx\n", dev->bus_id, gus->gf1.port);
273 goto out; 284 goto out;
274 } 285 }
275 if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) 286 gus->codec_flag = 1;
287
288 error = snd_es1688_pcm(es1688, 0, NULL);
289 if (error < 0)
276 goto out; 290 goto out;
277 291
278 if ((err = snd_es1688_mixer(es1688)) < 0) 292 error = snd_es1688_mixer(es1688);
293 if (error < 0)
279 goto out; 294 goto out;
280 295
281 snd_component_add(card, "ES1688"); 296 snd_component_add(card, "ES1688");
282 if (pcm_channels[dev] > 0) { 297
283 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) 298 if (pcm_channels[n] > 0) {
299 error = snd_gf1_pcm_new(gus, 1, 1, NULL);
300 if (error < 0)
284 goto out; 301 goto out;
285 } 302 }
286 if ((err = snd_gf1_new_mixer(gus)) < 0) 303
304 error = snd_gf1_new_mixer(gus);
305 if (error < 0)
287 goto out; 306 goto out;
288 307
289 if ((err = snd_gusextreme_mixer(es1688)) < 0) 308 error = snd_gusextreme_mixer(es1688);
309 if (error < 0)
290 goto out; 310 goto out;
291 311
292 if (snd_opl3_create(card, es1688->port, es1688->port + 2, 312 if (snd_opl3_create(card, es1688->port, es1688->port + 2,
293 OPL3_HW_OPL3, 0, &opl3) < 0) { 313 OPL3_HW_OPL3, 0, &opl3) < 0)
294 printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); 314 printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n",
295 } else { 315 dev->bus_id, es1688->port);
296 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) 316 else {
317 error = snd_opl3_hwdep_new(opl3, 0, 2, NULL);
318 if (error < 0)
297 goto out; 319 goto out;
298 } 320 }
299 321
300 if (es1688->mpu_port >= 0x300 && 322 if (es1688->mpu_port >= 0x300) {
301 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, 323 error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
302 es1688->mpu_port, 0, 324 es1688->mpu_port, 0,
303 xmpu_irq, 325 mpu_irq[n], IRQF_DISABLED, NULL);
304 IRQF_DISABLED, 326 if (error < 0)
305 NULL)) < 0) 327 goto out;
306 goto out; 328 }
307 329
308 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", 330 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, "
309 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); 331 "irq %i&%i, dma %i&%i", es1688->port,
332 gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8);
310 333
311 snd_card_set_dev(card, &pdev->dev); 334 snd_card_set_dev(card, dev);
312 335
313 if ((err = snd_card_register(card)) < 0) 336 error = snd_card_register(card);
337 if (error < 0)
314 goto out; 338 goto out;
315 339
316 platform_set_drvdata(pdev, card); 340 dev_set_drvdata(dev, card);
317 return 0; 341 return 0;
318 342
319 out: 343out: snd_card_free(card);
320 snd_card_free(card); 344 return error;
321 return err;
322} 345}
323 346
324static int __devexit snd_gusextreme_remove(struct platform_device *devptr) 347static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n)
325{ 348{
326 snd_card_free(platform_get_drvdata(devptr)); 349 snd_card_free(dev_get_drvdata(dev));
327 platform_set_drvdata(devptr, NULL); 350 dev_set_drvdata(dev, NULL);
328 return 0; 351 return 0;
329} 352}
330 353
331#define GUSEXTREME_DRIVER "snd_gusextreme" 354static struct isa_driver snd_gusextreme_driver = {
332 355 .match = snd_gusextreme_match,
333static struct platform_driver snd_gusextreme_driver = {
334 .probe = snd_gusextreme_probe, 356 .probe = snd_gusextreme_probe,
335 .remove = __devexit_p(snd_gusextreme_remove), 357 .remove = snd_gusextreme_remove,
336 /* FIXME: suspend/resume */ 358#if 0 /* FIXME */
359 .suspend = snd_gusextreme_suspend,
360 .resume = snd_gusextreme_resume,
361#endif
337 .driver = { 362 .driver = {
338 .name = GUSEXTREME_DRIVER 363 .name = DEV_NAME
339 }, 364 }
340}; 365};
341 366
342static void __init_or_module snd_gusextreme_unregister_all(void)
343{
344 int i;
345
346 for (i = 0; i < ARRAY_SIZE(devices); ++i)
347 platform_device_unregister(devices[i]);
348 platform_driver_unregister(&snd_gusextreme_driver);
349}
350
351static int __init alsa_card_gusextreme_init(void) 367static int __init alsa_card_gusextreme_init(void)
352{ 368{
353 int i, cards, err; 369 return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS);
354
355 err = platform_driver_register(&snd_gusextreme_driver);
356 if (err < 0)
357 return err;
358
359 cards = 0;
360 for (i = 0; i < SNDRV_CARDS; i++) {
361 struct platform_device *device;
362 if (! enable[i])
363 continue;
364 device = platform_device_register_simple(GUSEXTREME_DRIVER,
365 i, NULL, 0);
366 if (IS_ERR(device))
367 continue;
368 if (!platform_get_drvdata(device)) {
369 platform_device_unregister(device);
370 continue;
371 }
372 devices[i] = device;
373 cards++;
374 }
375 if (!cards) {
376#ifdef MODULE
377 printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n");
378#endif
379 snd_gusextreme_unregister_all();
380 return -ENODEV;
381 }
382 return 0;
383} 370}
384 371
385static void __exit alsa_card_gusextreme_exit(void) 372static void __exit alsa_card_gusextreme_exit(void)
386{ 373{
387 snd_gusextreme_unregister_all(); 374 isa_unregister_driver(&snd_gusextreme_driver);
388} 375}
389 376
390module_init(alsa_card_gusextreme_init) 377module_init(alsa_card_gusextreme_init);
391module_exit(alsa_card_gusextreme_exit) 378module_exit(alsa_card_gusextreme_exit);
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index d1ad90ca035..708783d4351 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -72,8 +72,6 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
72module_param_array(pcm_channels, int, NULL, 0444); 72module_param_array(pcm_channels, int, NULL, 0444);
73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); 73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
74 74
75static struct platform_device *devices[SNDRV_CARDS];
76
77struct snd_gusmax { 75struct snd_gusmax {
78 int irq; 76 int irq;
79 struct snd_card *card; 77 struct snd_card *card;
@@ -205,9 +203,13 @@ static void snd_gusmax_free(struct snd_card *card)
205 free_irq(maxcard->irq, (void *)maxcard); 203 free_irq(maxcard->irq, (void *)maxcard);
206} 204}
207 205
208static int __devinit snd_gusmax_probe(struct platform_device *pdev) 206static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev)
207{
208 return enable[dev];
209}
210
211static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev)
209{ 212{
210 int dev = pdev->id;
211 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 213 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
212 static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; 214 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
213 int xirq, xdma1, xdma2, err; 215 int xirq, xdma1, xdma2, err;
@@ -333,7 +335,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
333 if (xdma2 >= 0) 335 if (xdma2 >= 0)
334 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 336 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
335 337
336 snd_card_set_dev(card, &pdev->dev); 338 snd_card_set_dev(card, pdev);
337 339
338 if ((err = snd_card_register(card)) < 0) 340 if ((err = snd_card_register(card)) < 0)
339 goto _err; 341 goto _err;
@@ -341,7 +343,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
341 maxcard->gus = gus; 343 maxcard->gus = gus;
342 maxcard->cs4231 = cs4231; 344 maxcard->cs4231 = cs4231;
343 345
344 platform_set_drvdata(pdev, card); 346 dev_set_drvdata(pdev, card);
345 return 0; 347 return 0;
346 348
347 _err: 349 _err:
@@ -349,70 +351,33 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
349 return err; 351 return err;
350} 352}
351 353
352static int __devexit snd_gusmax_remove(struct platform_device *devptr) 354static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev)
353{ 355{
354 snd_card_free(platform_get_drvdata(devptr)); 356 snd_card_free(dev_get_drvdata(devptr));
355 platform_set_drvdata(devptr, NULL); 357 dev_set_drvdata(devptr, NULL);
356 return 0; 358 return 0;
357} 359}
358 360
359#define GUSMAX_DRIVER "snd_gusmax" 361#define DEV_NAME "gusmax"
360 362
361static struct platform_driver snd_gusmax_driver = { 363static struct isa_driver snd_gusmax_driver = {
364 .match = snd_gusmax_match,
362 .probe = snd_gusmax_probe, 365 .probe = snd_gusmax_probe,
363 .remove = __devexit_p(snd_gusmax_remove), 366 .remove = __devexit_p(snd_gusmax_remove),
364 /* FIXME: suspend/resume */ 367 /* FIXME: suspend/resume */
365 .driver = { 368 .driver = {
366 .name = GUSMAX_DRIVER 369 .name = DEV_NAME
367 }, 370 },
368}; 371};
369 372
370static void __init_or_module snd_gusmax_unregister_all(void)
371{
372 int i;
373
374 for (i = 0; i < ARRAY_SIZE(devices); ++i)
375 platform_device_unregister(devices[i]);
376 platform_driver_unregister(&snd_gusmax_driver);
377}
378
379static int __init alsa_card_gusmax_init(void) 373static int __init alsa_card_gusmax_init(void)
380{ 374{
381 int i, cards, err; 375 return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
382
383 err = platform_driver_register(&snd_gusmax_driver);
384 if (err < 0)
385 return err;
386
387 cards = 0;
388 for (i = 0; i < SNDRV_CARDS; i++) {
389 struct platform_device *device;
390 if (! enable[i])
391 continue;
392 device = platform_device_register_simple(GUSMAX_DRIVER,
393 i, NULL, 0);
394 if (IS_ERR(device))
395 continue;
396 if (!platform_get_drvdata(device)) {
397 platform_device_unregister(device);
398 continue;
399 }
400 devices[i] = device;
401 cards++;
402 }
403 if (!cards) {
404#ifdef MODULE
405 printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
406#endif
407 snd_gusmax_unregister_all();
408 return -ENODEV;
409 }
410 return 0;
411} 376}
412 377
413static void __exit alsa_card_gusmax_exit(void) 378static void __exit alsa_card_gusmax_exit(void)
414{ 379{
415 snd_gusmax_unregister_all(); 380 isa_unregister_driver(&snd_gusmax_driver);
416} 381}
417 382
418module_init(alsa_card_gusmax_init) 383module_init(alsa_card_gusmax_init)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 4ec2d79431f..0220cdbe1a2 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -25,7 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pnp.h> 31#include <linux/pnp.h>
@@ -115,9 +115,6 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
115module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
117 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
121struct snd_interwave { 118struct snd_interwave {
122 int irq; 119 int irq;
123 struct snd_card *card; 120 struct snd_card *card;
@@ -138,6 +135,8 @@ struct snd_interwave {
138 135
139 136
140#ifdef CONFIG_PNP 137#ifdef CONFIG_PNP
138static int isa_registered;
139static int pnp_registered;
141 140
142static struct pnp_card_device_id snd_interwave_pnpids[] = { 141static struct pnp_card_device_id snd_interwave_pnpids[] = {
143#ifndef SNDRV_STB 142#ifndef SNDRV_STB
@@ -793,7 +792,7 @@ static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
793 return 0; 792 return 0;
794} 793}
795 794
796static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) 795static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr)
797{ 796{
798 struct snd_card *card; 797 struct snd_card *card;
799 int err; 798 int err;
@@ -802,18 +801,30 @@ static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device
802 if (! card) 801 if (! card)
803 return -ENOMEM; 802 return -ENOMEM;
804 803
805 snd_card_set_dev(card, &devptr->dev); 804 snd_card_set_dev(card, devptr);
806 if ((err = snd_interwave_probe(card, dev)) < 0) { 805 if ((err = snd_interwave_probe(card, dev)) < 0) {
807 snd_card_free(card); 806 snd_card_free(card);
808 return err; 807 return err;
809 } 808 }
810 platform_set_drvdata(devptr, card); 809 dev_set_drvdata(devptr, card);
811 return 0; 810 return 0;
812} 811}
813 812
814static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) 813static int __devinit snd_interwave_isa_match(struct device *pdev,
814 unsigned int dev)
815{
816 if (!enable[dev])
817 return 0;
818#ifdef CONFIG_PNP
819 if (isapnp[dev])
820 return 0;
821#endif
822 return 1;
823}
824
825static int __devinit snd_interwave_isa_probe(struct device *pdev,
826 unsigned int dev)
815{ 827{
816 int dev = pdev->id;
817 int err; 828 int err;
818 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 829 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
819 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; 830 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
@@ -838,13 +849,13 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
838 } 849 }
839 850
840 if (port[dev] != SNDRV_AUTO_PORT) 851 if (port[dev] != SNDRV_AUTO_PORT)
841 return snd_interwave_nonpnp_probe1(dev, pdev); 852 return snd_interwave_isa_probe1(dev, pdev);
842 else { 853 else {
843 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; 854 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
844 int i; 855 int i;
845 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 856 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
846 port[dev] = possible_ports[i]; 857 port[dev] = possible_ports[i];
847 err = snd_interwave_nonpnp_probe1(dev, pdev); 858 err = snd_interwave_isa_probe1(dev, pdev);
848 if (! err) 859 if (! err)
849 return 0; 860 return 0;
850 } 861 }
@@ -852,16 +863,17 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
852 } 863 }
853} 864}
854 865
855static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) 866static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev)
856{ 867{
857 snd_card_free(platform_get_drvdata(devptr)); 868 snd_card_free(dev_get_drvdata(devptr));
858 platform_set_drvdata(devptr, NULL); 869 dev_set_drvdata(devptr, NULL);
859 return 0; 870 return 0;
860} 871}
861 872
862static struct platform_driver snd_interwave_driver = { 873static struct isa_driver snd_interwave_driver = {
863 .probe = snd_interwave_nonpnp_probe, 874 .match = snd_interwave_isa_match,
864 .remove = __devexit_p(snd_interwave_nonpnp_remove), 875 .probe = snd_interwave_isa_probe,
876 .remove = __devexit_p(snd_interwave_isa_remove),
865 /* FIXME: suspend,resume */ 877 /* FIXME: suspend,resume */
866 .driver = { 878 .driver = {
867 .name = INTERWAVE_DRIVER 879 .name = INTERWAVE_DRIVER
@@ -869,8 +881,6 @@ static struct platform_driver snd_interwave_driver = {
869}; 881};
870 882
871#ifdef CONFIG_PNP 883#ifdef CONFIG_PNP
872static unsigned int __devinitdata interwave_pnp_devices;
873
874static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, 884static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
875 const struct pnp_card_device_id *pid) 885 const struct pnp_card_device_id *pid)
876{ 886{
@@ -900,7 +910,6 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
900 } 910 }
901 pnp_set_card_drvdata(pcard, card); 911 pnp_set_card_drvdata(pcard, card);
902 dev++; 912 dev++;
903 interwave_pnp_devices++;
904 return 0; 913 return 0;
905} 914}
906 915
@@ -921,64 +930,33 @@ static struct pnp_card_driver interwave_pnpc_driver = {
921 930
922#endif /* CONFIG_PNP */ 931#endif /* CONFIG_PNP */
923 932
924static void __init_or_module snd_interwave_unregister_all(void)
925{
926 int i;
927
928 if (pnp_registered)
929 pnp_unregister_card_driver(&interwave_pnpc_driver);
930 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
931 platform_device_unregister(platform_devices[i]);
932 platform_driver_unregister(&snd_interwave_driver);
933}
934
935static int __init alsa_card_interwave_init(void) 933static int __init alsa_card_interwave_init(void)
936{ 934{
937 int i, err, cards = 0; 935 int err;
938
939 if ((err = platform_driver_register(&snd_interwave_driver)) < 0)
940 return err;
941 936
942 for (i = 0; i < SNDRV_CARDS; i++) { 937 err = isa_register_driver(&snd_interwave_driver, SNDRV_CARDS);
943 struct platform_device *device;
944 if (! enable[i])
945 continue;
946#ifdef CONFIG_PNP 938#ifdef CONFIG_PNP
947 if (isapnp[i]) 939 if (!err)
948 continue; 940 isa_registered = 1;
949#endif
950 device = platform_device_register_simple(INTERWAVE_DRIVER,
951 i, NULL, 0);
952 if (IS_ERR(device))
953 continue;
954 if (!platform_get_drvdata(device)) {
955 platform_device_unregister(device);
956 continue;
957 }
958 platform_devices[i] = device;
959 cards++;
960 }
961 941
962 /* ISA PnP cards */
963 err = pnp_register_card_driver(&interwave_pnpc_driver); 942 err = pnp_register_card_driver(&interwave_pnpc_driver);
964 if (!err) { 943 if (!err)
965 pnp_registered = 1; 944 pnp_registered = 1;
966 cards += interwave_pnp_devices;;
967 }
968 945
969 if (!cards) { 946 if (isa_registered)
970#ifdef MODULE 947 err = 0;
971 printk(KERN_ERR "InterWave soundcard not found or device busy\n");
972#endif 948#endif
973 snd_interwave_unregister_all(); 949 return err;
974 return -ENODEV;
975 }
976 return 0;
977} 950}
978 951
979static void __exit alsa_card_interwave_exit(void) 952static void __exit alsa_card_interwave_exit(void)
980{ 953{
981 snd_interwave_unregister_all(); 954#ifdef CONFIG_PNP
955 if (pnp_registered)
956 pnp_unregister_card_driver(&interwave_pnpc_driver);
957 if (isa_registered)
958#endif
959 isa_unregister_driver(&snd_interwave_driver);
982} 960}
983 961
984module_init(alsa_card_interwave_init) 962module_init(alsa_card_interwave_init)
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index f3db686b1c0..e70db32991d 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pm.h> 27#include <linux/pm.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
@@ -91,12 +91,11 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
91module_param_array(opl3sa3_ymode, int, NULL, 0444); 91module_param_array(opl3sa3_ymode, int, NULL, 0444);
92MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 92MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
93 93
94static struct platform_device *platform_devices[SNDRV_CARDS];
95#ifdef CONFIG_PNP 94#ifdef CONFIG_PNP
95static int isa_registered;
96static int pnp_registered; 96static int pnp_registered;
97static int pnpc_registered; 97static int pnpc_registered;
98#endif 98#endif
99static unsigned int snd_opl3sa2_devices;
100 99
101/* control ports */ 100/* control ports */
102#define OPL3SA2_PM_CTRL 0x01 101#define OPL3SA2_PM_CTRL 0x01
@@ -165,6 +164,8 @@ static struct pnp_card_device_id snd_opl3sa2_pnpids[] = {
165 { .id = "YMH0801", .devs = { { "YMH0021" } } }, 164 { .id = "YMH0801", .devs = { { "YMH0021" } } },
166 /* NeoMagic MagicWave 3DX */ 165 /* NeoMagic MagicWave 3DX */
167 { .id = "NMX2200", .devs = { { "YMH2210" } } }, 166 { .id = "NMX2200", .devs = { { "YMH2210" } } },
167 /* NeoMagic MagicWave 3D */
168 { .id = "NMX2200", .devs = { { "NMX2210" } } },
168 /* --- */ 169 /* --- */
169 { .id = "" } /* end */ 170 { .id = "" } /* end */
170}; 171};
@@ -783,7 +784,6 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
783 } 784 }
784 pnp_set_drvdata(pdev, card); 785 pnp_set_drvdata(pdev, card);
785 dev++; 786 dev++;
786 snd_opl3sa2_devices++;
787 return 0; 787 return 0;
788} 788}
789 789
@@ -850,7 +850,6 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
850 } 850 }
851 pnp_set_card_drvdata(pcard, card); 851 pnp_set_card_drvdata(pcard, card);
852 dev++; 852 dev++;
853 snd_opl3sa2_devices++;
854 return 0; 853 return 0;
855} 854}
856 855
@@ -884,138 +883,121 @@ static struct pnp_card_driver opl3sa2_pnpc_driver = {
884}; 883};
885#endif /* CONFIG_PNP */ 884#endif /* CONFIG_PNP */
886 885
887static int __devinit snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) 886static int __devinit snd_opl3sa2_isa_match(struct device *pdev,
887 unsigned int dev)
888{ 888{
889 struct snd_card *card; 889 if (!enable[dev])
890 int err; 890 return 0;
891 int dev = pdev->id; 891#ifdef CONFIG_PNP
892 892 if (isapnp[dev])
893 return 0;
894#endif
893 if (port[dev] == SNDRV_AUTO_PORT) { 895 if (port[dev] == SNDRV_AUTO_PORT) {
894 snd_printk(KERN_ERR PFX "specify port\n"); 896 snd_printk(KERN_ERR PFX "specify port\n");
895 return -EINVAL; 897 return 0;
896 } 898 }
897 if (wss_port[dev] == SNDRV_AUTO_PORT) { 899 if (wss_port[dev] == SNDRV_AUTO_PORT) {
898 snd_printk(KERN_ERR PFX "specify wss_port\n"); 900 snd_printk(KERN_ERR PFX "specify wss_port\n");
899 return -EINVAL; 901 return 0;
900 } 902 }
901 if (fm_port[dev] == SNDRV_AUTO_PORT) { 903 if (fm_port[dev] == SNDRV_AUTO_PORT) {
902 snd_printk(KERN_ERR PFX "specify fm_port\n"); 904 snd_printk(KERN_ERR PFX "specify fm_port\n");
903 return -EINVAL; 905 return 0;
904 } 906 }
905 if (midi_port[dev] == SNDRV_AUTO_PORT) { 907 if (midi_port[dev] == SNDRV_AUTO_PORT) {
906 snd_printk(KERN_ERR PFX "specify midi_port\n"); 908 snd_printk(KERN_ERR PFX "specify midi_port\n");
907 return -EINVAL; 909 return 0;
908 } 910 }
911 return 1;
912}
913
914static int __devinit snd_opl3sa2_isa_probe(struct device *pdev,
915 unsigned int dev)
916{
917 struct snd_card *card;
918 int err;
909 919
910 card = snd_opl3sa2_card_new(dev); 920 card = snd_opl3sa2_card_new(dev);
911 if (! card) 921 if (! card)
912 return -ENOMEM; 922 return -ENOMEM;
913 snd_card_set_dev(card, &pdev->dev); 923 snd_card_set_dev(card, pdev);
914 if ((err = snd_opl3sa2_probe(card, dev)) < 0) { 924 if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
915 snd_card_free(card); 925 snd_card_free(card);
916 return err; 926 return err;
917 } 927 }
918 platform_set_drvdata(pdev, card); 928 dev_set_drvdata(pdev, card);
919 return 0; 929 return 0;
920} 930}
921 931
922static int __devexit snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) 932static int __devexit snd_opl3sa2_isa_remove(struct device *devptr,
933 unsigned int dev)
923{ 934{
924 snd_card_free(platform_get_drvdata(devptr)); 935 snd_card_free(dev_get_drvdata(devptr));
925 platform_set_drvdata(devptr, NULL); 936 dev_set_drvdata(devptr, NULL);
926 return 0; 937 return 0;
927} 938}
928 939
929#ifdef CONFIG_PM 940#ifdef CONFIG_PM
930static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 941static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n,
942 pm_message_t state)
931{ 943{
932 return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); 944 return snd_opl3sa2_suspend(dev_get_drvdata(dev), state);
933} 945}
934 946
935static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) 947static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n)
936{ 948{
937 return snd_opl3sa2_resume(platform_get_drvdata(dev)); 949 return snd_opl3sa2_resume(dev_get_drvdata(dev));
938} 950}
939#endif 951#endif
940 952
941#define OPL3SA2_DRIVER "snd_opl3sa2" 953#define DEV_NAME "opl3sa2"
942 954
943static struct platform_driver snd_opl3sa2_nonpnp_driver = { 955static struct isa_driver snd_opl3sa2_isa_driver = {
944 .probe = snd_opl3sa2_nonpnp_probe, 956 .match = snd_opl3sa2_isa_match,
945 .remove = __devexit( snd_opl3sa2_nonpnp_remove), 957 .probe = snd_opl3sa2_isa_probe,
958 .remove = __devexit_p(snd_opl3sa2_isa_remove),
946#ifdef CONFIG_PM 959#ifdef CONFIG_PM
947 .suspend = snd_opl3sa2_nonpnp_suspend, 960 .suspend = snd_opl3sa2_isa_suspend,
948 .resume = snd_opl3sa2_nonpnp_resume, 961 .resume = snd_opl3sa2_isa_resume,
949#endif 962#endif
950 .driver = { 963 .driver = {
951 .name = OPL3SA2_DRIVER 964 .name = DEV_NAME
952 }, 965 },
953}; 966};
954 967
955static void __init_or_module snd_opl3sa2_unregister_all(void)
956{
957 int i;
958
959#ifdef CONFIG_PNP
960 if (pnpc_registered)
961 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
962 if (pnp_registered)
963 pnp_unregister_driver(&opl3sa2_pnp_driver);
964#endif
965 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
966 platform_device_unregister(platform_devices[i]);
967 platform_driver_unregister(&snd_opl3sa2_nonpnp_driver);
968}
969
970static int __init alsa_card_opl3sa2_init(void) 968static int __init alsa_card_opl3sa2_init(void)
971{ 969{
972 int i, err; 970 int err;
973
974 if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0)
975 return err;
976 971
977 for (i = 0; i < SNDRV_CARDS; i++) { 972 err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS);
978 struct platform_device *device;
979 if (! enable[i])
980 continue;
981#ifdef CONFIG_PNP 973#ifdef CONFIG_PNP
982 if (isapnp[i]) 974 if (!err)
983 continue; 975 isa_registered = 1;
984#endif
985 device = platform_device_register_simple(OPL3SA2_DRIVER,
986 i, NULL, 0);
987 if (IS_ERR(device))
988 continue;
989 if (!platform_get_drvdata(device)) {
990 platform_device_unregister(device);
991 continue;
992 }
993 platform_devices[i] = device;
994 snd_opl3sa2_devices++;
995 }
996 976
997#ifdef CONFIG_PNP
998 err = pnp_register_driver(&opl3sa2_pnp_driver); 977 err = pnp_register_driver(&opl3sa2_pnp_driver);
999 if (!err) 978 if (!err)
1000 pnp_registered = 1; 979 pnp_registered = 1;
980
1001 err = pnp_register_card_driver(&opl3sa2_pnpc_driver); 981 err = pnp_register_card_driver(&opl3sa2_pnpc_driver);
1002 if (!err) 982 if (!err)
1003 pnpc_registered = 1; 983 pnpc_registered = 1;
1004#endif
1005 984
1006 if (!snd_opl3sa2_devices) { 985 if (isa_registered || pnp_registered)
1007#ifdef MODULE 986 err = 0;
1008 snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n");
1009#endif 987#endif
1010 snd_opl3sa2_unregister_all(); 988 return err;
1011 return -ENODEV;
1012 }
1013 return 0;
1014} 989}
1015 990
1016static void __exit alsa_card_opl3sa2_exit(void) 991static void __exit alsa_card_opl3sa2_exit(void)
1017{ 992{
1018 snd_opl3sa2_unregister_all(); 993#ifdef CONFIG_PNP
994 if (pnpc_registered)
995 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
996 if (pnp_registered)
997 pnp_unregister_driver(&opl3sa2_pnp_driver);
998 if (isa_registered)
999#endif
1000 isa_unregister_driver(&snd_opl3sa2_isa_driver);
1019} 1001}
1020 1002
1021module_init(alsa_card_opl3sa2_init) 1003module_init(alsa_card_opl3sa2_init)
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index 1dd98375ac8..cd29b30b362 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -25,7 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/ioport.h> 31#include <linux/ioport.h>
@@ -137,10 +137,6 @@ struct snd_miro {
137 137
138static void snd_miro_proc_init(struct snd_miro * miro); 138static void snd_miro_proc_init(struct snd_miro * miro);
139 139
140#define DRIVER_NAME "snd-miro"
141
142static struct platform_device *device;
143
144static char * snd_opti9xx_names[] = { 140static char * snd_opti9xx_names[] = {
145 "unkown", 141 "unkown",
146 "82C928", "82C929", 142 "82C928", "82C929",
@@ -558,7 +554,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol,
558 return change; 554 return change;
559} 555}
560 556
561static struct snd_kcontrol_new snd_miro_controls[] = { 557static struct snd_kcontrol_new snd_miro_controls[] __devinitdata = {
562MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER), 558MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER),
563MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC), 559MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC),
564MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE), 560MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE),
@@ -570,7 +566,7 @@ MIRO_DOUBLE("Aux Playback Volume", 2, ACI_GET_LINE2, ACI_SET_LINE2),
570 566
571/* Equalizer with seven bands (only PCM20) 567/* Equalizer with seven bands (only PCM20)
572 from -12dB up to +12dB on each band */ 568 from -12dB up to +12dB on each band */
573static struct snd_kcontrol_new snd_miro_eq_controls[] = { 569static struct snd_kcontrol_new snd_miro_eq_controls[] __devinitdata = {
574MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1), 570MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1),
575MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2), 571MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2),
576MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3), 572MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3),
@@ -580,15 +576,15 @@ MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, ACI_GET_EQ6, ACI_SET_EQ6),
580MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7), 576MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7),
581}; 577};
582 578
583static struct snd_kcontrol_new snd_miro_radio_control[] = { 579static struct snd_kcontrol_new snd_miro_radio_control[] __devinitdata = {
584MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1), 580MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1),
585}; 581};
586 582
587static struct snd_kcontrol_new snd_miro_line_control[] = { 583static struct snd_kcontrol_new snd_miro_line_control[] __devinitdata = {
588MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1), 584MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1),
589}; 585};
590 586
591static struct snd_kcontrol_new snd_miro_preamp_control[] = { 587static struct snd_kcontrol_new snd_miro_preamp_control[] __devinitdata = {
592{ 588{
593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
594 .name = "Mic Boost", 590 .name = "Mic Boost",
@@ -598,7 +594,7 @@ static struct snd_kcontrol_new snd_miro_preamp_control[] = {
598 .put = snd_miro_put_preamp, 594 .put = snd_miro_put_preamp,
599}}; 595}};
600 596
601static struct snd_kcontrol_new snd_miro_amp_control[] = { 597static struct snd_kcontrol_new snd_miro_amp_control[] __devinitdata = {
602{ 598{
603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
604 .name = "Line Boost", 600 .name = "Line Boost",
@@ -608,7 +604,7 @@ static struct snd_kcontrol_new snd_miro_amp_control[] = {
608 .put = snd_miro_put_amp, 604 .put = snd_miro_put_amp,
609}}; 605}};
610 606
611static struct snd_kcontrol_new snd_miro_capture_control[] = { 607static struct snd_kcontrol_new snd_miro_capture_control[] __devinitdata = {
612{ 608{
613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
614 .name = "PCM Capture Switch", 610 .name = "PCM Capture Switch",
@@ -618,7 +614,7 @@ static struct snd_kcontrol_new snd_miro_capture_control[] = {
618 .put = snd_miro_put_capture, 614 .put = snd_miro_put_capture,
619}}; 615}};
620 616
621static unsigned char aci_init_values[][2] __initdata = { 617static unsigned char aci_init_values[][2] __devinitdata = {
622 { ACI_SET_MUTE, 0x00 }, 618 { ACI_SET_MUTE, 0x00 },
623 { ACI_SET_POWERAMP, 0x00 }, 619 { ACI_SET_POWERAMP, 0x00 },
624 { ACI_SET_PREAMP, 0x00 }, 620 { ACI_SET_PREAMP, 0x00 },
@@ -641,7 +637,7 @@ static unsigned char aci_init_values[][2] __initdata = {
641 { ACI_SET_MASTER + 1, 0x20 }, 637 { ACI_SET_MASTER + 1, 0x20 },
642}; 638};
643 639
644static int __init snd_set_aci_init_values(struct snd_miro *miro) 640static int __devinit snd_set_aci_init_values(struct snd_miro *miro)
645{ 641{
646 int idx, error; 642 int idx, error;
647 643
@@ -751,7 +747,8 @@ static long snd_legacy_find_free_ioport(long *port_table, long size)
751 return -1; 747 return -1;
752} 748}
753 749
754static int __init snd_miro_init(struct snd_miro *chip, unsigned short hardware) 750static int __devinit snd_miro_init(struct snd_miro *chip,
751 unsigned short hardware)
755{ 752{
756 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 753 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
757 754
@@ -962,7 +959,7 @@ static void snd_miro_proc_read(struct snd_info_entry * entry,
962 snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); 959 snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp);
963} 960}
964 961
965static void __init snd_miro_proc_init(struct snd_miro * miro) 962static void __devinit snd_miro_proc_init(struct snd_miro * miro)
966{ 963{
967 struct snd_info_entry *entry; 964 struct snd_info_entry *entry;
968 965
@@ -974,7 +971,7 @@ static void __init snd_miro_proc_init(struct snd_miro * miro)
974 * Init 971 * Init
975 */ 972 */
976 973
977static int __init snd_miro_configure(struct snd_miro *chip) 974static int __devinit snd_miro_configure(struct snd_miro *chip)
978{ 975{
979 unsigned char wss_base_bits; 976 unsigned char wss_base_bits;
980 unsigned char irq_bits; 977 unsigned char irq_bits;
@@ -1131,7 +1128,8 @@ __skip_mpu:
1131 return 0; 1128 return 0;
1132} 1129}
1133 1130
1134static int __init snd_card_miro_detect(struct snd_card *card, struct snd_miro *chip) 1131static int __devinit snd_card_miro_detect(struct snd_card *card,
1132 struct snd_miro *chip)
1135{ 1133{
1136 int i, err; 1134 int i, err;
1137 unsigned char value; 1135 unsigned char value;
@@ -1157,7 +1155,8 @@ static int __init snd_card_miro_detect(struct snd_card *card, struct snd_miro *c
1157 return -ENODEV; 1155 return -ENODEV;
1158} 1156}
1159 1157
1160static int __init snd_card_miro_aci_detect(struct snd_card *card, struct snd_miro * miro) 1158static int __devinit snd_card_miro_aci_detect(struct snd_card *card,
1159 struct snd_miro * miro)
1161{ 1160{
1162 unsigned char regval; 1161 unsigned char regval;
1163 int i; 1162 int i;
@@ -1213,7 +1212,12 @@ static void snd_card_miro_free(struct snd_card *card)
1213 release_and_free_resource(miro->res_mc_base); 1212 release_and_free_resource(miro->res_mc_base);
1214} 1213}
1215 1214
1216static int __init snd_miro_probe(struct platform_device *devptr) 1215static int __devinit snd_miro_match(struct device *devptr, unsigned int n)
1216{
1217 return 1;
1218}
1219
1220static int __devinit snd_miro_probe(struct device *devptr, unsigned int n)
1217{ 1221{
1218 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1222 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1219 static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; 1223 static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1};
@@ -1399,56 +1403,44 @@ static int __init snd_miro_probe(struct platform_device *devptr)
1399 return error; 1403 return error;
1400 } 1404 }
1401 1405
1402 snd_card_set_dev(card, &devptr->dev); 1406 snd_card_set_dev(card, devptr);
1403 1407
1404 if ((error = snd_card_register(card))) { 1408 if ((error = snd_card_register(card))) {
1405 snd_card_free(card); 1409 snd_card_free(card);
1406 return error; 1410 return error;
1407 } 1411 }
1408 1412
1409 platform_set_drvdata(devptr, card); 1413 dev_set_drvdata(devptr, card);
1410 return 0; 1414 return 0;
1411} 1415}
1412 1416
1413static int __devexit snd_miro_remove(struct platform_device *devptr) 1417static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev)
1414{ 1418{
1415 snd_card_free(platform_get_drvdata(devptr)); 1419 snd_card_free(dev_get_drvdata(devptr));
1416 platform_set_drvdata(devptr, NULL); 1420 dev_set_drvdata(devptr, NULL);
1417 return 0; 1421 return 0;
1418} 1422}
1419 1423
1420static struct platform_driver snd_miro_driver = { 1424#define DEV_NAME "miro"
1425
1426static struct isa_driver snd_miro_driver = {
1427 .match = snd_miro_match,
1421 .probe = snd_miro_probe, 1428 .probe = snd_miro_probe,
1422 .remove = __devexit_p(snd_miro_remove), 1429 .remove = __devexit_p(snd_miro_remove),
1423 /* FIXME: suspend/resume */ 1430 /* FIXME: suspend/resume */
1424 .driver = { 1431 .driver = {
1425 .name = DRIVER_NAME 1432 .name = DEV_NAME
1426 }, 1433 },
1427}; 1434};
1428 1435
1429static int __init alsa_card_miro_init(void) 1436static int __init alsa_card_miro_init(void)
1430{ 1437{
1431 int error; 1438 return isa_register_driver(&snd_miro_driver, 1);
1432
1433 if ((error = platform_driver_register(&snd_miro_driver)) < 0)
1434 return error;
1435 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
1436 if (! IS_ERR(device)) {
1437 if (platform_get_drvdata(device))
1438 return 0;
1439 platform_device_unregister(device);
1440 }
1441#ifdef MODULE
1442 printk(KERN_ERR "no miro soundcard found\n");
1443#endif
1444 platform_driver_unregister(&snd_miro_driver);
1445 return PTR_ERR(device);
1446} 1439}
1447 1440
1448static void __exit alsa_card_miro_exit(void) 1441static void __exit alsa_card_miro_exit(void)
1449{ 1442{
1450 platform_device_unregister(device); 1443 isa_unregister_driver(&snd_miro_driver);
1451 platform_driver_unregister(&snd_miro_driver);
1452} 1444}
1453 1445
1454module_init(alsa_card_miro_init) 1446module_init(alsa_card_miro_init)
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index df227377c33..049d479ce2b 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -26,7 +26,7 @@
26#include <sound/driver.h> 26#include <sound/driver.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/platform_device.h> 29#include <linux/isa.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pnp.h> 32#include <linux/pnp.h>
@@ -259,7 +259,6 @@ struct snd_opti9xx {
259}; 259};
260 260
261static int snd_opti9xx_pnp_is_probed; 261static int snd_opti9xx_pnp_is_probed;
262static struct platform_device *snd_opti9xx_platform_device;
263 262
264#ifdef CONFIG_PNP 263#ifdef CONFIG_PNP
265 264
@@ -281,10 +280,10 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids);
281#endif /* CONFIG_PNP */ 280#endif /* CONFIG_PNP */
282 281
283#ifdef OPTi93X 282#ifdef OPTi93X
284#define DRIVER_NAME "snd-card-opti93x" 283#define DEV_NAME "opti93x"
285#else 284#else
286#define DRIVER_NAME "snd-card-opti92x" 285#define DEV_NAME "opti92x"
287#endif /* OPTi93X */ 286#endif
288 287
289static char * snd_opti9xx_names[] = { 288static char * snd_opti9xx_names[] = {
290 "unkown", 289 "unkown",
@@ -294,7 +293,7 @@ static char * snd_opti9xx_names[] = {
294}; 293};
295 294
296 295
297static long __init snd_legacy_find_free_ioport(long *port_table, long size) 296static long __devinit snd_legacy_find_free_ioport(long *port_table, long size)
298{ 297{
299 while (*port_table != -1) { 298 while (*port_table != -1) {
300 if (request_region(*port_table, size, "ALSA test")) { 299 if (request_region(*port_table, size, "ALSA test")) {
@@ -306,7 +305,8 @@ static long __init snd_legacy_find_free_ioport(long *port_table, long size)
306 return -1; 305 return -1;
307} 306}
308 307
309static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) 308static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
309 unsigned short hardware)
310{ 310{
311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
312 312
@@ -451,7 +451,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
452 452
453 453
454static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) 454static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
455{ 455{
456 unsigned char wss_base_bits; 456 unsigned char wss_base_bits;
457 unsigned char irq_bits; 457 unsigned char irq_bits;
@@ -934,10 +934,8 @@ static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
934 case SNDRV_PCM_TRIGGER_STOP: 934 case SNDRV_PCM_TRIGGER_STOP:
935 { 935 {
936 unsigned int what = 0; 936 unsigned int what = 0;
937 struct list_head *pos;
938 struct snd_pcm_substream *s; 937 struct snd_pcm_substream *s;
939 snd_pcm_group_for_each(pos, substream) { 938 snd_pcm_group_for_each_entry(s, substream) {
940 s = snd_pcm_group_substream_entry(pos);
941 if (s == chip->playback_substream) { 939 if (s == chip->playback_substream) {
942 what |= OPTi93X_PLAYBACK_ENABLE; 940 what |= OPTi93X_PLAYBACK_ENABLE;
943 snd_pcm_trigger_done(s, substream); 941 snd_pcm_trigger_done(s, substream);
@@ -1291,7 +1289,7 @@ static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
1291 } 1289 }
1292 codec->dma2 = chip->dma2; 1290 codec->dma2 = chip->dma2;
1293 1291
1294 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DRIVER_NAME" - WSS", codec)) { 1292 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DEV_NAME" - WSS", codec)) {
1295 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); 1293 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
1296 snd_opti93x_free(codec); 1294 snd_opti93x_free(codec);
1297 return -EBUSY; 1295 return -EBUSY;
@@ -1561,7 +1559,7 @@ static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
1561 return change; 1559 return change;
1562} 1560}
1563 1561
1564static struct snd_kcontrol_new snd_opti93x_controls[] = { 1562static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = {
1565OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 1563OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
1566OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), 1564OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
1567OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), 1565OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
@@ -1622,7 +1620,8 @@ static int snd_opti93x_mixer(struct snd_opti93x *chip)
1622 1620
1623#endif /* OPTi93X */ 1621#endif /* OPTi93X */
1624 1622
1625static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) 1623static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
1624 struct snd_opti9xx *chip)
1626{ 1625{
1627 int i, err; 1626 int i, err;
1628 1627
@@ -1676,8 +1675,9 @@ static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti
1676} 1675}
1677 1676
1678#ifdef CONFIG_PNP 1677#ifdef CONFIG_PNP
1679static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, 1678static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
1680 const struct pnp_card_device_id *pid) 1679 struct pnp_card_link *card,
1680 const struct pnp_card_device_id *pid)
1681{ 1681{
1682 struct pnp_dev *pdev; 1682 struct pnp_dev *pdev;
1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -1778,7 +1778,7 @@ static void snd_card_opti9xx_free(struct snd_card *card)
1778 release_and_free_resource(chip->res_mc_base); 1778 release_and_free_resource(chip->res_mc_base);
1779} 1779}
1780 1780
1781static int __init snd_opti9xx_probe(struct snd_card *card) 1781static int __devinit snd_opti9xx_probe(struct snd_card *card)
1782{ 1782{
1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1784 int error; 1784 int error;
@@ -1924,7 +1924,20 @@ static struct snd_card *snd_opti9xx_card_new(void)
1924 return card; 1924 return card;
1925} 1925}
1926 1926
1927static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) 1927static int __devinit snd_opti9xx_isa_match(struct device *devptr,
1928 unsigned int dev)
1929{
1930#ifdef CONFIG_PNP
1931 if (snd_opti9xx_pnp_is_probed)
1932 return 0;
1933 if (isapnp)
1934 return 0;
1935#endif
1936 return 1;
1937}
1938
1939static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
1940 unsigned int dev)
1928{ 1941{
1929 struct snd_card *card; 1942 struct snd_card *card;
1930 int error; 1943 int error;
@@ -1940,9 +1953,6 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1940 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; 1953 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
1941#endif /* CS4231 || OPTi93X */ 1954#endif /* CS4231 || OPTi93X */
1942 1955
1943 if (snd_opti9xx_pnp_is_probed)
1944 return -EBUSY;
1945
1946 if (mpu_port == SNDRV_AUTO_PORT) { 1956 if (mpu_port == SNDRV_AUTO_PORT) {
1947 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { 1957 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
1948 snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); 1958 snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
@@ -1984,34 +1994,36 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1984 snd_card_free(card); 1994 snd_card_free(card);
1985 return error; 1995 return error;
1986 } 1996 }
1987 snd_card_set_dev(card, &devptr->dev); 1997 snd_card_set_dev(card, devptr);
1988 if ((error = snd_opti9xx_probe(card)) < 0) { 1998 if ((error = snd_opti9xx_probe(card)) < 0) {
1989 snd_card_free(card); 1999 snd_card_free(card);
1990 return error; 2000 return error;
1991 } 2001 }
1992 platform_set_drvdata(devptr, card); 2002 dev_set_drvdata(devptr, card);
1993 return 0; 2003 return 0;
1994} 2004}
1995 2005
1996static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) 2006static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
2007 unsigned int dev)
1997{ 2008{
1998 snd_card_free(platform_get_drvdata(devptr)); 2009 snd_card_free(dev_get_drvdata(devptr));
1999 platform_set_drvdata(devptr, NULL); 2010 dev_set_drvdata(devptr, NULL);
2000 return 0; 2011 return 0;
2001} 2012}
2002 2013
2003static struct platform_driver snd_opti9xx_driver = { 2014static struct isa_driver snd_opti9xx_driver = {
2004 .probe = snd_opti9xx_nonpnp_probe, 2015 .match = snd_opti9xx_isa_match,
2005 .remove = __devexit_p(snd_opti9xx_nonpnp_remove), 2016 .probe = snd_opti9xx_isa_probe,
2017 .remove = __devexit_p(snd_opti9xx_isa_remove),
2006 /* FIXME: suspend/resume */ 2018 /* FIXME: suspend/resume */
2007 .driver = { 2019 .driver = {
2008 .name = DRIVER_NAME 2020 .name = DEV_NAME
2009 }, 2021 },
2010}; 2022};
2011 2023
2012#ifdef CONFIG_PNP 2024#ifdef CONFIG_PNP
2013static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, 2025static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
2014 const struct pnp_card_device_id *pid) 2026 const struct pnp_card_device_id *pid)
2015{ 2027{
2016 struct snd_card *card; 2028 struct snd_card *card;
2017 int error, hw; 2029 int error, hw;
@@ -2074,11 +2086,6 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2074}; 2086};
2075#endif 2087#endif
2076 2088
2077#ifdef CONFIG_PNP
2078#define is_isapnp_selected() isapnp
2079#else
2080#define is_isapnp_selected() 0
2081#endif
2082#ifdef OPTi93X 2089#ifdef OPTi93X
2083#define CHIP_NAME "82C93x" 2090#define CHIP_NAME "82C93x"
2084#else 2091#else
@@ -2087,42 +2094,20 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2087 2094
2088static int __init alsa_card_opti9xx_init(void) 2095static int __init alsa_card_opti9xx_init(void)
2089{ 2096{
2090 int error;
2091 struct platform_device *device;
2092
2093#ifdef CONFIG_PNP 2097#ifdef CONFIG_PNP
2094 pnp_register_card_driver(&opti9xx_pnpc_driver); 2098 pnp_register_card_driver(&opti9xx_pnpc_driver);
2095 if (snd_opti9xx_pnp_is_probed) 2099 if (snd_opti9xx_pnp_is_probed)
2096 return 0; 2100 return 0;
2097#endif
2098 if (! is_isapnp_selected()) {
2099 error = platform_driver_register(&snd_opti9xx_driver);
2100 if (error < 0)
2101 return error;
2102 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
2103 if (!IS_ERR(device)) {
2104 if (platform_get_drvdata(device)) {
2105 snd_opti9xx_platform_device = device;
2106 return 0;
2107 }
2108 platform_device_unregister(device);
2109 }
2110 platform_driver_unregister(&snd_opti9xx_driver);
2111 }
2112#ifdef CONFIG_PNP
2113 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2101 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2114#endif 2102#endif
2115#ifdef MODULE 2103 return isa_register_driver(&snd_opti9xx_driver, 1);
2116 printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n");
2117#endif
2118 return -ENODEV;
2119} 2104}
2120 2105
2121static void __exit alsa_card_opti9xx_exit(void) 2106static void __exit alsa_card_opti9xx_exit(void)
2122{ 2107{
2123 if (!snd_opti9xx_pnp_is_probed) { 2108 if (!snd_opti9xx_pnp_is_probed) {
2124 platform_device_unregister(snd_opti9xx_platform_device); 2109 isa_unregister_driver(&snd_opti9xx_driver);
2125 platform_driver_unregister(&snd_opti9xx_driver); 2110 return;
2126 } 2111 }
2127#ifdef CONFIG_PNP 2112#ifdef CONFIG_PNP
2128 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2113 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
diff --git a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile
index fd9d9c5726f..556e6692802 100644
--- a/sound/isa/sb/Makefile
+++ b/sound/isa/sb/Makefile
@@ -22,14 +22,13 @@ snd-es968-objs := es968.o
22sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) 22sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
23 23
24# Toplevel Module Dependency 24# Toplevel Module Dependency
25obj-$(CONFIG_SND_ALS100) += snd-sb16-dsp.o snd-sb-common.o 25obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o
26obj-$(CONFIG_SND_CMI8330) += snd-sb16-dsp.o snd-sb-common.o 26obj-$(CONFIG_SND_SB16_DSP) += snd-sb16-dsp.o
27obj-$(CONFIG_SND_DT019X) += snd-sb16-dsp.o snd-sb-common.o 27obj-$(CONFIG_SND_SB8_DSP) += snd-sb8-dsp.o
28obj-$(CONFIG_SND_SB8) += snd-sb8.o snd-sb8-dsp.o snd-sb-common.o 28obj-$(CONFIG_SND_SB8) += snd-sb8.o
29obj-$(CONFIG_SND_SB16) += snd-sb16.o snd-sb16-dsp.o snd-sb-common.o 29obj-$(CONFIG_SND_SB16) += snd-sb16.o
30obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o snd-sb16-dsp.o snd-sb-common.o 30obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o
31obj-$(CONFIG_SND_ES968) += snd-es968.o snd-sb8-dsp.o snd-sb-common.o 31obj-$(CONFIG_SND_ES968) += snd-es968.o
32obj-$(CONFIG_SND_ALS4000) += snd-sb-common.o
33ifeq ($(CONFIG_SND_SB16_CSP),y) 32ifeq ($(CONFIG_SND_SB16_CSP),y)
34 obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o 33 obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o
35 obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o 34 obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index d64e67f2baf..c4ba24bfd27 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -25,7 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <sound/core.h> 30#include <sound/core.h>
31#include <sound/sb.h> 31#include <sound/sb.h>
@@ -128,8 +128,8 @@ module_param_array(seq_ports, int, NULL, 0444);
128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); 128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
129#endif 129#endif
130 130
131static struct platform_device *platform_devices[SNDRV_CARDS];
132#ifdef CONFIG_PNP 131#ifdef CONFIG_PNP
132static int isa_registered;
133static int pnp_registered; 133static int pnp_registered;
134#endif 134#endif
135 135
@@ -519,7 +519,7 @@ static int snd_sb16_resume(struct snd_card *card)
519} 519}
520#endif 520#endif
521 521
522static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) 522static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
523{ 523{
524 struct snd_card_sb16 *acard; 524 struct snd_card_sb16 *acard;
525 struct snd_card *card; 525 struct snd_card *card;
@@ -539,19 +539,23 @@ static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *dev
539 awe_port[dev] = port[dev] + 0x400; 539 awe_port[dev] = port[dev] + 0x400;
540#endif 540#endif
541 541
542 snd_card_set_dev(card, &devptr->dev); 542 snd_card_set_dev(card, pdev);
543 if ((err = snd_sb16_probe(card, dev)) < 0) { 543 if ((err = snd_sb16_probe(card, dev)) < 0) {
544 snd_card_free(card); 544 snd_card_free(card);
545 return err; 545 return err;
546 } 546 }
547 platform_set_drvdata(devptr, card); 547 dev_set_drvdata(pdev, card);
548 return 0; 548 return 0;
549} 549}
550 550
551 551
552static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) 552static int __devinit snd_sb16_isa_match(struct device *pdev, unsigned int dev)
553{
554 return enable[dev] && !is_isapnp_selected(dev);
555}
556
557static int __devinit snd_sb16_isa_probe(struct device *pdev, unsigned int dev)
553{ 558{
554 int dev = pdev->id;
555 int err; 559 int err;
556 static int possible_irqs[] = {5, 9, 10, 7, -1}; 560 static int possible_irqs[] = {5, 9, 10, 7, -1};
557 static int possible_dmas8[] = {1, 3, 0, -1}; 561 static int possible_dmas8[] = {1, 3, 0, -1};
@@ -577,13 +581,13 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev)
577 } 581 }
578 582
579 if (port[dev] != SNDRV_AUTO_PORT) 583 if (port[dev] != SNDRV_AUTO_PORT)
580 return snd_sb16_nonpnp_probe1(dev, pdev); 584 return snd_sb16_isa_probe1(dev, pdev);
581 else { 585 else {
582 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; 586 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280};
583 int i; 587 int i;
584 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 588 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
585 port[dev] = possible_ports[i]; 589 port[dev] = possible_ports[i];
586 err = snd_sb16_nonpnp_probe1(dev, pdev); 590 err = snd_sb16_isa_probe1(dev, pdev);
587 if (! err) 591 if (! err)
588 return 0; 592 return 0;
589 } 593 }
@@ -591,47 +595,47 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev)
591 } 595 }
592} 596}
593 597
594static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) 598static int __devexit snd_sb16_isa_remove(struct device *pdev, unsigned int dev)
595{ 599{
596 snd_card_free(platform_get_drvdata(devptr)); 600 snd_card_free(dev_get_drvdata(pdev));
597 platform_set_drvdata(devptr, NULL); 601 dev_set_drvdata(pdev, NULL);
598 return 0; 602 return 0;
599} 603}
600 604
601#ifdef CONFIG_PM 605#ifdef CONFIG_PM
602static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 606static int snd_sb16_isa_suspend(struct device *dev, unsigned int n,
607 pm_message_t state)
603{ 608{
604 return snd_sb16_suspend(platform_get_drvdata(dev), state); 609 return snd_sb16_suspend(dev_get_drvdata(dev), state);
605} 610}
606 611
607static int snd_sb16_nonpnp_resume(struct platform_device *dev) 612static int snd_sb16_isa_resume(struct device *dev, unsigned int n)
608{ 613{
609 return snd_sb16_resume(platform_get_drvdata(dev)); 614 return snd_sb16_resume(dev_get_drvdata(dev));
610} 615}
611#endif 616#endif
612 617
613#ifdef SNDRV_SBAWE 618#ifdef SNDRV_SBAWE
614#define SND_SB16_DRIVER "snd_sbawe" 619#define DEV_NAME "sbawe"
615#else 620#else
616#define SND_SB16_DRIVER "snd_sb16" 621#define DEV_NAME "sb16"
617#endif 622#endif
618 623
619static struct platform_driver snd_sb16_nonpnp_driver = { 624static struct isa_driver snd_sb16_isa_driver = {
620 .probe = snd_sb16_nonpnp_probe, 625 .match = snd_sb16_isa_match,
621 .remove = __devexit_p(snd_sb16_nonpnp_remove), 626 .probe = snd_sb16_isa_probe,
627 .remove = __devexit_p(snd_sb16_isa_remove),
622#ifdef CONFIG_PM 628#ifdef CONFIG_PM
623 .suspend = snd_sb16_nonpnp_suspend, 629 .suspend = snd_sb16_isa_suspend,
624 .resume = snd_sb16_nonpnp_resume, 630 .resume = snd_sb16_isa_resume,
625#endif 631#endif
626 .driver = { 632 .driver = {
627 .name = SND_SB16_DRIVER 633 .name = DEV_NAME
628 }, 634 },
629}; 635};
630 636
631 637
632#ifdef CONFIG_PNP 638#ifdef CONFIG_PNP
633static unsigned int __devinitdata sb16_pnp_devices;
634
635static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, 639static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
636 const struct pnp_card_device_id *pid) 640 const struct pnp_card_device_id *pid)
637{ 641{
@@ -653,7 +657,6 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
653 } 657 }
654 pnp_set_card_drvdata(pcard, card); 658 pnp_set_card_drvdata(pcard, card);
655 dev++; 659 dev++;
656 sb16_pnp_devices++;
657 return 0; 660 return 0;
658 } 661 }
659 662
@@ -695,68 +698,33 @@ static struct pnp_card_driver sb16_pnpc_driver = {
695 698
696#endif /* CONFIG_PNP */ 699#endif /* CONFIG_PNP */
697 700
698static void __init_or_module snd_sb16_unregister_all(void)
699{
700 int i;
701
702#ifdef CONFIG_PNP
703 if (pnp_registered)
704 pnp_unregister_card_driver(&sb16_pnpc_driver);
705#endif
706 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
707 platform_device_unregister(platform_devices[i]);
708 platform_driver_unregister(&snd_sb16_nonpnp_driver);
709}
710
711static int __init alsa_card_sb16_init(void) 701static int __init alsa_card_sb16_init(void)
712{ 702{
713 int i, err, cards = 0; 703 int err;
714
715 if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0)
716 return err;
717 704
718 for (i = 0; i < SNDRV_CARDS; i++) { 705 err = isa_register_driver(&snd_sb16_isa_driver, SNDRV_CARDS);
719 struct platform_device *device;
720 if (! enable[i] || is_isapnp_selected(i))
721 continue;
722 device = platform_device_register_simple(SND_SB16_DRIVER,
723 i, NULL, 0);
724 if (IS_ERR(device))
725 continue;
726 if (!platform_get_drvdata(device)) {
727 platform_device_unregister(device);
728 continue;
729 }
730 platform_devices[i] = device;
731 cards++;
732 }
733#ifdef CONFIG_PNP 706#ifdef CONFIG_PNP
734 /* PnP cards at last */ 707 if (!err)
708 isa_registered = 1;
709
735 err = pnp_register_card_driver(&sb16_pnpc_driver); 710 err = pnp_register_card_driver(&sb16_pnpc_driver);
736 if (!err) { 711 if (!err)
737 pnp_registered = 1; 712 pnp_registered = 1;
738 cards += sb16_pnp_devices;
739 }
740#endif
741 713
742 if (!cards) { 714 if (isa_registered)
743#ifdef MODULE 715 err = 0;
744 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");
745#ifdef SNDRV_SBAWE_EMU8000
746 snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n");
747#else
748 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");
749#endif 716#endif
750#endif 717 return err;
751 snd_sb16_unregister_all();
752 return -ENODEV;
753 }
754 return 0;
755} 718}
756 719
757static void __exit alsa_card_sb16_exit(void) 720static void __exit alsa_card_sb16_exit(void)
758{ 721{
759 snd_sb16_unregister_all(); 722#ifdef CONFIG_PNP
723 if (pnp_registered)
724 pnp_unregister_card_driver(&sb16_pnpc_driver);
725 if (isa_registered)
726#endif
727 isa_unregister_driver(&snd_sb16_isa_driver);
760} 728}
761 729
762module_init(alsa_card_sb16_init) 730module_init(alsa_card_sb16_init)
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index 3d9d7e0107c..b279f2308ae 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -36,6 +36,13 @@
36MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>"); 36MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
37MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor"); 37MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
40MODULE_FIRMWARE("sb16/mulaw_main.csp");
41MODULE_FIRMWARE("sb16/alaw_main.csp");
42MODULE_FIRMWARE("sb16/ima_adpcm_init.csp");
43MODULE_FIRMWARE("sb16/ima_adpcm_playback.csp");
44MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp");
45#endif
39 46
40#ifdef SNDRV_LITTLE_ENDIAN 47#ifdef SNDRV_LITTLE_ENDIAN
41#define CSP_HDR_VALUE(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24)) 48#define CSP_HDR_VALUE(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
@@ -161,13 +168,17 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
161 */ 168 */
162static void snd_sb_csp_free(struct snd_hwdep *hwdep) 169static void snd_sb_csp_free(struct snd_hwdep *hwdep)
163{ 170{
171#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
164 int i; 172 int i;
173#endif
165 struct snd_sb_csp *p = hwdep->private_data; 174 struct snd_sb_csp *p = hwdep->private_data;
166 if (p) { 175 if (p) {
167 if (p->running & SNDRV_SB_CSP_ST_RUNNING) 176 if (p->running & SNDRV_SB_CSP_ST_RUNNING)
168 snd_sb_csp_stop(p); 177 snd_sb_csp_stop(p);
178#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
169 for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i) 179 for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i)
170 release_firmware(p->csp_programs[i]); 180 release_firmware(p->csp_programs[i]);
181#endif
171 kfree(p); 182 kfree(p);
172 } 183 }
173} 184}
@@ -690,9 +701,7 @@ static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __use
690 return err; 701 return err;
691} 702}
692 703
693#define FIRMWARE_IN_THE_KERNEL 704#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
694
695#ifdef FIRMWARE_IN_THE_KERNEL
696#include "sb16_csp_codecs.h" 705#include "sb16_csp_codecs.h"
697 706
698static const struct firmware snd_sb_csp_static_programs[] = { 707static const struct firmware snd_sb_csp_static_programs[] = {
@@ -714,22 +723,19 @@ static int snd_sb_csp_firmware_load(struct snd_sb_csp *p, int index, int flags)
714 "sb16/ima_adpcm_capture.csp", 723 "sb16/ima_adpcm_capture.csp",
715 }; 724 };
716 const struct firmware *program; 725 const struct firmware *program;
717 int err;
718 726
719 BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT); 727 BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT);
720 program = p->csp_programs[index]; 728 program = p->csp_programs[index];
721 if (!program) { 729 if (!program) {
722 err = request_firmware(&program, names[index], 730#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
723 p->chip->card->dev); 731 program = &snd_sb_csp_static_programs[index];
724 if (err >= 0)
725 p->csp_programs[index] = program;
726 else {
727#ifdef FIRMWARE_IN_THE_KERNEL
728 program = &snd_sb_csp_static_programs[index];
729#else 732#else
733 int err = request_firmware(&program, names[index],
734 p->chip->card->dev);
735 if (err < 0)
730 return err; 736 return err;
731#endif 737#endif
732 } 738 p->csp_programs[index] = program;
733 } 739 }
734 return snd_sb_csp_load(p, program->data, program->size, flags); 740 return snd_sb_csp_load(p, program->data, program->size, flags);
735} 741}
diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c
index 383911b9e74..5d4d3aafe2d 100644
--- a/sound/isa/sb/sb16_main.c
+++ b/sound/isa/sb/sb16_main.c
@@ -563,6 +563,11 @@ static int snd_sb16_playback_open(struct snd_pcm_substream *substream)
563 __open_ok: 563 __open_ok:
564 if (chip->hardware == SB_HW_ALS100) 564 if (chip->hardware == SB_HW_ALS100)
565 runtime->hw.rate_max = 48000; 565 runtime->hw.rate_max = 48000;
566 if (chip->hardware == SB_HW_CS5530) {
567 runtime->hw.buffer_bytes_max = 32 * 1024;
568 runtime->hw.periods_min = 2;
569 runtime->hw.rate_min = 44100;
570 }
566 if (chip->mode & SB_RATE_LOCK) 571 if (chip->mode & SB_RATE_LOCK)
567 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate; 572 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
568 chip->playback_substream = substream; 573 chip->playback_substream = substream;
@@ -633,6 +638,11 @@ static int snd_sb16_capture_open(struct snd_pcm_substream *substream)
633 __open_ok: 638 __open_ok:
634 if (chip->hardware == SB_HW_ALS100) 639 if (chip->hardware == SB_HW_ALS100)
635 runtime->hw.rate_max = 48000; 640 runtime->hw.rate_max = 48000;
641 if (chip->hardware == SB_HW_CS5530) {
642 runtime->hw.buffer_bytes_max = 32 * 1024;
643 runtime->hw.periods_min = 2;
644 runtime->hw.rate_min = 44100;
645 }
636 if (chip->mode & SB_RATE_LOCK) 646 if (chip->mode & SB_RATE_LOCK)
637 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate; 647 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
638 chip->capture_substream = substream; 648 chip->capture_substream = substream;
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index be1e83e6dea..a1b3786b391 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -56,8 +56,6 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
56module_param_array(dma8, int, NULL, 0444); 56module_param_array(dma8, int, NULL, 0444);
57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); 57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
58 58
59static struct platform_device *devices[SNDRV_CARDS];
60
61struct snd_sb8 { 59struct snd_sb8 {
62 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 60 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
63 struct snd_sb *chip; 61 struct snd_sb *chip;
@@ -83,9 +81,23 @@ static void snd_sb8_free(struct snd_card *card)
83 release_and_free_resource(acard->fm_res); 81 release_and_free_resource(acard->fm_res);
84} 82}
85 83
86static int __devinit snd_sb8_probe(struct platform_device *pdev) 84static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev)
85{
86 if (!enable[dev])
87 return 0;
88 if (irq[dev] == SNDRV_AUTO_IRQ) {
89 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
90 return 0;
91 }
92 if (dma8[dev] == SNDRV_AUTO_DMA) {
93 snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id);
94 return 0;
95 }
96 return 1;
97}
98
99static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev)
87{ 100{
88 int dev = pdev->id;
89 struct snd_sb *chip; 101 struct snd_sb *chip;
90 struct snd_card *card; 102 struct snd_card *card;
91 struct snd_sb8 *acard; 103 struct snd_sb8 *acard;
@@ -180,12 +192,12 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
180 chip->port, 192 chip->port,
181 irq[dev], dma8[dev]); 193 irq[dev], dma8[dev]);
182 194
183 snd_card_set_dev(card, &pdev->dev); 195 snd_card_set_dev(card, pdev);
184 196
185 if ((err = snd_card_register(card)) < 0) 197 if ((err = snd_card_register(card)) < 0)
186 goto _err; 198 goto _err;
187 199
188 platform_set_drvdata(pdev, card); 200 dev_set_drvdata(pdev, card);
189 return 0; 201 return 0;
190 202
191 _err: 203 _err:
@@ -193,17 +205,18 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
193 return err; 205 return err;
194} 206}
195 207
196static int __devexit snd_sb8_remove(struct platform_device *pdev) 208static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev)
197{ 209{
198 snd_card_free(platform_get_drvdata(pdev)); 210 snd_card_free(dev_get_drvdata(pdev));
199 platform_set_drvdata(pdev, NULL); 211 dev_set_drvdata(pdev, NULL);
200 return 0; 212 return 0;
201} 213}
202 214
203#ifdef CONFIG_PM 215#ifdef CONFIG_PM
204static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) 216static int snd_sb8_suspend(struct device *dev, unsigned int n,
217 pm_message_t state)
205{ 218{
206 struct snd_card *card = platform_get_drvdata(dev); 219 struct snd_card *card = dev_get_drvdata(dev);
207 struct snd_sb8 *acard = card->private_data; 220 struct snd_sb8 *acard = card->private_data;
208 struct snd_sb *chip = acard->chip; 221 struct snd_sb *chip = acard->chip;
209 222
@@ -213,9 +226,9 @@ static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state)
213 return 0; 226 return 0;
214} 227}
215 228
216static int snd_sb8_resume(struct platform_device *dev) 229static int snd_sb8_resume(struct device *dev, unsigned int n)
217{ 230{
218 struct snd_card *card = platform_get_drvdata(dev); 231 struct snd_card *card = dev_get_drvdata(dev);
219 struct snd_sb8 *acard = card->private_data; 232 struct snd_sb8 *acard = card->private_data;
220 struct snd_sb *chip = acard->chip; 233 struct snd_sb *chip = acard->chip;
221 234
@@ -226,9 +239,10 @@ static int snd_sb8_resume(struct platform_device *dev)
226} 239}
227#endif 240#endif
228 241
229#define SND_SB8_DRIVER "snd_sb8" 242#define DEV_NAME "sb8"
230 243
231static struct platform_driver snd_sb8_driver = { 244static struct isa_driver snd_sb8_driver = {
245 .match = snd_sb8_match,
232 .probe = snd_sb8_probe, 246 .probe = snd_sb8_probe,
233 .remove = __devexit_p(snd_sb8_remove), 247 .remove = __devexit_p(snd_sb8_remove),
234#ifdef CONFIG_PM 248#ifdef CONFIG_PM
@@ -236,56 +250,18 @@ static struct platform_driver snd_sb8_driver = {
236 .resume = snd_sb8_resume, 250 .resume = snd_sb8_resume,
237#endif 251#endif
238 .driver = { 252 .driver = {
239 .name = SND_SB8_DRIVER 253 .name = DEV_NAME
240 }, 254 },
241}; 255};
242 256
243static void __init_or_module snd_sb8_unregister_all(void)
244{
245 int i;
246
247 for (i = 0; i < ARRAY_SIZE(devices); ++i)
248 platform_device_unregister(devices[i]);
249 platform_driver_unregister(&snd_sb8_driver);
250}
251
252static int __init alsa_card_sb8_init(void) 257static int __init alsa_card_sb8_init(void)
253{ 258{
254 int i, cards, err; 259 return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS);
255
256 err = platform_driver_register(&snd_sb8_driver);
257 if (err < 0)
258 return err;
259
260 cards = 0;
261 for (i = 0; i < SNDRV_CARDS; i++) {
262 struct platform_device *device;
263 if (! enable[i])
264 continue;
265 device = platform_device_register_simple(SND_SB8_DRIVER,
266 i, NULL, 0);
267 if (IS_ERR(device))
268 continue;
269 if (!platform_get_drvdata(device)) {
270 platform_device_unregister(device);
271 continue;
272 }
273 devices[i] = device;
274 cards++;
275 }
276 if (!cards) {
277#ifdef MODULE
278 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
279#endif
280 snd_sb8_unregister_all();
281 return -ENODEV;
282 }
283 return 0;
284} 260}
285 261
286static void __exit alsa_card_sb8_exit(void) 262static void __exit alsa_card_sb8_exit(void)
287{ 263{
288 snd_sb8_unregister_all(); 264 isa_unregister_driver(&snd_sb8_driver);
289} 265}
290 266
291module_init(alsa_card_sb8_init) 267module_init(alsa_card_sb8_init)
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c
index 3094f385216..efa9d5c2558 100644
--- a/sound/isa/sb/sb_common.c
+++ b/sound/isa/sb/sb_common.c
@@ -128,7 +128,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
128 minor = version & 0xff; 128 minor = version & 0xff;
129 snd_printdd("SB [0x%lx]: DSP chip found, version = %i.%i\n", 129 snd_printdd("SB [0x%lx]: DSP chip found, version = %i.%i\n",
130 chip->port, major, minor); 130 chip->port, major, minor);
131 131
132 switch (chip->hardware) { 132 switch (chip->hardware) {
133 case SB_HW_AUTO: 133 case SB_HW_AUTO:
134 switch (major) { 134 switch (major) {
@@ -168,6 +168,9 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
168 case SB_HW_DT019X: 168 case SB_HW_DT019X:
169 str = "(DT019X/ALS007)"; 169 str = "(DT019X/ALS007)";
170 break; 170 break;
171 case SB_HW_CS5530:
172 str = "16 (CS5530)";
173 break;
171 default: 174 default:
172 return -ENODEV; 175 return -ENODEV;
173 } 176 }
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c
index 490b1ca5cf5..3d4befcff28 100644
--- a/sound/isa/sb/sb_mixer.c
+++ b/sound/isa/sb/sb_mixer.c
@@ -821,6 +821,7 @@ int snd_sbmixer_new(struct snd_sb *chip)
821 break; 821 break;
822 case SB_HW_16: 822 case SB_HW_16:
823 case SB_HW_ALS100: 823 case SB_HW_ALS100:
824 case SB_HW_CS5530:
824 if ((err = snd_sbmixer_init(chip, 825 if ((err = snd_sbmixer_init(chip,
825 snd_sb16_controls, 826 snd_sb16_controls,
826 ARRAY_SIZE(snd_sb16_controls), 827 ARRAY_SIZE(snd_sb16_controls),
@@ -950,6 +951,7 @@ void snd_sbmixer_suspend(struct snd_sb *chip)
950 break; 951 break;
951 case SB_HW_16: 952 case SB_HW_16:
952 case SB_HW_ALS100: 953 case SB_HW_ALS100:
954 case SB_HW_CS5530:
953 save_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); 955 save_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs));
954 break; 956 break;
955 case SB_HW_ALS4000: 957 case SB_HW_ALS4000:
@@ -975,6 +977,7 @@ void snd_sbmixer_resume(struct snd_sb *chip)
975 break; 977 break;
976 case SB_HW_16: 978 case SB_HW_16:
977 case SB_HW_ALS100: 979 case SB_HW_ALS100:
980 case SB_HW_CS5530:
978 restore_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); 981 restore_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs));
979 break; 982 break;
980 case SB_HW_ALS4000: 983 case SB_HW_ALS4000:
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
index 4fcd0f4e868..922519def09 100644
--- a/sound/isa/sgalaxy.c
+++ b/sound/isa/sgalaxy.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
@@ -64,8 +64,6 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver.");
64module_param_array(dma1, int, NULL, 0444); 64module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); 65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
66 66
67static struct platform_device *devices[SNDRV_CARDS];
68
69#define SGALAXY_AUXC_LEFT 18 67#define SGALAXY_AUXC_LEFT 18
70#define SGALAXY_AUXC_RIGHT 19 68#define SGALAXY_AUXC_RIGHT 19
71 69
@@ -96,7 +94,8 @@ static int snd_sgalaxy_sbdsp_reset(unsigned long port)
96 return 0; 94 return 0;
97} 95}
98 96
99static int __init snd_sgalaxy_sbdsp_command(unsigned long port, unsigned char val) 97static int __devinit snd_sgalaxy_sbdsp_command(unsigned long port,
98 unsigned char val)
100{ 99{
101 int i; 100 int i;
102 101
@@ -114,7 +113,7 @@ static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id)
114 return IRQ_NONE; 113 return IRQ_NONE;
115} 114}
116 115
117static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) 116static int __devinit snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
118{ 117{
119 static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 118 static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1,
120 0x10, 0x18, 0x20, -1, -1, -1, -1}; 119 0x10, 0x18, 0x20, -1, -1, -1, -1};
@@ -161,7 +160,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
161 return 0; 160 return 0;
162} 161}
163 162
164static int __init snd_sgalaxy_detect(int dev, int irq, int dma) 163static int __devinit snd_sgalaxy_detect(int dev, int irq, int dma)
165{ 164{
166#if 0 165#if 0
167 snd_printdd(PFX "switching to WSS mode\n"); 166 snd_printdd(PFX "switching to WSS mode\n");
@@ -182,7 +181,7 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7
182AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) 181AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0)
183}; 182};
184 183
185static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) 184static int __devinit snd_sgalaxy_mixer(struct snd_ad1848 *chip)
186{ 185{
187 struct snd_card *card = chip->card; 186 struct snd_card *card = chip->card;
188 struct snd_ctl_elem_id id1, id2; 187 struct snd_ctl_elem_id id1, id2;
@@ -218,23 +217,29 @@ static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip)
218 return 0; 217 return 0;
219} 218}
220 219
221static int __init snd_sgalaxy_probe(struct platform_device *devptr) 220static int __devinit snd_sgalaxy_match(struct device *devptr, unsigned int dev)
222{ 221{
223 int dev = devptr->id; 222 if (!enable[dev])
224 static int possible_irqs[] = {7, 9, 10, 11, -1}; 223 return 0;
225 static int possible_dmas[] = {1, 3, 0, -1};
226 int err, xirq, xdma1;
227 struct snd_card *card;
228 struct snd_ad1848 *chip;
229
230 if (sbport[dev] == SNDRV_AUTO_PORT) { 224 if (sbport[dev] == SNDRV_AUTO_PORT) {
231 snd_printk(KERN_ERR PFX "specify SB port\n"); 225 snd_printk(KERN_ERR PFX "specify SB port\n");
232 return -EINVAL; 226 return 0;
233 } 227 }
234 if (wssport[dev] == SNDRV_AUTO_PORT) { 228 if (wssport[dev] == SNDRV_AUTO_PORT) {
235 snd_printk(KERN_ERR PFX "specify WSS port\n"); 229 snd_printk(KERN_ERR PFX "specify WSS port\n");
236 return -EINVAL; 230 return 0;
237 } 231 }
232 return 1;
233}
234
235static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev)
236{
237 static int possible_irqs[] = {7, 9, 10, 11, -1};
238 static int possible_dmas[] = {1, 3, 0, -1};
239 int err, xirq, xdma1;
240 struct snd_card *card;
241 struct snd_ad1848 *chip;
242
238 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 243 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
239 if (card == NULL) 244 if (card == NULL)
240 return -ENOMEM; 245 return -ENOMEM;
@@ -283,12 +288,12 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr)
283 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", 288 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d",
284 wssport[dev], xirq, xdma1); 289 wssport[dev], xirq, xdma1);
285 290
286 snd_card_set_dev(card, &devptr->dev); 291 snd_card_set_dev(card, devptr);
287 292
288 if ((err = snd_card_register(card)) < 0) 293 if ((err = snd_card_register(card)) < 0)
289 goto _err; 294 goto _err;
290 295
291 platform_set_drvdata(devptr, card); 296 dev_set_drvdata(devptr, card);
292 return 0; 297 return 0;
293 298
294 _err: 299 _err:
@@ -296,17 +301,18 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr)
296 return err; 301 return err;
297} 302}
298 303
299static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) 304static int __devexit snd_sgalaxy_remove(struct device *devptr, unsigned int dev)
300{ 305{
301 snd_card_free(platform_get_drvdata(devptr)); 306 snd_card_free(dev_get_drvdata(devptr));
302 platform_set_drvdata(devptr, NULL); 307 dev_set_drvdata(devptr, NULL);
303 return 0; 308 return 0;
304} 309}
305 310
306#ifdef CONFIG_PM 311#ifdef CONFIG_PM
307static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) 312static int snd_sgalaxy_suspend(struct device *pdev, unsigned int n,
313 pm_message_t state)
308{ 314{
309 struct snd_card *card = platform_get_drvdata(pdev); 315 struct snd_card *card = dev_get_drvdata(pdev);
310 struct snd_ad1848 *chip = card->private_data; 316 struct snd_ad1848 *chip = card->private_data;
311 317
312 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 318 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -314,9 +320,9 @@ static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state)
314 return 0; 320 return 0;
315} 321}
316 322
317static int snd_sgalaxy_resume(struct platform_device *pdev) 323static int snd_sgalaxy_resume(struct device *pdev, unsigned int n)
318{ 324{
319 struct snd_card *card = platform_get_drvdata(pdev); 325 struct snd_card *card = dev_get_drvdata(pdev);
320 struct snd_ad1848 *chip = card->private_data; 326 struct snd_ad1848 *chip = card->private_data;
321 327
322 chip->resume(chip); 328 chip->resume(chip);
@@ -328,9 +334,10 @@ static int snd_sgalaxy_resume(struct platform_device *pdev)
328} 334}
329#endif 335#endif
330 336
331#define SND_SGALAXY_DRIVER "snd_sgalaxy" 337#define DEV_NAME "sgalaxy"
332 338
333static struct platform_driver snd_sgalaxy_driver = { 339static struct isa_driver snd_sgalaxy_driver = {
340 .match = snd_sgalaxy_match,
334 .probe = snd_sgalaxy_probe, 341 .probe = snd_sgalaxy_probe,
335 .remove = __devexit_p(snd_sgalaxy_remove), 342 .remove = __devexit_p(snd_sgalaxy_remove),
336#ifdef CONFIG_PM 343#ifdef CONFIG_PM
@@ -338,56 +345,18 @@ static struct platform_driver snd_sgalaxy_driver = {
338 .resume = snd_sgalaxy_resume, 345 .resume = snd_sgalaxy_resume,
339#endif 346#endif
340 .driver = { 347 .driver = {
341 .name = SND_SGALAXY_DRIVER 348 .name = DEV_NAME
342 }, 349 },
343}; 350};
344 351
345static void __init_or_module snd_sgalaxy_unregister_all(void)
346{
347 int i;
348
349 for (i = 0; i < ARRAY_SIZE(devices); ++i)
350 platform_device_unregister(devices[i]);
351 platform_driver_unregister(&snd_sgalaxy_driver);
352}
353
354static int __init alsa_card_sgalaxy_init(void) 352static int __init alsa_card_sgalaxy_init(void)
355{ 353{
356 int i, cards, err; 354 return isa_register_driver(&snd_sgalaxy_driver, SNDRV_CARDS);
357
358 err = platform_driver_register(&snd_sgalaxy_driver);
359 if (err < 0)
360 return err;
361
362 cards = 0;
363 for (i = 0; i < SNDRV_CARDS; i++) {
364 struct platform_device *device;
365 if (! enable[i])
366 continue;
367 device = platform_device_register_simple(SND_SGALAXY_DRIVER,
368 i, NULL, 0);
369 if (IS_ERR(device))
370 continue;
371 if (!platform_get_drvdata(device)) {
372 platform_device_unregister(device);
373 continue;
374 }
375 devices[i] = device;
376 cards++;
377 }
378 if (!cards) {
379#ifdef MODULE
380 snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
381#endif
382 snd_sgalaxy_unregister_all();
383 return -ENODEV;
384 }
385 return 0;
386} 355}
387 356
388static void __exit alsa_card_sgalaxy_exit(void) 357static void __exit alsa_card_sgalaxy_exit(void)
389{ 358{
390 snd_sgalaxy_unregister_all(); 359 isa_unregister_driver(&snd_sgalaxy_driver);
391} 360}
392 361
393module_init(alsa_card_sgalaxy_init) 362module_init(alsa_card_sgalaxy_init)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index b1f25823c65..cbad2a51cba 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/pnp.h> 29#include <linux/pnp.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
@@ -68,10 +68,10 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
68module_param_array(dma, int, NULL, 0444); 68module_param_array(dma, int, NULL, 0444);
69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); 69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
70 70
71static struct platform_device *platform_devices[SNDRV_CARDS];
72
73#ifdef CONFIG_PNP 71#ifdef CONFIG_PNP
72static int isa_registered;
74static int pnp_registered; 73static int pnp_registered;
74
75static struct pnp_card_device_id sscape_pnpids[] = { 75static struct pnp_card_device_id sscape_pnpids[] = {
76 { .id = "ENS3081", .devs = { { "ENS0000" } } }, 76 { .id = "ENS3081", .devs = { { "ENS0000" } } },
77 { .id = "" } /* end */ 77 { .id = "" } /* end */
@@ -382,7 +382,7 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout)
382 unsigned long flags; 382 unsigned long flags;
383 unsigned char x; 383 unsigned char x;
384 384
385 schedule_timeout_interruptible(1); 385 schedule_timeout(1);
386 386
387 spin_lock_irqsave(&s->lock, flags); 387 spin_lock_irqsave(&s->lock, flags);
388 x = inb(HOST_DATA_IO(s->io_base)); 388 x = inb(HOST_DATA_IO(s->io_base));
@@ -409,7 +409,7 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
409 unsigned long flags; 409 unsigned long flags;
410 unsigned char x; 410 unsigned char x;
411 411
412 schedule_timeout_interruptible(1); 412 schedule_timeout(1);
413 413
414 spin_lock_irqsave(&s->lock, flags); 414 spin_lock_irqsave(&s->lock, flags);
415 x = inb(HOST_DATA_IO(s->io_base)); 415 x = inb(HOST_DATA_IO(s->io_base));
@@ -1254,9 +1254,27 @@ static int __devinit create_sscape(int dev, struct snd_card **rcardp)
1254} 1254}
1255 1255
1256 1256
1257static int __devinit snd_sscape_probe(struct platform_device *pdev) 1257static int __devinit snd_sscape_match(struct device *pdev, unsigned int i)
1258{
1259 /*
1260 * Make sure we were given ALL of the other parameters.
1261 */
1262 if (port[i] == SNDRV_AUTO_PORT)
1263 return 0;
1264
1265 if (irq[i] == SNDRV_AUTO_IRQ ||
1266 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1267 dma[i] == SNDRV_AUTO_DMA) {
1268 printk(KERN_INFO
1269 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
1270 return 0;
1271 }
1272
1273 return 1;
1274}
1275
1276static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
1258{ 1277{
1259 int dev = pdev->id;
1260 struct snd_card *card; 1278 struct snd_card *card;
1261 int ret; 1279 int ret;
1262 1280
@@ -1264,30 +1282,31 @@ static int __devinit snd_sscape_probe(struct platform_device *pdev)
1264 ret = create_sscape(dev, &card); 1282 ret = create_sscape(dev, &card);
1265 if (ret < 0) 1283 if (ret < 0)
1266 return ret; 1284 return ret;
1267 snd_card_set_dev(card, &pdev->dev); 1285 snd_card_set_dev(card, pdev);
1268 if ((ret = snd_card_register(card)) < 0) { 1286 if ((ret = snd_card_register(card)) < 0) {
1269 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1287 printk(KERN_ERR "sscape: Failed to register sound card\n");
1270 return ret; 1288 return ret;
1271 } 1289 }
1272 platform_set_drvdata(pdev, card); 1290 dev_set_drvdata(pdev, card);
1273 return 0; 1291 return 0;
1274} 1292}
1275 1293
1276static int __devexit snd_sscape_remove(struct platform_device *devptr) 1294static int __devexit snd_sscape_remove(struct device *devptr, unsigned int dev)
1277{ 1295{
1278 snd_card_free(platform_get_drvdata(devptr)); 1296 snd_card_free(dev_get_drvdata(devptr));
1279 platform_set_drvdata(devptr, NULL); 1297 dev_set_drvdata(devptr, NULL);
1280 return 0; 1298 return 0;
1281} 1299}
1282 1300
1283#define SSCAPE_DRIVER "snd_sscape" 1301#define DEV_NAME "sscape"
1284 1302
1285static struct platform_driver snd_sscape_driver = { 1303static struct isa_driver snd_sscape_driver = {
1304 .match = snd_sscape_match,
1286 .probe = snd_sscape_probe, 1305 .probe = snd_sscape_probe,
1287 .remove = __devexit_p(snd_sscape_remove), 1306 .remove = __devexit_p(snd_sscape_remove),
1288 /* FIXME: suspend/resume */ 1307 /* FIXME: suspend/resume */
1289 .driver = { 1308 .driver = {
1290 .name = SSCAPE_DRIVER 1309 .name = DEV_NAME
1291 }, 1310 },
1292}; 1311};
1293 1312
@@ -1386,90 +1405,33 @@ static struct pnp_card_driver sscape_pnpc_driver = {
1386 1405
1387#endif /* CONFIG_PNP */ 1406#endif /* CONFIG_PNP */
1388 1407
1389static void __init_or_module sscape_unregister_all(void) 1408static int __init sscape_init(void)
1390{ 1409{
1391 int i; 1410 int err;
1392 1411
1412 err = isa_register_driver(&snd_sscape_driver, SNDRV_CARDS);
1393#ifdef CONFIG_PNP 1413#ifdef CONFIG_PNP
1394 if (pnp_registered) 1414 if (!err)
1395 pnp_unregister_card_driver(&sscape_pnpc_driver); 1415 isa_registered = 1;
1396#endif
1397 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
1398 platform_device_unregister(platform_devices[i]);
1399 platform_driver_unregister(&snd_sscape_driver);
1400}
1401
1402static int __init sscape_manual_probe(void)
1403{
1404 struct platform_device *device;
1405 int i, ret;
1406
1407 ret = platform_driver_register(&snd_sscape_driver);
1408 if (ret < 0)
1409 return ret;
1410 1416
1411 for (i = 0; i < SNDRV_CARDS; ++i) { 1417 err = pnp_register_card_driver(&sscape_pnpc_driver);
1412 /* 1418 if (!err)
1413 * We do NOT probe for ports. 1419 pnp_registered = 1;
1414 * If we're not given a port number for this
1415 * card then we completely ignore this line
1416 * of parameters.
1417 */
1418 if (port[i] == SNDRV_AUTO_PORT)
1419 continue;
1420
1421 /*
1422 * Make sure we were given ALL of the other parameters.
1423 */
1424 if (irq[i] == SNDRV_AUTO_IRQ ||
1425 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1426 dma[i] == SNDRV_AUTO_DMA) {
1427 printk(KERN_INFO
1428 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
1429 sscape_unregister_all();
1430 return -ENXIO;
1431 }
1432
1433 /*
1434 * This cards looks OK ...
1435 */
1436 device = platform_device_register_simple(SSCAPE_DRIVER,
1437 i, NULL, 0);
1438 if (IS_ERR(device))
1439 continue;
1440 if (!platform_get_drvdata(device)) {
1441 platform_device_unregister(device);
1442 continue;
1443 }
1444 platform_devices[i] = device;
1445 }
1446 return 0;
1447}
1448 1420
1449static void sscape_exit(void) 1421 if (isa_registered)
1450{ 1422 err = 0;
1451 sscape_unregister_all(); 1423#endif
1424 return err;
1452} 1425}
1453 1426
1454 1427static void __exit sscape_exit(void)
1455static int __init sscape_init(void)
1456{ 1428{
1457 int ret;
1458
1459 /*
1460 * First check whether we were passed any parameters.
1461 * These MUST take precedence over ANY automatic way
1462 * of allocating cards, because the operator is
1463 * S-P-E-L-L-I-N-G it out for us...
1464 */
1465 ret = sscape_manual_probe();
1466 if (ret < 0)
1467 return ret;
1468#ifdef CONFIG_PNP 1429#ifdef CONFIG_PNP
1469 if (pnp_register_card_driver(&sscape_pnpc_driver) == 0) 1430 if (pnp_registered)
1470 pnp_registered = 1; 1431 pnp_unregister_card_driver(&sscape_pnpc_driver);
1432 if (isa_registered)
1471#endif 1433#endif
1472 return 0; 1434 isa_unregister_driver(&snd_sscape_driver);
1473} 1435}
1474 1436
1475module_init(sscape_init); 1437module_init(sscape_init);
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index e2fdd5fd39d..83c2fc4cfc6 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -24,7 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/pnp.h> 28#include <linux/pnp.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <sound/core.h> 30#include <sound/core.h>
@@ -40,7 +40,9 @@ MODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}");
40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
43#ifdef CONFIG_PNP
43static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 44static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
45#endif
44static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 46static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
45static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ 47static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
46static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 48static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
@@ -83,9 +85,8 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
83module_param_array(use_cs4232_midi, bool, NULL, 0444); 85module_param_array(use_cs4232_midi, bool, NULL, 0444);
84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 86MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
85 87
86static struct platform_device *platform_devices[SNDRV_CARDS];
87
88#ifdef CONFIG_PNP 88#ifdef CONFIG_PNP
89static int isa_registered;
89static int pnp_registered; 90static int pnp_registered;
90 91
91static struct pnp_card_device_id snd_wavefront_pnpids[] = { 92static struct pnp_card_device_id snd_wavefront_pnpids[] = {
@@ -588,56 +589,67 @@ snd_wavefront_probe (struct snd_card *card, int dev)
588 return snd_card_register(card); 589 return snd_card_register(card);
589} 590}
590 591
591static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev) 592static int __devinit snd_wavefront_isa_match(struct device *pdev,
593 unsigned int dev)
592{ 594{
593 int dev = pdev->id; 595 if (!enable[dev])
594 struct snd_card *card; 596 return 0;
595 int err; 597#ifdef CONFIG_PNP
596 598 if (isapnp[dev])
599 return 0;
600#endif
597 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 601 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
598 snd_printk("specify CS4232 port\n"); 602 snd_printk("specify CS4232 port\n");
599 return -EINVAL; 603 return 0;
600 } 604 }
601 if (ics2115_port[dev] == SNDRV_AUTO_PORT) { 605 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
602 snd_printk("specify ICS2115 port\n"); 606 snd_printk("specify ICS2115 port\n");
603 return -ENODEV; 607 return 0;
604 } 608 }
609 return 1;
610}
611
612static int __devinit snd_wavefront_isa_probe(struct device *pdev,
613 unsigned int dev)
614{
615 struct snd_card *card;
616 int err;
605 617
606 card = snd_wavefront_card_new(dev); 618 card = snd_wavefront_card_new(dev);
607 if (! card) 619 if (! card)
608 return -ENOMEM; 620 return -ENOMEM;
609 snd_card_set_dev(card, &pdev->dev); 621 snd_card_set_dev(card, pdev);
610 if ((err = snd_wavefront_probe(card, dev)) < 0) { 622 if ((err = snd_wavefront_probe(card, dev)) < 0) {
611 snd_card_free(card); 623 snd_card_free(card);
612 return err; 624 return err;
613 } 625 }
614 626
615 platform_set_drvdata(pdev, card); 627 dev_set_drvdata(pdev, card);
616 return 0; 628 return 0;
617} 629}
618 630
619static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) 631static int __devexit snd_wavefront_isa_remove(struct device *devptr,
632 unsigned int dev)
620{ 633{
621 snd_card_free(platform_get_drvdata(devptr)); 634 snd_card_free(dev_get_drvdata(devptr));
622 platform_set_drvdata(devptr, NULL); 635 dev_set_drvdata(devptr, NULL);
623 return 0; 636 return 0;
624} 637}
625 638
626#define WAVEFRONT_DRIVER "snd_wavefront" 639#define DEV_NAME "wavefront"
627 640
628static struct platform_driver snd_wavefront_driver = { 641static struct isa_driver snd_wavefront_driver = {
629 .probe = snd_wavefront_nonpnp_probe, 642 .match = snd_wavefront_isa_match,
630 .remove = __devexit_p(snd_wavefront_nonpnp_remove), 643 .probe = snd_wavefront_isa_probe,
644 .remove = __devexit_p(snd_wavefront_isa_remove),
631 /* FIXME: suspend, resume */ 645 /* FIXME: suspend, resume */
632 .driver = { 646 .driver = {
633 .name = WAVEFRONT_DRIVER 647 .name = DEV_NAME
634 }, 648 },
635}; 649};
636 650
637 651
638#ifdef CONFIG_PNP 652#ifdef CONFIG_PNP
639static unsigned int __devinitdata wavefront_pnp_devices;
640
641static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, 653static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
642 const struct pnp_card_device_id *pid) 654 const struct pnp_card_device_id *pid)
643{ 655{
@@ -670,7 +682,6 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
670 682
671 pnp_set_card_drvdata(pcard, card); 683 pnp_set_card_drvdata(pcard, card);
672 dev++; 684 dev++;
673 wavefront_pnp_devices++;
674 return 0; 685 return 0;
675} 686}
676 687
@@ -691,67 +702,33 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
691 702
692#endif /* CONFIG_PNP */ 703#endif /* CONFIG_PNP */
693 704
694static void __init_or_module snd_wavefront_unregister_all(void)
695{
696 int i;
697
698#ifdef CONFIG_PNP
699 if (pnp_registered)
700 pnp_unregister_card_driver(&wavefront_pnpc_driver);
701#endif
702 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
703 platform_device_unregister(platform_devices[i]);
704 platform_driver_unregister(&snd_wavefront_driver);
705}
706
707static int __init alsa_card_wavefront_init(void) 705static int __init alsa_card_wavefront_init(void)
708{ 706{
709 int i, err, cards = 0; 707 int err;
710
711 if ((err = platform_driver_register(&snd_wavefront_driver)) < 0)
712 return err;
713 708
714 for (i = 0; i < SNDRV_CARDS; i++) { 709 err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
715 struct platform_device *device;
716 if (! enable[i])
717 continue;
718#ifdef CONFIG_PNP 710#ifdef CONFIG_PNP
719 if (isapnp[i]) 711 if (!err)
720 continue; 712 isa_registered = 1;
721#endif
722 device = platform_device_register_simple(WAVEFRONT_DRIVER,
723 i, NULL, 0);
724 if (IS_ERR(device))
725 continue;
726 if (!platform_get_drvdata(device)) {
727 platform_device_unregister(device);
728 continue;
729 }
730 platform_devices[i] = device;
731 cards++;
732 }
733 713
734#ifdef CONFIG_PNP
735 err = pnp_register_card_driver(&wavefront_pnpc_driver); 714 err = pnp_register_card_driver(&wavefront_pnpc_driver);
736 if (!err) { 715 if (!err)
737 pnp_registered = 1; 716 pnp_registered = 1;
738 cards += wavefront_pnp_devices;
739 }
740#endif
741 717
742 if (!cards) { 718 if (isa_registered)
743#ifdef MODULE 719 err = 0;
744 printk (KERN_ERR "No WaveFront cards found or devices busy\n");
745#endif 720#endif
746 snd_wavefront_unregister_all(); 721 return err;
747 return -ENODEV;
748 }
749 return 0;
750} 722}
751 723
752static void __exit alsa_card_wavefront_exit(void) 724static void __exit alsa_card_wavefront_exit(void)
753{ 725{
754 snd_wavefront_unregister_all(); 726#ifdef CONFIG_PNP
727 if (pnp_registered)
728 pnp_unregister_card_driver(&wavefront_pnpc_driver);
729 if (isa_registered)
730#endif
731 isa_unregister_driver(&snd_wavefront_driver);
755} 732}
756 733
757module_init(alsa_card_wavefront_init) 734module_init(alsa_card_wavefront_init)
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index 15331ed8819..fc95a870f69 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -35,9 +35,7 @@
35 35
36#define WAIT_IDLE 0xff 36#define WAIT_IDLE 0xff
37 37
38#define FIRMWARE_IN_THE_KERNEL 38#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
39
40#ifdef FIRMWARE_IN_THE_KERNEL
41#include "yss225.c" 39#include "yss225.c"
42static const struct firmware yss225_registers_firmware = { 40static const struct firmware yss225_registers_firmware = {
43 .data = (u8 *)yss225_registers, 41 .data = (u8 *)yss225_registers,
@@ -258,21 +256,21 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
258{ 256{
259 unsigned int i; 257 unsigned int i;
260 int err; 258 int err;
261 const struct firmware *firmware; 259 const struct firmware *firmware = NULL;
262 260
263 if (dev->fx_initialized) 261 if (dev->fx_initialized)
264 return 0; 262 return 0;
265 263
264#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
265 firmware = &yss225_registers_firmware;
266#else
266 err = request_firmware(&firmware, "yamaha/yss225_registers.bin", 267 err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
267 dev->card->dev); 268 dev->card->dev);
268 if (err < 0) { 269 if (err < 0) {
269#ifdef FIRMWARE_IN_THE_KERNEL
270 firmware = &yss225_registers_firmware;
271#else
272 err = -1; 270 err = -1;
273 goto out; 271 goto out;
274#endif
275 } 272 }
273#endif
276 274
277 for (i = 0; i + 1 < firmware->size; i += 2) { 275 for (i = 0; i + 1 < firmware->size; i += 2) {
278 if (firmware->data[i] >= 8 && firmware->data[i] < 16) { 276 if (firmware->data[i] >= 8 && firmware->data[i] < 16) {
@@ -295,9 +293,12 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
295 err = 0; 293 err = 0;
296 294
297out: 295out:
298#ifdef FIRMWARE_IN_THE_KERNEL 296#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
299 if (firmware != &yss225_registers_firmware) 297 release_firmware(firmware);
300#endif 298#endif
301 release_firmware(firmware);
302 return err; 299 return err;
303} 300}
301
302#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
303MODULE_FIRMWARE("yamaha/yss225_registers.bin");
304#endif
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index 78020d832e0..bacc51c8658 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -1780,7 +1780,7 @@ wavefront_should_cause_interrupt (snd_wavefront_t *dev,
1780 outb (val,port); 1780 outb (val,port);
1781 spin_unlock_irq(&dev->irq_lock); 1781 spin_unlock_irq(&dev->irq_lock);
1782 while (1) { 1782 while (1) {
1783 if ((timeout = schedule_timeout_interruptible(timeout)) == 0) 1783 if ((timeout = schedule_timeout(timeout)) == 0)
1784 return; 1784 return;
1785 if (dev->irq_ok) 1785 if (dev->irq_ok)
1786 return; 1786 return;
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index 4b30ae6d8ba..866d4de8d4a 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -5,35 +5,6 @@
5# 5#
6# Prompt user for primary drivers. 6# Prompt user for primary drivers.
7 7
8config OSS_OBSOLETE
9 bool "Obsolete OSS drivers"
10 depends on SOUND_PRIME
11 help
12 This option enables support for obsolete OSS drivers that
13 are scheduled for removal in the near future.
14
15 Please contact Adrian Bunk <bunk@stusta.de> if you had to
16 say Y here because your hardware is not properly supported
17 by ALSA.
18
19 If unsure, say N.
20
21config SOUND_BT878
22 tristate "BT878 audio dma"
23 depends on SOUND_PRIME && PCI && OSS_OBSOLETE
24 ---help---
25 Audio DMA support for bt878 based grabber boards. As you might have
26 already noticed, bt878 is listed with two functions in /proc/pci.
27 Function 0 does the video stuff (bt848 compatible), function 1 does
28 the same for audio data. This is a driver for the audio part of
29 the chip. If you say 'Y' here you get a oss-compatible dsp device
30 where you can record from. If you want just watch TV you probably
31 don't need this driver as most TV cards handle sound with a short
32 cable from the TV card to your sound card's line-in.
33
34 To compile this driver as a module, choose M here: the module will
35 be called btaudio.
36
37config SOUND_BCM_CS4297A 8config SOUND_BCM_CS4297A
38 tristate "Crystal Sound CS4297a (for Swarm)" 9 tristate "Crystal Sound CS4297a (for Swarm)"
39 depends on SOUND_PRIME && SIBYTE_SWARM 10 depends on SOUND_PRIME && SIBYTE_SWARM
@@ -44,13 +15,6 @@ config SOUND_BCM_CS4297A
44 note that CONFIG_KGDB should not be enabled at the same 15 note that CONFIG_KGDB should not be enabled at the same
45 time, since it also attempts to use this UART port. 16 time, since it also attempts to use this UART port.
46 17
47config SOUND_ICH
48 tristate "Intel ICH (i8xx) audio support"
49 depends on SOUND_PRIME && PCI && OSS_OBSOLETE
50 help
51 Support for integral audio in Intel's I/O Controller Hub (ICH)
52 chipset, as used on the 810/820/840 motherboards.
53
54config SOUND_VWSND 18config SOUND_VWSND
55 tristate "SGI Visual Workstation Sound" 19 tristate "SGI Visual Workstation Sound"
56 depends on SOUND_PRIME && X86_VISWS 20 depends on SOUND_PRIME && X86_VISWS
@@ -346,29 +310,9 @@ config MSND_FIFOSIZE
346 and Pinnacle). Larger values reduce the chance of data overruns at 310 and Pinnacle). Larger values reduce the chance of data overruns at
347 the expense of overall latency. If unsure, use the default. 311 the expense of overall latency. If unsure, use the default.
348 312
349config SOUND_VIA82CXXX
350 tristate "VIA 82C686 Audio Codec"
351 depends on SOUND_PRIME && PCI && OSS_OBSOLETE
352 help
353 Say Y here to include support for the audio codec found on VIA
354 82Cxxx-based chips. Typically these are built into a motherboard.
355
356 DO NOT select Sound Blaster or Adlib with this driver, unless
357 you have a Sound Blaster or Adlib card in addition to your VIA
358 audio chip.
359
360config MIDI_VIA82CXXX
361 bool "VIA 82C686 MIDI"
362 depends on SOUND_VIA82CXXX && ISA_DMA_API
363 help
364 Answer Y to use the MIDI interface of the Via686. You may need to
365 enable this in the BIOS before it will work. This is for connection
366 to external MIDI hardware, and is not required for software playback
367 of MIDI files.
368
369config SOUND_OSS 313config SOUND_OSS
370 tristate "OSS sound modules" 314 tristate "OSS sound modules"
371 depends on SOUND_PRIME && ISA_DMA_API 315 depends on SOUND_PRIME && ISA_DMA_API && VIRT_TO_BUS
372 help 316 help
373 OSS is the Open Sound System suite of sound card drivers. They make 317 OSS is the Open Sound System suite of sound card drivers. They make
374 sound programming easier since they provide a common API. Say Y or 318 sound programming easier since they provide a common API. Say Y or
@@ -400,23 +344,10 @@ config SOUND_DMAP
400 344
401 Say Y unless you have 16MB or more RAM or a PCI sound card. 345 Say Y unless you have 16MB or more RAM or a PCI sound card.
402 346
403config SOUND_CS4232
404 tristate "Crystal CS4232 based (PnP) cards"
405 depends on SOUND_OSS && OSS_OBSOLETE
406 help
407 Say Y here if you have a card based on the Crystal CS4232 chip set,
408 which uses its own Plug and Play protocol.
409
410 If you compile the driver into the kernel, you have to add
411 "cs4232=<io>,<irq>,<dma>,<dma2>,<mpuio>,<mpuirq>" to the kernel
412 command line.
413
414 See <file:Documentation/sound/oss/CS4232> for more information on
415 configuring this card.
416
417config SOUND_SSCAPE 347config SOUND_SSCAPE
418 tristate "Ensoniq SoundScape support" 348 tristate "Ensoniq SoundScape support"
419 depends on SOUND_OSS 349 depends on SOUND_OSS
350 depends on VIRT_TO_BUS
420 help 351 help
421 Answer Y if you have a sound card based on the Ensoniq SoundScape 352 Answer Y if you have a sound card based on the Ensoniq SoundScape
422 chipset. Such cards are being manufactured at least by Ensoniq, Spea 353 chipset. Such cards are being manufactured at least by Ensoniq, Spea
@@ -719,13 +650,6 @@ config SOUND_WAVEARTIST
719 Say Y here to include support for the Rockwell WaveArtist sound 650 Say Y here to include support for the Rockwell WaveArtist sound
720 system. This driver is mainly for the NetWinder. 651 system. This driver is mainly for the NetWinder.
721 652
722config SOUND_TVMIXER
723 tristate "TV card (bt848) mixer support"
724 depends on SOUND_PRIME && I2C && VIDEO_V4L1 && OSS_OBSOLETE
725 help
726 Support for audio mixer facilities on the BT848 TV frame-grabber
727 card.
728
729config SOUND_KAHLUA 653config SOUND_KAHLUA
730 tristate "XpressAudio Sound Blaster emulation" 654 tristate "XpressAudio Sound Blaster emulation"
731 depends on SOUND_SB 655 depends on SOUND_SB
diff --git a/sound/oss/Makefile b/sound/oss/Makefile
index 2489bd6bb08..7a2f9ae7b7c 100644
--- a/sound/oss/Makefile
+++ b/sound/oss/Makefile
@@ -18,20 +18,15 @@ obj-$(CONFIG_SOUND_TRIX) += trix.o ad1848.o sb_lib.o uart401.o
18obj-$(CONFIG_SOUND_SSCAPE) += sscape.o ad1848.o mpu401.o 18obj-$(CONFIG_SOUND_SSCAPE) += sscape.o ad1848.o mpu401.o
19obj-$(CONFIG_SOUND_CS4232) += cs4232.o uart401.o 19obj-$(CONFIG_SOUND_CS4232) += cs4232.o uart401.o
20obj-$(CONFIG_SOUND_MSS) += ad1848.o 20obj-$(CONFIG_SOUND_MSS) += ad1848.o
21obj-$(CONFIG_SOUND_OPL3SA2) += opl3sa2.o ad1848.o mpu401.o
22obj-$(CONFIG_SOUND_PAS) += pas2.o sb.o sb_lib.o uart401.o 21obj-$(CONFIG_SOUND_PAS) += pas2.o sb.o sb_lib.o uart401.o
23obj-$(CONFIG_SOUND_SB) += sb.o sb_lib.o uart401.o 22obj-$(CONFIG_SOUND_SB) += sb.o sb_lib.o uart401.o
24obj-$(CONFIG_SOUND_KAHLUA) += kahlua.o 23obj-$(CONFIG_SOUND_KAHLUA) += kahlua.o
25obj-$(CONFIG_SOUND_MPU401) += mpu401.o 24obj-$(CONFIG_SOUND_MPU401) += mpu401.o
26obj-$(CONFIG_SOUND_UART6850) += uart6850.o 25obj-$(CONFIG_SOUND_UART6850) += uart6850.o
27obj-$(CONFIG_SOUND_ADLIB) += adlib_card.o opl3.o
28obj-$(CONFIG_SOUND_YM3812) += opl3.o 26obj-$(CONFIG_SOUND_YM3812) += opl3.o
29obj-$(CONFIG_SOUND_VMIDI) += v_midi.o 27obj-$(CONFIG_SOUND_VMIDI) += v_midi.o
30obj-$(CONFIG_SOUND_VIDC) += vidc_mod.o 28obj-$(CONFIG_SOUND_VIDC) += vidc_mod.o
31obj-$(CONFIG_SOUND_WAVEARTIST) += waveartist.o 29obj-$(CONFIG_SOUND_WAVEARTIST) += waveartist.o
32obj-$(CONFIG_SOUND_AD1816) += ad1816.o
33obj-$(CONFIG_SOUND_AD1889) += ad1889.o ac97_codec.o
34obj-$(CONFIG_SOUND_ACI_MIXER) += aci.o
35 30
36obj-$(CONFIG_SOUND_VIA82CXXX) += via82cxxx_audio.o ac97_codec.o 31obj-$(CONFIG_SOUND_VIA82CXXX) += via82cxxx_audio.o ac97_codec.o
37ifeq ($(CONFIG_MIDI_VIA82CXXX),y) 32ifeq ($(CONFIG_MIDI_VIA82CXXX),y)
@@ -40,24 +35,16 @@ endif
40obj-$(CONFIG_SOUND_MSNDCLAS) += msnd.o msnd_classic.o 35obj-$(CONFIG_SOUND_MSNDCLAS) += msnd.o msnd_classic.o
41obj-$(CONFIG_SOUND_MSNDPIN) += msnd.o msnd_pinnacle.o 36obj-$(CONFIG_SOUND_MSNDPIN) += msnd.o msnd_pinnacle.o
42obj-$(CONFIG_SOUND_VWSND) += vwsnd.o 37obj-$(CONFIG_SOUND_VWSND) += vwsnd.o
43obj-$(CONFIG_SOUND_NM256) += nm256_audio.o ac97.o
44obj-$(CONFIG_SOUND_ICH) += i810_audio.o ac97_codec.o 38obj-$(CONFIG_SOUND_ICH) += i810_audio.o ac97_codec.o
45obj-$(CONFIG_SOUND_ES1371) += es1371.o ac97_codec.o 39obj-$(CONFIG_SOUND_ES1371) += es1371.o ac97_codec.o
46obj-$(CONFIG_SOUND_VRC5477) += nec_vrc5477.o ac97_codec.o 40obj-$(CONFIG_SOUND_VRC5477) += nec_vrc5477.o ac97_codec.o
47obj-$(CONFIG_SOUND_AU1550_AC97) += au1550_ac97.o ac97_codec.o 41obj-$(CONFIG_SOUND_AU1550_AC97) += au1550_ac97.o ac97_codec.o
48obj-$(CONFIG_SOUND_FUSION) += cs46xx.o ac97_codec.o
49obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o 42obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o
50obj-$(CONFIG_SOUND_EMU10K1) += ac97_codec.o
51obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o 43obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o
52obj-$(CONFIG_SOUND_BT878) += btaudio.o 44obj-$(CONFIG_SOUND_BT878) += btaudio.o
53 45
54obj-$(CONFIG_SOUND_WM97XX) += ac97_plugin_wm97xx.o 46obj-$(CONFIG_SOUND_WM97XX) += ac97_plugin_wm97xx.o
55 47
56ifeq ($(CONFIG_MIDI_EMU10K1),y)
57 obj-$(CONFIG_SOUND_EMU10K1) += sound.o
58endif
59
60obj-$(CONFIG_SOUND_EMU10K1) += emu10k1/
61obj-$(CONFIG_DMASOUND) += dmasound/ 48obj-$(CONFIG_DMASOUND) += dmasound/
62 49
63# Declare multi-part drivers. 50# Declare multi-part drivers.
diff --git a/sound/oss/ac97.c b/sound/oss/ac97.c
deleted file mode 100644
index 72cf4ed7793..00000000000
--- a/sound/oss/ac97.c
+++ /dev/null
@@ -1,432 +0,0 @@
1#include <linux/module.h>
2#include <linux/kernel.h>
3#include <linux/init.h>
4#include "ac97.h"
5
6/* Flag for mono controls. */
7#define MO 0
8/* And for stereo. */
9#define ST 1
10
11/* Whether or not the bits in the channel are inverted. */
12#define INV 1
13#define NINV 0
14
15static struct ac97_chn_desc {
16 int ac97_regnum;
17 int oss_channel;
18 int maxval;
19 int is_stereo;
20 int oss_mask;
21 int recordNum;
22 u16 regmask;
23 int is_inverted;
24} mixerRegs[] = {
25 { AC97_MASTER_VOL_STEREO, SOUND_MIXER_VOLUME, 0x3f, ST, SOUND_MASK_VOLUME, 5, 0x0000, INV },
26 { AC97_MASTER_VOL_MONO, SOUND_MIXER_PHONEOUT, 0x3f, MO, SOUND_MASK_PHONEOUT, 6, 0x0000, INV },
27 { AC97_MASTER_TONE, SOUND_MIXER_TREBLE, 0x0f, MO, SOUND_MASK_TREBLE, -1, 0x00ff, INV },
28 { AC97_MASTER_TONE, SOUND_MIXER_BASS, 0x0f, MO, SOUND_MASK_BASS, -1, 0xff00, INV },
29 { AC97_PCBEEP_VOL, SOUND_MIXER_SPEAKER, 0x0f, MO, SOUND_MASK_SPEAKER, -1, 0x001e, INV },
30 { AC97_PHONE_VOL, SOUND_MIXER_PHONEIN, 0x1f, MO, SOUND_MASK_PHONEIN, 7, 0x0000, INV },
31 { AC97_MIC_VOL, SOUND_MIXER_MIC, 0x1f, MO, SOUND_MASK_MIC, 0, 0x0000, INV },
32 { AC97_LINEIN_VOL, SOUND_MIXER_LINE, 0x1f, ST, SOUND_MASK_LINE, 4, 0x0000, INV },
33 { AC97_CD_VOL, SOUND_MIXER_CD, 0x1f, ST, SOUND_MASK_CD, 1, 0x0000, INV },
34 { AC97_VIDEO_VOL, SOUND_MIXER_VIDEO, 0x1f, ST, SOUND_MASK_VIDEO, 2, 0x0000, INV },
35 { AC97_AUX_VOL, SOUND_MIXER_LINE1, 0x1f, ST, SOUND_MASK_LINE1, 3, 0x0000, INV },
36 { AC97_PCMOUT_VOL, SOUND_MIXER_PCM, 0x1f, ST, SOUND_MASK_PCM, -1, 0x0000, INV },
37 { AC97_RECORD_GAIN, SOUND_MIXER_IGAIN, 0x0f, ST, SOUND_MASK_IGAIN, -1, 0x0000, NINV },
38 { -1, -1, 0xff, 0, 0, -1, 0x0000, 0 },
39};
40
41static struct ac97_chn_desc *
42ac97_find_chndesc (struct ac97_hwint *dev, int oss_channel)
43{
44 int x;
45
46 for (x = 0; mixerRegs[x].oss_channel != -1; x++) {
47 if (mixerRegs[x].oss_channel == oss_channel)
48 return mixerRegs + x;
49 }
50
51 return NULL;
52}
53
54static inline int
55ac97_is_valid_channel (struct ac97_hwint *dev, struct ac97_chn_desc *chn)
56{
57 return (dev->last_written_mixer_values[chn->ac97_regnum / 2]
58 != AC97_REG_UNSUPPORTED);
59}
60
61int
62ac97_init (struct ac97_hwint *dev)
63{
64 int x;
65 int reg0;
66
67 /* Clear out the arrays of cached values. */
68 for (x = 0; x < AC97_REG_CNT; x++)
69 dev->last_written_mixer_values[x] = AC97_REGVAL_UNKNOWN;
70
71 for (x = 0; x < SOUND_MIXER_NRDEVICES; x++)
72 dev->last_written_OSS_values[x] = AC97_REGVAL_UNKNOWN;
73
74 /* Clear the device masks. */
75 dev->mixer_devmask = 0;
76 dev->mixer_stereomask = 0;
77 dev->mixer_recmask = 0;
78
79 /* ??? Do a "standard reset" via register 0? */
80
81 /* Hardware-dependent reset. */
82 if (dev->reset_device (dev))
83 return -1;
84
85 /* Check the mixer device capabilities. */
86 reg0 = dev->read_reg (dev, AC97_RESET);
87
88 if (reg0 < 0)
89 return -1;
90
91 /* Check for support for treble/bass controls. */
92 if (! (reg0 & 4)) {
93 dev->last_written_mixer_values[AC97_MASTER_TONE / 2]
94 = AC97_REG_UNSUPPORTED;
95 }
96
97 /* ??? There may be other tests here? */
98
99 /* Fill in the device masks. */
100 for (x = 0; mixerRegs[x].ac97_regnum != -1; x++) {
101 if (ac97_is_valid_channel (dev, mixerRegs + x)) {
102 dev->mixer_devmask |= mixerRegs[x].oss_mask;
103
104 if (mixerRegs[x].is_stereo)
105 dev->mixer_stereomask |= mixerRegs[x].oss_mask;
106
107 if (mixerRegs[x].recordNum != -1)
108 dev->mixer_recmask |= mixerRegs[x].oss_mask;
109 }
110 }
111
112 return 0;
113}
114
115/* Return the contents of register REG; use the cache if the value in it
116 is valid. Returns a negative error code on failure. */
117static int
118ac97_get_register (struct ac97_hwint *dev, u8 reg)
119{
120 if (reg > 127 || (reg & 1))
121 return -EINVAL;
122
123 /* See if it's in the cache, or if it's just plain invalid. */
124 switch (dev->last_written_mixer_values[reg / 2]) {
125 case AC97_REG_UNSUPPORTED:
126 return -EINVAL;
127 break;
128 case AC97_REGVAL_UNKNOWN:
129 dev->last_written_mixer_values[reg / 2] = dev->read_reg (dev, reg);
130 break;
131 default:
132 break;
133 }
134 return dev->last_written_mixer_values[reg / 2];
135}
136
137/* Write VALUE to AC97 register REG, and cache its value in the last-written
138 cache. Returns a negative error code on failure, or 0 on success. */
139int
140ac97_put_register (struct ac97_hwint *dev, u8 reg, u16 value)
141{
142 if (reg > 127 || (reg & 1))
143 return -EINVAL;
144
145 if (dev->last_written_mixer_values[reg / 2] == AC97_REG_UNSUPPORTED)
146 return -EINVAL;
147 else {
148 int res = dev->write_reg (dev, reg, value);
149 if (res >= 0) {
150 dev->last_written_mixer_values[reg / 2] = value;
151 return 0;
152 }
153 else
154 return res;
155 }
156}
157
158/* Scale VALUE (a value fro 0 to MAXVAL) to a value from 0-100. If
159 IS_STEREO is set, VALUE is a stereo value; the left channel value
160 is in the lower 8 bits, and the right channel value is in the upper
161 8 bits.
162
163 A negative error code is returned on failure, or the unsigned
164 scaled value on success. */
165
166static int
167ac97_scale_to_oss_val (int value, int maxval, int is_stereo, int inv)
168{
169 /* Muted? */
170 if (value & AC97_MUTE)
171 return 0;
172
173 if (is_stereo)
174 return (ac97_scale_to_oss_val (value & 255, maxval, 0, inv) << 8)
175 | (ac97_scale_to_oss_val ((value >> 8) & 255, maxval, 0, inv) << 0);
176 else {
177 int i;
178
179 /* Inverted. */
180 if (inv)
181 value = maxval - value;
182
183 i = (value * 100 + (maxval / 2)) / maxval;
184 if (i > 100)
185 i = 100;
186 if (i < 0)
187 i = 0;
188 return i;
189 }
190}
191
192static int
193ac97_scale_from_oss_val (int value, int maxval, int is_stereo, int inv)
194{
195 if (is_stereo)
196 return (ac97_scale_from_oss_val (value & 255, maxval, 0, inv) << 8)
197 | (ac97_scale_from_oss_val ((value >> 8) & 255, maxval, 0, inv) << 0);
198 else {
199 int i = ((value & 255) * maxval + 50) / 100;
200 if (inv)
201 i = maxval - i;
202 if (i < 0)
203 i = 0;
204 if (i > maxval)
205 i = maxval;
206 return i;
207 }
208}
209
210static int
211ac97_set_mixer (struct ac97_hwint *dev, int oss_channel, u16 oss_value)
212{
213 int scaled_value;
214 struct ac97_chn_desc *channel = ac97_find_chndesc (dev, oss_channel);
215 int result;
216
217 if (channel == NULL)
218 return -ENODEV;
219 if (! ac97_is_valid_channel (dev, channel))
220 return -ENODEV;
221 scaled_value = ac97_scale_from_oss_val (oss_value, channel->maxval,
222 channel->is_stereo,
223 channel->is_inverted);
224 if (scaled_value < 0)
225 return scaled_value;
226
227 if (channel->regmask != 0) {
228 int mv;
229
230 int oldval = ac97_get_register (dev, channel->ac97_regnum);
231 if (oldval < 0)
232 return oldval;
233
234 for (mv = channel->regmask; ! (mv & 1); mv >>= 1)
235 scaled_value <<= 1;
236
237 scaled_value &= channel->regmask;
238 scaled_value |= (oldval & ~channel->regmask);
239 }
240 result = ac97_put_register (dev, channel->ac97_regnum, scaled_value);
241 if (result == 0)
242 dev->last_written_OSS_values[oss_channel] = oss_value;
243 return result;
244}
245
246static int
247ac97_get_mixer_scaled (struct ac97_hwint *dev, int oss_channel)
248{
249 struct ac97_chn_desc *channel = ac97_find_chndesc (dev, oss_channel);
250 int regval;
251
252 if (channel == NULL)
253 return -ENODEV;
254
255 if (! ac97_is_valid_channel (dev, channel))
256 return -ENODEV;
257
258 regval = ac97_get_register (dev, channel->ac97_regnum);
259
260 if (regval < 0)
261 return regval;
262
263 if (channel->regmask != 0) {
264 int mv;
265
266 regval &= channel->regmask;
267
268 for (mv = channel->regmask; ! (mv & 1); mv >>= 1)
269 regval >>= 1;
270 }
271 return ac97_scale_to_oss_val (regval, channel->maxval,
272 channel->is_stereo,
273 channel->is_inverted);
274}
275
276static int
277ac97_get_recmask (struct ac97_hwint *dev)
278{
279 int recReg = ac97_get_register (dev, AC97_RECORD_SELECT);
280
281 if (recReg < 0)
282 return recReg;
283 else {
284 int x;
285 for (x = 0; mixerRegs[x].ac97_regnum >= 0; x++) {
286 if (mixerRegs[x].recordNum == (recReg & 7))
287 return mixerRegs[x].oss_mask;
288 }
289 return -ENODEV;
290 }
291}
292
293static int
294ac97_set_recmask (struct ac97_hwint *dev, int oss_recmask)
295{
296 int x;
297
298 if (oss_recmask == 0)
299 oss_recmask = SOUND_MIXER_MIC;
300
301 for (x = 0; mixerRegs[x].ac97_regnum >= 0; x++) {
302 if ((mixerRegs[x].recordNum >= 0)
303 && (oss_recmask & mixerRegs[x].oss_mask))
304 break;
305 }
306 if (mixerRegs[x].ac97_regnum < 0)
307 return -ENODEV;
308 else {
309 int regval = (mixerRegs[x].recordNum << 8) | mixerRegs[x].recordNum;
310 int res = ac97_put_register (dev, AC97_RECORD_SELECT, regval);
311 if (res == 0)
312 return ac97_get_recmask (dev);
313 else
314 return res;
315 }
316}
317
318/* Set the mixer DEV to the list of values in VALUE_LIST. Return 0 on
319 success, or a negative error code. */
320int
321ac97_set_values (struct ac97_hwint *dev,
322 struct ac97_mixer_value_list *value_list)
323{
324 int x;
325
326 for (x = 0; value_list[x].oss_channel != -1; x++) {
327 int chnum = value_list[x].oss_channel;
328 struct ac97_chn_desc *chent = ac97_find_chndesc (dev, chnum);
329 if (chent != NULL) {
330 u16 val;
331 int res;
332
333 if (chent->is_stereo)
334 val = (value_list[x].value.stereo.right << 8)
335 | value_list[x].value.stereo.left;
336 else {
337 /* We do this so the returned value looks OK in the
338 mixer app. It's not necessary otherwise. */
339 val = (value_list[x].value.mono << 8)
340 | value_list[x].value.mono;
341 }
342 res = ac97_set_mixer (dev, chnum, val);
343 if (res < 0)
344 return res;
345 }
346 else
347 return -ENODEV;
348 }
349 return 0;
350}
351
352int
353ac97_mixer_ioctl (struct ac97_hwint *dev, unsigned int cmd, void __user *arg)
354{
355 int ret;
356
357 switch (cmd) {
358 case SOUND_MIXER_READ_RECSRC:
359 ret = ac97_get_recmask (dev);
360 break;
361
362 case SOUND_MIXER_WRITE_RECSRC:
363 {
364 if (get_user (ret, (int __user *) arg))
365 ret = -EFAULT;
366 else
367 ret = ac97_set_recmask (dev, ret);
368 }
369 break;
370
371 case SOUND_MIXER_READ_CAPS:
372 ret = SOUND_CAP_EXCL_INPUT;
373 break;
374
375 case SOUND_MIXER_READ_DEVMASK:
376 ret = dev->mixer_devmask;
377 break;
378
379 case SOUND_MIXER_READ_RECMASK:
380 ret = dev->mixer_recmask;
381 break;
382
383 case SOUND_MIXER_READ_STEREODEVS:
384 ret = dev->mixer_stereomask;
385 break;
386
387 default:
388 /* Read or write request. */
389 ret = -EINVAL;
390 if (_IOC_TYPE (cmd) == 'M') {
391 int dir = _SIOC_DIR (cmd);
392 int channel = _IOC_NR (cmd);
393
394 if (channel >= 0 && channel < SOUND_MIXER_NRDEVICES) {
395 ret = 0;
396 if (dir & _SIOC_WRITE) {
397 int val;
398 if (get_user (val, (int __user *) arg) == 0)
399 ret = ac97_set_mixer (dev, channel, val);
400 else
401 ret = -EFAULT;
402 }
403 if (ret >= 0 && (dir & _SIOC_READ)) {
404 if (dev->last_written_OSS_values[channel]
405 == AC97_REGVAL_UNKNOWN)
406 dev->last_written_OSS_values[channel]
407 = ac97_get_mixer_scaled (dev, channel);
408 ret = dev->last_written_OSS_values[channel];
409 }
410 }
411 }
412 break;
413 }
414
415 if (ret < 0)
416 return ret;
417 else
418 return put_user(ret, (int __user *) arg);
419}
420
421EXPORT_SYMBOL(ac97_init);
422EXPORT_SYMBOL(ac97_set_values);
423EXPORT_SYMBOL(ac97_put_register);
424EXPORT_SYMBOL(ac97_mixer_ioctl);
425MODULE_LICENSE("GPL");
426
427
428/*
429 * Local variables:
430 * c-basic-offset: 4
431 * End:
432 */
diff --git a/sound/oss/ac97.h b/sound/oss/ac97.h
deleted file mode 100644
index 01837a9d7d6..00000000000
--- a/sound/oss/ac97.h
+++ /dev/null
@@ -1,201 +0,0 @@
1/*
2 * ac97.h
3 *
4 * definitions for the AC97, Intel's Audio Codec 97 Spec
5 * also includes support for a generic AC97 interface
6 */
7
8#ifndef _AC97_H_
9#define _AC97_H_
10#include "sound_config.h"
11#include "sound_calls.h"
12
13#define AC97_RESET 0x0000 //
14#define AC97_MASTER_VOL_STEREO 0x0002 // Line Out
15#define AC97_HEADPHONE_VOL 0x0004 //
16#define AC97_MASTER_VOL_MONO 0x0006 // TAD Output
17#define AC97_MASTER_TONE 0x0008 //
18#define AC97_PCBEEP_VOL 0x000a // none
19#define AC97_PHONE_VOL 0x000c // TAD Input (mono)
20#define AC97_MIC_VOL 0x000e // MIC Input (mono)
21#define AC97_LINEIN_VOL 0x0010 // Line Input (stereo)
22#define AC97_CD_VOL 0x0012 // CD Input (stereo)
23#define AC97_VIDEO_VOL 0x0014 // none
24#define AC97_AUX_VOL 0x0016 // Aux Input (stereo)
25#define AC97_PCMOUT_VOL 0x0018 // Wave Output (stereo)
26#define AC97_RECORD_SELECT 0x001a //
27#define AC97_RECORD_GAIN 0x001c
28#define AC97_RECORD_GAIN_MIC 0x001e
29#define AC97_GENERAL_PURPOSE 0x0020
30#define AC97_3D_CONTROL 0x0022
31#define AC97_MODEM_RATE 0x0024
32#define AC97_POWER_CONTROL 0x0026
33
34/* registers 0x0028 - 0x0058 are reserved */
35
36/* AC'97 2.0 */
37#define AC97_EXTENDED_ID 0x0028 /* Extended Audio ID */
38#define AC97_EXTENDED_STATUS 0x002A /* Extended Audio Status */
39#define AC97_PCM_FRONT_DAC_RATE 0x002C /* PCM Front DAC Rate */
40#define AC97_PCM_SURR_DAC_RATE 0x002E /* PCM Surround DAC Rate */
41#define AC97_PCM_LFE_DAC_RATE 0x0030 /* PCM LFE DAC Rate */
42#define AC97_PCM_LR_ADC_RATE 0x0032 /* PCM LR DAC Rate */
43#define AC97_PCM_MIC_ADC_RATE 0x0034 /* PCM MIC ADC Rate */
44#define AC97_CENTER_LFE_MASTER 0x0036 /* Center + LFE Master Volume */
45#define AC97_SURROUND_MASTER 0x0038 /* Surround (Rear) Master Volume */
46#define AC97_RESERVED_3A 0x003A /* Reserved */
47/* range 0x3c-0x58 - MODEM */
48
49/* registers 0x005a - 0x007a are vendor reserved */
50
51#define AC97_VENDOR_ID1 0x007c
52#define AC97_VENDOR_ID2 0x007e
53
54/* volume control bit defines */
55
56#define AC97_MUTE 0x8000
57#define AC97_MICBOOST 0x0040
58#define AC97_LEFTVOL 0x3f00
59#define AC97_RIGHTVOL 0x003f
60
61/* record mux defines */
62
63#define AC97_RECMUX_MIC 0x0000
64#define AC97_RECMUX_CD 0x0101
65#define AC97_RECMUX_VIDEO 0x0202 /* not used */
66#define AC97_RECMUX_AUX 0x0303
67#define AC97_RECMUX_LINE 0x0404
68#define AC97_RECMUX_STEREO_MIX 0x0505
69#define AC97_RECMUX_MONO_MIX 0x0606
70#define AC97_RECMUX_PHONE 0x0707
71
72
73/* general purpose register bit defines */
74
75#define AC97_GP_LPBK 0x0080 /* Loopback mode */
76#define AC97_GP_MS 0x0100 /* Mic Select 0=Mic1, 1=Mic2 */
77#define AC97_GP_MIX 0x0200 /* Mono output select 0=Mix, 1=Mic */
78#define AC97_GP_RLBK 0x0400 /* Remote Loopback - Modem line codec */
79#define AC97_GP_LLBK 0x0800 /* Local Loopback - Modem Line codec */
80#define AC97_GP_LD 0x1000 /* Loudness 1=on */
81#define AC97_GP_3D 0x2000 /* 3D Enhancement 1=on */
82#define AC97_GP_ST 0x4000 /* Stereo Enhancement 1=on */
83#define AC97_GP_POP 0x8000 /* Pcm Out Path, 0=pre 3D, 1=post 3D */
84
85
86/* powerdown control and status bit defines */
87
88/* status */
89#define AC97_PWR_MDM 0x0010 /* Modem section ready */
90#define AC97_PWR_REF 0x0008 /* Vref nominal */
91#define AC97_PWR_ANL 0x0004 /* Analog section ready */
92#define AC97_PWR_DAC 0x0002 /* DAC section ready */
93#define AC97_PWR_ADC 0x0001 /* ADC section ready */
94
95/* control */
96#define AC97_PWR_PR0 0x0100 /* ADC and Mux powerdown */
97#define AC97_PWR_PR1 0x0200 /* DAC powerdown */
98#define AC97_PWR_PR2 0x0400 /* Output mixer powerdown (Vref on) */
99#define AC97_PWR_PR3 0x0800 /* Output mixer powerdown (Vref off) */
100#define AC97_PWR_PR4 0x1000 /* AC-link powerdown */
101#define AC97_PWR_PR5 0x2000 /* Internal Clk disable */
102#define AC97_PWR_PR6 0x4000 /* HP amp powerdown */
103#define AC97_PWR_PR7 0x8000 /* Modem off - if supported */
104
105/* useful power states */
106#define AC97_PWR_D0 0x0000 /* everything on */
107#define AC97_PWR_D1 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
108#define AC97_PWR_D2 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
109#define AC97_PWR_D3 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
110#define AC97_PWR_ANLOFF AC97_PWR_PR2|AC97_PWR_PR3 /* analog section off */
111
112/* Total number of defined registers. */
113#define AC97_REG_CNT 64
114
115/* Generic AC97 mixer interface. */
116
117/* Structure describing access to the hardware. */
118struct ac97_hwint
119{
120 /* Perform any hardware-specific reset and initialization. Returns
121 0 on success, or a negative error code. */
122 int (*reset_device) (struct ac97_hwint *dev);
123
124 /* Returns the contents of the specified register REG. The caller
125 should check to see if the desired contents are available in
126 the cache first, if applicable. Returns a positive unsigned value
127 representing the contents of the register, or a negative error
128 code. */
129 int (*read_reg) (struct ac97_hwint *dev, u8 reg);
130
131 /* Writes VALUE to register REG. Returns 0 on success, or a
132 negative error code. */
133 int (*write_reg) (struct ac97_hwint *dev, u8 reg, u16 value);
134
135 /* Hardware-specific information. */
136 void *driver_private;
137
138 /* Three OSS masks. */
139 int mixer_devmask;
140 int mixer_stereomask;
141 int mixer_recmask;
142
143 /* The mixer cache. The indices correspond to the AC97 hardware register
144 number / 2, since the register numbers are always an even number.
145
146 Unknown values are set to -1; unsupported registers contain a
147 -2. */
148 int last_written_mixer_values[AC97_REG_CNT];
149
150 /* A cache of values written via OSS; we need these so we can return
151 the values originally written by the user.
152
153 Why the original user values? Because the real-world hardware
154 has less precision, and some existing applications assume that
155 they will get back the exact value that they wrote (aumix).
156
157 A -1 value indicates that no value has been written to this mixer
158 channel via OSS. */
159 int last_written_OSS_values[SOUND_MIXER_NRDEVICES];
160};
161
162/* Values stored in the register cache. */
163#define AC97_REGVAL_UNKNOWN -1
164#define AC97_REG_UNSUPPORTED -2
165
166struct ac97_mixer_value_list
167{
168 /* Mixer channel to set. List is terminated by a value of -1. */
169 int oss_channel;
170 /* The scaled value to set it to; values generally range from 0-100. */
171 union {
172 struct {
173 u8 left, right;
174 } stereo;
175 u8 mono;
176 } value;
177};
178
179/* Initialize the ac97 mixer by resetting it. */
180extern int ac97_init (struct ac97_hwint *dev);
181
182/* Sets the mixer DEV to the values in VALUE_LIST. Returns 0 on success,
183 or a negative error code. */
184extern int ac97_set_values (struct ac97_hwint *dev,
185 struct ac97_mixer_value_list *value_list);
186
187/* Writes the specified VALUE to the AC97 register REG in the mixer.
188 Takes care of setting the last-written cache as well. */
189extern int ac97_put_register (struct ac97_hwint *dev, u8 reg, u16 value);
190
191/* Default ioctl. */
192extern int ac97_mixer_ioctl (struct ac97_hwint *dev, unsigned int cmd,
193 void __user * arg);
194
195#endif
196
197/*
198 * Local variables:
199 * c-basic-offset: 4
200 * End:
201 */
diff --git a/sound/oss/aci.c b/sound/oss/aci.c
deleted file mode 100644
index 3bfac375dbd..00000000000
--- a/sound/oss/aci.c
+++ /dev/null
@@ -1,712 +0,0 @@
1/*
2 * Audio Command Interface (ACI) driver (sound/aci.c)
3 *
4 * ACI is a protocol used to communicate with the microcontroller on
5 * some sound cards produced by miro, e.g. the miroSOUND PCM12 and
6 * PCM20. The ACI has been developed for miro by Norberto Pellicci
7 * <pellicci@home.com>. Special thanks to both him and miro for
8 * providing the ACI specification.
9 *
10 * The main function of the ACI is to control the mixer and to get a
11 * product identification. On the PCM20, ACI also controls the radio
12 * tuner on this card, this is supported in the Video for Linux
13 * miropcm20 driver.
14 * -
15 * This is a fullfeatured implementation. Unsupported features
16 * are bugs... (:
17 *
18 * It is not longer necessary to load the mad16 module first. The
19 * user is currently responsible to set the mad16 mixer correctly.
20 *
21 * To toggle the solo mode for full duplex operation just use the OSS
22 * record switch for the pcm ('wave') controller. Robert
23 * -
24 *
25 * Revision history:
26 *
27 * 1995-11-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
28 * First version written.
29 * 1995-12-31 Markus Kuhn
30 * Second revision, general code cleanup.
31 * 1996-05-16 Hannu Savolainen
32 * Integrated with other parts of the driver.
33 * 1996-05-28 Markus Kuhn
34 * Initialize CS4231A mixer, make ACI first mixer,
35 * use new private mixer API for solo mode.
36 * 1998-08-18 Ruurd Reitsma <R.A.Reitsma@wbmt.tudelft.nl>
37 * Small modification to export ACI functions and
38 * complete modularisation.
39 * 2000-06-20 Robert Siemer <Robert.Siemer@gmx.de>
40 * Don't initialize the CS4231A mixer anymore, so the code is
41 * working again, and other small changes to fit in todays
42 * kernels.
43 * 2000-08-26 Robert Siemer
44 * Clean up and rewrite for 2.4.x. Maybe it's SMP safe now... (:
45 * ioctl bugfix, and integration of solo-mode into OSS-API,
46 * added (OSS-limited) equalizer support, return value bugfix,
47 * changed param aci_reset to reset, new params: ide, wss.
48 * 2001-04-20 Robert Siemer
49 * even more cleanups...
50 * 2001-10-08 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
51 * Get rid of check_region, .bss optimizations, use set_current_state
52 */
53
54#include <linux/kernel.h>
55#include <linux/init.h>
56#include <linux/module.h>
57#include <linux/proc_fs.h>
58#include <linux/slab.h>
59#include <linux/mutex.h>
60
61#include <asm/io.h>
62#include <asm/uaccess.h>
63#include "sound_config.h"
64
65int aci_port; /* as determined by bit 4 in the OPTi 929 MC4 register */
66static int aci_idcode[2]; /* manufacturer and product ID */
67int aci_version; /* ACI firmware version */
68
69EXPORT_SYMBOL(aci_port);
70EXPORT_SYMBOL(aci_version);
71
72#include "aci.h"
73
74
75static int aci_solo; /* status bit of the card that can't be *
76 * checked with ACI versions prior to 0xb0 */
77static int aci_amp; /* status bit for power-amp/line-out level
78 but I have no docs about what is what... */
79static int aci_micpreamp=3; /* microphone preamp-level that can't be *
80 * checked with ACI versions prior to 0xb0 */
81
82static int mixer_device;
83static struct mutex aci_mutex;
84
85#ifdef MODULE
86static int reset;
87module_param(reset, bool, 0);
88MODULE_PARM_DESC(reset,"When set to 1, reset aci mixer.");
89#else
90static int reset = 1;
91#endif
92
93static int ide=-1;
94module_param(ide, int, 0);
95MODULE_PARM_DESC(ide,"1 enable, 0 disable ide-port - untested"
96 " default: do nothing");
97static int wss=-1;
98module_param(wss, int, 0);
99MODULE_PARM_DESC(wss,"change between ACI/WSS-mixer; use 0 and 1 - untested"
100 " default: do nothing; for PCM1-pro only");
101
102#ifdef DEBUG
103static void print_bits(unsigned char c)
104{
105 int j;
106 printk(KERN_DEBUG "aci: ");
107
108 for (j=7; j>=0; j--) {
109 printk("%d", (c >> j) & 0x1);
110 }
111
112 printk("\n");
113}
114#endif
115
116/*
117 * This busy wait code normally requires less than 15 loops and
118 * practically always less than 100 loops on my i486/DX2 66 MHz.
119 *
120 * Warning: Waiting on the general status flag after reseting the MUTE
121 * function can take a VERY long time, because the PCM12 does some kind
122 * of fade-in effect. For this reason, access to the MUTE function has
123 * not been implemented at all.
124 *
125 * - The OSS interface has no mute option. It takes about 3 seconds to
126 * fade-in on my PCM20. busy_wait() handles it great now... Robert
127 */
128
129static int busy_wait(void)
130{
131 #define MINTIME 500
132 long timeout;
133 unsigned char byte;
134
135 for (timeout = 1; timeout <= MINTIME+30; timeout++) {
136 if (((byte=inb(BUSY_REGISTER)) & 1) == 0) {
137 if (timeout >= MINTIME)
138 printk(KERN_DEBUG "aci: Got READYFLAG in round %ld.\n", timeout-MINTIME);
139 return byte;
140 }
141 if (timeout >= MINTIME) {
142 long out=10*HZ;
143 switch (timeout-MINTIME) {
144 case 0 ... 9:
145 out /= 10;
146 case 10 ... 19:
147 out /= 10;
148 case 20 ... 30:
149 out /= 10;
150 default:
151 set_current_state(TASK_UNINTERRUPTIBLE);
152 schedule_timeout(out);
153 break;
154 }
155 }
156 }
157 printk(KERN_WARNING "aci: busy_wait() time out.\n");
158 return -EBUSY;
159}
160
161/* The four ACI command types are fucked up. [-:
162 * implied is: 1w - special case for INIT
163 * write is: 2w1r
164 * read is: x(1w1r) where x is 1 or 2 (1 CHECK_SIG, 1 CHECK_STER,
165 * 1 VERSION, 2 IDCODE)
166 * the command is only in the first write, rest is protocol overhead
167 *
168 * indexed is technically a write and used for STATUS
169 * and the special case for TUNE is: 3w1r
170 *
171 * Here the new general sheme: TUNE --> aci_rw_cmd(x, y, z)
172 * indexed and write --> aci_rw_cmd(x, y, -1)
173 * implied and read (x=1) --> aci_rw_cmd(x, -1, -1)
174 *
175 * Read (x>=2) is not implemented (only used during initialization).
176 * Use aci_idcode[2] and aci_version... Robert
177 */
178
179/* Some notes for error detection: theoretically it is possible.
180 * But it doubles the I/O-traffic from ww(r) to wwwrw(r) in the normal
181 * case and doesn't seem to be designed for that... Robert
182 */
183
184static inline int aci_rawwrite(unsigned char byte)
185{
186 if (busy_wait() >= 0) {
187#ifdef DEBUG
188 printk(KERN_DEBUG "aci_rawwrite(%d)\n", byte);
189#endif
190 outb(byte, COMMAND_REGISTER);
191 return 0;
192 } else
193 return -EBUSY;
194}
195
196static inline int aci_rawread(void)
197{
198 unsigned char byte;
199
200 if (busy_wait() >= 0) {
201 byte=inb(STATUS_REGISTER);
202#ifdef DEBUG
203 printk(KERN_DEBUG "%d = aci_rawread()\n", byte);
204#endif
205 return byte;
206 } else
207 return -EBUSY;
208}
209
210
211int aci_rw_cmd(int write1, int write2, int write3)
212{
213 int write[] = {write1, write2, write3};
214 int read = -EINTR, i;
215
216 if (mutex_lock_interruptible(&aci_mutex))
217 goto out;
218
219 for (i=0; i<3; i++) {
220 if (write[i]< 0 || write[i] > 255)
221 break;
222 else {
223 read = aci_rawwrite(write[i]);
224 if (read < 0)
225 goto out_up;
226 }
227
228 }
229
230 read = aci_rawread();
231out_up: mutex_unlock(&aci_mutex);
232out: return read;
233}
234
235EXPORT_SYMBOL(aci_rw_cmd);
236
237static int setvolume(int __user *arg,
238 unsigned char left_index, unsigned char right_index)
239{
240 int vol, ret, uservol, buf;
241
242 __get_user(uservol, arg);
243
244 /* left channel */
245 vol = uservol & 0xff;
246 if (vol > 100)
247 vol = 100;
248 vol = SCALE(100, 0x20, vol);
249 if ((buf=aci_write_cmd(left_index, 0x20 - vol))<0)
250 return buf;
251 ret = SCALE(0x20, 100, vol);
252
253
254 /* right channel */
255 vol = (uservol >> 8) & 0xff;
256 if (vol > 100)
257 vol = 100;
258 vol = SCALE(100, 0x20, vol);
259 if ((buf=aci_write_cmd(right_index, 0x20 - vol))<0)
260 return buf;
261 ret |= SCALE(0x20, 100, vol) << 8;
262
263 __put_user(ret, arg);
264
265 return 0;
266}
267
268static int getvolume(int __user *arg,
269 unsigned char left_index, unsigned char right_index)
270{
271 int vol;
272 int buf;
273
274 /* left channel */
275 if ((buf=aci_indexed_cmd(ACI_STATUS, left_index))<0)
276 return buf;
277 vol = SCALE(0x20, 100, buf < 0x20 ? 0x20-buf : 0);
278
279 /* right channel */
280 if ((buf=aci_indexed_cmd(ACI_STATUS, right_index))<0)
281 return buf;
282 vol |= SCALE(0x20, 100, buf < 0x20 ? 0x20-buf : 0) << 8;
283
284 __put_user(vol, arg);
285
286 return 0;
287}
288
289
290/* The equalizer is somewhat strange on the ACI. From -12dB to +12dB
291 * write: 0xff..down.to..0x80==0x00..up.to..0x7f
292 */
293
294static inline unsigned int eq_oss2aci(unsigned int vol)
295{
296 int boost=0;
297 unsigned int ret;
298
299 if (vol > 100)
300 vol = 100;
301 if (vol > 50) {
302 vol -= 51;
303 boost=1;
304 }
305 if (boost)
306 ret=SCALE(49, 0x7e, vol)+1;
307 else
308 ret=0xff - SCALE(50, 0x7f, vol);
309 return ret;
310}
311
312static inline unsigned int eq_aci2oss(unsigned int vol)
313{
314 if (vol < 0x80)
315 return SCALE(0x7f, 50, vol) + 50;
316 else
317 return SCALE(0x7f, 50, 0xff-vol);
318}
319
320
321static int setequalizer(int __user *arg,
322 unsigned char left_index, unsigned char right_index)
323{
324 int buf;
325 unsigned int vol;
326
327 __get_user(vol, arg);
328
329 /* left channel */
330 if ((buf=aci_write_cmd(left_index, eq_oss2aci(vol & 0xff)))<0)
331 return buf;
332
333 /* right channel */
334 if ((buf=aci_write_cmd(right_index, eq_oss2aci((vol>>8) & 0xff)))<0)
335 return buf;
336
337 /* the ACI equalizer is more precise */
338 return 0;
339}
340
341static int getequalizer(int __user *arg,
342 unsigned char left_index, unsigned char right_index)
343{
344 int buf;
345 unsigned int vol;
346
347 /* left channel */
348 if ((buf=aci_indexed_cmd(ACI_STATUS, left_index))<0)
349 return buf;
350 vol = eq_aci2oss(buf);
351
352 /* right channel */
353 if ((buf=aci_indexed_cmd(ACI_STATUS, right_index))<0)
354 return buf;
355 vol |= eq_aci2oss(buf) << 8;
356
357 __put_user(vol, arg);
358
359 return 0;
360}
361
362static int aci_mixer_ioctl (int dev, unsigned int cmd, void __user * arg)
363{
364 int vol, buf;
365 int __user *p = arg;
366
367 switch (cmd) {
368 case SOUND_MIXER_WRITE_VOLUME:
369 return setvolume(p, 0x01, 0x00);
370 case SOUND_MIXER_WRITE_CD:
371 return setvolume(p, 0x3c, 0x34);
372 case SOUND_MIXER_WRITE_MIC:
373 return setvolume(p, 0x38, 0x30);
374 case SOUND_MIXER_WRITE_LINE:
375 return setvolume(p, 0x39, 0x31);
376 case SOUND_MIXER_WRITE_SYNTH:
377 return setvolume(p, 0x3b, 0x33);
378 case SOUND_MIXER_WRITE_PCM:
379 return setvolume(p, 0x3a, 0x32);
380 case MIXER_WRITE(SOUND_MIXER_RADIO): /* fall through */
381 case SOUND_MIXER_WRITE_LINE1: /* AUX1 or radio */
382 return setvolume(p, 0x3d, 0x35);
383 case SOUND_MIXER_WRITE_LINE2: /* AUX2 */
384 return setvolume(p, 0x3e, 0x36);
385 case SOUND_MIXER_WRITE_BASS: /* set band one and two */
386 if (aci_idcode[1]=='C') {
387 if ((buf=setequalizer(p, 0x48, 0x40)) ||
388 (buf=setequalizer(p, 0x49, 0x41)));
389 return buf;
390 }
391 break;
392 case SOUND_MIXER_WRITE_TREBLE: /* set band six and seven */
393 if (aci_idcode[1]=='C') {
394 if ((buf=setequalizer(p, 0x4d, 0x45)) ||
395 (buf=setequalizer(p, 0x4e, 0x46)));
396 return buf;
397 }
398 break;
399 case SOUND_MIXER_WRITE_IGAIN: /* MIC pre-amp */
400 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
401 __get_user(vol, p);
402 vol = vol & 0xff;
403 if (vol > 100)
404 vol = 100;
405 vol = SCALE(100, 3, vol);
406 if ((buf=aci_write_cmd(ACI_WRITE_IGAIN, vol))<0)
407 return buf;
408 aci_micpreamp = vol;
409 vol = SCALE(3, 100, vol);
410 vol |= (vol << 8);
411 __put_user(vol, p);
412 return 0;
413 }
414 break;
415 case SOUND_MIXER_WRITE_OGAIN: /* Power-amp/line-out level */
416 if (aci_idcode[1]=='A' || aci_idcode[1]=='B') {
417 __get_user(buf, p);
418 buf = buf & 0xff;
419 if (buf > 50)
420 vol = 1;
421 else
422 vol = 0;
423 if ((buf=aci_write_cmd(ACI_SET_POWERAMP, vol))<0)
424 return buf;
425 aci_amp = vol;
426 if (aci_amp)
427 buf = (100 || 100<<8);
428 else
429 buf = 0;
430 __put_user(buf, p);
431 return 0;
432 }
433 break;
434 case SOUND_MIXER_WRITE_RECSRC:
435 /* handle solo mode control */
436 __get_user(buf, p);
437 /* unset solo when RECSRC for PCM is requested */
438 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
439 vol = !(buf & SOUND_MASK_PCM);
440 if ((buf=aci_write_cmd(ACI_SET_SOLOMODE, vol))<0)
441 return buf;
442 aci_solo = vol;
443 }
444 buf = (SOUND_MASK_CD| SOUND_MASK_MIC| SOUND_MASK_LINE|
445 SOUND_MASK_SYNTH| SOUND_MASK_LINE2);
446 if (aci_idcode[1] == 'C') /* PCM20 radio */
447 buf |= SOUND_MASK_RADIO;
448 else
449 buf |= SOUND_MASK_LINE1;
450 if (!aci_solo)
451 buf |= SOUND_MASK_PCM;
452 __put_user(buf, p);
453 return 0;
454 case SOUND_MIXER_READ_DEVMASK:
455 buf = (SOUND_MASK_VOLUME | SOUND_MASK_CD |
456 SOUND_MASK_MIC | SOUND_MASK_LINE |
457 SOUND_MASK_SYNTH | SOUND_MASK_PCM |
458 SOUND_MASK_LINE2);
459 switch (aci_idcode[1]) {
460 case 'C': /* PCM20 radio */
461 buf |= (SOUND_MASK_RADIO | SOUND_MASK_IGAIN |
462 SOUND_MASK_BASS | SOUND_MASK_TREBLE);
463 break;
464 case 'B': /* PCM12 */
465 buf |= (SOUND_MASK_LINE1 | SOUND_MASK_IGAIN |
466 SOUND_MASK_OGAIN);
467 break;
468 case 'A': /* PCM1-pro */
469 buf |= (SOUND_MASK_LINE1 | SOUND_MASK_OGAIN);
470 break;
471 default:
472 buf |= SOUND_MASK_LINE1;
473 }
474 __put_user(buf, p);
475 return 0;
476 case SOUND_MIXER_READ_STEREODEVS:
477 buf = (SOUND_MASK_VOLUME | SOUND_MASK_CD |
478 SOUND_MASK_MIC | SOUND_MASK_LINE |
479 SOUND_MASK_SYNTH | SOUND_MASK_PCM |
480 SOUND_MASK_LINE2);
481 switch (aci_idcode[1]) {
482 case 'C': /* PCM20 radio */
483 buf |= (SOUND_MASK_RADIO |
484 SOUND_MASK_BASS | SOUND_MASK_TREBLE);
485 break;
486 default:
487 buf |= SOUND_MASK_LINE1;
488 }
489 __put_user(buf, p);
490 return 0;
491 case SOUND_MIXER_READ_RECMASK:
492 buf = (SOUND_MASK_CD| SOUND_MASK_MIC| SOUND_MASK_LINE|
493 SOUND_MASK_SYNTH| SOUND_MASK_LINE2| SOUND_MASK_PCM);
494 if (aci_idcode[1] == 'C') /* PCM20 radio */
495 buf |= SOUND_MASK_RADIO;
496 else
497 buf |= SOUND_MASK_LINE1;
498
499 __put_user(buf, p);
500 return 0;
501 case SOUND_MIXER_READ_RECSRC:
502 buf = (SOUND_MASK_CD | SOUND_MASK_MIC | SOUND_MASK_LINE |
503 SOUND_MASK_SYNTH | SOUND_MASK_LINE2);
504 /* do we need aci_solo or can I get it from the ACI? */
505 switch (aci_idcode[1]) {
506 case 'B': /* PCM12 */
507 case 'C': /* PCM20 radio */
508 if (aci_version >= 0xb0) {
509 if ((vol=aci_rw_cmd(ACI_STATUS,
510 ACI_S_GENERAL, -1))<0)
511 return vol;
512 if (vol & 0x20)
513 buf |= SOUND_MASK_PCM;
514 }
515 else
516 if (!aci_solo)
517 buf |= SOUND_MASK_PCM;
518 break;
519 default:
520 buf |= SOUND_MASK_PCM;
521 }
522 if (aci_idcode[1] == 'C') /* PCM20 radio */
523 buf |= SOUND_MASK_RADIO;
524 else
525 buf |= SOUND_MASK_LINE1;
526
527 __put_user(buf, p);
528 return 0;
529 case SOUND_MIXER_READ_CAPS:
530 __put_user(0, p);
531 return 0;
532 case SOUND_MIXER_READ_VOLUME:
533 return getvolume(p, 0x04, 0x03);
534 case SOUND_MIXER_READ_CD:
535 return getvolume(p, 0x0a, 0x09);
536 case SOUND_MIXER_READ_MIC:
537 return getvolume(p, 0x06, 0x05);
538 case SOUND_MIXER_READ_LINE:
539 return getvolume(p, 0x08, 0x07);
540 case SOUND_MIXER_READ_SYNTH:
541 return getvolume(p, 0x0c, 0x0b);
542 case SOUND_MIXER_READ_PCM:
543 return getvolume(p, 0x0e, 0x0d);
544 case MIXER_READ(SOUND_MIXER_RADIO): /* fall through */
545 case SOUND_MIXER_READ_LINE1: /* AUX1 */
546 return getvolume(p, 0x11, 0x10);
547 case SOUND_MIXER_READ_LINE2: /* AUX2 */
548 return getvolume(p, 0x13, 0x12);
549 case SOUND_MIXER_READ_BASS: /* get band one */
550 if (aci_idcode[1]=='C') {
551 return getequalizer(p, 0x23, 0x22);
552 }
553 break;
554 case SOUND_MIXER_READ_TREBLE: /* get band seven */
555 if (aci_idcode[1]=='C') {
556 return getequalizer(p, 0x2f, 0x2e);
557 }
558 break;
559 case SOUND_MIXER_READ_IGAIN: /* MIC pre-amp */
560 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
561 /* aci_micpreamp or ACI? */
562 if (aci_version >= 0xb0) {
563 if ((buf=aci_indexed_cmd(ACI_STATUS,
564 ACI_S_READ_IGAIN))<0)
565 return buf;
566 }
567 else
568 buf=aci_micpreamp;
569 vol = SCALE(3, 100, buf <= 3 ? buf : 3);
570 vol |= vol << 8;
571 __put_user(vol, p);
572 return 0;
573 }
574 break;
575 case SOUND_MIXER_READ_OGAIN:
576 if (aci_amp)
577 buf = (100 || 100<<8);
578 else
579 buf = 0;
580 __put_user(buf, p);
581 return 0;
582 }
583 return -EINVAL;
584}
585
586static struct mixer_operations aci_mixer_operations =
587{
588 .owner = THIS_MODULE,
589 .id = "ACI",
590 .ioctl = aci_mixer_ioctl
591};
592
593/*
594 * There is also an internal mixer in the codec (CS4231A or AD1845),
595 * that deserves no purpose in an ACI based system which uses an
596 * external ACI controlled stereo mixer. Make sure that this codec
597 * mixer has the AUX1 input selected as the recording source, that the
598 * input gain is set near maximum and that the other channels going
599 * from the inputs to the codec output are muted.
600 */
601
602static int __init attach_aci(void)
603{
604 char *boardname;
605 int i, rc = -EBUSY;
606
607 mutex_init(&aci_mutex);
608
609 outb(0xE3, 0xf8f); /* Write MAD16 password */
610 aci_port = (inb(0xf90) & 0x10) ?
611 0x344: 0x354; /* Get aci_port from MC4_PORT */
612
613 if (!request_region(aci_port, 3, "sound mixer (ACI)")) {
614 printk(KERN_NOTICE
615 "aci: I/O area 0x%03x-0x%03x already used.\n",
616 aci_port, aci_port+2);
617 goto out;
618 }
619
620 /* force ACI into a known state */
621 rc = -EFAULT;
622 for (i=0; i<3; i++)
623 if (aci_rw_cmd(ACI_ERROR_OP, -1, -1)<0)
624 goto out_release_region;
625
626 /* official this is one aci read call: */
627 rc = -EFAULT;
628 if ((aci_idcode[0]=aci_rw_cmd(ACI_READ_IDCODE, -1, -1))<0 ||
629 (aci_idcode[1]=aci_rw_cmd(ACI_READ_IDCODE, -1, -1))<0) {
630 printk(KERN_ERR "aci: Failed to read idcode on 0x%03x.\n",
631 aci_port);
632 goto out_release_region;
633 }
634
635 if ((aci_version=aci_rw_cmd(ACI_READ_VERSION, -1, -1))<0) {
636 printk(KERN_ERR "aci: Failed to read version on 0x%03x.\n",
637 aci_port);
638 goto out_release_region;
639 }
640
641 if (aci_idcode[0] == 'm') {
642 /* It looks like a miro sound card. */
643 switch (aci_idcode[1]) {
644 case 'A':
645 boardname = "PCM1 pro / early PCM12";
646 break;
647 case 'B':
648 boardname = "PCM12";
649 break;
650 case 'C':
651 boardname = "PCM20 radio";
652 break;
653 default:
654 boardname = "unknown miro";
655 }
656 } else {
657 printk(KERN_WARNING "aci: Warning: unsupported card! - "
658 "no hardware, no specs...\n");
659 boardname = "unknown Cardinal Technologies";
660 }
661
662 printk(KERN_INFO "<ACI 0x%02x, id %02x/%02x \"%c/%c\", (%s)> at 0x%03x\n",
663 aci_version,
664 aci_idcode[0], aci_idcode[1],
665 aci_idcode[0], aci_idcode[1],
666 boardname, aci_port);
667
668 rc = -EBUSY;
669 if (reset) {
670 /* first write()s after reset fail with my PCM20 */
671 if (aci_rw_cmd(ACI_INIT, -1, -1)<0 ||
672 aci_rw_cmd(ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP)<0 ||
673 aci_rw_cmd(ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP)<0)
674 goto out_release_region;
675 }
676
677 /* the PCM20 is muted after reset (and reboot) */
678 if (aci_rw_cmd(ACI_SET_MUTE, 0x00, -1)<0)
679 goto out_release_region;
680
681 if (ide>=0)
682 if (aci_rw_cmd(ACI_SET_IDE, !ide, -1)<0)
683 goto out_release_region;
684
685 if (wss>=0 && aci_idcode[1]=='A')
686 if (aci_rw_cmd(ACI_SET_WSS, !!wss, -1)<0)
687 goto out_release_region;
688
689 mixer_device = sound_install_mixer(MIXER_DRIVER_VERSION, boardname,
690 &aci_mixer_operations,
691 sizeof(aci_mixer_operations), NULL);
692 rc = 0;
693 if (mixer_device < 0) {
694 printk(KERN_ERR "aci: Failed to install mixer.\n");
695 rc = mixer_device;
696 goto out_release_region;
697 } /* else Maybe initialize the CS4231A mixer here... */
698out: return rc;
699out_release_region:
700 release_region(aci_port, 3);
701 goto out;
702}
703
704static void __exit unload_aci(void)
705{
706 sound_unload_mixerdev(mixer_device);
707 release_region(aci_port, 3);
708}
709
710module_init(attach_aci);
711module_exit(unload_aci);
712MODULE_LICENSE("GPL");
diff --git a/sound/oss/aci.h b/sound/oss/aci.h
deleted file mode 100644
index 20102ee088e..00000000000
--- a/sound/oss/aci.h
+++ /dev/null
@@ -1,57 +0,0 @@
1#ifndef _ACI_H_
2#define _ACI_H_
3
4extern int aci_port;
5extern int aci_version; /* ACI firmware version */
6extern int aci_rw_cmd(int write1, int write2, int write3);
7
8#define aci_indexed_cmd(a, b) aci_rw_cmd(a, b, -1)
9#define aci_write_cmd(a, b) aci_rw_cmd(a, b, -1)
10#define aci_read_cmd(a) aci_rw_cmd(a,-1, -1)
11
12#define COMMAND_REGISTER (aci_port) /* write register */
13#define STATUS_REGISTER (aci_port + 1) /* read register */
14#define BUSY_REGISTER (aci_port + 2) /* also used for rds */
15
16#define RDS_REGISTER BUSY_REGISTER
17
18#define ACI_SET_MUTE 0x0d
19#define ACI_SET_POWERAMP 0x0f
20#define ACI_SET_TUNERMUTE 0xa3
21#define ACI_SET_TUNERMONO 0xa4
22#define ACI_SET_IDE 0xd0
23#define ACI_SET_WSS 0xd1
24#define ACI_SET_SOLOMODE 0xd2
25#define ACI_WRITE_IGAIN 0x03
26#define ACI_WRITE_TUNE 0xa7
27#define ACI_READ_TUNERSTEREO 0xa8
28#define ACI_READ_TUNERSTATION 0xa9
29#define ACI_READ_VERSION 0xf1
30#define ACI_READ_IDCODE 0xf2
31#define ACI_INIT 0xff
32#define ACI_STATUS 0xf0
33#define ACI_S_GENERAL 0x00
34#define ACI_S_READ_IGAIN 0x21
35#define ACI_ERROR_OP 0xdf
36
37/*
38 * The following macro SCALE can be used to scale one integer volume
39 * value into another one using only integer arithmetic. If the input
40 * value x is in the range 0 <= x <= xmax, then the result will be in
41 * the range 0 <= SCALE(xmax,ymax,x) <= ymax.
42 *
43 * This macro has for all xmax, ymax > 0 and all 0 <= x <= xmax the
44 * following nice properties:
45 *
46 * - SCALE(xmax,ymax,xmax) = ymax
47 * - SCALE(xmax,ymax,0) = 0
48 * - SCALE(xmax,ymax,SCALE(ymax,xmax,SCALE(xmax,ymax,x))) = SCALE(xmax,ymax,x)
49 *
50 * In addition, the rounding error is minimal and nicely distributed.
51 * The proofs are left as an exercise to the reader.
52 */
53
54#define SCALE(xmax,ymax,x) (((x)*(ymax)+(xmax)/2)/(xmax))
55
56
57#endif /* _ACI_H_ */
diff --git a/sound/oss/ad1816.c b/sound/oss/ad1816.c
deleted file mode 100644
index caabf31193f..00000000000
--- a/sound/oss/ad1816.c
+++ /dev/null
@@ -1,1368 +0,0 @@
1/*
2 *
3 * AD1816 lowlevel sound driver for Linux 2.6.0 and above
4 *
5 * Copyright (C) 1998-2003 by Thorsten Knabe <linux@thorsten-knabe.de>
6 *
7 * Based on the CS4232/AD1848 driver Copyright (C) by Hannu Savolainen 1993-1996
8 *
9 *
10 * version: 1.5
11 * status: beta
12 * date: 2003/07/15
13 *
14 * Changes:
15 * Oleg Drokin: Some cleanup of load/unload functions. 1998/11/24
16 *
17 * Thorsten Knabe: attach and unload rewritten,
18 * some argument checks added 1998/11/30
19 *
20 * Thorsten Knabe: Buggy isa bridge workaround added 1999/01/16
21 *
22 * David Moews/Thorsten Knabe: Introduced options
23 * parameter. Added slightly modified patch from
24 * David Moews to disable dsp audio sources by setting
25 * bit 0 of options parameter. This seems to be
26 * required by some Aztech/Newcom SC-16 cards. 1999/04/18
27 *
28 * Christoph Hellwig: Adapted to module_init/module_exit. 2000/03/03
29 *
30 * Christoph Hellwig: Added isapnp support 2000/03/15
31 *
32 * Arnaldo Carvalho de Melo: get rid of check_region 2001/10/07
33 *
34 * Thorsten Knabe: Compiling with CONFIG_PNP enabled
35 * works again. It is now possible to use more than one
36 * AD1816 sound card. Sample rate now may be changed during
37 * playback/capture. printk() uses log levels everywhere.
38 * SMP fixes. DMA handling fixes.
39 * Other minor code cleanup. 2003/07/15
40 *
41 */
42
43
44#include <linux/module.h>
45#include <linux/init.h>
46#include <linux/interrupt.h>
47#include <linux/isapnp.h>
48#include <linux/stddef.h>
49#include <linux/spinlock.h>
50#include "sound_config.h"
51
52#define DEBUGNOISE(x)
53
54#define CHECK_FOR_POWER { int timeout=100; \
55 while (timeout > 0 && (inb(devc->base)&0x80)!= 0x80) {\
56 timeout--; \
57 } \
58 if (timeout==0) {\
59 printk(KERN_WARNING "ad1816: Check for power failed in %s line: %d\n",__FILE__,__LINE__); \
60 } \
61}
62
63/* structure to hold device specific information */
64typedef struct
65{
66 int base; /* set in attach */
67 int irq;
68 int dma_playback;
69 int dma_capture;
70
71 int opened; /* open */
72 int speed;
73 int channels;
74 int audio_format;
75 int audio_mode;
76
77 int recmask; /* setup */
78 unsigned char format_bits;
79 int supported_devices;
80 int supported_rec_devices;
81 unsigned short levels[SOUND_MIXER_NRDEVICES];
82 /* misc */
83 struct pnp_dev *pnpdev; /* configured via pnp */
84 int dev_no; /* this is the # in audio_devs and NOT
85 in ad1816_info */
86 spinlock_t lock;
87} ad1816_info;
88
89static int nr_ad1816_devs;
90static int ad1816_clockfreq = 33000;
91static int options;
92
93/* supported audio formats */
94static int ad_format_mask =
95AFMT_U8 | AFMT_S16_LE | AFMT_S16_BE | AFMT_MU_LAW | AFMT_A_LAW;
96
97/* array of device info structures */
98static ad1816_info dev_info[MAX_AUDIO_DEV];
99
100
101/* ------------------------------------------------------------------- */
102
103/* functions for easier access to inderect registers */
104
105static int ad_read (ad1816_info * devc, int reg)
106{
107 int result;
108
109 CHECK_FOR_POWER;
110 outb ((unsigned char) (reg & 0x3f), devc->base+0);
111 result = inb(devc->base+2);
112 result+= inb(devc->base+3)<<8;
113 return (result);
114}
115
116
117static void ad_write (ad1816_info * devc, int reg, int data)
118{
119 CHECK_FOR_POWER;
120 outb ((unsigned char) (reg & 0xff), devc->base+0);
121 outb ((unsigned char) (data & 0xff),devc->base+2);
122 outb ((unsigned char) ((data>>8)&0xff),devc->base+3);
123}
124
125/* ------------------------------------------------------------------- */
126
127/* function interface required by struct audio_driver */
128
129static void ad1816_halt_input (int dev)
130{
131 unsigned long flags;
132 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
133 unsigned char buffer;
134
135 DEBUGNOISE(printk(KERN_DEBUG "ad1816: halt_input called\n"));
136
137 spin_lock_irqsave(&devc->lock,flags);
138
139 if(!isa_dma_bridge_buggy) {
140 disable_dma(audio_devs[dev]->dmap_in->dma);
141 }
142
143 buffer=inb(devc->base+9);
144 if (buffer & 0x01) {
145 /* disable capture */
146 outb(buffer & ~0x01,devc->base+9);
147 }
148
149 if(!isa_dma_bridge_buggy) {
150 enable_dma(audio_devs[dev]->dmap_in->dma);
151 }
152
153 /* Clear interrupt status */
154 outb (~0x40, devc->base+1);
155
156 devc->audio_mode &= ~PCM_ENABLE_INPUT;
157 spin_unlock_irqrestore(&devc->lock,flags);
158}
159
160static void ad1816_halt_output (int dev)
161{
162 unsigned long flags;
163 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
164
165 unsigned char buffer;
166
167 DEBUGNOISE(printk(KERN_DEBUG "ad1816: halt_output called!\n"));
168
169 spin_lock_irqsave(&devc->lock,flags);
170 /* Mute pcm output */
171 ad_write(devc, 4, ad_read(devc,4)|0x8080);
172
173 if(!isa_dma_bridge_buggy) {
174 disable_dma(audio_devs[dev]->dmap_out->dma);
175 }
176
177 buffer=inb(devc->base+8);
178 if (buffer & 0x01) {
179 /* disable capture */
180 outb(buffer & ~0x01,devc->base+8);
181 }
182
183 if(!isa_dma_bridge_buggy) {
184 enable_dma(audio_devs[dev]->dmap_out->dma);
185 }
186
187 /* Clear interrupt status */
188 outb ((unsigned char)~0x80, devc->base+1);
189
190 devc->audio_mode &= ~PCM_ENABLE_OUTPUT;
191 spin_unlock_irqrestore(&devc->lock,flags);
192}
193
194static void ad1816_output_block (int dev, unsigned long buf,
195 int count, int intrflag)
196{
197 unsigned long flags;
198 unsigned long cnt;
199 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
200
201 DEBUGNOISE(printk(KERN_DEBUG "ad1816: output_block called buf=%ld count=%d flags=%d\n",buf,count,intrflag));
202
203 cnt = count/4 - 1;
204
205 spin_lock_irqsave(&devc->lock,flags);
206
207 /* set transfer count */
208 ad_write (devc, 8, cnt & 0xffff);
209
210 devc->audio_mode |= PCM_ENABLE_OUTPUT;
211 spin_unlock_irqrestore(&devc->lock,flags);
212}
213
214
215static void ad1816_start_input (int dev, unsigned long buf, int count,
216 int intrflag)
217{
218 unsigned long flags;
219 unsigned long cnt;
220 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
221
222 DEBUGNOISE(printk(KERN_DEBUG "ad1816: start_input called buf=%ld count=%d flags=%d\n",buf,count,intrflag));
223
224 cnt = count/4 - 1;
225
226 spin_lock_irqsave(&devc->lock,flags);
227
228 /* set transfer count */
229 ad_write (devc, 10, cnt & 0xffff);
230 devc->audio_mode |= PCM_ENABLE_INPUT;
231 spin_unlock_irqrestore(&devc->lock,flags);
232}
233
234static int ad1816_prepare_for_input (int dev, int bsize, int bcount)
235{
236 unsigned long flags;
237 unsigned int freq;
238 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
239 unsigned char fmt_bits;
240
241 DEBUGNOISE(printk(KERN_DEBUG "ad1816: prepare_for_input called: bsize=%d bcount=%d\n",bsize,bcount));
242
243 spin_lock_irqsave(&devc->lock,flags);
244 fmt_bits= (devc->format_bits&0x7)<<3;
245
246 /* set mono/stereo mode */
247 if (devc->channels > 1) {
248 fmt_bits |=0x4;
249 }
250 /* set Mono/Stereo in playback/capture register */
251 outb( (inb(devc->base+8) & ~0x3C)|fmt_bits, devc->base+8);
252 outb( (inb(devc->base+9) & ~0x3C)|fmt_bits, devc->base+9);
253
254 freq=((unsigned int)devc->speed*33000)/ad1816_clockfreq;
255
256 /* write playback/capture speeds */
257 ad_write (devc, 2, freq & 0xffff);
258 ad_write (devc, 3, freq & 0xffff);
259
260 spin_unlock_irqrestore(&devc->lock,flags);
261
262 ad1816_halt_input(dev);
263 return 0;
264}
265
266static int ad1816_prepare_for_output (int dev, int bsize, int bcount)
267{
268 unsigned long flags;
269 unsigned int freq;
270 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
271 unsigned char fmt_bits;
272
273 DEBUGNOISE(printk(KERN_DEBUG "ad1816: prepare_for_output called: bsize=%d bcount=%d\n",bsize,bcount));
274
275 spin_lock_irqsave(&devc->lock,flags);
276
277 fmt_bits= (devc->format_bits&0x7)<<3;
278 /* set mono/stereo mode */
279 if (devc->channels > 1) {
280 fmt_bits |=0x4;
281 }
282
283 /* write format bits to playback/capture registers */
284 outb( (inb(devc->base+8) & ~0x3C)|fmt_bits, devc->base+8);
285 outb( (inb(devc->base+9) & ~0x3C)|fmt_bits, devc->base+9);
286
287 freq=((unsigned int)devc->speed*33000)/ad1816_clockfreq;
288
289 /* write playback/capture speeds */
290 ad_write (devc, 2, freq & 0xffff);
291 ad_write (devc, 3, freq & 0xffff);
292
293 spin_unlock_irqrestore(&devc->lock,flags);
294
295 ad1816_halt_output(dev);
296 return 0;
297
298}
299
300static void ad1816_trigger (int dev, int state)
301{
302 unsigned long flags;
303 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
304
305 DEBUGNOISE(printk(KERN_DEBUG "ad1816: trigger called! (devc=%d,devc->base=%d\n", devc, devc->base));
306
307 /* mode may have changed */
308
309 spin_lock_irqsave(&devc->lock,flags);
310
311 /* mask out modes not specified on open call */
312 state &= devc->audio_mode;
313
314 /* setup soundchip to new io-mode */
315 if (state & PCM_ENABLE_INPUT) {
316 /* enable capture */
317 outb(inb(devc->base+9)|0x01, devc->base+9);
318 } else {
319 /* disable capture */
320 outb(inb(devc->base+9)&~0x01, devc->base+9);
321 }
322
323 if (state & PCM_ENABLE_OUTPUT) {
324 /* enable playback */
325 outb(inb(devc->base+8)|0x01, devc->base+8);
326 /* unmute pcm output */
327 ad_write(devc, 4, ad_read(devc,4)&~0x8080);
328 } else {
329 /* mute pcm output */
330 ad_write(devc, 4, ad_read(devc,4)|0x8080);
331 /* disable capture */
332 outb(inb(devc->base+8)&~0x01, devc->base+8);
333 }
334 spin_unlock_irqrestore(&devc->lock,flags);
335}
336
337
338/* halt input & output */
339static void ad1816_halt (int dev)
340{
341 ad1816_halt_input(dev);
342 ad1816_halt_output(dev);
343}
344
345static void ad1816_reset (int dev)
346{
347 ad1816_halt (dev);
348}
349
350/* set playback speed */
351static int ad1816_set_speed (int dev, int arg)
352{
353 unsigned long flags;
354 unsigned int freq;
355 int ret;
356
357 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
358
359 spin_lock_irqsave(&devc->lock, flags);
360 if (arg == 0) {
361 ret = devc->speed;
362 spin_unlock_irqrestore(&devc->lock, flags);
363 return ret;
364 }
365 /* range checking */
366 if (arg < 4000) {
367 arg = 4000;
368 }
369 if (arg > 55000) {
370 arg = 55000;
371 }
372 devc->speed = arg;
373
374 /* change speed during playback */
375 freq=((unsigned int)devc->speed*33000)/ad1816_clockfreq;
376 /* write playback/capture speeds */
377 ad_write (devc, 2, freq & 0xffff);
378 ad_write (devc, 3, freq & 0xffff);
379
380 ret = devc->speed;
381 spin_unlock_irqrestore(&devc->lock, flags);
382 return ret;
383
384}
385
386static unsigned int ad1816_set_bits (int dev, unsigned int arg)
387{
388 unsigned long flags;
389 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
390
391 static struct format_tbl {
392 int format;
393 unsigned char bits;
394 } format2bits[] = {
395 { 0, 0 },
396 { AFMT_MU_LAW, 1 },
397 { AFMT_A_LAW, 3 },
398 { AFMT_IMA_ADPCM, 0 },
399 { AFMT_U8, 0 },
400 { AFMT_S16_LE, 2 },
401 { AFMT_S16_BE, 6 },
402 { AFMT_S8, 0 },
403 { AFMT_U16_LE, 0 },
404 { AFMT_U16_BE, 0 }
405 };
406
407 int i, n = sizeof (format2bits) / sizeof (struct format_tbl);
408
409 spin_lock_irqsave(&devc->lock, flags);
410 /* return current format */
411 if (arg == 0) {
412 arg = devc->audio_format;
413 spin_unlock_irqrestore(&devc->lock, flags);
414 return arg;
415 }
416 devc->audio_format = arg;
417
418 /* search matching format bits */
419 for (i = 0; i < n; i++)
420 if (format2bits[i].format == arg) {
421 devc->format_bits = format2bits[i].bits;
422 devc->audio_format = arg;
423 spin_unlock_irqrestore(&devc->lock, flags);
424 return arg;
425 }
426
427 /* Still hanging here. Something must be terribly wrong */
428 devc->format_bits = 0;
429 devc->audio_format = AFMT_U8;
430 spin_unlock_irqrestore(&devc->lock, flags);
431 return(AFMT_U8);
432}
433
434static short ad1816_set_channels (int dev, short arg)
435{
436 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
437
438 if (arg != 1 && arg != 2)
439 return devc->channels;
440
441 devc->channels = arg;
442 return arg;
443}
444
445/* open device */
446static int ad1816_open (int dev, int mode)
447{
448 ad1816_info *devc = NULL;
449 unsigned long flags;
450
451 /* is device number valid ? */
452 if (dev < 0 || dev >= num_audiodevs)
453 return -(ENXIO);
454
455 /* get device info of this dev */
456 devc = (ad1816_info *) audio_devs[dev]->devc;
457
458 /* make check if device already open atomic */
459 spin_lock_irqsave(&devc->lock,flags);
460
461 if (devc->opened) {
462 spin_unlock_irqrestore(&devc->lock,flags);
463 return -(EBUSY);
464 }
465
466 /* mark device as open */
467 devc->opened = 1;
468
469 devc->audio_mode = 0;
470 devc->speed = 8000;
471 devc->audio_format=AFMT_U8;
472 devc->channels=1;
473 spin_unlock_irqrestore(&devc->lock,flags);
474 ad1816_reset(devc->dev_no); /* halt all pending output */
475 return 0;
476}
477
478static void ad1816_close (int dev) /* close device */
479{
480 unsigned long flags;
481 ad1816_info *devc = (ad1816_info *) audio_devs[dev]->devc;
482
483 /* halt all pending output */
484 ad1816_reset(devc->dev_no);
485
486 spin_lock_irqsave(&devc->lock,flags);
487 devc->opened = 0;
488 devc->audio_mode = 0;
489 devc->speed = 8000;
490 devc->audio_format=AFMT_U8;
491 devc->format_bits = 0;
492 spin_unlock_irqrestore(&devc->lock,flags);
493}
494
495
496/* ------------------------------------------------------------------- */
497
498/* Audio driver structure */
499
500static struct audio_driver ad1816_audio_driver =
501{
502 .owner = THIS_MODULE,
503 .open = ad1816_open,
504 .close = ad1816_close,
505 .output_block = ad1816_output_block,
506 .start_input = ad1816_start_input,
507 .prepare_for_input = ad1816_prepare_for_input,
508 .prepare_for_output = ad1816_prepare_for_output,
509 .halt_io = ad1816_halt,
510 .halt_input = ad1816_halt_input,
511 .halt_output = ad1816_halt_output,
512 .trigger = ad1816_trigger,
513 .set_speed = ad1816_set_speed,
514 .set_bits = ad1816_set_bits,
515 .set_channels = ad1816_set_channels,
516};
517
518
519/* ------------------------------------------------------------------- */
520
521/* Interrupt handler */
522
523
524static irqreturn_t ad1816_interrupt (int irq, void *dev_id)
525{
526 unsigned char status;
527 ad1816_info *devc = (ad1816_info *)dev_id;
528
529 if (irq < 0 || irq > 15) {
530 printk(KERN_WARNING "ad1816: Got bogus interrupt %d\n", irq);
531 return IRQ_NONE;
532 }
533
534 spin_lock(&devc->lock);
535
536 /* read interrupt register */
537 status = inb (devc->base+1);
538 /* Clear all interrupt */
539 outb (~status, devc->base+1);
540
541 DEBUGNOISE(printk(KERN_DEBUG "ad1816: Got interrupt subclass %d\n",status));
542
543 if (status == 0) {
544 DEBUGNOISE(printk(KERN_DEBUG "ad1816: interrupt: Got interrupt, but no source.\n"));
545 spin_unlock(&devc->lock);
546 return IRQ_NONE;
547 }
548
549 if (devc->opened && (devc->audio_mode & PCM_ENABLE_INPUT) && (status&64))
550 DMAbuf_inputintr (devc->dev_no);
551
552 if (devc->opened && (devc->audio_mode & PCM_ENABLE_OUTPUT) && (status & 128))
553 DMAbuf_outputintr (devc->dev_no, 1);
554
555 spin_unlock(&devc->lock);
556 return IRQ_HANDLED;
557}
558
559/* ------------------------------------------------------------------- */
560
561/* Mixer stuff */
562
563struct mixer_def {
564 unsigned int regno: 7;
565 unsigned int polarity:1; /* 0=normal, 1=reversed */
566 unsigned int bitpos:4;
567 unsigned int nbits:4;
568};
569
570static char mix_cvt[101] = {
571 0, 0, 3, 7,10,13,16,19,21,23,26,28,30,32,34,35,37,39,40,42,
572 43,45,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,63,64,65,
573 65,66,67,68,69,70,70,71,72,73,73,74,75,75,76,77,77,78,79,79,
574 80,81,81,82,82,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,
575 91,91,92,92,93,93,94,94,95,95,96,96,96,97,97,98,98,98,99,99,
576 100
577};
578
579typedef struct mixer_def mixer_ent;
580
581/*
582 * Most of the mixer entries work in backwards. Setting the polarity field
583 * makes them to work correctly.
584 *
585 * The channel numbering used by individual soundcards is not fixed. Some
586 * cards have assigned different meanings for the AUX1, AUX2 and LINE inputs.
587 * The current version doesn't try to compensate this.
588 */
589
590#define MIX_ENT(name, reg_l, pola_l, pos_l, len_l, reg_r, pola_r, pos_r, len_r) \
591 {{reg_l, pola_l, pos_l, len_l}, {reg_r, pola_r, pos_r, len_r}}
592
593
594static mixer_ent mix_devices[SOUND_MIXER_NRDEVICES][2] = {
595MIX_ENT(SOUND_MIXER_VOLUME, 14, 1, 8, 5, 14, 1, 0, 5),
596MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0),
597MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0),
598MIX_ENT(SOUND_MIXER_SYNTH, 5, 1, 8, 6, 5, 1, 0, 6),
599MIX_ENT(SOUND_MIXER_PCM, 4, 1, 8, 6, 4, 1, 0, 6),
600MIX_ENT(SOUND_MIXER_SPEAKER, 0, 0, 0, 0, 0, 0, 0, 0),
601MIX_ENT(SOUND_MIXER_LINE, 18, 1, 8, 5, 18, 1, 0, 5),
602MIX_ENT(SOUND_MIXER_MIC, 19, 1, 8, 5, 19, 1, 0, 5),
603MIX_ENT(SOUND_MIXER_CD, 15, 1, 8, 5, 15, 1, 0, 5),
604MIX_ENT(SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0),
605MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0),
606MIX_ENT(SOUND_MIXER_RECLEV, 20, 0, 8, 4, 20, 0, 0, 4),
607MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 0, 0, 0, 0, 0),
608MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0),
609MIX_ENT(SOUND_MIXER_LINE1, 17, 1, 8, 5, 17, 1, 0, 5),
610MIX_ENT(SOUND_MIXER_LINE2, 16, 1, 8, 5, 16, 1, 0, 5),
611MIX_ENT(SOUND_MIXER_LINE3, 39, 0, 9, 4, 39, 1, 0, 5)
612};
613
614
615static unsigned short default_mixer_levels[SOUND_MIXER_NRDEVICES] =
616{
617 0x4343, /* Master Volume */
618 0x3232, /* Bass */
619 0x3232, /* Treble */
620 0x0000, /* FM */
621 0x4343, /* PCM */
622 0x0000, /* PC Speaker */
623 0x0000, /* Ext Line */
624 0x0000, /* Mic */
625 0x0000, /* CD */
626 0x0000, /* Recording monitor */
627 0x0000, /* SB PCM */
628 0x0000, /* Recording level */
629 0x0000, /* Input gain */
630 0x0000, /* Output gain */
631 0x0000, /* Line1 */
632 0x0000, /* Line2 */
633 0x0000 /* Line3 (usually line in)*/
634};
635
636#define LEFT_CHN 0
637#define RIGHT_CHN 1
638
639
640
641static int
642ad1816_set_recmask (ad1816_info * devc, int mask)
643{
644 unsigned long flags;
645 unsigned char recdev;
646 int i, n;
647
648 spin_lock_irqsave(&devc->lock, flags);
649 mask &= devc->supported_rec_devices;
650
651 n = 0;
652 /* Count selected device bits */
653 for (i = 0; i < 32; i++)
654 if (mask & (1 << i))
655 n++;
656
657 if (n == 0)
658 mask = SOUND_MASK_MIC;
659 else if (n != 1) { /* Too many devices selected */
660 /* Filter out active settings */
661 mask &= ~devc->recmask;
662
663 n = 0;
664 /* Count selected device bits */
665 for (i = 0; i < 32; i++)
666 if (mask & (1 << i))
667 n++;
668
669 if (n != 1)
670 mask = SOUND_MASK_MIC;
671 }
672
673 switch (mask) {
674 case SOUND_MASK_MIC:
675 recdev = 5;
676 break;
677
678 case SOUND_MASK_LINE:
679 recdev = 0;
680 break;
681
682 case SOUND_MASK_CD:
683 recdev = 2;
684 break;
685
686 case SOUND_MASK_LINE1:
687 recdev = 4;
688 break;
689
690 case SOUND_MASK_LINE2:
691 recdev = 3;
692 break;
693
694 case SOUND_MASK_VOLUME:
695 recdev = 1;
696 break;
697
698 default:
699 mask = SOUND_MASK_MIC;
700 recdev = 5;
701 }
702
703 recdev <<= 4;
704 ad_write (devc, 20,
705 (ad_read (devc, 20) & 0x8f8f) | recdev | (recdev<<8));
706
707 devc->recmask = mask;
708 spin_unlock_irqrestore(&devc->lock, flags);
709 return mask;
710}
711
712static void
713change_bits (int *regval, int dev, int chn, int newval)
714{
715 unsigned char mask;
716 int shift;
717
718 /* Reverse polarity*/
719
720 if (mix_devices[dev][chn].polarity == 1)
721 newval = 100 - newval;
722
723 mask = (1 << mix_devices[dev][chn].nbits) - 1;
724 shift = mix_devices[dev][chn].bitpos;
725 /* Scale it */
726 newval = (int) ((newval * mask) + 50) / 100;
727 /* Clear bits */
728 *regval &= ~(mask << shift);
729 /* Set new value */
730 *regval |= (newval & mask) << shift;
731}
732
733static int
734ad1816_mixer_get (ad1816_info * devc, int dev)
735{
736 DEBUGNOISE(printk(KERN_DEBUG "ad1816: mixer_get called!\n"));
737
738 /* range check + supported mixer check */
739 if (dev < 0 || dev >= SOUND_MIXER_NRDEVICES )
740 return (-(EINVAL));
741 if (!((1 << dev) & devc->supported_devices))
742 return -(EINVAL);
743
744 return devc->levels[dev];
745}
746
747static int
748ad1816_mixer_set (ad1816_info * devc, int dev, int value)
749{
750 int left = value & 0x000000ff;
751 int right = (value & 0x0000ff00) >> 8;
752 int retvol;
753
754 int regoffs;
755 int val;
756 int valmute;
757 unsigned long flags;
758
759 DEBUGNOISE(printk(KERN_DEBUG "ad1816: mixer_set called!\n"));
760
761 if (dev < 0 || dev >= SOUND_MIXER_NRDEVICES )
762 return -(EINVAL);
763
764 if (left > 100)
765 left = 100;
766 if (left < 0)
767 left = 0;
768 if (right > 100)
769 right = 100;
770 if (right < 0)
771 right = 0;
772
773 /* Mono control */
774 if (mix_devices[dev][RIGHT_CHN].nbits == 0)
775 right = left;
776 retvol = left | (right << 8);
777
778 /* Scale it */
779
780 left = mix_cvt[left];
781 right = mix_cvt[right];
782
783 /* reject all mixers that are not supported */
784 if (!(devc->supported_devices & (1 << dev)))
785 return -(EINVAL);
786
787 /* sanity check */
788 if (mix_devices[dev][LEFT_CHN].nbits == 0)
789 return -(EINVAL);
790 spin_lock_irqsave(&devc->lock, flags);
791
792 /* keep precise volume internal */
793 devc->levels[dev] = retvol;
794
795 /* Set the left channel */
796 regoffs = mix_devices[dev][LEFT_CHN].regno;
797 val = ad_read (devc, regoffs);
798 change_bits (&val, dev, LEFT_CHN, left);
799
800 valmute=val;
801
802 /* Mute bit masking on some registers */
803 if ( regoffs==5 || regoffs==14 || regoffs==15 ||
804 regoffs==16 || regoffs==17 || regoffs==18 ||
805 regoffs==19 || regoffs==39) {
806 if (left==0)
807 valmute |= 0x8000;
808 else
809 valmute &= ~0x8000;
810 }
811 ad_write (devc, regoffs, valmute); /* mute */
812
813 /*
814 * Set the right channel
815 */
816
817 /* Was just a mono channel */
818 if (mix_devices[dev][RIGHT_CHN].nbits == 0) {
819 spin_unlock_irqrestore(&devc->lock, flags);
820 return retvol;
821 }
822
823 regoffs = mix_devices[dev][RIGHT_CHN].regno;
824 val = ad_read (devc, regoffs);
825 change_bits (&val, dev, RIGHT_CHN, right);
826
827 valmute=val;
828 if ( regoffs==5 || regoffs==14 || regoffs==15 ||
829 regoffs==16 || regoffs==17 || regoffs==18 ||
830 regoffs==19 || regoffs==39) {
831 if (right==0)
832 valmute |= 0x80;
833 else
834 valmute &= ~0x80;
835 }
836 ad_write (devc, regoffs, valmute); /* mute */
837 spin_unlock_irqrestore(&devc->lock, flags);
838 return retvol;
839}
840
841#define MIXER_DEVICES ( SOUND_MASK_VOLUME | \
842 SOUND_MASK_SYNTH | \
843 SOUND_MASK_PCM | \
844 SOUND_MASK_LINE | \
845 SOUND_MASK_LINE1 | \
846 SOUND_MASK_LINE2 | \
847 SOUND_MASK_LINE3 | \
848 SOUND_MASK_MIC | \
849 SOUND_MASK_CD | \
850 SOUND_MASK_RECLEV \
851 )
852#define REC_DEVICES ( SOUND_MASK_LINE2 |\
853 SOUND_MASK_LINE |\
854 SOUND_MASK_LINE1 |\
855 SOUND_MASK_MIC |\
856 SOUND_MASK_CD |\
857 SOUND_MASK_VOLUME \
858 )
859
860static void
861ad1816_mixer_reset (ad1816_info * devc)
862{
863 int i;
864
865 devc->supported_devices = MIXER_DEVICES;
866
867 devc->supported_rec_devices = REC_DEVICES;
868
869 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
870 if (devc->supported_devices & (1 << i))
871 ad1816_mixer_set (devc, i, default_mixer_levels[i]);
872 ad1816_set_recmask (devc, SOUND_MASK_MIC);
873}
874
875static int
876ad1816_mixer_ioctl (int dev, unsigned int cmd, void __user * arg)
877{
878 ad1816_info *devc = mixer_devs[dev]->devc;
879 int val;
880 int __user *p = arg;
881
882 DEBUGNOISE(printk(KERN_DEBUG "ad1816: mixer_ioctl called!\n"));
883
884 /* Mixer ioctl */
885 if (((cmd >> 8) & 0xff) == 'M') {
886
887 /* set ioctl */
888 if (_SIOC_DIR (cmd) & _SIOC_WRITE) {
889 switch (cmd & 0xff){
890 case SOUND_MIXER_RECSRC:
891
892 if (get_user(val, p))
893 return -EFAULT;
894 val=ad1816_set_recmask (devc, val);
895 return put_user(val, p);
896 break;
897
898 default:
899 if (get_user(val, p))
900 return -EFAULT;
901 if ((val=ad1816_mixer_set (devc, cmd & 0xff, val))<0)
902 return val;
903 else
904 return put_user(val, p);
905 }
906 } else {
907 /* read ioctl */
908 switch (cmd & 0xff) {
909
910 case SOUND_MIXER_RECSRC:
911 val=devc->recmask;
912 return put_user(val, p);
913 break;
914
915 case SOUND_MIXER_DEVMASK:
916 val=devc->supported_devices;
917 return put_user(val, p);
918 break;
919
920 case SOUND_MIXER_STEREODEVS:
921 val=devc->supported_devices & ~(SOUND_MASK_SPEAKER | SOUND_MASK_IMIX);
922 return put_user(val, p);
923 break;
924
925 case SOUND_MIXER_RECMASK:
926 val=devc->supported_rec_devices;
927 return put_user(val, p);
928 break;
929
930 case SOUND_MIXER_CAPS:
931 val=SOUND_CAP_EXCL_INPUT;
932 return put_user(val, p);
933 break;
934
935 default:
936 if ((val=ad1816_mixer_get (devc, cmd & 0xff))<0)
937 return val;
938 else
939 return put_user(val, p);
940 }
941 }
942 } else
943 /* not for mixer */
944 return -(EINVAL);
945}
946
947/* ------------------------------------------------------------------- */
948
949/* Mixer structure */
950
951static struct mixer_operations ad1816_mixer_operations = {
952 .owner = THIS_MODULE,
953 .id = "AD1816",
954 .name = "AD1816 Mixer",
955 .ioctl = ad1816_mixer_ioctl
956};
957
958
959/* ------------------------------------------------------------------- */
960
961/* stuff for card recognition, init and unloading PNP ...*/
962
963
964/* check if AD1816 present at specified hw_config and register device with OS
965 * return 1 if initialization was successful, 0 otherwise
966 */
967static int __init ad1816_init_card (struct address_info *hw_config,
968 struct pnp_dev *pnp)
969{
970 ad1816_info *devc = NULL;
971 int tmp;
972 int oss_devno = -1;
973
974 printk(KERN_INFO "ad1816: initializing card: io=0x%x, irq=%d, dma=%d, "
975 "dma2=%d, clockfreq=%d, options=%d isadmabug=%d "
976 "%s\n",
977 hw_config->io_base,
978 hw_config->irq,
979 hw_config->dma,
980 hw_config->dma2,
981 ad1816_clockfreq,
982 options,
983 isa_dma_bridge_buggy,
984 pnp?"(PNP)":"");
985
986 /* ad1816_info structure remaining ? */
987 if (nr_ad1816_devs >= MAX_AUDIO_DEV) {
988 printk(KERN_WARNING "ad1816: no more ad1816_info structures "
989 "left\n");
990 goto out;
991 }
992
993 devc = &dev_info[nr_ad1816_devs];
994 devc->base = hw_config->io_base;
995 devc->irq = hw_config->irq;
996 devc->dma_playback=hw_config->dma;
997 devc->dma_capture=hw_config->dma2;
998 devc->opened = 0;
999 devc->pnpdev = pnp;
1000 spin_lock_init(&devc->lock);
1001
1002 if (!request_region(devc->base, 16, "AD1816 Sound")) {
1003 printk(KERN_WARNING "ad1816: I/O port 0x%03x not free\n",
1004 devc->base);
1005 goto out;
1006 }
1007
1008 printk(KERN_INFO "ad1816: Examining AD1816 at address 0x%03x.\n",
1009 devc->base);
1010
1011
1012 /* tests for ad1816 */
1013 /* base+0: bit 1 must be set but not 255 */
1014 tmp=inb(devc->base);
1015 if ( (tmp&0x80)==0 || tmp==255 ) {
1016 printk (KERN_INFO "ad1816: Chip is not an AD1816 or chip "
1017 "is not active (Test 0)\n");
1018 goto out_release_region;
1019 }
1020
1021 /* writes to ireg 8 are copied to ireg 9 */
1022 ad_write(devc,8,12345);
1023 if (ad_read(devc,9)!=12345) {
1024 printk(KERN_INFO "ad1816: Chip is not an AD1816 (Test 1)\n");
1025 goto out_release_region;
1026 }
1027
1028 /* writes to ireg 8 are copied to ireg 9 */
1029 ad_write(devc,8,54321);
1030 if (ad_read(devc,9)!=54321) {
1031 printk(KERN_INFO "ad1816: Chip is not an AD1816 (Test 2)\n");
1032 goto out_release_region;
1033 }
1034
1035 /* writes to ireg 10 are copied to ireg 11 */
1036 ad_write(devc,10,54321);
1037 if (ad_read(devc,11)!=54321) {
1038 printk (KERN_INFO "ad1816: Chip is not an AD1816 (Test 3)\n");
1039 goto out_release_region;
1040 }
1041
1042 /* writes to ireg 10 are copied to ireg 11 */
1043 ad_write(devc,10,12345);
1044 if (ad_read(devc,11)!=12345) {
1045 printk (KERN_INFO "ad1816: Chip is not an AD1816 (Test 4)\n");
1046 goto out_release_region;
1047 }
1048
1049 /* bit in base +1 cannot be set to 1 */
1050 tmp=inb(devc->base+1);
1051 outb(0xff,devc->base+1);
1052 if (inb(devc->base+1)!=tmp) {
1053 printk(KERN_INFO "ad1816: Chip is not an AD1816 (Test 5)\n");
1054 goto out_release_region;
1055 }
1056
1057 printk(KERN_INFO "ad1816: AD1816 (version %d) successfully detected!\n",
1058 ad_read(devc,45));
1059
1060 /* disable all interrupts */
1061 ad_write(devc,1,0);
1062
1063 /* Clear pending interrupts */
1064 outb (0, devc->base+1);
1065
1066 /* allocate irq */
1067 if (devc->irq < 0 || devc->irq > 15)
1068 goto out_release_region;
1069 if (request_irq(devc->irq, ad1816_interrupt,0,
1070 "SoundPort", devc) < 0) {
1071 printk(KERN_WARNING "ad1816: IRQ in use\n");
1072 goto out_release_region;
1073 }
1074
1075 /* DMA stuff */
1076 if (sound_alloc_dma (devc->dma_playback, "Sound System")) {
1077 printk(KERN_WARNING "ad1816: Can't allocate DMA%d\n",
1078 devc->dma_playback);
1079 goto out_free_irq;
1080 }
1081
1082 if ( devc->dma_capture >= 0 &&
1083 devc->dma_capture != devc->dma_playback) {
1084 if (sound_alloc_dma(devc->dma_capture,
1085 "Sound System (capture)")) {
1086 printk(KERN_WARNING "ad1816: Can't allocate DMA%d\n",
1087 devc->dma_capture);
1088 goto out_free_dma;
1089 }
1090 devc->audio_mode=DMA_AUTOMODE|DMA_DUPLEX;
1091 } else {
1092 printk(KERN_WARNING "ad1816: Only one DMA channel "
1093 "available/configured. No duplex operation possible\n");
1094 devc->audio_mode=DMA_AUTOMODE;
1095 }
1096
1097 conf_printf2 ("AD1816 audio driver",
1098 devc->base, devc->irq, devc->dma_playback,
1099 devc->dma_capture);
1100
1101 /* register device */
1102 if ((oss_devno = sound_install_audiodrv (AUDIO_DRIVER_VERSION,
1103 "AD1816 audio driver",
1104 &ad1816_audio_driver,
1105 sizeof (struct audio_driver),
1106 devc->audio_mode,
1107 ad_format_mask,
1108 devc,
1109 devc->dma_playback,
1110 devc->dma_capture)) < 0) {
1111 printk(KERN_WARNING "ad1816: Can't install sound driver\n");
1112 goto out_free_dma_2;
1113 }
1114
1115
1116 ad_write(devc,32,0x80f0); /* sound system mode */
1117 if (options&1) {
1118 ad_write(devc,33,0); /* disable all audiosources for dsp */
1119 } else {
1120 ad_write(devc,33,0x03f8); /* enable all audiosources for dsp */
1121 }
1122 ad_write(devc,4,0x8080); /* default values for volumes (muted)*/
1123 ad_write(devc,5,0x8080);
1124 ad_write(devc,6,0x8080);
1125 ad_write(devc,7,0x8080);
1126 ad_write(devc,15,0x8888);
1127 ad_write(devc,16,0x8888);
1128 ad_write(devc,17,0x8888);
1129 ad_write(devc,18,0x8888);
1130 ad_write(devc,19,0xc888); /* +20db mic active */
1131 ad_write(devc,14,0x0000); /* Master volume unmuted */
1132 ad_write(devc,39,0x009f); /* 3D effect on 0% phone out muted */
1133 ad_write(devc,44,0x0080); /* everything on power, 3d enabled for d/a */
1134 outb(0x10,devc->base+8); /* set dma mode */
1135 outb(0x10,devc->base+9);
1136
1137 /* enable capture + playback interrupt */
1138 ad_write(devc,1,0xc000);
1139
1140 /* set mixer defaults */
1141 ad1816_mixer_reset (devc);
1142
1143 /* register mixer */
1144 if ((audio_devs[oss_devno]->mixer_dev=sound_install_mixer(
1145 MIXER_DRIVER_VERSION,
1146 "AD1816 audio driver",
1147 &ad1816_mixer_operations,
1148 sizeof (struct mixer_operations),
1149 devc)) < 0) {
1150 printk(KERN_WARNING "Can't install mixer\n");
1151 }
1152 /* make ad1816_info active */
1153 nr_ad1816_devs++;
1154 printk(KERN_INFO "ad1816: card successfully installed!\n");
1155 return 1;
1156 /* error handling */
1157out_free_dma_2:
1158 if (devc->dma_capture >= 0 && devc->dma_capture != devc->dma_playback)
1159 sound_free_dma(devc->dma_capture);
1160out_free_dma:
1161 sound_free_dma(devc->dma_playback);
1162out_free_irq:
1163 free_irq(devc->irq, devc);
1164out_release_region:
1165 release_region(devc->base, 16);
1166out:
1167 return 0;
1168}
1169
1170static void __exit unload_card(ad1816_info *devc)
1171{
1172 int mixer, dev = 0;
1173
1174 if (devc != NULL) {
1175 printk("ad1816: Unloading card at address 0x%03x\n",devc->base);
1176
1177 dev = devc->dev_no;
1178 mixer = audio_devs[dev]->mixer_dev;
1179
1180 /* unreg mixer*/
1181 if(mixer>=0) {
1182 sound_unload_mixerdev(mixer);
1183 }
1184 /* unreg audiodev */
1185 sound_unload_audiodev(dev);
1186
1187 /* free dma channels */
1188 if (devc->dma_capture>=0 &&
1189 devc->dma_capture != devc->dma_playback) {
1190 sound_free_dma(devc->dma_capture);
1191 }
1192 sound_free_dma (devc->dma_playback);
1193 /* free irq */
1194 free_irq(devc->irq, devc);
1195 /* free io */
1196 release_region (devc->base, 16);
1197#ifdef __ISAPNP__
1198 if (devc->pnpdev) {
1199 pnp_disable_dev(devc->pnpdev);
1200 pnp_device_detach(devc->pnpdev);
1201 }
1202#endif
1203
1204 } else
1205 printk(KERN_WARNING "ad1816: no device/card specified\n");
1206}
1207
1208static int __initdata io = -1;
1209static int __initdata irq = -1;
1210static int __initdata dma = -1;
1211static int __initdata dma2 = -1;
1212
1213#ifdef __ISAPNP__
1214/* use isapnp for configuration */
1215static int isapnp = 1;
1216static int isapnpjump;
1217module_param(isapnp, bool, 0);
1218module_param(isapnpjump, int, 0);
1219#endif
1220
1221module_param(io, int, 0);
1222module_param(irq, int, 0);
1223module_param(dma, int, 0);
1224module_param(dma2, int, 0);
1225module_param(ad1816_clockfreq, int, 0);
1226module_param(options, int, 0);
1227
1228#ifdef __ISAPNP__
1229static struct {
1230 unsigned short card_vendor, card_device;
1231 unsigned short vendor;
1232 unsigned short function;
1233 struct ad1816_data *data;
1234} isapnp_ad1816_list[] __initdata = {
1235 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
1236 ISAPNP_VENDOR('A','D','S'), ISAPNP_FUNCTION(0x7150),
1237 NULL },
1238 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
1239 ISAPNP_VENDOR('A','D','S'), ISAPNP_FUNCTION(0x7180),
1240 NULL },
1241 {0}
1242};
1243
1244MODULE_DEVICE_TABLE(isapnp, isapnp_ad1816_list);
1245
1246
1247static void __init ad1816_config_pnp_card(struct pnp_card *card,
1248 unsigned short vendor,
1249 unsigned short function)
1250{
1251 struct address_info cfg;
1252 struct pnp_dev *card_dev = pnp_find_dev(card, vendor, function, NULL);
1253 if (!card_dev) return;
1254 if (pnp_device_attach(card_dev) < 0) {
1255 printk(KERN_WARNING "ad1816: Failed to attach PnP device\n");
1256 return;
1257 }
1258 if (pnp_activate_dev(card_dev) < 0) {
1259 printk(KERN_WARNING "ad1816: Failed to activate PnP device\n");
1260 pnp_device_detach(card_dev);
1261 return;
1262 }
1263 cfg.io_base = pnp_port_start(card_dev, 2);
1264 cfg.irq = pnp_irq(card_dev, 0);
1265 cfg.dma = pnp_irq(card_dev, 0);
1266 cfg.dma2 = pnp_irq(card_dev, 1);
1267 if (!ad1816_init_card(&cfg, card_dev)) {
1268 pnp_disable_dev(card_dev);
1269 pnp_device_detach(card_dev);
1270 }
1271}
1272
1273static void __init ad1816_config_pnp_cards(void)
1274{
1275 int nr_pnp_cfg;
1276 int i;
1277
1278 /* Count entries in isapnp_ad1816_list */
1279 for (nr_pnp_cfg = 0; isapnp_ad1816_list[nr_pnp_cfg].card_vendor != 0;
1280 nr_pnp_cfg++);
1281 /* Check and adjust isapnpjump */
1282 if( isapnpjump < 0 || isapnpjump >= nr_pnp_cfg) {
1283 printk(KERN_WARNING
1284 "ad1816: Valid range for isapnpjump is 0-%d. "
1285 "Adjusted to 0.\n", nr_pnp_cfg-1);
1286 isapnpjump = 0;
1287 }
1288 for (i = isapnpjump; isapnp_ad1816_list[i].card_vendor != 0; i++) {
1289 struct pnp_card *card = NULL;
1290 /* iterate over all pnp cards */
1291 while ((card = pnp_find_card(isapnp_ad1816_list[i].card_vendor,
1292 isapnp_ad1816_list[i].card_device, card)))
1293 ad1816_config_pnp_card(card,
1294 isapnp_ad1816_list[i].vendor,
1295 isapnp_ad1816_list[i].function);
1296 }
1297}
1298#endif
1299
1300/* module initialization */
1301static int __init init_ad1816(void)
1302{
1303 printk(KERN_INFO "ad1816: AD1816 sounddriver "
1304 "Copyright (C) 1998-2003 by Thorsten Knabe and "
1305 "others\n");
1306#ifdef AD1816_CLOCK
1307 /* set ad1816_clockfreq if set during compilation */
1308 ad1816_clockfreq=AD1816_CLOCK;
1309#endif
1310 if (ad1816_clockfreq<5000 || ad1816_clockfreq>100000) {
1311 ad1816_clockfreq=33000;
1312 }
1313
1314#ifdef __ISAPNP__
1315 /* configure PnP cards */
1316 if(isapnp) ad1816_config_pnp_cards();
1317#endif
1318 /* configure card by module params */
1319 if (io != -1 && irq != -1 && dma != -1) {
1320 struct address_info cfg;
1321 cfg.io_base = io;
1322 cfg.irq = irq;
1323 cfg.dma = dma;
1324 cfg.dma2 = dma2;
1325 ad1816_init_card(&cfg, NULL);
1326 }
1327 if (nr_ad1816_devs <= 0)
1328 return -ENODEV;
1329 return 0;
1330}
1331
1332/* module cleanup */
1333static void __exit cleanup_ad1816 (void)
1334{
1335 int i;
1336 ad1816_info *devc = NULL;
1337
1338 /* remove any soundcard */
1339 for (i = 0; i < nr_ad1816_devs; i++) {
1340 devc = &dev_info[i];
1341 unload_card(devc);
1342 }
1343 nr_ad1816_devs=0;
1344 printk(KERN_INFO "ad1816: driver unloaded!\n");
1345}
1346
1347module_init(init_ad1816);
1348module_exit(cleanup_ad1816);
1349
1350#ifndef MODULE
1351/* kernel command line parameter evaluation */
1352static int __init setup_ad1816(char *str)
1353{
1354 /* io, irq, dma, dma2 */
1355 int ints[5];
1356
1357 str = get_options(str, ARRAY_SIZE(ints), ints);
1358
1359 io = ints[1];
1360 irq = ints[2];
1361 dma = ints[3];
1362 dma2 = ints[4];
1363 return 1;
1364}
1365
1366__setup("ad1816=", setup_ad1816);
1367#endif
1368MODULE_LICENSE("GPL");
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
deleted file mode 100644
index c0730a3563a..00000000000
--- a/sound/oss/ad1889.c
+++ /dev/null
@@ -1,1101 +0,0 @@
1/*
2 * Copyright 2001-2004 Randolph Chung <tausq@debian.org>
3 *
4 * Analog Devices 1889 PCI audio driver (AD1819 AC97-compatible codec)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Notes:
21 * 1. Only flat DMA is supported; s-g is not supported right now
22 *
23 *
24<jsm> tausq: Anyway, to set up sample rates for D to A, you just use the sample rate on the codec. For A to D, you need to set the codec always to 48K (using the split sample rate feature on the codec) and then set the resampler on the AD1889 to the sample rate you want.
25<jsm> Also, when changing the sample rate on the codec you need to power it down and re power it up for the change to take effect!
26 *
27 * $Id: ad1889.c,v 1.3 2002/10/19 21:31:44 grundler Exp $
28 */
29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/ioport.h>
32#include <linux/pci.h>
33#include <linux/poll.h>
34#include <linux/proc_fs.h>
35#include <linux/slab.h>
36#include <linux/soundcard.h>
37#include <linux/ac97_codec.h>
38#include <linux/sound.h>
39#include <linux/interrupt.h>
40#include <linux/mutex.h>
41
42#include <asm/delay.h>
43#include <asm/io.h>
44#include <asm/dma.h>
45#include <asm/uaccess.h>
46
47#include "ad1889.h"
48
49#define DBG(fmt, arg...) printk(fmt, ##arg)
50#define DEVNAME "ad1889"
51
52#define NR_HW_CH 4
53#define DAC_RUNNING 1
54#define ADC_RUNNING 2
55
56#define UNDERRUN(dev) (0)
57
58#define AD1889_READW(dev,reg) readw(dev->regbase + reg)
59#define AD1889_WRITEW(dev,reg,val) writew((val), dev->regbase + reg)
60#define AD1889_READL(dev,reg) readl(dev->regbase + reg)
61#define AD1889_WRITEL(dev,reg,val) writel((val), dev->regbase + reg)
62
63//now 100ms
64/* #define WAIT_10MS() schedule_timeout(HZ/10) */
65#define WAIT_10MS() do { int __i; for (__i = 0; __i < 100; __i++) udelay(1000); } while(0)
66
67/* currently only support a single device */
68static ad1889_dev_t *ad1889_dev = NULL;
69
70/************************* helper routines ***************************** */
71static inline void ad1889_set_wav_rate(ad1889_dev_t *dev, int rate)
72{
73 struct ac97_codec *ac97_codec = dev->ac97_codec;
74
75 DBG("Setting WAV rate to %d\n", rate);
76 dev->state[AD_WAV_STATE].dmabuf.rate = rate;
77 AD1889_WRITEW(dev, AD_DS_WAS, rate);
78
79 /* Cycle the DAC to enable the new rate */
80 ac97_codec->codec_write(dev->ac97_codec, AC97_POWER_CONTROL, 0x0200);
81 WAIT_10MS();
82 ac97_codec->codec_write(dev->ac97_codec, AC97_POWER_CONTROL, 0);
83}
84
85static inline void ad1889_set_wav_fmt(ad1889_dev_t *dev, int fmt)
86{
87 u16 tmp;
88
89 DBG("Setting WAV format to 0x%x\n", fmt);
90
91 tmp = AD1889_READW(ad1889_dev, AD_DS_WSMC);
92 if (fmt & AFMT_S16_LE) {
93 //tmp |= 0x0100; /* set WA16 */
94 tmp |= 0x0300; /* set WA16 stereo */
95 } else if (fmt & AFMT_U8) {
96 tmp &= ~0x0100; /* clear WA16 */
97 }
98 AD1889_WRITEW(ad1889_dev, AD_DS_WSMC, tmp);
99}
100
101static inline void ad1889_set_adc_fmt(ad1889_dev_t *dev, int fmt)
102{
103 u16 tmp;
104
105 DBG("Setting ADC format to 0x%x\n", fmt);
106
107 tmp = AD1889_READW(ad1889_dev, AD_DS_RAMC);
108 if (fmt & AFMT_S16_LE) {
109 tmp |= 0x0100; /* set WA16 */
110 } else if (fmt & AFMT_U8) {
111 tmp &= ~0x0100; /* clear WA16 */
112 }
113 AD1889_WRITEW(ad1889_dev, AD_DS_RAMC, tmp);
114}
115
116static void ad1889_start_wav(ad1889_state_t *state)
117{
118 unsigned long flags;
119 struct dmabuf *dmabuf = &state->dmabuf;
120 int cnt;
121 u16 tmp;
122
123 spin_lock_irqsave(&state->card->lock, flags);
124
125 if (dmabuf->dma_len) /* DMA already in flight */
126 goto skip_dma;
127
128 /* setup dma */
129 cnt = dmabuf->wr_ptr - dmabuf->rd_ptr;
130 if (cnt == 0) /* done - don't need to do anything */
131 goto skip_dma;
132
133 /* If the wr_ptr has wrapped, only map to the end */
134 if (cnt < 0)
135 cnt = DMA_SIZE - dmabuf->rd_ptr;
136
137 dmabuf->dma_handle = pci_map_single(ad1889_dev->pci,
138 dmabuf->rawbuf + dmabuf->rd_ptr,
139 cnt, PCI_DMA_TODEVICE);
140 dmabuf->dma_len = cnt;
141 dmabuf->ready = 1;
142
143 DBG("Starting playback at 0x%p for %ld bytes\n", dmabuf->rawbuf +
144 dmabuf->rd_ptr, dmabuf->dma_len);
145
146 /* load up the current register set */
147 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVCC, cnt);
148 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVICC, cnt);
149 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVCA, dmabuf->dma_handle);
150
151 /* TODO: for now we load the base registers with the same thing */
152 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVBC, cnt);
153 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVIBC, cnt);
154 AD1889_WRITEL(ad1889_dev, AD_DMA_WAVBA, dmabuf->dma_handle);
155
156 /* and we're off to the races... */
157 AD1889_WRITEL(ad1889_dev, AD_DMA_CHSS, 0x8);
158 tmp = AD1889_READW(ad1889_dev, AD_DS_WSMC);
159 tmp |= 0x0400; /* set WAEN */
160 AD1889_WRITEW(ad1889_dev, AD_DS_WSMC, tmp);
161 (void) AD1889_READW(ad1889_dev, AD_DS_WSMC); /* flush posted PCI write */
162
163 dmabuf->enable |= DAC_RUNNING;
164
165skip_dma:
166 spin_unlock_irqrestore(&state->card->lock, flags);
167}
168
169
170static void ad1889_stop_wav(ad1889_state_t *state)
171{
172 unsigned long flags;
173 struct dmabuf *dmabuf = &state->dmabuf;
174
175 spin_lock_irqsave(&state->card->lock, flags);
176
177 if (dmabuf->enable & DAC_RUNNING) {
178 u16 tmp;
179 unsigned long cnt = dmabuf->dma_len;
180
181 tmp = AD1889_READW(ad1889_dev, AD_DS_WSMC);
182 tmp &= ~0x0400; /* clear WAEN */
183 AD1889_WRITEW(ad1889_dev, AD_DS_WSMC, tmp);
184 (void) AD1889_READW(ad1889_dev, AD_DS_WSMC); /* flush posted PCI write */
185 pci_unmap_single(ad1889_dev->pci, dmabuf->dma_handle,
186 cnt, PCI_DMA_TODEVICE);
187
188 dmabuf->enable &= ~DAC_RUNNING;
189
190 /* update dma pointers */
191 dmabuf->rd_ptr += cnt;
192 dmabuf->rd_ptr &= (DMA_SIZE - 1);
193
194 dmabuf->dma_handle = 0;
195 dmabuf->dma_len = 0;
196 dmabuf->ready = 0;
197
198 wake_up(&dmabuf->wait);
199 }
200
201 spin_unlock_irqrestore(&state->card->lock, flags);
202}
203
204
205#if 0
206static void ad1889_startstop_adc(ad1889_state_t *state, int start)
207{
208 u16 tmp;
209 unsigned long flags;
210
211 spin_lock_irqsave(&state->card->lock, flags);
212
213 tmp = AD1889_READW(ad1889_dev, AD_DS_RAMC);
214 if (start) {
215 state->dmabuf.enable |= ADC_RUNNING;
216 tmp |= 0x0004; /* set ADEN */
217 } else {
218 state->dmabuf.enable &= ~ADC_RUNNING;
219 tmp &= ~0x0004; /* clear ADEN */
220 }
221 AD1889_WRITEW(ad1889_dev, AD_DS_RAMC, tmp);
222
223 spin_unlock_irqrestore(&state->card->lock, flags);
224}
225#endif
226
227static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
228{
229 ad1889_dev_t *dev;
230 struct dmabuf *dmabuf;
231 int i;
232
233 if ((dev = kzalloc(sizeof(ad1889_dev_t), GFP_KERNEL)) == NULL)
234 return NULL;
235 spin_lock_init(&dev->lock);
236 dev->pci = pci;
237
238 for (i = 0; i < AD_MAX_STATES; i++) {
239 dev->state[i].card = dev;
240 mutex_init(&dev->state[i].mutex);
241 init_waitqueue_head(&dev->state[i].dmabuf.wait);
242 }
243
244 /* allocate dma buffer */
245
246 for (i = 0; i < AD_MAX_STATES; i++) {
247 dmabuf = &dev->state[i].dmabuf;
248 dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA);
249 if (!dmabuf->rawbuf)
250 goto err_free_dmabuf;
251 dmabuf->rawbuf_size = DMA_SIZE;
252 dmabuf->dma_handle = 0;
253 dmabuf->rd_ptr = dmabuf->wr_ptr = dmabuf->dma_len = 0UL;
254 dmabuf->ready = 0;
255 dmabuf->rate = 48000;
256 }
257 return dev;
258
259err_free_dmabuf:
260 while (--i >= 0)
261 kfree(dev->state[i].dmabuf.rawbuf);
262 kfree(dev);
263 return NULL;
264}
265
266static void ad1889_free_dev(ad1889_dev_t *dev)
267{
268 int j;
269 struct dmabuf *dmabuf;
270
271 if (dev == NULL)
272 return;
273
274 if (dev->ac97_codec)
275 ac97_release_codec(dev->ac97_codec);
276
277 for (j = 0; j < AD_MAX_STATES; j++) {
278 dmabuf = &dev->state[j].dmabuf;
279 kfree(dmabuf->rawbuf);
280 }
281
282 kfree(dev);
283}
284
285static inline void ad1889_trigger_playback(ad1889_dev_t *dev)
286{
287#if 0
288 u32 val;
289 struct dmabuf *dmabuf = &dev->state[AD_WAV_STATE].dmabuf;
290#endif
291
292 ad1889_start_wav(&dev->state[AD_WAV_STATE]);
293}
294
295static int ad1889_read_proc (char *page, char **start, off_t off,
296 int count, int *eof, void *data)
297{
298 char *out = page;
299 int len, i;
300 ad1889_dev_t *dev = data;
301 ad1889_reg_t regs[] = {
302 { "WSMC", AD_DS_WSMC, 16 },
303 { "RAMC", AD_DS_RAMC, 16 },
304 { "WADA", AD_DS_WADA, 16 },
305 { "SYDA", AD_DS_SYDA, 16 },
306 { "WAS", AD_DS_WAS, 16 },
307 { "RES", AD_DS_RES, 16 },
308 { "CCS", AD_DS_CCS, 16 },
309 { "ADCBA", AD_DMA_ADCBA, 32 },
310 { "ADCCA", AD_DMA_ADCCA, 32 },
311 { "ADCBC", AD_DMA_ADCBC, 32 },
312 { "ADCCC", AD_DMA_ADCCC, 32 },
313 { "ADCIBC", AD_DMA_ADCIBC, 32 },
314 { "ADCICC", AD_DMA_ADCICC, 32 },
315 { "ADCCTRL", AD_DMA_ADCCTRL, 16 },
316 { "WAVBA", AD_DMA_WAVBA, 32 },
317 { "WAVCA", AD_DMA_WAVCA, 32 },
318 { "WAVBC", AD_DMA_WAVBC, 32 },
319 { "WAVCC", AD_DMA_WAVCC, 32 },
320 { "WAVIBC", AD_DMA_WAVIBC, 32 },
321 { "WAVICC", AD_DMA_WAVICC, 32 },
322 { "WAVCTRL", AD_DMA_WAVCTRL, 16 },
323 { "DISR", AD_DMA_DISR, 32 },
324 { "CHSS", AD_DMA_CHSS, 32 },
325 { "IPC", AD_GPIO_IPC, 16 },
326 { "OP", AD_GPIO_OP, 16 },
327 { "IP", AD_GPIO_IP, 16 },
328 { "ACIC", AD_AC97_ACIC, 16 },
329 { "AC97_RESET", AD_AC97_BASE + AC97_RESET, 16 },
330 { "AC97_MASTER_VOL_STEREO", AD_AC97_BASE + AC97_MASTER_VOL_STEREO, 16 },
331 { "AC97_HEADPHONE_VOL", AD_AC97_BASE + AC97_HEADPHONE_VOL, 16 },
332 { "AC97_MASTER_VOL_MONO", AD_AC97_BASE + AC97_MASTER_VOL_MONO, 16 },
333 { "AC97_MASTER_TONE", AD_AC97_BASE + AC97_MASTER_TONE, 16 },
334 { "AC97_PCBEEP_VOL", AD_AC97_BASE + AC97_PCBEEP_VOL, 16 },
335 { "AC97_PHONE_VOL", AD_AC97_BASE + AC97_PHONE_VOL, 16 },
336 { "AC97_MIC_VOL", AD_AC97_BASE + AC97_MIC_VOL, 16 },
337 { "AC97_LINEIN_VOL", AD_AC97_BASE + AC97_LINEIN_VOL, 16 },
338 { "AC97_CD_VOL", AD_AC97_BASE + AC97_CD_VOL, 16 },
339 { "AC97_VIDEO_VOL", AD_AC97_BASE + AC97_VIDEO_VOL, 16 },
340 { "AC97_AUX_VOL", AD_AC97_BASE + AC97_AUX_VOL, 16 },
341 { "AC97_PCMOUT_VOL", AD_AC97_BASE + AC97_PCMOUT_VOL, 16 },
342 { "AC97_RECORD_SELECT", AD_AC97_BASE + AC97_RECORD_SELECT, 16 },
343 { "AC97_RECORD_GAIN", AD_AC97_BASE + AC97_RECORD_GAIN, 16 },
344 { "AC97_RECORD_GAIN_MIC", AD_AC97_BASE + AC97_RECORD_GAIN_MIC, 16 },
345 { "AC97_GENERAL_PURPOSE", AD_AC97_BASE + AC97_GENERAL_PURPOSE, 16 },
346 { "AC97_3D_CONTROL", AD_AC97_BASE + AC97_3D_CONTROL, 16 },
347 { "AC97_MODEM_RATE", AD_AC97_BASE + AC97_MODEM_RATE, 16 },
348 { "AC97_POWER_CONTROL", AD_AC97_BASE + AC97_POWER_CONTROL, 16 },
349 { NULL }
350 };
351
352 if (dev == NULL)
353 return -ENODEV;
354
355 for (i = 0; regs[i].name != 0; i++)
356 out += sprintf(out, "%s: 0x%0*x\n", regs[i].name,
357 regs[i].width >> 2,
358 (regs[i].width == 16
359 ? AD1889_READW(dev, regs[i].offset)
360 : AD1889_READL(dev, regs[i].offset)));
361
362 for (i = 0; i < AD_MAX_STATES; i++) {
363 out += sprintf(out, "DMA status for %s:\n",
364 (i == AD_WAV_STATE ? "WAV" : "ADC"));
365 out += sprintf(out, "\t\t0x%p (IOVA: 0x%llu)\n",
366 dev->state[i].dmabuf.rawbuf,
367 (unsigned long long)dev->state[i].dmabuf.dma_handle);
368
369 out += sprintf(out, "\tread ptr: offset %u\n",
370 (unsigned int)dev->state[i].dmabuf.rd_ptr);
371 out += sprintf(out, "\twrite ptr: offset %u\n",
372 (unsigned int)dev->state[i].dmabuf.wr_ptr);
373 out += sprintf(out, "\tdma len: offset %u\n",
374 (unsigned int)dev->state[i].dmabuf.dma_len);
375 }
376
377 len = out - page - off;
378 if (len < count) {
379 *eof = 1;
380 if (len <= 0) return 0;
381 } else {
382 len = count;
383 }
384 *start = page + off;
385 return len;
386}
387
388/***************************** DMA interfaces ************************** */
389#if 0
390static inline unsigned long ad1889_get_dma_addr(ad1889_state_t *state)
391{
392 struct dmabuf *dmabuf = &state->dmabuf;
393 u32 offset;
394
395 if (!(dmabuf->enable & (DAC_RUNNING | ADC_RUNNING))) {
396 printk(KERN_ERR DEVNAME ": get_dma_addr called without dma enabled\n");
397 return 0;
398 }
399
400 if (dmabuf->enable & DAC_RUNNING)
401 offset = le32_to_cpu(AD1889_READL(state->card, AD_DMA_WAVBA));
402 else
403 offset = le32_to_cpu(AD1889_READL(state->card, AD_DMA_ADCBA));
404
405 return (unsigned long)bus_to_virt((unsigned long)offset) - (unsigned long)dmabuf->rawbuf;
406}
407
408static void ad1889_update_ptr(ad1889_dev_t *dev, int wake)
409{
410 ad1889_state_t *state;
411 struct dmabuf *dmabuf;
412 unsigned long hwptr;
413 int diff;
414
415 /* check ADC first */
416 state = &dev->adc_state;
417 dmabuf = &state->dmabuf;
418 if (dmabuf->enable & ADC_RUNNING) {
419 hwptr = ad1889_get_dma_addr(state);
420 diff = (dmabuf->dmasize + hwptr - dmabuf->hwptr) % dmabuf->dmasize;
421
422 dmabuf->hwptr = hwptr;
423 dmabuf->total_bytes += diff;
424 dmabuf->count += diff;
425 if (dmabuf->count > dmabuf->dmasize)
426 dmabuf->count = dmabuf->dmasize;
427
428 if (dmabuf->mapped) {
429 if (wake & dmabuf->count >= dmabuf->fragsize)
430 wake_up(&dmabuf->wait);
431 } else {
432 if (wake & dmabuf->count > 0)
433 wake_up(&dmabuf->wait);
434 }
435 }
436
437 /* check DAC */
438 state = &dev->wav_state;
439 dmabuf = &state->dmabuf;
440 if (dmabuf->enable & DAC_RUNNING) {
441XXX
442
443}
444#endif
445
446/************************* /dev/dsp interfaces ************************* */
447
448static ssize_t ad1889_read(struct file *file, char __user *buffer, size_t count,
449 loff_t *ppos)
450{
451 return 0;
452}
453
454static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t count,
455 loff_t *ppos)
456{
457 ad1889_dev_t *dev = (ad1889_dev_t *)file->private_data;
458 ad1889_state_t *state = &dev->state[AD_WAV_STATE];
459 volatile struct dmabuf *dmabuf = &state->dmabuf;
460 ssize_t ret = 0;
461 DECLARE_WAITQUEUE(wait, current);
462
463 mutex_lock(&state->mutex);
464#if 0
465 if (dmabuf->mapped) {
466 ret = -ENXIO;
467 goto err1;
468 }
469#endif
470 if (!access_ok(VERIFY_READ, buffer, count)) {
471 ret = -EFAULT;
472 goto err1;
473 }
474
475 add_wait_queue(&state->dmabuf.wait, &wait);
476
477 /* start filling dma buffer.... */
478 while (count > 0) {
479 long rem;
480 long cnt = count;
481 unsigned long flags;
482
483 for (;;) {
484 long used_bytes;
485 long timeout; /* max time for DMA in jiffies */
486
487 /* buffer is full if wr catches up to rd */
488 spin_lock_irqsave(&state->card->lock, flags);
489 used_bytes = dmabuf->wr_ptr - dmabuf->rd_ptr;
490 timeout = (dmabuf->dma_len * HZ) / dmabuf->rate;
491 spin_unlock_irqrestore(&state->card->lock, flags);
492
493 /* adjust for buffer wrap around */
494 used_bytes = (used_bytes + DMA_SIZE) & (DMA_SIZE - 1);
495
496 /* If at least one page unused */
497 if (used_bytes < (DMA_SIZE - 0x1000))
498 break;
499
500 /* dma buffer full */
501
502 if (file->f_flags & O_NONBLOCK) {
503 ret = -EAGAIN;
504 goto err2;
505 }
506
507 set_current_state(TASK_INTERRUPTIBLE);
508 schedule_timeout(timeout + 1);
509 if (signal_pending(current)) {
510 ret = -ERESTARTSYS;
511 goto err2;
512 }
513 }
514
515 /* watch out for wrapping around static buffer */
516 spin_lock_irqsave(&state->card->lock, flags);
517 rem = DMA_SIZE - dmabuf->wr_ptr;
518 if (cnt > rem)
519 cnt = rem;
520
521 rem = dmabuf->wr_ptr;
522
523 /* update dma pointers */
524 dmabuf->wr_ptr += cnt;
525 dmabuf->wr_ptr &= DMA_SIZE - 1; /* wrap ptr if necessary */
526 spin_unlock_irqrestore(&state->card->lock, flags);
527
528 /* transfer unwrapped chunk */
529 if (copy_from_user(dmabuf->rawbuf + rem, buffer, cnt)) {
530 ret = -EFAULT;
531 goto err2;
532 }
533
534 DBG("Writing 0x%lx bytes to +0x%lx\n", cnt, rem);
535
536 /* update counters */
537 count -= cnt;
538 buffer += cnt;
539 ret += cnt;
540
541 /* we have something to play - go play it! */
542 ad1889_trigger_playback(dev);
543 }
544
545err2:
546 remove_wait_queue(&state->dmabuf.wait, &wait);
547err1:
548 mutex_unlock(&state->mutex);
549 return ret;
550}
551
552static unsigned int ad1889_poll(struct file *file, struct poll_table_struct *wait)
553{
554 unsigned int mask = 0;
555#if 0
556 ad1889_dev_t *dev = (ad1889_dev_t *)file->private_data;
557 ad1889_state_t *state = NULL;
558 struct dmabuf *dmabuf;
559 unsigned long flags;
560
561 if (!(file->f_mode & (FMODE_READ | FMODE_WRITE)))
562 return -EINVAL;
563
564 if (file->f_mode & FMODE_WRITE) {
565 state = &dev->state[AD_WAV_STATE];
566 if (!state) return 0;
567 dmabuf = &state->dmabuf;
568 poll_wait(file, &dmabuf->wait, wait);
569 }
570
571 if (file->f_mode & FMODE_READ) {
572 state = &dev->state[AD_ADC_STATE];
573 if (!state) return 0;
574 dmabuf = &state->dmabuf;
575 poll_wait(file, &dmabuf->wait, wait);
576 }
577
578 spin_lock_irqsave(&dev->lock, flags);
579 ad1889_update_ptr(dev, 0);
580
581 if (file->f_mode & FMODE_WRITE) {
582 state = &dev->state[WAV_STATE];
583 dmabuf = &state->dmabuf;
584 if (dmabuf->mapped) {
585 if (dmabuf->count >= (int)dmabuf->fragsize)
586 mask |= POLLOUT | POLLWRNORM;
587 } else {
588 if ((int)dmabuf->dmasize >= dmabuf->count +
589 (int)dmabuf->fragsize)
590 mask |= POLLOUT | POLLWRNORM;
591 }
592 }
593
594 if (file ->f_mode & FMODE_READ) {
595 state = &dev->state[AD_ADC_STATE];
596 dmabuf = &state->dmabuf;
597 if (dmabuf->count >= (int)dmabuf->fragsize)
598 mask |= POLLIN | POLLRDNORM;
599 }
600 spin_unlock_irqrestore(&dev->lock, flags);
601
602#endif
603 return mask;
604}
605
606static int ad1889_mmap(struct file *file, struct vm_area_struct *vma)
607{
608 return 0;
609}
610
611static int ad1889_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
612 unsigned long arg)
613{
614 int val = 0;
615 ad1889_dev_t *dev = (ad1889_dev_t *)file->private_data;
616 struct dmabuf *dmabuf;
617 audio_buf_info abinfo;
618 int __user *p = (int __user *)arg;
619
620 DBG("ad1889_ioctl cmd 0x%x arg %lu\n", cmd, arg);
621
622 switch (cmd)
623 {
624 case OSS_GETVERSION:
625 return put_user(SOUND_VERSION, p);
626
627 case SNDCTL_DSP_RESET:
628 break;
629
630 case SNDCTL_DSP_SYNC:
631 break;
632
633 case SNDCTL_DSP_SPEED:
634 /* set sampling rate */
635 if (get_user(val, p))
636 return -EFAULT;
637 if (val > 5400 && val < 48000)
638 {
639 if (file->f_mode & FMODE_WRITE)
640 AD1889_WRITEW(ad1889_dev, AD_DS_WAS, val);
641 if (file->f_mode & FMODE_READ)
642 AD1889_WRITEW(ad1889_dev, AD_DS_RES, val);
643 }
644 return 0;
645
646 case SNDCTL_DSP_STEREO: /* undocumented? */
647 if (get_user(val, p))
648 return -EFAULT;
649 if (file->f_mode & FMODE_READ) {
650 val = AD1889_READW(ad1889_dev, AD_DS_WSMC);
651 if (val) {
652 val |= 0x0200; /* set WAST */
653 } else {
654 val &= ~0x0200; /* clear WAST */
655 }
656 AD1889_WRITEW(ad1889_dev, AD_DS_WSMC, val);
657 }
658 if (file->f_mode & FMODE_WRITE) {
659 val = AD1889_READW(ad1889_dev, AD_DS_RAMC);
660 if (val) {
661 val |= 0x0002; /* set ADST */
662 } else {
663 val &= ~0x0002; /* clear ADST */
664 }
665 AD1889_WRITEW(ad1889_dev, AD_DS_RAMC, val);
666 }
667
668 return 0;
669
670 case SNDCTL_DSP_GETBLKSIZE:
671 return put_user(DMA_SIZE, p);
672
673 case SNDCTL_DSP_GETFMTS:
674 return put_user(AFMT_S16_LE|AFMT_U8, p);
675
676 case SNDCTL_DSP_SETFMT:
677 if (get_user(val, p))
678 return -EFAULT;
679
680 if (val == 0) {
681 if (file->f_mode & FMODE_READ)
682 ad1889_set_adc_fmt(dev, val);
683
684 if (file->f_mode & FMODE_WRITE)
685 ad1889_set_wav_fmt(dev, val);
686 } else {
687 val = AFMT_S16_LE | AFMT_U8;
688 }
689
690 return put_user(val, p);
691
692 case SNDCTL_DSP_CHANNELS:
693 break;
694
695 case SNDCTL_DSP_POST:
696 /* send all data to device */
697 break;
698
699 case SNDCTL_DSP_SUBDIVIDE:
700 break;
701
702 case SNDCTL_DSP_SETFRAGMENT:
703 /* not supported; uses fixed fragment sizes */
704 return put_user(DMA_SIZE, p);
705
706 case SNDCTL_DSP_GETOSPACE:
707 case SNDCTL_DSP_GETISPACE:
708 /* space left in dma buffers */
709 if (cmd == SNDCTL_DSP_GETOSPACE)
710 dmabuf = &dev->state[AD_WAV_STATE].dmabuf;
711 else
712 dmabuf = &dev->state[AD_ADC_STATE].dmabuf;
713 abinfo.fragments = 1;
714 abinfo.fragstotal = 1;
715 abinfo.fragsize = DMA_SIZE;
716 abinfo.bytes = DMA_SIZE;
717 return copy_to_user(p, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
718 case SNDCTL_DSP_NONBLOCK:
719 file->f_flags |= O_NONBLOCK;
720 return 0;
721
722 case SNDCTL_DSP_GETCAPS:
723 return put_user(0, p);
724
725 case SNDCTL_DSP_GETTRIGGER:
726 case SNDCTL_DSP_SETTRIGGER:
727 break;
728
729 case SNDCTL_DSP_GETIPTR:
730 case SNDCTL_DSP_GETOPTR:
731 break;
732
733 case SNDCTL_DSP_SETDUPLEX:
734 break;
735
736 case SNDCTL_DSP_GETODELAY:
737 break;
738
739 case SOUND_PCM_READ_RATE:
740 return put_user(AD1889_READW(ad1889_dev, AD_DS_WAS), p);
741
742 case SOUND_PCM_READ_CHANNELS:
743 case SOUND_PCM_READ_BITS:
744 break;
745
746 case SNDCTL_DSP_MAPINBUF:
747 case SNDCTL_DSP_MAPOUTBUF:
748 case SNDCTL_DSP_SETSYNCRO:
749 case SOUND_PCM_WRITE_FILTER:
750 case SOUND_PCM_READ_FILTER:
751 break;
752
753 default:
754 break;
755 }
756
757 return -ENOTTY;
758}
759
760static int ad1889_open(struct inode *inode, struct file *file)
761{
762 /* check minor; only support /dev/dsp atm */
763 if (iminor(inode) != 3)
764 return -ENXIO;
765
766 file->private_data = ad1889_dev;
767
768 ad1889_set_wav_rate(ad1889_dev, 48000);
769 ad1889_set_wav_fmt(ad1889_dev, AFMT_S16_LE);
770 AD1889_WRITEW(ad1889_dev, AD_DS_WADA, 0x0404); /* attenuation */
771 return nonseekable_open(inode, file);
772}
773
774static int ad1889_release(struct inode *inode, struct file *file)
775{
776 /* if we have state free it here */
777 return 0;
778}
779
780static const struct file_operations ad1889_fops = {
781 .owner = THIS_MODULE,
782 .llseek = no_llseek,
783 .read = ad1889_read,
784 .write = ad1889_write,
785 .poll = ad1889_poll,
786 .ioctl = ad1889_ioctl,
787 .mmap = ad1889_mmap,
788 .open = ad1889_open,
789 .release = ad1889_release,
790};
791
792/************************* /dev/mixer interfaces ************************ */
793static int ad1889_mixer_open(struct inode *inode, struct file *file)
794{
795 if (ad1889_dev->ac97_codec->dev_mixer != iminor(inode))
796 return -ENODEV;
797
798 file->private_data = ad1889_dev->ac97_codec;
799 return 0;
800}
801
802static int ad1889_mixer_release(struct inode *inode, struct file *file)
803{
804 return 0;
805}
806
807static int ad1889_mixer_ioctl(struct inode *inode, struct file *file,
808 unsigned int cmd, unsigned long arg)
809{
810 struct ac97_codec *codec = (struct ac97_codec *)file->private_data;
811 return codec->mixer_ioctl(codec, cmd, arg);
812}
813
814static const struct file_operations ad1889_mixer_fops = {
815 .owner = THIS_MODULE,
816 .llseek = no_llseek,
817 .ioctl = ad1889_mixer_ioctl,
818 .open = ad1889_mixer_open,
819 .release = ad1889_mixer_release,
820};
821
822/************************* AC97 interfaces ****************************** */
823static void ad1889_codec_write(struct ac97_codec *ac97, u8 reg, u16 val)
824{
825 ad1889_dev_t *dev = ac97->private_data;
826
827 //DBG("Writing 0x%x to 0x%lx\n", val, dev->regbase + AD_AC97_BASE + reg);
828 AD1889_WRITEW(dev, AD_AC97_BASE + reg, val);
829}
830
831static u16 ad1889_codec_read(struct ac97_codec *ac97, u8 reg)
832{
833 ad1889_dev_t *dev = ac97->private_data;
834 //DBG("Reading from 0x%lx\n", dev->regbase + AD_AC97_BASE + reg);
835 return AD1889_READW(dev, AD_AC97_BASE + reg);
836}
837
838static int ad1889_ac97_init(ad1889_dev_t *dev, int id)
839{
840 struct ac97_codec *ac97;
841 u16 eid;
842
843 if ((ac97 = ac97_alloc_codec()) == NULL)
844 return -ENOMEM;
845
846 ac97->private_data = dev;
847 ac97->id = id;
848
849 ac97->codec_read = ad1889_codec_read;
850 ac97->codec_write = ad1889_codec_write;
851
852 if (ac97_probe_codec(ac97) == 0) {
853 printk(DEVNAME ": ac97_probe_codec failed\n");
854 goto out_free;
855 }
856
857 eid = ad1889_codec_read(ac97, AC97_EXTENDED_ID);
858 if (eid == 0xffff) {
859 printk(KERN_WARNING DEVNAME ": no codec attached?\n");
860 goto out_free;
861 }
862
863 dev->ac97_features = eid;
864
865 if ((ac97->dev_mixer = register_sound_mixer(&ad1889_mixer_fops, -1)) < 0) {
866 printk(KERN_ERR DEVNAME ": cannot register mixer\n");
867 goto out_free;
868 }
869
870 dev->ac97_codec = ac97;
871 return 0;
872
873out_free:
874 ac97_release_codec(ac97);
875 return -ENODEV;
876}
877
878static int ad1889_aclink_reset(struct pci_dev * pcidev)
879{
880 u16 stat;
881 int retry = 200;
882 ad1889_dev_t *dev = pci_get_drvdata(pcidev);
883
884 AD1889_WRITEW(dev, AD_DS_CCS, 0x8000); /* turn on clock */
885 AD1889_READW(dev, AD_DS_CCS);
886
887 WAIT_10MS();
888
889 stat = AD1889_READW(dev, AD_AC97_ACIC);
890 stat |= 0x0002; /* Reset Disable */
891 AD1889_WRITEW(dev, AD_AC97_ACIC, stat);
892 (void) AD1889_READW(dev, AD_AC97_ACIC); /* flush posted write */
893
894 udelay(10);
895
896 stat = AD1889_READW(dev, AD_AC97_ACIC);
897 stat |= 0x0001; /* Interface Enable */
898 AD1889_WRITEW(dev, AD_AC97_ACIC, stat);
899
900 do {
901 if (AD1889_READW(dev, AD_AC97_ACIC) & 0x8000) /* Ready */
902 break;
903 WAIT_10MS();
904 retry--;
905 } while (retry > 0);
906
907 if (!retry) {
908 printk(KERN_ERR "ad1889_aclink_reset: codec is not ready [0x%x]\n",
909 AD1889_READW(dev, AD_AC97_ACIC));
910 return -EBUSY;
911 }
912
913 /* TODO reset AC97 codec */
914 /* TODO set wave/adc pci ctrl status */
915
916 stat = AD1889_READW(dev, AD_AC97_ACIC);
917 stat |= 0x0004; /* Audio Stream Output Enable */
918 AD1889_WRITEW(dev, AD_AC97_ACIC, stat);
919 return 0;
920}
921
922/************************* PCI interfaces ****************************** */
923/* PCI device table */
924static struct pci_device_id ad1889_id_tbl[] = {
925 { PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS, PCI_ANY_ID,
926 PCI_ANY_ID, 0, 0, (unsigned long)DEVNAME },
927 { },
928};
929MODULE_DEVICE_TABLE(pci, ad1889_id_tbl);
930
931static irqreturn_t ad1889_interrupt(int irq, void *dev_id)
932{
933 u32 stat;
934 ad1889_dev_t *dev = (ad1889_dev_t *)dev_id;
935
936 stat = AD1889_READL(dev, AD_DMA_DISR);
937
938 /* clear ISR */
939 AD1889_WRITEL(dev, AD_DMA_DISR, stat);
940
941 if (stat & 0x8) { /* WAVI */
942 DBG("WAV interrupt\n");
943 dev->stats.wav_intrs++;
944 if (dev->state[AD_WAV_STATE].dmabuf.ready) {
945 ad1889_stop_wav(&dev->state[AD_WAV_STATE]); /* clean up */
946 ad1889_start_wav(&dev->state[AD_WAV_STATE]); /* start new */
947 }
948 }
949
950 if ((stat & 0x2) && dev->state[AD_ADC_STATE].dmabuf.ready) { /* ADCI */
951 DBG("ADC interrupt\n");
952 dev->stats.adc_intrs++;
953 }
954 if(stat)
955 return IRQ_HANDLED;
956 return IRQ_NONE;
957}
958
959static void ad1889_initcfg(ad1889_dev_t *dev)
960{
961 u16 tmp16;
962 u32 tmp32;
963
964 /* make sure the interrupt bits are setup the way we want */
965 tmp32 = AD1889_READL(dev, AD_DMA_WAVCTRL);
966 tmp32 &= ~0xff; /* flat dma, no sg, mask out the intr bits */
967 tmp32 |= 0x6; /* intr on count, loop */
968 AD1889_WRITEL(dev, AD_DMA_WAVCTRL, tmp32);
969
970 /* unmute... */
971 tmp16 = AD1889_READW(dev, AD_DS_WADA);
972 tmp16 &= ~0x8080;
973 AD1889_WRITEW(dev, AD_DS_WADA, tmp16);
974}
975
976static int __devinit ad1889_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
977{
978 int err;
979 ad1889_dev_t *dev;
980 unsigned long bar;
981 struct proc_dir_entry *proc_root = NULL;
982
983 if ((err = pci_enable_device(pcidev)) != 0) {
984 printk(KERN_ERR DEVNAME ": pci_enable_device failed\n");
985 return err;
986 }
987
988 pci_set_master(pcidev);
989 if ((dev = ad1889_alloc_dev(pcidev)) == NULL) {
990 printk(KERN_ERR DEVNAME ": cannot allocate memory for device\n");
991 return -ENOMEM;
992 }
993 pci_set_drvdata(pcidev, dev);
994 bar = pci_resource_start(pcidev, 0);
995
996 if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_MEM)) {
997 printk(KERN_ERR DEVNAME ": memory region not assigned\n");
998 goto out1;
999 }
1000
1001 if (pci_request_region(pcidev, 0, DEVNAME)) {
1002 printk(KERN_ERR DEVNAME ": unable to request memory region\n");
1003 goto out1;
1004 }
1005
1006 dev->regbase = ioremap_nocache(bar, AD_DS_IOMEMSIZE);
1007 if (!dev->regbase) {
1008 printk(KERN_ERR DEVNAME ": unable to remap iomem\n");
1009 goto out2;
1010 }
1011
1012 if (request_irq(pcidev->irq, ad1889_interrupt, IRQF_SHARED, DEVNAME, dev) != 0) {
1013 printk(KERN_ERR DEVNAME ": unable to request interrupt\n");
1014 goto out3;
1015 }
1016
1017 printk(KERN_INFO DEVNAME ": %s at %p IRQ %d\n",
1018 (char *)ent->driver_data, dev->regbase, pcidev->irq);
1019
1020 if (ad1889_aclink_reset(pcidev) != 0)
1021 goto out4;
1022
1023 /* register /dev/dsp */
1024 if ((dev->dev_audio = register_sound_dsp(&ad1889_fops, -1)) < 0) {
1025 printk(KERN_ERR DEVNAME ": cannot register /dev/dsp\n");
1026 goto out4;
1027 }
1028
1029 if ((err = ad1889_ac97_init(dev, 0)) != 0)
1030 goto out5;
1031
1032 /* XXX: cleanups */
1033 if (((proc_root = proc_mkdir("driver/ad1889", NULL)) == NULL) ||
1034 create_proc_read_entry("ac97", S_IFREG|S_IRUGO, proc_root, ac97_read_proc, dev->ac97_codec) == NULL ||
1035 create_proc_read_entry("info", S_IFREG|S_IRUGO, proc_root, ad1889_read_proc, dev) == NULL)
1036 goto out5;
1037
1038 ad1889_initcfg(dev);
1039
1040 //DBG(DEVNAME ": Driver initialization done!\n");
1041
1042 ad1889_dev = dev;
1043
1044 return 0;
1045
1046out5:
1047 unregister_sound_dsp(dev->dev_audio);
1048out4:
1049 free_irq(pcidev->irq, dev);
1050out3:
1051 iounmap(dev->regbase);
1052out2:
1053 pci_release_region(pcidev, 0);
1054out1:
1055 ad1889_free_dev(dev);
1056 pci_set_drvdata(pcidev, NULL);
1057
1058 return -ENODEV;
1059}
1060
1061static void __devexit ad1889_remove(struct pci_dev *pcidev)
1062{
1063 ad1889_dev_t *dev = pci_get_drvdata(pcidev);
1064
1065 if (dev == NULL) return;
1066
1067 unregister_sound_mixer(dev->ac97_codec->dev_mixer);
1068 unregister_sound_dsp(dev->dev_audio);
1069 free_irq(pcidev->irq, dev);
1070 iounmap(dev->regbase);
1071 pci_release_region(pcidev, 0);
1072
1073 /* any hw programming needed? */
1074 ad1889_free_dev(dev);
1075 pci_set_drvdata(pcidev, NULL);
1076}
1077
1078MODULE_AUTHOR("Randolph Chung");
1079MODULE_DESCRIPTION("Analog Devices AD1889 PCI Audio");
1080MODULE_LICENSE("GPL");
1081
1082static struct pci_driver ad1889_driver = {
1083 .name = DEVNAME,
1084 .id_table = ad1889_id_tbl,
1085 .probe = ad1889_probe,
1086 .remove = __devexit_p(ad1889_remove),
1087};
1088
1089static int __init ad1889_init_module(void)
1090{
1091 return pci_register_driver(&ad1889_driver);
1092}
1093
1094static void ad1889_exit_module(void)
1095{
1096 pci_unregister_driver(&ad1889_driver);
1097 return;
1098}
1099
1100module_init(ad1889_init_module);
1101module_exit(ad1889_exit_module);
diff --git a/sound/oss/ad1889.h b/sound/oss/ad1889.h
deleted file mode 100644
index 09913765967..00000000000
--- a/sound/oss/ad1889.h
+++ /dev/null
@@ -1,135 +0,0 @@
1#ifndef _AD1889_H_
2#define _AD1889_H_
3
4#define AD_DS_WSMC 0x00 /* DMA input wave/syn mixer control */
5#define AD_DS_RAMC 0x02 /* DMA output resamp/ADC mixer control */
6#define AD_DS_WADA 0x04 /* DMA input wave attenuation */
7#define AD_DS_SYDA 0x06 /* DMA input syn attentuation */
8#define AD_DS_WAS 0x08 /* wave input sample rate */
9#define AD_DS_RES 0x0a /* resampler output sample rate */
10#define AD_DS_CCS 0x0c /* chip control/status */
11
12#define AD_DMA_RESBA 0x40 /* RES base addr */
13#define AD_DMA_RESCA 0x44 /* RES current addr */
14#define AD_DMA_RESBC 0x48 /* RES base cnt */
15#define AD_DMA_RESCC 0x4c /* RES current count */
16#define AD_DMA_ADCBA 0x50 /* ADC */
17#define AD_DMA_ADCCA 0x54
18#define AD_DMA_ADCBC 0x58
19#define AD_DMA_ADCCC 0x5c
20#define AD_DMA_SYNBA 0x60 /* SYN */
21#define AD_DMA_SYNCA 0x64
22#define AD_DMA_SYNBC 0x68
23#define AD_DMA_SYNCC 0x6c
24#define AD_DMA_WAVBA 0x70 /* WAV */
25#define AD_DMA_WAVCA 0x74
26#define AD_DMA_WAVBC 0x78
27#define AD_DMA_WAVCC 0x7c
28#define AD_DMA_RESICC 0x80 /* RES interrupt current count */
29#define AD_DMA_RESIBC 0x84 /* RES interrupt base count */
30#define AD_DMA_ADCICC 0x88 /* ADC interrupt current count */
31#define AD_DMA_ADCIBC 0x8c /* ADC interrupt base count */
32#define AD_DMA_SYNICC 0x90 /* SYN interrupt current count */
33#define AD_DMA_SYNIBC 0x94 /* SYN interrupt base count */
34#define AD_DMA_WAVICC 0x98 /* WAV interrupt current count */
35#define AD_DMA_WAVIBC 0x9c /* WAV interrupt base count */
36#define AD_DMA_RESCTRL 0xa0 /* RES PCI control/status */
37#define AD_DMA_ADCCTRL 0xa8 /* ADC PCI control/status */
38#define AD_DMA_SYNCTRL 0xb0 /* SYN PCI control/status */
39#define AD_DMA_WAVCTRL 0xb8 /* WAV PCI control/status */
40#define AD_DMA_DISR 0xc0 /* PCI DMA intr status */
41#define AD_DMA_CHSS 0xc4 /* PCI DMA channel stop status */
42
43#define AD_GPIO_IPC 0xc8 /* IO port ctrl */
44#define AD_GPIO_OP 0xca /* IO output status */
45#define AD_GPIO_IP 0xcc /* IO input status */
46
47/* AC97 registers, 0x100 - 0x17f; see ac97.h */
48#define AD_AC97_BASE 0x100 /* ac97 base register */
49#define AD_AC97_ACIC 0x180 /* AC Link interface ctrl */
50
51/* OPL3; BAR1 */
52#define AD_OPL_M0AS 0x00 /* Music0 address/status */
53#define AD_OPL_M0DATA 0x01 /* Music0 data */
54#define AD_OPL_M1A 0x02 /* Music1 address */
55#define AD_OPL_M1DATA 0x03 /* Music1 data */
56/* 0x04-0x0f reserved */
57
58/* MIDI; BAR2 */
59#define AD_MIDA 0x00 /* MIDI data */
60#define AD_MISC 0x01 /* MIDI status/cmd */
61/* 0x02-0xff reserved */
62
63#define AD_DS_IOMEMSIZE 512
64#define AD_OPL_MEMSIZE 16
65#define AD_MIDI_MEMSIZE 16
66
67#define AD_WAV_STATE 0
68#define AD_ADC_STATE 1
69#define AD_MAX_STATES 2
70
71#define DMA_SIZE (128*1024)
72
73#define DMA_FLAG_MAPPED 1
74
75struct ad1889_dev;
76
77typedef struct ad1889_state {
78 struct ad1889_dev *card;
79
80 mode_t open_mode;
81 struct dmabuf {
82 unsigned int rate;
83 unsigned char fmt, enable;
84
85 /* buf management */
86 size_t rawbuf_size;
87 void *rawbuf;
88 dma_addr_t dma_handle; /* mapped address */
89 unsigned long dma_len; /* number of bytes mapped */
90
91 /* indexes into rawbuf for setting up DMA engine */
92 volatile unsigned long rd_ptr, wr_ptr;
93
94 wait_queue_head_t wait; /* to wait for buf servicing */
95
96 /* OSS bits */
97 unsigned int mapped:1;
98 unsigned int ready:1;
99 unsigned int ossfragshift;
100 int ossmaxfrags;
101 unsigned int subdivision;
102 } dmabuf;
103
104 struct mutex mutex;
105} ad1889_state_t;
106
107typedef struct ad1889_dev {
108 void __iomem *regbase;
109 struct pci_dev *pci;
110
111 spinlock_t lock;
112
113 int dev_audio;
114
115 /* states; one per channel; right now only WAV and ADC */
116 struct ad1889_state state[AD_MAX_STATES];
117
118 /* AC97 codec */
119 struct ac97_codec *ac97_codec;
120 u16 ac97_features;
121
122 /* debugging stuff */
123 struct stats {
124 unsigned int wav_intrs, adc_intrs;
125 unsigned int blocks, underrun, error;
126 } stats;
127} ad1889_dev_t;
128
129typedef struct ad1889_reg {
130 const char *name;
131 int offset;
132 int width;
133} ad1889_reg_t;
134
135#endif
diff --git a/sound/oss/adlib_card.c b/sound/oss/adlib_card.c
deleted file mode 100644
index c9a7c9b470d..00000000000
--- a/sound/oss/adlib_card.c
+++ /dev/null
@@ -1,73 +0,0 @@
1/*
2 * sound/oss/adlib_card.c
3 *
4 * Detection routine for the AdLib card.
5 *
6 * Copyright (C) by Hannu Savolainen 1993-1997
7 *
8 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
9 * Version 2 (June 1991). See the "COPYING" file distributed with this software
10 * for more info.
11 */
12
13#include <linux/module.h>
14#include <linux/init.h>
15
16#include "sound_config.h"
17
18#include "opl3.h"
19
20static void __init attach_adlib_card(struct address_info *hw_config)
21{
22 hw_config->slots[0] = opl3_init(hw_config->io_base, hw_config->osp, THIS_MODULE);
23}
24
25static int __init probe_adlib(struct address_info *hw_config)
26{
27 return opl3_detect(hw_config->io_base, hw_config->osp);
28}
29
30static struct address_info cfg;
31
32static int __initdata io = -1;
33
34module_param(io, int, 0);
35
36static int __init init_adlib(void)
37{
38 cfg.io_base = io;
39
40 if (cfg.io_base == -1) {
41 printk(KERN_ERR "adlib: must specify I/O address.\n");
42 return -EINVAL;
43 }
44 if (probe_adlib(&cfg) == 0)
45 return -ENODEV;
46 attach_adlib_card(&cfg);
47
48 return 0;
49}
50
51static void __exit cleanup_adlib(void)
52{
53 sound_unload_synthdev(cfg.slots[0]);
54
55}
56
57module_init(init_adlib);
58module_exit(cleanup_adlib);
59
60#ifndef MODULE
61static int __init setup_adlib(char *str)
62{
63 /* io */
64 int ints[2];
65 str = get_options(str, ARRAY_SIZE(ints), ints);
66
67 io = ints[1];
68
69 return 1;
70}
71__setup("adlib=", setup_adlib);
72#endif
73MODULE_LICENSE("GPL");
diff --git a/sound/oss/cs461x.h b/sound/oss/cs461x.h
deleted file mode 100644
index 0ce41338e6d..00000000000
--- a/sound/oss/cs461x.h
+++ /dev/null
@@ -1,1691 +0,0 @@
1#ifndef __CS461X_H
2#define __CS461X_H
3
4/*
5 * Copyright (c) by Cirrus Logic Corporation <pcaudio@crystal.cirrus.com>
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
7 * Definitions for Cirrus Logic CS461x chips
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25
26#ifndef PCI_VENDOR_ID_CIRRUS
27#define PCI_VENDOR_ID_CIRRUS 0x1013
28#endif
29#ifndef PCI_DEVICE_ID_CIRRUS_4610
30#define PCI_DEVICE_ID_CIRRUS_4610 0x6001
31#endif
32#ifndef PCI_DEVICE_ID_CIRRUS_4612
33#define PCI_DEVICE_ID_CIRRUS_4612 0x6003
34#endif
35#ifndef PCI_DEVICE_ID_CIRRUS_4615
36#define PCI_DEVICE_ID_CIRRUS_4615 0x6004
37#endif
38
39/*
40 * Direct registers
41 */
42
43/*
44 * The following define the offsets of the registers accessed via base address
45 * register zero on the CS461x part.
46 */
47#define BA0_HISR 0x00000000
48#define BA0_HSR0 0x00000004
49#define BA0_HICR 0x00000008
50#define BA0_DMSR 0x00000100
51#define BA0_HSAR 0x00000110
52#define BA0_HDAR 0x00000114
53#define BA0_HDMR 0x00000118
54#define BA0_HDCR 0x0000011C
55#define BA0_PFMC 0x00000200
56#define BA0_PFCV1 0x00000204
57#define BA0_PFCV2 0x00000208
58#define BA0_PCICFG00 0x00000300
59#define BA0_PCICFG04 0x00000304
60#define BA0_PCICFG08 0x00000308
61#define BA0_PCICFG0C 0x0000030C
62#define BA0_PCICFG10 0x00000310
63#define BA0_PCICFG14 0x00000314
64#define BA0_PCICFG18 0x00000318
65#define BA0_PCICFG1C 0x0000031C
66#define BA0_PCICFG20 0x00000320
67#define BA0_PCICFG24 0x00000324
68#define BA0_PCICFG28 0x00000328
69#define BA0_PCICFG2C 0x0000032C
70#define BA0_PCICFG30 0x00000330
71#define BA0_PCICFG34 0x00000334
72#define BA0_PCICFG38 0x00000338
73#define BA0_PCICFG3C 0x0000033C
74#define BA0_CLKCR1 0x00000400
75#define BA0_CLKCR2 0x00000404
76#define BA0_PLLM 0x00000408
77#define BA0_PLLCC 0x0000040C
78#define BA0_FRR 0x00000410
79#define BA0_CFL1 0x00000414
80#define BA0_CFL2 0x00000418
81#define BA0_SERMC1 0x00000420
82#define BA0_SERMC2 0x00000424
83#define BA0_SERC1 0x00000428
84#define BA0_SERC2 0x0000042C
85#define BA0_SERC3 0x00000430
86#define BA0_SERC4 0x00000434
87#define BA0_SERC5 0x00000438
88#define BA0_SERBSP 0x0000043C
89#define BA0_SERBST 0x00000440
90#define BA0_SERBCM 0x00000444
91#define BA0_SERBAD 0x00000448
92#define BA0_SERBCF 0x0000044C
93#define BA0_SERBWP 0x00000450
94#define BA0_SERBRP 0x00000454
95#ifndef NO_CS4612
96#define BA0_ASER_FADDR 0x00000458
97#endif
98#define BA0_ACCTL 0x00000460
99#define BA0_ACSTS 0x00000464
100#define BA0_ACOSV 0x00000468
101#define BA0_ACCAD 0x0000046C
102#define BA0_ACCDA 0x00000470
103#define BA0_ACISV 0x00000474
104#define BA0_ACSAD 0x00000478
105#define BA0_ACSDA 0x0000047C
106#define BA0_JSPT 0x00000480
107#define BA0_JSCTL 0x00000484
108#define BA0_JSC1 0x00000488
109#define BA0_JSC2 0x0000048C
110#define BA0_MIDCR 0x00000490
111#define BA0_MIDSR 0x00000494
112#define BA0_MIDWP 0x00000498
113#define BA0_MIDRP 0x0000049C
114#define BA0_JSIO 0x000004A0
115#ifndef NO_CS4612
116#define BA0_ASER_MASTER 0x000004A4
117#endif
118#define BA0_CFGI 0x000004B0
119#define BA0_SSVID 0x000004B4
120#define BA0_GPIOR 0x000004B8
121#ifndef NO_CS4612
122#define BA0_EGPIODR 0x000004BC
123#define BA0_EGPIOPTR 0x000004C0
124#define BA0_EGPIOTR 0x000004C4
125#define BA0_EGPIOWR 0x000004C8
126#define BA0_EGPIOSR 0x000004CC
127#define BA0_SERC6 0x000004D0
128#define BA0_SERC7 0x000004D4
129#define BA0_SERACC 0x000004D8
130#define BA0_ACCTL2 0x000004E0
131#define BA0_ACSTS2 0x000004E4
132#define BA0_ACOSV2 0x000004E8
133#define BA0_ACCAD2 0x000004EC
134#define BA0_ACCDA2 0x000004F0
135#define BA0_ACISV2 0x000004F4
136#define BA0_ACSAD2 0x000004F8
137#define BA0_ACSDA2 0x000004FC
138#define BA0_IOTAC0 0x00000500
139#define BA0_IOTAC1 0x00000504
140#define BA0_IOTAC2 0x00000508
141#define BA0_IOTAC3 0x0000050C
142#define BA0_IOTAC4 0x00000510
143#define BA0_IOTAC5 0x00000514
144#define BA0_IOTAC6 0x00000518
145#define BA0_IOTAC7 0x0000051C
146#define BA0_IOTAC8 0x00000520
147#define BA0_IOTAC9 0x00000524
148#define BA0_IOTAC10 0x00000528
149#define BA0_IOTAC11 0x0000052C
150#define BA0_IOTFR0 0x00000540
151#define BA0_IOTFR1 0x00000544
152#define BA0_IOTFR2 0x00000548
153#define BA0_IOTFR3 0x0000054C
154#define BA0_IOTFR4 0x00000550
155#define BA0_IOTFR5 0x00000554
156#define BA0_IOTFR6 0x00000558
157#define BA0_IOTFR7 0x0000055C
158#define BA0_IOTFIFO 0x00000580
159#define BA0_IOTRRD 0x00000584
160#define BA0_IOTFP 0x00000588
161#define BA0_IOTCR 0x0000058C
162#define BA0_DPCID 0x00000590
163#define BA0_DPCIA 0x00000594
164#define BA0_DPCIC 0x00000598
165#define BA0_PCPCIR 0x00000600
166#define BA0_PCPCIG 0x00000604
167#define BA0_PCPCIEN 0x00000608
168#define BA0_EPCIPMC 0x00000610
169#endif
170
171/*
172 * The following define the offsets of the registers and memories accessed via
173 * base address register one on the CS461x part.
174 */
175#define BA1_SP_DMEM0 0x00000000
176#define BA1_SP_DMEM1 0x00010000
177#define BA1_SP_PMEM 0x00020000
178#define BA1_SP_REG 0x00030000
179#define BA1_SPCR 0x00030000
180#define BA1_DREG 0x00030004
181#define BA1_DSRWP 0x00030008
182#define BA1_TWPR 0x0003000C
183#define BA1_SPWR 0x00030010
184#define BA1_SPIR 0x00030014
185#define BA1_FGR1 0x00030020
186#define BA1_SPCS 0x00030028
187#define BA1_SDSR 0x0003002C
188#define BA1_FRMT 0x00030030
189#define BA1_FRCC 0x00030034
190#define BA1_FRSC 0x00030038
191#define BA1_OMNI_MEM 0x000E0000
192
193/*
194 * The following defines are for the flags in the host interrupt status
195 * register.
196 */
197#define HISR_VC_MASK 0x0000FFFF
198#define HISR_VC0 0x00000001
199#define HISR_VC1 0x00000002
200#define HISR_VC2 0x00000004
201#define HISR_VC3 0x00000008
202#define HISR_VC4 0x00000010
203#define HISR_VC5 0x00000020
204#define HISR_VC6 0x00000040
205#define HISR_VC7 0x00000080
206#define HISR_VC8 0x00000100
207#define HISR_VC9 0x00000200
208#define HISR_VC10 0x00000400
209#define HISR_VC11 0x00000800
210#define HISR_VC12 0x00001000
211#define HISR_VC13 0x00002000
212#define HISR_VC14 0x00004000
213#define HISR_VC15 0x00008000
214#define HISR_INT0 0x00010000
215#define HISR_INT1 0x00020000
216#define HISR_DMAI 0x00040000
217#define HISR_FROVR 0x00080000
218#define HISR_MIDI 0x00100000
219#ifdef NO_CS4612
220#define HISR_RESERVED 0x0FE00000
221#else
222#define HISR_SBINT 0x00200000
223#define HISR_RESERVED 0x0FC00000
224#endif
225#define HISR_H0P 0x40000000
226#define HISR_INTENA 0x80000000
227
228/*
229 * The following defines are for the flags in the host signal register 0.
230 */
231#define HSR0_VC_MASK 0xFFFFFFFF
232#define HSR0_VC16 0x00000001
233#define HSR0_VC17 0x00000002
234#define HSR0_VC18 0x00000004
235#define HSR0_VC19 0x00000008
236#define HSR0_VC20 0x00000010
237#define HSR0_VC21 0x00000020
238#define HSR0_VC22 0x00000040
239#define HSR0_VC23 0x00000080
240#define HSR0_VC24 0x00000100
241#define HSR0_VC25 0x00000200
242#define HSR0_VC26 0x00000400
243#define HSR0_VC27 0x00000800
244#define HSR0_VC28 0x00001000
245#define HSR0_VC29 0x00002000
246#define HSR0_VC30 0x00004000
247#define HSR0_VC31 0x00008000
248#define HSR0_VC32 0x00010000
249#define HSR0_VC33 0x00020000
250#define HSR0_VC34 0x00040000
251#define HSR0_VC35 0x00080000
252#define HSR0_VC36 0x00100000
253#define HSR0_VC37 0x00200000
254#define HSR0_VC38 0x00400000
255#define HSR0_VC39 0x00800000
256#define HSR0_VC40 0x01000000
257#define HSR0_VC41 0x02000000
258#define HSR0_VC42 0x04000000
259#define HSR0_VC43 0x08000000
260#define HSR0_VC44 0x10000000
261#define HSR0_VC45 0x20000000
262#define HSR0_VC46 0x40000000
263#define HSR0_VC47 0x80000000
264
265/*
266 * The following defines are for the flags in the host interrupt control
267 * register.
268 */
269#define HICR_IEV 0x00000001
270#define HICR_CHGM 0x00000002
271
272/*
273 * The following defines are for the flags in the DMA status register.
274 */
275#define DMSR_HP 0x00000001
276#define DMSR_HR 0x00000002
277#define DMSR_SP 0x00000004
278#define DMSR_SR 0x00000008
279
280/*
281 * The following defines are for the flags in the host DMA source address
282 * register.
283 */
284#define HSAR_HOST_ADDR_MASK 0xFFFFFFFF
285#define HSAR_DSP_ADDR_MASK 0x0000FFFF
286#define HSAR_MEMID_MASK 0x000F0000
287#define HSAR_MEMID_SP_DMEM0 0x00000000
288#define HSAR_MEMID_SP_DMEM1 0x00010000
289#define HSAR_MEMID_SP_PMEM 0x00020000
290#define HSAR_MEMID_SP_DEBUG 0x00030000
291#define HSAR_MEMID_OMNI_MEM 0x000E0000
292#define HSAR_END 0x40000000
293#define HSAR_ERR 0x80000000
294
295/*
296 * The following defines are for the flags in the host DMA destination address
297 * register.
298 */
299#define HDAR_HOST_ADDR_MASK 0xFFFFFFFF
300#define HDAR_DSP_ADDR_MASK 0x0000FFFF
301#define HDAR_MEMID_MASK 0x000F0000
302#define HDAR_MEMID_SP_DMEM0 0x00000000
303#define HDAR_MEMID_SP_DMEM1 0x00010000
304#define HDAR_MEMID_SP_PMEM 0x00020000
305#define HDAR_MEMID_SP_DEBUG 0x00030000
306#define HDAR_MEMID_OMNI_MEM 0x000E0000
307#define HDAR_END 0x40000000
308#define HDAR_ERR 0x80000000
309
310/*
311 * The following defines are for the flags in the host DMA control register.
312 */
313#define HDMR_AC_MASK 0x0000F000
314#define HDMR_AC_8_16 0x00001000
315#define HDMR_AC_M_S 0x00002000
316#define HDMR_AC_B_L 0x00004000
317#define HDMR_AC_S_U 0x00008000
318
319/*
320 * The following defines are for the flags in the host DMA control register.
321 */
322#define HDCR_COUNT_MASK 0x000003FF
323#define HDCR_DONE 0x00004000
324#define HDCR_OPT 0x00008000
325#define HDCR_WBD 0x00400000
326#define HDCR_WBS 0x00800000
327#define HDCR_DMS_MASK 0x07000000
328#define HDCR_DMS_LINEAR 0x00000000
329#define HDCR_DMS_16_DWORDS 0x01000000
330#define HDCR_DMS_32_DWORDS 0x02000000
331#define HDCR_DMS_64_DWORDS 0x03000000
332#define HDCR_DMS_128_DWORDS 0x04000000
333#define HDCR_DMS_256_DWORDS 0x05000000
334#define HDCR_DMS_512_DWORDS 0x06000000
335#define HDCR_DMS_1024_DWORDS 0x07000000
336#define HDCR_DH 0x08000000
337#define HDCR_SMS_MASK 0x70000000
338#define HDCR_SMS_LINEAR 0x00000000
339#define HDCR_SMS_16_DWORDS 0x10000000
340#define HDCR_SMS_32_DWORDS 0x20000000
341#define HDCR_SMS_64_DWORDS 0x30000000
342#define HDCR_SMS_128_DWORDS 0x40000000
343#define HDCR_SMS_256_DWORDS 0x50000000
344#define HDCR_SMS_512_DWORDS 0x60000000
345#define HDCR_SMS_1024_DWORDS 0x70000000
346#define HDCR_SH 0x80000000
347#define HDCR_COUNT_SHIFT 0
348
349/*
350 * The following defines are for the flags in the performance monitor control
351 * register.
352 */
353#define PFMC_C1SS_MASK 0x0000001F
354#define PFMC_C1EV 0x00000020
355#define PFMC_C1RS 0x00008000
356#define PFMC_C2SS_MASK 0x001F0000
357#define PFMC_C2EV 0x00200000
358#define PFMC_C2RS 0x80000000
359#define PFMC_C1SS_SHIFT 0
360#define PFMC_C2SS_SHIFT 16
361#define PFMC_BUS_GRANT 0
362#define PFMC_GRANT_AFTER_REQ 1
363#define PFMC_TRANSACTION 2
364#define PFMC_DWORD_TRANSFER 3
365#define PFMC_SLAVE_READ 4
366#define PFMC_SLAVE_WRITE 5
367#define PFMC_PREEMPTION 6
368#define PFMC_DISCONNECT_RETRY 7
369#define PFMC_INTERRUPT 8
370#define PFMC_BUS_OWNERSHIP 9
371#define PFMC_TRANSACTION_LAG 10
372#define PFMC_PCI_CLOCK 11
373#define PFMC_SERIAL_CLOCK 12
374#define PFMC_SP_CLOCK 13
375
376/*
377 * The following defines are for the flags in the performance counter value 1
378 * register.
379 */
380#define PFCV1_PC1V_MASK 0xFFFFFFFF
381#define PFCV1_PC1V_SHIFT 0
382
383/*
384 * The following defines are for the flags in the performance counter value 2
385 * register.
386 */
387#define PFCV2_PC2V_MASK 0xFFFFFFFF
388#define PFCV2_PC2V_SHIFT 0
389
390/*
391 * The following defines are for the flags in the clock control register 1.
392 */
393#define CLKCR1_OSCS 0x00000001
394#define CLKCR1_OSCP 0x00000002
395#define CLKCR1_PLLSS_MASK 0x0000000C
396#define CLKCR1_PLLSS_SERIAL 0x00000000
397#define CLKCR1_PLLSS_CRYSTAL 0x00000004
398#define CLKCR1_PLLSS_PCI 0x00000008
399#define CLKCR1_PLLSS_RESERVED 0x0000000C
400#define CLKCR1_PLLP 0x00000010
401#define CLKCR1_SWCE 0x00000020
402#define CLKCR1_PLLOS 0x00000040
403
404/*
405 * The following defines are for the flags in the clock control register 2.
406 */
407#define CLKCR2_PDIVS_MASK 0x0000000F
408#define CLKCR2_PDIVS_1 0x00000001
409#define CLKCR2_PDIVS_2 0x00000002
410#define CLKCR2_PDIVS_4 0x00000004
411#define CLKCR2_PDIVS_7 0x00000007
412#define CLKCR2_PDIVS_8 0x00000008
413#define CLKCR2_PDIVS_16 0x00000000
414
415/*
416 * The following defines are for the flags in the PLL multiplier register.
417 */
418#define PLLM_MASK 0x000000FF
419#define PLLM_SHIFT 0
420
421/*
422 * The following defines are for the flags in the PLL capacitor coefficient
423 * register.
424 */
425#define PLLCC_CDR_MASK 0x00000007
426#ifndef NO_CS4610
427#define PLLCC_CDR_240_350_MHZ 0x00000000
428#define PLLCC_CDR_184_265_MHZ 0x00000001
429#define PLLCC_CDR_144_205_MHZ 0x00000002
430#define PLLCC_CDR_111_160_MHZ 0x00000003
431#define PLLCC_CDR_87_123_MHZ 0x00000004
432#define PLLCC_CDR_67_96_MHZ 0x00000005
433#define PLLCC_CDR_52_74_MHZ 0x00000006
434#define PLLCC_CDR_45_58_MHZ 0x00000007
435#endif
436#ifndef NO_CS4612
437#define PLLCC_CDR_271_398_MHZ 0x00000000
438#define PLLCC_CDR_227_330_MHZ 0x00000001
439#define PLLCC_CDR_167_239_MHZ 0x00000002
440#define PLLCC_CDR_150_215_MHZ 0x00000003
441#define PLLCC_CDR_107_154_MHZ 0x00000004
442#define PLLCC_CDR_98_140_MHZ 0x00000005
443#define PLLCC_CDR_73_104_MHZ 0x00000006
444#define PLLCC_CDR_63_90_MHZ 0x00000007
445#endif
446#define PLLCC_LPF_MASK 0x000000F8
447#ifndef NO_CS4610
448#define PLLCC_LPF_23850_60000_KHZ 0x00000000
449#define PLLCC_LPF_7960_26290_KHZ 0x00000008
450#define PLLCC_LPF_4160_10980_KHZ 0x00000018
451#define PLLCC_LPF_1740_4580_KHZ 0x00000038
452#define PLLCC_LPF_724_1910_KHZ 0x00000078
453#define PLLCC_LPF_317_798_KHZ 0x000000F8
454#endif
455#ifndef NO_CS4612
456#define PLLCC_LPF_25580_64530_KHZ 0x00000000
457#define PLLCC_LPF_14360_37270_KHZ 0x00000008
458#define PLLCC_LPF_6100_16020_KHZ 0x00000018
459#define PLLCC_LPF_2540_6690_KHZ 0x00000038
460#define PLLCC_LPF_1050_2780_KHZ 0x00000078
461#define PLLCC_LPF_450_1160_KHZ 0x000000F8
462#endif
463
464/*
465 * The following defines are for the flags in the feature reporting register.
466 */
467#define FRR_FAB_MASK 0x00000003
468#define FRR_MASK_MASK 0x0000001C
469#ifdef NO_CS4612
470#define FRR_CFOP_MASK 0x000000E0
471#else
472#define FRR_CFOP_MASK 0x00000FE0
473#endif
474#define FRR_CFOP_NOT_DVD 0x00000020
475#define FRR_CFOP_A3D 0x00000040
476#define FRR_CFOP_128_PIN 0x00000080
477#ifndef NO_CS4612
478#define FRR_CFOP_CS4280 0x00000800
479#endif
480#define FRR_FAB_SHIFT 0
481#define FRR_MASK_SHIFT 2
482#define FRR_CFOP_SHIFT 5
483
484/*
485 * The following defines are for the flags in the configuration load 1
486 * register.
487 */
488#define CFL1_CLOCK_SOURCE_MASK 0x00000003
489#define CFL1_CLOCK_SOURCE_CS423X 0x00000000
490#define CFL1_CLOCK_SOURCE_AC97 0x00000001
491#define CFL1_CLOCK_SOURCE_CRYSTAL 0x00000002
492#define CFL1_CLOCK_SOURCE_DUAL_AC97 0x00000003
493#define CFL1_VALID_DATA_MASK 0x000000FF
494
495/*
496 * The following defines are for the flags in the configuration load 2
497 * register.
498 */
499#define CFL2_VALID_DATA_MASK 0x000000FF
500
501/*
502 * The following defines are for the flags in the serial port master control
503 * register 1.
504 */
505#define SERMC1_MSPE 0x00000001
506#define SERMC1_PTC_MASK 0x0000000E
507#define SERMC1_PTC_CS423X 0x00000000
508#define SERMC1_PTC_AC97 0x00000002
509#define SERMC1_PTC_DAC 0x00000004
510#define SERMC1_PLB 0x00000010
511#define SERMC1_XLB 0x00000020
512
513/*
514 * The following defines are for the flags in the serial port master control
515 * register 2.
516 */
517#define SERMC2_LROE 0x00000001
518#define SERMC2_MCOE 0x00000002
519#define SERMC2_MCDIV 0x00000004
520
521/*
522 * The following defines are for the flags in the serial port 1 configuration
523 * register.
524 */
525#define SERC1_SO1EN 0x00000001
526#define SERC1_SO1F_MASK 0x0000000E
527#define SERC1_SO1F_CS423X 0x00000000
528#define SERC1_SO1F_AC97 0x00000002
529#define SERC1_SO1F_DAC 0x00000004
530#define SERC1_SO1F_SPDIF 0x00000006
531
532/*
533 * The following defines are for the flags in the serial port 2 configuration
534 * register.
535 */
536#define SERC2_SI1EN 0x00000001
537#define SERC2_SI1F_MASK 0x0000000E
538#define SERC2_SI1F_CS423X 0x00000000
539#define SERC2_SI1F_AC97 0x00000002
540#define SERC2_SI1F_ADC 0x00000004
541#define SERC2_SI1F_SPDIF 0x00000006
542
543/*
544 * The following defines are for the flags in the serial port 3 configuration
545 * register.
546 */
547#define SERC3_SO2EN 0x00000001
548#define SERC3_SO2F_MASK 0x00000006
549#define SERC3_SO2F_DAC 0x00000000
550#define SERC3_SO2F_SPDIF 0x00000002
551
552/*
553 * The following defines are for the flags in the serial port 4 configuration
554 * register.
555 */
556#define SERC4_SO3EN 0x00000001
557#define SERC4_SO3F_MASK 0x00000006
558#define SERC4_SO3F_DAC 0x00000000
559#define SERC4_SO3F_SPDIF 0x00000002
560
561/*
562 * The following defines are for the flags in the serial port 5 configuration
563 * register.
564 */
565#define SERC5_SI2EN 0x00000001
566#define SERC5_SI2F_MASK 0x00000006
567#define SERC5_SI2F_ADC 0x00000000
568#define SERC5_SI2F_SPDIF 0x00000002
569
570/*
571 * The following defines are for the flags in the serial port backdoor sample
572 * pointer register.
573 */
574#define SERBSP_FSP_MASK 0x0000000F
575#define SERBSP_FSP_SHIFT 0
576
577/*
578 * The following defines are for the flags in the serial port backdoor status
579 * register.
580 */
581#define SERBST_RRDY 0x00000001
582#define SERBST_WBSY 0x00000002
583
584/*
585 * The following defines are for the flags in the serial port backdoor command
586 * register.
587 */
588#define SERBCM_RDC 0x00000001
589#define SERBCM_WRC 0x00000002
590
591/*
592 * The following defines are for the flags in the serial port backdoor address
593 * register.
594 */
595#ifdef NO_CS4612
596#define SERBAD_FAD_MASK 0x000000FF
597#else
598#define SERBAD_FAD_MASK 0x000001FF
599#endif
600#define SERBAD_FAD_SHIFT 0
601
602/*
603 * The following defines are for the flags in the serial port backdoor
604 * configuration register.
605 */
606#define SERBCF_HBP 0x00000001
607
608/*
609 * The following defines are for the flags in the serial port backdoor write
610 * port register.
611 */
612#define SERBWP_FWD_MASK 0x000FFFFF
613#define SERBWP_FWD_SHIFT 0
614
615/*
616 * The following defines are for the flags in the serial port backdoor read
617 * port register.
618 */
619#define SERBRP_FRD_MASK 0x000FFFFF
620#define SERBRP_FRD_SHIFT 0
621
622/*
623 * The following defines are for the flags in the async FIFO address register.
624 */
625#ifndef NO_CS4612
626#define ASER_FADDR_A1_MASK 0x000001FF
627#define ASER_FADDR_EN1 0x00008000
628#define ASER_FADDR_A2_MASK 0x01FF0000
629#define ASER_FADDR_EN2 0x80000000
630#define ASER_FADDR_A1_SHIFT 0
631#define ASER_FADDR_A2_SHIFT 16
632#endif
633
634/*
635 * The following defines are for the flags in the AC97 control register.
636 */
637#define ACCTL_RSTN 0x00000001
638#define ACCTL_ESYN 0x00000002
639#define ACCTL_VFRM 0x00000004
640#define ACCTL_DCV 0x00000008
641#define ACCTL_CRW 0x00000010
642#define ACCTL_ASYN 0x00000020
643#ifndef NO_CS4612
644#define ACCTL_TC 0x00000040
645#endif
646
647/*
648 * The following defines are for the flags in the AC97 status register.
649 */
650#define ACSTS_CRDY 0x00000001
651#define ACSTS_VSTS 0x00000002
652#ifndef NO_CS4612
653#define ACSTS_WKUP 0x00000004
654#endif
655
656/*
657 * The following defines are for the flags in the AC97 output slot valid
658 * register.
659 */
660#define ACOSV_SLV3 0x00000001
661#define ACOSV_SLV4 0x00000002
662#define ACOSV_SLV5 0x00000004
663#define ACOSV_SLV6 0x00000008
664#define ACOSV_SLV7 0x00000010
665#define ACOSV_SLV8 0x00000020
666#define ACOSV_SLV9 0x00000040
667#define ACOSV_SLV10 0x00000080
668#define ACOSV_SLV11 0x00000100
669#define ACOSV_SLV12 0x00000200
670
671/*
672 * The following defines are for the flags in the AC97 command address
673 * register.
674 */
675#define ACCAD_CI_MASK 0x0000007F
676#define ACCAD_CI_SHIFT 0
677
678/*
679 * The following defines are for the flags in the AC97 command data register.
680 */
681#define ACCDA_CD_MASK 0x0000FFFF
682#define ACCDA_CD_SHIFT 0
683
684/*
685 * The following defines are for the flags in the AC97 input slot valid
686 * register.
687 */
688#define ACISV_ISV3 0x00000001
689#define ACISV_ISV4 0x00000002
690#define ACISV_ISV5 0x00000004
691#define ACISV_ISV6 0x00000008
692#define ACISV_ISV7 0x00000010
693#define ACISV_ISV8 0x00000020
694#define ACISV_ISV9 0x00000040
695#define ACISV_ISV10 0x00000080
696#define ACISV_ISV11 0x00000100
697#define ACISV_ISV12 0x00000200
698
699/*
700 * The following defines are for the flags in the AC97 status address
701 * register.
702 */
703#define ACSAD_SI_MASK 0x0000007F
704#define ACSAD_SI_SHIFT 0
705
706/*
707 * The following defines are for the flags in the AC97 status data register.
708 */
709#define ACSDA_SD_MASK 0x0000FFFF
710#define ACSDA_SD_SHIFT 0
711
712/*
713 * The following defines are for the flags in the joystick poll/trigger
714 * register.
715 */
716#define JSPT_CAX 0x00000001
717#define JSPT_CAY 0x00000002
718#define JSPT_CBX 0x00000004
719#define JSPT_CBY 0x00000008
720#define JSPT_BA1 0x00000010
721#define JSPT_BA2 0x00000020
722#define JSPT_BB1 0x00000040
723#define JSPT_BB2 0x00000080
724
725/*
726 * The following defines are for the flags in the joystick control register.
727 */
728#define JSCTL_SP_MASK 0x00000003
729#define JSCTL_SP_SLOW 0x00000000
730#define JSCTL_SP_MEDIUM_SLOW 0x00000001
731#define JSCTL_SP_MEDIUM_FAST 0x00000002
732#define JSCTL_SP_FAST 0x00000003
733#define JSCTL_ARE 0x00000004
734
735/*
736 * The following defines are for the flags in the joystick coordinate pair 1
737 * readback register.
738 */
739#define JSC1_Y1V_MASK 0x0000FFFF
740#define JSC1_X1V_MASK 0xFFFF0000
741#define JSC1_Y1V_SHIFT 0
742#define JSC1_X1V_SHIFT 16
743
744/*
745 * The following defines are for the flags in the joystick coordinate pair 2
746 * readback register.
747 */
748#define JSC2_Y2V_MASK 0x0000FFFF
749#define JSC2_X2V_MASK 0xFFFF0000
750#define JSC2_Y2V_SHIFT 0
751#define JSC2_X2V_SHIFT 16
752
753/*
754 * The following defines are for the flags in the MIDI control register.
755 */
756#define MIDCR_TXE 0x00000001 /* Enable transmitting. */
757#define MIDCR_RXE 0x00000002 /* Enable receiving. */
758#define MIDCR_RIE 0x00000004 /* Interrupt upon tx ready. */
759#define MIDCR_TIE 0x00000008 /* Interrupt upon rx ready. */
760#define MIDCR_MLB 0x00000010 /* Enable midi loopback. */
761#define MIDCR_MRST 0x00000020 /* Reset interface. */
762
763/*
764 * The following defines are for the flags in the MIDI status register.
765 */
766#define MIDSR_TBF 0x00000001 /* Tx FIFO is full. */
767#define MIDSR_RBE 0x00000002 /* Rx FIFO is empty. */
768
769/*
770 * The following defines are for the flags in the MIDI write port register.
771 */
772#define MIDWP_MWD_MASK 0x000000FF
773#define MIDWP_MWD_SHIFT 0
774
775/*
776 * The following defines are for the flags in the MIDI read port register.
777 */
778#define MIDRP_MRD_MASK 0x000000FF
779#define MIDRP_MRD_SHIFT 0
780
781/*
782 * The following defines are for the flags in the joystick GPIO register.
783 */
784#define JSIO_DAX 0x00000001
785#define JSIO_DAY 0x00000002
786#define JSIO_DBX 0x00000004
787#define JSIO_DBY 0x00000008
788#define JSIO_AXOE 0x00000010
789#define JSIO_AYOE 0x00000020
790#define JSIO_BXOE 0x00000040
791#define JSIO_BYOE 0x00000080
792
793/*
794 * The following defines are for the flags in the master async/sync serial
795 * port enable register.
796 */
797#ifndef NO_CS4612
798#define ASER_MASTER_ME 0x00000001
799#endif
800
801/*
802 * The following defines are for the flags in the configuration interface
803 * register.
804 */
805#define CFGI_CLK 0x00000001
806#define CFGI_DOUT 0x00000002
807#define CFGI_DIN_EEN 0x00000004
808#define CFGI_EELD 0x00000008
809
810/*
811 * The following defines are for the flags in the subsystem ID and vendor ID
812 * register.
813 */
814#define SSVID_VID_MASK 0x0000FFFF
815#define SSVID_SID_MASK 0xFFFF0000
816#define SSVID_VID_SHIFT 0
817#define SSVID_SID_SHIFT 16
818
819/*
820 * The following defines are for the flags in the GPIO pin interface register.
821 */
822#define GPIOR_VOLDN 0x00000001
823#define GPIOR_VOLUP 0x00000002
824#define GPIOR_SI2D 0x00000004
825#define GPIOR_SI2OE 0x00000008
826
827/*
828 * The following defines are for the flags in the extended GPIO pin direction
829 * register.
830 */
831#ifndef NO_CS4612
832#define EGPIODR_GPOE0 0x00000001
833#define EGPIODR_GPOE1 0x00000002
834#define EGPIODR_GPOE2 0x00000004
835#define EGPIODR_GPOE3 0x00000008
836#define EGPIODR_GPOE4 0x00000010
837#define EGPIODR_GPOE5 0x00000020
838#define EGPIODR_GPOE6 0x00000040
839#define EGPIODR_GPOE7 0x00000080
840#define EGPIODR_GPOE8 0x00000100
841#endif
842
843/*
844 * The following defines are for the flags in the extended GPIO pin polarity/
845 * type register.
846 */
847#ifndef NO_CS4612
848#define EGPIOPTR_GPPT0 0x00000001
849#define EGPIOPTR_GPPT1 0x00000002
850#define EGPIOPTR_GPPT2 0x00000004
851#define EGPIOPTR_GPPT3 0x00000008
852#define EGPIOPTR_GPPT4 0x00000010
853#define EGPIOPTR_GPPT5 0x00000020
854#define EGPIOPTR_GPPT6 0x00000040
855#define EGPIOPTR_GPPT7 0x00000080
856#define EGPIOPTR_GPPT8 0x00000100
857#endif
858
859/*
860 * The following defines are for the flags in the extended GPIO pin sticky
861 * register.
862 */
863#ifndef NO_CS4612
864#define EGPIOTR_GPS0 0x00000001
865#define EGPIOTR_GPS1 0x00000002
866#define EGPIOTR_GPS2 0x00000004
867#define EGPIOTR_GPS3 0x00000008
868#define EGPIOTR_GPS4 0x00000010
869#define EGPIOTR_GPS5 0x00000020
870#define EGPIOTR_GPS6 0x00000040
871#define EGPIOTR_GPS7 0x00000080
872#define EGPIOTR_GPS8 0x00000100
873#endif
874
875/*
876 * The following defines are for the flags in the extended GPIO ping wakeup
877 * register.
878 */
879#ifndef NO_CS4612
880#define EGPIOWR_GPW0 0x00000001
881#define EGPIOWR_GPW1 0x00000002
882#define EGPIOWR_GPW2 0x00000004
883#define EGPIOWR_GPW3 0x00000008
884#define EGPIOWR_GPW4 0x00000010
885#define EGPIOWR_GPW5 0x00000020
886#define EGPIOWR_GPW6 0x00000040
887#define EGPIOWR_GPW7 0x00000080
888#define EGPIOWR_GPW8 0x00000100
889#endif
890
891/*
892 * The following defines are for the flags in the extended GPIO pin status
893 * register.
894 */
895#ifndef NO_CS4612
896#define EGPIOSR_GPS0 0x00000001
897#define EGPIOSR_GPS1 0x00000002
898#define EGPIOSR_GPS2 0x00000004
899#define EGPIOSR_GPS3 0x00000008
900#define EGPIOSR_GPS4 0x00000010
901#define EGPIOSR_GPS5 0x00000020
902#define EGPIOSR_GPS6 0x00000040
903#define EGPIOSR_GPS7 0x00000080
904#define EGPIOSR_GPS8 0x00000100
905#endif
906
907/*
908 * The following defines are for the flags in the serial port 6 configuration
909 * register.
910 */
911#ifndef NO_CS4612
912#define SERC6_ASDO2EN 0x00000001
913#endif
914
915/*
916 * The following defines are for the flags in the serial port 7 configuration
917 * register.
918 */
919#ifndef NO_CS4612
920#define SERC7_ASDI2EN 0x00000001
921#define SERC7_POSILB 0x00000002
922#define SERC7_SIPOLB 0x00000004
923#define SERC7_SOSILB 0x00000008
924#define SERC7_SISOLB 0x00000010
925#endif
926
927/*
928 * The following defines are for the flags in the serial port AC link
929 * configuration register.
930 */
931#ifndef NO_CS4612
932#define SERACC_CODEC_TYPE_MASK 0x00000001
933#define SERACC_CODEC_TYPE_1_03 0x00000000
934#define SERACC_CODEC_TYPE_2_0 0x00000001
935#define SERACC_TWO_CODECS 0x00000002
936#define SERACC_MDM 0x00000004
937#define SERACC_HSP 0x00000008
938#endif
939
940/*
941 * The following defines are for the flags in the AC97 control register 2.
942 */
943#ifndef NO_CS4612
944#define ACCTL2_RSTN 0x00000001
945#define ACCTL2_ESYN 0x00000002
946#define ACCTL2_VFRM 0x00000004
947#define ACCTL2_DCV 0x00000008
948#define ACCTL2_CRW 0x00000010
949#define ACCTL2_ASYN 0x00000020
950#endif
951
952/*
953 * The following defines are for the flags in the AC97 status register 2.
954 */
955#ifndef NO_CS4612
956#define ACSTS2_CRDY 0x00000001
957#define ACSTS2_VSTS 0x00000002
958#endif
959
960/*
961 * The following defines are for the flags in the AC97 output slot valid
962 * register 2.
963 */
964#ifndef NO_CS4612
965#define ACOSV2_SLV3 0x00000001
966#define ACOSV2_SLV4 0x00000002
967#define ACOSV2_SLV5 0x00000004
968#define ACOSV2_SLV6 0x00000008
969#define ACOSV2_SLV7 0x00000010
970#define ACOSV2_SLV8 0x00000020
971#define ACOSV2_SLV9 0x00000040
972#define ACOSV2_SLV10 0x00000080
973#define ACOSV2_SLV11 0x00000100
974#define ACOSV2_SLV12 0x00000200
975#endif
976
977/*
978 * The following defines are for the flags in the AC97 command address
979 * register 2.
980 */
981#ifndef NO_CS4612
982#define ACCAD2_CI_MASK 0x0000007F
983#define ACCAD2_CI_SHIFT 0
984#endif
985
986/*
987 * The following defines are for the flags in the AC97 command data register
988 * 2.
989 */
990#ifndef NO_CS4612
991#define ACCDA2_CD_MASK 0x0000FFFF
992#define ACCDA2_CD_SHIFT 0
993#endif
994
995/*
996 * The following defines are for the flags in the AC97 input slot valid
997 * register 2.
998 */
999#ifndef NO_CS4612
1000#define ACISV2_ISV3 0x00000001
1001#define ACISV2_ISV4 0x00000002
1002#define ACISV2_ISV5 0x00000004
1003#define ACISV2_ISV6 0x00000008
1004#define ACISV2_ISV7 0x00000010
1005#define ACISV2_ISV8 0x00000020
1006#define ACISV2_ISV9 0x00000040
1007#define ACISV2_ISV10 0x00000080
1008#define ACISV2_ISV11 0x00000100
1009#define ACISV2_ISV12 0x00000200
1010#endif
1011
1012/*
1013 * The following defines are for the flags in the AC97 status address
1014 * register 2.
1015 */
1016#ifndef NO_CS4612
1017#define ACSAD2_SI_MASK 0x0000007F
1018#define ACSAD2_SI_SHIFT 0
1019#endif
1020
1021/*
1022 * The following defines are for the flags in the AC97 status data register 2.
1023 */
1024#ifndef NO_CS4612
1025#define ACSDA2_SD_MASK 0x0000FFFF
1026#define ACSDA2_SD_SHIFT 0
1027#endif
1028
1029/*
1030 * The following defines are for the flags in the I/O trap address and control
1031 * registers (all 12).
1032 */
1033#ifndef NO_CS4612
1034#define IOTAC_SA_MASK 0x0000FFFF
1035#define IOTAC_MSK_MASK 0x000F0000
1036#define IOTAC_IODC_MASK 0x06000000
1037#define IOTAC_IODC_16_BIT 0x00000000
1038#define IOTAC_IODC_10_BIT 0x02000000
1039#define IOTAC_IODC_12_BIT 0x04000000
1040#define IOTAC_WSPI 0x08000000
1041#define IOTAC_RSPI 0x10000000
1042#define IOTAC_WSE 0x20000000
1043#define IOTAC_WE 0x40000000
1044#define IOTAC_RE 0x80000000
1045#define IOTAC_SA_SHIFT 0
1046#define IOTAC_MSK_SHIFT 16
1047#endif
1048
1049/*
1050 * The following defines are for the flags in the I/O trap fast read registers
1051 * (all 8).
1052 */
1053#ifndef NO_CS4612
1054#define IOTFR_D_MASK 0x0000FFFF
1055#define IOTFR_A_MASK 0x000F0000
1056#define IOTFR_R_MASK 0x0F000000
1057#define IOTFR_ALL 0x40000000
1058#define IOTFR_VL 0x80000000
1059#define IOTFR_D_SHIFT 0
1060#define IOTFR_A_SHIFT 16
1061#define IOTFR_R_SHIFT 24
1062#endif
1063
1064/*
1065 * The following defines are for the flags in the I/O trap FIFO register.
1066 */
1067#ifndef NO_CS4612
1068#define IOTFIFO_BA_MASK 0x00003FFF
1069#define IOTFIFO_S_MASK 0x00FF0000
1070#define IOTFIFO_OF 0x40000000
1071#define IOTFIFO_SPIOF 0x80000000
1072#define IOTFIFO_BA_SHIFT 0
1073#define IOTFIFO_S_SHIFT 16
1074#endif
1075
1076/*
1077 * The following defines are for the flags in the I/O trap retry read data
1078 * register.
1079 */
1080#ifndef NO_CS4612
1081#define IOTRRD_D_MASK 0x0000FFFF
1082#define IOTRRD_RDV 0x80000000
1083#define IOTRRD_D_SHIFT 0
1084#endif
1085
1086/*
1087 * The following defines are for the flags in the I/O trap FIFO pointer
1088 * register.
1089 */
1090#ifndef NO_CS4612
1091#define IOTFP_CA_MASK 0x00003FFF
1092#define IOTFP_PA_MASK 0x3FFF0000
1093#define IOTFP_CA_SHIFT 0
1094#define IOTFP_PA_SHIFT 16
1095#endif
1096
1097/*
1098 * The following defines are for the flags in the I/O trap control register.
1099 */
1100#ifndef NO_CS4612
1101#define IOTCR_ITD 0x00000001
1102#define IOTCR_HRV 0x00000002
1103#define IOTCR_SRV 0x00000004
1104#define IOTCR_DTI 0x00000008
1105#define IOTCR_DFI 0x00000010
1106#define IOTCR_DDP 0x00000020
1107#define IOTCR_JTE 0x00000040
1108#define IOTCR_PPE 0x00000080
1109#endif
1110
1111/*
1112 * The following defines are for the flags in the direct PCI data register.
1113 */
1114#ifndef NO_CS4612
1115#define DPCID_D_MASK 0xFFFFFFFF
1116#define DPCID_D_SHIFT 0
1117#endif
1118
1119/*
1120 * The following defines are for the flags in the direct PCI address register.
1121 */
1122#ifndef NO_CS4612
1123#define DPCIA_A_MASK 0xFFFFFFFF
1124#define DPCIA_A_SHIFT 0
1125#endif
1126
1127/*
1128 * The following defines are for the flags in the direct PCI command register.
1129 */
1130#ifndef NO_CS4612
1131#define DPCIC_C_MASK 0x0000000F
1132#define DPCIC_C_IOREAD 0x00000002
1133#define DPCIC_C_IOWRITE 0x00000003
1134#define DPCIC_BE_MASK 0x000000F0
1135#endif
1136
1137/*
1138 * The following defines are for the flags in the PC/PCI request register.
1139 */
1140#ifndef NO_CS4612
1141#define PCPCIR_RDC_MASK 0x00000007
1142#define PCPCIR_C_MASK 0x00007000
1143#define PCPCIR_REQ 0x00008000
1144#define PCPCIR_RDC_SHIFT 0
1145#define PCPCIR_C_SHIFT 12
1146#endif
1147
1148/*
1149 * The following defines are for the flags in the PC/PCI grant register.
1150 */
1151#ifndef NO_CS4612
1152#define PCPCIG_GDC_MASK 0x00000007
1153#define PCPCIG_VL 0x00008000
1154#define PCPCIG_GDC_SHIFT 0
1155#endif
1156
1157/*
1158 * The following defines are for the flags in the PC/PCI master enable
1159 * register.
1160 */
1161#ifndef NO_CS4612
1162#define PCPCIEN_EN 0x00000001
1163#endif
1164
1165/*
1166 * The following defines are for the flags in the extended PCI power
1167 * management control register.
1168 */
1169#ifndef NO_CS4612
1170#define EPCIPMC_GWU 0x00000001
1171#define EPCIPMC_FSPC 0x00000002
1172#endif
1173
1174/*
1175 * The following defines are for the flags in the SP control register.
1176 */
1177#define SPCR_RUN 0x00000001
1178#define SPCR_STPFR 0x00000002
1179#define SPCR_RUNFR 0x00000004
1180#define SPCR_TICK 0x00000008
1181#define SPCR_DRQEN 0x00000020
1182#define SPCR_RSTSP 0x00000040
1183#define SPCR_OREN 0x00000080
1184#ifndef NO_CS4612
1185#define SPCR_PCIINT 0x00000100
1186#define SPCR_OINTD 0x00000200
1187#define SPCR_CRE 0x00008000
1188#endif
1189
1190/*
1191 * The following defines are for the flags in the debug index register.
1192 */
1193#define DREG_REGID_MASK 0x0000007F
1194#define DREG_DEBUG 0x00000080
1195#define DREG_RGBK_MASK 0x00000700
1196#define DREG_TRAP 0x00000800
1197#if !defined(NO_CS4612)
1198#if !defined(NO_CS4615)
1199#define DREG_TRAPX 0x00001000
1200#endif
1201#endif
1202#define DREG_REGID_SHIFT 0
1203#define DREG_RGBK_SHIFT 8
1204#define DREG_RGBK_REGID_MASK 0x0000077F
1205#define DREG_REGID_R0 0x00000010
1206#define DREG_REGID_R1 0x00000011
1207#define DREG_REGID_R2 0x00000012
1208#define DREG_REGID_R3 0x00000013
1209#define DREG_REGID_R4 0x00000014
1210#define DREG_REGID_R5 0x00000015
1211#define DREG_REGID_R6 0x00000016
1212#define DREG_REGID_R7 0x00000017
1213#define DREG_REGID_R8 0x00000018
1214#define DREG_REGID_R9 0x00000019
1215#define DREG_REGID_RA 0x0000001A
1216#define DREG_REGID_RB 0x0000001B
1217#define DREG_REGID_RC 0x0000001C
1218#define DREG_REGID_RD 0x0000001D
1219#define DREG_REGID_RE 0x0000001E
1220#define DREG_REGID_RF 0x0000001F
1221#define DREG_REGID_RA_BUS_LOW 0x00000020
1222#define DREG_REGID_RA_BUS_HIGH 0x00000038
1223#define DREG_REGID_YBUS_LOW 0x00000050
1224#define DREG_REGID_YBUS_HIGH 0x00000058
1225#define DREG_REGID_TRAP_0 0x00000100
1226#define DREG_REGID_TRAP_1 0x00000101
1227#define DREG_REGID_TRAP_2 0x00000102
1228#define DREG_REGID_TRAP_3 0x00000103
1229#define DREG_REGID_TRAP_4 0x00000104
1230#define DREG_REGID_TRAP_5 0x00000105
1231#define DREG_REGID_TRAP_6 0x00000106
1232#define DREG_REGID_TRAP_7 0x00000107
1233#define DREG_REGID_INDIRECT_ADDRESS 0x0000010E
1234#define DREG_REGID_TOP_OF_STACK 0x0000010F
1235#if !defined(NO_CS4612)
1236#if !defined(NO_CS4615)
1237#define DREG_REGID_TRAP_8 0x00000110
1238#define DREG_REGID_TRAP_9 0x00000111
1239#define DREG_REGID_TRAP_10 0x00000112
1240#define DREG_REGID_TRAP_11 0x00000113
1241#define DREG_REGID_TRAP_12 0x00000114
1242#define DREG_REGID_TRAP_13 0x00000115
1243#define DREG_REGID_TRAP_14 0x00000116
1244#define DREG_REGID_TRAP_15 0x00000117
1245#define DREG_REGID_TRAP_16 0x00000118
1246#define DREG_REGID_TRAP_17 0x00000119
1247#define DREG_REGID_TRAP_18 0x0000011A
1248#define DREG_REGID_TRAP_19 0x0000011B
1249#define DREG_REGID_TRAP_20 0x0000011C
1250#define DREG_REGID_TRAP_21 0x0000011D
1251#define DREG_REGID_TRAP_22 0x0000011E
1252#define DREG_REGID_TRAP_23 0x0000011F
1253#endif
1254#endif
1255#define DREG_REGID_RSA0_LOW 0x00000200
1256#define DREG_REGID_RSA0_HIGH 0x00000201
1257#define DREG_REGID_RSA1_LOW 0x00000202
1258#define DREG_REGID_RSA1_HIGH 0x00000203
1259#define DREG_REGID_RSA2 0x00000204
1260#define DREG_REGID_RSA3 0x00000205
1261#define DREG_REGID_RSI0_LOW 0x00000206
1262#define DREG_REGID_RSI0_HIGH 0x00000207
1263#define DREG_REGID_RSI1 0x00000208
1264#define DREG_REGID_RSI2 0x00000209
1265#define DREG_REGID_SAGUSTATUS 0x0000020A
1266#define DREG_REGID_RSCONFIG01_LOW 0x0000020B
1267#define DREG_REGID_RSCONFIG01_HIGH 0x0000020C
1268#define DREG_REGID_RSCONFIG23_LOW 0x0000020D
1269#define DREG_REGID_RSCONFIG23_HIGH 0x0000020E
1270#define DREG_REGID_RSDMA01E 0x0000020F
1271#define DREG_REGID_RSDMA23E 0x00000210
1272#define DREG_REGID_RSD0_LOW 0x00000211
1273#define DREG_REGID_RSD0_HIGH 0x00000212
1274#define DREG_REGID_RSD1_LOW 0x00000213
1275#define DREG_REGID_RSD1_HIGH 0x00000214
1276#define DREG_REGID_RSD2_LOW 0x00000215
1277#define DREG_REGID_RSD2_HIGH 0x00000216
1278#define DREG_REGID_RSD3_LOW 0x00000217
1279#define DREG_REGID_RSD3_HIGH 0x00000218
1280#define DREG_REGID_SRAR_HIGH 0x0000021A
1281#define DREG_REGID_SRAR_LOW 0x0000021B
1282#define DREG_REGID_DMA_STATE 0x0000021C
1283#define DREG_REGID_CURRENT_DMA_STREAM 0x0000021D
1284#define DREG_REGID_NEXT_DMA_STREAM 0x0000021E
1285#define DREG_REGID_CPU_STATUS 0x00000300
1286#define DREG_REGID_MAC_MODE 0x00000301
1287#define DREG_REGID_STACK_AND_REPEAT 0x00000302
1288#define DREG_REGID_INDEX0 0x00000304
1289#define DREG_REGID_INDEX1 0x00000305
1290#define DREG_REGID_DMA_STATE_0_3 0x00000400
1291#define DREG_REGID_DMA_STATE_4_7 0x00000404
1292#define DREG_REGID_DMA_STATE_8_11 0x00000408
1293#define DREG_REGID_DMA_STATE_12_15 0x0000040C
1294#define DREG_REGID_DMA_STATE_16_19 0x00000410
1295#define DREG_REGID_DMA_STATE_20_23 0x00000414
1296#define DREG_REGID_DMA_STATE_24_27 0x00000418
1297#define DREG_REGID_DMA_STATE_28_31 0x0000041C
1298#define DREG_REGID_DMA_STATE_32_35 0x00000420
1299#define DREG_REGID_DMA_STATE_36_39 0x00000424
1300#define DREG_REGID_DMA_STATE_40_43 0x00000428
1301#define DREG_REGID_DMA_STATE_44_47 0x0000042C
1302#define DREG_REGID_DMA_STATE_48_51 0x00000430
1303#define DREG_REGID_DMA_STATE_52_55 0x00000434
1304#define DREG_REGID_DMA_STATE_56_59 0x00000438
1305#define DREG_REGID_DMA_STATE_60_63 0x0000043C
1306#define DREG_REGID_DMA_STATE_64_67 0x00000440
1307#define DREG_REGID_DMA_STATE_68_71 0x00000444
1308#define DREG_REGID_DMA_STATE_72_75 0x00000448
1309#define DREG_REGID_DMA_STATE_76_79 0x0000044C
1310#define DREG_REGID_DMA_STATE_80_83 0x00000450
1311#define DREG_REGID_DMA_STATE_84_87 0x00000454
1312#define DREG_REGID_DMA_STATE_88_91 0x00000458
1313#define DREG_REGID_DMA_STATE_92_95 0x0000045C
1314#define DREG_REGID_TRAP_SELECT 0x00000500
1315#define DREG_REGID_TRAP_WRITE_0 0x00000500
1316#define DREG_REGID_TRAP_WRITE_1 0x00000501
1317#define DREG_REGID_TRAP_WRITE_2 0x00000502
1318#define DREG_REGID_TRAP_WRITE_3 0x00000503
1319#define DREG_REGID_TRAP_WRITE_4 0x00000504
1320#define DREG_REGID_TRAP_WRITE_5 0x00000505
1321#define DREG_REGID_TRAP_WRITE_6 0x00000506
1322#define DREG_REGID_TRAP_WRITE_7 0x00000507
1323#if !defined(NO_CS4612)
1324#if !defined(NO_CS4615)
1325#define DREG_REGID_TRAP_WRITE_8 0x00000510
1326#define DREG_REGID_TRAP_WRITE_9 0x00000511
1327#define DREG_REGID_TRAP_WRITE_10 0x00000512
1328#define DREG_REGID_TRAP_WRITE_11 0x00000513
1329#define DREG_REGID_TRAP_WRITE_12 0x00000514
1330#define DREG_REGID_TRAP_WRITE_13 0x00000515
1331#define DREG_REGID_TRAP_WRITE_14 0x00000516
1332#define DREG_REGID_TRAP_WRITE_15 0x00000517
1333#define DREG_REGID_TRAP_WRITE_16 0x00000518
1334#define DREG_REGID_TRAP_WRITE_17 0x00000519
1335#define DREG_REGID_TRAP_WRITE_18 0x0000051A
1336#define DREG_REGID_TRAP_WRITE_19 0x0000051B
1337#define DREG_REGID_TRAP_WRITE_20 0x0000051C
1338#define DREG_REGID_TRAP_WRITE_21 0x0000051D
1339#define DREG_REGID_TRAP_WRITE_22 0x0000051E
1340#define DREG_REGID_TRAP_WRITE_23 0x0000051F
1341#endif
1342#endif
1343#define DREG_REGID_MAC0_ACC0_LOW 0x00000600
1344#define DREG_REGID_MAC0_ACC1_LOW 0x00000601
1345#define DREG_REGID_MAC0_ACC2_LOW 0x00000602
1346#define DREG_REGID_MAC0_ACC3_LOW 0x00000603
1347#define DREG_REGID_MAC1_ACC0_LOW 0x00000604
1348#define DREG_REGID_MAC1_ACC1_LOW 0x00000605
1349#define DREG_REGID_MAC1_ACC2_LOW 0x00000606
1350#define DREG_REGID_MAC1_ACC3_LOW 0x00000607
1351#define DREG_REGID_MAC0_ACC0_MID 0x00000608
1352#define DREG_REGID_MAC0_ACC1_MID 0x00000609
1353#define DREG_REGID_MAC0_ACC2_MID 0x0000060A
1354#define DREG_REGID_MAC0_ACC3_MID 0x0000060B
1355#define DREG_REGID_MAC1_ACC0_MID 0x0000060C
1356#define DREG_REGID_MAC1_ACC1_MID 0x0000060D
1357#define DREG_REGID_MAC1_ACC2_MID 0x0000060E
1358#define DREG_REGID_MAC1_ACC3_MID 0x0000060F
1359#define DREG_REGID_MAC0_ACC0_HIGH 0x00000610
1360#define DREG_REGID_MAC0_ACC1_HIGH 0x00000611
1361#define DREG_REGID_MAC0_ACC2_HIGH 0x00000612
1362#define DREG_REGID_MAC0_ACC3_HIGH 0x00000613
1363#define DREG_REGID_MAC1_ACC0_HIGH 0x00000614
1364#define DREG_REGID_MAC1_ACC1_HIGH 0x00000615
1365#define DREG_REGID_MAC1_ACC2_HIGH 0x00000616
1366#define DREG_REGID_MAC1_ACC3_HIGH 0x00000617
1367#define DREG_REGID_RSHOUT_LOW 0x00000620
1368#define DREG_REGID_RSHOUT_MID 0x00000628
1369#define DREG_REGID_RSHOUT_HIGH 0x00000630
1370
1371/*
1372 * The following defines are for the flags in the DMA stream requestor write
1373 */
1374#define DSRWP_DSR_MASK 0x0000000F
1375#define DSRWP_DSR_BG_RQ 0x00000001
1376#define DSRWP_DSR_PRIORITY_MASK 0x00000006
1377#define DSRWP_DSR_PRIORITY_0 0x00000000
1378#define DSRWP_DSR_PRIORITY_1 0x00000002
1379#define DSRWP_DSR_PRIORITY_2 0x00000004
1380#define DSRWP_DSR_PRIORITY_3 0x00000006
1381#define DSRWP_DSR_RQ_PENDING 0x00000008
1382
1383/*
1384 * The following defines are for the flags in the trap write port register.
1385 */
1386#define TWPR_TW_MASK 0x0000FFFF
1387#define TWPR_TW_SHIFT 0
1388
1389/*
1390 * The following defines are for the flags in the stack pointer write
1391 * register.
1392 */
1393#define SPWR_STKP_MASK 0x0000000F
1394#define SPWR_STKP_SHIFT 0
1395
1396/*
1397 * The following defines are for the flags in the SP interrupt register.
1398 */
1399#define SPIR_FRI 0x00000001
1400#define SPIR_DOI 0x00000002
1401#define SPIR_GPI2 0x00000004
1402#define SPIR_GPI3 0x00000008
1403#define SPIR_IP0 0x00000010
1404#define SPIR_IP1 0x00000020
1405#define SPIR_IP2 0x00000040
1406#define SPIR_IP3 0x00000080
1407
1408/*
1409 * The following defines are for the flags in the functional group 1 register.
1410 */
1411#define FGR1_F1S_MASK 0x0000FFFF
1412#define FGR1_F1S_SHIFT 0
1413
1414/*
1415 * The following defines are for the flags in the SP clock status register.
1416 */
1417#define SPCS_FRI 0x00000001
1418#define SPCS_DOI 0x00000002
1419#define SPCS_GPI2 0x00000004
1420#define SPCS_GPI3 0x00000008
1421#define SPCS_IP0 0x00000010
1422#define SPCS_IP1 0x00000020
1423#define SPCS_IP2 0x00000040
1424#define SPCS_IP3 0x00000080
1425#define SPCS_SPRUN 0x00000100
1426#define SPCS_SLEEP 0x00000200
1427#define SPCS_FG 0x00000400
1428#define SPCS_ORUN 0x00000800
1429#define SPCS_IRQ 0x00001000
1430#define SPCS_FGN_MASK 0x0000E000
1431#define SPCS_FGN_SHIFT 13
1432
1433/*
1434 * The following defines are for the flags in the SP DMA requestor status
1435 * register.
1436 */
1437#define SDSR_DCS_MASK 0x000000FF
1438#define SDSR_DCS_SHIFT 0
1439#define SDSR_DCS_NONE 0x00000007
1440
1441/*
1442 * The following defines are for the flags in the frame timer register.
1443 */
1444#define FRMT_FTV_MASK 0x0000FFFF
1445#define FRMT_FTV_SHIFT 0
1446
1447/*
1448 * The following defines are for the flags in the frame timer current count
1449 * register.
1450 */
1451#define FRCC_FCC_MASK 0x0000FFFF
1452#define FRCC_FCC_SHIFT 0
1453
1454/*
1455 * The following defines are for the flags in the frame timer save count
1456 * register.
1457 */
1458#define FRSC_FCS_MASK 0x0000FFFF
1459#define FRSC_FCS_SHIFT 0
1460
1461/*
1462 * The following define the various flags stored in the scatter/gather
1463 * descriptors.
1464 */
1465#define DMA_SG_NEXT_ENTRY_MASK 0x00000FF8
1466#define DMA_SG_SAMPLE_END_MASK 0x0FFF0000
1467#define DMA_SG_SAMPLE_END_FLAG 0x10000000
1468#define DMA_SG_LOOP_END_FLAG 0x20000000
1469#define DMA_SG_SIGNAL_END_FLAG 0x40000000
1470#define DMA_SG_SIGNAL_PAGE_FLAG 0x80000000
1471#define DMA_SG_NEXT_ENTRY_SHIFT 3
1472#define DMA_SG_SAMPLE_END_SHIFT 16
1473
1474/*
1475 * The following define the offsets of the fields within the on-chip generic
1476 * DMA requestor.
1477 */
1478#define DMA_RQ_CONTROL1 0x00000000
1479#define DMA_RQ_CONTROL2 0x00000004
1480#define DMA_RQ_SOURCE_ADDR 0x00000008
1481#define DMA_RQ_DESTINATION_ADDR 0x0000000C
1482#define DMA_RQ_NEXT_PAGE_ADDR 0x00000010
1483#define DMA_RQ_NEXT_PAGE_SGDESC 0x00000014
1484#define DMA_RQ_LOOP_START_ADDR 0x00000018
1485#define DMA_RQ_POST_LOOP_ADDR 0x0000001C
1486#define DMA_RQ_PAGE_MAP_ADDR 0x00000020
1487
1488/*
1489 * The following defines are for the flags in the first control word of the
1490 * on-chip generic DMA requestor.
1491 */
1492#define DMA_RQ_C1_COUNT_MASK 0x000003FF
1493#define DMA_RQ_C1_DESTINATION_SCATTER 0x00001000
1494#define DMA_RQ_C1_SOURCE_GATHER 0x00002000
1495#define DMA_RQ_C1_DONE_FLAG 0x00004000
1496#define DMA_RQ_C1_OPTIMIZE_STATE 0x00008000
1497#define DMA_RQ_C1_SAMPLE_END_STATE_MASK 0x00030000
1498#define DMA_RQ_C1_FULL_PAGE 0x00000000
1499#define DMA_RQ_C1_BEFORE_SAMPLE_END 0x00010000
1500#define DMA_RQ_C1_PAGE_MAP_ERROR 0x00020000
1501#define DMA_RQ_C1_AT_SAMPLE_END 0x00030000
1502#define DMA_RQ_C1_LOOP_END_STATE_MASK 0x000C0000
1503#define DMA_RQ_C1_NOT_LOOP_END 0x00000000
1504#define DMA_RQ_C1_BEFORE_LOOP_END 0x00040000
1505#define DMA_RQ_C1_2PAGE_LOOP_BEGIN 0x00080000
1506#define DMA_RQ_C1_LOOP_BEGIN 0x000C0000
1507#define DMA_RQ_C1_PAGE_MAP_MASK 0x00300000
1508#define DMA_RQ_C1_PM_NONE_PENDING 0x00000000
1509#define DMA_RQ_C1_PM_NEXT_PENDING 0x00100000
1510#define DMA_RQ_C1_PM_RESERVED 0x00200000
1511#define DMA_RQ_C1_PM_LOOP_NEXT_PENDING 0x00300000
1512#define DMA_RQ_C1_WRITEBACK_DEST_FLAG 0x00400000
1513#define DMA_RQ_C1_WRITEBACK_SRC_FLAG 0x00800000
1514#define DMA_RQ_C1_DEST_SIZE_MASK 0x07000000
1515#define DMA_RQ_C1_DEST_LINEAR 0x00000000
1516#define DMA_RQ_C1_DEST_MOD16 0x01000000
1517#define DMA_RQ_C1_DEST_MOD32 0x02000000
1518#define DMA_RQ_C1_DEST_MOD64 0x03000000
1519#define DMA_RQ_C1_DEST_MOD128 0x04000000
1520#define DMA_RQ_C1_DEST_MOD256 0x05000000
1521#define DMA_RQ_C1_DEST_MOD512 0x06000000
1522#define DMA_RQ_C1_DEST_MOD1024 0x07000000
1523#define DMA_RQ_C1_DEST_ON_HOST 0x08000000
1524#define DMA_RQ_C1_SOURCE_SIZE_MASK 0x70000000
1525#define DMA_RQ_C1_SOURCE_LINEAR 0x00000000
1526#define DMA_RQ_C1_SOURCE_MOD16 0x10000000
1527#define DMA_RQ_C1_SOURCE_MOD32 0x20000000
1528#define DMA_RQ_C1_SOURCE_MOD64 0x30000000
1529#define DMA_RQ_C1_SOURCE_MOD128 0x40000000
1530#define DMA_RQ_C1_SOURCE_MOD256 0x50000000
1531#define DMA_RQ_C1_SOURCE_MOD512 0x60000000
1532#define DMA_RQ_C1_SOURCE_MOD1024 0x70000000
1533#define DMA_RQ_C1_SOURCE_ON_HOST 0x80000000
1534#define DMA_RQ_C1_COUNT_SHIFT 0
1535
1536/*
1537 * The following defines are for the flags in the second control word of the
1538 * on-chip generic DMA requestor.
1539 */
1540#define DMA_RQ_C2_VIRTUAL_CHANNEL_MASK 0x0000003F
1541#define DMA_RQ_C2_VIRTUAL_SIGNAL_MASK 0x00000300
1542#define DMA_RQ_C2_NO_VIRTUAL_SIGNAL 0x00000000
1543#define DMA_RQ_C2_SIGNAL_EVERY_DMA 0x00000100
1544#define DMA_RQ_C2_SIGNAL_SOURCE_PINGPONG 0x00000200
1545#define DMA_RQ_C2_SIGNAL_DEST_PINGPONG 0x00000300
1546#define DMA_RQ_C2_AUDIO_CONVERT_MASK 0x0000F000
1547#define DMA_RQ_C2_AC_NONE 0x00000000
1548#define DMA_RQ_C2_AC_8_TO_16_BIT 0x00001000
1549#define DMA_RQ_C2_AC_MONO_TO_STEREO 0x00002000
1550#define DMA_RQ_C2_AC_ENDIAN_CONVERT 0x00004000
1551#define DMA_RQ_C2_AC_SIGNED_CONVERT 0x00008000
1552#define DMA_RQ_C2_LOOP_END_MASK 0x0FFF0000
1553#define DMA_RQ_C2_LOOP_MASK 0x30000000
1554#define DMA_RQ_C2_NO_LOOP 0x00000000
1555#define DMA_RQ_C2_ONE_PAGE_LOOP 0x10000000
1556#define DMA_RQ_C2_TWO_PAGE_LOOP 0x20000000
1557#define DMA_RQ_C2_MULTI_PAGE_LOOP 0x30000000
1558#define DMA_RQ_C2_SIGNAL_LOOP_BACK 0x40000000
1559#define DMA_RQ_C2_SIGNAL_POST_BEGIN_PAGE 0x80000000
1560#define DMA_RQ_C2_VIRTUAL_CHANNEL_SHIFT 0
1561#define DMA_RQ_C2_LOOP_END_SHIFT 16
1562
1563/*
1564 * The following defines are for the flags in the source and destination words
1565 * of the on-chip generic DMA requestor.
1566 */
1567#define DMA_RQ_SD_ADDRESS_MASK 0x0000FFFF
1568#define DMA_RQ_SD_MEMORY_ID_MASK 0x000F0000
1569#define DMA_RQ_SD_SP_PARAM_ADDR 0x00000000
1570#define DMA_RQ_SD_SP_SAMPLE_ADDR 0x00010000
1571#define DMA_RQ_SD_SP_PROGRAM_ADDR 0x00020000
1572#define DMA_RQ_SD_SP_DEBUG_ADDR 0x00030000
1573#define DMA_RQ_SD_OMNIMEM_ADDR 0x000E0000
1574#define DMA_RQ_SD_END_FLAG 0x40000000
1575#define DMA_RQ_SD_ERROR_FLAG 0x80000000
1576#define DMA_RQ_SD_ADDRESS_SHIFT 0
1577
1578/*
1579 * The following defines are for the flags in the page map address word of the
1580 * on-chip generic DMA requestor.
1581 */
1582#define DMA_RQ_PMA_LOOP_THIRD_PAGE_ENTRY_MASK 0x00000FF8
1583#define DMA_RQ_PMA_PAGE_TABLE_MASK 0xFFFFF000
1584#define DMA_RQ_PMA_LOOP_THIRD_PAGE_ENTRY_SHIFT 3
1585#define DMA_RQ_PMA_PAGE_TABLE_SHIFT 12
1586
1587#define BA1_VARIDEC_BUF_1 0x000
1588
1589#define BA1_PDTC 0x0c0 /* BA1_PLAY_DMA_TRANSACTION_COUNT_REG */
1590#define BA1_PFIE 0x0c4 /* BA1_PLAY_FORMAT_&_INTERRUPT_ENABLE_REG */
1591#define BA1_PBA 0x0c8 /* BA1_PLAY_BUFFER_ADDRESS */
1592#define BA1_PVOL 0x0f8 /* BA1_PLAY_VOLUME_REG */
1593#define BA1_PSRC 0x288 /* BA1_PLAY_SAMPLE_RATE_CORRECTION_REG */
1594#define BA1_PCTL 0x2a4 /* BA1_PLAY_CONTROL_REG */
1595#define BA1_PPI 0x2b4 /* BA1_PLAY_PHASE_INCREMENT_REG */
1596
1597#define BA1_CCTL 0x064 /* BA1_CAPTURE_CONTROL_REG */
1598#define BA1_CIE 0x104 /* BA1_CAPTURE_INTERRUPT_ENABLE_REG */
1599#define BA1_CBA 0x10c /* BA1_CAPTURE_BUFFER_ADDRESS */
1600#define BA1_CSRC 0x2c8 /* BA1_CAPTURE_SAMPLE_RATE_CORRECTION_REG */
1601#define BA1_CCI 0x2d8 /* BA1_CAPTURE_COEFFICIENT_INCREMENT_REG */
1602#define BA1_CD 0x2e0 /* BA1_CAPTURE_DELAY_REG */
1603#define BA1_CPI 0x2f4 /* BA1_CAPTURE_PHASE_INCREMENT_REG */
1604#define BA1_CVOL 0x2f8 /* BA1_CAPTURE_VOLUME_REG */
1605
1606#define BA1_CFG1 0x134 /* BA1_CAPTURE_FRAME_GROUP_1_REG */
1607#define BA1_CFG2 0x138 /* BA1_CAPTURE_FRAME_GROUP_2_REG */
1608#define BA1_CCST 0x13c /* BA1_CAPTURE_CONSTANT_REG */
1609#define BA1_CSPB 0x340 /* BA1_CAPTURE_SPB_ADDRESS */
1610
1611/*
1612 *
1613 */
1614
1615#define CS461X_MODE_OUTPUT (1<<0) /* MIDI UART - output */
1616#define CS461X_MODE_INPUT (1<<1) /* MIDI UART - input */
1617
1618//****************************************************************************
1619//
1620// The following define the offsets of the AC97 shadow registers, which appear
1621// as a virtual extension to the base address register zero memory range.
1622//
1623//****************************************************************************
1624#define AC97_REG_OFFSET_MASK 0x0000007EL
1625#define AC97_CODEC_NUMBER_MASK 0x00003000L
1626
1627#define BA0_AC97_RESET 0x00001000L
1628#define BA0_AC97_MASTER_VOLUME 0x00001002L
1629#define BA0_AC97_HEADPHONE_VOLUME 0x00001004L
1630#define BA0_AC97_MASTER_VOLUME_MONO 0x00001006L
1631#define BA0_AC97_MASTER_TONE 0x00001008L
1632#define BA0_AC97_PC_BEEP_VOLUME 0x0000100AL
1633#define BA0_AC97_PHONE_VOLUME 0x0000100CL
1634#define BA0_AC97_MIC_VOLUME 0x0000100EL
1635#define BA0_AC97_LINE_IN_VOLUME 0x00001010L
1636#define BA0_AC97_CD_VOLUME 0x00001012L
1637#define BA0_AC97_VIDEO_VOLUME 0x00001014L
1638#define BA0_AC97_AUX_VOLUME 0x00001016L
1639#define BA0_AC97_PCM_OUT_VOLUME 0x00001018L
1640#define BA0_AC97_RECORD_SELECT 0x0000101AL
1641#define BA0_AC97_RECORD_GAIN 0x0000101CL
1642#define BA0_AC97_RECORD_GAIN_MIC 0x0000101EL
1643#define BA0_AC97_GENERAL_PURPOSE 0x00001020L
1644#define BA0_AC97_3D_CONTROL 0x00001022L
1645#define BA0_AC97_MODEM_RATE 0x00001024L
1646#define BA0_AC97_POWERDOWN 0x00001026L
1647#define BA0_AC97_EXT_AUDIO_ID 0x00001028L
1648#define BA0_AC97_EXT_AUDIO_POWER 0x0000102AL
1649#define BA0_AC97_PCM_FRONT_DAC_RATE 0x0000102CL
1650#define BA0_AC97_PCM_SURR_DAC_RATE 0x0000102EL
1651#define BA0_AC97_PCM_LFE_DAC_RATE 0x00001030L
1652#define BA0_AC97_PCM_LR_ADC_RATE 0x00001032L
1653#define BA0_AC97_MIC_ADC_RATE 0x00001034L
1654#define BA0_AC97_6CH_VOL_C_LFE 0x00001036L
1655#define BA0_AC97_6CH_VOL_SURROUND 0x00001038L
1656#define BA0_AC97_RESERVED_3A 0x0000103AL
1657#define BA0_AC97_EXT_MODEM_ID 0x0000103CL
1658#define BA0_AC97_EXT_MODEM_POWER 0x0000103EL
1659#define BA0_AC97_LINE1_CODEC_RATE 0x00001040L
1660#define BA0_AC97_LINE2_CODEC_RATE 0x00001042L
1661#define BA0_AC97_HANDSET_CODEC_RATE 0x00001044L
1662#define BA0_AC97_LINE1_CODEC_LEVEL 0x00001046L
1663#define BA0_AC97_LINE2_CODEC_LEVEL 0x00001048L
1664#define BA0_AC97_HANDSET_CODEC_LEVEL 0x0000104AL
1665#define BA0_AC97_GPIO_PIN_CONFIG 0x0000104CL
1666#define BA0_AC97_GPIO_PIN_TYPE 0x0000104EL
1667#define BA0_AC97_GPIO_PIN_STICKY 0x00001050L
1668#define BA0_AC97_GPIO_PIN_WAKEUP 0x00001052L
1669#define BA0_AC97_GPIO_PIN_STATUS 0x00001054L
1670#define BA0_AC97_MISC_MODEM_AFE_STAT 0x00001056L
1671#define BA0_AC97_RESERVED_58 0x00001058L
1672#define BA0_AC97_CRYSTAL_REV_N_FAB_ID 0x0000105AL
1673#define BA0_AC97_TEST_AND_MISC_CTRL 0x0000105CL
1674#define BA0_AC97_AC_MODE 0x0000105EL
1675#define BA0_AC97_MISC_CRYSTAL_CONTROL 0x00001060L
1676#define BA0_AC97_LINE1_HYPRID_CTRL 0x00001062L
1677#define BA0_AC97_VENDOR_RESERVED_64 0x00001064L
1678#define BA0_AC97_VENDOR_RESERVED_66 0x00001066L
1679#define BA0_AC97_SPDIF_CONTROL 0x00001068L
1680#define BA0_AC97_VENDOR_RESERVED_6A 0x0000106AL
1681#define BA0_AC97_VENDOR_RESERVED_6C 0x0000106CL
1682#define BA0_AC97_VENDOR_RESERVED_6E 0x0000106EL
1683#define BA0_AC97_VENDOR_RESERVED_70 0x00001070L
1684#define BA0_AC97_VENDOR_RESERVED_72 0x00001072L
1685#define BA0_AC97_VENDOR_RESERVED_74 0x00001074L
1686#define BA0_AC97_CAL_ADDRESS 0x00001076L
1687#define BA0_AC97_CAL_DATA 0x00001078L
1688#define BA0_AC97_VENDOR_RESERVED_7A 0x0000107AL
1689#define BA0_AC97_VENDOR_ID1 0x0000107CL
1690#define BA0_AC97_VENDOR_ID2 0x0000107EL
1691#endif /* __CS461X_H */
diff --git a/sound/oss/cs461x_image.h b/sound/oss/cs461x_image.h
deleted file mode 100644
index b5c5a46d342..00000000000
--- a/sound/oss/cs461x_image.h
+++ /dev/null
@@ -1,322 +0,0 @@
1/****************************************************************************
2 * "CWCIMAGE.H"-- For CS46XX. Ver 1.04
3 * Copyright 1998-2001 (c) Cirrus Logic Corp.
4 * Version 1.04
5 ****************************************************************************
6 */
7#ifndef __CS_IMAGE_H
8#define __CS_IMAGE_H
9
10#define CLEAR__COUNT 3
11#define FILL__COUNT 4
12#define BA1__DWORD_SIZE 13*1024+512
13
14static struct
15{
16 unsigned BA1__DestByteOffset;
17 unsigned BA1__SourceSize;
18} ClrStat[CLEAR__COUNT] ={ {0x00000000, 0x00003000 },
19 {0x00010000, 0x00003800 },
20 {0x00020000, 0x00007000 } };
21
22static u32 FillArray1[]={
230x00000000,0x00000000,0x00000000,0x00000000,
240x00000000,0x00000000,0x00000000,0x00000000,
250x00000000,0x00000000,0x00000163,0x00000000,
260x00000000,0x00000000,0x00000000,0x00000000,
270x00000000,0x00000000,0x00000000,0x00000000,
280x00000000,0x00000000,0x00000000,0x00000000,
290x00000000,0x00200040,0x00008010,0x00000000,
300x00000000,0x80000001,0x00000001,0x00060000,
310x00000000,0x00000000,0x00000000,0x00000000,
320x00000000,0x00000000,0x00000000,0x00000000,
330x00000000,0x00900080,0x00000173,0x00000000,
340x00000000,0x00000010,0x00800000,0x00900000,
350xf2c0000f,0x00000200,0x00000000,0x00010600,
360x00000000,0x00000000,0x00000000,0x00000000,
370x00000000,0x00000000,0x00000163,0x330300c2,
380x06000000,0x00000000,0x80008000,0x80008000,
390x3fc0000f,0x00000301,0x00010400,0x00000000,
400x00000000,0x00000000,0x00000000,0x00000000,
410x00000000,0x00b00000,0x00d0806d,0x330480c3,
420x04800000,0x00000001,0x00800001,0x0000ffff,
430x00000000,0x00000000,0x00000000,0x00000000,
440x00000000,0x00000000,0x00000000,0x00000000,
450x00000000,0x00000000,0x00000000,0x00000000,
460x00000000,0x00000000,0x00000000,0x00000000,
470x00000000,0x00000000,0x00000000,0x00000000,
480x00000000,0x00000000,0x00000000,0x00000000,
490x00000000,0x00000000,0x00000000,0x00000000,
500x00000000,0x00000000,0x00000000,0x00000000,
510x066a0600,0x06350070,0x0000929d,0x929d929d,
520x00000000,0x0000735a,0x00000600,0x00000000,
530x929d735a,0x00000000,0x00010000,0x735a735a,
540xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
550x00000000,0x00000000,0x00000000,0x00000000,
560x00000000,0x00000000,0x00000000,0x00000000,
570x00000000,0x00000000,0x0000804f,0x000000c3,
580x05000000,0x00a00010,0x00000000,0x80008000,
590x00000000,0x00000000,0x00000700,0x00000000,
600x00000000,0x00000000,0x00000000,0x00000000,
610x00000080,0x00a00000,0x0000809a,0x000000c2,
620x07400000,0x00000000,0x80008000,0xffffffff,
630x00c80028,0x00005555,0x00000000,0x000107a0,
640x00c80028,0x000000c2,0x06800000,0x00000000,
650x06e00080,0x00300000,0x000080bb,0x000000c9,
660x07a00000,0x04000000,0x80008000,0xffffffff,
670x00c80028,0x00005555,0x00000000,0x00000780,
680x00c80028,0x000000c5,0xff800000,0x00000000,
690x00640080,0x00c00000,0x00008197,0x000000c9,
700x07800000,0x04000000,0x80008000,0xffffffff,
710x00000000,0x00000000,0x00000000,0x00000000,
720x00000000,0x00000000,0x00000000,0x00000000,
730x00000000,0x00000000,0x0000805e,0x000000c1,
740x00000000,0x00800000,0x80008000,0x80008000,
750x00020000,0x0000ffff,0x00000000,0x00000000};
76
77static u32 FillArray2[]={
780x929d0600,0x929d929d,0x929d929d,0x929d0000,
790x929d929d,0x929d929d,0x929d929d,0x929d929d,
800x929d929d,0x00100635,0x060b013f,0x00000004,
810x00000001,0x007a0002,0x00000000,0x066e0610,
820x0105929d,0x929d929d,0x929d929d,0x929d929d,
830x929d929d,0xa431ac75,0x0001735a,0xa431ac75,
840xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
850xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
860xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
870xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
880xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
890xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
900xa431ac75,0xa431ac75,0xa431ac75,0x735a0051,
910x00000000,0x929d929d,0x929d929d,0x929d929d,
920x929d929d,0x929d929d,0x929d929d,0x929d929d,
930x929d929d,0x929d929d,0x00000000,0x06400136,
940x0000270f,0x00010000,0x007a0000,0x00000000,
950x068e0645,0x0105929d,0x929d929d,0x929d929d,
960x929d929d,0x929d929d,0xa431ac75,0x0001735a,
970xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
980xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
990xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
1000xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
1010xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
1020xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
1030xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
1040x735a0100,0x00000000,0x00000000,0x00000000};
105
106static u32 FillArray3[]={
1070x00000000,0x00000000,0x00000000,0x00010004};
108
109static u32 FillArray4[]={
1100x00040730,0x00001002,0x000f619e,0x00001003,
1110x00001705,0x00001400,0x000a411e,0x00001003,
1120x00040730,0x00001002,0x000f619e,0x00001003,
1130x00009705,0x00001400,0x000a411e,0x00001003,
1140x00040730,0x00001002,0x000f619e,0x00001003,
1150x00011705,0x00001400,0x000a411e,0x00001003,
1160x00040730,0x00001002,0x000f619e,0x00001003,
1170x00019705,0x00001400,0x000a411e,0x00001003,
1180x00040730,0x00001002,0x000f619e,0x00001003,
1190x00021705,0x00001400,0x000a411e,0x00001003,
1200x00040730,0x00001002,0x000f619e,0x00001003,
1210x00029705,0x00001400,0x000a411e,0x00001003,
1220x00040730,0x00001002,0x000f619e,0x00001003,
1230x00031705,0x00001400,0x000a411e,0x00001003,
1240x00040730,0x00001002,0x000f619e,0x00001003,
1250x00039705,0x00001400,0x000a411e,0x00001003,
1260x000fe19e,0x00001003,0x0009c730,0x00001003,
1270x0008e19c,0x00001003,0x000083c1,0x00093040,
1280x00098730,0x00001002,0x000ee19e,0x00001003,
1290x00009705,0x00001400,0x000a211e,0x00001003,
1300x00098730,0x00001002,0x000ee19e,0x00001003,
1310x00011705,0x00001400,0x000a211e,0x00001003,
1320x00098730,0x00001002,0x000ee19e,0x00001003,
1330x00019705,0x00001400,0x000a211e,0x00001003,
1340x00098730,0x00001002,0x000ee19e,0x00001003,
1350x00021705,0x00001400,0x000a211e,0x00001003,
1360x00098730,0x00001002,0x000ee19e,0x00001003,
1370x00029705,0x00001400,0x000a211e,0x00001003,
1380x00098730,0x00001002,0x000ee19e,0x00001003,
1390x00031705,0x00001400,0x000a211e,0x00001003,
1400x00098730,0x00001002,0x000ee19e,0x00001003,
1410x00039705,0x00001400,0x000a211e,0x00001003,
1420x0000a730,0x00001008,0x000e2730,0x00001002,
1430x0000a731,0x00001002,0x0000a731,0x00001002,
1440x0000a731,0x00001002,0x0000a731,0x00001002,
1450x0000a731,0x00001002,0x0000a731,0x00001002,
1460x00000000,0x00000000,0x000f619c,0x00001003,
1470x0007f801,0x000c0000,0x00000037,0x00001000,
1480x00000000,0x00000000,0x00000000,0x00000000,
1490x00000000,0x00000000,0x00000000,0x00000000,
1500x00000000,0x000c0000,0x00000000,0x00000000,
1510x0000373c,0x00001000,0x00000000,0x00000000,
1520x000ee19c,0x00001003,0x0007f801,0x000c0000,
1530x00000037,0x00001000,0x00000000,0x00000000,
1540x00000000,0x00000000,0x00000000,0x00000000,
1550x00000000,0x00000000,0x0000273c,0x00001000,
1560x00000033,0x00001000,0x000e679e,0x00001003,
1570x00007705,0x00001400,0x000ac71e,0x00001003,
1580x00087fc1,0x000c3be0,0x0007f801,0x000c0000,
1590x00000037,0x00001000,0x00000000,0x00000000,
1600x00000000,0x00000000,0x00000000,0x00000000,
1610x00000000,0x00000000,0x0000a730,0x00001003,
1620x00000033,0x00001000,0x0007f801,0x000c0000,
1630x00000037,0x00001000,0x00000000,0x00000000,
1640x00000000,0x00000000,0x00000000,0x00000000,
1650x00000000,0x00000000,0x00000000,0x000c0000,
1660x00000032,0x00001000,0x0000273d,0x00001000,
1670x0004a730,0x00001003,0x00000f41,0x00097140,
1680x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
1690x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
1700x00000000,0x00000000,0x0001bf05,0x0003fc40,
1710x00002725,0x000aa400,0x00013705,0x00093a00,
1720x0000002e,0x0009d6c0,0x00038630,0x00001004,
1730x0004ef0a,0x000eb785,0x0003fc8a,0x00000000,
1740x00000000,0x000c70e0,0x0007d182,0x0002c640,
1750x00000630,0x00001004,0x000799b8,0x0002c6c0,
1760x00031705,0x00092240,0x00039f05,0x000932c0,
1770x0003520a,0x00000000,0x00040731,0x0000100b,
1780x00010705,0x000b20c0,0x00000000,0x000eba44,
1790x00032108,0x000c60c4,0x00065208,0x000c2917,
1800x000406b0,0x00001007,0x00012f05,0x00036880,
1810x0002818e,0x000c0000,0x0004410a,0x00000000,
1820x00040630,0x00001007,0x00029705,0x000c0000,
1830x00000000,0x00000000,0x00003fc1,0x0003fc40,
1840x000037c1,0x00091b40,0x00003fc1,0x000911c0,
1850x000037c1,0x000957c0,0x00003fc1,0x000951c0,
1860x000037c1,0x00000000,0x00003fc1,0x000991c0,
1870x000037c1,0x00000000,0x00003fc1,0x0009d1c0,
1880x000037c1,0x00000000,0x0001ccc1,0x000915c0,
1890x0001c441,0x0009d800,0x0009cdc1,0x00091240,
1900x0001c541,0x00091d00,0x0009cfc1,0x00095240,
1910x0001c741,0x00095c80,0x000e8ca9,0x00099240,
1920x000e85ad,0x00095640,0x00069ca9,0x00099d80,
1930x000e952d,0x00099640,0x000eaca9,0x0009d6c0,
1940x000ea5ad,0x00091a40,0x0006bca9,0x0009de80,
1950x000eb52d,0x00095a40,0x000ecca9,0x00099ac0,
1960x000ec5ad,0x0009da40,0x000edca9,0x0009d300,
1970x000a6e0a,0x00001000,0x000ed52d,0x00091e40,
1980x000eeca9,0x00095ec0,0x000ee5ad,0x00099e40,
1990x0006fca9,0x00002500,0x000fb208,0x000c59a0,
2000x000ef52d,0x0009de40,0x00068ca9,0x000912c1,
2010x000683ad,0x00095241,0x00020f05,0x000991c1,
2020x00000000,0x00000000,0x00086f88,0x00001000,
2030x0009cf81,0x000b5340,0x0009c701,0x000b92c0,
2040x0009de81,0x000bd300,0x0009d601,0x000b1700,
2050x0001fd81,0x000b9d80,0x0009f501,0x000b57c0,
2060x000a0f81,0x000bd740,0x00020701,0x000b5c80,
2070x000a1681,0x000b97c0,0x00021601,0x00002500,
2080x000a0701,0x000b9b40,0x000a0f81,0x000b1bc0,
2090x00021681,0x00002d00,0x00020f81,0x000bd800,
2100x000a0701,0x000b5bc0,0x00021601,0x00003500,
2110x000a0f81,0x000b5f40,0x000a0701,0x000bdbc0,
2120x00021681,0x00003d00,0x00020f81,0x000b1d00,
2130x000a0701,0x000b1fc0,0x00021601,0x00020500,
2140x00020f81,0x000b1341,0x000a0701,0x000b9fc0,
2150x00021681,0x00020d00,0x00020f81,0x000bde80,
2160x000a0701,0x000bdfc0,0x00021601,0x00021500,
2170x00020f81,0x000b9341,0x00020701,0x000b53c1,
2180x00021681,0x00021d00,0x000a0f81,0x000d0380,
2190x0000b601,0x000b15c0,0x00007b01,0x00000000,
2200x00007b81,0x000bd1c0,0x00007b01,0x00000000,
2210x00007b81,0x000b91c0,0x00007b01,0x000b57c0,
2220x00007b81,0x000b51c0,0x00007b01,0x000b1b40,
2230x00007b81,0x000b11c0,0x00087b01,0x000c3dc0,
2240x0007e488,0x000d7e45,0x00000000,0x000d7a44,
2250x0007e48a,0x00000000,0x00011f05,0x00084080,
2260x00000000,0x00000000,0x00001705,0x000b3540,
2270x00008a01,0x000bf040,0x00007081,0x000bb5c0,
2280x00055488,0x00000000,0x0000d482,0x0003fc40,
2290x0003fc88,0x00000000,0x0001e401,0x000b3a00,
2300x0001ec81,0x000bd6c0,0x0004ef08,0x000eb784,
2310x000c86b0,0x00001007,0x00008281,0x000bb240,
2320x0000b801,0x000b7140,0x00007888,0x00000000,
2330x0000073c,0x00001000,0x0007f188,0x000c0000,
2340x00000000,0x00000000,0x00055288,0x000c555c,
2350x0005528a,0x000c0000,0x0009fa88,0x000c5d00,
2360x0000fa88,0x00000000,0x00000032,0x00001000,
2370x0000073d,0x00001000,0x0007f188,0x000c0000,
2380x00000000,0x00000000,0x0008c01c,0x00001003,
2390x00002705,0x00001008,0x0008b201,0x000c1392,
2400x0000ba01,0x00000000,0x00008731,0x00001400,
2410x0004c108,0x000fe0c4,0x00057488,0x00000000,
2420x000a6388,0x00001001,0x0008b334,0x000bc141,
2430x0003020e,0x00000000,0x000886b0,0x00001008,
2440x00003625,0x000c5dfa,0x000a638a,0x00001001,
2450x0008020e,0x00001002,0x0008a6b0,0x00001008,
2460x0007f301,0x00000000,0x00000000,0x00000000,
2470x00002725,0x000a8c40,0x000000ae,0x00000000,
2480x000d8630,0x00001008,0x00000000,0x000c74e0,
2490x0007d182,0x0002d640,0x000a8630,0x00001008,
2500x000799b8,0x0002d6c0,0x0000748a,0x000c3ec5,
2510x0007420a,0x000c0000,0x00062208,0x000c4117,
2520x00070630,0x00001009,0x00000000,0x000c0000,
2530x0001022e,0x00000000,0x0003a630,0x00001009,
2540x00000000,0x000c0000,0x00000036,0x00001000,
2550x00000000,0x00000000,0x00000000,0x00000000,
2560x00000000,0x00000000,0x00000000,0x00000000,
2570x0002a730,0x00001008,0x0007f801,0x000c0000,
2580x00000037,0x00001000,0x00000000,0x00000000,
2590x00000000,0x00000000,0x00000000,0x00000000,
2600x00000000,0x00000000,0x0002a730,0x00001008,
2610x00000033,0x00001000,0x0002a705,0x00001008,
2620x00007a01,0x000c0000,0x000e6288,0x000d550a,
2630x0006428a,0x00000000,0x00060730,0x0000100a,
2640x00000000,0x000c0000,0x00000000,0x00000000,
2650x0007aab0,0x00034880,0x00078fb0,0x0000100b,
2660x00057488,0x00000000,0x00033b94,0x00081140,
2670x000183ae,0x00000000,0x000786b0,0x0000100b,
2680x00022f05,0x000c3545,0x0000eb8a,0x00000000,
2690x00042731,0x00001003,0x0007aab0,0x00034880,
2700x00048fb0,0x0000100a,0x00057488,0x00000000,
2710x00033b94,0x00081140,0x000183ae,0x00000000,
2720x000806b0,0x0000100b,0x00022f05,0x00000000,
2730x00007401,0x00091140,0x00048f05,0x000951c0,
2740x00042731,0x00001003,0x0000473d,0x00001000,
2750x000f19b0,0x000bbc47,0x00080000,0x000bffc7,
2760x000fe19e,0x00001003,0x00000000,0x00000000,
2770x0008e19c,0x00001003,0x000083c1,0x00093040,
2780x00000f41,0x00097140,0x0000a841,0x0009b240,
2790x0000a0c1,0x0009f040,0x0001c641,0x00093540,
2800x0001cec1,0x0009b5c0,0x00000000,0x000fdc44,
2810x00055208,0x00000000,0x00010705,0x000a2880,
2820x0000a23a,0x00093a00,0x0003fc8a,0x000df6c5,
2830x0004ef0a,0x000c0000,0x00012f05,0x00036880,
2840x00065308,0x000c2997,0x000d86b0,0x0000100a,
2850x0004410a,0x000d40c7,0x00000000,0x00000000,
2860x00080730,0x00001004,0x00056f0a,0x000ea105,
2870x00000000,0x00000000,0x0000473d,0x00001000,
2880x000f19b0,0x000bbc47,0x00080000,0x000bffc7,
2890x0000273d,0x00001000,0x00000000,0x000eba44,
2900x00048f05,0x0000f440,0x00007401,0x0000f7c0,
2910x00000734,0x00001000,0x00010705,0x000a6880,
2920x00006a88,0x000c75c4,0x00000000,0x000e5084,
2930x00000000,0x000eba44,0x00087401,0x000e4782,
2940x00000734,0x00001000,0x00010705,0x000a6880,
2950x00006a88,0x000c75c4,0x0007c108,0x000c0000,
2960x0007e721,0x000bed40,0x00005f25,0x000badc0,
2970x0003ba97,0x000beb80,0x00065590,0x000b2e00,
2980x00033217,0x00003ec0,0x00065590,0x000b8e40,
2990x0003ed80,0x000491c0,0x00073fb0,0x00074c80,
3000x000283a0,0x0000100c,0x000ee388,0x00042970,
3010x00008301,0x00021ef2,0x000b8f14,0x0000000f,
3020x000c4d8d,0x0000001b,0x000d6dc2,0x000e06c6,
3030x000032ac,0x000c3916,0x0004edc2,0x00074c80,
3040x00078898,0x00001000,0x00038894,0x00000032,
3050x000c4d8d,0x00092e1b,0x000d6dc2,0x000e06c6,
3060x0004edc2,0x000c1956,0x0000722c,0x00034a00,
3070x00041705,0x0009ed40,0x00058730,0x00001400,
3080x000d7488,0x000c3a00,0x00048f05,0x00000000};
309
310static struct
311{ u32 Offset;
312 u32 Size;
313 u32 *pFill;
314} FillStat[FILL__COUNT] = {
315 {0x00000000, sizeof(FillArray1), FillArray1},
316 {0x00001800, sizeof(FillArray2), FillArray2},
317 {0x000137f0, sizeof(FillArray3), FillArray3},
318 {0x00020000, sizeof(FillArray4), FillArray4}
319 };
320
321
322#endif
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
deleted file mode 100644
index 2a1f0d9ac96..00000000000
--- a/sound/oss/cs46xx.c
+++ /dev/null
@@ -1,5444 +0,0 @@
1/*
2 * Crystal SoundFusion CS46xx driver
3 *
4 * Copyright 1998-2001 Cirrus Logic Corporation <pcaudio@crystal.cirrus.com>
5 * <twoller@crystal.cirrus.com>
6 * Copyright 1999-2000 Jaroslav Kysela <perex@suse.cz>
7 * Copyright 2000 Alan Cox <alan@redhat.com>
8 *
9 * The core of this code is taken from the ALSA project driver by
10 * Jaroslav. Please send Jaroslav the credit for the driver and
11 * report bugs in this port to <alan@redhat.com>
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 * Current maintainers:
27 * Cirrus Logic Corporation, Thomas Woller (tw)
28 * <twoller@crystal.cirrus.com>
29 * Nils Faerber (nf)
30 * <nils@kernelconcepts.de>
31 * Thanks to David Pollard for testing.
32 *
33 * Changes:
34 * 20000909-nf Changed cs_read, cs_write and drain_dac
35 * 20001025-tw Separate Playback/Capture structs and buffers.
36 * Added Scatter/Gather support for Playback.
37 * Added Capture.
38 * 20001027-nf Port to kernel 2.4.0-test9, some clean-ups
39 * Start of powermanagement support (CS46XX_PM).
40 * 20001128-tw Add module parm for default buffer order.
41 * added DMA_GFP flag to kmalloc dma buffer allocs.
42 * backfill silence to eliminate stuttering on
43 * underruns.
44 * 20001201-tw add resyncing of swptr on underruns.
45 * 20001205-tw-nf fixed GETOSPACE ioctl() after open()
46 * 20010113-tw patch from Hans Grobler general cleanup.
47 * 20010117-tw 2.4.0 pci cleanup, wrapper code for 2.2.16-2.4.0
48 * 20010118-tw basic PM support for 2.2.16+ and 2.4.0/2.4.2.
49 * 20010228-dh patch from David Huggins - cs_update_ptr recursion.
50 * 20010409-tw add hercules game theatre XP amp code.
51 * 20010420-tw cleanup powerdown/up code.
52 * 20010521-tw eliminate pops, and fixes for powerdown.
53 * 20010525-tw added fixes for thinkpads with powerdown logic.
54 * 20010723-sh patch from Horms (Simon Horman) -
55 * SOUND_PCM_READ_BITS returns bits as set in driver
56 * rather than a logical or of the possible values.
57 * Various ioctls handle the case where the device
58 * is open for reading or writing but not both better.
59 *
60 * Status:
61 * Playback/Capture supported from 8k-48k.
62 * 16Bit Signed LE & 8Bit Unsigned, with Mono or Stereo supported.
63 *
64 * APM/PM - 2.2.x APM is enabled and functioning fine. APM can also
65 * be enabled for 2.4.x by modifying the CS46XX_ACPI_SUPPORT macro
66 * definition.
67 *
68 * Hercules Game Theatre XP - the EGPIO2 pin controls the external Amp,
69 * so, use the drain/polarity to enable.
70 * hercules_egpio_disable set to 1, will force a 0 to EGPIODR.
71 *
72 * VTB Santa Cruz - the GPIO7/GPIO8 on the Secondary Codec control
73 * the external amplifier for the "back" speakers, since we do not
74 * support the secondary codec then this external amp is also not
75 * turned on.
76 */
77
78#include <linux/interrupt.h>
79#include <linux/list.h>
80#include <linux/module.h>
81#include <linux/string.h>
82#include <linux/ioport.h>
83#include <linux/sched.h>
84#include <linux/delay.h>
85#include <linux/sound.h>
86#include <linux/slab.h>
87#include <linux/soundcard.h>
88#include <linux/pci.h>
89#include <linux/bitops.h>
90#include <linux/init.h>
91#include <linux/poll.h>
92#include <linux/ac97_codec.h>
93#include <linux/mutex.h>
94#include <linux/mm.h>
95
96#include <asm/io.h>
97#include <asm/dma.h>
98#include <asm/uaccess.h>
99
100#include "cs46xxpm.h"
101#include "cs46xx_wrapper-24.h"
102#include "cs461x.h"
103
104/* MIDI buffer sizes */
105#define CS_MIDIINBUF 500
106#define CS_MIDIOUTBUF 500
107
108#define ADC_RUNNING 1
109#define DAC_RUNNING 2
110
111#define CS_FMT_16BIT 1 /* These are fixed in fact */
112#define CS_FMT_STEREO 2
113#define CS_FMT_MASK 3
114
115#define CS_TYPE_ADC 1
116#define CS_TYPE_DAC 2
117
118#define CS_TRUE 1
119#define CS_FALSE 0
120
121#define CS_INC_USE_COUNT(m) (atomic_inc(m))
122#define CS_DEC_USE_COUNT(m) (atomic_dec(m))
123#define CS_DEC_AND_TEST(m) (atomic_dec_and_test(m))
124#define CS_IN_USE(m) (atomic_read(m) != 0)
125
126#define CS_DBGBREAKPOINT {__asm__("INT $3");}
127/*
128 * CS461x definitions
129 */
130
131#define CS461X_BA0_SIZE 0x2000
132#define CS461X_BA1_DATA0_SIZE 0x3000
133#define CS461X_BA1_DATA1_SIZE 0x3800
134#define CS461X_BA1_PRG_SIZE 0x7000
135#define CS461X_BA1_REG_SIZE 0x0100
136
137#define GOF_PER_SEC 200
138
139#define CSDEBUG_INTERFACE 1
140#define CSDEBUG 1
141/*
142 * Turn on/off debugging compilation by using 1/0 respectively for CSDEBUG
143 *
144 *
145 * CSDEBUG is usual mode is set to 1, then use the
146 * cs_debuglevel and cs_debugmask to turn on or off debugging.
147 * Debug level of 1 has been defined to be kernel errors and info
148 * that should be printed on any released driver.
149 */
150#if CSDEBUG
151#define CS_DBGOUT(mask,level,x) if ((cs_debuglevel >= (level)) && ((mask) & cs_debugmask)) {x;}
152#else
153#define CS_DBGOUT(mask,level,x)
154#endif
155/*
156 * cs_debugmask areas
157 */
158#define CS_INIT 0x00000001 /* initialization and probe functions */
159#define CS_ERROR 0x00000002 /* tmp debugging bit placeholder */
160#define CS_INTERRUPT 0x00000004 /* interrupt handler (separate from all other) */
161#define CS_FUNCTION 0x00000008 /* enter/leave functions */
162#define CS_WAVE_WRITE 0x00000010 /* write information for wave */
163#define CS_WAVE_READ 0x00000020 /* read information for wave */
164#define CS_MIDI_WRITE 0x00000040 /* write information for midi */
165#define CS_MIDI_READ 0x00000080 /* read information for midi */
166#define CS_MPU401_WRITE 0x00000100 /* write information for mpu401 */
167#define CS_MPU401_READ 0x00000200 /* read information for mpu401 */
168#define CS_OPEN 0x00000400 /* all open functions in the driver */
169#define CS_RELEASE 0x00000800 /* all release functions in the driver */
170#define CS_PARMS 0x00001000 /* functional and operational parameters */
171#define CS_IOCTL 0x00002000 /* ioctl (non-mixer) */
172#define CS_PM 0x00004000 /* PM */
173#define CS_TMP 0x10000000 /* tmp debug mask bit */
174
175#define CS_IOCTL_CMD_SUSPEND 0x1 // suspend
176#define CS_IOCTL_CMD_RESUME 0x2 // resume
177
178#if CSDEBUG
179static unsigned long cs_debuglevel = 1; /* levels range from 1-9 */
180module_param(cs_debuglevel, ulong, 0644);
181static unsigned long cs_debugmask = CS_INIT | CS_ERROR; /* use CS_DBGOUT with various mask values */
182module_param(cs_debugmask, ulong, 0644);
183#endif
184static unsigned long hercules_egpio_disable; /* if non-zero set all EGPIO to 0 */
185module_param(hercules_egpio_disable, ulong, 0);
186static unsigned long initdelay = 700; /* PM delay in millisecs */
187module_param(initdelay, ulong, 0);
188static unsigned long powerdown = -1; /* turn on/off powerdown processing in driver */
189module_param(powerdown, ulong, 0);
190#define DMABUF_DEFAULTORDER 3
191static unsigned long defaultorder = DMABUF_DEFAULTORDER;
192module_param(defaultorder, ulong, 0);
193
194static int external_amp;
195module_param(external_amp, bool, 0);
196static int thinkpad;
197module_param(thinkpad, bool, 0);
198
199/*
200* set the powerdown module parm to 0 to disable all
201* powerdown. also set thinkpad to 1 to disable powerdown,
202* but also to enable the clkrun functionality.
203*/
204static unsigned cs_powerdown = 1;
205static unsigned cs_laptop_wait = 1;
206
207/* An instance of the 4610 channel */
208struct cs_channel
209{
210 int used;
211 int num;
212 void *state;
213};
214
215#define CS46XX_MAJOR_VERSION "1"
216#define CS46XX_MINOR_VERSION "28"
217
218#ifdef __ia64__
219#define CS46XX_ARCH "64" //architecture key
220#else
221#define CS46XX_ARCH "32" //architecture key
222#endif
223
224static struct list_head cs46xx_devs = { &cs46xx_devs, &cs46xx_devs };
225
226/* magic numbers to protect our data structures */
227#define CS_CARD_MAGIC 0x43525553 /* "CRUS" */
228#define CS_STATE_MAGIC 0x4c4f4749 /* "LOGI" */
229#define NR_HW_CH 3
230
231/* maxinum number of AC97 codecs connected, AC97 2.0 defined 4 */
232#define NR_AC97 2
233
234static const unsigned sample_size[] = { 1, 2, 2, 4 };
235static const unsigned sample_shift[] = { 0, 1, 1, 2 };
236
237/* "software" or virtual channel, an instance of opened /dev/dsp */
238struct cs_state {
239 unsigned int magic;
240 struct cs_card *card; /* Card info */
241
242 /* single open lock mechanism, only used for recording */
243 struct mutex open_mutex;
244 wait_queue_head_t open_wait;
245
246 /* file mode */
247 mode_t open_mode;
248
249 /* virtual channel number */
250 int virt;
251
252 struct dmabuf {
253 /* wave sample stuff */
254 unsigned int rate;
255 unsigned char fmt, enable;
256
257 /* hardware channel */
258 struct cs_channel *channel;
259 int pringbuf; /* Software ring slot */
260 void *pbuf; /* 4K hardware DMA buffer */
261
262 /* OSS buffer management stuff */
263 void *rawbuf;
264 dma_addr_t dma_handle;
265 unsigned buforder;
266 unsigned numfrag;
267 unsigned fragshift;
268 unsigned divisor;
269 unsigned type;
270 void *tmpbuff; /* tmp buffer for sample conversions */
271 dma_addr_t dmaaddr;
272 dma_addr_t dmaaddr_tmpbuff;
273 unsigned buforder_tmpbuff; /* Log base 2 of size in bytes.. */
274
275 /* our buffer acts like a circular ring */
276 unsigned hwptr; /* where dma last started, updated by update_ptr */
277 unsigned swptr; /* where driver last clear/filled, updated by read/write */
278 int count; /* bytes to be comsumed or been generated by dma machine */
279 unsigned total_bytes; /* total bytes dmaed by hardware */
280 unsigned blocks; /* total blocks */
281
282 unsigned error; /* number of over/underruns */
283 unsigned underrun; /* underrun pending before next write has occurred */
284 wait_queue_head_t wait; /* put process on wait queue when no more space in buffer */
285
286 /* redundant, but makes calculations easier */
287 unsigned fragsize;
288 unsigned dmasize;
289 unsigned fragsamples;
290
291 /* OSS stuff */
292 unsigned mapped:1;
293 unsigned ready:1;
294 unsigned endcleared:1;
295 unsigned SGok:1;
296 unsigned update_flag;
297 unsigned ossfragshift;
298 int ossmaxfrags;
299 unsigned subdivision;
300 } dmabuf;
301 /* Guard against mmap/write/read races */
302 struct mutex sem;
303};
304
305struct cs_card {
306 struct cs_channel channel[2];
307 unsigned int magic;
308
309 /* We keep cs461x cards in a linked list */
310 struct cs_card *next;
311
312 /* The cs461x has a certain amount of cross channel interaction
313 so we use a single per card lock */
314 spinlock_t lock;
315
316 /* Keep AC97 sane */
317 spinlock_t ac97_lock;
318
319 /* mixer use count */
320 atomic_t mixer_use_cnt;
321
322 /* PCI device stuff */
323 struct pci_dev *pci_dev;
324 struct list_head list;
325
326 unsigned int pctl, cctl; /* Hardware DMA flag sets */
327
328 /* soundcore stuff */
329 int dev_audio;
330 int dev_midi;
331
332 /* structures for abstraction of hardware facilities, codecs, banks and channels*/
333 struct ac97_codec *ac97_codec[NR_AC97];
334 struct cs_state *states[2];
335
336 u16 ac97_features;
337
338 int amplifier; /* Amplifier control */
339 void (*amplifier_ctrl)(struct cs_card *, int);
340 void (*amp_init)(struct cs_card *);
341
342 int active; /* Active clocking */
343 void (*active_ctrl)(struct cs_card *, int);
344
345 /* hardware resources */
346 unsigned long ba0_addr;
347 unsigned long ba1_addr;
348 u32 irq;
349
350 /* mappings */
351 void __iomem *ba0;
352 union
353 {
354 struct
355 {
356 u8 __iomem *data0;
357 u8 __iomem *data1;
358 u8 __iomem *pmem;
359 u8 __iomem *reg;
360 } name;
361 u8 __iomem *idx[4];
362 } ba1;
363
364 /* Function support */
365 struct cs_channel *(*alloc_pcm_channel)(struct cs_card *);
366 struct cs_channel *(*alloc_rec_pcm_channel)(struct cs_card *);
367 void (*free_pcm_channel)(struct cs_card *, int chan);
368
369 /* /dev/midi stuff */
370 struct {
371 unsigned ird, iwr, icnt;
372 unsigned ord, owr, ocnt;
373 wait_queue_head_t open_wait;
374 wait_queue_head_t iwait;
375 wait_queue_head_t owait;
376 spinlock_t lock;
377 unsigned char ibuf[CS_MIDIINBUF];
378 unsigned char obuf[CS_MIDIOUTBUF];
379 mode_t open_mode;
380 struct mutex open_mutex;
381 } midi;
382 struct cs46xx_pm pm;
383};
384
385static int cs_open_mixdev(struct inode *inode, struct file *file);
386static int cs_release_mixdev(struct inode *inode, struct file *file);
387static int cs_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
388 unsigned long arg);
389static int cs_hardware_init(struct cs_card *card);
390static int cs46xx_powerup(struct cs_card *card, unsigned int type);
391static int cs461x_powerdown(struct cs_card *card, unsigned int type, int suspendflag);
392static void cs461x_clear_serial_FIFOs(struct cs_card *card, int type);
393#ifdef CONFIG_PM
394static int cs46xx_suspend_tbl(struct pci_dev *pcidev, pm_message_t state);
395static int cs46xx_resume_tbl(struct pci_dev *pcidev);
396#endif
397
398#if CSDEBUG
399
400/* DEBUG ROUTINES */
401
402#define SOUND_MIXER_CS_GETDBGLEVEL _SIOWR('M',120, int)
403#define SOUND_MIXER_CS_SETDBGLEVEL _SIOWR('M',121, int)
404#define SOUND_MIXER_CS_GETDBGMASK _SIOWR('M',122, int)
405#define SOUND_MIXER_CS_SETDBGMASK _SIOWR('M',123, int)
406#define SOUND_MIXER_CS_APM _SIOWR('M',124, int)
407
408static void printioctl(unsigned int x)
409{
410 unsigned int i;
411 unsigned char vidx;
412 /* these values are incorrect for the ac97 driver, fix.
413 * Index of mixtable1[] member is Device ID
414 * and must be <= SOUND_MIXER_NRDEVICES.
415 * Value of array member is index into s->mix.vol[]
416 */
417 static const unsigned char mixtable1[SOUND_MIXER_NRDEVICES] = {
418 [SOUND_MIXER_PCM] = 1, /* voice */
419 [SOUND_MIXER_LINE1] = 2, /* AUX */
420 [SOUND_MIXER_CD] = 3, /* CD */
421 [SOUND_MIXER_LINE] = 4, /* Line */
422 [SOUND_MIXER_SYNTH] = 5, /* FM */
423 [SOUND_MIXER_MIC] = 6, /* Mic */
424 [SOUND_MIXER_SPEAKER] = 7, /* Speaker */
425 [SOUND_MIXER_RECLEV] = 8, /* Recording level */
426 [SOUND_MIXER_VOLUME] = 9 /* Master Volume */
427 };
428
429 switch (x) {
430 case SOUND_MIXER_CS_GETDBGMASK:
431 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_CS_GETDBGMASK: ") );
432 break;
433 case SOUND_MIXER_CS_GETDBGLEVEL:
434 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_CS_GETDBGLEVEL: ") );
435 break;
436 case SOUND_MIXER_CS_SETDBGMASK:
437 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_CS_SETDBGMASK: ") );
438 break;
439 case SOUND_MIXER_CS_SETDBGLEVEL:
440 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_CS_SETDBGLEVEL: ") );
441 break;
442 case OSS_GETVERSION:
443 CS_DBGOUT(CS_IOCTL, 4, printk("OSS_GETVERSION: ") );
444 break;
445 case SNDCTL_DSP_SYNC:
446 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SYNC: ") );
447 break;
448 case SNDCTL_DSP_SETDUPLEX:
449 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SETDUPLEX: ") );
450 break;
451 case SNDCTL_DSP_GETCAPS:
452 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETCAPS: ") );
453 break;
454 case SNDCTL_DSP_RESET:
455 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_RESET: ") );
456 break;
457 case SNDCTL_DSP_SPEED:
458 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SPEED: ") );
459 break;
460 case SNDCTL_DSP_STEREO:
461 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_STEREO: ") );
462 break;
463 case SNDCTL_DSP_CHANNELS:
464 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_CHANNELS: ") );
465 break;
466 case SNDCTL_DSP_GETFMTS:
467 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETFMTS: ") );
468 break;
469 case SNDCTL_DSP_SETFMT:
470 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SETFMT: ") );
471 break;
472 case SNDCTL_DSP_POST:
473 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_POST: ") );
474 break;
475 case SNDCTL_DSP_GETTRIGGER:
476 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETTRIGGER: ") );
477 break;
478 case SNDCTL_DSP_SETTRIGGER:
479 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SETTRIGGER: ") );
480 break;
481 case SNDCTL_DSP_GETOSPACE:
482 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETOSPACE: ") );
483 break;
484 case SNDCTL_DSP_GETISPACE:
485 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETISPACE: ") );
486 break;
487 case SNDCTL_DSP_NONBLOCK:
488 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_NONBLOCK: ") );
489 break;
490 case SNDCTL_DSP_GETODELAY:
491 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETODELAY: ") );
492 break;
493 case SNDCTL_DSP_GETIPTR:
494 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETIPTR: ") );
495 break;
496 case SNDCTL_DSP_GETOPTR:
497 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETOPTR: ") );
498 break;
499 case SNDCTL_DSP_GETBLKSIZE:
500 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_GETBLKSIZE: ") );
501 break;
502 case SNDCTL_DSP_SETFRAGMENT:
503 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SETFRAGMENT: ") );
504 break;
505 case SNDCTL_DSP_SUBDIVIDE:
506 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SUBDIVIDE: ") );
507 break;
508 case SOUND_PCM_READ_RATE:
509 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_PCM_READ_RATE: ") );
510 break;
511 case SOUND_PCM_READ_CHANNELS:
512 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_PCM_READ_CHANNELS: ") );
513 break;
514 case SOUND_PCM_READ_BITS:
515 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_PCM_READ_BITS: ") );
516 break;
517 case SOUND_PCM_WRITE_FILTER:
518 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_PCM_WRITE_FILTER: ") );
519 break;
520 case SNDCTL_DSP_SETSYNCRO:
521 CS_DBGOUT(CS_IOCTL, 4, printk("SNDCTL_DSP_SETSYNCRO: ") );
522 break;
523 case SOUND_PCM_READ_FILTER:
524 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_PCM_READ_FILTER: ") );
525 break;
526 case SOUND_MIXER_PRIVATE1:
527 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_PRIVATE1: ") );
528 break;
529 case SOUND_MIXER_PRIVATE2:
530 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_PRIVATE2: ") );
531 break;
532 case SOUND_MIXER_PRIVATE3:
533 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_PRIVATE3: ") );
534 break;
535 case SOUND_MIXER_PRIVATE4:
536 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_PRIVATE4: ") );
537 break;
538 case SOUND_MIXER_PRIVATE5:
539 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_PRIVATE5: ") );
540 break;
541 case SOUND_MIXER_INFO:
542 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_INFO: ") );
543 break;
544 case SOUND_OLD_MIXER_INFO:
545 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_OLD_MIXER_INFO: ") );
546 break;
547 default:
548 switch (_IOC_NR(x)) {
549 case SOUND_MIXER_VOLUME:
550 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_VOLUME: ") );
551 break;
552 case SOUND_MIXER_SPEAKER:
553 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_SPEAKER: ") );
554 break;
555 case SOUND_MIXER_RECLEV:
556 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_RECLEV: ") );
557 break;
558 case SOUND_MIXER_MIC:
559 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_MIC: ") );
560 break;
561 case SOUND_MIXER_SYNTH:
562 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_SYNTH: ") );
563 break;
564 case SOUND_MIXER_RECSRC:
565 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_RECSRC: ") );
566 break;
567 case SOUND_MIXER_DEVMASK:
568 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_DEVMASK: ") );
569 break;
570 case SOUND_MIXER_RECMASK:
571 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_RECMASK: ") );
572 break;
573 case SOUND_MIXER_STEREODEVS:
574 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_STEREODEVS: ") );
575 break;
576 case SOUND_MIXER_CAPS:
577 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_CAPS:") );
578 break;
579 default:
580 i = _IOC_NR(x);
581 if (i >= SOUND_MIXER_NRDEVICES || !(vidx = mixtable1[i])) {
582 CS_DBGOUT(CS_IOCTL, 4, printk("UNKNOWN IOCTL: 0x%.8x NR=%d ",x,i) );
583 } else {
584 CS_DBGOUT(CS_IOCTL, 4, printk("SOUND_MIXER_IOCTL AC9x: 0x%.8x NR=%d ",
585 x,i));
586 }
587 break;
588 }
589 }
590 CS_DBGOUT(CS_IOCTL, 4, printk("command = 0x%x IOC_NR=%d\n",x, _IOC_NR(x)) );
591}
592#endif
593
594/*
595 * common I/O routines
596 */
597
598static void cs461x_poke(struct cs_card *codec, unsigned long reg, unsigned int val)
599{
600 writel(val, codec->ba1.idx[(reg >> 16) & 3] + (reg & 0xffff));
601}
602
603static unsigned int cs461x_peek(struct cs_card *codec, unsigned long reg)
604{
605 return readl(codec->ba1.idx[(reg >> 16) & 3] + (reg & 0xffff));
606}
607
608static void cs461x_pokeBA0(struct cs_card *codec, unsigned long reg, unsigned int val)
609{
610 writel(val, codec->ba0 + reg);
611}
612
613static unsigned int cs461x_peekBA0(struct cs_card *codec, unsigned long reg)
614{
615 return readl(codec->ba0 + reg);
616}
617
618
619static u16 cs_ac97_get(struct ac97_codec *dev, u8 reg);
620static void cs_ac97_set(struct ac97_codec *dev, u8 reg, u16 data);
621
622static struct cs_channel *cs_alloc_pcm_channel(struct cs_card *card)
623{
624 if (card->channel[1].used == 1)
625 return NULL;
626 card->channel[1].used = 1;
627 card->channel[1].num = 1;
628 return &card->channel[1];
629}
630
631static struct cs_channel *cs_alloc_rec_pcm_channel(struct cs_card *card)
632{
633 if (card->channel[0].used == 1)
634 return NULL;
635 card->channel[0].used = 1;
636 card->channel[0].num = 0;
637 return &card->channel[0];
638}
639
640static void cs_free_pcm_channel(struct cs_card *card, int channel)
641{
642 card->channel[channel].state = NULL;
643 card->channel[channel].used = 0;
644}
645
646/*
647 * setup a divisor value to help with conversion from
648 * 16bit Stereo, down to 8bit stereo/mono or 16bit mono.
649 * assign a divisor of 1 if using 16bit Stereo as that is
650 * the only format that the static image will capture.
651 */
652static void cs_set_divisor(struct dmabuf *dmabuf)
653{
654 if (dmabuf->type == CS_TYPE_DAC)
655 dmabuf->divisor = 1;
656 else if (!(dmabuf->fmt & CS_FMT_STEREO) &&
657 (dmabuf->fmt & CS_FMT_16BIT))
658 dmabuf->divisor = 2;
659 else if ((dmabuf->fmt & CS_FMT_STEREO) &&
660 !(dmabuf->fmt & CS_FMT_16BIT))
661 dmabuf->divisor = 2;
662 else if (!(dmabuf->fmt & CS_FMT_STEREO) &&
663 !(dmabuf->fmt & CS_FMT_16BIT))
664 dmabuf->divisor = 4;
665 else
666 dmabuf->divisor = 1;
667
668 CS_DBGOUT(CS_PARMS | CS_FUNCTION, 8, printk(
669 "cs46xx: cs_set_divisor()- %s %d\n",
670 (dmabuf->type == CS_TYPE_ADC) ? "ADC" : "DAC",
671 dmabuf->divisor) );
672}
673
674/*
675* mute some of the more prevalent registers to avoid popping.
676*/
677static void cs_mute(struct cs_card *card, int state)
678{
679 struct ac97_codec *dev = card->ac97_codec[0];
680
681 CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_INFO "cs46xx: cs_mute()+ %s\n",
682 (state == CS_TRUE) ? "Muting" : "UnMuting"));
683
684 if (state == CS_TRUE) {
685 /*
686 * fix pops when powering up on thinkpads
687 */
688 card->pm.u32AC97_master_volume = (u32)cs_ac97_get( dev,
689 (u8)BA0_AC97_MASTER_VOLUME);
690 card->pm.u32AC97_headphone_volume = (u32)cs_ac97_get(dev,
691 (u8)BA0_AC97_HEADPHONE_VOLUME);
692 card->pm.u32AC97_master_volume_mono = (u32)cs_ac97_get(dev,
693 (u8)BA0_AC97_MASTER_VOLUME_MONO);
694 card->pm.u32AC97_pcm_out_volume = (u32)cs_ac97_get(dev,
695 (u8)BA0_AC97_PCM_OUT_VOLUME);
696
697 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME, 0x8000);
698 cs_ac97_set(dev, (u8)BA0_AC97_HEADPHONE_VOLUME, 0x8000);
699 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME_MONO, 0x8000);
700 cs_ac97_set(dev, (u8)BA0_AC97_PCM_OUT_VOLUME, 0x8000);
701 } else {
702 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME, card->pm.u32AC97_master_volume);
703 cs_ac97_set(dev, (u8)BA0_AC97_HEADPHONE_VOLUME, card->pm.u32AC97_headphone_volume);
704 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME_MONO, card->pm.u32AC97_master_volume_mono);
705 cs_ac97_set(dev, (u8)BA0_AC97_PCM_OUT_VOLUME, card->pm.u32AC97_pcm_out_volume);
706 }
707 CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_INFO "cs46xx: cs_mute()-\n"));
708}
709
710/* set playback sample rate */
711static unsigned int cs_set_dac_rate(struct cs_state * state, unsigned int rate)
712{
713 struct dmabuf *dmabuf = &state->dmabuf;
714 unsigned int tmp1, tmp2;
715 unsigned int phiIncr;
716 unsigned int correctionPerGOF, correctionPerSec;
717 unsigned long flags;
718
719 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_set_dac_rate()+ %d\n",rate) );
720
721 /*
722 * Compute the values used to drive the actual sample rate conversion.
723 * The following formulas are being computed, using inline assembly
724 * since we need to use 64 bit arithmetic to compute the values:
725 *
726 * phiIncr = floor((Fs,in * 2^26) / Fs,out)
727 * correctionPerGOF = floor((Fs,in * 2^26 - Fs,out * phiIncr) /
728 * GOF_PER_SEC)
729 * ulCorrectionPerSec = Fs,in * 2^26 - Fs,out * phiIncr -M
730 * GOF_PER_SEC * correctionPerGOF
731 *
732 * i.e.
733 *
734 * phiIncr:other = dividend:remainder((Fs,in * 2^26) / Fs,out)
735 * correctionPerGOF:correctionPerSec =
736 * dividend:remainder(ulOther / GOF_PER_SEC)
737 */
738 tmp1 = rate << 16;
739 phiIncr = tmp1 / 48000;
740 tmp1 -= phiIncr * 48000;
741 tmp1 <<= 10;
742 phiIncr <<= 10;
743 tmp2 = tmp1 / 48000;
744 phiIncr += tmp2;
745 tmp1 -= tmp2 * 48000;
746 correctionPerGOF = tmp1 / GOF_PER_SEC;
747 tmp1 -= correctionPerGOF * GOF_PER_SEC;
748 correctionPerSec = tmp1;
749
750 /*
751 * Fill in the SampleRateConverter control block.
752 */
753 spin_lock_irqsave(&state->card->lock, flags);
754 cs461x_poke(state->card, BA1_PSRC,
755 ((correctionPerSec << 16) & 0xFFFF0000) | (correctionPerGOF & 0xFFFF));
756 cs461x_poke(state->card, BA1_PPI, phiIncr);
757 spin_unlock_irqrestore(&state->card->lock, flags);
758 dmabuf->rate = rate;
759
760 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_set_dac_rate()- %d\n",rate) );
761 return rate;
762}
763
764/* set recording sample rate */
765static unsigned int cs_set_adc_rate(struct cs_state *state, unsigned int rate)
766{
767 struct dmabuf *dmabuf = &state->dmabuf;
768 struct cs_card *card = state->card;
769 unsigned int phiIncr, coeffIncr, tmp1, tmp2;
770 unsigned int correctionPerGOF, correctionPerSec, initialDelay;
771 unsigned int frameGroupLength, cnt;
772 unsigned long flags;
773 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_set_adc_rate()+ %d\n",rate) );
774
775 /*
776 * We can only decimate by up to a factor of 1/9th the hardware rate.
777 * Correct the value if an attempt is made to stray outside that limit.
778 */
779 if ((rate * 9) < 48000)
780 rate = 48000 / 9;
781
782 /*
783 * We cannot capture at at rate greater than the Input Rate (48000).
784 * Return an error if an attempt is made to stray outside that limit.
785 */
786 if (rate > 48000)
787 rate = 48000;
788
789 /*
790 * Compute the values used to drive the actual sample rate conversion.
791 * The following formulas are being computed, using inline assembly
792 * since we need to use 64 bit arithmetic to compute the values:
793 *
794 * coeffIncr = -floor((Fs,out * 2^23) / Fs,in)
795 * phiIncr = floor((Fs,in * 2^26) / Fs,out)
796 * correctionPerGOF = floor((Fs,in * 2^26 - Fs,out * phiIncr) /
797 * GOF_PER_SEC)
798 * correctionPerSec = Fs,in * 2^26 - Fs,out * phiIncr -
799 * GOF_PER_SEC * correctionPerGOF
800 * initialDelay = ceil((24 * Fs,in) / Fs,out)
801 *
802 * i.e.
803 *
804 * coeffIncr = neg(dividend((Fs,out * 2^23) / Fs,in))
805 * phiIncr:ulOther = dividend:remainder((Fs,in * 2^26) / Fs,out)
806 * correctionPerGOF:correctionPerSec =
807 * dividend:remainder(ulOther / GOF_PER_SEC)
808 * initialDelay = dividend(((24 * Fs,in) + Fs,out - 1) / Fs,out)
809 */
810 tmp1 = rate << 16;
811 coeffIncr = tmp1 / 48000;
812 tmp1 -= coeffIncr * 48000;
813 tmp1 <<= 7;
814 coeffIncr <<= 7;
815 coeffIncr += tmp1 / 48000;
816 coeffIncr ^= 0xFFFFFFFF;
817 coeffIncr++;
818 tmp1 = 48000 << 16;
819 phiIncr = tmp1 / rate;
820 tmp1 -= phiIncr * rate;
821 tmp1 <<= 10;
822 phiIncr <<= 10;
823 tmp2 = tmp1 / rate;
824 phiIncr += tmp2;
825 tmp1 -= tmp2 * rate;
826 correctionPerGOF = tmp1 / GOF_PER_SEC;
827 tmp1 -= correctionPerGOF * GOF_PER_SEC;
828 correctionPerSec = tmp1;
829 initialDelay = ((48000 * 24) + rate - 1) / rate;
830
831 /*
832 * Fill in the VariDecimate control block.
833 */
834 spin_lock_irqsave(&card->lock, flags);
835 cs461x_poke(card, BA1_CSRC,
836 ((correctionPerSec << 16) & 0xFFFF0000) | (correctionPerGOF & 0xFFFF));
837 cs461x_poke(card, BA1_CCI, coeffIncr);
838 cs461x_poke(card, BA1_CD,
839 (((BA1_VARIDEC_BUF_1 + (initialDelay << 2)) << 16) & 0xFFFF0000) | 0x80);
840 cs461x_poke(card, BA1_CPI, phiIncr);
841 spin_unlock_irqrestore(&card->lock, flags);
842
843 /*
844 * Figure out the frame group length for the write back task. Basically,
845 * this is just the factors of 24000 (2^6*3*5^3) that are not present in
846 * the output sample rate.
847 */
848 frameGroupLength = 1;
849 for (cnt = 2; cnt <= 64; cnt *= 2) {
850 if (((rate / cnt) * cnt) != rate)
851 frameGroupLength *= 2;
852 }
853 if (((rate / 3) * 3) != rate) {
854 frameGroupLength *= 3;
855 }
856 for (cnt = 5; cnt <= 125; cnt *= 5) {
857 if (((rate / cnt) * cnt) != rate)
858 frameGroupLength *= 5;
859 }
860
861 /*
862 * Fill in the WriteBack control block.
863 */
864 spin_lock_irqsave(&card->lock, flags);
865 cs461x_poke(card, BA1_CFG1, frameGroupLength);
866 cs461x_poke(card, BA1_CFG2, (0x00800000 | frameGroupLength));
867 cs461x_poke(card, BA1_CCST, 0x0000FFFF);
868 cs461x_poke(card, BA1_CSPB, ((65536 * rate) / 24000));
869 cs461x_poke(card, (BA1_CSPB + 4), 0x0000FFFF);
870 spin_unlock_irqrestore(&card->lock, flags);
871 dmabuf->rate = rate;
872 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_set_adc_rate()- %d\n",rate) );
873 return rate;
874}
875
876/* prepare channel attributes for playback */
877static void cs_play_setup(struct cs_state *state)
878{
879 struct dmabuf *dmabuf = &state->dmabuf;
880 struct cs_card *card = state->card;
881 unsigned int tmp, Count, playFormat;
882
883 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_play_setup()+\n") );
884 cs461x_poke(card, BA1_PVOL, 0x80008000);
885 if (!dmabuf->SGok)
886 cs461x_poke(card, BA1_PBA, virt_to_bus(dmabuf->pbuf));
887
888 Count = 4;
889 playFormat=cs461x_peek(card, BA1_PFIE);
890 if ((dmabuf->fmt & CS_FMT_STEREO)) {
891 playFormat &= ~DMA_RQ_C2_AC_MONO_TO_STEREO;
892 Count *= 2;
893 } else
894 playFormat |= DMA_RQ_C2_AC_MONO_TO_STEREO;
895
896 if ((dmabuf->fmt & CS_FMT_16BIT)) {
897 playFormat &= ~(DMA_RQ_C2_AC_8_TO_16_BIT
898 | DMA_RQ_C2_AC_SIGNED_CONVERT);
899 Count *= 2;
900 } else
901 playFormat |= (DMA_RQ_C2_AC_8_TO_16_BIT
902 | DMA_RQ_C2_AC_SIGNED_CONVERT);
903
904 cs461x_poke(card, BA1_PFIE, playFormat);
905
906 tmp = cs461x_peek(card, BA1_PDTC);
907 tmp &= 0xfffffe00;
908 cs461x_poke(card, BA1_PDTC, tmp | --Count);
909
910 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_play_setup()-\n") );
911}
912
913static struct InitStruct
914{
915 u32 off;
916 u32 val;
917} InitArray[] = { {0x00000040, 0x3fc0000f},
918 {0x0000004c, 0x04800000},
919
920 {0x000000b3, 0x00000780},
921 {0x000000b7, 0x00000000},
922 {0x000000bc, 0x07800000},
923
924 {0x000000cd, 0x00800000},
925 };
926
927/*
928 * "SetCaptureSPValues()" -- Initialize record task values before each
929 * capture startup.
930 */
931static void SetCaptureSPValues(struct cs_card *card)
932{
933 unsigned i, offset;
934 CS_DBGOUT(CS_FUNCTION, 8, printk("cs46xx: SetCaptureSPValues()+\n") );
935 for (i = 0; i < sizeof(InitArray) / sizeof(struct InitStruct); i++) {
936 offset = InitArray[i].off*4; /* 8bit to 32bit offset value */
937 cs461x_poke(card, offset, InitArray[i].val );
938 }
939 CS_DBGOUT(CS_FUNCTION, 8, printk("cs46xx: SetCaptureSPValues()-\n") );
940}
941
942/* prepare channel attributes for recording */
943static void cs_rec_setup(struct cs_state *state)
944{
945 struct cs_card *card = state->card;
946 struct dmabuf *dmabuf = &state->dmabuf;
947
948 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_rec_setup()+\n"));
949 SetCaptureSPValues(card);
950
951 /*
952 * set the attenuation to 0dB
953 */
954 cs461x_poke(card, BA1_CVOL, 0x80008000);
955
956 /*
957 * set the physical address of the capture buffer into the SP
958 */
959 cs461x_poke(card, BA1_CBA, virt_to_bus(dmabuf->rawbuf));
960
961 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_rec_setup()-\n") );
962}
963
964
965/* get current playback/recording dma buffer pointer (byte offset from LBA),
966 called with spinlock held! */
967
968static inline unsigned cs_get_dma_addr(struct cs_state *state)
969{
970 struct dmabuf *dmabuf = &state->dmabuf;
971 u32 offset;
972
973 if ( (!(dmabuf->enable & DAC_RUNNING)) &&
974 (!(dmabuf->enable & ADC_RUNNING) ) )
975 {
976 CS_DBGOUT(CS_ERROR, 2, printk(
977 "cs46xx: ERROR cs_get_dma_addr(): not enabled \n") );
978 return 0;
979 }
980
981 /*
982 * granularity is byte boundary, good part.
983 */
984 if (dmabuf->enable & DAC_RUNNING)
985 offset = cs461x_peek(state->card, BA1_PBA);
986 else /* ADC_RUNNING must be set */
987 offset = cs461x_peek(state->card, BA1_CBA);
988
989 CS_DBGOUT(CS_PARMS | CS_FUNCTION, 9,
990 printk("cs46xx: cs_get_dma_addr() %d\n",offset) );
991 offset = (u32)bus_to_virt((unsigned long)offset) - (u32)dmabuf->rawbuf;
992 CS_DBGOUT(CS_PARMS | CS_FUNCTION, 8,
993 printk("cs46xx: cs_get_dma_addr()- %d\n",offset) );
994 return offset;
995}
996
997static void resync_dma_ptrs(struct cs_state *state)
998{
999 struct dmabuf *dmabuf;
1000
1001 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: resync_dma_ptrs()+ \n") );
1002 if (state) {
1003 dmabuf = &state->dmabuf;
1004 dmabuf->hwptr=dmabuf->swptr = 0;
1005 dmabuf->pringbuf = 0;
1006 }
1007 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: resync_dma_ptrs()- \n") );
1008}
1009
1010/* Stop recording (lock held) */
1011static inline void __stop_adc(struct cs_state *state)
1012{
1013 struct dmabuf *dmabuf = &state->dmabuf;
1014 struct cs_card *card = state->card;
1015 unsigned int tmp;
1016
1017 dmabuf->enable &= ~ADC_RUNNING;
1018
1019 tmp = cs461x_peek(card, BA1_CCTL);
1020 tmp &= 0xFFFF0000;
1021 cs461x_poke(card, BA1_CCTL, tmp );
1022}
1023
1024static void stop_adc(struct cs_state *state)
1025{
1026 unsigned long flags;
1027
1028 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: stop_adc()+ \n") );
1029 spin_lock_irqsave(&state->card->lock, flags);
1030 __stop_adc(state);
1031 spin_unlock_irqrestore(&state->card->lock, flags);
1032 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: stop_adc()- \n") );
1033}
1034
1035static void start_adc(struct cs_state *state)
1036{
1037 struct dmabuf *dmabuf = &state->dmabuf;
1038 struct cs_card *card = state->card;
1039 unsigned long flags;
1040 unsigned int tmp;
1041
1042 spin_lock_irqsave(&card->lock, flags);
1043 if (!(dmabuf->enable & ADC_RUNNING) &&
1044 ((dmabuf->mapped || dmabuf->count < (signed)dmabuf->dmasize)
1045 && dmabuf->ready) &&
1046 ((card->pm.flags & CS46XX_PM_IDLE) ||
1047 (card->pm.flags & CS46XX_PM_RESUMED)) )
1048 {
1049 dmabuf->enable |= ADC_RUNNING;
1050 cs_set_divisor(dmabuf);
1051 tmp = cs461x_peek(card, BA1_CCTL);
1052 tmp &= 0xFFFF0000;
1053 tmp |= card->cctl;
1054 CS_DBGOUT(CS_FUNCTION, 2, printk(
1055 "cs46xx: start_adc() poke 0x%x \n",tmp) );
1056 cs461x_poke(card, BA1_CCTL, tmp);
1057 }
1058 spin_unlock_irqrestore(&card->lock, flags);
1059}
1060
1061/* stop playback (lock held) */
1062static inline void __stop_dac(struct cs_state *state)
1063{
1064 struct dmabuf *dmabuf = &state->dmabuf;
1065 struct cs_card *card = state->card;
1066 unsigned int tmp;
1067
1068 dmabuf->enable &= ~DAC_RUNNING;
1069
1070 tmp=cs461x_peek(card, BA1_PCTL);
1071 tmp&=0xFFFF;
1072 cs461x_poke(card, BA1_PCTL, tmp);
1073}
1074
1075static void stop_dac(struct cs_state *state)
1076{
1077 unsigned long flags;
1078
1079 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: stop_dac()+ \n") );
1080 spin_lock_irqsave(&state->card->lock, flags);
1081 __stop_dac(state);
1082 spin_unlock_irqrestore(&state->card->lock, flags);
1083 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: stop_dac()- \n") );
1084}
1085
1086static void start_dac(struct cs_state *state)
1087{
1088 struct dmabuf *dmabuf = &state->dmabuf;
1089 struct cs_card *card = state->card;
1090 unsigned long flags;
1091 int tmp;
1092
1093 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: start_dac()+ \n") );
1094 spin_lock_irqsave(&card->lock, flags);
1095 if (!(dmabuf->enable & DAC_RUNNING) &&
1096 ((dmabuf->mapped || dmabuf->count > 0) && dmabuf->ready) &&
1097 ((card->pm.flags & CS46XX_PM_IDLE) ||
1098 (card->pm.flags & CS46XX_PM_RESUMED)) )
1099 {
1100 dmabuf->enable |= DAC_RUNNING;
1101 tmp = cs461x_peek(card, BA1_PCTL);
1102 tmp &= 0xFFFF;
1103 tmp |= card->pctl;
1104 CS_DBGOUT(CS_PARMS, 6, printk(
1105 "cs46xx: start_dac() poke card=%p tmp=0x%.08x addr=%p \n",
1106 card, (unsigned)tmp,
1107 card->ba1.idx[(BA1_PCTL >> 16) & 3]+(BA1_PCTL&0xffff) ) );
1108 cs461x_poke(card, BA1_PCTL, tmp);
1109 }
1110 spin_unlock_irqrestore(&card->lock, flags);
1111 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: start_dac()- \n") );
1112}
1113
1114#define DMABUF_MINORDER 1
1115
1116/*
1117 * allocate DMA buffer, playback and recording buffers are separate.
1118 */
1119static int alloc_dmabuf(struct cs_state *state)
1120{
1121
1122 struct cs_card *card=state->card;
1123 struct dmabuf *dmabuf = &state->dmabuf;
1124 void *rawbuf = NULL;
1125 void *tmpbuff = NULL;
1126 int order;
1127 struct page *map, *mapend;
1128 unsigned long df;
1129
1130 dmabuf->ready = dmabuf->mapped = 0;
1131 dmabuf->SGok = 0;
1132/*
1133* check for order within limits, but do not overwrite value.
1134*/
1135 if ((defaultorder > 1) && (defaultorder < 12))
1136 df = defaultorder;
1137 else
1138 df = 2;
1139
1140 for (order = df; order >= DMABUF_MINORDER; order--)
1141 if ((rawbuf = (void *)pci_alloc_consistent(
1142 card->pci_dev, PAGE_SIZE << order, &dmabuf->dmaaddr)))
1143 break;
1144 if (!rawbuf) {
1145 CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
1146 "cs46xx: alloc_dmabuf(): unable to allocate rawbuf\n"));
1147 return -ENOMEM;
1148 }
1149 dmabuf->buforder = order;
1150 dmabuf->rawbuf = rawbuf;
1151 // Now mark the pages as reserved; otherwise the
1152 // remap_pfn_range() in cs46xx_mmap doesn't work.
1153 // 1. get index to last page in mem_map array for rawbuf.
1154 mapend = virt_to_page(dmabuf->rawbuf +
1155 (PAGE_SIZE << dmabuf->buforder) - 1);
1156
1157 // 2. mark each physical page in range as 'reserved'.
1158 for (map = virt_to_page(dmabuf->rawbuf); map <= mapend; map++)
1159 cs4x_mem_map_reserve(map);
1160
1161 CS_DBGOUT(CS_PARMS, 9, printk("cs46xx: alloc_dmabuf(): allocated %ld (order = %d) bytes at %p\n",
1162 PAGE_SIZE << order, order, rawbuf) );
1163
1164/*
1165* only allocate the conversion buffer for the ADC
1166*/
1167 if (dmabuf->type == CS_TYPE_DAC) {
1168 dmabuf->tmpbuff = NULL;
1169 dmabuf->buforder_tmpbuff = 0;
1170 return 0;
1171 }
1172/*
1173 * now the temp buffer for 16/8 conversions
1174 */
1175
1176 tmpbuff = (void *) pci_alloc_consistent(
1177 card->pci_dev, PAGE_SIZE << order, &dmabuf->dmaaddr_tmpbuff);
1178
1179 if (!tmpbuff)
1180 return -ENOMEM;
1181 CS_DBGOUT(CS_PARMS, 9, printk("cs46xx: allocated %ld (order = %d) bytes at %p\n",
1182 PAGE_SIZE << order, order, tmpbuff) );
1183
1184 dmabuf->tmpbuff = tmpbuff;
1185 dmabuf->buforder_tmpbuff = order;
1186
1187 // Now mark the pages as reserved; otherwise the
1188 // remap_pfn_range() in cs46xx_mmap doesn't work.
1189 // 1. get index to last page in mem_map array for rawbuf.
1190 mapend = virt_to_page(dmabuf->tmpbuff +
1191 (PAGE_SIZE << dmabuf->buforder_tmpbuff) - 1);
1192
1193 // 2. mark each physical page in range as 'reserved'.
1194 for (map = virt_to_page(dmabuf->tmpbuff); map <= mapend; map++)
1195 cs4x_mem_map_reserve(map);
1196 return 0;
1197}
1198
1199/* free DMA buffer */
1200static void dealloc_dmabuf(struct cs_state *state)
1201{
1202 struct dmabuf *dmabuf = &state->dmabuf;
1203 struct page *map, *mapend;
1204
1205 if (dmabuf->rawbuf) {
1206 // Undo prog_dmabuf()'s marking the pages as reserved
1207 mapend = virt_to_page(dmabuf->rawbuf +
1208 (PAGE_SIZE << dmabuf->buforder) - 1);
1209 for (map = virt_to_page(dmabuf->rawbuf); map <= mapend; map++)
1210 cs4x_mem_map_unreserve(map);
1211 free_dmabuf(state->card, dmabuf);
1212 }
1213
1214 if (dmabuf->tmpbuff) {
1215 // Undo prog_dmabuf()'s marking the pages as reserved
1216 mapend = virt_to_page(dmabuf->tmpbuff +
1217 (PAGE_SIZE << dmabuf->buforder_tmpbuff) - 1);
1218 for (map = virt_to_page(dmabuf->tmpbuff); map <= mapend; map++)
1219 cs4x_mem_map_unreserve(map);
1220 free_dmabuf2(state->card, dmabuf);
1221 }
1222
1223 dmabuf->rawbuf = NULL;
1224 dmabuf->tmpbuff = NULL;
1225 dmabuf->mapped = dmabuf->ready = 0;
1226 dmabuf->SGok = 0;
1227}
1228
1229static int __prog_dmabuf(struct cs_state *state)
1230{
1231 struct dmabuf *dmabuf = &state->dmabuf;
1232 unsigned long flags;
1233 unsigned long allocated_pages, allocated_bytes;
1234 unsigned long tmp1, tmp2, fmt=0;
1235 unsigned long *ptmp = (unsigned long *) dmabuf->pbuf;
1236 unsigned long SGarray[9], nSGpages=0;
1237 int ret;
1238
1239 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf()+ \n"));
1240/*
1241 * check for CAPTURE and use only non-sg for initial release
1242 */
1243 if (dmabuf->type == CS_TYPE_ADC) {
1244 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf() ADC\n"));
1245 /*
1246 * add in non-sg support for capture.
1247 */
1248 spin_lock_irqsave(&state->card->lock, flags);
1249 /* add code to reset the rawbuf memory. TRW */
1250 resync_dma_ptrs(state);
1251 dmabuf->total_bytes = dmabuf->blocks = 0;
1252 dmabuf->count = dmabuf->error = dmabuf->underrun = 0;
1253
1254 dmabuf->SGok = 0;
1255
1256 spin_unlock_irqrestore(&state->card->lock, flags);
1257
1258 /* allocate DMA buffer if not allocated yet */
1259 if (!dmabuf->rawbuf || !dmabuf->tmpbuff)
1260 if ((ret = alloc_dmabuf(state)))
1261 return ret;
1262 /*
1263 * static image only supports 16Bit signed, stereo - hard code fmt
1264 */
1265 fmt = CS_FMT_16BIT | CS_FMT_STEREO;
1266
1267 dmabuf->numfrag = 2;
1268 dmabuf->fragsize = 2048;
1269 dmabuf->fragsamples = 2048 >> sample_shift[fmt];
1270 dmabuf->dmasize = 4096;
1271 dmabuf->fragshift = 11;
1272
1273 memset(dmabuf->rawbuf, (fmt & CS_FMT_16BIT) ? 0 : 0x80,
1274 dmabuf->dmasize);
1275 memset(dmabuf->tmpbuff, (fmt & CS_FMT_16BIT) ? 0 : 0x80,
1276 PAGE_SIZE<<dmabuf->buforder_tmpbuff);
1277
1278 /*
1279 * Now set up the ring
1280 */
1281
1282 spin_lock_irqsave(&state->card->lock, flags);
1283 cs_rec_setup(state);
1284 spin_unlock_irqrestore(&state->card->lock, flags);
1285
1286 /* set the ready flag for the dma buffer */
1287 dmabuf->ready = 1;
1288
1289 CS_DBGOUT(CS_PARMS, 4, printk(
1290 "cs46xx: prog_dmabuf(): CAPTURE rate=%d fmt=0x%x numfrag=%d "
1291 "fragsize=%d dmasize=%d\n",
1292 dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
1293 dmabuf->fragsize, dmabuf->dmasize) );
1294
1295 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf()- 0 \n"));
1296 return 0;
1297 } else if (dmabuf->type == CS_TYPE_DAC) {
1298 /*
1299 * Must be DAC
1300 */
1301 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf() DAC\n"));
1302 spin_lock_irqsave(&state->card->lock, flags);
1303 resync_dma_ptrs(state);
1304 dmabuf->total_bytes = dmabuf->blocks = 0;
1305 dmabuf->count = dmabuf->error = dmabuf->underrun = 0;
1306
1307 dmabuf->SGok = 0;
1308
1309 spin_unlock_irqrestore(&state->card->lock, flags);
1310
1311 /* allocate DMA buffer if not allocated yet */
1312 if (!dmabuf->rawbuf)
1313 if ((ret = alloc_dmabuf(state)))
1314 return ret;
1315
1316 allocated_pages = 1 << dmabuf->buforder;
1317 allocated_bytes = allocated_pages*PAGE_SIZE;
1318
1319 if (allocated_pages < 2) {
1320 CS_DBGOUT(CS_FUNCTION, 4, printk(
1321 "cs46xx: prog_dmabuf() Error: allocated_pages too small (%d)\n",
1322 (unsigned)allocated_pages));
1323 return -ENOMEM;
1324 }
1325
1326 /* Use all the pages allocated, fragsize 4k. */
1327 /* Use 'pbuf' for S/G page map table. */
1328 dmabuf->SGok = 1; /* Use S/G. */
1329
1330 nSGpages = allocated_bytes/4096; /* S/G pages always 4k. */
1331
1332 /* Set up S/G variables. */
1333 *ptmp = virt_to_bus(dmabuf->rawbuf);
1334 *(ptmp + 1) = 0x00000008;
1335 for (tmp1 = 1; tmp1 < nSGpages; tmp1++) {
1336 *(ptmp + 2 * tmp1) = virt_to_bus((dmabuf->rawbuf) + 4096 * tmp1);
1337 if (tmp1 == nSGpages - 1)
1338 tmp2 = 0xbfff0000;
1339 else
1340 tmp2 = 0x80000000 + 8 * (tmp1 + 1);
1341 *(ptmp + 2 * tmp1 + 1) = tmp2;
1342 }
1343 SGarray[0] = 0x82c0200d;
1344 SGarray[1] = 0xffff0000;
1345 SGarray[2] = *ptmp;
1346 SGarray[3] = 0x00010600;
1347 SGarray[4] = *(ptmp+2);
1348 SGarray[5] = 0x80000010;
1349 SGarray[6] = *ptmp;
1350 SGarray[7] = *(ptmp+2);
1351 SGarray[8] = (virt_to_bus(dmabuf->pbuf) & 0xffff000) | 0x10;
1352
1353 if (dmabuf->SGok) {
1354 dmabuf->numfrag = nSGpages;
1355 dmabuf->fragsize = 4096;
1356 dmabuf->fragsamples = 4096 >> sample_shift[dmabuf->fmt];
1357 dmabuf->fragshift = 12;
1358 dmabuf->dmasize = dmabuf->numfrag * 4096;
1359 } else {
1360 SGarray[0] = 0xf2c0000f;
1361 SGarray[1] = 0x00000200;
1362 SGarray[2] = 0;
1363 SGarray[3] = 0x00010600;
1364 SGarray[4]=SGarray[5]=SGarray[6]=SGarray[7]=SGarray[8] = 0;
1365 dmabuf->numfrag = 2;
1366 dmabuf->fragsize = 2048;
1367 dmabuf->fragsamples = 2048 >> sample_shift[dmabuf->fmt];
1368 dmabuf->dmasize = 4096;
1369 dmabuf->fragshift = 11;
1370 }
1371 for (tmp1 = 0; tmp1 < sizeof(SGarray) / 4; tmp1++)
1372 cs461x_poke(state->card, BA1_PDTC+tmp1 * 4, SGarray[tmp1]);
1373
1374 memset(dmabuf->rawbuf, (dmabuf->fmt & CS_FMT_16BIT) ? 0 : 0x80,
1375 dmabuf->dmasize);
1376
1377 /*
1378 * Now set up the ring
1379 */
1380
1381 spin_lock_irqsave(&state->card->lock, flags);
1382 cs_play_setup(state);
1383 spin_unlock_irqrestore(&state->card->lock, flags);
1384
1385 /* set the ready flag for the dma buffer */
1386 dmabuf->ready = 1;
1387
1388 CS_DBGOUT(CS_PARMS, 4, printk(
1389 "cs46xx: prog_dmabuf(): PLAYBACK rate=%d fmt=0x%x numfrag=%d "
1390 "fragsize=%d dmasize=%d\n",
1391 dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
1392 dmabuf->fragsize, dmabuf->dmasize) );
1393
1394 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf()- \n"));
1395 return 0;
1396 } else {
1397 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: prog_dmabuf()- Invalid Type %d\n",
1398 dmabuf->type));
1399 }
1400 return 1;
1401}
1402
1403static int prog_dmabuf(struct cs_state *state)
1404{
1405 int ret;
1406
1407 mutex_lock(&state->sem);
1408 ret = __prog_dmabuf(state);
1409 mutex_unlock(&state->sem);
1410
1411 return ret;
1412}
1413
1414static void cs_clear_tail(struct cs_state *state)
1415{
1416}
1417
1418static int drain_dac(struct cs_state *state, int nonblock)
1419{
1420 DECLARE_WAITQUEUE(wait, current);
1421 struct dmabuf *dmabuf = &state->dmabuf;
1422 struct cs_card *card=state->card;
1423 unsigned long flags;
1424 unsigned long tmo;
1425 int count;
1426
1427 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: drain_dac()+ \n"));
1428 if (dmabuf->mapped || !dmabuf->ready)
1429 {
1430 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: drain_dac()- 0, not ready\n"));
1431 return 0;
1432 }
1433
1434 add_wait_queue(&dmabuf->wait, &wait);
1435 for (;;) {
1436 /* It seems that we have to set the current state to TASK_INTERRUPTIBLE
1437 every time to make the process really go to sleep */
1438 current->state = TASK_INTERRUPTIBLE;
1439
1440 spin_lock_irqsave(&state->card->lock, flags);
1441 count = dmabuf->count;
1442 spin_unlock_irqrestore(&state->card->lock, flags);
1443
1444 if (count <= 0)
1445 break;
1446
1447 if (signal_pending(current))
1448 break;
1449
1450 if (nonblock) {
1451 remove_wait_queue(&dmabuf->wait, &wait);
1452 current->state = TASK_RUNNING;
1453 return -EBUSY;
1454 }
1455
1456 tmo = (dmabuf->dmasize * HZ) / dmabuf->rate;
1457 tmo >>= sample_shift[dmabuf->fmt];
1458 tmo += (2048*HZ)/dmabuf->rate;
1459
1460 if (!schedule_timeout(tmo ? tmo : 1) && tmo){
1461 printk(KERN_ERR "cs46xx: drain_dac, dma timeout? %d\n", count);
1462 break;
1463 }
1464 }
1465 remove_wait_queue(&dmabuf->wait, &wait);
1466 current->state = TASK_RUNNING;
1467 if (signal_pending(current)) {
1468 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: drain_dac()- -ERESTARTSYS\n"));
1469 /*
1470 * set to silence and let that clear the fifos.
1471 */
1472 cs461x_clear_serial_FIFOs(card, CS_TYPE_DAC);
1473 return -ERESTARTSYS;
1474 }
1475
1476 CS_DBGOUT(CS_FUNCTION, 4, printk("cs46xx: drain_dac()- 0\n"));
1477 return 0;
1478}
1479
1480
1481/* update buffer manangement pointers, especially, dmabuf->count and dmabuf->hwptr */
1482static void cs_update_ptr(struct cs_card *card, int wake)
1483{
1484 struct cs_state *state;
1485 struct dmabuf *dmabuf;
1486 unsigned hwptr;
1487 int diff;
1488
1489 /* error handling and process wake up for ADC */
1490 state = card->states[0];
1491 if (state) {
1492 dmabuf = &state->dmabuf;
1493 if (dmabuf->enable & ADC_RUNNING) {
1494 /* update hardware pointer */
1495 hwptr = cs_get_dma_addr(state);
1496
1497 diff = (dmabuf->dmasize + hwptr - dmabuf->hwptr) % dmabuf->dmasize;
1498 CS_DBGOUT(CS_PARMS, 9, printk(
1499 "cs46xx: cs_update_ptr()+ ADC hwptr=%d diff=%d\n",
1500 hwptr,diff) );
1501 dmabuf->hwptr = hwptr;
1502 dmabuf->total_bytes += diff;
1503 dmabuf->count += diff;
1504 if (dmabuf->count > dmabuf->dmasize)
1505 dmabuf->count = dmabuf->dmasize;
1506
1507 if (dmabuf->mapped) {
1508 if (wake && dmabuf->count >= (signed)dmabuf->fragsize)
1509 wake_up(&dmabuf->wait);
1510 } else {
1511 if (wake && dmabuf->count > 0)
1512 wake_up(&dmabuf->wait);
1513 }
1514 }
1515 }
1516
1517/*
1518 * Now the DAC
1519 */
1520 state = card->states[1];
1521 if (state) {
1522 dmabuf = &state->dmabuf;
1523 /* error handling and process wake up for DAC */
1524 if (dmabuf->enable & DAC_RUNNING) {
1525 /* update hardware pointer */
1526 hwptr = cs_get_dma_addr(state);
1527
1528 diff = (dmabuf->dmasize + hwptr - dmabuf->hwptr) % dmabuf->dmasize;
1529 CS_DBGOUT(CS_PARMS, 9, printk(
1530 "cs46xx: cs_update_ptr()+ DAC hwptr=%d diff=%d\n",
1531 hwptr,diff) );
1532 dmabuf->hwptr = hwptr;
1533 dmabuf->total_bytes += diff;
1534 if (dmabuf->mapped) {
1535 dmabuf->count += diff;
1536 if (wake && dmabuf->count >= (signed)dmabuf->fragsize)
1537 wake_up(&dmabuf->wait);
1538 /*
1539 * other drivers use fragsize, but don't see any sense
1540 * in that, since dmasize is the buffer asked for
1541 * via mmap.
1542 */
1543 if (dmabuf->count > dmabuf->dmasize)
1544 dmabuf->count &= dmabuf->dmasize-1;
1545 } else {
1546 dmabuf->count -= diff;
1547 /*
1548 * backfill with silence and clear out the last
1549 * "diff" number of bytes.
1550 */
1551 if (hwptr >= diff) {
1552 memset(dmabuf->rawbuf + hwptr - diff,
1553 (dmabuf->fmt & CS_FMT_16BIT) ? 0 : 0x80, diff);
1554 } else {
1555 memset(dmabuf->rawbuf,
1556 (dmabuf->fmt & CS_FMT_16BIT) ? 0 : 0x80,
1557 (unsigned)hwptr);
1558 memset((char *)dmabuf->rawbuf +
1559 dmabuf->dmasize + hwptr - diff,
1560 (dmabuf->fmt & CS_FMT_16BIT) ? 0 : 0x80,
1561 diff - hwptr);
1562 }
1563
1564 if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
1565 CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO
1566 "cs46xx: ERROR DAC count<0 or count > dmasize (%d)\n",
1567 dmabuf->count));
1568 /*
1569 * buffer underrun or buffer overrun, reset the
1570 * count of bytes written back to 0.
1571 */
1572 if (dmabuf->count < 0)
1573 dmabuf->underrun = 1;
1574 dmabuf->count = 0;
1575 dmabuf->error++;
1576 }
1577 if (wake && dmabuf->count < (signed)dmabuf->dmasize / 2)
1578 wake_up(&dmabuf->wait);
1579 }
1580 }
1581 }
1582}
1583
1584
1585/* hold spinlock for the following! */
1586static void cs_handle_midi(struct cs_card *card)
1587{
1588 unsigned char ch;
1589 int wake;
1590 unsigned temp1;
1591
1592 wake = 0;
1593 while (!(cs461x_peekBA0(card, BA0_MIDSR) & MIDSR_RBE)) {
1594 ch = cs461x_peekBA0(card, BA0_MIDRP);
1595 if (card->midi.icnt < CS_MIDIINBUF) {
1596 card->midi.ibuf[card->midi.iwr] = ch;
1597 card->midi.iwr = (card->midi.iwr + 1) % CS_MIDIINBUF;
1598 card->midi.icnt++;
1599 }
1600 wake = 1;
1601 }
1602 if (wake)
1603 wake_up(&card->midi.iwait);
1604 wake = 0;
1605 while (!(cs461x_peekBA0(card, BA0_MIDSR) & MIDSR_TBF) && card->midi.ocnt > 0) {
1606 temp1 = ( card->midi.obuf[card->midi.ord] ) & 0x000000ff;
1607 cs461x_pokeBA0(card, BA0_MIDWP,temp1);
1608 card->midi.ord = (card->midi.ord + 1) % CS_MIDIOUTBUF;
1609 card->midi.ocnt--;
1610 if (card->midi.ocnt < CS_MIDIOUTBUF-16)
1611 wake = 1;
1612 }
1613 if (wake)
1614 wake_up(&card->midi.owait);
1615}
1616
1617static irqreturn_t cs_interrupt(int irq, void *dev_id)
1618{
1619 struct cs_card *card = (struct cs_card *)dev_id;
1620 /* Single channel card */
1621 struct cs_state *recstate = card->channel[0].state;
1622 struct cs_state *playstate = card->channel[1].state;
1623 u32 status;
1624
1625 CS_DBGOUT(CS_INTERRUPT, 9, printk("cs46xx: cs_interrupt()+ \n"));
1626
1627 spin_lock(&card->lock);
1628
1629 status = cs461x_peekBA0(card, BA0_HISR);
1630
1631 if ((status & 0x7fffffff) == 0) {
1632 cs461x_pokeBA0(card, BA0_HICR, HICR_CHGM|HICR_IEV);
1633 spin_unlock(&card->lock);
1634 return IRQ_HANDLED; /* Might be IRQ_NONE.. */
1635 }
1636
1637 /*
1638 * check for playback or capture interrupt only
1639 */
1640 if (((status & HISR_VC0) && playstate && playstate->dmabuf.ready) ||
1641 (((status & HISR_VC1) && recstate && recstate->dmabuf.ready))) {
1642 CS_DBGOUT(CS_INTERRUPT, 8, printk(
1643 "cs46xx: cs_interrupt() interrupt bit(s) set (0x%x)\n",status));
1644 cs_update_ptr(card, CS_TRUE);
1645 }
1646
1647 if (status & HISR_MIDI)
1648 cs_handle_midi(card);
1649
1650 /* clear 'em */
1651 cs461x_pokeBA0(card, BA0_HICR, HICR_CHGM|HICR_IEV);
1652 spin_unlock(&card->lock);
1653 CS_DBGOUT(CS_INTERRUPT, 9, printk("cs46xx: cs_interrupt()- \n"));
1654 return IRQ_HANDLED;
1655}
1656
1657
1658/**********************************************************************/
1659
1660static ssize_t cs_midi_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
1661{
1662 struct cs_card *card = file->private_data;
1663 ssize_t ret;
1664 unsigned long flags;
1665 unsigned ptr;
1666 int cnt;
1667
1668 if (!access_ok(VERIFY_WRITE, buffer, count))
1669 return -EFAULT;
1670 ret = 0;
1671 while (count > 0) {
1672 spin_lock_irqsave(&card->lock, flags);
1673 ptr = card->midi.ird;
1674 cnt = CS_MIDIINBUF - ptr;
1675 if (card->midi.icnt < cnt)
1676 cnt = card->midi.icnt;
1677 spin_unlock_irqrestore(&card->lock, flags);
1678 if (cnt > count)
1679 cnt = count;
1680 if (cnt <= 0) {
1681 if (file->f_flags & O_NONBLOCK)
1682 return ret ? ret : -EAGAIN;
1683 interruptible_sleep_on(&card->midi.iwait);
1684 if (signal_pending(current))
1685 return ret ? ret : -ERESTARTSYS;
1686 continue;
1687 }
1688 if (copy_to_user(buffer, card->midi.ibuf + ptr, cnt))
1689 return ret ? ret : -EFAULT;
1690 ptr = (ptr + cnt) % CS_MIDIINBUF;
1691 spin_lock_irqsave(&card->lock, flags);
1692 card->midi.ird = ptr;
1693 card->midi.icnt -= cnt;
1694 spin_unlock_irqrestore(&card->lock, flags);
1695 count -= cnt;
1696 buffer += cnt;
1697 ret += cnt;
1698 }
1699 return ret;
1700}
1701
1702
1703static ssize_t cs_midi_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
1704{
1705 struct cs_card *card = file->private_data;
1706 ssize_t ret;
1707 unsigned long flags;
1708 unsigned ptr;
1709 int cnt;
1710
1711 if (!access_ok(VERIFY_READ, buffer, count))
1712 return -EFAULT;
1713 ret = 0;
1714 while (count > 0) {
1715 spin_lock_irqsave(&card->lock, flags);
1716 ptr = card->midi.owr;
1717 cnt = CS_MIDIOUTBUF - ptr;
1718 if (card->midi.ocnt + cnt > CS_MIDIOUTBUF)
1719 cnt = CS_MIDIOUTBUF - card->midi.ocnt;
1720 if (cnt <= 0)
1721 cs_handle_midi(card);
1722 spin_unlock_irqrestore(&card->lock, flags);
1723 if (cnt > count)
1724 cnt = count;
1725 if (cnt <= 0) {
1726 if (file->f_flags & O_NONBLOCK)
1727 return ret ? ret : -EAGAIN;
1728 interruptible_sleep_on(&card->midi.owait);
1729 if (signal_pending(current))
1730 return ret ? ret : -ERESTARTSYS;
1731 continue;
1732 }
1733 if (copy_from_user(card->midi.obuf + ptr, buffer, cnt))
1734 return ret ? ret : -EFAULT;
1735 ptr = (ptr + cnt) % CS_MIDIOUTBUF;
1736 spin_lock_irqsave(&card->lock, flags);
1737 card->midi.owr = ptr;
1738 card->midi.ocnt += cnt;
1739 spin_unlock_irqrestore(&card->lock, flags);
1740 count -= cnt;
1741 buffer += cnt;
1742 ret += cnt;
1743 spin_lock_irqsave(&card->lock, flags);
1744 cs_handle_midi(card);
1745 spin_unlock_irqrestore(&card->lock, flags);
1746 }
1747 return ret;
1748}
1749
1750
1751static unsigned int cs_midi_poll(struct file *file, struct poll_table_struct *wait)
1752{
1753 struct cs_card *card = file->private_data;
1754 unsigned long flags;
1755 unsigned int mask = 0;
1756
1757 if (file->f_flags & FMODE_WRITE)
1758 poll_wait(file, &card->midi.owait, wait);
1759 if (file->f_flags & FMODE_READ)
1760 poll_wait(file, &card->midi.iwait, wait);
1761 spin_lock_irqsave(&card->lock, flags);
1762 if (file->f_flags & FMODE_READ) {
1763 if (card->midi.icnt > 0)
1764 mask |= POLLIN | POLLRDNORM;
1765 }
1766 if (file->f_flags & FMODE_WRITE) {
1767 if (card->midi.ocnt < CS_MIDIOUTBUF)
1768 mask |= POLLOUT | POLLWRNORM;
1769 }
1770 spin_unlock_irqrestore(&card->lock, flags);
1771 return mask;
1772}
1773
1774
1775static int cs_midi_open(struct inode *inode, struct file *file)
1776{
1777 unsigned int minor = iminor(inode);
1778 struct cs_card *card = NULL;
1779 unsigned long flags;
1780 struct list_head *entry;
1781
1782 list_for_each(entry, &cs46xx_devs) {
1783 card = list_entry(entry, struct cs_card, list);
1784 if (card->dev_midi == minor)
1785 break;
1786 }
1787
1788 if (entry == &cs46xx_devs)
1789 return -ENODEV;
1790 if (!card) {
1791 CS_DBGOUT(CS_FUNCTION | CS_OPEN, 2, printk(KERN_INFO
1792 "cs46xx: cs46xx_midi_open(): Error - unable to find card struct\n"));
1793 return -ENODEV;
1794 }
1795
1796 file->private_data = card;
1797 /* wait for device to become free */
1798 mutex_lock(&card->midi.open_mutex);
1799 while (card->midi.open_mode & file->f_mode) {
1800 if (file->f_flags & O_NONBLOCK) {
1801 mutex_unlock(&card->midi.open_mutex);
1802 return -EBUSY;
1803 }
1804 mutex_unlock(&card->midi.open_mutex);
1805 interruptible_sleep_on(&card->midi.open_wait);
1806 if (signal_pending(current))
1807 return -ERESTARTSYS;
1808 mutex_lock(&card->midi.open_mutex);
1809 }
1810 spin_lock_irqsave(&card->midi.lock, flags);
1811 if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) {
1812 card->midi.ird = card->midi.iwr = card->midi.icnt = 0;
1813 card->midi.ord = card->midi.owr = card->midi.ocnt = 0;
1814 card->midi.ird = card->midi.iwr = card->midi.icnt = 0;
1815 cs461x_pokeBA0(card, BA0_MIDCR, 0x0000000f); /* Enable xmit, rcv. */
1816 cs461x_pokeBA0(card, BA0_HICR, HICR_IEV | HICR_CHGM); /* Enable interrupts */
1817 }
1818 if (file->f_mode & FMODE_READ)
1819 card->midi.ird = card->midi.iwr = card->midi.icnt = 0;
1820 if (file->f_mode & FMODE_WRITE)
1821 card->midi.ord = card->midi.owr = card->midi.ocnt = 0;
1822 spin_unlock_irqrestore(&card->midi.lock, flags);
1823 card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
1824 mutex_unlock(&card->midi.open_mutex);
1825 return 0;
1826}
1827
1828
1829static int cs_midi_release(struct inode *inode, struct file *file)
1830{
1831 struct cs_card *card = file->private_data;
1832 DECLARE_WAITQUEUE(wait, current);
1833 unsigned long flags;
1834 unsigned count, tmo;
1835
1836 if (file->f_mode & FMODE_WRITE) {
1837 current->state = TASK_INTERRUPTIBLE;
1838 add_wait_queue(&card->midi.owait, &wait);
1839 for (;;) {
1840 spin_lock_irqsave(&card->midi.lock, flags);
1841 count = card->midi.ocnt;
1842 spin_unlock_irqrestore(&card->midi.lock, flags);
1843 if (count <= 0)
1844 break;
1845 if (signal_pending(current))
1846 break;
1847 if (file->f_flags & O_NONBLOCK)
1848 break;
1849 tmo = (count * HZ) / 3100;
1850 if (!schedule_timeout(tmo ? : 1) && tmo)
1851 printk(KERN_DEBUG "cs46xx: midi timed out??\n");
1852 }
1853 remove_wait_queue(&card->midi.owait, &wait);
1854 current->state = TASK_RUNNING;
1855 }
1856 mutex_lock(&card->midi.open_mutex);
1857 card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE)));
1858 mutex_unlock(&card->midi.open_mutex);
1859 wake_up(&card->midi.open_wait);
1860 return 0;
1861}
1862
1863/*
1864 * Midi file operations struct.
1865 */
1866static /*const*/ struct file_operations cs_midi_fops = {
1867 CS_OWNER CS_THIS_MODULE
1868 .llseek = no_llseek,
1869 .read = cs_midi_read,
1870 .write = cs_midi_write,
1871 .poll = cs_midi_poll,
1872 .open = cs_midi_open,
1873 .release = cs_midi_release,
1874};
1875
1876/*
1877 *
1878 * CopySamples copies 16-bit stereo signed samples from the source to the
1879 * destination, possibly converting down to unsigned 8-bit and/or mono.
1880 * count specifies the number of output bytes to write.
1881 *
1882 * Arguments:
1883 *
1884 * dst - Pointer to a destination buffer.
1885 * src - Pointer to a source buffer
1886 * count - The number of bytes to copy into the destination buffer.
1887 * fmt - CS_FMT_16BIT and/or CS_FMT_STEREO bits
1888 * dmabuf - pointer to the dma buffer structure
1889 *
1890 * NOTES: only call this routine if the output desired is not 16 Signed Stereo
1891 *
1892 *
1893 */
1894static void CopySamples(char *dst, char *src, int count, unsigned fmt,
1895 struct dmabuf *dmabuf)
1896{
1897 s32 s32AudioSample;
1898 s16 *psSrc = (s16 *)src;
1899 s16 *psDst = (s16 *)dst;
1900 u8 *pucDst = (u8 *)dst;
1901
1902 CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_INFO "cs46xx: CopySamples()+ ") );
1903 CS_DBGOUT(CS_WAVE_READ, 8, printk(KERN_INFO
1904 " dst=%p src=%p count=%d fmt=0x%x\n",
1905 dst,src,count,fmt) );
1906
1907 /*
1908 * See if the data should be output as 8-bit unsigned stereo.
1909 */
1910 if ((fmt & CS_FMT_STEREO) && !(fmt & CS_FMT_16BIT)) {
1911 /*
1912 * Convert each 16-bit signed stereo sample to 8-bit unsigned
1913 * stereo using rounding.
1914 */
1915 psSrc = (s16 *)src;
1916 count = count / 2;
1917 while (count--)
1918 *(pucDst++) = (u8)(((s16)(*psSrc++) + (s16)0x8000) >> 8);
1919 }
1920 /*
1921 * See if the data should be output at 8-bit unsigned mono.
1922 */
1923 else if (!(fmt & CS_FMT_STEREO) && !(fmt & CS_FMT_16BIT)) {
1924 /*
1925 * Convert each 16-bit signed stereo sample to 8-bit unsigned
1926 * mono using averaging and rounding.
1927 */
1928 psSrc = (s16 *)src;
1929 count = count / 2;
1930 while (count--) {
1931 s32AudioSample = ((*psSrc) + (*(psSrc + 1))) / 2 + (s32)0x80;
1932 if (s32AudioSample > 0x7fff)
1933 s32AudioSample = 0x7fff;
1934 *(pucDst++) = (u8)(((s16)s32AudioSample + (s16)0x8000) >> 8);
1935 psSrc += 2;
1936 }
1937 }
1938 /*
1939 * See if the data should be output at 16-bit signed mono.
1940 */
1941 else if (!(fmt & CS_FMT_STEREO) && (fmt & CS_FMT_16BIT)) {
1942 /*
1943 * Convert each 16-bit signed stereo sample to 16-bit signed
1944 * mono using averaging.
1945 */
1946 psSrc = (s16 *)src;
1947 count = count / 2;
1948 while (count--) {
1949 *(psDst++) = (s16)((*psSrc) + (*(psSrc + 1))) / 2;
1950 psSrc += 2;
1951 }
1952 }
1953}
1954
1955/*
1956 * cs_copy_to_user()
1957 * replacement for the standard copy_to_user, to allow for a conversion from
1958 * 16 bit to 8 bit and from stereo to mono, if the record conversion is active.
1959 * The current CS46xx/CS4280 static image only records in 16bit unsigned Stereo,
1960 * so we convert from any of the other format combinations.
1961 */
1962static unsigned cs_copy_to_user(
1963 struct cs_state *s,
1964 void __user *dest,
1965 void *hwsrc,
1966 unsigned cnt,
1967 unsigned *copied)
1968{
1969 struct dmabuf *dmabuf = &s->dmabuf;
1970 void *src = hwsrc; /* default to the standard destination buffer addr */
1971
1972 CS_DBGOUT(CS_FUNCTION, 6, printk(KERN_INFO
1973 "cs_copy_to_user()+ fmt=0x%x cnt=%d dest=%p\n",
1974 dmabuf->fmt,(unsigned)cnt,dest) );
1975
1976 if (cnt > dmabuf->dmasize)
1977 cnt = dmabuf->dmasize;
1978 if (!cnt) {
1979 *copied = 0;
1980 return 0;
1981 }
1982 if (dmabuf->divisor != 1) {
1983 if (!dmabuf->tmpbuff) {
1984 *copied = cnt / dmabuf->divisor;
1985 return 0;
1986 }
1987
1988 CopySamples((char *)dmabuf->tmpbuff, (char *)hwsrc, cnt,
1989 dmabuf->fmt, dmabuf);
1990 src = dmabuf->tmpbuff;
1991 cnt = cnt/dmabuf->divisor;
1992 }
1993 if (copy_to_user(dest, src, cnt)) {
1994 CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_ERR
1995 "cs46xx: cs_copy_to_user()- fault dest=%p src=%p cnt=%d\n",
1996 dest,src,cnt));
1997 *copied = 0;
1998 return -EFAULT;
1999 }
2000 *copied = cnt;
2001 CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_INFO
2002 "cs46xx: cs_copy_to_user()- copied bytes is %d \n",cnt));
2003 return 0;
2004}
2005
2006/* in this loop, dmabuf.count signifies the amount of data that is waiting to be copied to
2007 the user's buffer. it is filled by the dma machine and drained by this loop. */
2008static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
2009{
2010 struct cs_card *card = file->private_data;
2011 struct cs_state *state;
2012 DECLARE_WAITQUEUE(wait, current);
2013 struct dmabuf *dmabuf;
2014 ssize_t ret = 0;
2015 unsigned long flags;
2016 unsigned swptr;
2017 int cnt;
2018 unsigned copied = 0;
2019
2020 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4,
2021 printk("cs46xx: cs_read()+ %zd\n",count) );
2022 state = card->states[0];
2023 if (!state)
2024 return -ENODEV;
2025 dmabuf = &state->dmabuf;
2026
2027 if (dmabuf->mapped)
2028 return -ENXIO;
2029 if (!access_ok(VERIFY_WRITE, buffer, count))
2030 return -EFAULT;
2031
2032 mutex_lock(&state->sem);
2033 if (!dmabuf->ready && (ret = __prog_dmabuf(state)))
2034 goto out2;
2035
2036 add_wait_queue(&state->dmabuf.wait, &wait);
2037 while (count > 0) {
2038 while (!(card->pm.flags & CS46XX_PM_IDLE)) {
2039 schedule();
2040 if (signal_pending(current)) {
2041 if (!ret)
2042 ret = -ERESTARTSYS;
2043 goto out;
2044 }
2045 }
2046 spin_lock_irqsave(&state->card->lock, flags);
2047 swptr = dmabuf->swptr;
2048 cnt = dmabuf->dmasize - swptr;
2049 if (dmabuf->count < cnt)
2050 cnt = dmabuf->count;
2051 if (cnt <= 0)
2052 __set_current_state(TASK_INTERRUPTIBLE);
2053 spin_unlock_irqrestore(&state->card->lock, flags);
2054
2055 if (cnt > (count * dmabuf->divisor))
2056 cnt = count * dmabuf->divisor;
2057 if (cnt <= 0) {
2058 /* buffer is empty, start the dma machine and wait for data to be
2059 recorded */
2060 start_adc(state);
2061 if (file->f_flags & O_NONBLOCK) {
2062 if (!ret)
2063 ret = -EAGAIN;
2064 goto out;
2065 }
2066 mutex_unlock(&state->sem);
2067 schedule();
2068 if (signal_pending(current)) {
2069 if (!ret)
2070 ret = -ERESTARTSYS;
2071 goto out;
2072 }
2073 mutex_lock(&state->sem);
2074 if (dmabuf->mapped) {
2075 if (!ret)
2076 ret = -ENXIO;
2077 goto out;
2078 }
2079 continue;
2080 }
2081
2082 CS_DBGOUT(CS_WAVE_READ, 2, printk(KERN_INFO
2083 "_read() copy_to cnt=%d count=%zd ", cnt,count) );
2084 CS_DBGOUT(CS_WAVE_READ, 8, printk(KERN_INFO
2085 " .dmasize=%d .count=%d buffer=%p ret=%zd\n",
2086 dmabuf->dmasize,dmabuf->count,buffer,ret));
2087
2088 if (cs_copy_to_user(state, buffer,
2089 (char *)dmabuf->rawbuf + swptr, cnt, &copied)) {
2090 if (!ret)
2091 ret = -EFAULT;
2092 goto out;
2093 }
2094 swptr = (swptr + cnt) % dmabuf->dmasize;
2095 spin_lock_irqsave(&card->lock, flags);
2096 dmabuf->swptr = swptr;
2097 dmabuf->count -= cnt;
2098 spin_unlock_irqrestore(&card->lock, flags);
2099 count -= copied;
2100 buffer += copied;
2101 ret += copied;
2102 start_adc(state);
2103 }
2104out:
2105 remove_wait_queue(&state->dmabuf.wait, &wait);
2106out2:
2107 mutex_unlock(&state->sem);
2108 set_current_state(TASK_RUNNING);
2109 CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4,
2110 printk("cs46xx: cs_read()- %zd\n",ret) );
2111 return ret;
2112}
2113
2114/* in this loop, dmabuf.count signifies the amount of data that is waiting to be dma to
2115 the soundcard. it is drained by the dma machine and filled by this loop. */
2116static ssize_t cs_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
2117{
2118 struct cs_card *card = file->private_data;
2119 struct cs_state *state;
2120 DECLARE_WAITQUEUE(wait, current);
2121 struct dmabuf *dmabuf;
2122 ssize_t ret;
2123 unsigned long flags;
2124 unsigned swptr;
2125 int cnt;
2126
2127 CS_DBGOUT(CS_WAVE_WRITE | CS_FUNCTION, 4,
2128 printk("cs46xx: cs_write called, count = %zd\n", count) );
2129 state = card->states[1];
2130 if (!state)
2131 return -ENODEV;
2132 if (!access_ok(VERIFY_READ, buffer, count))
2133 return -EFAULT;
2134 dmabuf = &state->dmabuf;
2135
2136 mutex_lock(&state->sem);
2137 if (dmabuf->mapped) {
2138 ret = -ENXIO;
2139 goto out;
2140 }
2141
2142 if (!dmabuf->ready && (ret = __prog_dmabuf(state)))
2143 goto out;
2144 add_wait_queue(&state->dmabuf.wait, &wait);
2145 ret = 0;
2146/*
2147* Start the loop to read from the user's buffer and write to the dma buffer.
2148* check for PM events and underrun/overrun in the loop.
2149*/
2150 while (count > 0) {
2151 while (!(card->pm.flags & CS46XX_PM_IDLE)) {
2152 schedule();
2153 if (signal_pending(current)) {
2154 if (!ret)
2155 ret = -ERESTARTSYS;
2156 goto out;
2157 }
2158 }
2159 spin_lock_irqsave(&state->card->lock, flags);
2160 if (dmabuf->count < 0) {
2161 /* buffer underrun, we are recovering from sleep_on_timeout,
2162 resync hwptr and swptr */
2163 dmabuf->count = 0;
2164 dmabuf->swptr = dmabuf->hwptr;
2165 }
2166 if (dmabuf->underrun) {
2167 dmabuf->underrun = 0;
2168 dmabuf->hwptr = cs_get_dma_addr(state);
2169 dmabuf->swptr = dmabuf->hwptr;
2170 }
2171
2172 swptr = dmabuf->swptr;
2173 cnt = dmabuf->dmasize - swptr;
2174 if (dmabuf->count + cnt > dmabuf->dmasize)
2175 cnt = dmabuf->dmasize - dmabuf->count;
2176 if (cnt <= 0)
2177 __set_current_state(TASK_INTERRUPTIBLE);
2178 spin_unlock_irqrestore(&state->card->lock, flags);
2179
2180 if (cnt > count)
2181 cnt = count;
2182 if (cnt <= 0) {
2183 /* buffer is full, start the dma machine and wait for data to be
2184 played */
2185 start_dac(state);
2186 if (file->f_flags & O_NONBLOCK) {
2187 if (!ret)
2188 ret = -EAGAIN;
2189 goto out;
2190 }
2191 mutex_unlock(&state->sem);
2192 schedule();
2193 if (signal_pending(current)) {
2194 if (!ret)
2195 ret = -ERESTARTSYS;
2196 goto out;
2197 }
2198 mutex_lock(&state->sem);
2199 if (dmabuf->mapped) {
2200 if (!ret)
2201 ret = -ENXIO;
2202 goto out;
2203 }
2204 continue;
2205 }
2206 if (copy_from_user(dmabuf->rawbuf + swptr, buffer, cnt)) {
2207 if (!ret)
2208 ret = -EFAULT;
2209 goto out;
2210 }
2211 spin_lock_irqsave(&state->card->lock, flags);
2212 swptr = (swptr + cnt) % dmabuf->dmasize;
2213 dmabuf->swptr = swptr;
2214 dmabuf->count += cnt;
2215 if (dmabuf->count > dmabuf->dmasize) {
2216 CS_DBGOUT(CS_WAVE_WRITE | CS_ERROR, 2, printk(
2217 "cs46xx: cs_write() d->count > dmasize - resetting\n"));
2218 dmabuf->count = dmabuf->dmasize;
2219 }
2220 dmabuf->endcleared = 0;
2221 spin_unlock_irqrestore(&state->card->lock, flags);
2222
2223 count -= cnt;
2224 buffer += cnt;
2225 ret += cnt;
2226 start_dac(state);
2227 }
2228out:
2229 mutex_unlock(&state->sem);
2230 remove_wait_queue(&state->dmabuf.wait, &wait);
2231 set_current_state(TASK_RUNNING);
2232
2233 CS_DBGOUT(CS_WAVE_WRITE | CS_FUNCTION, 2,
2234 printk("cs46xx: cs_write()- ret=%zd\n", ret));
2235 return ret;
2236}
2237
2238static unsigned int cs_poll(struct file *file, struct poll_table_struct *wait)
2239{
2240 struct cs_card *card = file->private_data;
2241 struct dmabuf *dmabuf;
2242 struct cs_state *state;
2243 unsigned long flags;
2244 unsigned int mask = 0;
2245
2246 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_poll()+ \n"));
2247 if (!(file->f_mode & (FMODE_WRITE | FMODE_READ))) {
2248 return -EINVAL;
2249 }
2250 if (file->f_mode & FMODE_WRITE) {
2251 state = card->states[1];
2252 if (state) {
2253 dmabuf = &state->dmabuf;
2254 poll_wait(file, &dmabuf->wait, wait);
2255 }
2256 }
2257 if (file->f_mode & FMODE_READ) {
2258 state = card->states[0];
2259 if (state) {
2260 dmabuf = &state->dmabuf;
2261 poll_wait(file, &dmabuf->wait, wait);
2262 }
2263 }
2264
2265 spin_lock_irqsave(&card->lock, flags);
2266 cs_update_ptr(card, CS_FALSE);
2267 if (file->f_mode & FMODE_READ) {
2268 state = card->states[0];
2269 if (state) {
2270 dmabuf = &state->dmabuf;
2271 if (dmabuf->count >= (signed)dmabuf->fragsize)
2272 mask |= POLLIN | POLLRDNORM;
2273 }
2274 }
2275 if (file->f_mode & FMODE_WRITE) {
2276 state = card->states[1];
2277 if (state) {
2278 dmabuf = &state->dmabuf;
2279 if (dmabuf->mapped) {
2280 if (dmabuf->count >= (signed)dmabuf->fragsize)
2281 mask |= POLLOUT | POLLWRNORM;
2282 } else {
2283 if ((signed)dmabuf->dmasize >= dmabuf->count
2284 + (signed)dmabuf->fragsize)
2285 mask |= POLLOUT | POLLWRNORM;
2286 }
2287 }
2288 }
2289 spin_unlock_irqrestore(&card->lock, flags);
2290
2291 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_poll()- (0x%x) \n",
2292 mask));
2293 return mask;
2294}
2295
2296/*
2297 * We let users mmap the ring buffer. Its not the real DMA buffer but
2298 * that side of the code is hidden in the IRQ handling. We do a software
2299 * emulation of DMA from a 64K or so buffer into a 2K FIFO.
2300 * (the hardware probably deserves a moan here but Crystal send me nice
2301 * toys ;)).
2302 */
2303
2304static int cs_mmap(struct file *file, struct vm_area_struct *vma)
2305{
2306 struct cs_card *card = file->private_data;
2307 struct cs_state *state;
2308 struct dmabuf *dmabuf;
2309 int ret = 0;
2310 unsigned long size;
2311
2312 CS_DBGOUT(CS_FUNCTION | CS_PARMS, 2, printk("cs46xx: cs_mmap()+ file=%p %s %s\n",
2313 file, vma->vm_flags & VM_WRITE ? "VM_WRITE" : "",
2314 vma->vm_flags & VM_READ ? "VM_READ" : "") );
2315
2316 if (vma->vm_flags & VM_WRITE) {
2317 state = card->states[1];
2318 if (state) {
2319 CS_DBGOUT(CS_OPEN, 2, printk(
2320 "cs46xx: cs_mmap() VM_WRITE - state TRUE prog_dmabuf DAC\n") );
2321 if ((ret = prog_dmabuf(state)) != 0)
2322 return ret;
2323 }
2324 } else if (vma->vm_flags & VM_READ) {
2325 state = card->states[0];
2326 if (state) {
2327 CS_DBGOUT(CS_OPEN, 2, printk(
2328 "cs46xx: cs_mmap() VM_READ - state TRUE prog_dmabuf ADC\n") );
2329 if ((ret = prog_dmabuf(state)) != 0)
2330 return ret;
2331 }
2332 } else {
2333 CS_DBGOUT(CS_ERROR, 2, printk(
2334 "cs46xx: cs_mmap() return -EINVAL\n") );
2335 return -EINVAL;
2336 }
2337
2338/*
2339 * For now ONLY support playback, but seems like the only way to use
2340 * mmap() is to open an FD with RDWR, just read or just write access
2341 * does not function, get an error back from the kernel.
2342 * Also, QuakeIII opens with RDWR! So, there must be something
2343 * to needing read/write access mapping. So, allow read/write but
2344 * use the DAC only.
2345 */
2346 state = card->states[1];
2347 if (!state) {
2348 ret = -EINVAL;
2349 goto out;
2350 }
2351
2352 mutex_lock(&state->sem);
2353 dmabuf = &state->dmabuf;
2354 if (cs4x_pgoff(vma) != 0) {
2355 ret = -EINVAL;
2356 goto out;
2357 }
2358 size = vma->vm_end - vma->vm_start;
2359
2360 CS_DBGOUT(CS_PARMS, 2, printk("cs46xx: cs_mmap(): size=%d\n",(unsigned)size) );
2361
2362 if (size > (PAGE_SIZE << dmabuf->buforder)) {
2363 ret = -EINVAL;
2364 goto out;
2365 }
2366 if (remap_pfn_range(vma, vma->vm_start,
2367 virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
2368 size, vma->vm_page_prot)) {
2369 ret = -EAGAIN;
2370 goto out;
2371 }
2372 dmabuf->mapped = 1;
2373
2374 CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") );
2375out:
2376 mutex_unlock(&state->sem);
2377 return ret;
2378}
2379
2380static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
2381{
2382 struct cs_card *card = file->private_data;
2383 struct cs_state *state;
2384 struct dmabuf *dmabuf = NULL;
2385 unsigned long flags;
2386 audio_buf_info abinfo;
2387 count_info cinfo;
2388 int val, valsave, ret;
2389 int mapped = 0;
2390 void __user *argp = (void __user *)arg;
2391 int __user *p = argp;
2392
2393 state = card->states[0];
2394 if (state) {
2395 dmabuf = &state->dmabuf;
2396 mapped = (file->f_mode & FMODE_READ) && dmabuf->mapped;
2397 }
2398 state = card->states[1];
2399 if (state) {
2400 dmabuf = &state->dmabuf;
2401 mapped |= (file->f_mode & FMODE_WRITE) && dmabuf->mapped;
2402 }
2403
2404#if CSDEBUG
2405 printioctl(cmd);
2406#endif
2407
2408 switch (cmd) {
2409 case OSS_GETVERSION:
2410 return put_user(SOUND_VERSION, p);
2411 case SNDCTL_DSP_RESET:
2412 /* FIXME: spin_lock ? */
2413 if (file->f_mode & FMODE_WRITE) {
2414 state = card->states[1];
2415 if (state) {
2416 dmabuf = &state->dmabuf;
2417 stop_dac(state);
2418 synchronize_irq(card->irq);
2419 dmabuf->ready = 0;
2420 resync_dma_ptrs(state);
2421 dmabuf->swptr = dmabuf->hwptr = 0;
2422 dmabuf->count = dmabuf->total_bytes = 0;
2423 dmabuf->blocks = 0;
2424 dmabuf->SGok = 0;
2425 }
2426 }
2427 if (file->f_mode & FMODE_READ) {
2428 state = card->states[0];
2429 if (state) {
2430 dmabuf = &state->dmabuf;
2431 stop_adc(state);
2432 synchronize_irq(card->irq);
2433 resync_dma_ptrs(state);
2434 dmabuf->ready = 0;
2435 dmabuf->swptr = dmabuf->hwptr = 0;
2436 dmabuf->count = dmabuf->total_bytes = 0;
2437 dmabuf->blocks = 0;
2438 dmabuf->SGok = 0;
2439 }
2440 }
2441 CS_DBGOUT(CS_IOCTL, 2, printk("cs46xx: DSP_RESET()-\n") );
2442 return 0;
2443 case SNDCTL_DSP_SYNC:
2444 if (file->f_mode & FMODE_WRITE)
2445 return drain_dac(state, file->f_flags & O_NONBLOCK);
2446 return 0;
2447 case SNDCTL_DSP_SPEED: /* set sample rate */
2448 if (get_user(val, p))
2449 return -EFAULT;
2450 if (val >= 0) {
2451 if (file->f_mode & FMODE_READ) {
2452 state = card->states[0];
2453 if (state) {
2454 dmabuf = &state->dmabuf;
2455 stop_adc(state);
2456 dmabuf->ready = 0;
2457 dmabuf->SGok = 0;
2458 cs_set_adc_rate(state, val);
2459 cs_set_divisor(dmabuf);
2460 }
2461 }
2462 if (file->f_mode & FMODE_WRITE) {
2463 state = card->states[1];
2464 if (state) {
2465 dmabuf = &state->dmabuf;
2466 stop_dac(state);
2467 dmabuf->ready = 0;
2468 dmabuf->SGok = 0;
2469 cs_set_dac_rate(state, val);
2470 cs_set_divisor(dmabuf);
2471 }
2472 }
2473 CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(
2474 "cs46xx: cs_ioctl() DSP_SPEED %s %s %d\n",
2475 file->f_mode & FMODE_WRITE ? "DAC" : "",
2476 file->f_mode & FMODE_READ ? "ADC" : "",
2477 dmabuf->rate ) );
2478 return put_user(dmabuf->rate, p);
2479 }
2480 return put_user(0, p);
2481 case SNDCTL_DSP_STEREO: /* set stereo or mono channel */
2482 if (get_user(val, p))
2483 return -EFAULT;
2484 if (file->f_mode & FMODE_WRITE) {
2485 state = card->states[1];
2486 if (state) {
2487 dmabuf = &state->dmabuf;
2488 stop_dac(state);
2489 dmabuf->ready = 0;
2490 dmabuf->SGok = 0;
2491 if (val)
2492 dmabuf->fmt |= CS_FMT_STEREO;
2493 else
2494 dmabuf->fmt &= ~CS_FMT_STEREO;
2495 cs_set_divisor(dmabuf);
2496 CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(
2497 "cs46xx: DSP_STEREO() DAC %s\n",
2498 (dmabuf->fmt & CS_FMT_STEREO) ?
2499 "STEREO":"MONO") );
2500 }
2501 }
2502 if (file->f_mode & FMODE_READ) {
2503 state = card->states[0];
2504 if (state) {
2505 dmabuf = &state->dmabuf;
2506 stop_adc(state);
2507 dmabuf->ready = 0;
2508 dmabuf->SGok = 0;
2509 if (val)
2510 dmabuf->fmt |= CS_FMT_STEREO;
2511 else
2512 dmabuf->fmt &= ~CS_FMT_STEREO;
2513 cs_set_divisor(dmabuf);
2514 CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(
2515 "cs46xx: DSP_STEREO() ADC %s\n",
2516 (dmabuf->fmt & CS_FMT_STEREO) ?
2517 "STEREO":"MONO") );
2518 }
2519 }
2520 return 0;
2521 case SNDCTL_DSP_GETBLKSIZE:
2522 if (file->f_mode & FMODE_WRITE) {
2523 state = card->states[1];
2524 if (state) {
2525 dmabuf = &state->dmabuf;
2526 if ((val = prog_dmabuf(state)))
2527 return val;
2528 return put_user(dmabuf->fragsize, p);
2529 }
2530 }
2531 if (file->f_mode & FMODE_READ) {
2532 state = card->states[0];
2533 if (state) {
2534 dmabuf = &state->dmabuf;
2535 if ((val = prog_dmabuf(state)))
2536 return val;
2537 return put_user(dmabuf->fragsize/dmabuf->divisor,
2538 p);
2539 }
2540 }
2541 return put_user(0, p);
2542 case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format*/
2543 return put_user(AFMT_S16_LE | AFMT_U8, p);
2544 case SNDCTL_DSP_SETFMT: /* Select sample format */
2545 if (get_user(val, p))
2546 return -EFAULT;
2547 CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(
2548 "cs46xx: cs_ioctl() DSP_SETFMT %s %s %s %s\n",
2549 file->f_mode & FMODE_WRITE ? "DAC" : "",
2550 file->f_mode & FMODE_READ ? "ADC" : "",
2551 val == AFMT_S16_LE ? "16Bit Signed" : "",
2552 val == AFMT_U8 ? "8Bit Unsigned" : "") );
2553 valsave = val;
2554 if (val != AFMT_QUERY) {
2555 if (val==AFMT_S16_LE || val==AFMT_U8) {
2556 if (file->f_mode & FMODE_WRITE) {
2557 state = card->states[1];
2558 if (state) {
2559 dmabuf = &state->dmabuf;
2560 stop_dac(state);
2561 dmabuf->ready = 0;
2562 dmabuf->SGok = 0;
2563 if (val == AFMT_S16_LE)
2564 dmabuf->fmt |= CS_FMT_16BIT;
2565 else
2566 dmabuf->fmt &= ~CS_FMT_16BIT;
2567 cs_set_divisor(dmabuf);
2568 if ((ret = prog_dmabuf(state)))
2569 return ret;
2570 }
2571 }
2572 if (file->f_mode & FMODE_READ) {
2573 val = valsave;
2574 state = card->states[0];
2575 if (state) {
2576 dmabuf = &state->dmabuf;
2577 stop_adc(state);
2578 dmabuf->ready = 0;
2579 dmabuf->SGok = 0;
2580 if (val == AFMT_S16_LE)
2581 dmabuf->fmt |= CS_FMT_16BIT;
2582 else
2583 dmabuf->fmt &= ~CS_FMT_16BIT;
2584 cs_set_divisor(dmabuf);
2585 if ((ret = prog_dmabuf(state)))
2586 return ret;
2587 }
2588 }
2589 } else {
2590 CS_DBGOUT(CS_IOCTL | CS_ERROR, 2, printk(
2591 "cs46xx: DSP_SETFMT() Unsupported format (0x%x)\n",
2592 valsave) );
2593 }
2594 } else {
2595 if (file->f_mode & FMODE_WRITE) {
2596 state = card->states[1];
2597 if (state)
2598 dmabuf = &state->dmabuf;
2599 } else if (file->f_mode & FMODE_READ) {
2600 state = card->states[0];
2601 if (state)
2602 dmabuf = &state->dmabuf;
2603 }
2604 }
2605 if (dmabuf) {
2606 if (dmabuf->fmt & CS_FMT_16BIT)
2607 return put_user(AFMT_S16_LE, p);
2608 else
2609 return put_user(AFMT_U8, p);
2610 }
2611 return put_user(0, p);
2612 case SNDCTL_DSP_CHANNELS:
2613 if (get_user(val, p))
2614 return -EFAULT;
2615 if (val != 0) {
2616 if (file->f_mode & FMODE_WRITE) {
2617 state = card->states[1];
2618 if (state) {
2619 dmabuf = &state->dmabuf;
2620 stop_dac(state);
2621 dmabuf->ready = 0;
2622 dmabuf->SGok = 0;
2623 if (val > 1)
2624 dmabuf->fmt |= CS_FMT_STEREO;
2625 else
2626 dmabuf->fmt &= ~CS_FMT_STEREO;
2627 cs_set_divisor(dmabuf);
2628 if (prog_dmabuf(state))
2629 return 0;
2630 }
2631 }
2632 if (file->f_mode & FMODE_READ) {
2633 state = card->states[0];
2634 if (state) {
2635 dmabuf = &state->dmabuf;
2636 stop_adc(state);
2637 dmabuf->ready = 0;
2638 dmabuf->SGok = 0;
2639 if (val > 1)
2640 dmabuf->fmt |= CS_FMT_STEREO;
2641 else
2642 dmabuf->fmt &= ~CS_FMT_STEREO;
2643 cs_set_divisor(dmabuf);
2644 if (prog_dmabuf(state))
2645 return 0;
2646 }
2647 }
2648 }
2649 return put_user((dmabuf->fmt & CS_FMT_STEREO) ? 2 : 1,
2650 p);
2651 case SNDCTL_DSP_POST:
2652 /*
2653 * There will be a longer than normal pause in the data.
2654 * so... do nothing, because there is nothing that we can do.
2655 */
2656 return 0;
2657 case SNDCTL_DSP_SUBDIVIDE:
2658 if (file->f_mode & FMODE_WRITE) {
2659 state = card->states[1];
2660 if (state) {
2661 dmabuf = &state->dmabuf;
2662 if (dmabuf->subdivision)
2663 return -EINVAL;
2664 if (get_user(val, p))
2665 return -EFAULT;
2666 if (val != 1 && val != 2)
2667 return -EINVAL;
2668 dmabuf->subdivision = val;
2669 }
2670 }
2671 if (file->f_mode & FMODE_READ) {
2672 state = card->states[0];
2673 if (state) {
2674 dmabuf = &state->dmabuf;
2675 if (dmabuf->subdivision)
2676 return -EINVAL;
2677 if (get_user(val, p))
2678 return -EFAULT;
2679 if (val != 1 && val != 2)
2680 return -EINVAL;
2681 dmabuf->subdivision = val;
2682 }
2683 }
2684 return 0;
2685 case SNDCTL_DSP_SETFRAGMENT:
2686 if (get_user(val, p))
2687 return -EFAULT;
2688 if (file->f_mode & FMODE_WRITE) {
2689 state = card->states[1];
2690 if (state) {
2691 dmabuf = &state->dmabuf;
2692 dmabuf->ossfragshift = val & 0xffff;
2693 dmabuf->ossmaxfrags = (val >> 16) & 0xffff;
2694 }
2695 }
2696 if (file->f_mode & FMODE_READ) {
2697 state = card->states[0];
2698 if (state) {
2699 dmabuf = &state->dmabuf;
2700 dmabuf->ossfragshift = val & 0xffff;
2701 dmabuf->ossmaxfrags = (val >> 16) & 0xffff;
2702 }
2703 }
2704 return 0;
2705 case SNDCTL_DSP_GETOSPACE:
2706 if (!(file->f_mode & FMODE_WRITE))
2707 return -EINVAL;
2708 state = card->states[1];
2709 if (state) {
2710 dmabuf = &state->dmabuf;
2711 spin_lock_irqsave(&state->card->lock, flags);
2712 cs_update_ptr(card, CS_TRUE);
2713 abinfo.fragsize = dmabuf->fragsize;
2714 abinfo.fragstotal = dmabuf->numfrag;
2715 /*
2716 * for mmap we always have total space available
2717 */
2718 if (dmabuf->mapped)
2719 abinfo.bytes = dmabuf->dmasize;
2720 else
2721 abinfo.bytes = dmabuf->dmasize - dmabuf->count;
2722
2723 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
2724 spin_unlock_irqrestore(&state->card->lock, flags);
2725 return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
2726 }
2727 return -ENODEV;
2728 case SNDCTL_DSP_GETISPACE:
2729 if (!(file->f_mode & FMODE_READ))
2730 return -EINVAL;
2731 state = card->states[0];
2732 if (state) {
2733 dmabuf = &state->dmabuf;
2734 spin_lock_irqsave(&state->card->lock, flags);
2735 cs_update_ptr(card, CS_TRUE);
2736 abinfo.fragsize = dmabuf->fragsize/dmabuf->divisor;
2737 abinfo.bytes = dmabuf->count/dmabuf->divisor;
2738 abinfo.fragstotal = dmabuf->numfrag;
2739 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
2740 spin_unlock_irqrestore(&state->card->lock, flags);
2741 return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
2742 }
2743 return -ENODEV;
2744 case SNDCTL_DSP_NONBLOCK:
2745 file->f_flags |= O_NONBLOCK;
2746 return 0;
2747 case SNDCTL_DSP_GETCAPS:
2748 return put_user(DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP,
2749 p);
2750 case SNDCTL_DSP_GETTRIGGER:
2751 val = 0;
2752 CS_DBGOUT(CS_IOCTL, 2, printk("cs46xx: DSP_GETTRIGGER()+\n") );
2753 if (file->f_mode & FMODE_WRITE) {
2754 state = card->states[1];
2755 if (state) {
2756 dmabuf = &state->dmabuf;
2757 if (dmabuf->enable & DAC_RUNNING)
2758 val |= PCM_ENABLE_INPUT;
2759 }
2760 }
2761 if (file->f_mode & FMODE_READ) {
2762 if (state) {
2763 state = card->states[0];
2764 dmabuf = &state->dmabuf;
2765 if (dmabuf->enable & ADC_RUNNING)
2766 val |= PCM_ENABLE_OUTPUT;
2767 }
2768 }
2769 CS_DBGOUT(CS_IOCTL, 2, printk("cs46xx: DSP_GETTRIGGER()- val=0x%x\n",val) );
2770 return put_user(val, p);
2771 case SNDCTL_DSP_SETTRIGGER:
2772 if (get_user(val, p))
2773 return -EFAULT;
2774 if (file->f_mode & FMODE_READ) {
2775 state = card->states[0];
2776 if (state) {
2777 dmabuf = &state->dmabuf;
2778 if (val & PCM_ENABLE_INPUT) {
2779 if (!dmabuf->ready && (ret = prog_dmabuf(state)))
2780 return ret;
2781 start_adc(state);
2782 } else
2783 stop_adc(state);
2784 }
2785 }
2786 if (file->f_mode & FMODE_WRITE) {
2787 state = card->states[1];
2788 if (state) {
2789 dmabuf = &state->dmabuf;
2790 if (val & PCM_ENABLE_OUTPUT) {
2791 if (!dmabuf->ready && (ret = prog_dmabuf(state)))
2792 return ret;
2793 start_dac(state);
2794 } else
2795 stop_dac(state);
2796 }
2797 }
2798 return 0;
2799 case SNDCTL_DSP_GETIPTR:
2800 if (!(file->f_mode & FMODE_READ))
2801 return -EINVAL;
2802 state = card->states[0];
2803 if (state) {
2804 dmabuf = &state->dmabuf;
2805 spin_lock_irqsave(&state->card->lock, flags);
2806 cs_update_ptr(card, CS_TRUE);
2807 cinfo.bytes = dmabuf->total_bytes/dmabuf->divisor;
2808 cinfo.blocks = dmabuf->count/dmabuf->divisor >> dmabuf->fragshift;
2809 cinfo.ptr = dmabuf->hwptr/dmabuf->divisor;
2810 spin_unlock_irqrestore(&state->card->lock, flags);
2811 if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
2812 return -EFAULT;
2813 return 0;
2814 }
2815 return -ENODEV;
2816 case SNDCTL_DSP_GETOPTR:
2817 if (!(file->f_mode & FMODE_WRITE))
2818 return -EINVAL;
2819 state = card->states[1];
2820 if (state) {
2821 dmabuf = &state->dmabuf;
2822 spin_lock_irqsave(&state->card->lock, flags);
2823 cs_update_ptr(card, CS_TRUE);
2824 cinfo.bytes = dmabuf->total_bytes;
2825 if (dmabuf->mapped) {
2826 cinfo.blocks = (cinfo.bytes >> dmabuf->fragshift)
2827 - dmabuf->blocks;
2828 CS_DBGOUT(CS_PARMS, 8,
2829 printk("total_bytes=%d blocks=%d dmabuf->blocks=%d\n",
2830 cinfo.bytes,cinfo.blocks,dmabuf->blocks) );
2831 dmabuf->blocks = cinfo.bytes >> dmabuf->fragshift;
2832 } else {
2833 cinfo.blocks = dmabuf->count >> dmabuf->fragshift;
2834 }
2835 cinfo.ptr = dmabuf->hwptr;
2836
2837 CS_DBGOUT(CS_PARMS, 4, printk(
2838 "cs46xx: GETOPTR bytes=%d blocks=%d ptr=%d\n",
2839 cinfo.bytes,cinfo.blocks,cinfo.ptr) );
2840 spin_unlock_irqrestore(&state->card->lock, flags);
2841 if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
2842 return -EFAULT;
2843 return 0;
2844 }
2845 return -ENODEV;
2846 case SNDCTL_DSP_SETDUPLEX:
2847 return 0;
2848 case SNDCTL_DSP_GETODELAY:
2849 if (!(file->f_mode & FMODE_WRITE))
2850 return -EINVAL;
2851 state = card->states[1];
2852 if (state) {
2853 dmabuf = &state->dmabuf;
2854 spin_lock_irqsave(&state->card->lock, flags);
2855 cs_update_ptr(card, CS_TRUE);
2856 val = dmabuf->count;
2857 spin_unlock_irqrestore(&state->card->lock, flags);
2858 } else
2859 val = 0;
2860 return put_user(val, p);
2861 case SOUND_PCM_READ_RATE:
2862 if (file->f_mode & FMODE_READ)
2863 state = card->states[0];
2864 else
2865 state = card->states[1];
2866 if (state) {
2867 dmabuf = &state->dmabuf;
2868 return put_user(dmabuf->rate, p);
2869 }
2870 return put_user(0, p);
2871 case SOUND_PCM_READ_CHANNELS:
2872 if (file->f_mode & FMODE_READ)
2873 state = card->states[0];
2874 else
2875 state = card->states[1];
2876 if (state) {
2877 dmabuf = &state->dmabuf;
2878 return put_user((dmabuf->fmt & CS_FMT_STEREO) ? 2 : 1,
2879 p);
2880 }
2881 return put_user(0, p);
2882 case SOUND_PCM_READ_BITS:
2883 if (file->f_mode & FMODE_READ)
2884 state = card->states[0];
2885 else
2886 state = card->states[1];
2887 if (state) {
2888 dmabuf = &state->dmabuf;
2889 return put_user((dmabuf->fmt & CS_FMT_16BIT) ?
2890 AFMT_S16_LE : AFMT_U8, p);
2891
2892 }
2893 return put_user(0, p);
2894 case SNDCTL_DSP_MAPINBUF:
2895 case SNDCTL_DSP_MAPOUTBUF:
2896 case SNDCTL_DSP_SETSYNCRO:
2897 case SOUND_PCM_WRITE_FILTER:
2898 case SOUND_PCM_READ_FILTER:
2899 return -EINVAL;
2900 }
2901 return -EINVAL;
2902}
2903
2904
2905/*
2906 * AMP control - null AMP
2907 */
2908
2909static void amp_none(struct cs_card *card, int change)
2910{
2911}
2912
2913/*
2914 * Crystal EAPD mode
2915 */
2916
2917static void amp_voyetra(struct cs_card *card, int change)
2918{
2919 /* Manage the EAPD bit on the Crystal 4297
2920 and the Analog AD1885 */
2921
2922 int old = card->amplifier;
2923
2924 card->amplifier+=change;
2925 if (card->amplifier && !old) {
2926 /* Turn the EAPD amp on */
2927 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL,
2928 cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) |
2929 0x8000);
2930 } else if(old && !card->amplifier) {
2931 /* Turn the EAPD amp off */
2932 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL,
2933 cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
2934 ~0x8000);
2935 }
2936}
2937
2938
2939/*
2940 * Game Theatre XP card - EGPIO[2] is used to enable the external amp.
2941 */
2942
2943static void amp_hercules(struct cs_card *card, int change)
2944{
2945 int old = card->amplifier;
2946 if (!card) {
2947 CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO
2948 "cs46xx: amp_hercules() called before initialized.\n"));
2949 return;
2950 }
2951 card->amplifier+=change;
2952 if ((card->amplifier && !old) && !(hercules_egpio_disable)) {
2953 CS_DBGOUT(CS_PARMS, 4, printk(KERN_INFO
2954 "cs46xx: amp_hercules() external amp enabled\n"));
2955 cs461x_pokeBA0(card, BA0_EGPIODR,
2956 EGPIODR_GPOE2); /* enable EGPIO2 output */
2957 cs461x_pokeBA0(card, BA0_EGPIOPTR,
2958 EGPIOPTR_GPPT2); /* open-drain on output */
2959 } else if (old && !card->amplifier) {
2960 CS_DBGOUT(CS_PARMS, 4, printk(KERN_INFO
2961 "cs46xx: amp_hercules() external amp disabled\n"));
2962 cs461x_pokeBA0(card, BA0_EGPIODR, 0); /* disable */
2963 cs461x_pokeBA0(card, BA0_EGPIOPTR, 0); /* disable */
2964 }
2965}
2966
2967/*
2968 * Handle the CLKRUN on a thinkpad. We must disable CLKRUN support
2969 * whenever we need to beat on the chip.
2970 *
2971 * The original idea and code for this hack comes from David Kaiser at
2972 * Linuxcare. Perhaps one day Crystal will document their chips well
2973 * enough to make them useful.
2974 */
2975
2976static void clkrun_hack(struct cs_card *card, int change)
2977{
2978 struct pci_dev *acpi_dev;
2979 u16 control;
2980 u8 pp;
2981 unsigned long port;
2982 int old = card->active;
2983
2984 card->active+=change;
2985
2986 acpi_dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
2987 if (acpi_dev == NULL)
2988 return; /* Not a thinkpad thats for sure */
2989
2990 /* Find the control port */
2991 pci_read_config_byte(acpi_dev, 0x41, &pp);
2992 port = pp << 8;
2993
2994 /* Read ACPI port */
2995 control = inw(port + 0x10);
2996
2997 /* Flip CLKRUN off while running */
2998 if (!card->active && old) {
2999 CS_DBGOUT(CS_PARMS , 9, printk( KERN_INFO
3000 "cs46xx: clkrun() enable clkrun - change=%d active=%d\n",
3001 change,card->active));
3002 outw(control|0x2000, port+0x10);
3003 } else {
3004 /*
3005 * sometimes on a resume the bit is set, so always reset the bit.
3006 */
3007 CS_DBGOUT(CS_PARMS , 9, printk( KERN_INFO
3008 "cs46xx: clkrun() disable clkrun - change=%d active=%d\n",
3009 change,card->active));
3010 outw(control&~0x2000, port+0x10);
3011 }
3012 pci_dev_put(acpi_dev);
3013}
3014
3015
3016static int cs_open(struct inode *inode, struct file *file)
3017{
3018 struct cs_card *card = file->private_data;
3019 struct cs_state *state = NULL;
3020 struct dmabuf *dmabuf = NULL;
3021 struct list_head *entry;
3022 unsigned int minor = iminor(inode);
3023 int ret = 0;
3024 unsigned int tmp;
3025
3026 CS_DBGOUT(CS_OPEN | CS_FUNCTION, 2, printk("cs46xx: cs_open()+ file=%p %s %s\n",
3027 file, file->f_mode & FMODE_WRITE ? "FMODE_WRITE" : "",
3028 file->f_mode & FMODE_READ ? "FMODE_READ" : "") );
3029
3030 list_for_each(entry, &cs46xx_devs) {
3031 card = list_entry(entry, struct cs_card, list);
3032
3033 if (!((card->dev_audio ^ minor) & ~0xf))
3034 break;
3035 }
3036 if (entry == &cs46xx_devs)
3037 return -ENODEV;
3038 if (!card) {
3039 CS_DBGOUT(CS_FUNCTION | CS_OPEN, 2, printk(KERN_INFO
3040 "cs46xx: cs_open(): Error - unable to find audio card struct\n"));
3041 return -ENODEV;
3042 }
3043
3044 /*
3045 * hardcode state[0] for capture, [1] for playback
3046 */
3047 if (file->f_mode & FMODE_READ) {
3048 CS_DBGOUT(CS_WAVE_READ, 2, printk("cs46xx: cs_open() FMODE_READ\n") );
3049 if (card->states[0] == NULL) {
3050 state = card->states[0] =
3051 kzalloc(sizeof(struct cs_state), GFP_KERNEL);
3052 if (state == NULL)
3053 return -ENOMEM;
3054 mutex_init(&state->sem);
3055 dmabuf = &state->dmabuf;
3056 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3057 if (dmabuf->pbuf == NULL) {
3058 kfree(state);
3059 card->states[0] = NULL;
3060 return -ENOMEM;
3061 }
3062 } else {
3063 state = card->states[0];
3064 if (state->open_mode & FMODE_READ)
3065 return -EBUSY;
3066 }
3067 dmabuf->channel = card->alloc_rec_pcm_channel(card);
3068
3069 if (dmabuf->channel == NULL) {
3070 kfree(card->states[0]);
3071 card->states[0] = NULL;
3072 return -ENODEV;
3073 }
3074
3075 /* Now turn on external AMP if needed */
3076 state->card = card;
3077 state->card->active_ctrl(state->card, 1);
3078 state->card->amplifier_ctrl(state->card, 1);
3079
3080 if ((tmp = cs46xx_powerup(card, CS_POWER_ADC))) {
3081 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
3082 "cs46xx: cs46xx_powerup of ADC failed (0x%x)\n", tmp));
3083 return -EIO;
3084 }
3085
3086 dmabuf->channel->state = state;
3087 /* initialize the virtual channel */
3088 state->virt = 0;
3089 state->magic = CS_STATE_MAGIC;
3090 init_waitqueue_head(&dmabuf->wait);
3091 mutex_init(&state->open_mutex);
3092 file->private_data = card;
3093
3094 mutex_lock(&state->open_mutex);
3095
3096 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3097 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
3098 /dev/dspW will accept 16-bits sample */
3099
3100 /* Default input is 8bit mono */
3101 dmabuf->fmt &= ~CS_FMT_MASK;
3102 dmabuf->type = CS_TYPE_ADC;
3103 dmabuf->ossfragshift = 0;
3104 dmabuf->ossmaxfrags = 0;
3105 dmabuf->subdivision = 0;
3106 cs_set_adc_rate(state, 8000);
3107 cs_set_divisor(dmabuf);
3108
3109 state->open_mode |= FMODE_READ;
3110 mutex_unlock(&state->open_mutex);
3111 }
3112 if (file->f_mode & FMODE_WRITE) {
3113 CS_DBGOUT(CS_OPEN, 2, printk("cs46xx: cs_open() FMODE_WRITE\n") );
3114 if (card->states[1] == NULL) {
3115 state = card->states[1] =
3116 kzalloc(sizeof(struct cs_state), GFP_KERNEL);
3117 if (state == NULL)
3118 return -ENOMEM;
3119 mutex_init(&state->sem);
3120 dmabuf = &state->dmabuf;
3121 dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
3122 if (dmabuf->pbuf == NULL) {
3123 kfree(state);
3124 card->states[1] = NULL;
3125 return -ENOMEM;
3126 }
3127 } else {
3128 state = card->states[1];
3129 if (state->open_mode & FMODE_WRITE)
3130 return -EBUSY;
3131 }
3132 dmabuf->channel = card->alloc_pcm_channel(card);
3133
3134 if (dmabuf->channel == NULL) {
3135 kfree(card->states[1]);
3136 card->states[1] = NULL;
3137 return -ENODEV;
3138 }
3139
3140 /* Now turn on external AMP if needed */
3141 state->card = card;
3142 state->card->active_ctrl(state->card, 1);
3143 state->card->amplifier_ctrl(state->card, 1);
3144
3145 if ((tmp = cs46xx_powerup(card, CS_POWER_DAC))) {
3146 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
3147 "cs46xx: cs46xx_powerup of DAC failed (0x%x)\n", tmp));
3148 return -EIO;
3149 }
3150
3151 dmabuf->channel->state = state;
3152 /* initialize the virtual channel */
3153 state->virt = 1;
3154 state->magic = CS_STATE_MAGIC;
3155 init_waitqueue_head(&dmabuf->wait);
3156 mutex_init(&state->open_mutex);
3157 file->private_data = card;
3158
3159 mutex_lock(&state->open_mutex);
3160
3161 /* set default sample format. According to OSS Programmer's Guide /dev/dsp
3162 should be default to unsigned 8-bits, mono, with sample rate 8kHz and
3163 /dev/dspW will accept 16-bits sample */
3164
3165 /* Default output is 8bit mono. */
3166 dmabuf->fmt &= ~CS_FMT_MASK;
3167 dmabuf->type = CS_TYPE_DAC;
3168 dmabuf->ossfragshift = 0;
3169 dmabuf->ossmaxfrags = 0;
3170 dmabuf->subdivision = 0;
3171 cs_set_dac_rate(state, 8000);
3172 cs_set_divisor(dmabuf);
3173
3174 state->open_mode |= FMODE_WRITE;
3175 mutex_unlock(&state->open_mutex);
3176 if ((ret = prog_dmabuf(state)))
3177 return ret;
3178 }
3179 CS_DBGOUT(CS_OPEN | CS_FUNCTION, 2, printk("cs46xx: cs_open()- 0\n"));
3180 return nonseekable_open(inode, file);
3181}
3182
3183static int cs_release(struct inode *inode, struct file *file)
3184{
3185 struct cs_card *card = file->private_data;
3186 struct dmabuf *dmabuf;
3187 struct cs_state *state;
3188 unsigned int tmp;
3189 CS_DBGOUT(CS_RELEASE | CS_FUNCTION, 2, printk("cs46xx: cs_release()+ file=%p %s %s\n",
3190 file, file->f_mode & FMODE_WRITE ? "FMODE_WRITE" : "",
3191 file->f_mode & FMODE_READ ? "FMODE_READ" : ""));
3192
3193 if (!(file->f_mode & (FMODE_WRITE | FMODE_READ)))
3194 return -EINVAL;
3195 state = card->states[1];
3196 if (state) {
3197 if ((state->open_mode & FMODE_WRITE) & (file->f_mode & FMODE_WRITE)) {
3198 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_WRITE\n"));
3199 dmabuf = &state->dmabuf;
3200 cs_clear_tail(state);
3201 drain_dac(state, file->f_flags & O_NONBLOCK);
3202 /* stop DMA state machine and free DMA buffers/channels */
3203 mutex_lock(&state->open_mutex);
3204 stop_dac(state);
3205 dealloc_dmabuf(state);
3206 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3207 free_page((unsigned long)state->dmabuf.pbuf);
3208
3209 /* we're covered by the open_mutex */
3210 mutex_unlock(&state->open_mutex);
3211 state->card->states[state->virt] = NULL;
3212 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3213
3214 if ((tmp = cs461x_powerdown(card, CS_POWER_DAC, CS_FALSE))) {
3215 CS_DBGOUT(CS_ERROR, 1, printk(KERN_INFO
3216 "cs46xx: cs_release_mixdev() powerdown DAC failure (0x%x)\n",tmp) );
3217 }
3218
3219 /* Now turn off external AMP if needed */
3220 state->card->amplifier_ctrl(state->card, -1);
3221 state->card->active_ctrl(state->card, -1);
3222 kfree(state);
3223 }
3224 }
3225
3226 state = card->states[0];
3227 if (state) {
3228 if ((state->open_mode & FMODE_READ) & (file->f_mode & FMODE_READ)) {
3229 CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n"));
3230 dmabuf = &state->dmabuf;
3231 mutex_lock(&state->open_mutex);
3232 stop_adc(state);
3233 dealloc_dmabuf(state);
3234 state->card->free_pcm_channel(state->card, dmabuf->channel->num);
3235 free_page((unsigned long)state->dmabuf.pbuf);
3236
3237 /* we're covered by the open_mutex */
3238 mutex_unlock(&state->open_mutex);
3239 state->card->states[state->virt] = NULL;
3240 state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
3241
3242 if ((tmp = cs461x_powerdown(card, CS_POWER_ADC, CS_FALSE))) {
3243 CS_DBGOUT(CS_ERROR, 1, printk(KERN_INFO
3244 "cs46xx: cs_release_mixdev() powerdown ADC failure (0x%x)\n",tmp) );
3245 }
3246
3247 /* Now turn off external AMP if needed */
3248 state->card->amplifier_ctrl(state->card, -1);
3249 state->card->active_ctrl(state->card, -1);
3250 kfree(state);
3251 }
3252 }
3253
3254 CS_DBGOUT(CS_FUNCTION | CS_RELEASE, 2, printk("cs46xx: cs_release()- 0\n"));
3255 return 0;
3256}
3257
3258static void printpm(struct cs_card *s)
3259{
3260 CS_DBGOUT(CS_PM, 9, printk("pm struct:\n"));
3261 CS_DBGOUT(CS_PM, 9, printk("flags:0x%x u32CLKCR1_SAVE: 0%x u32SSPMValue: 0x%x\n",
3262 (unsigned)s->pm.flags,s->pm.u32CLKCR1_SAVE,s->pm.u32SSPMValue));
3263 CS_DBGOUT(CS_PM, 9, printk("u32PPLVCvalue: 0x%x u32PPRVCvalue: 0x%x\n",
3264 s->pm.u32PPLVCvalue,s->pm.u32PPRVCvalue));
3265 CS_DBGOUT(CS_PM, 9, printk("u32FMLVCvalue: 0x%x u32FMRVCvalue: 0x%x\n",
3266 s->pm.u32FMLVCvalue,s->pm.u32FMRVCvalue));
3267 CS_DBGOUT(CS_PM, 9, printk("u32GPIORvalue: 0x%x u32JSCTLvalue: 0x%x\n",
3268 s->pm.u32GPIORvalue,s->pm.u32JSCTLvalue));
3269 CS_DBGOUT(CS_PM, 9, printk("u32SSCR: 0x%x u32SRCSA: 0x%x\n",
3270 s->pm.u32SSCR,s->pm.u32SRCSA));
3271 CS_DBGOUT(CS_PM, 9, printk("u32DacASR: 0x%x u32AdcASR: 0x%x\n",
3272 s->pm.u32DacASR,s->pm.u32AdcASR));
3273 CS_DBGOUT(CS_PM, 9, printk("u32DacSR: 0x%x u32AdcSR: 0x%x\n",
3274 s->pm.u32DacSR,s->pm.u32AdcSR));
3275 CS_DBGOUT(CS_PM, 9, printk("u32MIDCR_Save: 0x%x\n",
3276 s->pm.u32MIDCR_Save));
3277 CS_DBGOUT(CS_PM, 9, printk("u32AC97_powerdown: 0x%x _general_purpose 0x%x\n",
3278 s->pm.u32AC97_powerdown,s->pm.u32AC97_general_purpose));
3279 CS_DBGOUT(CS_PM, 9, printk("u32AC97_master_volume: 0x%x\n",
3280 s->pm.u32AC97_master_volume));
3281 CS_DBGOUT(CS_PM, 9, printk("u32AC97_headphone_volume: 0x%x\n",
3282 s->pm.u32AC97_headphone_volume));
3283 CS_DBGOUT(CS_PM, 9, printk("u32AC97_master_volume_mono: 0x%x\n",
3284 s->pm.u32AC97_master_volume_mono));
3285 CS_DBGOUT(CS_PM, 9, printk("u32AC97_pcm_out_volume: 0x%x\n",
3286 s->pm.u32AC97_pcm_out_volume));
3287 CS_DBGOUT(CS_PM, 9, printk("dmabuf_swptr_play: 0x%x dmabuf_count_play: %d\n",
3288 s->pm.dmabuf_swptr_play,s->pm.dmabuf_count_play));
3289 CS_DBGOUT(CS_PM, 9, printk("dmabuf_swptr_capture: 0x%x dmabuf_count_capture: %d\n",
3290 s->pm.dmabuf_swptr_capture,s->pm.dmabuf_count_capture));
3291
3292}
3293
3294/****************************************************************************
3295*
3296* Suspend - save the ac97 regs, mute the outputs and power down the part.
3297*
3298****************************************************************************/
3299static void cs46xx_ac97_suspend(struct cs_card *card)
3300{
3301 int Count,i;
3302 struct ac97_codec *dev=card->ac97_codec[0];
3303 unsigned int tmp;
3304
3305 CS_DBGOUT(CS_PM, 9, printk("cs46xx: cs46xx_ac97_suspend()+\n"));
3306
3307 if (card->states[1]) {
3308 stop_dac(card->states[1]);
3309 resync_dma_ptrs(card->states[1]);
3310 }
3311 if (card->states[0]) {
3312 stop_adc(card->states[0]);
3313 resync_dma_ptrs(card->states[0]);
3314 }
3315
3316 for (Count = 0x2, i = 0; (Count <= CS46XX_AC97_HIGHESTREGTORESTORE)
3317 && (i < CS46XX_AC97_NUMBER_RESTORE_REGS);
3318 Count += 2, i++) {
3319 card->pm.ac97[i] = cs_ac97_get(dev, BA0_AC97_RESET + Count);
3320 }
3321/*
3322* Save the ac97 volume registers as well as the current powerdown state.
3323* Now, mute the all the outputs (master, headphone, and mono), as well
3324* as the PCM volume, in preparation for powering down the entire part.
3325 card->pm.u32AC97_master_volume = (u32)cs_ac97_get( dev,
3326 (u8)BA0_AC97_MASTER_VOLUME);
3327 card->pm.u32AC97_headphone_volume = (u32)cs_ac97_get(dev,
3328 (u8)BA0_AC97_HEADPHONE_VOLUME);
3329 card->pm.u32AC97_master_volume_mono = (u32)cs_ac97_get(dev,
3330 (u8)BA0_AC97_MASTER_VOLUME_MONO);
3331 card->pm.u32AC97_pcm_out_volume = (u32)cs_ac97_get(dev,
3332 (u8)BA0_AC97_PCM_OUT_VOLUME);
3333*/
3334/*
3335* mute the outputs
3336*/
3337 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME, 0x8000);
3338 cs_ac97_set(dev, (u8)BA0_AC97_HEADPHONE_VOLUME, 0x8000);
3339 cs_ac97_set(dev, (u8)BA0_AC97_MASTER_VOLUME_MONO, 0x8000);
3340 cs_ac97_set(dev, (u8)BA0_AC97_PCM_OUT_VOLUME, 0x8000);
3341
3342/*
3343* save the registers that cause pops
3344*/
3345 card->pm.u32AC97_powerdown = (u32)cs_ac97_get(dev, (u8)AC97_POWER_CONTROL);
3346 card->pm.u32AC97_general_purpose = (u32)cs_ac97_get(dev, (u8)BA0_AC97_GENERAL_PURPOSE);
3347/*
3348* And power down everything on the AC97 codec.
3349* well, for now, only power down the DAC/ADC and MIXER VREFON components.
3350* trouble with removing VREF.
3351*/
3352 if ((tmp = cs461x_powerdown(card, CS_POWER_DAC | CS_POWER_ADC |
3353 CS_POWER_MIXVON, CS_TRUE))) {
3354 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
3355 "cs46xx: cs46xx_ac97_suspend() failure (0x%x)\n",tmp));
3356 }
3357
3358 CS_DBGOUT(CS_PM, 9, printk("cs46xx: cs46xx_ac97_suspend()-\n"));
3359}
3360
3361/****************************************************************************
3362*
3363* Resume - power up the part and restore its registers..
3364*
3365****************************************************************************/
3366static void cs46xx_ac97_resume(struct cs_card *card)
3367{
3368 int Count,i;
3369 struct ac97_codec *dev=card->ac97_codec[0];
3370
3371 CS_DBGOUT(CS_PM, 9, printk("cs46xx: cs46xx_ac97_resume()+\n"));
3372
3373/*
3374* First, we restore the state of the general purpose register. This
3375* contains the mic select (mic1 or mic2) and if we restore this after
3376* we restore the mic volume/boost state and mic2 was selected at
3377* suspend time, we will end up with a brief period of time where mic1
3378* is selected with the volume/boost settings for mic2, causing
3379* acoustic feedback. So we restore the general purpose register
3380* first, thereby getting the correct mic selected before we restore
3381* the mic volume/boost.
3382*/
3383 cs_ac97_set(dev, (u8)BA0_AC97_GENERAL_PURPOSE,
3384 (u16)card->pm.u32AC97_general_purpose);
3385/*
3386* Now, while the outputs are still muted, restore the state of power
3387* on the AC97 part.
3388*/
3389 cs_ac97_set(dev, (u8)BA0_AC97_POWERDOWN, (u16)card->pm.u32AC97_powerdown);
3390 mdelay(5 * cs_laptop_wait);
3391/*
3392* Restore just the first set of registers, from register number
3393* 0x02 to the register number that ulHighestRegToRestore specifies.
3394*/
3395 for (Count = 0x2, i=0; (Count <= CS46XX_AC97_HIGHESTREGTORESTORE) &&
3396 (i < CS46XX_AC97_NUMBER_RESTORE_REGS); Count += 2, i++) {
3397 cs_ac97_set(dev, (u8)(BA0_AC97_RESET + Count), (u16)card->pm.ac97[i]);
3398 }
3399
3400 /* Check if we have to init the amplifier */
3401 if (card->amp_init)
3402 card->amp_init(card);
3403
3404 CS_DBGOUT(CS_PM, 9, printk("cs46xx: cs46xx_ac97_resume()-\n"));
3405}
3406
3407
3408static int cs46xx_restart_part(struct cs_card *card)
3409{
3410 struct dmabuf *dmabuf;
3411
3412 CS_DBGOUT(CS_PM | CS_FUNCTION, 4,
3413 printk( "cs46xx: cs46xx_restart_part()+\n"));
3414 if (card->states[1]) {
3415 dmabuf = &card->states[1]->dmabuf;
3416 dmabuf->ready = 0;
3417 resync_dma_ptrs(card->states[1]);
3418 cs_set_divisor(dmabuf);
3419 if (__prog_dmabuf(card->states[1])) {
3420 CS_DBGOUT(CS_PM | CS_ERROR, 1,
3421 printk("cs46xx: cs46xx_restart_part()- (-1) prog_dmabuf() dac error\n"));
3422 return -1;
3423 }
3424 cs_set_dac_rate(card->states[1], dmabuf->rate);
3425 }
3426 if (card->states[0]) {
3427 dmabuf = &card->states[0]->dmabuf;
3428 dmabuf->ready = 0;
3429 resync_dma_ptrs(card->states[0]);
3430 cs_set_divisor(dmabuf);
3431 if (__prog_dmabuf(card->states[0])) {
3432 CS_DBGOUT(CS_PM | CS_ERROR, 1,
3433 printk("cs46xx: cs46xx_restart_part()- (-1) prog_dmabuf() adc error\n"));
3434 return -1;
3435 }
3436 cs_set_adc_rate(card->states[0], dmabuf->rate);
3437 }
3438 card->pm.flags |= CS46XX_PM_RESUMED;
3439 if (card->states[0])
3440 start_adc(card->states[0]);
3441 if (card->states[1])
3442 start_dac(card->states[1]);
3443
3444 card->pm.flags |= CS46XX_PM_IDLE;
3445 card->pm.flags &= ~(CS46XX_PM_SUSPENDING | CS46XX_PM_SUSPENDED
3446 | CS46XX_PM_RESUMING | CS46XX_PM_RESUMED);
3447 if (card->states[0])
3448 wake_up(&card->states[0]->dmabuf.wait);
3449 if (card->states[1])
3450 wake_up(&card->states[1]->dmabuf.wait);
3451
3452 CS_DBGOUT(CS_PM | CS_FUNCTION, 4,
3453 printk( "cs46xx: cs46xx_restart_part()-\n"));
3454 return 0;
3455}
3456
3457static void cs461x_reset(struct cs_card *card);
3458static void cs461x_proc_stop(struct cs_card *card);
3459static int cs46xx_suspend(struct cs_card *card, pm_message_t state)
3460{
3461 unsigned int tmp;
3462
3463 CS_DBGOUT(CS_PM | CS_FUNCTION, 4,
3464 printk("cs46xx: cs46xx_suspend()+ flags=0x%x s=%p\n",
3465 (unsigned)card->pm.flags,card));
3466/*
3467* check the current state, only suspend if IDLE
3468*/
3469 if (!(card->pm.flags & CS46XX_PM_IDLE)) {
3470 CS_DBGOUT(CS_PM | CS_ERROR, 2,
3471 printk("cs46xx: cs46xx_suspend() unable to suspend, not IDLE\n"));
3472 return 1;
3473 }
3474 card->pm.flags &= ~CS46XX_PM_IDLE;
3475 card->pm.flags |= CS46XX_PM_SUSPENDING;
3476
3477 card->active_ctrl(card,1);
3478
3479 tmp = cs461x_peek(card, BA1_PFIE);
3480 tmp &= ~0x0000f03f;
3481 tmp |= 0x00000010;
3482 cs461x_poke(card, BA1_PFIE, tmp); /* playback interrupt disable */
3483
3484 tmp = cs461x_peek(card, BA1_CIE);
3485 tmp &= ~0x0000003f;
3486 tmp |= 0x00000011;
3487 cs461x_poke(card, BA1_CIE, tmp); /* capture interrupt disable */
3488
3489 /*
3490 * Stop playback DMA.
3491 */
3492 tmp = cs461x_peek(card, BA1_PCTL);
3493 cs461x_poke(card, BA1_PCTL, tmp & 0x0000ffff);
3494
3495 /*
3496 * Stop capture DMA.
3497 */
3498 tmp = cs461x_peek(card, BA1_CCTL);
3499 cs461x_poke(card, BA1_CCTL, tmp & 0xffff0000);
3500
3501 if (card->states[1]) {
3502 card->pm.dmabuf_swptr_play = card->states[1]->dmabuf.swptr;
3503 card->pm.dmabuf_count_play = card->states[1]->dmabuf.count;
3504 }
3505 if (card->states[0]) {
3506 card->pm.dmabuf_swptr_capture = card->states[0]->dmabuf.swptr;
3507 card->pm.dmabuf_count_capture = card->states[0]->dmabuf.count;
3508 }
3509
3510 cs46xx_ac97_suspend(card);
3511
3512 /*
3513 * Reset the processor.
3514 */
3515 cs461x_reset(card);
3516
3517 cs461x_proc_stop(card);
3518
3519 /*
3520 * Power down the DAC and ADC. For now leave the other areas on.
3521 */
3522 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, 0x0300);
3523
3524 /*
3525 * Power down the PLL.
3526 */
3527 cs461x_pokeBA0(card, BA0_CLKCR1, 0);
3528
3529 /*
3530 * Turn off the Processor by turning off the software clock enable flag in
3531 * the clock control register.
3532 */
3533 tmp = cs461x_peekBA0(card, BA0_CLKCR1) & ~CLKCR1_SWCE;
3534 cs461x_pokeBA0(card, BA0_CLKCR1, tmp);
3535
3536 card->active_ctrl(card,-1);
3537
3538 card->pm.flags &= ~CS46XX_PM_SUSPENDING;
3539 card->pm.flags |= CS46XX_PM_SUSPENDED;
3540
3541 printpm(card);
3542
3543 CS_DBGOUT(CS_PM | CS_FUNCTION, 4,
3544 printk("cs46xx: cs46xx_suspend()- flags=0x%x\n",
3545 (unsigned)card->pm.flags));
3546 return 0;
3547}
3548
3549static int cs46xx_resume(struct cs_card *card)
3550{
3551 int i;
3552
3553 CS_DBGOUT(CS_PM | CS_FUNCTION, 4,
3554 printk( "cs46xx: cs46xx_resume()+ flags=0x%x\n",
3555 (unsigned)card->pm.flags));
3556 if (!(card->pm.flags & CS46XX_PM_SUSPENDED)) {
3557 CS_DBGOUT(CS_PM | CS_ERROR, 2,
3558 printk("cs46xx: cs46xx_resume() unable to resume, not SUSPENDED\n"));
3559 return 1;
3560 }
3561 card->pm.flags |= CS46XX_PM_RESUMING;
3562 card->pm.flags &= ~CS46XX_PM_SUSPENDED;
3563 printpm(card);
3564 card->active_ctrl(card, 1);
3565
3566 for (i = 0; i < 5; i++) {
3567 if (cs_hardware_init(card) != 0) {
3568 CS_DBGOUT(CS_PM | CS_ERROR, 4, printk(
3569 "cs46xx: cs46xx_resume()- ERROR in cs_hardware_init()\n"));
3570 mdelay(10 * cs_laptop_wait);
3571 cs461x_reset(card);
3572 continue;
3573 }
3574 break;
3575 }
3576 if (i >= 4) {
3577 CS_DBGOUT(CS_PM | CS_ERROR, 1, printk(
3578 "cs46xx: cs46xx_resume()- cs_hardware_init() failed, retried %d times.\n",i));
3579 return 0;
3580 }
3581
3582 if (cs46xx_restart_part(card)) {
3583 CS_DBGOUT(CS_PM | CS_ERROR, 4, printk(
3584 "cs46xx: cs46xx_resume(): cs46xx_restart_part() returned error\n"));
3585 }
3586
3587 card->active_ctrl(card, -1);
3588
3589 CS_DBGOUT(CS_PM | CS_FUNCTION, 4, printk("cs46xx: cs46xx_resume()- flags=0x%x\n",
3590 (unsigned)card->pm.flags));
3591 return 0;
3592}
3593
3594static /*const*/ struct file_operations cs461x_fops = {
3595 CS_OWNER CS_THIS_MODULE
3596 .llseek = no_llseek,
3597 .read = cs_read,
3598 .write = cs_write,
3599 .poll = cs_poll,
3600 .ioctl = cs_ioctl,
3601 .mmap = cs_mmap,
3602 .open = cs_open,
3603 .release = cs_release,
3604};
3605
3606/* Write AC97 codec registers */
3607
3608
3609static u16 _cs_ac97_get(struct ac97_codec *dev, u8 reg)
3610{
3611 struct cs_card *card = dev->private_data;
3612 int count,loopcnt;
3613 unsigned int tmp;
3614 u16 ret;
3615
3616 /*
3617 * 1. Write ACCAD = Command Address Register = 46Ch for AC97 register address
3618 * 2. Write ACCDA = Command Data Register = 470h for data to write to AC97
3619 * 3. Write ACCTL = Control Register = 460h for initiating the write
3620 * 4. Read ACCTL = 460h, DCV should be reset by now and 460h = 17h
3621 * 5. if DCV not cleared, break and return error
3622 * 6. Read ACSTS = Status Register = 464h, check VSTS bit
3623 */
3624
3625 cs461x_peekBA0(card, BA0_ACSDA);
3626
3627 /*
3628 * Setup the AC97 control registers on the CS461x to send the
3629 * appropriate command to the AC97 to perform the read.
3630 * ACCAD = Command Address Register = 46Ch
3631 * ACCDA = Command Data Register = 470h
3632 * ACCTL = Control Register = 460h
3633 * set DCV - will clear when process completed
3634 * set CRW - Read command
3635 * set VFRM - valid frame enabled
3636 * set ESYN - ASYNC generation enabled
3637 * set RSTN - ARST# inactive, AC97 codec not reset
3638 */
3639
3640 cs461x_pokeBA0(card, BA0_ACCAD, reg);
3641 cs461x_pokeBA0(card, BA0_ACCDA, 0);
3642 cs461x_pokeBA0(card, BA0_ACCTL, ACCTL_DCV | ACCTL_CRW |
3643 ACCTL_VFRM | ACCTL_ESYN |
3644 ACCTL_RSTN);
3645
3646
3647 /*
3648 * Wait for the read to occur.
3649 */
3650 if (!(card->pm.flags & CS46XX_PM_IDLE))
3651 loopcnt = 2000;
3652 else
3653 loopcnt = 500 * cs_laptop_wait;
3654 loopcnt *= cs_laptop_wait;
3655 for (count = 0; count < loopcnt; count++) {
3656 /*
3657 * First, we want to wait for a short time.
3658 */
3659 udelay(10 * cs_laptop_wait);
3660 /*
3661 * Now, check to see if the read has completed.
3662 * ACCTL = 460h, DCV should be reset by now and 460h = 17h
3663 */
3664 if (!(cs461x_peekBA0(card, BA0_ACCTL) & ACCTL_DCV))
3665 break;
3666 }
3667
3668 /*
3669 * Make sure the read completed.
3670 */
3671 if (cs461x_peekBA0(card, BA0_ACCTL) & ACCTL_DCV) {
3672 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
3673 "cs46xx: AC'97 read problem (ACCTL_DCV), reg = 0x%x returning 0xffff\n", reg));
3674 return 0xffff;
3675 }
3676
3677 /*
3678 * Wait for the valid status bit to go active.
3679 */
3680
3681 if (!(card->pm.flags & CS46XX_PM_IDLE))
3682 loopcnt = 2000;
3683 else
3684 loopcnt = 1000;
3685 loopcnt *= cs_laptop_wait;
3686 for (count = 0; count < loopcnt; count++) {
3687 /*
3688 * Read the AC97 status register.
3689 * ACSTS = Status Register = 464h
3690 * VSTS - Valid Status
3691 */
3692 if (cs461x_peekBA0(card, BA0_ACSTS) & ACSTS_VSTS)
3693 break;
3694 udelay(10 * cs_laptop_wait);
3695 }
3696
3697 /*
3698 * Make sure we got valid status.
3699 */
3700 if (!((tmp = cs461x_peekBA0(card, BA0_ACSTS)) & ACSTS_VSTS)) {
3701 CS_DBGOUT(CS_ERROR, 2, printk(KERN_WARNING
3702 "cs46xx: AC'97 read problem (ACSTS_VSTS), reg = 0x%x val=0x%x 0xffff \n",
3703 reg, tmp));
3704 return 0xffff;
3705 }
3706
3707 /*
3708 * Read the data returned from the AC97 register.
3709 * ACSDA = Status Data Register = 474h
3710 */
3711 CS_DBGOUT(CS_FUNCTION, 9, printk(KERN_INFO
3712 "cs46xx: cs_ac97_get() reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n",
3713 reg, cs461x_peekBA0(card, BA0_ACSDA),
3714 cs461x_peekBA0(card, BA0_ACCAD)));
3715 ret = cs461x_peekBA0(card, BA0_ACSDA);
3716 return ret;
3717}
3718
3719static u16 cs_ac97_get(struct ac97_codec *dev, u8 reg)
3720{
3721 u16 ret;
3722 struct cs_card *card = dev->private_data;
3723
3724 spin_lock(&card->ac97_lock);
3725 ret = _cs_ac97_get(dev, reg);
3726 spin_unlock(&card->ac97_lock);
3727 return ret;
3728}
3729
3730static void cs_ac97_set(struct ac97_codec *dev, u8 reg, u16 val)
3731{
3732 struct cs_card *card = dev->private_data;
3733 int count;
3734 int val2 = 0;
3735
3736 spin_lock(&card->ac97_lock);
3737
3738 if (reg == AC97_CD_VOL)
3739 val2 = _cs_ac97_get(dev, AC97_CD_VOL);
3740
3741 /*
3742 * 1. Write ACCAD = Command Address Register = 46Ch for AC97 register address
3743 * 2. Write ACCDA = Command Data Register = 470h for data to write to AC97
3744 * 3. Write ACCTL = Control Register = 460h for initiating the write
3745 * 4. Read ACCTL = 460h, DCV should be reset by now and 460h = 07h
3746 * 5. if DCV not cleared, break and return error
3747 */
3748
3749 /*
3750 * Setup the AC97 control registers on the CS461x to send the
3751 * appropriate command to the AC97 to perform the read.
3752 * ACCAD = Command Address Register = 46Ch
3753 * ACCDA = Command Data Register = 470h
3754 * ACCTL = Control Register = 460h
3755 * set DCV - will clear when process completed
3756 * reset CRW - Write command
3757 * set VFRM - valid frame enabled
3758 * set ESYN - ASYNC generation enabled
3759 * set RSTN - ARST# inactive, AC97 codec not reset
3760 */
3761 cs461x_pokeBA0(card, BA0_ACCAD, reg);
3762 cs461x_pokeBA0(card, BA0_ACCDA, val);
3763 cs461x_peekBA0(card, BA0_ACCTL);
3764 cs461x_pokeBA0(card, BA0_ACCTL, 0 | ACCTL_VFRM | ACCTL_ESYN | ACCTL_RSTN);
3765 cs461x_pokeBA0(card, BA0_ACCTL, ACCTL_DCV | ACCTL_VFRM |
3766 ACCTL_ESYN | ACCTL_RSTN);
3767 for (count = 0; count < 1000; count++) {
3768 /*
3769 * First, we want to wait for a short time.
3770 */
3771 udelay(10 * cs_laptop_wait);
3772 /*
3773 * Now, check to see if the write has completed.
3774 * ACCTL = 460h, DCV should be reset by now and 460h = 07h
3775 */
3776 if (!(cs461x_peekBA0(card, BA0_ACCTL) & ACCTL_DCV))
3777 break;
3778 }
3779 /*
3780 * Make sure the write completed.
3781 */
3782 if (cs461x_peekBA0(card, BA0_ACCTL) & ACCTL_DCV) {
3783 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
3784 "cs46xx: AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val));
3785 }
3786
3787 spin_unlock(&card->ac97_lock);
3788
3789 /*
3790 * Adjust power if the mixer is selected/deselected according
3791 * to the CD.
3792 *
3793 * IF the CD is a valid input source (mixer or direct) AND
3794 * the CD is not muted THEN power is needed
3795 *
3796 * We do two things. When record select changes the input to
3797 * add/remove the CD we adjust the power count if the CD is
3798 * unmuted.
3799 *
3800 * When the CD mute changes we adjust the power level if the
3801 * CD was a valid input.
3802 *
3803 * We also check for CD volume != 0, as the CD mute isn't
3804 * normally tweaked from userspace.
3805 */
3806
3807 /* CD mute change ? */
3808
3809 if (reg == AC97_CD_VOL) {
3810 /* Mute bit change ? */
3811 if ((val2^val) & 0x8000 ||
3812 ((val2 == 0x1f1f || val == 0x1f1f) && val2 != val)) {
3813 /* This is a hack but its cleaner than the alternatives.
3814 Right now card->ac97_codec[0] might be NULL as we are
3815 still doing codec setup. This does an early assignment
3816 to avoid the problem if it occurs */
3817
3818 if (card->ac97_codec[0] == NULL)
3819 card->ac97_codec[0] = dev;
3820
3821 /* Mute on */
3822 if (val & 0x8000 || val == 0x1f1f)
3823 card->amplifier_ctrl(card, -1);
3824 else { /* Mute off power on */
3825 if (card->amp_init)
3826 card->amp_init(card);
3827 card->amplifier_ctrl(card, 1);
3828 }
3829 }
3830 }
3831}
3832
3833/* OSS /dev/mixer file operation methods */
3834
3835static int cs_open_mixdev(struct inode *inode, struct file *file)
3836{
3837 int i = 0;
3838 unsigned int minor = iminor(inode);
3839 struct cs_card *card = NULL;
3840 struct list_head *entry;
3841 unsigned int tmp;
3842
3843 CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4,
3844 printk(KERN_INFO "cs46xx: cs_open_mixdev()+\n"));
3845
3846 list_for_each(entry, &cs46xx_devs) {
3847 card = list_entry(entry, struct cs_card, list);
3848 for (i = 0; i < NR_AC97; i++)
3849 if (card->ac97_codec[i] != NULL &&
3850 card->ac97_codec[i]->dev_mixer == minor)
3851 goto match;
3852 }
3853 if (!card) {
3854 CS_DBGOUT(CS_FUNCTION | CS_OPEN | CS_ERROR, 2,
3855 printk(KERN_INFO "cs46xx: cs46xx_open_mixdev()- -ENODEV\n"));
3856 return -ENODEV;
3857 }
3858 match:
3859 if (!card->ac97_codec[i])
3860 return -ENODEV;
3861 file->private_data = card->ac97_codec[i];
3862
3863 card->active_ctrl(card,1);
3864 if (!CS_IN_USE(&card->mixer_use_cnt)) {
3865 if ((tmp = cs46xx_powerup(card, CS_POWER_MIXVON))) {
3866 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
3867 "cs46xx: cs_open_mixdev() powerup failure (0x%x)\n", tmp));
3868 return -EIO;
3869 }
3870 }
3871 card->amplifier_ctrl(card, 1);
3872 CS_INC_USE_COUNT(&card->mixer_use_cnt);
3873 CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4,
3874 printk(KERN_INFO "cs46xx: cs_open_mixdev()- 0\n"));
3875 return nonseekable_open(inode, file);
3876}
3877
3878static int cs_release_mixdev(struct inode *inode, struct file *file)
3879{
3880 unsigned int minor = iminor(inode);
3881 struct cs_card *card = NULL;
3882 struct list_head *entry;
3883 int i;
3884 unsigned int tmp;
3885
3886 CS_DBGOUT(CS_FUNCTION | CS_RELEASE, 4,
3887 printk(KERN_INFO "cs46xx: cs_release_mixdev()+\n"));
3888 list_for_each(entry, &cs46xx_devs)
3889 {
3890 card = list_entry(entry, struct cs_card, list);
3891 for (i = 0; i < NR_AC97; i++)
3892 if (card->ac97_codec[i] != NULL &&
3893 card->ac97_codec[i]->dev_mixer == minor)
3894 goto match;
3895 }
3896 if (!card) {
3897 CS_DBGOUT(CS_FUNCTION | CS_OPEN | CS_ERROR, 2,
3898 printk(KERN_INFO "cs46xx: cs46xx_open_mixdev()- -ENODEV\n"));
3899 return -ENODEV;
3900 }
3901match:
3902 if (!CS_DEC_AND_TEST(&card->mixer_use_cnt)) {
3903 CS_DBGOUT(CS_FUNCTION | CS_RELEASE, 4,
3904 printk(KERN_INFO "cs46xx: cs_release_mixdev()- no powerdown, usecnt>0\n"));
3905 card->active_ctrl(card, -1);
3906 card->amplifier_ctrl(card, -1);
3907 return 0;
3908 }
3909/*
3910* ok, no outstanding mixer opens, so powerdown.
3911*/
3912 if ((tmp = cs461x_powerdown(card, CS_POWER_MIXVON, CS_FALSE))) {
3913 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
3914 "cs46xx: cs_release_mixdev() powerdown MIXVON failure (0x%x)\n", tmp));
3915 card->active_ctrl(card, -1);
3916 card->amplifier_ctrl(card, -1);
3917 return -EIO;
3918 }
3919 card->active_ctrl(card, -1);
3920 card->amplifier_ctrl(card, -1);
3921 CS_DBGOUT(CS_FUNCTION | CS_RELEASE, 4,
3922 printk(KERN_INFO "cs46xx: cs_release_mixdev()- 0\n"));
3923 return 0;
3924}
3925
3926static int cs_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
3927 unsigned long arg)
3928{
3929 struct ac97_codec *codec = file->private_data;
3930 struct cs_card *card = NULL;
3931 struct list_head *entry;
3932 unsigned long __user *p = (long __user *)arg;
3933#if CSDEBUG_INTERFACE
3934 int val;
3935
3936 if ( (cmd == SOUND_MIXER_CS_GETDBGMASK) ||
3937 (cmd == SOUND_MIXER_CS_SETDBGMASK) ||
3938 (cmd == SOUND_MIXER_CS_GETDBGLEVEL) ||
3939 (cmd == SOUND_MIXER_CS_SETDBGLEVEL) ||
3940 (cmd == SOUND_MIXER_CS_APM)) {
3941 switch (cmd) {
3942 case SOUND_MIXER_CS_GETDBGMASK:
3943 return put_user(cs_debugmask, p);
3944 case SOUND_MIXER_CS_GETDBGLEVEL:
3945 return put_user(cs_debuglevel, p);
3946 case SOUND_MIXER_CS_SETDBGMASK:
3947 if (get_user(val, p))
3948 return -EFAULT;
3949 cs_debugmask = val;
3950 return 0;
3951 case SOUND_MIXER_CS_SETDBGLEVEL:
3952 if (get_user(val, p))
3953 return -EFAULT;
3954 cs_debuglevel = val;
3955 return 0;
3956 case SOUND_MIXER_CS_APM:
3957 if (get_user(val, p))
3958 return -EFAULT;
3959 if (val == CS_IOCTL_CMD_SUSPEND) {
3960 list_for_each(entry, &cs46xx_devs) {
3961 card = list_entry(entry, struct cs_card, list);
3962 cs46xx_suspend(card, PMSG_ON);
3963 }
3964
3965 } else if (val == CS_IOCTL_CMD_RESUME) {
3966 list_for_each(entry, &cs46xx_devs) {
3967 card = list_entry(entry, struct cs_card, list);
3968 cs46xx_resume(card);
3969 }
3970 } else {
3971 CS_DBGOUT(CS_ERROR, 1, printk(KERN_INFO
3972 "cs46xx: mixer_ioctl(): invalid APM cmd (%d)\n",
3973 val));
3974 }
3975 return 0;
3976 default:
3977 CS_DBGOUT(CS_ERROR, 1, printk(KERN_INFO
3978 "cs46xx: mixer_ioctl(): ERROR unknown debug cmd\n"));
3979 return 0;
3980 }
3981 }
3982#endif
3983 return codec->mixer_ioctl(codec, cmd, arg);
3984}
3985
3986static /*const*/ struct file_operations cs_mixer_fops = {
3987 CS_OWNER CS_THIS_MODULE
3988 .llseek = no_llseek,
3989 .ioctl = cs_ioctl_mixdev,
3990 .open = cs_open_mixdev,
3991 .release = cs_release_mixdev,
3992};
3993
3994/* AC97 codec initialisation. */
3995static int __init cs_ac97_init(struct cs_card *card)
3996{
3997 int num_ac97 = 0;
3998 int ready_2nd = 0;
3999 struct ac97_codec *codec;
4000 u16 eid;
4001
4002 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4003 "cs46xx: cs_ac97_init()+\n") );
4004
4005 for (num_ac97 = 0; num_ac97 < NR_AC97; num_ac97++) {
4006 if ((codec = ac97_alloc_codec()) == NULL)
4007 return -ENOMEM;
4008
4009 /* initialize some basic codec information, other fields will be filled
4010 in ac97_probe_codec */
4011 codec->private_data = card;
4012 codec->id = num_ac97;
4013
4014 codec->codec_read = cs_ac97_get;
4015 codec->codec_write = cs_ac97_set;
4016
4017 if (ac97_probe_codec(codec) == 0) {
4018 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4019 "cs46xx: cs_ac97_init()- codec number %d not found\n",
4020 num_ac97) );
4021 card->ac97_codec[num_ac97] = NULL;
4022 break;
4023 }
4024 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4025 "cs46xx: cs_ac97_init() found codec %d\n",num_ac97));
4026
4027 eid = cs_ac97_get(codec, AC97_EXTENDED_ID);
4028
4029 if (eid == 0xFFFF) {
4030 printk(KERN_WARNING "cs46xx: codec %d not present\n",num_ac97);
4031 ac97_release_codec(codec);
4032 break;
4033 }
4034
4035 card->ac97_features = eid;
4036
4037 if ((codec->dev_mixer = register_sound_mixer(&cs_mixer_fops, -1)) < 0) {
4038 printk(KERN_ERR "cs46xx: couldn't register mixer!\n");
4039 ac97_release_codec(codec);
4040 break;
4041 }
4042 card->ac97_codec[num_ac97] = codec;
4043
4044 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4045 "cs46xx: cs_ac97_init() ac97_codec[%d] set to %p\n",
4046 (unsigned int)num_ac97,
4047 codec));
4048 /* if there is no secondary codec at all, don't probe any more */
4049 if (!ready_2nd)
4050 {
4051 num_ac97 += 1;
4052 break;
4053 }
4054 }
4055 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4056 "cs46xx: cs_ac97_init()- %d\n", (unsigned int)num_ac97));
4057 return num_ac97;
4058}
4059
4060/*
4061 * load the static image into the DSP
4062 */
4063#include "cs461x_image.h"
4064static void cs461x_download_image(struct cs_card *card)
4065{
4066 unsigned i, j, temp1, temp2, offset, count;
4067 unsigned char __iomem *pBA1 = ioremap(card->ba1_addr, 0x40000);
4068 for (i = 0; i < CLEAR__COUNT; i++) {
4069 offset = ClrStat[i].BA1__DestByteOffset;
4070 count = ClrStat[i].BA1__SourceSize;
4071 for (temp1 = offset; temp1 < (offset + count); temp1 += 4)
4072 writel(0, pBA1+temp1);
4073 }
4074
4075 for (i = 0; i < FILL__COUNT; i++) {
4076 temp2 = FillStat[i].Offset;
4077 for (j = 0; j < (FillStat[i].Size) / 4; j++) {
4078 temp1 = (FillStat[i]).pFill[j];
4079 writel(temp1, pBA1+temp2 + j * 4);
4080 }
4081 }
4082 iounmap(pBA1);
4083}
4084
4085/*
4086 * Chip reset
4087 */
4088
4089static void cs461x_reset(struct cs_card *card)
4090{
4091 int idx;
4092
4093 /*
4094 * Write the reset bit of the SP control register.
4095 */
4096 cs461x_poke(card, BA1_SPCR, SPCR_RSTSP);
4097
4098 /*
4099 * Write the control register.
4100 */
4101 cs461x_poke(card, BA1_SPCR, SPCR_DRQEN);
4102
4103 /*
4104 * Clear the trap registers.
4105 */
4106 for (idx = 0; idx < 8; idx++) {
4107 cs461x_poke(card, BA1_DREG, DREG_REGID_TRAP_SELECT + idx);
4108 cs461x_poke(card, BA1_TWPR, 0xFFFF);
4109 }
4110 cs461x_poke(card, BA1_DREG, 0);
4111
4112 /*
4113 * Set the frame timer to reflect the number of cycles per frame.
4114 */
4115 cs461x_poke(card, BA1_FRMT, 0xadf);
4116}
4117
4118static void cs461x_clear_serial_FIFOs(struct cs_card *card, int type)
4119{
4120 int idx, loop, startfifo=0, endfifo=0, powerdown1 = 0;
4121 unsigned int tmp;
4122
4123 /*
4124 * See if the devices are powered down. If so, we must power them up first
4125 * or they will not respond.
4126 */
4127 if (!((tmp = cs461x_peekBA0(card, BA0_CLKCR1)) & CLKCR1_SWCE)) {
4128 cs461x_pokeBA0(card, BA0_CLKCR1, tmp | CLKCR1_SWCE);
4129 powerdown1 = 1;
4130 }
4131
4132 /*
4133 * We want to clear out the serial port FIFOs so we don't end up playing
4134 * whatever random garbage happens to be in them. We fill the sample FIFOS
4135 * with zero (silence).
4136 */
4137 cs461x_pokeBA0(card, BA0_SERBWP, 0);
4138
4139 /*
4140 * Check for which FIFO locations to clear, if we are currently
4141 * playing or capturing then we don't want to put in 128 bytes of
4142 * "noise".
4143 */
4144 if (type & CS_TYPE_DAC) {
4145 startfifo = 128;
4146 endfifo = 256;
4147 }
4148 if (type & CS_TYPE_ADC) {
4149 startfifo = 0;
4150 if (!endfifo)
4151 endfifo = 128;
4152 }
4153 /*
4154 * Fill sample FIFO locations (256 locations total).
4155 */
4156 for (idx = startfifo; idx < endfifo; idx++) {
4157 /*
4158 * Make sure the previous FIFO write operation has completed.
4159 */
4160 for (loop = 0; loop < 5; loop++) {
4161 udelay(50);
4162 if (!(cs461x_peekBA0(card, BA0_SERBST) & SERBST_WBSY))
4163 break;
4164 }
4165 if (cs461x_peekBA0(card, BA0_SERBST) & SERBST_WBSY) {
4166 if (powerdown1)
4167 cs461x_pokeBA0(card, BA0_CLKCR1, tmp);
4168 }
4169 /*
4170 * Write the serial port FIFO index.
4171 */
4172 cs461x_pokeBA0(card, BA0_SERBAD, idx);
4173 /*
4174 * Tell the serial port to load the new value into the FIFO location.
4175 */
4176 cs461x_pokeBA0(card, BA0_SERBCM, SERBCM_WRC);
4177 }
4178 /*
4179 * Now, if we powered up the devices, then power them back down again.
4180 * This is kinda ugly, but should never happen.
4181 */
4182 if (powerdown1)
4183 cs461x_pokeBA0(card, BA0_CLKCR1, tmp);
4184}
4185
4186
4187static int cs461x_powerdown(struct cs_card *card, unsigned int type, int suspendflag)
4188{
4189 int count;
4190 unsigned int tmp=0,muted=0;
4191
4192 CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO
4193 "cs46xx: cs461x_powerdown()+ type=0x%x\n",type));
4194 if (!cs_powerdown && !suspendflag) {
4195 CS_DBGOUT(CS_FUNCTION, 8, printk(KERN_INFO
4196 "cs46xx: cs461x_powerdown() DISABLED exiting\n"));
4197 return 0;
4198 }
4199 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4200 CS_DBGOUT(CS_FUNCTION, 8, printk(KERN_INFO
4201 "cs46xx: cs461x_powerdown() powerdown reg=0x%x\n",tmp));
4202/*
4203* if powering down only the VREF, and not powering down the DAC/ADC,
4204* then do not power down the VREF, UNLESS both the DAC and ADC are not
4205* currently powered down. If powering down DAC and ADC, then
4206* it is possible to power down the VREF (ON).
4207*/
4208 if (((type & CS_POWER_MIXVON) &&
4209 (!(type & CS_POWER_ADC) || (!(type & CS_POWER_DAC))))
4210 &&
4211 ((tmp & CS_AC97_POWER_CONTROL_ADC_ON) ||
4212 (tmp & CS_AC97_POWER_CONTROL_DAC_ON))) {
4213 CS_DBGOUT(CS_FUNCTION, 8, printk(KERN_INFO
4214 "cs46xx: cs461x_powerdown()- 0 unable to powerdown. tmp=0x%x\n",tmp));
4215 return 0;
4216 }
4217/*
4218* for now, always keep power to the mixer block.
4219* not sure why it's a problem but it seems to be if we power off.
4220*/
4221 type &= ~CS_POWER_MIXVON;
4222 type &= ~CS_POWER_MIXVOFF;
4223
4224 /*
4225 * Power down indicated areas.
4226 */
4227 if (type & CS_POWER_MIXVOFF) {
4228
4229 CS_DBGOUT(CS_FUNCTION, 4,
4230 printk(KERN_INFO "cs46xx: cs461x_powerdown()+ MIXVOFF\n"));
4231 /*
4232 * Power down the MIXER (VREF ON) on the AC97 card.
4233 */
4234 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4235 if (tmp & CS_AC97_POWER_CONTROL_MIXVOFF_ON) {
4236 if (!muted) {
4237 cs_mute(card, CS_TRUE);
4238 muted = 1;
4239 }
4240 tmp |= CS_AC97_POWER_CONTROL_MIXVOFF;
4241 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp );
4242 /*
4243 * Now, we wait until we sample a ready state.
4244 */
4245 for (count = 0; count < 32; count++) {
4246 /*
4247 * First, lets wait a short while to let things settle out a
4248 * bit, and to prevent retrying the read too quickly.
4249 */
4250 udelay(500);
4251
4252 /*
4253 * Read the current state of the power control register.
4254 */
4255 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4256 CS_AC97_POWER_CONTROL_MIXVOFF_ON))
4257 break;
4258 }
4259
4260 /*
4261 * Check the status..
4262 */
4263 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4264 CS_AC97_POWER_CONTROL_MIXVOFF_ON) {
4265 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4266 "cs46xx: powerdown MIXVOFF failed\n"));
4267 return 1;
4268 }
4269 }
4270 }
4271 if (type & CS_POWER_MIXVON) {
4272
4273 CS_DBGOUT(CS_FUNCTION, 4,
4274 printk(KERN_INFO "cs46xx: cs461x_powerdown()+ MIXVON\n"));
4275 /*
4276 * Power down the MIXER (VREF ON) on the AC97 card.
4277 */
4278 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4279 if (tmp & CS_AC97_POWER_CONTROL_MIXVON_ON) {
4280 if (!muted) {
4281 cs_mute(card, CS_TRUE);
4282 muted = 1;
4283 }
4284 tmp |= CS_AC97_POWER_CONTROL_MIXVON;
4285 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp);
4286 /*
4287 * Now, we wait until we sample a ready state.
4288 */
4289 for (count = 0; count < 32; count++) {
4290 /*
4291 * First, lets wait a short while to let things settle out a
4292 * bit, and to prevent retrying the read too quickly.
4293 */
4294 udelay(500);
4295
4296 /*
4297 * Read the current state of the power control register.
4298 */
4299 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4300 CS_AC97_POWER_CONTROL_MIXVON_ON))
4301 break;
4302 }
4303
4304 /*
4305 * Check the status..
4306 */
4307 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4308 CS_AC97_POWER_CONTROL_MIXVON_ON) {
4309 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4310 "cs46xx: powerdown MIXVON failed\n"));
4311 return 1;
4312 }
4313 }
4314 }
4315 if (type & CS_POWER_ADC) {
4316 /*
4317 * Power down the ADC on the AC97 card.
4318 */
4319 CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO "cs46xx: cs461x_powerdown()+ ADC\n"));
4320 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4321 if (tmp & CS_AC97_POWER_CONTROL_ADC_ON) {
4322 if (!muted) {
4323 cs_mute(card, CS_TRUE);
4324 muted = 1;
4325 }
4326 tmp |= CS_AC97_POWER_CONTROL_ADC;
4327 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp);
4328
4329 /*
4330 * Now, we wait until we sample a ready state.
4331 */
4332 for (count = 0; count < 32; count++) {
4333 /*
4334 * First, lets wait a short while to let things settle out a
4335 * bit, and to prevent retrying the read too quickly.
4336 */
4337 udelay(500);
4338
4339 /*
4340 * Read the current state of the power control register.
4341 */
4342 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4343 CS_AC97_POWER_CONTROL_ADC_ON))
4344 break;
4345 }
4346
4347 /*
4348 * Check the status..
4349 */
4350 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4351 CS_AC97_POWER_CONTROL_ADC_ON) {
4352 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4353 "cs46xx: powerdown ADC failed\n"));
4354 return 1;
4355 }
4356 }
4357 }
4358 if (type & CS_POWER_DAC) {
4359 /*
4360 * Power down the DAC on the AC97 card.
4361 */
4362
4363 CS_DBGOUT(CS_FUNCTION, 4,
4364 printk(KERN_INFO "cs46xx: cs461x_powerdown()+ DAC\n"));
4365 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4366 if (tmp & CS_AC97_POWER_CONTROL_DAC_ON) {
4367 if (!muted) {
4368 cs_mute(card, CS_TRUE);
4369 muted = 1;
4370 }
4371 tmp |= CS_AC97_POWER_CONTROL_DAC;
4372 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp);
4373 /*
4374 * Now, we wait until we sample a ready state.
4375 */
4376 for (count = 0; count < 32; count++) {
4377 /*
4378 * First, lets wait a short while to let things settle out a
4379 * bit, and to prevent retrying the read too quickly.
4380 */
4381 udelay(500);
4382
4383 /*
4384 * Read the current state of the power control register.
4385 */
4386 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4387 CS_AC97_POWER_CONTROL_DAC_ON))
4388 break;
4389 }
4390
4391 /*
4392 * Check the status..
4393 */
4394 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4395 CS_AC97_POWER_CONTROL_DAC_ON) {
4396 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4397 "cs46xx: powerdown DAC failed\n"));
4398 return 1;
4399 }
4400 }
4401 }
4402 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4403 if (muted)
4404 cs_mute(card, CS_FALSE);
4405 CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO
4406 "cs46xx: cs461x_powerdown()- 0 tmp=0x%x\n",tmp));
4407 return 0;
4408}
4409
4410static int cs46xx_powerup(struct cs_card *card, unsigned int type)
4411{
4412 int count;
4413 unsigned int tmp = 0, muted = 0;
4414
4415 CS_DBGOUT(CS_FUNCTION, 8, printk(KERN_INFO
4416 "cs46xx: cs46xx_powerup()+ type=0x%x\n",type));
4417 /*
4418 * check for VREF and powerup if need to.
4419 */
4420 if (type & CS_POWER_MIXVON)
4421 type |= CS_POWER_MIXVOFF;
4422 if (type & (CS_POWER_DAC | CS_POWER_ADC))
4423 type |= CS_POWER_MIXVON | CS_POWER_MIXVOFF;
4424
4425 /*
4426 * Power up indicated areas.
4427 */
4428 if (type & CS_POWER_MIXVOFF) {
4429
4430 CS_DBGOUT(CS_FUNCTION, 4,
4431 printk(KERN_INFO "cs46xx: cs46xx_powerup()+ MIXVOFF\n"));
4432 /*
4433 * Power up the MIXER (VREF ON) on the AC97 card.
4434 */
4435 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4436 if (!(tmp & CS_AC97_POWER_CONTROL_MIXVOFF_ON)) {
4437 if (!muted) {
4438 cs_mute(card, CS_TRUE);
4439 muted = 1;
4440 }
4441 tmp &= ~CS_AC97_POWER_CONTROL_MIXVOFF;
4442 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp );
4443 /*
4444 * Now, we wait until we sample a ready state.
4445 */
4446 for (count = 0; count < 32; count++) {
4447 /*
4448 * First, lets wait a short while to let things settle out a
4449 * bit, and to prevent retrying the read too quickly.
4450 */
4451 udelay(500);
4452
4453 /*
4454 * Read the current state of the power control register.
4455 */
4456 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4457 CS_AC97_POWER_CONTROL_MIXVOFF_ON)
4458 break;
4459 }
4460
4461 /*
4462 * Check the status..
4463 */
4464 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4465 CS_AC97_POWER_CONTROL_MIXVOFF_ON)) {
4466 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4467 "cs46xx: powerup MIXVOFF failed\n"));
4468 return 1;
4469 }
4470 }
4471 }
4472 if(type & CS_POWER_MIXVON) {
4473
4474 CS_DBGOUT(CS_FUNCTION, 4,
4475 printk(KERN_INFO "cs46xx: cs46xx_powerup()+ MIXVON\n"));
4476 /*
4477 * Power up the MIXER (VREF ON) on the AC97 card.
4478 */
4479 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4480 if (!(tmp & CS_AC97_POWER_CONTROL_MIXVON_ON)) {
4481 if (!muted) {
4482 cs_mute(card, CS_TRUE);
4483 muted = 1;
4484 }
4485 tmp &= ~CS_AC97_POWER_CONTROL_MIXVON;
4486 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp );
4487 /*
4488 * Now, we wait until we sample a ready state.
4489 */
4490 for (count = 0; count < 32; count++) {
4491 /*
4492 * First, lets wait a short while to let things settle out a
4493 * bit, and to prevent retrying the read too quickly.
4494 */
4495 udelay(500);
4496
4497 /*
4498 * Read the current state of the power control register.
4499 */
4500 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4501 CS_AC97_POWER_CONTROL_MIXVON_ON)
4502 break;
4503 }
4504
4505 /*
4506 * Check the status..
4507 */
4508 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4509 CS_AC97_POWER_CONTROL_MIXVON_ON)) {
4510 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4511 "cs46xx: powerup MIXVON failed\n"));
4512 return 1;
4513 }
4514 }
4515 }
4516 if (type & CS_POWER_ADC) {
4517 /*
4518 * Power up the ADC on the AC97 card.
4519 */
4520 CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO "cs46xx: cs46xx_powerup()+ ADC\n"));
4521 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4522 if (!(tmp & CS_AC97_POWER_CONTROL_ADC_ON)) {
4523 if (!muted) {
4524 cs_mute(card, CS_TRUE);
4525 muted = 1;
4526 }
4527 tmp &= ~CS_AC97_POWER_CONTROL_ADC;
4528 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp );
4529
4530 /*
4531 * Now, we wait until we sample a ready state.
4532 */
4533 for (count = 0; count < 32; count++) {
4534 /*
4535 * First, lets wait a short while to let things settle out a
4536 * bit, and to prevent retrying the read too quickly.
4537 */
4538 udelay(500);
4539
4540 /*
4541 * Read the current state of the power control register.
4542 */
4543 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4544 CS_AC97_POWER_CONTROL_ADC_ON)
4545 break;
4546 }
4547
4548 /*
4549 * Check the status..
4550 */
4551 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4552 CS_AC97_POWER_CONTROL_ADC_ON)) {
4553 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4554 "cs46xx: powerup ADC failed\n"));
4555 return 1;
4556 }
4557 }
4558 }
4559 if (type & CS_POWER_DAC) {
4560 /*
4561 * Power up the DAC on the AC97 card.
4562 */
4563
4564 CS_DBGOUT(CS_FUNCTION, 4,
4565 printk(KERN_INFO "cs46xx: cs46xx_powerup()+ DAC\n"));
4566 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4567 if (!(tmp & CS_AC97_POWER_CONTROL_DAC_ON)) {
4568 if (!muted) {
4569 cs_mute(card, CS_TRUE);
4570 muted = 1;
4571 }
4572 tmp &= ~CS_AC97_POWER_CONTROL_DAC;
4573 cs_ac97_set(card->ac97_codec[0], AC97_POWER_CONTROL, tmp );
4574 /*
4575 * Now, we wait until we sample a ready state.
4576 */
4577 for (count = 0; count < 32; count++) {
4578 /*
4579 * First, lets wait a short while to let things settle out a
4580 * bit, and to prevent retrying the read too quickly.
4581 */
4582 udelay(500);
4583
4584 /*
4585 * Read the current state of the power control register.
4586 */
4587 if (cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4588 CS_AC97_POWER_CONTROL_DAC_ON)
4589 break;
4590 }
4591
4592 /*
4593 * Check the status..
4594 */
4595 if (!(cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL) &
4596 CS_AC97_POWER_CONTROL_DAC_ON)) {
4597 CS_DBGOUT(CS_ERROR, 1, printk(KERN_WARNING
4598 "cs46xx: powerup DAC failed\n"));
4599 return 1;
4600 }
4601 }
4602 }
4603 tmp = cs_ac97_get(card->ac97_codec[0], AC97_POWER_CONTROL);
4604 if (muted)
4605 cs_mute(card, CS_FALSE);
4606 CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO
4607 "cs46xx: cs46xx_powerup()- 0 tmp=0x%x\n",tmp));
4608 return 0;
4609}
4610
4611static void cs461x_proc_start(struct cs_card *card)
4612{
4613 int cnt;
4614
4615 /*
4616 * Set the frame timer to reflect the number of cycles per frame.
4617 */
4618 cs461x_poke(card, BA1_FRMT, 0xadf);
4619 /*
4620 * Turn on the run, run at frame, and DMA enable bits in the local copy of
4621 * the SP control register.
4622 */
4623 cs461x_poke(card, BA1_SPCR, SPCR_RUN | SPCR_RUNFR | SPCR_DRQEN);
4624 /*
4625 * Wait until the run at frame bit resets itself in the SP control
4626 * register.
4627 */
4628 for (cnt = 0; cnt < 25; cnt++) {
4629 udelay(50);
4630 if (!(cs461x_peek(card, BA1_SPCR) & SPCR_RUNFR))
4631 break;
4632 }
4633
4634 if (cs461x_peek(card, BA1_SPCR) & SPCR_RUNFR)
4635 printk(KERN_WARNING "cs46xx: SPCR_RUNFR never reset\n");
4636}
4637
4638static void cs461x_proc_stop(struct cs_card *card)
4639{
4640 /*
4641 * Turn off the run, run at frame, and DMA enable bits in the local copy of
4642 * the SP control register.
4643 */
4644 cs461x_poke(card, BA1_SPCR, 0);
4645}
4646
4647static int cs_hardware_init(struct cs_card *card)
4648{
4649 unsigned long end_time;
4650 unsigned int tmp,count;
4651
4652 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4653 "cs46xx: cs_hardware_init()+\n") );
4654 /*
4655 * First, blast the clock control register to zero so that the PLL starts
4656 * out in a known state, and blast the master serial port control register
4657 * to zero so that the serial ports also start out in a known state.
4658 */
4659 cs461x_pokeBA0(card, BA0_CLKCR1, 0);
4660 cs461x_pokeBA0(card, BA0_SERMC1, 0);
4661
4662 /*
4663 * If we are in AC97 mode, then we must set the part to a host controlled
4664 * AC-link. Otherwise, we won't be able to bring up the link.
4665 */
4666 cs461x_pokeBA0(card, BA0_SERACC, SERACC_HSP | SERACC_CODEC_TYPE_1_03); /* 1.03 card */
4667 /* cs461x_pokeBA0(card, BA0_SERACC, SERACC_HSP | SERACC_CODEC_TYPE_2_0); */ /* 2.00 card */
4668
4669 /*
4670 * Drive the ARST# pin low for a minimum of 1uS (as defined in the AC97
4671 * spec) and then drive it high. This is done for non AC97 modes since
4672 * there might be logic external to the CS461x that uses the ARST# line
4673 * for a reset.
4674 */
4675 cs461x_pokeBA0(card, BA0_ACCTL, 1);
4676 udelay(50);
4677 cs461x_pokeBA0(card, BA0_ACCTL, 0);
4678 udelay(50);
4679 cs461x_pokeBA0(card, BA0_ACCTL, ACCTL_RSTN);
4680
4681 /*
4682 * The first thing we do here is to enable sync generation. As soon
4683 * as we start receiving bit clock, we'll start producing the SYNC
4684 * signal.
4685 */
4686 cs461x_pokeBA0(card, BA0_ACCTL, ACCTL_ESYN | ACCTL_RSTN);
4687
4688 /*
4689 * Now wait for a short while to allow the AC97 part to start
4690 * generating bit clock (so we don't try to start the PLL without an
4691 * input clock).
4692 */
4693 mdelay(5 * cs_laptop_wait); /* 1 should be enough ?? (and pigs might fly) */
4694
4695 /*
4696 * Set the serial port timing configuration, so that
4697 * the clock control circuit gets its clock from the correct place.
4698 */
4699 cs461x_pokeBA0(card, BA0_SERMC1, SERMC1_PTC_AC97);
4700
4701 /*
4702 * The part seems to not be ready for a while after a resume.
4703 * so, if we are resuming, then wait for 700 mils. Note that 600 mils
4704 * is not enough for some platforms! tested on an IBM Thinkpads and
4705 * reference cards.
4706 */
4707 if (!(card->pm.flags & CS46XX_PM_IDLE))
4708 mdelay(initdelay);
4709 /*
4710 * Write the selected clock control setup to the hardware. Do not turn on
4711 * SWCE yet (if requested), so that the devices clocked by the output of
4712 * PLL are not clocked until the PLL is stable.
4713 */
4714 cs461x_pokeBA0(card, BA0_PLLCC, PLLCC_LPF_1050_2780_KHZ | PLLCC_CDR_73_104_MHZ);
4715 cs461x_pokeBA0(card, BA0_PLLM, 0x3a);
4716 cs461x_pokeBA0(card, BA0_CLKCR2, CLKCR2_PDIVS_8);
4717
4718 /*
4719 * Power up the PLL.
4720 */
4721 cs461x_pokeBA0(card, BA0_CLKCR1, CLKCR1_PLLP);
4722
4723 /*
4724 * Wait until the PLL has stabilized.
4725 */
4726 mdelay(5 * cs_laptop_wait); /* Again 1 should be enough ?? */
4727
4728 /*
4729 * Turn on clocking of the core so that we can setup the serial ports.
4730 */
4731 tmp = cs461x_peekBA0(card, BA0_CLKCR1) | CLKCR1_SWCE;
4732 cs461x_pokeBA0(card, BA0_CLKCR1, tmp);
4733
4734 /*
4735 * Fill the serial port FIFOs with silence.
4736 */
4737 cs461x_clear_serial_FIFOs(card,CS_TYPE_DAC | CS_TYPE_ADC);
4738
4739 /*
4740 * Set the serial port FIFO pointer to the first sample in the FIFO.
4741 */
4742 /* cs461x_pokeBA0(card, BA0_SERBSP, 0); */
4743
4744 /*
4745 * Write the serial port configuration to the part. The master
4746 * enable bit is not set until all other values have been written.
4747 */
4748 cs461x_pokeBA0(card, BA0_SERC1, SERC1_SO1F_AC97 | SERC1_SO1EN);
4749 cs461x_pokeBA0(card, BA0_SERC2, SERC2_SI1F_AC97 | SERC1_SO1EN);
4750 cs461x_pokeBA0(card, BA0_SERMC1, SERMC1_PTC_AC97 | SERMC1_MSPE);
4751
4752
4753 mdelay(5 * cs_laptop_wait); /* Shouldnt be needed ?? */
4754
4755/*
4756* If we are resuming under 2.2.x then we cannot schedule a timeout,
4757* so just spin the CPU.
4758*/
4759 if (card->pm.flags & CS46XX_PM_IDLE) {
4760 /*
4761 * Wait for the card ready signal from the AC97 card.
4762 */
4763 end_time = jiffies + 3 * (HZ >> 2);
4764 do {
4765 /*
4766 * Read the AC97 status register to see if we've seen a CODEC READY
4767 * signal from the AC97 card.
4768 */
4769 if (cs461x_peekBA0(card, BA0_ACSTS) & ACSTS_CRDY)
4770 break;
4771 current->state = TASK_UNINTERRUPTIBLE;
4772 schedule_timeout(1);
4773 } while (time_before(jiffies, end_time));
4774 } else {
4775 for (count = 0; count < 100; count++) {
4776 // First, we want to wait for a short time.
4777 udelay(25 * cs_laptop_wait);
4778
4779 if (cs461x_peekBA0(card, BA0_ACSTS) & ACSTS_CRDY)
4780 break;
4781 }
4782 }
4783
4784 /*
4785 * Make sure CODEC is READY.
4786 */
4787 if (!(cs461x_peekBA0(card, BA0_ACSTS) & ACSTS_CRDY)) {
4788 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_WARNING
4789 "cs46xx: create - never read card ready from AC'97\n"));
4790 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_WARNING
4791 "cs46xx: probably not a bug, try using the CS4232 driver,\n"));
4792 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_WARNING
4793 "cs46xx: or turn off any automatic Power Management support in the BIOS.\n"));
4794 return -EIO;
4795 }
4796
4797 /*
4798 * Assert the vaid frame signal so that we can start sending commands
4799 * to the AC97 card.
4800 */
4801 cs461x_pokeBA0(card, BA0_ACCTL, ACCTL_VFRM | ACCTL_ESYN | ACCTL_RSTN);
4802
4803 if (card->pm.flags & CS46XX_PM_IDLE) {
4804 /*
4805 * Wait until we've sampled input slots 3 and 4 as valid, meaning that
4806 * the card is pumping ADC data across the AC-link.
4807 */
4808 end_time = jiffies + 3 * (HZ >> 2);
4809 do {
4810 /*
4811 * Read the input slot valid register and see if input slots 3 and
4812 * 4 are valid yet.
4813 */
4814 if ((cs461x_peekBA0(card, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4))
4815 break;
4816 current->state = TASK_UNINTERRUPTIBLE;
4817 schedule_timeout(1);
4818 } while (time_before(jiffies, end_time));
4819 } else {
4820 for (count = 0; count < 100; count++) {
4821 // First, we want to wait for a short time.
4822 udelay(25 * cs_laptop_wait);
4823
4824 if ((cs461x_peekBA0(card, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4))
4825 break;
4826 }
4827 }
4828 /*
4829 * Make sure input slots 3 and 4 are valid. If not, then return
4830 * an error.
4831 */
4832 if ((cs461x_peekBA0(card, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) != (ACISV_ISV3 | ACISV_ISV4)) {
4833 printk(KERN_WARNING "cs46xx: create - never read ISV3 & ISV4 from AC'97\n");
4834 return -EIO;
4835 }
4836
4837 /*
4838 * Now, assert valid frame and the slot 3 and 4 valid bits. This will
4839 * commense the transfer of digital audio data to the AC97 card.
4840 */
4841 cs461x_pokeBA0(card, BA0_ACOSV, ACOSV_SLV3 | ACOSV_SLV4);
4842
4843 /*
4844 * Turn off the Processor by turning off the software clock enable flag in
4845 * the clock control register.
4846 */
4847 /* tmp = cs461x_peekBA0(card, BA0_CLKCR1) & ~CLKCR1_SWCE; */
4848 /* cs461x_pokeBA0(card, BA0_CLKCR1, tmp); */
4849
4850 /*
4851 * Reset the processor.
4852 */
4853 cs461x_reset(card);
4854
4855 /*
4856 * Download the image to the processor.
4857 */
4858
4859 cs461x_download_image(card);
4860
4861 /*
4862 * Stop playback DMA.
4863 */
4864 tmp = cs461x_peek(card, BA1_PCTL);
4865 card->pctl = tmp & 0xffff0000;
4866 cs461x_poke(card, BA1_PCTL, tmp & 0x0000ffff);
4867
4868 /*
4869 * Stop capture DMA.
4870 */
4871 tmp = cs461x_peek(card, BA1_CCTL);
4872 card->cctl = tmp & 0x0000ffff;
4873 cs461x_poke(card, BA1_CCTL, tmp & 0xffff0000);
4874
4875 /* initialize AC97 codec and register /dev/mixer */
4876 if (card->pm.flags & CS46XX_PM_IDLE) {
4877 if (cs_ac97_init(card) <= 0) {
4878 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
4879 "cs46xx: cs_ac97_init() failure\n"));
4880 return -EIO;
4881 }
4882 } else {
4883 cs46xx_ac97_resume(card);
4884 }
4885
4886 cs461x_proc_start(card);
4887
4888 /*
4889 * Enable interrupts on the part.
4890 */
4891 cs461x_pokeBA0(card, BA0_HICR, HICR_IEV | HICR_CHGM);
4892
4893 tmp = cs461x_peek(card, BA1_PFIE);
4894 tmp &= ~0x0000f03f;
4895 cs461x_poke(card, BA1_PFIE, tmp); /* playback interrupt enable */
4896
4897 tmp = cs461x_peek(card, BA1_CIE);
4898 tmp &= ~0x0000003f;
4899 tmp |= 0x00000001;
4900 cs461x_poke(card, BA1_CIE, tmp); /* capture interrupt enable */
4901
4902 /*
4903 * If IDLE then Power down the part. We will power components up
4904 * when we need them.
4905 */
4906 if (card->pm.flags & CS46XX_PM_IDLE) {
4907 if (!cs_powerdown) {
4908 if ((tmp = cs46xx_powerup(card, CS_POWER_DAC | CS_POWER_ADC |
4909 CS_POWER_MIXVON))) {
4910 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
4911 "cs46xx: cs461x_powerup() failure (0x%x)\n",tmp) );
4912 return -EIO;
4913 }
4914 } else {
4915 if ((tmp = cs461x_powerdown(card, CS_POWER_DAC | CS_POWER_ADC |
4916 CS_POWER_MIXVON, CS_FALSE))) {
4917 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
4918 "cs46xx: cs461x_powerdown() failure (0x%x)\n",tmp) );
4919 return -EIO;
4920 }
4921 }
4922 }
4923 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2, printk(KERN_INFO
4924 "cs46xx: cs_hardware_init()- 0\n"));
4925 return 0;
4926}
4927
4928/* install the driver, we do not allocate hardware channel nor DMA buffer now, they are defered
4929 until "ACCESS" time (in prog_dmabuf called by open/read/write/ioctl/mmap) */
4930
4931/*
4932 * Card subid table
4933 */
4934
4935struct cs_card_type
4936{
4937 u16 vendor;
4938 u16 id;
4939 char *name;
4940 void (*amp)(struct cs_card *, int);
4941 void (*amp_init)(struct cs_card *);
4942 void (*active)(struct cs_card *, int);
4943};
4944
4945static struct cs_card_type cards[] = {
4946 {
4947 .vendor = 0x1489,
4948 .id = 0x7001,
4949 .name = "Genius Soundmaker 128 value",
4950 .amp = amp_none,
4951 },
4952 {
4953 .vendor = 0x5053,
4954 .id = 0x3357,
4955 .name = "Voyetra",
4956 .amp = amp_voyetra,
4957 },
4958 {
4959 .vendor = 0x1071,
4960 .id = 0x6003,
4961 .name = "Mitac MI6020/21",
4962 .amp = amp_voyetra,
4963 },
4964 {
4965 .vendor = 0x14AF,
4966 .id = 0x0050,
4967 .name = "Hercules Game Theatre XP",
4968 .amp = amp_hercules,
4969 },
4970 {
4971 .vendor = 0x1681,
4972 .id = 0x0050,
4973 .name = "Hercules Game Theatre XP",
4974 .amp = amp_hercules,
4975 },
4976 {
4977 .vendor = 0x1681,
4978 .id = 0x0051,
4979 .name = "Hercules Game Theatre XP",
4980 .amp = amp_hercules,
4981 },
4982 {
4983 .vendor = 0x1681,
4984 .id = 0x0052,
4985 .name = "Hercules Game Theatre XP",
4986 .amp = amp_hercules,
4987 },
4988 {
4989 .vendor = 0x1681,
4990 .id = 0x0053,
4991 .name = "Hercules Game Theatre XP",
4992 .amp = amp_hercules,
4993 },
4994 {
4995 .vendor = 0x1681,
4996 .id = 0x0054,
4997 .name = "Hercules Game Theatre XP",
4998 .amp = amp_hercules,
4999 },
5000 {
5001 .vendor = 0x1681,
5002 .id = 0xa010,
5003 .name = "Hercules Fortissimo II",
5004 .amp = amp_none,
5005 },
5006 /* Not sure if the 570 needs the clkrun hack */
5007 {
5008 .vendor = PCI_VENDOR_ID_IBM,
5009 .id = 0x0132,
5010 .name = "Thinkpad 570",
5011 .amp = amp_none,
5012 .active = clkrun_hack,
5013 },
5014 {
5015 .vendor = PCI_VENDOR_ID_IBM,
5016 .id = 0x0153,
5017 .name = "Thinkpad 600X/A20/T20",
5018 .amp = amp_none,
5019 .active = clkrun_hack,
5020 },
5021 {
5022 .vendor = PCI_VENDOR_ID_IBM,
5023 .id = 0x1010,
5024 .name = "Thinkpad 600E (unsupported)",
5025 },
5026 {
5027 .name = "Card without SSID set",
5028 },
5029 { 0, },
5030};
5031
5032MODULE_AUTHOR("Alan Cox <alan@redhat.com>, Jaroslav Kysela, <pcaudio@crystal.cirrus.com>");
5033MODULE_DESCRIPTION("Crystal SoundFusion Audio Support");
5034MODULE_LICENSE("GPL");
5035
5036static const char cs46xx_banner[] = KERN_INFO "Crystal 4280/46xx + AC97 Audio, version " CS46XX_MAJOR_VERSION "." CS46XX_MINOR_VERSION "." CS46XX_ARCH ", " __TIME__ " " __DATE__ "\n";
5037static const char fndmsg[] = KERN_INFO "cs46xx: Found %d audio device(s).\n";
5038
5039static int __devinit cs46xx_probe(struct pci_dev *pci_dev,
5040 const struct pci_device_id *pciid)
5041{
5042 int i, j;
5043 u16 ss_card, ss_vendor;
5044 struct cs_card *card;
5045 dma_addr_t dma_mask;
5046 struct cs_card_type *cp = &cards[0];
5047
5048 CS_DBGOUT(CS_FUNCTION | CS_INIT, 2,
5049 printk(KERN_INFO "cs46xx: probe()+\n"));
5050
5051 dma_mask = 0xffffffff; /* this enables playback and recording */
5052 if (pci_enable_device(pci_dev)) {
5053 CS_DBGOUT(CS_INIT | CS_ERROR, 1, printk(KERN_ERR
5054 "cs46xx: pci_enable_device() failed\n"));
5055 return -1;
5056 }
5057 if (!RSRCISMEMORYREGION(pci_dev, 0) ||
5058 !RSRCISMEMORYREGION(pci_dev, 1)) {
5059 CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
5060 "cs46xx: probe()- Memory region not assigned\n"));
5061 return -1;
5062 }
5063 if (pci_dev->irq == 0) {
5064 CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
5065 "cs46xx: probe() IRQ not assigned\n"));
5066 return -1;
5067 }
5068 if (!pci_dma_supported(pci_dev, 0xffffffff)) {
5069 CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
5070 "cs46xx: probe() architecture does not support 32bit PCI busmaster DMA\n"));
5071 return -1;
5072 }
5073 pci_read_config_word(pci_dev, PCI_SUBSYSTEM_VENDOR_ID, &ss_vendor);
5074 pci_read_config_word(pci_dev, PCI_SUBSYSTEM_ID, &ss_card);
5075
5076 if ((card = kzalloc(sizeof(struct cs_card), GFP_KERNEL)) == NULL) {
5077 printk(KERN_ERR "cs46xx: out of memory\n");
5078 return -ENOMEM;
5079 }
5080 card->ba0_addr = RSRCADDRESS(pci_dev, 0);
5081 card->ba1_addr = RSRCADDRESS(pci_dev, 1);
5082 card->pci_dev = pci_dev;
5083 card->irq = pci_dev->irq;
5084 card->magic = CS_CARD_MAGIC;
5085 spin_lock_init(&card->lock);
5086 spin_lock_init(&card->ac97_lock);
5087
5088 pci_set_master(pci_dev);
5089
5090 printk(cs46xx_banner);
5091 printk(KERN_INFO "cs46xx: Card found at 0x%08lx and 0x%08lx, IRQ %d\n",
5092 card->ba0_addr, card->ba1_addr, card->irq);
5093
5094 card->alloc_pcm_channel = cs_alloc_pcm_channel;
5095 card->alloc_rec_pcm_channel = cs_alloc_rec_pcm_channel;
5096 card->free_pcm_channel = cs_free_pcm_channel;
5097 card->amplifier_ctrl = amp_none;
5098 card->active_ctrl = amp_none;
5099
5100 while (cp->name)
5101 {
5102 if (cp->vendor == ss_vendor && cp->id == ss_card) {
5103 card->amplifier_ctrl = cp->amp;
5104 if (cp->active)
5105 card->active_ctrl = cp->active;
5106 if (cp->amp_init)
5107 card->amp_init = cp->amp_init;
5108 break;
5109 }
5110 cp++;
5111 }
5112 if (cp->name == NULL) {
5113 printk(KERN_INFO "cs46xx: Unknown card (%04X:%04X) at 0x%08lx/0x%08lx, IRQ %d\n",
5114 ss_vendor, ss_card, card->ba0_addr, card->ba1_addr, card->irq);
5115 } else {
5116 printk(KERN_INFO "cs46xx: %s (%04X:%04X) at 0x%08lx/0x%08lx, IRQ %d\n",
5117 cp->name, ss_vendor, ss_card, card->ba0_addr, card->ba1_addr, card->irq);
5118 }
5119
5120 if (card->amplifier_ctrl == NULL) {
5121 card->amplifier_ctrl = amp_none;
5122 card->active_ctrl = clkrun_hack;
5123 }
5124
5125 if (external_amp == 1) {
5126 printk(KERN_INFO "cs46xx: Crystal EAPD support forced on.\n");
5127 card->amplifier_ctrl = amp_voyetra;
5128 }
5129
5130 if (thinkpad == 1) {
5131 printk(KERN_INFO "cs46xx: Activating CLKRUN hack for Thinkpad.\n");
5132 card->active_ctrl = clkrun_hack;
5133 }
5134/*
5135* The thinkpads don't work well without runtime updating on their kernel
5136* delay values (or any laptop with variable CPU speeds really).
5137* so, just to be safe set the init delay to 2100. Eliminates
5138* failures on T21 Thinkpads. remove this code when the udelay
5139* and mdelay kernel code is replaced by a pm timer, or the delays
5140* work well for battery and/or AC power both.
5141*/
5142 if (card->active_ctrl == clkrun_hack) {
5143 initdelay = 2100;
5144 cs_laptop_wait = 5;
5145 }
5146 if ((card->active_ctrl == clkrun_hack) && !(powerdown == 1)) {
5147/*
5148* for some currently unknown reason, powering down the DAC and ADC component
5149* blocks on thinkpads causes some funky behavior... distoorrrtion and ac97
5150* codec access problems. probably the serial clock becomes unsynced.
5151* added code to sync the chips back up, but only helped about 70% the time.
5152*/
5153 cs_powerdown = 0;
5154 }
5155 if (powerdown == 0)
5156 cs_powerdown = 0;
5157 card->active_ctrl(card, 1);
5158
5159 /* claim our iospace and irq */
5160
5161 card->ba0 = ioremap_nocache(card->ba0_addr, CS461X_BA0_SIZE);
5162 card->ba1.name.data0 = ioremap_nocache(card->ba1_addr + BA1_SP_DMEM0, CS461X_BA1_DATA0_SIZE);
5163 card->ba1.name.data1 = ioremap_nocache(card->ba1_addr + BA1_SP_DMEM1, CS461X_BA1_DATA1_SIZE);
5164 card->ba1.name.pmem = ioremap_nocache(card->ba1_addr + BA1_SP_PMEM, CS461X_BA1_PRG_SIZE);
5165 card->ba1.name.reg = ioremap_nocache(card->ba1_addr + BA1_SP_REG, CS461X_BA1_REG_SIZE);
5166
5167 CS_DBGOUT(CS_INIT, 4, printk(KERN_INFO
5168 "cs46xx: card=%p card->ba0=%p\n",card,card->ba0) );
5169 CS_DBGOUT(CS_INIT, 4, printk(KERN_INFO
5170 "cs46xx: card->ba1=%p %p %p %p\n",
5171 card->ba1.name.data0,
5172 card->ba1.name.data1,
5173 card->ba1.name.pmem,
5174 card->ba1.name.reg) );
5175
5176 if (card->ba0 == 0 || card->ba1.name.data0 == 0 ||
5177 card->ba1.name.data1 == 0 || card->ba1.name.pmem == 0 ||
5178 card->ba1.name.reg == 0)
5179 goto fail2;
5180
5181 if (request_irq(card->irq, &cs_interrupt, IRQF_SHARED, "cs46xx", card)) {
5182 printk(KERN_ERR "cs46xx: unable to allocate irq %d\n", card->irq);
5183 goto fail2;
5184 }
5185 /* register /dev/dsp */
5186 if ((card->dev_audio = register_sound_dsp(&cs461x_fops, -1)) < 0) {
5187 printk(KERN_ERR "cs46xx: unable to register dsp\n");
5188 goto fail;
5189 }
5190
5191 /* register /dev/midi */
5192 if ((card->dev_midi = register_sound_midi(&cs_midi_fops, -1)) < 0)
5193 printk(KERN_ERR "cs46xx: unable to register midi\n");
5194
5195 card->pm.flags |= CS46XX_PM_IDLE;
5196 for (i = 0; i < 5; i++) {
5197 if (cs_hardware_init(card) != 0) {
5198 CS_DBGOUT(CS_ERROR, 4, printk(
5199 "cs46xx: ERROR in cs_hardware_init()... retrying\n"));
5200 for (j = 0; j < NR_AC97; j++)
5201 if (card->ac97_codec[j] != NULL) {
5202 unregister_sound_mixer(card->ac97_codec[j]->dev_mixer);
5203 ac97_release_codec(card->ac97_codec[j]);
5204 }
5205 mdelay(10 * cs_laptop_wait);
5206 continue;
5207 }
5208 break;
5209 }
5210 if(i >= 4) {
5211 CS_DBGOUT(CS_PM | CS_ERROR, 1, printk(
5212 "cs46xx: cs46xx_probe()- cs_hardware_init() failed, retried %d times.\n",i));
5213 unregister_sound_dsp(card->dev_audio);
5214 if (card->dev_midi)
5215 unregister_sound_midi(card->dev_midi);
5216 goto fail;
5217 }
5218
5219 init_waitqueue_head(&card->midi.open_wait);
5220 mutex_init(&card->midi.open_mutex);
5221 init_waitqueue_head(&card->midi.iwait);
5222 init_waitqueue_head(&card->midi.owait);
5223 cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST);
5224 cs461x_pokeBA0(card, BA0_MIDCR, 0);
5225
5226 /*
5227 * Check if we have to init the amplifier, but probably already done
5228 * since the CD logic in the ac97 init code will turn on the ext amp.
5229 */
5230 if (cp->amp_init)
5231 cp->amp_init(card);
5232 card->active_ctrl(card, -1);
5233
5234 PCI_SET_DRIVER_DATA(pci_dev, card);
5235 PCI_SET_DMA_MASK(pci_dev, dma_mask);
5236 list_add(&card->list, &cs46xx_devs);
5237
5238 CS_DBGOUT(CS_PM, 9, printk(KERN_INFO "cs46xx: pm.flags=0x%x card=%p\n",
5239 (unsigned)card->pm.flags,card));
5240
5241 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
5242 "cs46xx: probe()- device allocated successfully\n"));
5243 return 0;
5244
5245fail:
5246 free_irq(card->irq, card);
5247fail2:
5248 if (card->ba0)
5249 iounmap(card->ba0);
5250 if (card->ba1.name.data0)
5251 iounmap(card->ba1.name.data0);
5252 if (card->ba1.name.data1)
5253 iounmap(card->ba1.name.data1);
5254 if (card->ba1.name.pmem)
5255 iounmap(card->ba1.name.pmem);
5256 if (card->ba1.name.reg)
5257 iounmap(card->ba1.name.reg);
5258 kfree(card);
5259 CS_DBGOUT(CS_INIT | CS_ERROR, 1, printk(KERN_INFO
5260 "cs46xx: probe()- no device allocated\n"));
5261 return -ENODEV;
5262} // probe_cs46xx
5263
5264// ---------------------------------------------------------------------
5265
5266static void __devexit cs46xx_remove(struct pci_dev *pci_dev)
5267{
5268 struct cs_card *card = PCI_GET_DRIVER_DATA(pci_dev);
5269 int i;
5270 unsigned int tmp;
5271
5272 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
5273 "cs46xx: cs46xx_remove()+\n"));
5274
5275 card->active_ctrl(card,1);
5276
5277 tmp = cs461x_peek(card, BA1_PFIE);
5278 tmp &= ~0x0000f03f;
5279 tmp |= 0x00000010;
5280 cs461x_poke(card, BA1_PFIE, tmp); /* playback interrupt disable */
5281
5282 tmp = cs461x_peek(card, BA1_CIE);
5283 tmp &= ~0x0000003f;
5284 tmp |= 0x00000011;
5285 cs461x_poke(card, BA1_CIE, tmp); /* capture interrupt disable */
5286
5287 /*
5288 * Stop playback DMA.
5289 */
5290 tmp = cs461x_peek(card, BA1_PCTL);
5291 cs461x_poke(card, BA1_PCTL, tmp & 0x0000ffff);
5292
5293 /*
5294 * Stop capture DMA.
5295 */
5296 tmp = cs461x_peek(card, BA1_CCTL);
5297 cs461x_poke(card, BA1_CCTL, tmp & 0xffff0000);
5298
5299 /*
5300 * Reset the processor.
5301 */
5302 cs461x_reset(card);
5303
5304 cs461x_proc_stop(card);
5305
5306 /*
5307 * Power down the DAC and ADC. We will power them up (if) when we need
5308 * them.
5309 */
5310 if ((tmp = cs461x_powerdown(card, CS_POWER_DAC | CS_POWER_ADC |
5311 CS_POWER_MIXVON, CS_TRUE))) {
5312 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(KERN_INFO
5313 "cs46xx: cs461x_powerdown() failure (0x%x)\n",tmp) );
5314 }
5315
5316 /*
5317 * Power down the PLL.
5318 */
5319 cs461x_pokeBA0(card, BA0_CLKCR1, 0);
5320
5321 /*
5322 * Turn off the Processor by turning off the software clock enable flag in
5323 * the clock control register.
5324 */
5325 tmp = cs461x_peekBA0(card, BA0_CLKCR1) & ~CLKCR1_SWCE;
5326 cs461x_pokeBA0(card, BA0_CLKCR1, tmp);
5327
5328 card->active_ctrl(card,-1);
5329
5330 /* free hardware resources */
5331 free_irq(card->irq, card);
5332 iounmap(card->ba0);
5333 iounmap(card->ba1.name.data0);
5334 iounmap(card->ba1.name.data1);
5335 iounmap(card->ba1.name.pmem);
5336 iounmap(card->ba1.name.reg);
5337
5338 /* unregister audio devices */
5339 for (i = 0; i < NR_AC97; i++)
5340 if (card->ac97_codec[i] != NULL) {
5341 unregister_sound_mixer(card->ac97_codec[i]->dev_mixer);
5342 ac97_release_codec(card->ac97_codec[i]);
5343 }
5344 unregister_sound_dsp(card->dev_audio);
5345 if (card->dev_midi)
5346 unregister_sound_midi(card->dev_midi);
5347 list_del(&card->list);
5348 kfree(card);
5349 PCI_SET_DRIVER_DATA(pci_dev,NULL);
5350
5351 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
5352 "cs46xx: cs46xx_remove()-: remove successful\n"));
5353}
5354
5355enum {
5356 CS46XX_4610 = 0,
5357 CS46XX_4612, /* same as 4630 */
5358 CS46XX_4615, /* same as 4624 */
5359};
5360
5361static struct pci_device_id cs46xx_pci_tbl[] = {
5362 {
5363 .vendor = PCI_VENDOR_ID_CIRRUS,
5364 .device = PCI_DEVICE_ID_CIRRUS_4610,
5365 .subvendor = PCI_ANY_ID,
5366 .subdevice = PCI_ANY_ID,
5367 .driver_data = CS46XX_4610,
5368 },
5369 {
5370 .vendor = PCI_VENDOR_ID_CIRRUS,
5371 .device = PCI_DEVICE_ID_CIRRUS_4612,
5372 .subvendor = PCI_ANY_ID,
5373 .subdevice = PCI_ANY_ID,
5374 .driver_data = CS46XX_4612,
5375 },
5376 {
5377 .vendor = PCI_VENDOR_ID_CIRRUS,
5378 .device = PCI_DEVICE_ID_CIRRUS_4615,
5379 .subvendor = PCI_ANY_ID,
5380 .subdevice = PCI_ANY_ID,
5381 .driver_data = CS46XX_4615,
5382 },
5383 { 0, },
5384};
5385
5386MODULE_DEVICE_TABLE(pci, cs46xx_pci_tbl);
5387
5388static struct pci_driver cs46xx_pci_driver = {
5389 .name = "cs46xx",
5390 .id_table = cs46xx_pci_tbl,
5391 .probe = cs46xx_probe,
5392 .remove = __devexit_p(cs46xx_remove),
5393#ifdef CONFIG_PM
5394 .suspend = cs46xx_suspend_tbl,
5395 .resume = cs46xx_resume_tbl,
5396#endif
5397};
5398
5399static int __init cs46xx_init_module(void)
5400{
5401 int rtn = 0;
5402 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
5403 "cs46xx: cs46xx_init_module()+ \n"));
5404 rtn = pci_register_driver(&cs46xx_pci_driver);
5405
5406 if (rtn == -ENODEV) {
5407 CS_DBGOUT(CS_ERROR | CS_INIT, 1, printk(
5408 "cs46xx: Unable to detect valid cs46xx device\n"));
5409 }
5410
5411 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2,
5412 printk(KERN_INFO "cs46xx: cs46xx_init_module()- (%d)\n",rtn));
5413 return rtn;
5414}
5415
5416static void __exit cs46xx_cleanup_module(void)
5417{
5418 pci_unregister_driver(&cs46xx_pci_driver);
5419 CS_DBGOUT(CS_INIT | CS_FUNCTION, 2,
5420 printk(KERN_INFO "cs46xx: cleanup_cs46xx() finished\n"));
5421}
5422
5423module_init(cs46xx_init_module);
5424module_exit(cs46xx_cleanup_module);
5425
5426#ifdef CONFIG_PM
5427static int cs46xx_suspend_tbl(struct pci_dev *pcidev, pm_message_t state)
5428{
5429 struct cs_card *s = PCI_GET_DRIVER_DATA(pcidev);
5430 CS_DBGOUT(CS_PM | CS_FUNCTION, 2,
5431 printk(KERN_INFO "cs46xx: cs46xx_suspend_tbl request\n"));
5432 cs46xx_suspend(s, state);
5433 return 0;
5434}
5435
5436static int cs46xx_resume_tbl(struct pci_dev *pcidev)
5437{
5438 struct cs_card *s = PCI_GET_DRIVER_DATA(pcidev);
5439 CS_DBGOUT(CS_PM | CS_FUNCTION, 2,
5440 printk(KERN_INFO "cs46xx: cs46xx_resume_tbl request\n"));
5441 cs46xx_resume(s);
5442 return 0;
5443}
5444#endif
diff --git a/sound/oss/cs46xx_wrapper-24.h b/sound/oss/cs46xx_wrapper-24.h
deleted file mode 100644
index f68e01181a7..00000000000
--- a/sound/oss/cs46xx_wrapper-24.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*******************************************************************************
2*
3* "cs46xx_wrapper.c" -- Cirrus Logic-Crystal CS46XX linux audio driver.
4*
5* Copyright (C) 2000,2001 Cirrus Logic Corp.
6* -- tom woller (twoller@crystal.cirrus.com) or
7* (pcaudio@crystal.cirrus.com).
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License
20* along with this program; if not, write to the Free Software
21* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*
23* 01/11/2001 trw - new file from cs4281 wrapper code.
24*
25*******************************************************************************/
26#ifndef __CS46XX_WRAPPER24_H
27#define __CS46XX_WRAPPER24_H
28
29#include <linux/spinlock.h>
30
31#define CS_OWNER .owner =
32#define CS_THIS_MODULE THIS_MODULE,
33static inline void cs46xx_null(struct pci_dev *pcidev) { return; }
34#define cs4x_mem_map_reserve(page) SetPageReserved(page)
35#define cs4x_mem_map_unreserve(page) ClearPageReserved(page)
36
37#define free_dmabuf(card, dmabuf) \
38 pci_free_consistent((card)->pci_dev, \
39 PAGE_SIZE << (dmabuf)->buforder, \
40 (dmabuf)->rawbuf, (dmabuf)->dmaaddr);
41#define free_dmabuf2(card, dmabuf) \
42 pci_free_consistent((card)->pci_dev, \
43 PAGE_SIZE << (dmabuf)->buforder_tmpbuff, \
44 (dmabuf)->tmpbuff, (dmabuf)->dmaaddr_tmpbuff);
45#define cs4x_pgoff(vma) ((vma)->vm_pgoff)
46
47#define RSRCISIOREGION(dev,num) ((dev)->resource[(num)].start != 0 && \
48 ((dev)->resource[(num)].flags & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO)
49#define RSRCISMEMORYREGION(dev,num) ((dev)->resource[(num)].start != 0 && \
50 ((dev)->resource[(num)].flags & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY)
51#define RSRCADDRESS(dev,num) ((dev)->resource[(num)].start)
52#define PCI_GET_DRIVER_DATA pci_get_drvdata
53#define PCI_SET_DRIVER_DATA pci_set_drvdata
54#define PCI_SET_DMA_MASK(pcidev,mask) pcidev->dma_mask = mask
55
56#endif
diff --git a/sound/oss/cs46xxpm.h b/sound/oss/cs46xxpm.h
deleted file mode 100644
index 2932b6e0e0b..00000000000
--- a/sound/oss/cs46xxpm.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*******************************************************************************
2*
3* "cs46xxpm.h" -- Cirrus Logic-Crystal CS46XX linux audio driver.
4*
5* Copyright (C) 2000,2001 Cirrus Logic Corp.
6* -- tom woller (twoller@crystal.cirrus.com) or
7* (pcaudio@crystal.cirrus.com).
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License
20* along with this program; if not, write to the Free Software
21* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*
23* 12/22/00 trw - new file.
24*
25*******************************************************************************/
26#ifndef __CS46XXPM_H
27#define __CS46XXPM_H
28
29#define CS46XX_AC97_HIGHESTREGTORESTORE 0x26
30#define CS46XX_AC97_NUMBER_RESTORE_REGS (CS46XX_AC97_HIGHESTREGTORESTORE/2-1)
31
32/* PM state defintions */
33#define CS46XX_PM_NOT_REGISTERED 0x1000
34#define CS46XX_PM_IDLE 0x0001
35#define CS46XX_PM_SUSPENDING 0x0002
36#define CS46XX_PM_SUSPENDED 0x0004
37#define CS46XX_PM_RESUMING 0x0008
38#define CS46XX_PM_RESUMED 0x0010
39
40#define CS_POWER_DAC 0x0001
41#define CS_POWER_ADC 0x0002
42#define CS_POWER_MIXVON 0x0004
43#define CS_POWER_MIXVOFF 0x0008
44#define CS_AC97_POWER_CONTROL_ON 0xf000 /* always on bits (inverted) */
45#define CS_AC97_POWER_CONTROL_ADC 0x0100
46#define CS_AC97_POWER_CONTROL_DAC 0x0200
47#define CS_AC97_POWER_CONTROL_MIXVON 0x0400
48#define CS_AC97_POWER_CONTROL_MIXVOFF 0x0800
49#define CS_AC97_POWER_CONTROL_ADC_ON 0x0001
50#define CS_AC97_POWER_CONTROL_DAC_ON 0x0002
51#define CS_AC97_POWER_CONTROL_MIXVON_ON 0x0004
52#define CS_AC97_POWER_CONTROL_MIXVOFF_ON 0x0008
53
54struct cs46xx_pm {
55 unsigned long flags;
56 u32 u32CLKCR1_SAVE,u32SSPMValue,u32PPLVCvalue,u32PPRVCvalue;
57 u32 u32FMLVCvalue,u32FMRVCvalue,u32GPIORvalue,u32JSCTLvalue,u32SSCR;
58 u32 u32SRCSA,u32DacASR,u32AdcASR,u32DacSR,u32AdcSR,u32MIDCR_Save;
59 u32 u32SSPM_BITS;
60 u32 ac97[CS46XX_AC97_NUMBER_RESTORE_REGS];
61 u32 u32AC97_master_volume, u32AC97_headphone_volume, u32AC97_master_volume_mono;
62 u32 u32AC97_pcm_out_volume, u32AC97_powerdown, u32AC97_general_purpose;
63 u32 u32hwptr_playback,u32hwptr_capture;
64 unsigned dmabuf_swptr_play;
65 int dmabuf_count_play;
66 unsigned dmabuf_swptr_capture;
67 int dmabuf_count_capture;
68};
69
70#endif
diff --git a/sound/oss/emu10k1/8010.h b/sound/oss/emu10k1/8010.h
deleted file mode 100644
index 61c6c42bbc3..00000000000
--- a/sound/oss/emu10k1/8010.h
+++ /dev/null
@@ -1,737 +0,0 @@
1/*
2 **********************************************************************
3 * 8010.h
4 * Copyright 1999-2001 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox Cleaned of 8bit chars, DOS
12 * line endings
13 * December 8, 1999 Jon Taylor Added lots of new register info
14 * May 16, 2001 Daniel Bertrand Added unofficial DBG register info
15 * Oct-Nov 2001 D.B. Added unofficial Audigy registers
16 *
17 **********************************************************************
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License as
21 * published by the Free Software Foundation; either version 2 of
22 * the License, or (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public
30 * License along with this program; if not, write to the Free
31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
32 * USA.
33 *
34 *
35 **********************************************************************
36 */
37
38
39#ifndef _8010_H
40#define _8010_H
41
42#include <linux/types.h>
43
44// Driver version:
45#define MAJOR_VER 0
46#define MINOR_VER 20
47#define DRIVER_VERSION "0.20a"
48
49
50// Audigy specify registers are prefixed with 'A_'
51
52/************************************************************************************************/
53/* PCI function 0 registers, address = <val> + PCIBASE0 */
54/************************************************************************************************/
55
56#define PTR 0x00 /* Indexed register set pointer register */
57 /* NOTE: The CHANNELNUM and ADDRESS words can */
58 /* be modified independently of each other. */
59#define PTR_CHANNELNUM_MASK 0x0000003f /* For each per-channel register, indicates the */
60 /* channel number of the register to be */
61 /* accessed. For non per-channel registers the */
62 /* value should be set to zero. */
63#define PTR_ADDRESS_MASK 0x07ff0000 /* Register index */
64
65#define DATA 0x04 /* Indexed register set data register */
66
67#define IPR 0x08 /* Global interrupt pending register */
68 /* Clear pending interrupts by writing a 1 to */
69 /* the relevant bits and zero to the other bits */
70
71/* The next two interrupts are for the midi port on the Audigy Drive (A_MPU1) */
72#define A_IPR_MIDITRANSBUFEMPTY2 0x10000000 /* MIDI UART transmit buffer empty */
73#define A_IPR_MIDIRECVBUFEMPTY2 0x08000000 /* MIDI UART receive buffer empty */
74
75#define IPR_SAMPLERATETRACKER 0x01000000 /* Sample rate tracker lock status change */
76#define IPR_FXDSP 0x00800000 /* Enable FX DSP interrupts */
77#define IPR_FORCEINT 0x00400000 /* Force Sound Blaster interrupt */
78#define IPR_PCIERROR 0x00200000 /* PCI bus error */
79#define IPR_VOLINCR 0x00100000 /* Volume increment button pressed */
80#define IPR_VOLDECR 0x00080000 /* Volume decrement button pressed */
81#define IPR_MUTE 0x00040000 /* Mute button pressed */
82#define IPR_MICBUFFULL 0x00020000 /* Microphone buffer full */
83#define IPR_MICBUFHALFFULL 0x00010000 /* Microphone buffer half full */
84#define IPR_ADCBUFFULL 0x00008000 /* ADC buffer full */
85#define IPR_ADCBUFHALFFULL 0x00004000 /* ADC buffer half full */
86#define IPR_EFXBUFFULL 0x00002000 /* Effects buffer full */
87#define IPR_EFXBUFHALFFULL 0x00001000 /* Effects buffer half full */
88#define IPR_GPSPDIFSTATUSCHANGE 0x00000800 /* GPSPDIF channel status change */
89#define IPR_CDROMSTATUSCHANGE 0x00000400 /* CD-ROM channel status change */
90#define IPR_INTERVALTIMER 0x00000200 /* Interval timer terminal count */
91#define IPR_MIDITRANSBUFEMPTY 0x00000100 /* MIDI UART transmit buffer empty */
92#define IPR_MIDIRECVBUFEMPTY 0x00000080 /* MIDI UART receive buffer empty */
93#define IPR_CHANNELLOOP 0x00000040 /* One or more channel loop interrupts pending */
94#define IPR_CHANNELNUMBERMASK 0x0000003f /* When IPR_CHANNELLOOP is set, indicates the */
95 /* Highest set channel in CLIPL or CLIPH. When */
96 /* IP is written with CL set, the bit in CLIPL */
97 /* or CLIPH corresponding to the CIN value */
98 /* written will be cleared. */
99#define A_IPR_MIDITRANSBUFEMPTY1 IPR_MIDITRANSBUFEMPTY /* MIDI UART transmit buffer empty */
100#define A_IPR_MIDIRECVBUFEMPTY1 IPR_MIDIRECVBUFEMPTY /* MIDI UART receive buffer empty */
101
102
103
104#define INTE 0x0c /* Interrupt enable register */
105#define INTE_VIRTUALSB_MASK 0xc0000000 /* Virtual Soundblaster I/O port capture */
106#define INTE_VIRTUALSB_220 0x00000000 /* Capture at I/O base address 0x220-0x22f */
107#define INTE_VIRTUALSB_240 0x40000000 /* Capture at I/O base address 0x240 */
108#define INTE_VIRTUALSB_260 0x80000000 /* Capture at I/O base address 0x260 */
109#define INTE_VIRTUALSB_280 0xc0000000 /* Capture at I/O base address 0x280 */
110#define INTE_VIRTUALMPU_MASK 0x30000000 /* Virtual MPU I/O port capture */
111#define INTE_VIRTUALMPU_300 0x00000000 /* Capture at I/O base address 0x300-0x301 */
112#define INTE_VIRTUALMPU_310 0x10000000 /* Capture at I/O base address 0x310 */
113#define INTE_VIRTUALMPU_320 0x20000000 /* Capture at I/O base address 0x320 */
114#define INTE_VIRTUALMPU_330 0x30000000 /* Capture at I/O base address 0x330 */
115#define INTE_MASTERDMAENABLE 0x08000000 /* Master DMA emulation at 0x000-0x00f */
116#define INTE_SLAVEDMAENABLE 0x04000000 /* Slave DMA emulation at 0x0c0-0x0df */
117#define INTE_MASTERPICENABLE 0x02000000 /* Master PIC emulation at 0x020-0x021 */
118#define INTE_SLAVEPICENABLE 0x01000000 /* Slave PIC emulation at 0x0a0-0x0a1 */
119#define INTE_VSBENABLE 0x00800000 /* Enable virtual Soundblaster */
120#define INTE_ADLIBENABLE 0x00400000 /* Enable AdLib emulation at 0x388-0x38b */
121#define INTE_MPUENABLE 0x00200000 /* Enable virtual MPU */
122#define INTE_FORCEINT 0x00100000 /* Continuously assert INTAN */
123
124#define INTE_MRHANDENABLE 0x00080000 /* Enable the "Mr. Hand" logic */
125 /* NOTE: There is no reason to use this under */
126 /* Linux, and it will cause odd hardware */
127 /* behavior and possibly random segfaults and */
128 /* lockups if enabled. */
129
130/* The next two interrupts are for the midi port on the Audigy Drive (A_MPU1) */
131#define A_INTE_MIDITXENABLE2 0x00020000 /* Enable MIDI transmit-buffer-empty interrupts */
132#define A_INTE_MIDIRXENABLE2 0x00010000 /* Enable MIDI receive-buffer-empty interrupts */
133
134
135#define INTE_SAMPLERATETRACKER 0x00002000 /* Enable sample rate tracker interrupts */
136 /* NOTE: This bit must always be enabled */
137#define INTE_FXDSPENABLE 0x00001000 /* Enable FX DSP interrupts */
138#define INTE_PCIERRORENABLE 0x00000800 /* Enable PCI bus error interrupts */
139#define INTE_VOLINCRENABLE 0x00000400 /* Enable volume increment button interrupts */
140#define INTE_VOLDECRENABLE 0x00000200 /* Enable volume decrement button interrupts */
141#define INTE_MUTEENABLE 0x00000100 /* Enable mute button interrupts */
142#define INTE_MICBUFENABLE 0x00000080 /* Enable microphone buffer interrupts */
143#define INTE_ADCBUFENABLE 0x00000040 /* Enable ADC buffer interrupts */
144#define INTE_EFXBUFENABLE 0x00000020 /* Enable Effects buffer interrupts */
145#define INTE_GPSPDIFENABLE 0x00000010 /* Enable GPSPDIF status interrupts */
146#define INTE_CDSPDIFENABLE 0x00000008 /* Enable CDSPDIF status interrupts */
147#define INTE_INTERVALTIMERENB 0x00000004 /* Enable interval timer interrupts */
148#define INTE_MIDITXENABLE 0x00000002 /* Enable MIDI transmit-buffer-empty interrupts */
149#define INTE_MIDIRXENABLE 0x00000001 /* Enable MIDI receive-buffer-empty interrupts */
150
151/* The next two interrupts are for the midi port on the Audigy (A_MPU2) */
152#define A_INTE_MIDITXENABLE1 INTE_MIDITXENABLE
153#define A_INTE_MIDIRXENABLE1 INTE_MIDIRXENABLE
154
155#define WC 0x10 /* Wall Clock register */
156#define WC_SAMPLECOUNTER_MASK 0x03FFFFC0 /* Sample periods elapsed since reset */
157#define WC_SAMPLECOUNTER 0x14060010
158#define WC_CURRENTCHANNEL 0x0000003F /* Channel [0..63] currently being serviced */
159 /* NOTE: Each channel takes 1/64th of a sample */
160 /* period to be serviced. */
161
162#define HCFG 0x14 /* Hardware config register */
163 /* NOTE: There is no reason to use the legacy */
164 /* SoundBlaster emulation stuff described below */
165 /* under Linux, and all kinds of weird hardware */
166 /* behavior can result if you try. Don't. */
167#define HCFG_LEGACYFUNC_MASK 0xe0000000 /* Legacy function number */
168#define HCFG_LEGACYFUNC_MPU 0x00000000 /* Legacy MPU */
169#define HCFG_LEGACYFUNC_SB 0x40000000 /* Legacy SB */
170#define HCFG_LEGACYFUNC_AD 0x60000000 /* Legacy AD */
171#define HCFG_LEGACYFUNC_MPIC 0x80000000 /* Legacy MPIC */
172#define HCFG_LEGACYFUNC_MDMA 0xa0000000 /* Legacy MDMA */
173#define HCFG_LEGACYFUNC_SPCI 0xc0000000 /* Legacy SPCI */
174#define HCFG_LEGACYFUNC_SDMA 0xe0000000 /* Legacy SDMA */
175#define HCFG_IOCAPTUREADDR 0x1f000000 /* The 4 LSBs of the captured I/O address. */
176#define HCFG_LEGACYWRITE 0x00800000 /* 1 = write, 0 = read */
177#define HCFG_LEGACYWORD 0x00400000 /* 1 = word, 0 = byte */
178#define HCFG_LEGACYINT 0x00200000 /* 1 = legacy event captured. Write 1 to clear. */
179 /* NOTE: The rest of the bits in this register */
180 /* _are_ relevant under Linux. */
181#define HCFG_CODECFORMAT_MASK 0x00070000 /* CODEC format */
182#define HCFG_CODECFORMAT_AC97 0x00000000 /* AC97 CODEC format -- Primary Output */
183#define HCFG_CODECFORMAT_I2S 0x00010000 /* I2S CODEC format -- Secondary (Rear) Output */
184#define HCFG_GPINPUT0 0x00004000 /* External pin112 */
185#define HCFG_GPINPUT1 0x00002000 /* External pin110 */
186
187#define HCFG_GPOUTPUT_MASK 0x00001c00 /* External pins which may be controlled */
188#define HCFG_GPOUT0 0x00001000 /* set to enable digital out on 5.1 cards */
189
190#define HCFG_JOYENABLE 0x00000200 /* Internal joystick enable */
191#define HCFG_PHASETRACKENABLE 0x00000100 /* Phase tracking enable */
192 /* 1 = Force all 3 async digital inputs to use */
193 /* the same async sample rate tracker (ZVIDEO) */
194#define HCFG_AC3ENABLE_MASK 0x0x0000e0 /* AC3 async input control - Not implemented */
195#define HCFG_AC3ENABLE_ZVIDEO 0x00000080 /* Channels 0 and 1 replace ZVIDEO */
196#define HCFG_AC3ENABLE_CDSPDIF 0x00000040 /* Channels 0 and 1 replace CDSPDIF */
197#define HCFG_AC3ENABLE_GPSPDIF 0x00000020 /* Channels 0 and 1 replace GPSPDIF */
198#define HCFG_AUTOMUTE 0x00000010 /* When set, the async sample rate convertors */
199 /* will automatically mute their output when */
200 /* they are not rate-locked to the external */
201 /* async audio source */
202#define HCFG_LOCKSOUNDCACHE 0x00000008 /* 1 = Cancel bustmaster accesses to soundcache */
203 /* NOTE: This should generally never be used. */
204#define HCFG_LOCKTANKCACHE_MASK 0x00000004 /* 1 = Cancel bustmaster accesses to tankcache */
205 /* NOTE: This should generally never be used. */
206#define HCFG_LOCKTANKCACHE 0x01020014
207#define HCFG_MUTEBUTTONENABLE 0x00000002 /* 1 = Master mute button sets AUDIOENABLE = 0. */
208 /* NOTE: This is a 'cheap' way to implement a */
209 /* master mute function on the mute button, and */
210 /* in general should not be used unless a more */
211 /* sophisticated master mute function has not */
212 /* been written. */
213#define HCFG_AUDIOENABLE 0x00000001 /* 0 = CODECs transmit zero-valued samples */
214 /* Should be set to 1 when the EMU10K1 is */
215 /* completely initialized. */
216
217//For Audigy, MPU port move to 0x70-0x74 ptr register
218
219#define MUDATA 0x18 /* MPU401 data register (8 bits) */
220
221#define MUCMD 0x19 /* MPU401 command register (8 bits) */
222#define MUCMD_RESET 0xff /* RESET command */
223#define MUCMD_ENTERUARTMODE 0x3f /* Enter_UART_mode command */
224 /* NOTE: All other commands are ignored */
225
226#define MUSTAT MUCMD /* MPU401 status register (8 bits) */
227#define MUSTAT_IRDYN 0x80 /* 0 = MIDI data or command ACK */
228#define MUSTAT_ORDYN 0x40 /* 0 = MUDATA can accept a command or data */
229
230#define A_IOCFG 0x18 /* GPIO on Audigy card (16bits) */
231#define A_GPINPUT_MASK 0xff00
232#define A_GPOUTPUT_MASK 0x00ff
233
234#define TIMER 0x1a /* Timer terminal count register (16-bit) */
235 /* NOTE: After the rate is changed, a maximum */
236 /* of 1024 sample periods should be allowed */
237 /* before the new rate is guaranteed accurate. */
238#define TIMER_RATE_MASK 0x03ff /* Timer interrupt rate in sample periods */
239 /* 0 == 1024 periods, [1..4] are not useful */
240
241#define AC97DATA 0x1c /* AC97 register set data register (16 bit) */
242
243#define AC97ADDRESS 0x1e /* AC97 register set address register (8 bit) */
244#define AC97ADDRESS_READY 0x80 /* Read-only bit, reflects CODEC READY signal */
245#define AC97ADDRESS_ADDRESS 0x7f /* Address of indexed AC97 register */
246
247/********************************************************************************************************/
248/* Emu10k1 pointer-offset register set, accessed through the PTR and DATA registers */
249/********************************************************************************************************/
250
251#define CPF 0x00 /* Current pitch and fraction register */
252#define CPF_CURRENTPITCH_MASK 0xffff0000 /* Current pitch (linear, 0x4000 == unity pitch shift) */
253#define CPF_CURRENTPITCH 0x10100000
254#define CPF_STEREO_MASK 0x00008000 /* 1 = Even channel interleave, odd channel locked */
255#define CPF_STOP_MASK 0x00004000 /* 1 = Current pitch forced to 0 */
256#define CPF_FRACADDRESS_MASK 0x00003fff /* Linear fractional address of the current channel */
257
258#define PTRX 0x01 /* Pitch target and send A/B amounts register */
259#define PTRX_PITCHTARGET_MASK 0xffff0000 /* Pitch target of specified channel */
260#define PTRX_PITCHTARGET 0x10100001
261#define PTRX_FXSENDAMOUNT_A_MASK 0x0000ff00 /* Linear level of channel output sent to FX send bus A */
262#define PTRX_FXSENDAMOUNT_A 0x08080001
263#define PTRX_FXSENDAMOUNT_B_MASK 0x000000ff /* Linear level of channel output sent to FX send bus B */
264#define PTRX_FXSENDAMOUNT_B 0x08000001
265
266#define CVCF 0x02 /* Current volume and filter cutoff register */
267#define CVCF_CURRENTVOL_MASK 0xffff0000 /* Current linear volume of specified channel */
268#define CVCF_CURRENTVOL 0x10100002
269#define CVCF_CURRENTFILTER_MASK 0x0000ffff /* Current filter cutoff frequency of specified channel */
270#define CVCF_CURRENTFILTER 0x10000002
271
272#define VTFT 0x03 /* Volume target and filter cutoff target register */
273#define VTFT_VOLUMETARGET_MASK 0xffff0000 /* Volume target of specified channel */
274#define VTFT_FILTERTARGET_MASK 0x0000ffff /* Filter cutoff target of specified channel */
275
276#define Z1 0x05 /* Filter delay memory 1 register */
277
278#define Z2 0x04 /* Filter delay memory 2 register */
279
280#define PSST 0x06 /* Send C amount and loop start address register */
281#define PSST_FXSENDAMOUNT_C_MASK 0xff000000 /* Linear level of channel output sent to FX send bus C */
282
283#define PSST_FXSENDAMOUNT_C 0x08180006
284
285#define PSST_LOOPSTARTADDR_MASK 0x00ffffff /* Loop start address of the specified channel */
286#define PSST_LOOPSTARTADDR 0x18000006
287
288#define DSL 0x07 /* Send D amount and loop start address register */
289#define DSL_FXSENDAMOUNT_D_MASK 0xff000000 /* Linear level of channel output sent to FX send bus D */
290
291#define DSL_FXSENDAMOUNT_D 0x08180007
292
293#define DSL_LOOPENDADDR_MASK 0x00ffffff /* Loop end address of the specified channel */
294#define DSL_LOOPENDADDR 0x18000007
295
296#define CCCA 0x08 /* Filter Q, interp. ROM, byte size, cur. addr register */
297#define CCCA_RESONANCE 0xf0000000 /* Lowpass filter resonance (Q) height */
298#define CCCA_INTERPROMMASK 0x0e000000 /* Selects passband of interpolation ROM */
299 /* 1 == full band, 7 == lowpass */
300 /* ROM 0 is used when pitch shifting downward or less */
301 /* then 3 semitones upward. Increasingly higher ROM */
302 /* numbers are used, typically in steps of 3 semitones, */
303 /* as upward pitch shifting is performed. */
304#define CCCA_INTERPROM_0 0x00000000 /* Select interpolation ROM 0 */
305#define CCCA_INTERPROM_1 0x02000000 /* Select interpolation ROM 1 */
306#define CCCA_INTERPROM_2 0x04000000 /* Select interpolation ROM 2 */
307#define CCCA_INTERPROM_3 0x06000000 /* Select interpolation ROM 3 */
308#define CCCA_INTERPROM_4 0x08000000 /* Select interpolation ROM 4 */
309#define CCCA_INTERPROM_5 0x0a000000 /* Select interpolation ROM 5 */
310#define CCCA_INTERPROM_6 0x0c000000 /* Select interpolation ROM 6 */
311#define CCCA_INTERPROM_7 0x0e000000 /* Select interpolation ROM 7 */
312#define CCCA_8BITSELECT 0x01000000 /* 1 = Sound memory for this channel uses 8-bit samples */
313#define CCCA_CURRADDR_MASK 0x00ffffff /* Current address of the selected channel */
314#define CCCA_CURRADDR 0x18000008
315
316#define CCR 0x09 /* Cache control register */
317#define CCR_CACHEINVALIDSIZE 0x07190009
318#define CCR_CACHEINVALIDSIZE_MASK 0xfe000000 /* Number of invalid samples cache for this channel */
319#define CCR_CACHELOOPFLAG 0x01000000 /* 1 = Cache has a loop service pending */
320#define CCR_INTERLEAVEDSAMPLES 0x00800000 /* 1 = A cache service will fetch interleaved samples */
321#define CCR_WORDSIZEDSAMPLES 0x00400000 /* 1 = A cache service will fetch word sized samples */
322#define CCR_READADDRESS 0x06100009
323#define CCR_READADDRESS_MASK 0x003f0000 /* Location of cache just beyond current cache service */
324#define CCR_LOOPINVALSIZE 0x0000fe00 /* Number of invalid samples in cache prior to loop */
325 /* NOTE: This is valid only if CACHELOOPFLAG is set */
326#define CCR_LOOPFLAG 0x00000100 /* Set for a single sample period when a loop occurs */
327#define CCR_CACHELOOPADDRHI 0x000000ff /* DSL_LOOPSTARTADDR's hi byte if CACHELOOPFLAG is set */
328
329#define CLP 0x0a /* Cache loop register (valid if CCR_CACHELOOPFLAG = 1) */
330 /* NOTE: This register is normally not used */
331#define CLP_CACHELOOPADDR 0x0000ffff /* Cache loop address (DSL_LOOPSTARTADDR [0..15]) */
332
333#define FXRT 0x0b /* Effects send routing register */
334 /* NOTE: It is illegal to assign the same routing to */
335 /* two effects sends. */
336#define FXRT_CHANNELA 0x000f0000 /* Effects send bus number for channel's effects send A */
337#define FXRT_CHANNELB 0x00f00000 /* Effects send bus number for channel's effects send B */
338#define FXRT_CHANNELC 0x0f000000 /* Effects send bus number for channel's effects send C */
339#define FXRT_CHANNELD 0xf0000000 /* Effects send bus number for channel's effects send D */
340
341#define MAPA 0x0c /* Cache map A */
342
343#define MAPB 0x0d /* Cache map B */
344
345#define MAP_PTE_MASK 0xffffe000 /* The 19 MSBs of the PTE indexed by the PTI */
346#define MAP_PTI_MASK 0x00001fff /* The 13 bit index to one of the 8192 PTE dwords */
347
348#define ENVVOL 0x10 /* Volume envelope register */
349#define ENVVOL_MASK 0x0000ffff /* Current value of volume envelope state variable */
350 /* 0x8000-n == 666*n usec delay */
351
352#define ATKHLDV 0x11 /* Volume envelope hold and attack register */
353#define ATKHLDV_PHASE0 0x00008000 /* 0 = Begin attack phase */
354#define ATKHLDV_HOLDTIME_MASK 0x00007f00 /* Envelope hold time (127-n == n*88.2msec) */
355#define ATKHLDV_ATTACKTIME_MASK 0x0000007f /* Envelope attack time, log encoded */
356 /* 0 = infinite, 1 = 10.9msec, ... 0x7f = 5.5msec */
357
358#define DCYSUSV 0x12 /* Volume envelope sustain and decay register */
359#define DCYSUSV_PHASE1_MASK 0x00008000 /* 0 = Begin attack phase, 1 = begin release phase */
360#define DCYSUSV_SUSTAINLEVEL_MASK 0x00007f00 /* 127 = full, 0 = off, 0.75dB increments */
361#define DCYSUSV_CHANNELENABLE_MASK 0x00000080 /* 1 = Inhibit envelope engine from writing values in */
362 /* this channel and from writing to pitch, filter and */
363 /* volume targets. */
364#define DCYSUSV_DECAYTIME_MASK 0x0000007f /* Volume envelope decay time, log encoded */
365 /* 0 = 43.7msec, 1 = 21.8msec, 0x7f = 22msec */
366
367#define LFOVAL1 0x13 /* Modulation LFO value */
368#define LFOVAL_MASK 0x0000ffff /* Current value of modulation LFO state variable */
369 /* 0x8000-n == 666*n usec delay */
370
371#define ENVVAL 0x14 /* Modulation envelope register */
372#define ENVVAL_MASK 0x0000ffff /* Current value of modulation envelope state variable */
373 /* 0x8000-n == 666*n usec delay */
374
375#define ATKHLDM 0x15 /* Modulation envelope hold and attack register */
376#define ATKHLDM_PHASE0 0x00008000 /* 0 = Begin attack phase */
377#define ATKHLDM_HOLDTIME 0x00007f00 /* Envelope hold time (127-n == n*42msec) */
378#define ATKHLDM_ATTACKTIME 0x0000007f /* Envelope attack time, log encoded */
379 /* 0 = infinite, 1 = 11msec, ... 0x7f = 5.5msec */
380
381#define DCYSUSM 0x16 /* Modulation envelope decay and sustain register */
382#define DCYSUSM_PHASE1_MASK 0x00008000 /* 0 = Begin attack phase, 1 = begin release phase */
383#define DCYSUSM_SUSTAINLEVEL_MASK 0x00007f00 /* 127 = full, 0 = off, 0.75dB increments */
384#define DCYSUSM_DECAYTIME_MASK 0x0000007f /* Envelope decay time, log encoded */
385 /* 0 = 43.7msec, 1 = 21.8msec, 0x7f = 22msec */
386
387#define LFOVAL2 0x17 /* Vibrato LFO register */
388#define LFOVAL2_MASK 0x0000ffff /* Current value of vibrato LFO state variable */
389 /* 0x8000-n == 666*n usec delay */
390
391#define IP 0x18 /* Initial pitch register */
392#define IP_MASK 0x0000ffff /* Exponential initial pitch shift */
393 /* 4 bits of octave, 12 bits of fractional octave */
394#define IP_UNITY 0x0000e000 /* Unity pitch shift */
395
396#define IFATN 0x19 /* Initial filter cutoff and attenuation register */
397#define IFATN_FILTERCUTOFF_MASK 0x0000ff00 /* Initial filter cutoff frequency in exponential units */
398 /* 6 most significant bits are semitones */
399 /* 2 least significant bits are fractions */
400#define IFATN_FILTERCUTOFF 0x08080019
401#define IFATN_ATTENUATION_MASK 0x000000ff /* Initial attenuation in 0.375dB steps */
402#define IFATN_ATTENUATION 0x08000019
403
404
405#define PEFE 0x1a /* Pitch envelope and filter envelope amount register */
406#define PEFE_PITCHAMOUNT_MASK 0x0000ff00 /* Pitch envlope amount */
407 /* Signed 2's complement, +/- one octave peak extremes */
408#define PEFE_PITCHAMOUNT 0x0808001a
409#define PEFE_FILTERAMOUNT_MASK 0x000000ff /* Filter envlope amount */
410 /* Signed 2's complement, +/- six octaves peak extremes */
411#define PEFE_FILTERAMOUNT 0x0800001a
412#define FMMOD 0x1b /* Vibrato/filter modulation from LFO register */
413#define FMMOD_MODVIBRATO 0x0000ff00 /* Vibrato LFO modulation depth */
414 /* Signed 2's complement, +/- one octave extremes */
415#define FMMOD_MOFILTER 0x000000ff /* Filter LFO modulation depth */
416 /* Signed 2's complement, +/- three octave extremes */
417
418
419#define TREMFRQ 0x1c /* Tremolo amount and modulation LFO frequency register */
420#define TREMFRQ_DEPTH 0x0000ff00 /* Tremolo depth */
421 /* Signed 2's complement, with +/- 12dB extremes */
422#define TREMFRQ_FREQUENCY 0x000000ff /* Tremolo LFO frequency */
423 /* ??Hz steps, maximum of ?? Hz. */
424
425#define FM2FRQ2 0x1d /* Vibrato amount and vibrato LFO frequency register */
426#define FM2FRQ2_DEPTH 0x0000ff00 /* Vibrato LFO vibrato depth */
427 /* Signed 2's complement, +/- one octave extremes */
428#define FM2FRQ2_FREQUENCY 0x000000ff /* Vibrato LFO frequency */
429 /* 0.039Hz steps, maximum of 9.85 Hz. */
430
431#define TEMPENV 0x1e /* Tempory envelope register */
432#define TEMPENV_MASK 0x0000ffff /* 16-bit value */
433 /* NOTE: All channels contain internal variables; do */
434 /* not write to these locations. */
435
436#define CD0 0x20 /* Cache data 0 register */
437#define CD1 0x21 /* Cache data 1 register */
438#define CD2 0x22 /* Cache data 2 register */
439#define CD3 0x23 /* Cache data 3 register */
440#define CD4 0x24 /* Cache data 4 register */
441#define CD5 0x25 /* Cache data 5 register */
442#define CD6 0x26 /* Cache data 6 register */
443#define CD7 0x27 /* Cache data 7 register */
444#define CD8 0x28 /* Cache data 8 register */
445#define CD9 0x29 /* Cache data 9 register */
446#define CDA 0x2a /* Cache data A register */
447#define CDB 0x2b /* Cache data B register */
448#define CDC 0x2c /* Cache data C register */
449#define CDD 0x2d /* Cache data D register */
450#define CDE 0x2e /* Cache data E register */
451#define CDF 0x2f /* Cache data F register */
452
453#define PTB 0x40 /* Page table base register */
454#define PTB_MASK 0xfffff000 /* Physical address of the page table in host memory */
455
456#define TCB 0x41 /* Tank cache base register */
457#define TCB_MASK 0xfffff000 /* Physical address of the bottom of host based TRAM */
458
459#define ADCCR 0x42 /* ADC sample rate/stereo control register */
460#define ADCCR_RCHANENABLE 0x00000010 /* Enables right channel for writing to the host */
461#define ADCCR_LCHANENABLE 0x00000008 /* Enables left channel for writing to the host */
462 /* NOTE: To guarantee phase coherency, both channels */
463 /* must be disabled prior to enabling both channels. */
464#define A_ADCCR_RCHANENABLE 0x00000020
465#define A_ADCCR_LCHANENABLE 0x00000010
466
467#define A_ADCCR_SAMPLERATE_MASK 0x0000000F /* Audigy sample rate convertor output rate */
468#define ADCCR_SAMPLERATE_MASK 0x00000007 /* Sample rate convertor output rate */
469
470#define ADCCR_SAMPLERATE_48 0x00000000 /* 48kHz sample rate */
471#define ADCCR_SAMPLERATE_44 0x00000001 /* 44.1kHz sample rate */
472#define ADCCR_SAMPLERATE_32 0x00000002 /* 32kHz sample rate */
473#define ADCCR_SAMPLERATE_24 0x00000003 /* 24kHz sample rate */
474#define ADCCR_SAMPLERATE_22 0x00000004 /* 22.05kHz sample rate */
475#define ADCCR_SAMPLERATE_16 0x00000005 /* 16kHz sample rate */
476#define ADCCR_SAMPLERATE_11 0x00000006 /* 11.025kHz sample rate */
477#define ADCCR_SAMPLERATE_8 0x00000007 /* 8kHz sample rate */
478
479#define A_ADCCR_SAMPLERATE_12 0x00000006 /* 12kHz sample rate */
480#define A_ADCCR_SAMPLERATE_11 0x00000007 /* 11.025kHz sample rate */
481#define A_ADCCR_SAMPLERATE_8 0x00000008 /* 8kHz sample rate */
482
483#define FXWC 0x43 /* FX output write channels register */
484 /* When set, each bit enables the writing of the */
485 /* corresponding FX output channel (internal registers */
486 /* 0x20-0x3f) into host memory. This mode of recording */
487 /* is 16bit, 48KHz only. All 32 channels can be enabled */
488 /* simultaneously. */
489#define TCBS 0x44 /* Tank cache buffer size register */
490#define TCBS_MASK 0x00000007 /* Tank cache buffer size field */
491#define TCBS_BUFFSIZE_16K 0x00000000
492#define TCBS_BUFFSIZE_32K 0x00000001
493#define TCBS_BUFFSIZE_64K 0x00000002
494#define TCBS_BUFFSIZE_128K 0x00000003
495#define TCBS_BUFFSIZE_256K 0x00000004
496#define TCBS_BUFFSIZE_512K 0x00000005
497#define TCBS_BUFFSIZE_1024K 0x00000006
498#define TCBS_BUFFSIZE_2048K 0x00000007
499
500#define MICBA 0x45 /* AC97 microphone buffer address register */
501#define MICBA_MASK 0xfffff000 /* 20 bit base address */
502
503#define ADCBA 0x46 /* ADC buffer address register */
504#define ADCBA_MASK 0xfffff000 /* 20 bit base address */
505
506#define FXBA 0x47 /* FX Buffer Address */
507#define FXBA_MASK 0xfffff000 /* 20 bit base address */
508
509#define MICBS 0x49 /* Microphone buffer size register */
510
511#define ADCBS 0x4a /* ADC buffer size register */
512
513#define FXBS 0x4b /* FX buffer size register */
514
515/* The following mask values define the size of the ADC, MIX and FX buffers in bytes */
516#define ADCBS_BUFSIZE_NONE 0x00000000
517#define ADCBS_BUFSIZE_384 0x00000001
518#define ADCBS_BUFSIZE_448 0x00000002
519#define ADCBS_BUFSIZE_512 0x00000003
520#define ADCBS_BUFSIZE_640 0x00000004
521#define ADCBS_BUFSIZE_768 0x00000005
522#define ADCBS_BUFSIZE_896 0x00000006
523#define ADCBS_BUFSIZE_1024 0x00000007
524#define ADCBS_BUFSIZE_1280 0x00000008
525#define ADCBS_BUFSIZE_1536 0x00000009
526#define ADCBS_BUFSIZE_1792 0x0000000a
527#define ADCBS_BUFSIZE_2048 0x0000000b
528#define ADCBS_BUFSIZE_2560 0x0000000c
529#define ADCBS_BUFSIZE_3072 0x0000000d
530#define ADCBS_BUFSIZE_3584 0x0000000e
531#define ADCBS_BUFSIZE_4096 0x0000000f
532#define ADCBS_BUFSIZE_5120 0x00000010
533#define ADCBS_BUFSIZE_6144 0x00000011
534#define ADCBS_BUFSIZE_7168 0x00000012
535#define ADCBS_BUFSIZE_8192 0x00000013
536#define ADCBS_BUFSIZE_10240 0x00000014
537#define ADCBS_BUFSIZE_12288 0x00000015
538#define ADCBS_BUFSIZE_14366 0x00000016
539#define ADCBS_BUFSIZE_16384 0x00000017
540#define ADCBS_BUFSIZE_20480 0x00000018
541#define ADCBS_BUFSIZE_24576 0x00000019
542#define ADCBS_BUFSIZE_28672 0x0000001a
543#define ADCBS_BUFSIZE_32768 0x0000001b
544#define ADCBS_BUFSIZE_40960 0x0000001c
545#define ADCBS_BUFSIZE_49152 0x0000001d
546#define ADCBS_BUFSIZE_57344 0x0000001e
547#define ADCBS_BUFSIZE_65536 0x0000001f
548
549
550#define CDCS 0x50 /* CD-ROM digital channel status register */
551
552#define GPSCS 0x51 /* General Purpose SPDIF channel status register*/
553
554#define DBG 0x52 /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */
555
556/* definitions for debug register - taken from the alsa drivers */
557#define DBG_ZC 0x80000000 /* zero tram counter */
558#define DBG_SATURATION_OCCURED 0x02000000 /* saturation control */
559#define DBG_SATURATION_ADDR 0x01ff0000 /* saturation address */
560#define DBG_SINGLE_STEP 0x00008000 /* single step mode */
561#define DBG_STEP 0x00004000 /* start single step */
562#define DBG_CONDITION_CODE 0x00003e00 /* condition code */
563#define DBG_SINGLE_STEP_ADDR 0x000001ff /* single step address */
564
565
566#define REG53 0x53 /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */
567
568#define A_DBG 0x53
569#define A_DBG_SINGLE_STEP 0x00020000 /* Set to zero to start dsp */
570#define A_DBG_ZC 0x40000000 /* zero tram counter */
571#define A_DBG_STEP_ADDR 0x000003ff
572#define A_DBG_SATURATION_OCCURED 0x20000000
573#define A_DBG_SATURATION_ADDR 0x0ffc0000
574
575#define SPCS0 0x54 /* SPDIF output Channel Status 0 register */
576
577#define SPCS1 0x55 /* SPDIF output Channel Status 1 register */
578
579#define SPCS2 0x56 /* SPDIF output Channel Status 2 register */
580
581#define SPCS_CLKACCYMASK 0x30000000 /* Clock accuracy */
582#define SPCS_CLKACCY_1000PPM 0x00000000 /* 1000 parts per million */
583#define SPCS_CLKACCY_50PPM 0x10000000 /* 50 parts per million */
584#define SPCS_CLKACCY_VARIABLE 0x20000000 /* Variable accuracy */
585#define SPCS_SAMPLERATEMASK 0x0f000000 /* Sample rate */
586#define SPCS_SAMPLERATE_44 0x00000000 /* 44.1kHz sample rate */
587#define SPCS_SAMPLERATE_48 0x02000000 /* 48kHz sample rate */
588#define SPCS_SAMPLERATE_32 0x03000000 /* 32kHz sample rate */
589#define SPCS_CHANNELNUMMASK 0x00f00000 /* Channel number */
590#define SPCS_CHANNELNUM_UNSPEC 0x00000000 /* Unspecified channel number */
591#define SPCS_CHANNELNUM_LEFT 0x00100000 /* Left channel */
592#define SPCS_CHANNELNUM_RIGHT 0x00200000 /* Right channel */
593#define SPCS_SOURCENUMMASK 0x000f0000 /* Source number */
594#define SPCS_SOURCENUM_UNSPEC 0x00000000 /* Unspecified source number */
595#define SPCS_GENERATIONSTATUS 0x00008000 /* Originality flag (see IEC-958 spec) */
596#define SPCS_CATEGORYCODEMASK 0x00007f00 /* Category code (see IEC-958 spec) */
597#define SPCS_MODEMASK 0x000000c0 /* Mode (see IEC-958 spec) */
598#define SPCS_EMPHASISMASK 0x00000038 /* Emphasis */
599#define SPCS_EMPHASIS_NONE 0x00000000 /* No emphasis */
600#define SPCS_EMPHASIS_50_15 0x00000008 /* 50/15 usec 2 channel */
601#define SPCS_COPYRIGHT 0x00000004 /* Copyright asserted flag -- do not modify */
602#define SPCS_NOTAUDIODATA 0x00000002 /* 0 = Digital audio, 1 = not audio */
603#define SPCS_PROFESSIONAL 0x00000001 /* 0 = Consumer (IEC-958), 1 = pro (AES3-1992) */
604
605/* The 32-bit CLIx and SOLx registers all have one bit per channel control/status */
606#define CLIEL 0x58 /* Channel loop interrupt enable low register */
607
608#define CLIEH 0x59 /* Channel loop interrupt enable high register */
609
610#define CLIPL 0x5a /* Channel loop interrupt pending low register */
611
612#define CLIPH 0x5b /* Channel loop interrupt pending high register */
613
614#define SOLEL 0x5c /* Stop on loop enable low register */
615
616#define SOLEH 0x5d /* Stop on loop enable high register */
617
618#define SPBYPASS 0x5e /* SPDIF BYPASS mode register */
619#define SPBYPASS_ENABLE 0x00000001 /* Enable SPDIF bypass mode */
620
621#define AC97SLOT 0x5f /* additional AC97 slots enable bits */
622#define AC97SLOT_CNTR 0x10 /* Center enable */
623#define AC97SLOT_LFE 0x20 /* LFE enable */
624
625#define CDSRCS 0x60 /* CD-ROM Sample Rate Converter status register */
626
627#define GPSRCS 0x61 /* General Purpose SPDIF sample rate cvt status */
628
629#define ZVSRCS 0x62 /* ZVideo sample rate converter status */
630 /* NOTE: This one has no SPDIFLOCKED field */
631 /* Assumes sample lock */
632
633/* These three bitfields apply to CDSRCS, GPSRCS, and (except as noted) ZVSRCS. */
634#define SRCS_SPDIFLOCKED 0x02000000 /* SPDIF stream locked */
635#define SRCS_RATELOCKED 0x01000000 /* Sample rate locked */
636#define SRCS_ESTSAMPLERATE 0x0007ffff /* Do not modify this field. */
637
638
639/* Note that these values can vary +/- by a small amount */
640#define SRCS_SPDIFRATE_44 0x0003acd9
641#define SRCS_SPDIFRATE_48 0x00040000
642#define SRCS_SPDIFRATE_96 0x00080000
643
644#define MICIDX 0x63 /* Microphone recording buffer index register */
645#define MICIDX_MASK 0x0000ffff /* 16-bit value */
646#define MICIDX_IDX 0x10000063
647
648#define A_ADCIDX 0x63
649#define A_ADCIDX_IDX 0x10000063
650
651#define ADCIDX 0x64 /* ADC recording buffer index register */
652#define ADCIDX_MASK 0x0000ffff /* 16 bit index field */
653#define ADCIDX_IDX 0x10000064
654
655#define FXIDX 0x65 /* FX recording buffer index register */
656#define FXIDX_MASK 0x0000ffff /* 16-bit value */
657#define FXIDX_IDX 0x10000065
658
659/* This is the MPU port on the card (via the game port) */
660#define A_MUDATA1 0x70
661#define A_MUCMD1 0x71
662#define A_MUSTAT1 A_MUCMD1
663
664/* This is the MPU port on the Audigy Drive */
665#define A_MUDATA2 0x72
666#define A_MUCMD2 0x73
667#define A_MUSTAT2 A_MUCMD2
668
669/* The next two are the Audigy equivalent of FXWC */
670/* the Audigy can record any output (16bit, 48kHz, up to 64 channel simultaneously) */
671/* Each bit selects a channel for recording */
672#define A_FXWC1 0x74 /* Selects 0x7f-0x60 for FX recording */
673#define A_FXWC2 0x75 /* Selects 0x9f-0x80 for FX recording */
674
675#define A_SPDIF_SAMPLERATE 0x76 /* Set the sample rate of SPDIF output */
676#define A_SPDIF_48000 0x00000080
677#define A_SPDIF_44100 0x00000000
678#define A_SPDIF_96000 0x00000040
679
680#define A_FXRT2 0x7c
681#define A_FXRT_CHANNELE 0x0000003f /* Effects send bus number for channel's effects send E */
682#define A_FXRT_CHANNELF 0x00003f00 /* Effects send bus number for channel's effects send F */
683#define A_FXRT_CHANNELG 0x003f0000 /* Effects send bus number for channel's effects send G */
684#define A_FXRT_CHANNELH 0x3f000000 /* Effects send bus number for channel's effects send H */
685
686#define A_SENDAMOUNTS 0x7d
687#define A_FXSENDAMOUNT_E_MASK 0xff000000
688#define A_FXSENDAMOUNT_F_MASK 0x00ff0000
689#define A_FXSENDAMOUNT_G_MASK 0x0000ff00
690#define A_FXSENDAMOUNT_H_MASK 0x000000ff
691
692/* The send amounts for this one are the same as used with the emu10k1 */
693#define A_FXRT1 0x7e
694#define A_FXRT_CHANNELA 0x0000003f
695#define A_FXRT_CHANNELB 0x00003f00
696#define A_FXRT_CHANNELC 0x003f0000
697#define A_FXRT_CHANNELD 0x3f000000
698
699
700/* Each FX general purpose register is 32 bits in length, all bits are used */
701#define FXGPREGBASE 0x100 /* FX general purpose registers base */
702#define A_FXGPREGBASE 0x400 /* Audigy GPRs, 0x400 to 0x5ff */
703/* Tank audio data is logarithmically compressed down to 16 bits before writing to TRAM and is */
704/* decompressed back to 20 bits on a read. There are a total of 160 locations, the last 32 */
705/* locations are for external TRAM. */
706#define TANKMEMDATAREGBASE 0x200 /* Tank memory data registers base */
707#define TANKMEMDATAREG_MASK 0x000fffff /* 20 bit tank audio data field */
708
709/* Combined address field and memory opcode or flag field. 160 locations, last 32 are external */
710#define TANKMEMADDRREGBASE 0x300 /* Tank memory address registers base */
711#define TANKMEMADDRREG_ADDR_MASK 0x000fffff /* 20 bit tank address field */
712#define TANKMEMADDRREG_CLEAR 0x00800000 /* Clear tank memory */
713#define TANKMEMADDRREG_ALIGN 0x00400000 /* Align read or write relative to tank access */
714#define TANKMEMADDRREG_WRITE 0x00200000 /* Write to tank memory */
715#define TANKMEMADDRREG_READ 0x00100000 /* Read from tank memory */
716
717#define MICROCODEBASE 0x400 /* Microcode data base address */
718
719/* Each DSP microcode instruction is mapped into 2 doublewords */
720/* NOTE: When writing, always write the LO doubleword first. Reads can be in either order. */
721#define LOWORD_OPX_MASK 0x000ffc00 /* Instruction operand X */
722#define LOWORD_OPY_MASK 0x000003ff /* Instruction operand Y */
723#define HIWORD_OPCODE_MASK 0x00f00000 /* Instruction opcode */
724#define HIWORD_RESULT_MASK 0x000ffc00 /* Instruction result */
725#define HIWORD_OPA_MASK 0x000003ff /* Instruction operand A */
726
727
728/* Audigy Soundcard have a different instruction format */
729#define AUDIGY_CODEBASE 0x600
730#define A_LOWORD_OPY_MASK 0x000007ff
731#define A_LOWORD_OPX_MASK 0x007ff000
732#define A_HIWORD_OPCODE_MASK 0x0f000000
733#define A_HIWORD_RESULT_MASK 0x007ff000
734#define A_HIWORD_OPA_MASK 0x000007ff
735
736
737#endif /* _8010_H */
diff --git a/sound/oss/emu10k1/Makefile b/sound/oss/emu10k1/Makefile
deleted file mode 100644
index b3af9ccb057..00000000000
--- a/sound/oss/emu10k1/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
1# Makefile for Creative Labs EMU10K1
2#
3# 12 Apr 2000 Rui Sousa
4
5obj-$(CONFIG_SOUND_EMU10K1) += emu10k1.o
6
7emu10k1-objs := audio.o cardmi.o cardmo.o cardwi.o cardwo.o ecard.o \
8 efxmgr.o emuadxmg.o hwaccess.o irqmgr.o main.o midi.o \
9 mixer.o passthrough.o recmgr.o timer.o voicemgr.o
10
11ifdef DEBUG
12 EXTRA_CFLAGS += -DEMU10K1_DEBUG
13endif
14
15ifdef CONFIG_MIDI_EMU10K1
16 EXTRA_CFLAGS += -DEMU10K1_SEQUENCER
17endif
diff --git a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
deleted file mode 100644
index e75ea21eb81..00000000000
--- a/sound/oss/emu10k1/audio.c
+++ /dev/null
@@ -1,1595 +0,0 @@
1/*
2 **********************************************************************
3 * audio.c -- /dev/dsp interface for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up types/leaks
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include <linux/module.h>
34#include <linux/poll.h>
35#include <linux/slab.h>
36#include <linux/bitops.h>
37#include <asm/io.h>
38#include <linux/sched.h>
39#include <linux/mm.h>
40#include <linux/smp_lock.h>
41
42#include "hwaccess.h"
43#include "cardwo.h"
44#include "cardwi.h"
45#include "recmgr.h"
46#include "irqmgr.h"
47#include "audio.h"
48#include "8010.h"
49
50static void calculate_ofrag(struct woinst *);
51static void calculate_ifrag(struct wiinst *);
52
53static void emu10k1_waveout_bh(unsigned long refdata);
54static void emu10k1_wavein_bh(unsigned long refdata);
55
56/* Audio file operations */
57static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
58{
59 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
60 struct wiinst *wiinst = wave_dev->wiinst;
61 ssize_t ret = 0;
62 unsigned long flags;
63
64 DPD(3, "emu10k1_audio_read(), buffer=%p, count=%d\n", buffer, (u32) count);
65
66 if (!access_ok(VERIFY_WRITE, buffer, count))
67 return -EFAULT;
68
69 spin_lock_irqsave(&wiinst->lock, flags);
70
71 if (wiinst->mmapped) {
72 spin_unlock_irqrestore(&wiinst->lock, flags);
73 return -ENXIO;
74 }
75
76 if (wiinst->state == WAVE_STATE_CLOSED) {
77 calculate_ifrag(wiinst);
78
79 while (emu10k1_wavein_open(wave_dev) < 0) {
80 spin_unlock_irqrestore(&wiinst->lock, flags);
81
82 if (file->f_flags & O_NONBLOCK)
83 return -EAGAIN;
84
85 interruptible_sleep_on(&wave_dev->card->open_wait);
86
87 if (signal_pending(current))
88 return -ERESTARTSYS;
89
90 spin_lock_irqsave(&wiinst->lock, flags);
91 }
92 }
93
94 spin_unlock_irqrestore(&wiinst->lock, flags);
95
96 while (count > 0) {
97 u32 bytestocopy;
98
99 spin_lock_irqsave(&wiinst->lock, flags);
100
101 if (!(wiinst->state & WAVE_STATE_STARTED)
102 && (wave_dev->enablebits & PCM_ENABLE_INPUT))
103 emu10k1_wavein_start(wave_dev);
104
105 emu10k1_wavein_update(wave_dev->card, wiinst);
106 emu10k1_wavein_getxfersize(wiinst, &bytestocopy);
107
108 spin_unlock_irqrestore(&wiinst->lock, flags);
109
110 DPD(3, "bytestocopy --> %d\n", bytestocopy);
111
112 if ((bytestocopy >= wiinst->buffer.fragment_size)
113 || (bytestocopy >= count)) {
114 int rc;
115
116 bytestocopy = min_t(u32, bytestocopy, count);
117
118 rc = emu10k1_wavein_xferdata(wiinst,
119 (u8 __user *)buffer,
120 &bytestocopy);
121 if (rc)
122 return rc;
123
124 count -= bytestocopy;
125 buffer += bytestocopy;
126 ret += bytestocopy;
127 }
128
129 if (count > 0) {
130 if ((file->f_flags & O_NONBLOCK)
131 || (!(wave_dev->enablebits & PCM_ENABLE_INPUT)))
132 return (ret ? ret : -EAGAIN);
133
134 interruptible_sleep_on(&wiinst->wait_queue);
135
136 if (signal_pending(current))
137 return (ret ? ret : -ERESTARTSYS);
138
139 }
140 }
141
142 DPD(3, "bytes copied -> %d\n", (u32) ret);
143
144 return ret;
145}
146
147static ssize_t emu10k1_audio_write(struct file *file, const char __user *buffer, size_t count, loff_t * ppos)
148{
149 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
150 struct woinst *woinst = wave_dev->woinst;
151 ssize_t ret;
152 unsigned long flags;
153
154 DPD(3, "emu10k1_audio_write(), buffer=%p, count=%d\n", buffer, (u32) count);
155
156 if (!access_ok(VERIFY_READ, buffer, count))
157 return -EFAULT;
158
159 spin_lock_irqsave(&woinst->lock, flags);
160
161 if (woinst->mmapped) {
162 spin_unlock_irqrestore(&woinst->lock, flags);
163 return -ENXIO;
164 }
165 // This is for emu10k1 revs less than 7, we need to go through tram
166 if (woinst->format.passthrough == 1) {
167 int r;
168
169 woinst->buffer.ossfragshift = PT_BLOCKSIZE_LOG2;
170 woinst->buffer.numfrags = PT_BLOCKCOUNT;
171 calculate_ofrag(woinst);
172
173 r = emu10k1_pt_write(file, buffer, count);
174 spin_unlock_irqrestore(&woinst->lock, flags);
175 return r;
176 }
177
178 if (woinst->state == WAVE_STATE_CLOSED) {
179 calculate_ofrag(woinst);
180
181 while (emu10k1_waveout_open(wave_dev) < 0) {
182 spin_unlock_irqrestore(&woinst->lock, flags);
183
184 if (file->f_flags & O_NONBLOCK)
185 return -EAGAIN;
186
187 interruptible_sleep_on(&wave_dev->card->open_wait);
188
189 if (signal_pending(current))
190 return -ERESTARTSYS;
191
192 spin_lock_irqsave(&woinst->lock, flags);
193 }
194 }
195
196 spin_unlock_irqrestore(&woinst->lock, flags);
197
198 ret = 0;
199 if (count % woinst->format.bytespersample)
200 return -EINVAL;
201
202 count /= woinst->num_voices;
203
204 while (count > 0) {
205 u32 bytestocopy;
206
207 spin_lock_irqsave(&woinst->lock, flags);
208 emu10k1_waveout_update(woinst);
209 emu10k1_waveout_getxfersize(woinst, &bytestocopy);
210 spin_unlock_irqrestore(&woinst->lock, flags);
211
212 DPD(3, "bytestocopy --> %d\n", bytestocopy);
213
214 if ((bytestocopy >= woinst->buffer.fragment_size)
215 || (bytestocopy >= count)) {
216
217 bytestocopy = min_t(u32, bytestocopy, count);
218
219 emu10k1_waveout_xferdata(woinst, (u8 __user *) buffer, &bytestocopy);
220
221 count -= bytestocopy;
222 buffer += bytestocopy * woinst->num_voices;
223 ret += bytestocopy * woinst->num_voices;
224
225 spin_lock_irqsave(&woinst->lock, flags);
226 woinst->total_copied += bytestocopy;
227
228 if (!(woinst->state & WAVE_STATE_STARTED)
229 && (wave_dev->enablebits & PCM_ENABLE_OUTPUT)
230 && (woinst->total_copied >= woinst->buffer.fragment_size))
231 emu10k1_waveout_start(wave_dev);
232
233 spin_unlock_irqrestore(&woinst->lock, flags);
234 }
235
236 if (count > 0) {
237 if ((file->f_flags & O_NONBLOCK)
238 || (!(wave_dev->enablebits & PCM_ENABLE_OUTPUT)))
239 return (ret ? ret : -EAGAIN);
240
241 interruptible_sleep_on(&woinst->wait_queue);
242
243 if (signal_pending(current))
244 return (ret ? ret : -ERESTARTSYS);
245 }
246 }
247
248 DPD(3, "bytes copied -> %d\n", (u32) ret);
249
250 return ret;
251}
252
253static int emu10k1_audio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
254{
255 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
256 struct woinst *woinst = NULL;
257 struct wiinst *wiinst = NULL;
258 int val = 0;
259 u32 bytestocopy;
260 unsigned long flags;
261 int __user *p = (int __user *)arg;
262
263 DPF(4, "emu10k1_audio_ioctl()\n");
264
265 if (file->f_mode & FMODE_WRITE)
266 woinst = wave_dev->woinst;
267
268 if (file->f_mode & FMODE_READ)
269 wiinst = wave_dev->wiinst;
270
271 switch (cmd) {
272 case OSS_GETVERSION:
273 DPF(2, "OSS_GETVERSION:\n");
274 return put_user(SOUND_VERSION, p);
275
276 case SNDCTL_DSP_RESET:
277 DPF(2, "SNDCTL_DSP_RESET:\n");
278 wave_dev->enablebits = PCM_ENABLE_OUTPUT | PCM_ENABLE_INPUT;
279
280 if (file->f_mode & FMODE_WRITE) {
281 spin_lock_irqsave(&woinst->lock, flags);
282
283 if (woinst->state & WAVE_STATE_OPEN) {
284 emu10k1_waveout_close(wave_dev);
285 }
286
287 woinst->mmapped = 0;
288 woinst->total_copied = 0;
289 woinst->total_played = 0;
290 woinst->blocks = 0;
291
292 spin_unlock_irqrestore(&woinst->lock, flags);
293 }
294
295 if (file->f_mode & FMODE_READ) {
296 spin_lock_irqsave(&wiinst->lock, flags);
297
298 if (wiinst->state & WAVE_STATE_OPEN) {
299 emu10k1_wavein_close(wave_dev);
300 }
301
302 wiinst->mmapped = 0;
303 wiinst->total_recorded = 0;
304 wiinst->blocks = 0;
305 spin_unlock_irqrestore(&wiinst->lock, flags);
306 }
307
308 break;
309
310 case SNDCTL_DSP_SYNC:
311 DPF(2, "SNDCTL_DSP_SYNC:\n");
312
313 if (file->f_mode & FMODE_WRITE) {
314
315 spin_lock_irqsave(&woinst->lock, flags);
316
317 if (woinst->state & WAVE_STATE_OPEN) {
318
319 if (woinst->state & WAVE_STATE_STARTED)
320 while ((woinst->total_played < woinst->total_copied)
321 && !signal_pending(current)) {
322 spin_unlock_irqrestore(&woinst->lock, flags);
323 interruptible_sleep_on(&woinst->wait_queue);
324 spin_lock_irqsave(&woinst->lock, flags);
325 }
326 emu10k1_waveout_close(wave_dev);
327 }
328
329 woinst->mmapped = 0;
330 woinst->total_copied = 0;
331 woinst->total_played = 0;
332 woinst->blocks = 0;
333
334 spin_unlock_irqrestore(&woinst->lock, flags);
335 }
336
337 if (file->f_mode & FMODE_READ) {
338 spin_lock_irqsave(&wiinst->lock, flags);
339
340 if (wiinst->state & WAVE_STATE_OPEN) {
341 emu10k1_wavein_close(wave_dev);
342 }
343
344 wiinst->mmapped = 0;
345 wiinst->total_recorded = 0;
346 wiinst->blocks = 0;
347 spin_unlock_irqrestore(&wiinst->lock, flags);
348 }
349
350 break;
351
352 case SNDCTL_DSP_SETDUPLEX:
353 DPF(2, "SNDCTL_DSP_SETDUPLEX:\n");
354 break;
355
356 case SNDCTL_DSP_GETCAPS:
357 DPF(2, "SNDCTL_DSP_GETCAPS:\n");
358 return put_user(DSP_CAP_DUPLEX | DSP_CAP_REALTIME |
359 DSP_CAP_TRIGGER | DSP_CAP_MMAP |
360 DSP_CAP_COPROC| DSP_CAP_MULTI, p);
361 case SNDCTL_DSP_SPEED:
362 DPF(2, "SNDCTL_DSP_SPEED:\n");
363
364 if (get_user(val, p))
365 return -EFAULT;
366
367 DPD(2, "val is %d\n", val);
368
369 if (val > 0) {
370 if (file->f_mode & FMODE_READ) {
371 struct wave_format format;
372
373 spin_lock_irqsave(&wiinst->lock, flags);
374
375 format = wiinst->format;
376 format.samplingrate = val;
377
378 if (emu10k1_wavein_setformat(wave_dev, &format) < 0) {
379 spin_unlock_irqrestore(&wiinst->lock, flags);
380 return -EINVAL;
381 }
382
383 val = wiinst->format.samplingrate;
384
385 spin_unlock_irqrestore(&wiinst->lock, flags);
386
387 DPD(2, "set recording sampling rate -> %d\n", val);
388 }
389
390 if (file->f_mode & FMODE_WRITE) {
391 struct wave_format format;
392
393 spin_lock_irqsave(&woinst->lock, flags);
394
395 format = woinst->format;
396 format.samplingrate = val;
397
398 if (emu10k1_waveout_setformat(wave_dev, &format) < 0) {
399 spin_unlock_irqrestore(&woinst->lock, flags);
400 return -EINVAL;
401 }
402
403 val = woinst->format.samplingrate;
404
405 spin_unlock_irqrestore(&woinst->lock, flags);
406
407 DPD(2, "set playback sampling rate -> %d\n", val);
408 }
409
410 return put_user(val, p);
411 } else {
412 if (file->f_mode & FMODE_READ)
413 val = wiinst->format.samplingrate;
414 else if (file->f_mode & FMODE_WRITE)
415 val = woinst->format.samplingrate;
416
417 return put_user(val, p);
418 }
419 break;
420
421 case SNDCTL_DSP_STEREO:
422 DPF(2, "SNDCTL_DSP_STEREO:\n");
423
424 if (get_user(val, p))
425 return -EFAULT;
426
427 DPD(2, " val is %d\n", val);
428
429 if (file->f_mode & FMODE_READ) {
430 struct wave_format format;
431
432 spin_lock_irqsave(&wiinst->lock, flags);
433
434 format = wiinst->format;
435 format.channels = val ? 2 : 1;
436
437 if (emu10k1_wavein_setformat(wave_dev, &format) < 0) {
438 spin_unlock_irqrestore(&wiinst->lock, flags);
439 return -EINVAL;
440 }
441
442 val = wiinst->format.channels - 1;
443
444 spin_unlock_irqrestore(&wiinst->lock, flags);
445 DPD(2, "set recording stereo -> %d\n", val);
446 }
447
448 if (file->f_mode & FMODE_WRITE) {
449 struct wave_format format;
450
451 spin_lock_irqsave(&woinst->lock, flags);
452
453 format = woinst->format;
454 format.channels = val ? 2 : 1;
455
456 if (emu10k1_waveout_setformat(wave_dev, &format) < 0) {
457 spin_unlock_irqrestore(&woinst->lock, flags);
458 return -EINVAL;
459 }
460
461 val = woinst->format.channels - 1;
462
463 spin_unlock_irqrestore(&woinst->lock, flags);
464
465 DPD(2, "set playback stereo -> %d\n", val);
466 }
467
468 return put_user(val, p);
469
470 break;
471
472 case SNDCTL_DSP_CHANNELS:
473 DPF(2, "SNDCTL_DSP_CHANNELS:\n");
474
475 if (get_user(val, p))
476 return -EFAULT;
477
478 DPD(2, " val is %d\n", val);
479
480 if (val > 0) {
481 if (file->f_mode & FMODE_READ) {
482 struct wave_format format;
483
484 spin_lock_irqsave(&wiinst->lock, flags);
485
486 format = wiinst->format;
487 format.channels = val;
488
489 if (emu10k1_wavein_setformat(wave_dev, &format) < 0) {
490 spin_unlock_irqrestore(&wiinst->lock, flags);
491 return -EINVAL;
492 }
493 val = wiinst->format.channels;
494
495 spin_unlock_irqrestore(&wiinst->lock, flags);
496 DPD(2, "set recording number of channels -> %d\n", val);
497 }
498
499 if (file->f_mode & FMODE_WRITE) {
500 struct wave_format format;
501
502 spin_lock_irqsave(&woinst->lock, flags);
503
504 format = woinst->format;
505 format.channels = val;
506
507 if (emu10k1_waveout_setformat(wave_dev, &format) < 0) {
508 spin_unlock_irqrestore(&woinst->lock, flags);
509 return -EINVAL;
510 }
511
512 val = woinst->format.channels;
513
514 spin_unlock_irqrestore(&woinst->lock, flags);
515 DPD(2, "set playback number of channels -> %d\n", val);
516 }
517
518 return put_user(val, p);
519 } else {
520 if (file->f_mode & FMODE_READ)
521 val = wiinst->format.channels;
522 else if (file->f_mode & FMODE_WRITE)
523 val = woinst->format.channels;
524
525 return put_user(val, p);
526 }
527 break;
528
529 case SNDCTL_DSP_GETFMTS:
530 DPF(2, "SNDCTL_DSP_GETFMTS:\n");
531
532 if (file->f_mode & FMODE_READ)
533 val = AFMT_S16_LE;
534 else if (file->f_mode & FMODE_WRITE) {
535 val = AFMT_S16_LE | AFMT_U8;
536 if (emu10k1_find_control_gpr(&wave_dev->card->mgr,
537 wave_dev->card->pt.patch_name,
538 wave_dev->card->pt.enable_gpr_name) >= 0)
539 val |= AFMT_AC3;
540 }
541 return put_user(val, p);
542
543 case SNDCTL_DSP_SETFMT: /* Same as SNDCTL_DSP_SAMPLESIZE */
544 DPF(2, "SNDCTL_DSP_SETFMT:\n");
545
546 if (get_user(val, p))
547 return -EFAULT;
548
549 DPD(2, " val is %d\n", val);
550
551 if (val != AFMT_QUERY) {
552 if (file->f_mode & FMODE_READ) {
553 struct wave_format format;
554
555 spin_lock_irqsave(&wiinst->lock, flags);
556
557 format = wiinst->format;
558 format.id = val;
559
560 if (emu10k1_wavein_setformat(wave_dev, &format) < 0) {
561 spin_unlock_irqrestore(&wiinst->lock, flags);
562 return -EINVAL;
563 }
564
565 val = wiinst->format.id;
566
567 spin_unlock_irqrestore(&wiinst->lock, flags);
568 DPD(2, "set recording format -> %d\n", val);
569 }
570
571 if (file->f_mode & FMODE_WRITE) {
572 struct wave_format format;
573
574 spin_lock_irqsave(&woinst->lock, flags);
575
576 format = woinst->format;
577 format.id = val;
578
579 if (emu10k1_waveout_setformat(wave_dev, &format) < 0) {
580 spin_unlock_irqrestore(&woinst->lock, flags);
581 return -EINVAL;
582 }
583
584 val = woinst->format.id;
585
586 spin_unlock_irqrestore(&woinst->lock, flags);
587 DPD(2, "set playback format -> %d\n", val);
588 }
589
590 return put_user(val, p);
591 } else {
592 if (file->f_mode & FMODE_READ)
593 val = wiinst->format.id;
594 else if (file->f_mode & FMODE_WRITE)
595 val = woinst->format.id;
596
597 return put_user(val, p);
598 }
599 break;
600
601 case SOUND_PCM_READ_BITS:
602
603 if (file->f_mode & FMODE_READ)
604 val = wiinst->format.bitsperchannel;
605 else if (file->f_mode & FMODE_WRITE)
606 val = woinst->format.bitsperchannel;
607
608 return put_user(val, p);
609
610 case SOUND_PCM_READ_RATE:
611
612 if (file->f_mode & FMODE_READ)
613 val = wiinst->format.samplingrate;
614 else if (file->f_mode & FMODE_WRITE)
615 val = woinst->format.samplingrate;
616
617 return put_user(val, p);
618
619 case SOUND_PCM_READ_CHANNELS:
620
621 if (file->f_mode & FMODE_READ)
622 val = wiinst->format.channels;
623 else if (file->f_mode & FMODE_WRITE)
624 val = woinst->format.channels;
625
626 return put_user(val, p);
627
628 case SOUND_PCM_WRITE_FILTER:
629 DPF(2, "SOUND_PCM_WRITE_FILTER: not implemented\n");
630 break;
631
632 case SOUND_PCM_READ_FILTER:
633 DPF(2, "SOUND_PCM_READ_FILTER: not implemented\n");
634 break;
635
636 case SNDCTL_DSP_SETSYNCRO:
637 DPF(2, "SNDCTL_DSP_SETSYNCRO: not implemented\n");
638 break;
639
640 case SNDCTL_DSP_GETTRIGGER:
641 DPF(2, "SNDCTL_DSP_GETTRIGGER:\n");
642
643 if (file->f_mode & FMODE_WRITE && (wave_dev->enablebits & PCM_ENABLE_OUTPUT))
644 val |= PCM_ENABLE_OUTPUT;
645
646 if (file->f_mode & FMODE_READ && (wave_dev->enablebits & PCM_ENABLE_INPUT))
647 val |= PCM_ENABLE_INPUT;
648
649 return put_user(val, p);
650
651 case SNDCTL_DSP_SETTRIGGER:
652 DPF(2, "SNDCTL_DSP_SETTRIGGER:\n");
653
654 if (get_user(val, p))
655 return -EFAULT;
656
657 if (file->f_mode & FMODE_WRITE) {
658 spin_lock_irqsave(&woinst->lock, flags);
659
660 if (val & PCM_ENABLE_OUTPUT) {
661 wave_dev->enablebits |= PCM_ENABLE_OUTPUT;
662 if (woinst->state & WAVE_STATE_OPEN)
663 emu10k1_waveout_start(wave_dev);
664 } else {
665 wave_dev->enablebits &= ~PCM_ENABLE_OUTPUT;
666 if (woinst->state & WAVE_STATE_STARTED)
667 emu10k1_waveout_stop(wave_dev);
668 }
669
670 spin_unlock_irqrestore(&woinst->lock, flags);
671 }
672
673 if (file->f_mode & FMODE_READ) {
674 spin_lock_irqsave(&wiinst->lock, flags);
675
676 if (val & PCM_ENABLE_INPUT) {
677 wave_dev->enablebits |= PCM_ENABLE_INPUT;
678 if (wiinst->state & WAVE_STATE_OPEN)
679 emu10k1_wavein_start(wave_dev);
680 } else {
681 wave_dev->enablebits &= ~PCM_ENABLE_INPUT;
682 if (wiinst->state & WAVE_STATE_STARTED)
683 emu10k1_wavein_stop(wave_dev);
684 }
685
686 spin_unlock_irqrestore(&wiinst->lock, flags);
687 }
688 break;
689
690 case SNDCTL_DSP_GETOSPACE:
691 {
692 audio_buf_info info;
693
694 DPF(4, "SNDCTL_DSP_GETOSPACE:\n");
695
696 if (!(file->f_mode & FMODE_WRITE))
697 return -EINVAL;
698
699 spin_lock_irqsave(&woinst->lock, flags);
700
701 if (woinst->state & WAVE_STATE_OPEN) {
702 emu10k1_waveout_update(woinst);
703 emu10k1_waveout_getxfersize(woinst, &bytestocopy);
704 info.bytes = bytestocopy;
705 } else {
706 calculate_ofrag(woinst);
707 info.bytes = woinst->buffer.size;
708 }
709 spin_unlock_irqrestore(&woinst->lock, flags);
710
711 info.bytes *= woinst->num_voices;
712 info.fragsize = woinst->buffer.fragment_size * woinst->num_voices;
713 info.fragstotal = woinst->buffer.numfrags * woinst->num_voices;
714 info.fragments = info.bytes / info.fragsize;
715
716 if (copy_to_user(p, &info, sizeof(info)))
717 return -EFAULT;
718 }
719 break;
720
721 case SNDCTL_DSP_GETISPACE:
722 {
723 audio_buf_info info;
724
725 DPF(4, "SNDCTL_DSP_GETISPACE:\n");
726
727 if (!(file->f_mode & FMODE_READ))
728 return -EINVAL;
729
730 spin_lock_irqsave(&wiinst->lock, flags);
731 if (wiinst->state & WAVE_STATE_OPEN) {
732 emu10k1_wavein_update(wave_dev->card, wiinst);
733 emu10k1_wavein_getxfersize(wiinst, &bytestocopy);
734 info.bytes = bytestocopy;
735 } else {
736 calculate_ifrag(wiinst);
737 info.bytes = 0;
738 }
739 spin_unlock_irqrestore(&wiinst->lock, flags);
740
741 info.fragstotal = wiinst->buffer.numfrags;
742 info.fragments = info.bytes / wiinst->buffer.fragment_size;
743 info.fragsize = wiinst->buffer.fragment_size;
744
745 if (copy_to_user(p, &info, sizeof(info)))
746 return -EFAULT;
747 }
748 break;
749
750 case SNDCTL_DSP_NONBLOCK:
751 DPF(2, "SNDCTL_DSP_NONBLOCK:\n");
752
753 file->f_flags |= O_NONBLOCK;
754 break;
755
756 case SNDCTL_DSP_GETODELAY:
757 DPF(4, "SNDCTL_DSP_GETODELAY:\n");
758
759 if (!(file->f_mode & FMODE_WRITE))
760 return -EINVAL;
761
762 spin_lock_irqsave(&woinst->lock, flags);
763 if (woinst->state & WAVE_STATE_OPEN) {
764 emu10k1_waveout_update(woinst);
765 emu10k1_waveout_getxfersize(woinst, &bytestocopy);
766 val = woinst->buffer.size - bytestocopy;
767 } else
768 val = 0;
769
770 val *= woinst->num_voices;
771 spin_unlock_irqrestore(&woinst->lock, flags);
772
773 return put_user(val, p);
774
775 case SNDCTL_DSP_GETIPTR:
776 {
777 count_info cinfo;
778
779 DPF(4, "SNDCTL_DSP_GETIPTR: \n");
780
781 if (!(file->f_mode & FMODE_READ))
782 return -EINVAL;
783
784 spin_lock_irqsave(&wiinst->lock, flags);
785
786 if (wiinst->state & WAVE_STATE_OPEN) {
787 emu10k1_wavein_update(wave_dev->card, wiinst);
788 cinfo.ptr = wiinst->buffer.hw_pos;
789 cinfo.bytes = cinfo.ptr + wiinst->total_recorded - wiinst->total_recorded % wiinst->buffer.size;
790 cinfo.blocks = cinfo.bytes / wiinst->buffer.fragment_size - wiinst->blocks;
791 wiinst->blocks = cinfo.bytes / wiinst->buffer.fragment_size;
792 } else {
793 cinfo.ptr = 0;
794 cinfo.bytes = 0;
795 cinfo.blocks = 0;
796 }
797
798 if (wiinst->mmapped)
799 wiinst->buffer.bytestocopy %= wiinst->buffer.fragment_size;
800
801 spin_unlock_irqrestore(&wiinst->lock, flags);
802
803 if (copy_to_user(p, &cinfo, sizeof(cinfo)))
804 return -EFAULT;
805 }
806 break;
807
808 case SNDCTL_DSP_GETOPTR:
809 {
810 count_info cinfo;
811
812 DPF(4, "SNDCTL_DSP_GETOPTR:\n");
813
814 if (!(file->f_mode & FMODE_WRITE))
815 return -EINVAL;
816
817 spin_lock_irqsave(&woinst->lock, flags);
818
819 if (woinst->state & WAVE_STATE_OPEN ||
820 ((woinst->format.passthrough == 1) && wave_dev->card->pt.state)) {
821 int num_fragments;
822
823 if (woinst->format.passthrough == 1) {
824 emu10k1_pt_waveout_update(wave_dev);
825 cinfo.bytes = woinst->total_played;
826 } else {
827 emu10k1_waveout_update(woinst);
828 cinfo.bytes = woinst->total_played;
829 }
830
831 cinfo.ptr = woinst->buffer.hw_pos;
832 num_fragments = cinfo.bytes / woinst->buffer.fragment_size;
833 cinfo.blocks = num_fragments - woinst->blocks;
834 woinst->blocks = num_fragments;
835
836 cinfo.bytes *= woinst->num_voices;
837 cinfo.ptr *= woinst->num_voices;
838 } else {
839 cinfo.ptr = 0;
840 cinfo.bytes = 0;
841 cinfo.blocks = 0;
842 }
843
844 if (woinst->mmapped)
845 woinst->buffer.free_bytes %= woinst->buffer.fragment_size;
846
847 spin_unlock_irqrestore(&woinst->lock, flags);
848
849 if (copy_to_user(p, &cinfo, sizeof(cinfo)))
850 return -EFAULT;
851 }
852 break;
853
854 case SNDCTL_DSP_GETBLKSIZE:
855 DPF(2, "SNDCTL_DSP_GETBLKSIZE:\n");
856
857 if (file->f_mode & FMODE_WRITE) {
858 spin_lock_irqsave(&woinst->lock, flags);
859
860 calculate_ofrag(woinst);
861 val = woinst->buffer.fragment_size * woinst->num_voices;
862
863 spin_unlock_irqrestore(&woinst->lock, flags);
864 }
865
866 if (file->f_mode & FMODE_READ) {
867 spin_lock_irqsave(&wiinst->lock, flags);
868
869 calculate_ifrag(wiinst);
870 val = wiinst->buffer.fragment_size;
871
872 spin_unlock_irqrestore(&wiinst->lock, flags);
873 }
874
875 return put_user(val, p);
876
877 break;
878
879 case SNDCTL_DSP_POST:
880 if (file->f_mode & FMODE_WRITE) {
881 spin_lock_irqsave(&woinst->lock, flags);
882
883 if (!(woinst->state & WAVE_STATE_STARTED)
884 && (wave_dev->enablebits & PCM_ENABLE_OUTPUT)
885 && (woinst->total_copied > 0))
886 emu10k1_waveout_start(wave_dev);
887
888 spin_unlock_irqrestore(&woinst->lock, flags);
889 }
890
891 break;
892
893 case SNDCTL_DSP_SUBDIVIDE:
894 DPF(2, "SNDCTL_DSP_SUBDIVIDE: not implemented\n");
895 break;
896
897 case SNDCTL_DSP_SETFRAGMENT:
898 DPF(2, "SNDCTL_DSP_SETFRAGMENT:\n");
899
900 if (get_user(val, p))
901 return -EFAULT;
902
903 DPD(2, "val is %#x\n", val);
904
905 if (val == 0)
906 return -EIO;
907
908 if (file->f_mode & FMODE_WRITE) {
909 /* digital pass-through fragment count and size are fixed values */
910 if (woinst->state & WAVE_STATE_OPEN || (woinst->format.passthrough == 1))
911 return -EINVAL; /* too late to change */
912
913 woinst->buffer.ossfragshift = val & 0xffff;
914 woinst->buffer.numfrags = (val >> 16) & 0xffff;
915 }
916
917 if (file->f_mode & FMODE_READ) {
918 if (wiinst->state & WAVE_STATE_OPEN)
919 return -EINVAL; /* too late to change */
920
921 wiinst->buffer.ossfragshift = val & 0xffff;
922 wiinst->buffer.numfrags = (val >> 16) & 0xffff;
923 }
924
925 break;
926
927 case SNDCTL_COPR_LOAD:
928 {
929 copr_buffer *buf;
930 u32 i;
931
932 DPF(4, "SNDCTL_COPR_LOAD:\n");
933
934 buf = kmalloc(sizeof(copr_buffer), GFP_KERNEL);
935 if (!buf)
936 return -ENOMEM;
937
938 if (copy_from_user(buf, p, sizeof(copr_buffer))) {
939 kfree (buf);
940 return -EFAULT;
941 }
942
943 if ((buf->command != CMD_READ) && (buf->command != CMD_WRITE)) {
944 kfree (buf);
945 return -EINVAL;
946 }
947
948 if (buf->command == CMD_WRITE) {
949
950#ifdef DBGEMU
951 if ((buf->offs < 0) || (buf->offs + buf->len > 0xe00) || (buf->len > 1000)) {
952#else
953 if (((buf->offs < 0x100) || (buf->offs + buf->len > (wave_dev->card->is_audigy ? 0xe00 : 0x800)) || (buf->len > 1000)
954 ) && !(
955 //any register allowed raw access to users goes here:
956 (buf->offs == DBG ||
957 buf->offs == A_DBG)
958 && (buf->len == 1))) {
959#endif
960 kfree(buf);
961 return -EINVAL;
962 }
963 } else {
964 if ((buf->offs < 0) || (buf->offs + buf->len > 0xe00) || (buf->len > 1000)) {
965 kfree(buf);
966 return -EINVAL;
967 }
968 }
969
970 if (((unsigned)buf->flags) > 0x3f)
971 buf->flags = 0;
972
973 if (buf->command == CMD_READ) {
974 for (i = 0; i < buf->len; i++)
975 ((u32 *) buf->data)[i] = sblive_readptr(wave_dev->card, buf->offs + i, buf->flags);
976
977 if (copy_to_user(p, buf, sizeof(copr_buffer))) {
978 kfree(buf);
979 return -EFAULT;
980 }
981 } else {
982 for (i = 0; i < buf->len; i++)
983 sblive_writeptr(wave_dev->card, buf->offs + i, buf->flags, ((u32 *) buf->data)[i]);
984 }
985
986 kfree (buf);
987 break;
988 }
989
990 default: /* Default is unrecognized command */
991 DPD(2, "default: %#x\n", cmd);
992 return -EINVAL;
993 }
994 return 0;
995}
996
997static struct page *emu10k1_mm_nopage (struct vm_area_struct * vma, unsigned long address, int *type)
998{
999 struct emu10k1_wavedevice *wave_dev = vma->vm_private_data;
1000 struct woinst *woinst = wave_dev->woinst;
1001 struct wiinst *wiinst = wave_dev->wiinst;
1002 struct page *dmapage;
1003 unsigned long pgoff;
1004 int rd, wr;
1005
1006 DPF(3, "emu10k1_mm_nopage()\n");
1007 DPD(3, "addr: %#lx\n", address);
1008
1009 if (address > vma->vm_end) {
1010 DPF(1, "EXIT, returning NOPAGE_SIGBUS\n");
1011 return NOPAGE_SIGBUS; /* Disallow mremap */
1012 }
1013
1014 pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT);
1015 if (woinst != NULL)
1016 wr = woinst->mmapped;
1017 else
1018 wr = 0;
1019
1020 if (wiinst != NULL)
1021 rd = wiinst->mmapped;
1022 else
1023 rd = 0;
1024
1025 /* if full-duplex (read+write) and we have two sets of bufs,
1026 * then the playback buffers come first, sez soundcard.c */
1027 if (wr) {
1028 if (pgoff >= woinst->buffer.pages) {
1029 pgoff -= woinst->buffer.pages;
1030 dmapage = virt_to_page ((u8 *) wiinst->buffer.addr + pgoff * PAGE_SIZE);
1031 } else
1032 dmapage = virt_to_page (woinst->voice[0].mem.addr[pgoff]);
1033 } else {
1034 dmapage = virt_to_page ((u8 *) wiinst->buffer.addr + pgoff * PAGE_SIZE);
1035 }
1036
1037 get_page (dmapage);
1038
1039 DPD(3, "page: %#lx\n", (unsigned long) dmapage);
1040 if (type)
1041 *type = VM_FAULT_MINOR;
1042 return dmapage;
1043}
1044
1045static struct vm_operations_struct emu10k1_mm_ops = {
1046 .nopage = emu10k1_mm_nopage,
1047};
1048
1049static int emu10k1_audio_mmap(struct file *file, struct vm_area_struct *vma)
1050{
1051 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
1052 unsigned long max_pages, n_pages, pgoffset;
1053 struct woinst *woinst = NULL;
1054 struct wiinst *wiinst = NULL;
1055 unsigned long flags;
1056
1057 DPF(2, "emu10k1_audio_mmap()\n");
1058
1059 max_pages = 0;
1060 if (vma->vm_flags & VM_WRITE) {
1061 woinst = wave_dev->woinst;
1062
1063 spin_lock_irqsave(&woinst->lock, flags);
1064
1065 /* No m'mapping possible for multichannel */
1066 if (woinst->num_voices > 1) {
1067 spin_unlock_irqrestore(&woinst->lock, flags);
1068 return -EINVAL;
1069 }
1070
1071 if (woinst->state == WAVE_STATE_CLOSED) {
1072 calculate_ofrag(woinst);
1073
1074 if (emu10k1_waveout_open(wave_dev) < 0) {
1075 spin_unlock_irqrestore(&woinst->lock, flags);
1076 ERROR();
1077 return -EINVAL;
1078 }
1079 }
1080
1081 woinst->mmapped = 1;
1082 max_pages += woinst->buffer.pages;
1083 spin_unlock_irqrestore(&woinst->lock, flags);
1084 }
1085
1086 if (vma->vm_flags & VM_READ) {
1087 wiinst = wave_dev->wiinst;
1088
1089 spin_lock_irqsave(&wiinst->lock, flags);
1090 if (wiinst->state == WAVE_STATE_CLOSED) {
1091 calculate_ifrag(wiinst);
1092
1093 if (emu10k1_wavein_open(wave_dev) < 0) {
1094 spin_unlock_irqrestore(&wiinst->lock, flags);
1095 ERROR();
1096 return -EINVAL;
1097 }
1098 }
1099
1100 wiinst->mmapped = 1;
1101 max_pages += wiinst->buffer.pages;
1102 spin_unlock_irqrestore(&wiinst->lock, flags);
1103 }
1104
1105 n_pages = ((vma->vm_end - vma->vm_start) + PAGE_SIZE - 1) >> PAGE_SHIFT;
1106 pgoffset = vma->vm_pgoff;
1107
1108 DPD(2, "vma_start: %#lx, vma_end: %#lx, vma_offset: %ld\n", vma->vm_start, vma->vm_end, pgoffset);
1109 DPD(2, "n_pages: %ld, max_pages: %ld\n", n_pages, max_pages);
1110
1111 if (pgoffset + n_pages > max_pages)
1112 return -EINVAL;
1113
1114 vma->vm_flags |= VM_RESERVED;
1115 vma->vm_ops = &emu10k1_mm_ops;
1116 vma->vm_private_data = wave_dev;
1117 return 0;
1118}
1119
1120static int emu10k1_audio_open(struct inode *inode, struct file *file)
1121{
1122 int minor = iminor(inode);
1123 struct emu10k1_card *card = NULL;
1124 struct list_head *entry;
1125 struct emu10k1_wavedevice *wave_dev;
1126
1127 DPF(2, "emu10k1_audio_open()\n");
1128
1129 /* Check for correct device to open */
1130
1131 list_for_each(entry, &emu10k1_devs) {
1132 card = list_entry(entry, struct emu10k1_card, list);
1133
1134 if (!((card->audio_dev ^ minor) & ~0xf) || !((card->audio_dev1 ^ minor) & ~0xf))
1135 goto match;
1136 }
1137
1138 return -ENODEV;
1139
1140match:
1141
1142 wave_dev = kmalloc(sizeof(struct emu10k1_wavedevice), GFP_KERNEL);
1143
1144 if (wave_dev == NULL) {
1145 ERROR();
1146 return -ENOMEM;
1147 }
1148
1149 wave_dev->card = card;
1150 wave_dev->wiinst = NULL;
1151 wave_dev->woinst = NULL;
1152 wave_dev->enablebits = PCM_ENABLE_OUTPUT | PCM_ENABLE_INPUT; /* Default */
1153
1154 if (file->f_mode & FMODE_READ) {
1155 /* Recording */
1156 struct wiinst *wiinst;
1157
1158 if ((wiinst = kmalloc(sizeof(struct wiinst), GFP_KERNEL)) == NULL) {
1159 ERROR();
1160 kfree(wave_dev);
1161 return -ENOMEM;
1162 }
1163
1164 wiinst->recsrc = card->wavein.recsrc;
1165 wiinst->fxwc = card->wavein.fxwc;
1166
1167 switch (wiinst->recsrc) {
1168 case WAVERECORD_AC97:
1169 wiinst->format.id = AFMT_S16_LE;
1170 wiinst->format.samplingrate = 8000;
1171 wiinst->format.bitsperchannel = 16;
1172 wiinst->format.channels = 1;
1173 break;
1174 case WAVERECORD_MIC:
1175 wiinst->format.id = AFMT_S16_LE;
1176 wiinst->format.samplingrate = 8000;
1177 wiinst->format.bitsperchannel = 16;
1178 wiinst->format.channels = 1;
1179 break;
1180 case WAVERECORD_FX:
1181 wiinst->format.id = AFMT_S16_LE;
1182 wiinst->format.samplingrate = 48000;
1183 wiinst->format.bitsperchannel = 16;
1184 wiinst->format.channels = hweight32(wiinst->fxwc);
1185 break;
1186 default:
1187 kfree(wave_dev);
1188 kfree(wiinst);
1189 BUG();
1190 break;
1191 }
1192
1193 wiinst->state = WAVE_STATE_CLOSED;
1194
1195 wiinst->buffer.ossfragshift = 0;
1196 wiinst->buffer.fragment_size = 0;
1197 wiinst->buffer.numfrags = 0;
1198
1199 init_waitqueue_head(&wiinst->wait_queue);
1200
1201 wiinst->mmapped = 0;
1202 wiinst->total_recorded = 0;
1203 wiinst->blocks = 0;
1204 spin_lock_init(&wiinst->lock);
1205 tasklet_init(&wiinst->timer.tasklet, emu10k1_wavein_bh, (unsigned long) wave_dev);
1206 wave_dev->wiinst = wiinst;
1207 emu10k1_wavein_setformat(wave_dev, &wiinst->format);
1208 }
1209
1210 if (file->f_mode & FMODE_WRITE) {
1211 struct woinst *woinst;
1212 int i;
1213
1214 if ((woinst = kmalloc(sizeof(struct woinst), GFP_KERNEL)) == NULL) {
1215 ERROR();
1216 kfree(wave_dev);
1217 return -ENOMEM;
1218 }
1219
1220 if (wave_dev->wiinst != NULL) {
1221 woinst->format = wave_dev->wiinst->format;
1222 } else {
1223 woinst->format.id = AFMT_U8;
1224 woinst->format.samplingrate = 8000;
1225 woinst->format.bitsperchannel = 8;
1226 woinst->format.channels = 1;
1227 }
1228
1229 woinst->state = WAVE_STATE_CLOSED;
1230
1231 woinst->buffer.fragment_size = 0;
1232 woinst->buffer.ossfragshift = 0;
1233 woinst->buffer.numfrags = 0;
1234 woinst->device = (card->audio_dev1 == minor);
1235 woinst->timer.state = TIMER_STATE_UNINSTALLED;
1236 woinst->num_voices = 1;
1237 for (i = 0; i < WAVEOUT_MAXVOICES; i++) {
1238 woinst->voice[i].usage = VOICE_USAGE_FREE;
1239 woinst->voice[i].mem.emupageindex = -1;
1240 }
1241
1242 init_waitqueue_head(&woinst->wait_queue);
1243
1244 woinst->mmapped = 0;
1245 woinst->total_copied = 0;
1246 woinst->total_played = 0;
1247 woinst->blocks = 0;
1248 spin_lock_init(&woinst->lock);
1249 tasklet_init(&woinst->timer.tasklet, emu10k1_waveout_bh, (unsigned long) wave_dev);
1250 wave_dev->woinst = woinst;
1251 emu10k1_waveout_setformat(wave_dev, &woinst->format);
1252 }
1253
1254 file->private_data = (void *) wave_dev;
1255
1256 return nonseekable_open(inode, file);
1257}
1258
1259static int emu10k1_audio_release(struct inode *inode, struct file *file)
1260{
1261 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
1262 struct emu10k1_card *card;
1263 unsigned long flags;
1264
1265 card = wave_dev->card;
1266
1267 DPF(2, "emu10k1_audio_release()\n");
1268
1269 if (file->f_mode & FMODE_WRITE) {
1270 struct woinst *woinst = wave_dev->woinst;
1271
1272 spin_lock_irqsave(&woinst->lock, flags);
1273 if(woinst->format.passthrough==2)
1274 card->pt.state=PT_STATE_PLAYING;
1275 if (woinst->format.passthrough && card->pt.state != PT_STATE_INACTIVE){
1276 spin_lock(&card->pt.lock);
1277 emu10k1_pt_stop(card);
1278 spin_unlock(&card->pt.lock);
1279 }
1280 if (woinst->state & WAVE_STATE_OPEN) {
1281 if (woinst->state & WAVE_STATE_STARTED) {
1282 if (!(file->f_flags & O_NONBLOCK)) {
1283 while (!signal_pending(current)
1284 && (woinst->total_played < woinst->total_copied)) {
1285 DPF(4, "Buffer hasn't been totally played, sleep....\n");
1286 spin_unlock_irqrestore(&woinst->lock, flags);
1287 interruptible_sleep_on(&woinst->wait_queue);
1288 spin_lock_irqsave(&woinst->lock, flags);
1289 }
1290 }
1291 }
1292 emu10k1_waveout_close(wave_dev);
1293 }
1294
1295 spin_unlock_irqrestore(&woinst->lock, flags);
1296 /* remove the tasklet */
1297 tasklet_kill(&woinst->timer.tasklet);
1298 kfree(wave_dev->woinst);
1299 }
1300
1301 if (file->f_mode & FMODE_READ) {
1302 struct wiinst *wiinst = wave_dev->wiinst;
1303
1304 spin_lock_irqsave(&wiinst->lock, flags);
1305
1306 if (wiinst->state & WAVE_STATE_OPEN) {
1307 emu10k1_wavein_close(wave_dev);
1308 }
1309
1310 spin_unlock_irqrestore(&wiinst->lock, flags);
1311 tasklet_kill(&wiinst->timer.tasklet);
1312 kfree(wave_dev->wiinst);
1313 }
1314
1315 kfree(wave_dev);
1316
1317 if (waitqueue_active(&card->open_wait))
1318 wake_up_interruptible(&card->open_wait);
1319
1320 return 0;
1321}
1322
1323/* FIXME sort out poll() + mmap() */
1324static unsigned int emu10k1_audio_poll(struct file *file, struct poll_table_struct *wait)
1325{
1326 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
1327 struct woinst *woinst = wave_dev->woinst;
1328 struct wiinst *wiinst = wave_dev->wiinst;
1329 unsigned int mask = 0;
1330 u32 bytestocopy;
1331 unsigned long flags;
1332
1333 DPF(4, "emu10k1_audio_poll()\n");
1334
1335 if (file->f_mode & FMODE_WRITE)
1336 poll_wait(file, &woinst->wait_queue, wait);
1337
1338 if (file->f_mode & FMODE_READ)
1339 poll_wait(file, &wiinst->wait_queue, wait);
1340
1341 if (file->f_mode & FMODE_WRITE) {
1342 spin_lock_irqsave(&woinst->lock, flags);
1343
1344 if (woinst->state & WAVE_STATE_OPEN) {
1345 emu10k1_waveout_update(woinst);
1346 emu10k1_waveout_getxfersize(woinst, &bytestocopy);
1347
1348 if (bytestocopy >= woinst->buffer.fragment_size)
1349 mask |= POLLOUT | POLLWRNORM;
1350 } else
1351 mask |= POLLOUT | POLLWRNORM;
1352
1353 spin_unlock_irqrestore(&woinst->lock, flags);
1354 }
1355
1356 if (file->f_mode & FMODE_READ) {
1357 spin_lock_irqsave(&wiinst->lock, flags);
1358
1359 if (wiinst->state & WAVE_STATE_OPEN) {
1360 emu10k1_wavein_update(wave_dev->card, wiinst);
1361 emu10k1_wavein_getxfersize(wiinst, &bytestocopy);
1362
1363 if (bytestocopy >= wiinst->buffer.fragment_size)
1364 mask |= POLLIN | POLLRDNORM;
1365 }
1366
1367 spin_unlock_irqrestore(&wiinst->lock, flags);
1368 }
1369
1370 return mask;
1371}
1372
1373static void calculate_ofrag(struct woinst *woinst)
1374{
1375 struct waveout_buffer *buffer = &woinst->buffer;
1376 u32 fragsize;
1377
1378 if (buffer->fragment_size)
1379 return;
1380
1381 if (!buffer->ossfragshift) {
1382 fragsize = (woinst->format.bytespervoicesample * woinst->format.samplingrate * WAVEOUT_DEFAULTFRAGLEN) / 1000 - 1;
1383
1384 while (fragsize) {
1385 fragsize >>= 1;
1386 buffer->ossfragshift++;
1387 }
1388 }
1389
1390 if (buffer->ossfragshift < WAVEOUT_MINFRAGSHIFT)
1391 buffer->ossfragshift = WAVEOUT_MINFRAGSHIFT;
1392
1393 buffer->fragment_size = 1 << buffer->ossfragshift;
1394
1395 while (buffer->fragment_size * WAVEOUT_MINFRAGS > WAVEOUT_MAXBUFSIZE)
1396 buffer->fragment_size >>= 1;
1397
1398 /* now we are sure that:
1399 (2^WAVEOUT_MINFRAGSHIFT) <= (fragment_size = 2^n) <= (WAVEOUT_MAXBUFSIZE / WAVEOUT_MINFRAGS)
1400 */
1401
1402 if (!buffer->numfrags) {
1403 u32 numfrags;
1404
1405 numfrags = (woinst->format.bytespervoicesample * woinst->format.samplingrate * WAVEOUT_DEFAULTBUFLEN) /
1406 (buffer->fragment_size * 1000) - 1;
1407
1408 buffer->numfrags = 1;
1409
1410 while (numfrags) {
1411 numfrags >>= 1;
1412 buffer->numfrags <<= 1;
1413 }
1414 }
1415
1416 if (buffer->numfrags < WAVEOUT_MINFRAGS)
1417 buffer->numfrags = WAVEOUT_MINFRAGS;
1418
1419 if (buffer->numfrags * buffer->fragment_size > WAVEOUT_MAXBUFSIZE)
1420 buffer->numfrags = WAVEOUT_MAXBUFSIZE / buffer->fragment_size;
1421
1422 if (buffer->numfrags < WAVEOUT_MINFRAGS)
1423 BUG();
1424
1425 buffer->size = buffer->fragment_size * buffer->numfrags;
1426 buffer->pages = buffer->size / PAGE_SIZE + ((buffer->size % PAGE_SIZE) ? 1 : 0);
1427
1428 DPD(2, " calculated playback fragment_size -> %d\n", buffer->fragment_size);
1429 DPD(2, " calculated playback numfrags -> %d\n", buffer->numfrags);
1430
1431 return;
1432}
1433
1434static void calculate_ifrag(struct wiinst *wiinst)
1435{
1436 struct wavein_buffer *buffer = &wiinst->buffer;
1437 u32 fragsize, bufsize, size[4];
1438 int i, j;
1439
1440 if (buffer->fragment_size)
1441 return;
1442
1443 if (!buffer->ossfragshift) {
1444 fragsize = (wiinst->format.bytespersec * WAVEIN_DEFAULTFRAGLEN) / 1000 - 1;
1445
1446 while (fragsize) {
1447 fragsize >>= 1;
1448 buffer->ossfragshift++;
1449 }
1450 }
1451
1452 if (buffer->ossfragshift < WAVEIN_MINFRAGSHIFT)
1453 buffer->ossfragshift = WAVEIN_MINFRAGSHIFT;
1454
1455 buffer->fragment_size = 1 << buffer->ossfragshift;
1456
1457 while (buffer->fragment_size * WAVEIN_MINFRAGS > WAVEIN_MAXBUFSIZE)
1458 buffer->fragment_size >>= 1;
1459
1460 /* now we are sure that:
1461 (2^WAVEIN_MINFRAGSHIFT) <= (fragment_size = 2^n) <= (WAVEIN_MAXBUFSIZE / WAVEIN_MINFRAGS)
1462 */
1463
1464
1465 if (!buffer->numfrags)
1466 buffer->numfrags = (wiinst->format.bytespersec * WAVEIN_DEFAULTBUFLEN) / (buffer->fragment_size * 1000) - 1;
1467
1468 if (buffer->numfrags < WAVEIN_MINFRAGS)
1469 buffer->numfrags = WAVEIN_MINFRAGS;
1470
1471 if (buffer->numfrags * buffer->fragment_size > WAVEIN_MAXBUFSIZE)
1472 buffer->numfrags = WAVEIN_MAXBUFSIZE / buffer->fragment_size;
1473
1474 if (buffer->numfrags < WAVEIN_MINFRAGS)
1475 BUG();
1476
1477 bufsize = buffer->fragment_size * buffer->numfrags;
1478
1479 /* the buffer size for recording is restricted to certain values, adjust it now */
1480 if (bufsize >= 0x10000) {
1481 buffer->size = 0x10000;
1482 buffer->sizeregval = 0x1f;
1483 } else {
1484 buffer->size = 0;
1485 size[0] = 384;
1486 size[1] = 448;
1487 size[2] = 512;
1488 size[3] = 640;
1489
1490 for (i = 0; i < 8; i++)
1491 for (j = 0; j < 4; j++)
1492 if (bufsize >= size[j]) {
1493 buffer->size = size[j];
1494 size[j] *= 2;
1495 buffer->sizeregval = i * 4 + j + 1;
1496 } else
1497 goto exitloop;
1498 exitloop:
1499 if (buffer->size == 0) {
1500 buffer->size = 384;
1501 buffer->sizeregval = 0x01;
1502 }
1503 }
1504
1505 /* adjust the fragment size so that buffer size is an integer multiple */
1506 while (buffer->size % buffer->fragment_size)
1507 buffer->fragment_size >>= 1;
1508
1509 buffer->numfrags = buffer->size / buffer->fragment_size;
1510 buffer->pages = buffer->size / PAGE_SIZE + ((buffer->size % PAGE_SIZE) ? 1 : 0);
1511
1512 DPD(2, " calculated recording fragment_size -> %d\n", buffer->fragment_size);
1513 DPD(2, " calculated recording numfrags -> %d\n", buffer->numfrags);
1514 DPD(2, " buffer size register -> %#04x\n", buffer->sizeregval);
1515
1516 return;
1517}
1518
1519static void emu10k1_wavein_bh(unsigned long refdata)
1520{
1521 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) refdata;
1522 struct wiinst *wiinst = wave_dev->wiinst;
1523 u32 bytestocopy;
1524 unsigned long flags;
1525
1526 if (!wiinst)
1527 return;
1528
1529 spin_lock_irqsave(&wiinst->lock, flags);
1530
1531 if (!(wiinst->state & WAVE_STATE_STARTED)) {
1532 spin_unlock_irqrestore(&wiinst->lock, flags);
1533 return;
1534 }
1535
1536 emu10k1_wavein_update(wave_dev->card, wiinst);
1537 emu10k1_wavein_getxfersize(wiinst, &bytestocopy);
1538
1539 spin_unlock_irqrestore(&wiinst->lock, flags);
1540
1541 if (bytestocopy >= wiinst->buffer.fragment_size) {
1542 if (waitqueue_active(&wiinst->wait_queue))
1543 wake_up_interruptible(&wiinst->wait_queue);
1544 } else
1545 DPD(3, "Not enough transfer size, %d\n", bytestocopy);
1546
1547 return;
1548}
1549
1550static void emu10k1_waveout_bh(unsigned long refdata)
1551{
1552 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) refdata;
1553 struct woinst *woinst = wave_dev->woinst;
1554 u32 bytestocopy;
1555 unsigned long flags;
1556
1557 if (!woinst)
1558 return;
1559
1560 spin_lock_irqsave(&woinst->lock, flags);
1561
1562 if (!(woinst->state & WAVE_STATE_STARTED)) {
1563 spin_unlock_irqrestore(&woinst->lock, flags);
1564 return;
1565 }
1566
1567 emu10k1_waveout_update(woinst);
1568 emu10k1_waveout_getxfersize(woinst, &bytestocopy);
1569
1570 if (woinst->buffer.fill_silence) {
1571 spin_unlock_irqrestore(&woinst->lock, flags);
1572 emu10k1_waveout_fillsilence(woinst);
1573 } else
1574 spin_unlock_irqrestore(&woinst->lock, flags);
1575
1576 if (bytestocopy >= woinst->buffer.fragment_size) {
1577 if (waitqueue_active(&woinst->wait_queue))
1578 wake_up_interruptible(&woinst->wait_queue);
1579 } else
1580 DPD(3, "Not enough transfer size -> %d\n", bytestocopy);
1581
1582 return;
1583}
1584
1585const struct file_operations emu10k1_audio_fops = {
1586 .owner = THIS_MODULE,
1587 .llseek = no_llseek,
1588 .read = emu10k1_audio_read,
1589 .write = emu10k1_audio_write,
1590 .poll = emu10k1_audio_poll,
1591 .ioctl = emu10k1_audio_ioctl,
1592 .mmap = emu10k1_audio_mmap,
1593 .open = emu10k1_audio_open,
1594 .release = emu10k1_audio_release,
1595};
diff --git a/sound/oss/emu10k1/audio.h b/sound/oss/emu10k1/audio.h
deleted file mode 100644
index 26ee81bbd6c..00000000000
--- a/sound/oss/emu10k1/audio.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 **********************************************************************
3 * audio.c -- /dev/dsp interface for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up types/leaks
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#ifndef _AUDIO_H
34#define _AUDIO_H
35
36struct emu10k1_wavedevice
37{
38 struct emu10k1_card *card;
39 struct wiinst *wiinst;
40 struct woinst *woinst;
41 u16 enablebits;
42};
43
44#endif /* _AUDIO_H */
diff --git a/sound/oss/emu10k1/cardmi.c b/sound/oss/emu10k1/cardmi.c
deleted file mode 100644
index 57674f8c8a2..00000000000
--- a/sound/oss/emu10k1/cardmi.c
+++ /dev/null
@@ -1,832 +0,0 @@
1/*
2 **********************************************************************
3 * sblive_mi.c - MIDI UART input HAL for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox clean up
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include <linux/slab.h>
34#include <linux/jiffies.h>
35
36#include "hwaccess.h"
37#include "8010.h"
38#include "cardmi.h"
39#include "irqmgr.h"
40
41
42static int emu10k1_mpuin_callback(struct emu10k1_mpuin *card_mpuin, u32 msg, unsigned long data, u32 bytesvalid);
43
44static int sblive_miStateInit(struct emu10k1_mpuin *);
45static int sblive_miStateEntry(struct emu10k1_mpuin *, u8);
46static int sblive_miStateParse(struct emu10k1_mpuin *, u8);
47static int sblive_miState3Byte(struct emu10k1_mpuin *, u8);
48static int sblive_miState3ByteKey(struct emu10k1_mpuin *, u8);
49static int sblive_miState3ByteVel(struct emu10k1_mpuin *, u8);
50static int sblive_miState2Byte(struct emu10k1_mpuin *, u8);
51static int sblive_miState2ByteKey(struct emu10k1_mpuin *, u8);
52static int sblive_miStateSysCommon2(struct emu10k1_mpuin *, u8);
53static int sblive_miStateSysCommon2Key(struct emu10k1_mpuin *, u8);
54static int sblive_miStateSysCommon3(struct emu10k1_mpuin *, u8);
55static int sblive_miStateSysCommon3Key(struct emu10k1_mpuin *, u8);
56static int sblive_miStateSysCommon3Vel(struct emu10k1_mpuin *, u8);
57static int sblive_miStateSysExNorm(struct emu10k1_mpuin *, u8);
58static int sblive_miStateSysReal(struct emu10k1_mpuin *, u8);
59
60
61static struct {
62 int (*Fn) (struct emu10k1_mpuin *, u8);
63} midistatefn[] = {
64
65 {
66 sblive_miStateParse}, {
67 sblive_miState3Byte}, /* 0x8n, 0x9n, 0xAn, 0xBn, 0xEn */
68 {
69 sblive_miState3ByteKey}, /* Byte 1 */
70 {
71 sblive_miState3ByteVel}, /* Byte 2 */
72 {
73 sblive_miState2Byte}, /* 0xCn, 0xDn */
74 {
75 sblive_miState2ByteKey}, /* Byte 1 */
76 {
77 sblive_miStateSysCommon2}, /* 0xF1 , 0xF3 */
78 {
79 sblive_miStateSysCommon2Key}, /* 0xF1 , 0xF3, Byte 1 */
80 {
81 sblive_miStateSysCommon3}, /* 0xF2 */
82 {
83 sblive_miStateSysCommon3Key}, /* 0xF2 , Byte 1 */
84 {
85 sblive_miStateSysCommon3Vel}, /* 0xF2 , Byte 2 */
86 {
87 sblive_miStateSysExNorm}, /* 0xF0, 0xF7, Normal mode */
88 {
89 sblive_miStateSysReal} /* 0xF4 - 0xF6 ,0xF8 - 0xFF */
90};
91
92
93/* Installs the IRQ handler for the MPU in port */
94
95/* and initialize parameters */
96
97int emu10k1_mpuin_open(struct emu10k1_card *card, struct midi_openinfo *openinfo)
98{
99 struct emu10k1_mpuin *card_mpuin = card->mpuin;
100
101 DPF(2, "emu10k1_mpuin_open\n");
102
103 if (!(card_mpuin->status & FLAGS_AVAILABLE))
104 return -1;
105
106 /* Copy open info and mark channel as in use */
107 card_mpuin->openinfo = *openinfo;
108 card_mpuin->status &= ~FLAGS_AVAILABLE; /* clear */
109 card_mpuin->status |= FLAGS_READY; /* set */
110 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
111 card_mpuin->firstmidiq = NULL;
112 card_mpuin->lastmidiq = NULL;
113 card_mpuin->qhead = 0;
114 card_mpuin->qtail = 0;
115
116 sblive_miStateInit(card_mpuin);
117
118 emu10k1_mpu_reset(card);
119 emu10k1_mpu_acquire(card);
120
121 return 0;
122}
123
124int emu10k1_mpuin_close(struct emu10k1_card *card)
125{
126 struct emu10k1_mpuin *card_mpuin = card->mpuin;
127
128 DPF(2, "emu10k1_mpuin_close()\n");
129
130 /* Check if there are pending input SysEx buffers */
131 if (card_mpuin->firstmidiq != NULL) {
132 ERROR();
133 return -1;
134 }
135
136 /* Disable RX interrupt */
137 emu10k1_irq_disable(card, card->is_audigy ? A_INTE_MIDIRXENABLE : INTE_MIDIRXENABLE);
138
139 emu10k1_mpu_release(card);
140
141 card_mpuin->status |= FLAGS_AVAILABLE; /* set */
142 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
143
144 return 0;
145}
146
147/* Adds MIDI buffer to local queue list */
148
149int emu10k1_mpuin_add_buffer(struct emu10k1_mpuin *card_mpuin, struct midi_hdr *midihdr)
150{
151 struct midi_queue *midiq;
152 unsigned long flags;
153
154 DPF(2, "emu10k1_mpuin_add_buffer()\n");
155
156 /* Update MIDI buffer flags */
157 midihdr->flags |= MIDIBUF_INQUEUE; /* set */
158 midihdr->flags &= ~MIDIBUF_DONE; /* clear */
159
160 if ((midiq = kmalloc(sizeof(struct midi_queue), GFP_ATOMIC)) == NULL) {
161 /* Message lost */
162 return -1;
163 }
164
165 midiq->next = NULL;
166 midiq->qtype = 1;
167 midiq->length = midihdr->bufferlength;
168 midiq->sizeLeft = midihdr->bufferlength;
169 midiq->midibyte = midihdr->data;
170 midiq->refdata = (unsigned long) midihdr;
171
172 spin_lock_irqsave(&card_mpuin->lock, flags);
173
174 if (card_mpuin->firstmidiq == NULL) {
175 card_mpuin->firstmidiq = midiq;
176 card_mpuin->lastmidiq = midiq;
177 } else {
178 (card_mpuin->lastmidiq)->next = midiq;
179 card_mpuin->lastmidiq = midiq;
180 }
181
182 spin_unlock_irqrestore(&card_mpuin->lock, flags);
183
184 return 0;
185}
186
187/* First set the Time Stamp if MIDI IN has not started. */
188
189/* Then enable RX Irq. */
190
191int emu10k1_mpuin_start(struct emu10k1_card *card)
192{
193 struct emu10k1_mpuin *card_mpuin = card->mpuin;
194 u8 dummy;
195
196 DPF(2, "emu10k1_mpuin_start()\n");
197
198 /* Set timestamp if not set */
199 if (card_mpuin->status & FLAGS_MIDM_STARTED) {
200 DPF(2, "Time Stamp not changed\n");
201 } else {
202 while (!emu10k1_mpu_read_data(card, &dummy));
203
204 card_mpuin->status |= FLAGS_MIDM_STARTED; /* set */
205
206 /* Set new time stamp */
207 card_mpuin->timestart = (jiffies * 1000) / HZ;
208 DPD(2, "New Time Stamp = %d\n", card_mpuin->timestart);
209
210 card_mpuin->qhead = 0;
211 card_mpuin->qtail = 0;
212
213 emu10k1_irq_enable(card, card->is_audigy ? A_INTE_MIDIRXENABLE : INTE_MIDIRXENABLE);
214 }
215
216 return 0;
217}
218
219/* Disable the RX Irq. If a partial recorded buffer */
220
221/* exist, send it up to IMIDI level. */
222
223int emu10k1_mpuin_stop(struct emu10k1_card *card)
224{
225 struct emu10k1_mpuin *card_mpuin = card->mpuin;
226 struct midi_queue *midiq;
227 unsigned long flags;
228
229 DPF(2, "emu10k1_mpuin_stop()\n");
230
231 emu10k1_irq_disable(card, card->is_audigy ? A_INTE_MIDIRXENABLE : INTE_MIDIRXENABLE);
232
233 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
234
235 if (card_mpuin->firstmidiq) {
236 spin_lock_irqsave(&card_mpuin->lock, flags);
237
238 midiq = card_mpuin->firstmidiq;
239 if (midiq != NULL) {
240 if (midiq->sizeLeft == midiq->length)
241 midiq = NULL;
242 else {
243 card_mpuin->firstmidiq = midiq->next;
244 if (card_mpuin->firstmidiq == NULL)
245 card_mpuin->lastmidiq = NULL;
246 }
247 }
248
249 spin_unlock_irqrestore(&card_mpuin->lock, flags);
250
251 if (midiq) {
252 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
253 kfree(midiq);
254 }
255 }
256
257 return 0;
258}
259
260/* Disable the RX Irq. If any buffer */
261
262/* exist, send it up to IMIDI level. */
263int emu10k1_mpuin_reset(struct emu10k1_card *card)
264{
265 struct emu10k1_mpuin *card_mpuin = card->mpuin;
266 struct midi_queue *midiq;
267
268 DPF(2, "emu10k1_mpuin_reset()\n");
269
270 emu10k1_irq_disable(card, card->is_audigy ? A_INTE_MIDIRXENABLE : INTE_MIDIRXENABLE);
271
272 while (card_mpuin->firstmidiq) {
273 midiq = card_mpuin->firstmidiq;
274 card_mpuin->firstmidiq = midiq->next;
275
276 if (midiq->sizeLeft == midiq->length)
277 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
278 else
279 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
280
281 kfree(midiq);
282 }
283
284 card_mpuin->lastmidiq = NULL;
285 card_mpuin->status &= ~FLAGS_MIDM_STARTED;
286
287 return 0;
288}
289
290/* Passes the message with the data back to the client */
291
292/* via IRQ & DPC callbacks to Ring 3 */
293static int emu10k1_mpuin_callback(struct emu10k1_mpuin *card_mpuin, u32 msg, unsigned long data, u32 bytesvalid)
294{
295 unsigned long timein;
296 struct midi_queue *midiq;
297 unsigned long callback_msg[3];
298 struct midi_hdr *midihdr;
299
300 /* Called during ISR. The data & code touched are:
301 * 1. card_mpuin
302 * 2. The function to be called
303 */
304
305 timein = card_mpuin->timein;
306 if (card_mpuin->timestart <= timein)
307 callback_msg[0] = timein - card_mpuin->timestart;
308 else
309 callback_msg[0] = (~0x0L - card_mpuin->timestart) + timein;
310
311 if (msg == ICARDMIDI_INDATA || msg == ICARDMIDI_INDATAERROR) {
312 callback_msg[1] = data;
313 callback_msg[2] = bytesvalid;
314 DPD(2, "emu10k1_mpuin_callback: midimsg = %#lx\n", data);
315 } else {
316 midiq = (struct midi_queue *) data;
317 midihdr = (struct midi_hdr *) midiq->refdata;
318
319 callback_msg[1] = midiq->length - midiq->sizeLeft;
320 callback_msg[2] = midiq->refdata;
321 midihdr->flags &= ~MIDIBUF_INQUEUE;
322 midihdr->flags |= MIDIBUF_DONE;
323
324 midihdr->bytesrecorded = midiq->length - midiq->sizeLeft;
325 }
326
327 /* Notify client that Sysex buffer has been sent */
328 emu10k1_midi_callback(msg, card_mpuin->openinfo.refdata, callback_msg);
329
330 return 0;
331}
332
333void emu10k1_mpuin_bh(unsigned long refdata)
334{
335 u8 data;
336 unsigned idx;
337 struct emu10k1_mpuin *card_mpuin = (struct emu10k1_mpuin *) refdata;
338 unsigned long flags;
339
340 while (card_mpuin->qhead != card_mpuin->qtail) {
341 spin_lock_irqsave(&card_mpuin->lock, flags);
342 idx = card_mpuin->qhead;
343 data = card_mpuin->midiq[idx].data;
344 card_mpuin->timein = card_mpuin->midiq[idx].timein;
345 idx = (idx + 1) % MIDIIN_MAX_BUFFER_SIZE;
346 card_mpuin->qhead = idx;
347 spin_unlock_irqrestore(&card_mpuin->lock, flags);
348
349 sblive_miStateEntry(card_mpuin, data);
350 }
351
352 return;
353}
354
355/* IRQ callback handler routine for the MPU in port */
356
357int emu10k1_mpuin_irqhandler(struct emu10k1_card *card)
358{
359 unsigned idx;
360 unsigned count;
361 u8 MPUIvalue;
362 struct emu10k1_mpuin *card_mpuin = card->mpuin;
363
364 /* IRQ service routine. The data and code touched are:
365 * 1. card_mpuin
366 */
367
368 count = 0;
369 idx = card_mpuin->qtail;
370
371 while (1) {
372 if (emu10k1_mpu_read_data(card, &MPUIvalue) < 0) {
373 break;
374 } else {
375 ++count;
376 card_mpuin->midiq[idx].data = MPUIvalue;
377 card_mpuin->midiq[idx].timein = (jiffies * 1000) / HZ;
378 idx = (idx + 1) % MIDIIN_MAX_BUFFER_SIZE;
379 }
380 }
381
382 if (count) {
383 card_mpuin->qtail = idx;
384
385 tasklet_hi_schedule(&card_mpuin->tasklet);
386 }
387
388 return 0;
389}
390
391/*****************************************************************************/
392
393/* Supporting functions for Midi-In Interpretation State Machine */
394
395/*****************************************************************************/
396
397/* FIXME: This should be a macro */
398static int sblive_miStateInit(struct emu10k1_mpuin *card_mpuin)
399{
400 card_mpuin->status = 0; /* For MIDI running status */
401 card_mpuin->fstatus = 0; /* For 0xFn status only */
402 card_mpuin->curstate = STIN_PARSE;
403 card_mpuin->laststate = STIN_PARSE;
404 card_mpuin->data = 0;
405 card_mpuin->timestart = 0;
406 card_mpuin->timein = 0;
407
408 return 0;
409}
410
411/* FIXME: This should be a macro */
412static int sblive_miStateEntry(struct emu10k1_mpuin *card_mpuin, u8 data)
413{
414 return midistatefn[card_mpuin->curstate].Fn(card_mpuin, data);
415}
416
417static int sblive_miStateParse(struct emu10k1_mpuin *card_mpuin, u8 data)
418{
419 switch (data & 0xf0) {
420 case 0x80:
421 case 0x90:
422 case 0xA0:
423 case 0xB0:
424 case 0xE0:
425 card_mpuin->curstate = STIN_3BYTE;
426 break;
427
428 case 0xC0:
429 case 0xD0:
430 card_mpuin->curstate = STIN_2BYTE;
431 break;
432
433 case 0xF0:
434 /* System messages do not affect the previous running status! */
435 switch (data & 0x0f) {
436 case 0x0:
437 card_mpuin->laststate = card_mpuin->curstate;
438 card_mpuin->curstate = STIN_SYS_EX_NORM;
439
440 if (card_mpuin->firstmidiq) {
441 struct midi_queue *midiq;
442
443 midiq = card_mpuin->firstmidiq;
444 *midiq->midibyte = data;
445 --midiq->sizeLeft;
446 ++midiq->midibyte;
447 }
448
449 return CTSTATUS_NEXT_BYTE;
450
451 case 0x7:
452 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, 0xf7, 0);
453 return -1;
454
455 case 0x2:
456 card_mpuin->laststate = card_mpuin->curstate;
457 card_mpuin->curstate = STIN_SYS_COMMON_3;
458 break;
459
460 case 0x1:
461 case 0x3:
462 card_mpuin->laststate = card_mpuin->curstate;
463 card_mpuin->curstate = STIN_SYS_COMMON_2;
464 break;
465
466 default:
467 /* includes 0xF4 - 0xF6, 0xF8 - 0xFF */
468 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
469 }
470
471 break;
472
473 default:
474 DPF(2, "BUG: default case hit\n");
475 return -1;
476 }
477
478 return midistatefn[card_mpuin->curstate].Fn(card_mpuin, data);
479}
480
481static int sblive_miState3Byte(struct emu10k1_mpuin *card_mpuin, u8 data)
482{
483 u8 temp = data & 0xf0;
484
485 if (temp < 0x80) {
486 return midistatefn[STIN_3BYTE_KEY].Fn(card_mpuin, data);
487 } else if (temp <= 0xe0 && temp != 0xc0 && temp != 0xd0) {
488 card_mpuin->status = data;
489 card_mpuin->curstate = STIN_3BYTE_KEY;
490
491 return CTSTATUS_NEXT_BYTE;
492 }
493
494 return midistatefn[STIN_PARSE].Fn(card_mpuin, data);
495}
496
497static int sblive_miState3ByteKey(struct emu10k1_mpuin *card_mpuin, u8 data)
498/* byte 1 */
499{
500 unsigned long tmp;
501
502 if (data > 0x7f) {
503 /* Real-time messages check */
504 if (data > 0xf7)
505 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
506
507 /* Invalid data! */
508 DPF(2, "Invalid data!\n");
509
510 card_mpuin->curstate = STIN_PARSE;
511 tmp = ((unsigned long) data) << 8;
512 tmp |= (unsigned long) card_mpuin->status;
513
514 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
515
516 return -1;
517 }
518
519 card_mpuin->data = data;
520 card_mpuin->curstate = STIN_3BYTE_VEL;
521
522 return CTSTATUS_NEXT_BYTE;
523}
524
525static int sblive_miState3ByteVel(struct emu10k1_mpuin *card_mpuin, u8 data)
526/* byte 2 */
527{
528 unsigned long tmp;
529
530 if (data > 0x7f) {
531 /* Real-time messages check */
532 if (data > 0xf7)
533 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
534
535 /* Invalid data! */
536 DPF(2, "Invalid data!\n");
537
538 card_mpuin->curstate = STIN_PARSE;
539 tmp = ((unsigned long) data) << 8;
540 tmp |= card_mpuin->data;
541 tmp = tmp << 8;
542 tmp |= (unsigned long) card_mpuin->status;
543
544 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
545
546 return -1;
547 }
548
549 card_mpuin->curstate = STIN_3BYTE;
550 tmp = (unsigned long) data;
551 tmp = tmp << 8;
552 tmp |= (unsigned long) card_mpuin->data;
553 tmp = tmp << 8;
554 tmp |= (unsigned long) card_mpuin->status;
555
556 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 3);
557
558 return 0;
559}
560
561static int sblive_miState2Byte(struct emu10k1_mpuin *card_mpuin, u8 data)
562{
563 u8 temp = data & 0xf0;
564
565 if ((temp == 0xc0) || (temp == 0xd0)) {
566 card_mpuin->status = data;
567 card_mpuin->curstate = STIN_2BYTE_KEY;
568
569 return CTSTATUS_NEXT_BYTE;
570 }
571
572 if (temp < 0x80)
573 return midistatefn[STIN_2BYTE_KEY].Fn(card_mpuin, data);
574
575 return midistatefn[STIN_PARSE].Fn(card_mpuin, data);
576}
577
578static int sblive_miState2ByteKey(struct emu10k1_mpuin *card_mpuin, u8 data)
579/* byte 1 */
580{
581 unsigned long tmp;
582
583 if (data > 0x7f) {
584 /* Real-time messages check */
585 if (data > 0xf7)
586 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
587
588 /* Invalid data! */
589 DPF(2, "Invalid data!\n");
590
591 card_mpuin->curstate = STIN_PARSE;
592 tmp = (unsigned long) data;
593 tmp = tmp << 8;
594 tmp |= (unsigned long) card_mpuin->status;
595
596 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
597
598 return -1;
599 }
600
601 card_mpuin->curstate = STIN_2BYTE;
602 tmp = (unsigned long) data;
603 tmp = tmp << 8;
604 tmp |= (unsigned long) card_mpuin->status;
605
606 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 2);
607
608 return 0;
609}
610
611static int sblive_miStateSysCommon2(struct emu10k1_mpuin *card_mpuin, u8 data)
612{
613 card_mpuin->fstatus = data;
614 card_mpuin->curstate = STIN_SYS_COMMON_2_KEY;
615
616 return CTSTATUS_NEXT_BYTE;
617}
618
619static int sblive_miStateSysCommon2Key(struct emu10k1_mpuin *card_mpuin, u8 data)
620/* byte 1 */
621{
622 unsigned long tmp;
623
624 if (data > 0x7f) {
625 /* Real-time messages check */
626 if (data > 0xf7)
627 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
628
629 /* Invalid data! */
630 DPF(2, "Invalid data!\n");
631
632 card_mpuin->curstate = card_mpuin->laststate;
633 tmp = (unsigned long) data;
634 tmp = tmp << 8;
635 tmp |= (unsigned long) card_mpuin->fstatus;
636
637 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
638
639 return -1;
640 }
641
642 card_mpuin->curstate = card_mpuin->laststate;
643 tmp = (unsigned long) data;
644 tmp = tmp << 8;
645 tmp |= (unsigned long) card_mpuin->fstatus;
646
647 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 2);
648
649 return 0;
650}
651
652static int sblive_miStateSysCommon3(struct emu10k1_mpuin *card_mpuin, u8 data)
653{
654 card_mpuin->fstatus = data;
655 card_mpuin->curstate = STIN_SYS_COMMON_3_KEY;
656
657 return CTSTATUS_NEXT_BYTE;
658}
659
660static int sblive_miStateSysCommon3Key(struct emu10k1_mpuin *card_mpuin, u8 data)
661/* byte 1 */
662{
663 unsigned long tmp;
664
665 if (data > 0x7f) {
666 /* Real-time messages check */
667 if (data > 0xf7)
668 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
669
670 /* Invalid data! */
671 DPF(2, "Invalid data!\n");
672
673 card_mpuin->curstate = card_mpuin->laststate;
674 tmp = (unsigned long) data;
675 tmp = tmp << 8;
676 tmp |= (unsigned long) card_mpuin->fstatus;
677
678 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
679
680 return -1;
681 }
682
683 card_mpuin->data = data;
684 card_mpuin->curstate = STIN_SYS_COMMON_3_VEL;
685
686 return CTSTATUS_NEXT_BYTE;
687}
688
689static int sblive_miStateSysCommon3Vel(struct emu10k1_mpuin *card_mpuin, u8 data)
690/* byte 2 */
691{
692 unsigned long tmp;
693
694 if (data > 0x7f) {
695 /* Real-time messages check */
696 if (data > 0xf7)
697 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
698
699 /* Invalid data! */
700 DPF(2, "Invalid data!\n");
701
702 card_mpuin->curstate = card_mpuin->laststate;
703 tmp = (unsigned long) data;
704 tmp = tmp << 8;
705 tmp |= (unsigned long) card_mpuin->data;
706 tmp = tmp << 8;
707 tmp |= (unsigned long) card_mpuin->fstatus;
708
709 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
710
711 return -1;
712 }
713
714 card_mpuin->curstate = card_mpuin->laststate;
715 tmp = (unsigned long) data;
716 tmp = tmp << 8;
717 tmp |= (unsigned long) card_mpuin->data;
718 tmp = tmp << 8;
719 tmp |= (unsigned long) card_mpuin->fstatus;
720
721 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 3);
722
723 return 0;
724}
725
726static int sblive_miStateSysExNorm(struct emu10k1_mpuin *card_mpuin, u8 data)
727{
728 unsigned long flags;
729
730 if ((data > 0x7f) && (data != 0xf7)) {
731 /* Real-time messages check */
732 if (data > 0xf7)
733 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
734
735 /* Invalid Data! */
736 DPF(2, "Invalid data!\n");
737
738 card_mpuin->curstate = card_mpuin->laststate;
739
740 if (card_mpuin->firstmidiq) {
741 struct midi_queue *midiq;
742
743 midiq = card_mpuin->firstmidiq;
744 *midiq->midibyte = data;
745 --midiq->sizeLeft;
746 ++midiq->midibyte;
747
748 spin_lock_irqsave(&card_mpuin->lock, flags);
749
750 card_mpuin->firstmidiq = midiq->next;
751 if (card_mpuin->firstmidiq == NULL)
752 card_mpuin->lastmidiq = NULL;
753
754 spin_unlock_irqrestore(&card_mpuin->lock, flags);
755
756 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
757
758 kfree(midiq);
759 }
760
761 return -1;
762 }
763
764 if (card_mpuin->firstmidiq) {
765 struct midi_queue *midiq;
766
767 midiq = card_mpuin->firstmidiq;
768 *midiq->midibyte = data;
769 --midiq->sizeLeft;
770 ++midiq->midibyte;
771 }
772
773 if (data == 0xf7) {
774 /* End of Sysex buffer */
775 /* Send down the buffer */
776
777 card_mpuin->curstate = card_mpuin->laststate;
778
779 if (card_mpuin->firstmidiq) {
780 struct midi_queue *midiq;
781
782 midiq = card_mpuin->firstmidiq;
783
784 spin_lock_irqsave(&card_mpuin->lock, flags);
785
786 card_mpuin->firstmidiq = midiq->next;
787 if (card_mpuin->firstmidiq == NULL)
788 card_mpuin->lastmidiq = NULL;
789
790 spin_unlock_irqrestore(&card_mpuin->lock, flags);
791
792 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
793
794 kfree(midiq);
795 }
796
797 return 0;
798 }
799
800 if (card_mpuin->firstmidiq) {
801 struct midi_queue *midiq;
802
803 midiq = card_mpuin->firstmidiq;
804
805 if (midiq->sizeLeft == 0) {
806 /* Special case */
807
808 spin_lock_irqsave(&card_mpuin->lock, flags);
809
810 card_mpuin->firstmidiq = midiq->next;
811 if (card_mpuin->firstmidiq == NULL)
812 card_mpuin->lastmidiq = NULL;
813
814 spin_unlock_irqrestore(&card_mpuin->lock, flags);
815
816 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
817
818 kfree(midiq);
819
820 return CTSTATUS_NEXT_BYTE;
821 }
822 }
823
824 return CTSTATUS_NEXT_BYTE;
825}
826
827static int sblive_miStateSysReal(struct emu10k1_mpuin *card_mpuin, u8 data)
828{
829 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, data, 1);
830
831 return CTSTATUS_NEXT_BYTE;
832}
diff --git a/sound/oss/emu10k1/cardmi.h b/sound/oss/emu10k1/cardmi.h
deleted file mode 100644
index d12c2411630..00000000000
--- a/sound/oss/emu10k1/cardmi.h
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 **********************************************************************
3 * sblive_mi.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#ifndef _CARDMI_H
34#define _CARDMI_H
35
36#include "icardmid.h"
37#include <linux/interrupt.h>
38
39typedef enum
40{
41 STIN_PARSE = 0,
42 STIN_3BYTE, /* 0x80, 0x90, 0xA0, 0xB0, 0xE0 */
43 STIN_3BYTE_KEY, /* Byte 1 */
44 STIN_3BYTE_VEL, /* Byte 1 */
45 STIN_2BYTE, /* 0xC0, 0xD0 */
46 STIN_2BYTE_KEY, /* Byte 1 */
47 STIN_SYS_COMMON_2, /* 0xF1, 0xF3 */
48 STIN_SYS_COMMON_2_KEY,
49 STIN_SYS_COMMON_3, /* 0xF2 */
50 STIN_SYS_COMMON_3_KEY,
51 STIN_SYS_COMMON_3_VEL,
52 STIN_SYS_EX_NORM, /* 0xF0, Normal mode */
53 STIN_SYS_REAL
54} midi_in_state;
55
56
57/* flags for card MIDI in object */
58#define FLAGS_MIDM_STARTED 0x00001000 // Data has started to come in after Midm Start
59#define MIDIIN_MAX_BUFFER_SIZE 200 // Definition for struct emu10k1_mpuin
60
61struct midi_data
62{
63 u8 data;
64 u32 timein;
65};
66
67struct emu10k1_mpuin
68{
69 spinlock_t lock;
70 struct midi_queue *firstmidiq;
71 struct midi_queue *lastmidiq;
72 unsigned qhead, qtail;
73 struct midi_data midiq[MIDIIN_MAX_BUFFER_SIZE];
74 struct tasklet_struct tasklet;
75 struct midi_openinfo openinfo;
76
77 /* For MIDI state machine */
78 u8 status; /* For MIDI running status */
79 u8 fstatus; /* For 0xFn status only */
80 midi_in_state curstate;
81 midi_in_state laststate;
82 u32 timestart;
83 u32 timein;
84 u8 data;
85};
86
87int emu10k1_mpuin_open(struct emu10k1_card *, struct midi_openinfo *);
88int emu10k1_mpuin_close(struct emu10k1_card *);
89int emu10k1_mpuin_add_buffer(struct emu10k1_mpuin *, struct midi_hdr *);
90int emu10k1_mpuin_start(struct emu10k1_card *);
91int emu10k1_mpuin_stop(struct emu10k1_card *);
92int emu10k1_mpuin_reset(struct emu10k1_card *);
93
94int emu10k1_mpuin_irqhandler(struct emu10k1_card *);
95void emu10k1_mpuin_bh(unsigned long);
96
97#endif /* _CARDMI_H */
diff --git a/sound/oss/emu10k1/cardmo.c b/sound/oss/emu10k1/cardmo.c
deleted file mode 100644
index a8cc75db3e4..00000000000
--- a/sound/oss/emu10k1/cardmo.c
+++ /dev/null
@@ -1,229 +0,0 @@
1/*
2 **********************************************************************
3 * cardmo.c - MIDI UART output HAL for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include <linux/slab.h>
34
35#include "hwaccess.h"
36#include "8010.h"
37#include "cardmo.h"
38#include "irqmgr.h"
39
40/* Installs the IRQ handler for the MPU out port *
41 * and initialize parameters */
42
43int emu10k1_mpuout_open(struct emu10k1_card *card, struct midi_openinfo *openinfo)
44{
45 struct emu10k1_mpuout *card_mpuout = card->mpuout;
46
47 DPF(2, "emu10k1_mpuout_open()\n");
48
49 if (!(card_mpuout->status & FLAGS_AVAILABLE))
50 return -1;
51
52 /* Copy open info and mark channel as in use */
53 card_mpuout->intr = 0;
54 card_mpuout->openinfo = *openinfo;
55 card_mpuout->status &= ~FLAGS_AVAILABLE;
56 card_mpuout->laststatus = 0x80;
57 card_mpuout->firstmidiq = NULL;
58 card_mpuout->lastmidiq = NULL;
59
60 emu10k1_mpu_reset(card);
61 emu10k1_mpu_acquire(card);
62
63 return 0;
64}
65
66int emu10k1_mpuout_close(struct emu10k1_card *card)
67{
68 struct emu10k1_mpuout *card_mpuout = card->mpuout;
69 struct midi_queue *midiq;
70 struct midi_hdr *midihdr;
71 unsigned long flags;
72
73 DPF(2, "emu10k1_mpuout_close()\n");
74
75 emu10k1_irq_disable(card, card->is_audigy ? A_INTE_MIDITXENABLE : INTE_MIDITXENABLE);
76
77 spin_lock_irqsave(&card_mpuout->lock, flags);
78
79 while (card_mpuout->firstmidiq != NULL) {
80 midiq = card_mpuout->firstmidiq;
81 midihdr = (struct midi_hdr *) midiq->refdata;
82
83 card_mpuout->firstmidiq = midiq->next;
84
85 kfree(midihdr->data);
86 kfree(midihdr);
87 kfree(midiq);
88 }
89
90 card_mpuout->lastmidiq = NULL;
91
92 emu10k1_mpu_release(card);
93
94 card_mpuout->status |= FLAGS_AVAILABLE;
95
96 spin_unlock_irqrestore(&card_mpuout->lock, flags);
97
98 return 0;
99}
100
101/* If there isn't enough buffer space, reject Midi Buffer. *
102* Otherwise, disable TX, create object to hold Midi *
103* uffer, update buffer flags and other parameters *
104* before enabling TX again. */
105
106int emu10k1_mpuout_add_buffer(struct emu10k1_card *card, struct midi_hdr *midihdr)
107{
108 struct emu10k1_mpuout *card_mpuout = card->mpuout;
109 struct midi_queue *midiq;
110 unsigned long flags;
111
112 DPF(2, "emu10k1_mpuout_add_buffer()\n");
113
114 if (card_mpuout->state == CARDMIDIOUT_STATE_SUSPEND)
115 return 0;
116
117 midihdr->flags |= MIDIBUF_INQUEUE;
118 midihdr->flags &= ~MIDIBUF_DONE;
119
120 if ((midiq = kmalloc(sizeof(struct midi_queue), GFP_KERNEL)) == NULL) {
121 /* Message lost */
122 return -1;
123 }
124
125 midiq->next = NULL;
126 midiq->qtype = 1;
127 midiq->length = midihdr->bufferlength;
128 midiq->sizeLeft = midihdr->bufferlength;
129 midiq->midibyte = midihdr->data;
130
131 midiq->refdata = (unsigned long) midihdr;
132
133 spin_lock_irqsave(&card_mpuout->lock, flags);
134
135 if (card_mpuout->firstmidiq == NULL) {
136 card_mpuout->firstmidiq = midiq;
137 card_mpuout->lastmidiq = midiq;
138 } else {
139 (card_mpuout->lastmidiq)->next = midiq;
140 card_mpuout->lastmidiq = midiq;
141 }
142
143 card_mpuout->intr = 0;
144
145 emu10k1_irq_enable(card, card->is_audigy ? A_INTE_MIDITXENABLE : INTE_MIDITXENABLE);
146
147 spin_unlock_irqrestore(&card_mpuout->lock, flags);
148
149 return 0;
150}
151
152void emu10k1_mpuout_bh(unsigned long refdata)
153{
154 struct emu10k1_card *card = (struct emu10k1_card *) refdata;
155 struct emu10k1_mpuout *card_mpuout = card->mpuout;
156 int cByteSent = 0;
157 struct midi_queue *midiq;
158 struct midi_queue *doneq = NULL;
159 unsigned long flags;
160
161 spin_lock_irqsave(&card_mpuout->lock, flags);
162
163 while (card_mpuout->firstmidiq != NULL) {
164 midiq = card_mpuout->firstmidiq;
165
166 while (cByteSent < 4 && midiq->sizeLeft) {
167 if (emu10k1_mpu_write_data(card, *midiq->midibyte) < 0) {
168 DPF(2, "emu10k1_mpuoutDpcCallback error!!\n");
169 } else {
170 ++cByteSent;
171 --midiq->sizeLeft;
172 ++midiq->midibyte;
173 }
174 }
175
176 if (midiq->sizeLeft == 0) {
177 if (doneq == NULL)
178 doneq = midiq;
179 card_mpuout->firstmidiq = midiq->next;
180 } else
181 break;
182 }
183
184 if (card_mpuout->firstmidiq == NULL)
185 card_mpuout->lastmidiq = NULL;
186
187 if (doneq != NULL) {
188 while (doneq != card_mpuout->firstmidiq) {
189 unsigned long callback_msg[3];
190
191 midiq = doneq;
192 doneq = midiq->next;
193
194 if (midiq->qtype) {
195 callback_msg[0] = 0;
196 callback_msg[1] = midiq->length;
197 callback_msg[2] = midiq->refdata;
198
199 emu10k1_midi_callback(ICARDMIDI_OUTLONGDATA, card_mpuout->openinfo.refdata, callback_msg);
200 } else if (((u8) midiq->refdata) < 0xF0 && ((u8) midiq->refdata) > 0x7F)
201 card_mpuout->laststatus = (u8) midiq->refdata;
202
203 kfree(midiq);
204 }
205 }
206
207 if ((card_mpuout->firstmidiq != NULL) || cByteSent) {
208 card_mpuout->intr = 0;
209 emu10k1_irq_enable(card, card->is_audigy ? A_INTE_MIDITXENABLE : INTE_MIDITXENABLE);
210 }
211
212 spin_unlock_irqrestore(&card_mpuout->lock, flags);
213
214 return;
215}
216
217int emu10k1_mpuout_irqhandler(struct emu10k1_card *card)
218{
219 struct emu10k1_mpuout *card_mpuout = card->mpuout;
220
221 DPF(4, "emu10k1_mpuout_irqhandler\n");
222
223 card_mpuout->intr = 1;
224 emu10k1_irq_disable(card, card->is_audigy ? A_INTE_MIDITXENABLE : INTE_MIDITXENABLE);
225
226 tasklet_hi_schedule(&card_mpuout->tasklet);
227
228 return 0;
229}
diff --git a/sound/oss/emu10k1/cardmo.h b/sound/oss/emu10k1/cardmo.h
deleted file mode 100644
index 7026eb3a85a..00000000000
--- a/sound/oss/emu10k1/cardmo.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 **********************************************************************
3 * cardmo.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#ifndef _CARDMO_H
34#define _CARDMO_H
35
36#include "icardmid.h"
37#include <linux/interrupt.h>
38
39#define CARDMIDIOUT_STATE_DEFAULT 0x00000000
40#define CARDMIDIOUT_STATE_SUSPEND 0x00000001
41
42struct emu10k1_mpuout
43{
44 u32 status;
45 u32 state;
46 volatile int intr;
47 struct midi_queue *firstmidiq;
48 struct midi_queue *lastmidiq;
49 u8 laststatus;
50 struct tasklet_struct tasklet;
51 spinlock_t lock;
52 struct midi_openinfo openinfo;
53};
54
55int emu10k1_mpuout_open(struct emu10k1_card *, struct midi_openinfo *);
56int emu10k1_mpuout_close(struct emu10k1_card *);
57int emu10k1_mpuout_add_buffer(struct emu10k1_card *, struct midi_hdr *);
58
59int emu10k1_mpuout_irqhandler(struct emu10k1_card *);
60void emu10k1_mpuout_bh(unsigned long);
61
62#endif /* _CARDMO_H */
diff --git a/sound/oss/emu10k1/cardwi.c b/sound/oss/emu10k1/cardwi.c
deleted file mode 100644
index 060d1be94d3..00000000000
--- a/sound/oss/emu10k1/cardwi.c
+++ /dev/null
@@ -1,384 +0,0 @@
1/*
2 **********************************************************************
3 * cardwi.c - PCM input HAL for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/poll.h>
33#include "hwaccess.h"
34#include "timer.h"
35#include "recmgr.h"
36#include "audio.h"
37#include "cardwi.h"
38
39/**
40 * query_format - returns a valid sound format
41 *
42 * This function will return a valid sound format as close
43 * to the requested one as possible.
44 */
45static void query_format(int recsrc, struct wave_format *wave_fmt)
46{
47
48 switch (recsrc) {
49 case WAVERECORD_AC97:
50
51 if ((wave_fmt->channels != 1) && (wave_fmt->channels != 2))
52 wave_fmt->channels = 2;
53
54 if (wave_fmt->samplingrate >= (0xBB80 + 0xAC44) / 2)
55 wave_fmt->samplingrate = 0xBB80;
56 else if (wave_fmt->samplingrate >= (0xAC44 + 0x7D00) / 2)
57 wave_fmt->samplingrate = 0xAC44;
58 else if (wave_fmt->samplingrate >= (0x7D00 + 0x5DC0) / 2)
59 wave_fmt->samplingrate = 0x7D00;
60 else if (wave_fmt->samplingrate >= (0x5DC0 + 0x5622) / 2)
61 wave_fmt->samplingrate = 0x5DC0;
62 else if (wave_fmt->samplingrate >= (0x5622 + 0x3E80) / 2)
63 wave_fmt->samplingrate = 0x5622;
64 else if (wave_fmt->samplingrate >= (0x3E80 + 0x2B11) / 2)
65 wave_fmt->samplingrate = 0x3E80;
66 else if (wave_fmt->samplingrate >= (0x2B11 + 0x1F40) / 2)
67 wave_fmt->samplingrate = 0x2B11;
68 else
69 wave_fmt->samplingrate = 0x1F40;
70
71 switch (wave_fmt->id) {
72 case AFMT_S16_LE:
73 wave_fmt->bitsperchannel = 16;
74 break;
75 case AFMT_U8:
76 wave_fmt->bitsperchannel = 8;
77 break;
78 default:
79 wave_fmt->id = AFMT_S16_LE;
80 wave_fmt->bitsperchannel = 16;
81 break;
82 }
83
84 break;
85
86 /* these can't be changed from the original values */
87 case WAVERECORD_MIC:
88 case WAVERECORD_FX:
89 break;
90
91 default:
92 BUG();
93 break;
94 }
95
96 wave_fmt->bytesperchannel = wave_fmt->bitsperchannel >> 3;
97 wave_fmt->bytespersample = wave_fmt->channels * wave_fmt->bytesperchannel;
98 wave_fmt->bytespersec = wave_fmt->bytespersample * wave_fmt->samplingrate;
99 wave_fmt->bytespervoicesample = wave_fmt->bytespersample;
100}
101
102static int alloc_buffer(struct emu10k1_card *card, struct wavein_buffer *buffer)
103{
104 buffer->addr = pci_alloc_consistent(card->pci_dev, buffer->size * buffer->cov,
105 &buffer->dma_handle);
106 if (buffer->addr == NULL)
107 return -1;
108
109 return 0;
110}
111
112static void free_buffer(struct emu10k1_card *card, struct wavein_buffer *buffer)
113{
114 if (buffer->addr != NULL)
115 pci_free_consistent(card->pci_dev, buffer->size * buffer->cov,
116 buffer->addr, buffer->dma_handle);
117}
118
119int emu10k1_wavein_open(struct emu10k1_wavedevice *wave_dev)
120{
121 struct emu10k1_card *card = wave_dev->card;
122 struct wiinst *wiinst = wave_dev->wiinst;
123 struct wiinst **wiinst_tmp = NULL;
124 u16 delay;
125 unsigned long flags;
126
127 DPF(2, "emu10k1_wavein_open()\n");
128
129 switch (wiinst->recsrc) {
130 case WAVERECORD_AC97:
131 wiinst_tmp = &card->wavein.ac97;
132 break;
133 case WAVERECORD_MIC:
134 wiinst_tmp = &card->wavein.mic;
135 break;
136 case WAVERECORD_FX:
137 wiinst_tmp = &card->wavein.fx;
138 break;
139 default:
140 BUG();
141 break;
142 }
143
144 spin_lock_irqsave(&card->lock, flags);
145 if (*wiinst_tmp != NULL) {
146 spin_unlock_irqrestore(&card->lock, flags);
147 return -1;
148 }
149
150 *wiinst_tmp = wiinst;
151 spin_unlock_irqrestore(&card->lock, flags);
152
153 /* handle 8 bit recording */
154 if (wiinst->format.bytesperchannel == 1) {
155 if (wiinst->buffer.size > 0x8000) {
156 wiinst->buffer.size = 0x8000;
157 wiinst->buffer.sizeregval = 0x1f;
158 } else
159 wiinst->buffer.sizeregval += 4;
160
161 wiinst->buffer.cov = 2;
162 } else
163 wiinst->buffer.cov = 1;
164
165 if (alloc_buffer(card, &wiinst->buffer) < 0) {
166 ERROR();
167 return -1;
168 }
169
170 emu10k1_set_record_src(card, wiinst);
171
172 emu10k1_reset_record(card, &wiinst->buffer);
173
174 wiinst->buffer.hw_pos = 0;
175 wiinst->buffer.pos = 0;
176 wiinst->buffer.bytestocopy = 0;
177
178 delay = (48000 * wiinst->buffer.fragment_size) / wiinst->format.bytespersec;
179
180 emu10k1_timer_install(card, &wiinst->timer, delay / 2);
181
182 wiinst->state = WAVE_STATE_OPEN;
183
184 return 0;
185}
186
187void emu10k1_wavein_close(struct emu10k1_wavedevice *wave_dev)
188{
189 struct emu10k1_card *card = wave_dev->card;
190 struct wiinst *wiinst = wave_dev->wiinst;
191 unsigned long flags;
192
193 DPF(2, "emu10k1_wavein_close()\n");
194
195 emu10k1_wavein_stop(wave_dev);
196
197 emu10k1_timer_uninstall(card, &wiinst->timer);
198
199 free_buffer(card, &wiinst->buffer);
200
201 spin_lock_irqsave(&card->lock, flags);
202 switch (wave_dev->wiinst->recsrc) {
203 case WAVERECORD_AC97:
204 card->wavein.ac97 = NULL;
205 break;
206 case WAVERECORD_MIC:
207 card->wavein.mic = NULL;
208 break;
209 case WAVERECORD_FX:
210 card->wavein.fx = NULL;
211 break;
212 default:
213 BUG();
214 break;
215 }
216 spin_unlock_irqrestore(&card->lock, flags);
217
218 wiinst->state = WAVE_STATE_CLOSED;
219}
220
221void emu10k1_wavein_start(struct emu10k1_wavedevice *wave_dev)
222{
223 struct emu10k1_card *card = wave_dev->card;
224 struct wiinst *wiinst = wave_dev->wiinst;
225
226 DPF(2, "emu10k1_wavein_start()\n");
227
228 emu10k1_start_record(card, &wiinst->buffer);
229 emu10k1_timer_enable(wave_dev->card, &wiinst->timer);
230
231 wiinst->state |= WAVE_STATE_STARTED;
232}
233
234void emu10k1_wavein_stop(struct emu10k1_wavedevice *wave_dev)
235{
236 struct emu10k1_card *card = wave_dev->card;
237 struct wiinst *wiinst = wave_dev->wiinst;
238
239 DPF(2, "emu10k1_wavein_stop()\n");
240
241 if (!(wiinst->state & WAVE_STATE_STARTED))
242 return;
243
244 emu10k1_timer_disable(card, &wiinst->timer);
245 emu10k1_stop_record(card, &wiinst->buffer);
246
247 wiinst->state &= ~WAVE_STATE_STARTED;
248}
249
250int emu10k1_wavein_setformat(struct emu10k1_wavedevice *wave_dev, struct wave_format *format)
251{
252 struct emu10k1_card *card = wave_dev->card;
253 struct wiinst *wiinst = wave_dev->wiinst;
254 u16 delay;
255
256 DPF(2, "emu10k1_wavein_setformat()\n");
257
258 if (wiinst->state & WAVE_STATE_STARTED)
259 return -1;
260
261 query_format(wiinst->recsrc, format);
262
263 if ((wiinst->format.samplingrate != format->samplingrate)
264 || (wiinst->format.bitsperchannel != format->bitsperchannel)
265 || (wiinst->format.channels != format->channels)) {
266
267 wiinst->format = *format;
268
269 if (wiinst->state == WAVE_STATE_CLOSED)
270 return 0;
271
272 wiinst->buffer.size *= wiinst->buffer.cov;
273
274 if (wiinst->format.bytesperchannel == 1) {
275 wiinst->buffer.cov = 2;
276 wiinst->buffer.size /= wiinst->buffer.cov;
277 } else
278 wiinst->buffer.cov = 1;
279
280 emu10k1_timer_uninstall(card, &wiinst->timer);
281
282 delay = (48000 * wiinst->buffer.fragment_size) / wiinst->format.bytespersec;
283
284 emu10k1_timer_install(card, &wiinst->timer, delay / 2);
285 }
286
287 return 0;
288}
289
290void emu10k1_wavein_getxfersize(struct wiinst *wiinst, u32 * size)
291{
292 struct wavein_buffer *buffer = &wiinst->buffer;
293
294 *size = buffer->bytestocopy;
295
296 if (wiinst->mmapped)
297 return;
298
299 if (*size > buffer->size) {
300 *size = buffer->size;
301 buffer->pos = buffer->hw_pos;
302 buffer->bytestocopy = buffer->size;
303 DPF(1, "buffer overrun\n");
304 }
305}
306
307static int copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
308{
309 if (cov == 1) {
310 if (__copy_to_user(dst, src + str, len))
311 return -EFAULT;
312 } else {
313 u8 byte;
314 u32 i;
315
316 src += 1 + 2 * str;
317
318 for (i = 0; i < len; i++) {
319 byte = src[2 * i] ^ 0x80;
320 if (__copy_to_user(dst + i, &byte, 1))
321 return -EFAULT;
322 }
323 }
324
325 return 0;
326}
327
328int emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
329{
330 struct wavein_buffer *buffer = &wiinst->buffer;
331 u32 sizetocopy, sizetocopy_now, start;
332 unsigned long flags;
333 int ret;
334
335 sizetocopy = min_t(u32, buffer->size, *size);
336 *size = sizetocopy;
337
338 if (!sizetocopy)
339 return 0;
340
341 spin_lock_irqsave(&wiinst->lock, flags);
342 start = buffer->pos;
343 buffer->pos += sizetocopy;
344 buffer->pos %= buffer->size;
345 buffer->bytestocopy -= sizetocopy;
346 sizetocopy_now = buffer->size - start;
347
348 spin_unlock_irqrestore(&wiinst->lock, flags);
349
350 if (sizetocopy > sizetocopy_now) {
351 sizetocopy -= sizetocopy_now;
352
353 ret = copy_block(data, buffer->addr, start, sizetocopy_now,
354 buffer->cov);
355 if (ret == 0)
356 ret = copy_block(data + sizetocopy_now, buffer->addr, 0,
357 sizetocopy, buffer->cov);
358 } else {
359 ret = copy_block(data, buffer->addr, start, sizetocopy,
360 buffer->cov);
361 }
362
363 return ret;
364}
365
366void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst)
367{
368 u32 hw_pos;
369 u32 diff;
370
371 /* There is no actual start yet */
372 if (!(wiinst->state & WAVE_STATE_STARTED)) {
373 hw_pos = wiinst->buffer.hw_pos;
374 } else {
375 /* hw_pos in byte units */
376 hw_pos = sblive_readptr(card, wiinst->buffer.idxreg, 0) / wiinst->buffer.cov;
377 }
378
379 diff = (wiinst->buffer.size + hw_pos - wiinst->buffer.hw_pos) % wiinst->buffer.size;
380 wiinst->total_recorded += diff;
381 wiinst->buffer.bytestocopy += diff;
382
383 wiinst->buffer.hw_pos = hw_pos;
384}
diff --git a/sound/oss/emu10k1/cardwi.h b/sound/oss/emu10k1/cardwi.h
deleted file mode 100644
index e82029b46ad..00000000000
--- a/sound/oss/emu10k1/cardwi.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 **********************************************************************
3 * cardwi.h -- header file for card wave input functions
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31#ifndef _CARDWI_H
32#define _CARDWI_H
33
34#include "icardwav.h"
35#include "audio.h"
36#include "timer.h"
37
38struct wavein_buffer {
39 u16 ossfragshift;
40 u32 fragment_size;
41 u32 numfrags;
42 u32 hw_pos; /* hardware cursor position */
43 u32 pos; /* software cursor position */
44 u32 bytestocopy; /* bytes of recorded data available */
45 u32 size;
46 u32 pages;
47 u32 sizereg;
48 u32 sizeregval;
49 u32 addrreg;
50 u32 idxreg;
51 u32 adcctl;
52 void *addr;
53 u8 cov;
54 dma_addr_t dma_handle;
55};
56
57struct wiinst
58{
59 u8 state;
60 struct emu_timer timer;
61 struct wave_format format;
62 struct wavein_buffer buffer;
63 wait_queue_head_t wait_queue;
64 u8 mmapped;
65 u32 total_recorded; /* total bytes read() from device */
66 u32 blocks;
67 spinlock_t lock;
68 u8 recsrc;
69 u16 fxwc;
70};
71
72#define WAVEIN_MAXBUFSIZE 65536
73#define WAVEIN_MINBUFSIZE 368
74
75#define WAVEIN_DEFAULTFRAGLEN 100
76#define WAVEIN_DEFAULTBUFLEN 1000
77
78#define WAVEIN_MINFRAGSHIFT 8
79#define WAVEIN_MINFRAGS 2
80
81int emu10k1_wavein_open(struct emu10k1_wavedevice *);
82void emu10k1_wavein_close(struct emu10k1_wavedevice *);
83void emu10k1_wavein_start(struct emu10k1_wavedevice *);
84void emu10k1_wavein_stop(struct emu10k1_wavedevice *);
85void emu10k1_wavein_getxfersize(struct wiinst *, u32 *);
86int emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *);
87int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *);
88void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *);
89
90
91#endif /* _CARDWI_H */
diff --git a/sound/oss/emu10k1/cardwo.c b/sound/oss/emu10k1/cardwo.c
deleted file mode 100644
index 54daca4f57b..00000000000
--- a/sound/oss/emu10k1/cardwo.c
+++ /dev/null
@@ -1,643 +0,0 @@
1/*
2 **********************************************************************
3 * cardwo.c - PCM output HAL for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/poll.h>
33#include "hwaccess.h"
34#include "8010.h"
35#include "voicemgr.h"
36#include "cardwo.h"
37#include "audio.h"
38
39static u32 samplerate_to_linearpitch(u32 samplingrate)
40{
41 samplingrate = (samplingrate << 8) / 375;
42 return (samplingrate >> 1) + (samplingrate & 1);
43}
44
45static void query_format(struct emu10k1_wavedevice *wave_dev, struct wave_format *wave_fmt)
46{
47 int i, j, do_passthrough = 0, is_ac3 = 0;
48 struct emu10k1_card *card = wave_dev->card;
49 struct woinst *woinst = wave_dev->woinst;
50
51 if ((wave_fmt->channels > 2) && (wave_fmt->id != AFMT_S16_LE) && (wave_fmt->id != AFMT_U8))
52 wave_fmt->channels = 2;
53
54 if ((wave_fmt->channels < 1) || (wave_fmt->channels > WAVEOUT_MAXVOICES))
55 wave_fmt->channels = 2;
56
57 if (wave_fmt->channels == 2)
58 woinst->num_voices = 1;
59 else
60 woinst->num_voices = wave_fmt->channels;
61
62 if (wave_fmt->samplingrate >= 0x2ee00)
63 wave_fmt->samplingrate = 0x2ee00;
64
65 wave_fmt->passthrough = 0;
66 do_passthrough = is_ac3 = 0;
67
68 if (card->pt.selected)
69 do_passthrough = 1;
70
71 switch (wave_fmt->id) {
72 case AFMT_S16_LE:
73 wave_fmt->bitsperchannel = 16;
74 break;
75 case AFMT_U8:
76 wave_fmt->bitsperchannel = 8;
77 break;
78 case AFMT_AC3:
79 do_passthrough = 1;
80 is_ac3 = 1;
81 break;
82 default:
83 wave_fmt->id = AFMT_S16_LE;
84 wave_fmt->bitsperchannel = 16;
85 break;
86 }
87 if (do_passthrough) {
88 /* currently only one waveout instance may use pass-through */
89 if (woinst->state != WAVE_STATE_CLOSED ||
90 card->pt.state != PT_STATE_INACTIVE ||
91 (wave_fmt->samplingrate != 48000 && !is_ac3)) {
92 DPF(2, "unable to set pass-through mode\n");
93 } else if (USE_PT_METHOD1) {
94 i = emu10k1_find_control_gpr(&card->mgr, card->pt.patch_name, card->pt.intr_gpr_name);
95 j = emu10k1_find_control_gpr(&card->mgr, card->pt.patch_name, card->pt.enable_gpr_name);
96 if (i < 0 || j < 0)
97 DPF(2, "unable to set pass-through mode\n");
98 else {
99 wave_fmt->samplingrate = 48000;
100 wave_fmt->channels = 2;
101 card->pt.pos_gpr = emu10k1_find_control_gpr(&card->mgr, card->pt.patch_name,
102 card->pt.pos_gpr_name);
103 wave_fmt->passthrough = 1;
104 card->pt.intr_gpr = i;
105 card->pt.enable_gpr = j;
106 card->pt.state = PT_STATE_INACTIVE;
107
108 DPD(2, "is_ac3 is %d\n", is_ac3);
109 card->pt.ac3data = is_ac3;
110 wave_fmt->bitsperchannel = 16;
111 }
112 }else{
113 DPF(2, "Using Passthrough Method 2\n");
114 card->pt.enable_gpr = emu10k1_find_control_gpr(&card->mgr, card->pt.patch_name,
115 card->pt.enable_gpr_name);
116 wave_fmt->passthrough = 2;
117 wave_fmt->bitsperchannel = 16;
118 }
119 }
120
121 wave_fmt->bytesperchannel = wave_fmt->bitsperchannel >> 3;
122 wave_fmt->bytespersample = wave_fmt->channels * wave_fmt->bytesperchannel;
123 wave_fmt->bytespersec = wave_fmt->bytespersample * wave_fmt->samplingrate;
124
125 if (wave_fmt->channels == 2)
126 wave_fmt->bytespervoicesample = wave_fmt->channels * wave_fmt->bytesperchannel;
127 else
128 wave_fmt->bytespervoicesample = wave_fmt->bytesperchannel;
129}
130
131static int get_voice(struct emu10k1_card *card, struct woinst *woinst, unsigned int voicenum)
132{
133 struct emu_voice *voice = &woinst->voice[voicenum];
134
135 /* Allocate voices here, if no voices available, return error. */
136
137 voice->usage = VOICE_USAGE_PLAYBACK;
138
139 voice->flags = 0;
140
141 if (woinst->format.channels == 2)
142 voice->flags |= VOICE_FLAGS_STEREO;
143
144 if (woinst->format.bitsperchannel == 16)
145 voice->flags |= VOICE_FLAGS_16BIT;
146
147 if (emu10k1_voice_alloc(card, voice) < 0) {
148 voice->usage = VOICE_USAGE_FREE;
149 return -1;
150 }
151
152 /* Calculate pitch */
153 voice->initial_pitch = (u16) (srToPitch(woinst->format.samplingrate) >> 8);
154 voice->pitch_target = samplerate_to_linearpitch(woinst->format.samplingrate);
155
156 DPD(2, "Initial pitch --> %#x\n", voice->initial_pitch);
157
158 voice->startloop = (voice->mem.emupageindex << 12) /
159 woinst->format.bytespervoicesample;
160 voice->endloop = voice->startloop + woinst->buffer.size / woinst->format.bytespervoicesample;
161 voice->start = voice->startloop;
162
163
164 voice->params[0].volume_target = 0xffff;
165 voice->params[0].initial_fc = 0xff;
166 voice->params[0].initial_attn = 0x00;
167 voice->params[0].byampl_env_sustain = 0x7f;
168 voice->params[0].byampl_env_decay = 0x7f;
169
170
171 if (voice->flags & VOICE_FLAGS_STEREO) {
172 if (woinst->format.passthrough == 2) {
173 voice->params[0].send_routing = voice->params[1].send_routing = card->waveout.send_routing[ROUTE_PT];
174 voice->params[0].send_routing2 = voice->params[1].send_routing2 = card->waveout.send_routing2[ROUTE_PT];
175 voice->params[0].send_dcba = 0xff;
176 voice->params[1].send_dcba = 0xff00;
177 voice->params[0].send_hgfe = voice->params[1].send_hgfe=0;
178 } else {
179 voice->params[0].send_dcba = card->waveout.send_dcba[SEND_LEFT];
180 voice->params[0].send_hgfe = card->waveout.send_hgfe[SEND_LEFT];
181 voice->params[1].send_dcba = card->waveout.send_dcba[SEND_RIGHT];
182 voice->params[1].send_hgfe = card->waveout.send_hgfe[SEND_RIGHT];
183
184 if (woinst->device) {
185 // /dev/dps1
186 voice->params[0].send_routing = voice->params[1].send_routing = card->waveout.send_routing[ROUTE_PCM1];
187 voice->params[0].send_routing2 = voice->params[1].send_routing2 = card->waveout.send_routing2[ROUTE_PCM1];
188 } else {
189 voice->params[0].send_routing = voice->params[1].send_routing = card->waveout.send_routing[ROUTE_PCM];
190 voice->params[0].send_routing2 = voice->params[1].send_routing2 = card->waveout.send_routing2[ROUTE_PCM];
191 }
192 }
193
194 voice->params[1].volume_target = 0xffff;
195 voice->params[1].initial_fc = 0xff;
196 voice->params[1].initial_attn = 0x00;
197 voice->params[1].byampl_env_sustain = 0x7f;
198 voice->params[1].byampl_env_decay = 0x7f;
199 } else {
200 if (woinst->num_voices > 1) {
201 // Multichannel pcm
202 voice->params[0].send_dcba=0xff;
203 voice->params[0].send_hgfe=0;
204 if (card->is_audigy) {
205 voice->params[0].send_routing = 0x3f3f3f00 + card->mchannel_fx + voicenum;
206 voice->params[0].send_routing2 = 0x3f3f3f3f;
207 } else {
208 voice->params[0].send_routing = 0xfff0 + card->mchannel_fx + voicenum;
209 }
210
211 } else {
212 voice->params[0].send_dcba = card->waveout.send_dcba[SEND_MONO];
213 voice->params[0].send_hgfe = card->waveout.send_hgfe[SEND_MONO];
214
215 if (woinst->device) {
216 voice->params[0].send_routing = card->waveout.send_routing[ROUTE_PCM1];
217 voice->params[0].send_routing2 = card->waveout.send_routing2[ROUTE_PCM1];
218 } else {
219 voice->params[0].send_routing = card->waveout.send_routing[ROUTE_PCM];
220 voice->params[0].send_routing2 = card->waveout.send_routing2[ROUTE_PCM];
221 }
222 }
223 }
224
225 DPD(2, "voice: startloop=%#x, endloop=%#x\n", voice->startloop, voice->endloop);
226
227 emu10k1_voice_playback_setup(voice);
228
229 return 0;
230}
231
232int emu10k1_waveout_open(struct emu10k1_wavedevice *wave_dev)
233{
234 struct emu10k1_card *card = wave_dev->card;
235 struct woinst *woinst = wave_dev->woinst;
236 struct waveout_buffer *buffer = &woinst->buffer;
237 unsigned int voicenum;
238 u16 delay;
239
240 DPF(2, "emu10k1_waveout_open()\n");
241
242 for (voicenum = 0; voicenum < woinst->num_voices; voicenum++) {
243 if (emu10k1_voice_alloc_buffer(card, &woinst->voice[voicenum].mem, woinst->buffer.pages) < 0) {
244 ERROR();
245 emu10k1_waveout_close(wave_dev);
246 return -1;
247 }
248
249 if (get_voice(card, woinst, voicenum) < 0) {
250 ERROR();
251 emu10k1_waveout_close(wave_dev);
252 return -1;
253 }
254 }
255
256 buffer->fill_silence = 0;
257 buffer->silence_bytes = 0;
258 buffer->silence_pos = 0;
259 buffer->hw_pos = 0;
260 buffer->free_bytes = woinst->buffer.size;
261
262 delay = (48000 * woinst->buffer.fragment_size) /
263 (woinst->format.samplingrate * woinst->format.bytespervoicesample);
264
265 emu10k1_timer_install(card, &woinst->timer, delay);
266
267 woinst->state = WAVE_STATE_OPEN;
268
269 return 0;
270}
271
272void emu10k1_waveout_close(struct emu10k1_wavedevice *wave_dev)
273{
274 struct emu10k1_card *card = wave_dev->card;
275 struct woinst *woinst = wave_dev->woinst;
276 unsigned int voicenum;
277
278 DPF(2, "emu10k1_waveout_close()\n");
279
280 emu10k1_waveout_stop(wave_dev);
281
282 emu10k1_timer_uninstall(card, &woinst->timer);
283
284 for (voicenum = 0; voicenum < woinst->num_voices; voicenum++) {
285 emu10k1_voice_free(&woinst->voice[voicenum]);
286 emu10k1_voice_free_buffer(card, &woinst->voice[voicenum].mem);
287 }
288
289 woinst->state = WAVE_STATE_CLOSED;
290}
291
292void emu10k1_waveout_start(struct emu10k1_wavedevice *wave_dev)
293{
294 struct emu10k1_card *card = wave_dev->card;
295 struct woinst *woinst = wave_dev->woinst;
296 struct pt_data *pt = &card->pt;
297
298 DPF(2, "emu10k1_waveout_start()\n");
299
300 if (woinst->format.passthrough == 2) {
301 emu10k1_pt_setup(wave_dev);
302 sblive_writeptr(card, (card->is_audigy ? A_GPR_BASE : GPR_BASE) + pt->enable_gpr, 0, 1);
303 pt->state = PT_STATE_PLAYING;
304 }
305
306 /* Actual start */
307 emu10k1_voices_start(woinst->voice, woinst->num_voices, woinst->total_played);
308
309 emu10k1_timer_enable(card, &woinst->timer);
310
311 woinst->state |= WAVE_STATE_STARTED;
312}
313
314int emu10k1_waveout_setformat(struct emu10k1_wavedevice *wave_dev, struct wave_format *format)
315{
316 struct emu10k1_card *card = wave_dev->card;
317 struct woinst *woinst = wave_dev->woinst;
318 unsigned int voicenum;
319 u16 delay;
320
321 DPF(2, "emu10k1_waveout_setformat()\n");
322
323 if (woinst->state & WAVE_STATE_STARTED)
324 return -1;
325
326 query_format(wave_dev, format);
327
328 if (woinst->format.samplingrate != format->samplingrate ||
329 woinst->format.channels != format->channels ||
330 woinst->format.bitsperchannel != format->bitsperchannel) {
331
332 woinst->format = *format;
333
334 if (woinst->state == WAVE_STATE_CLOSED)
335 return 0;
336
337 emu10k1_timer_uninstall(card, &woinst->timer);
338
339 for (voicenum = 0; voicenum < woinst->num_voices; voicenum++) {
340 emu10k1_voice_free(&woinst->voice[voicenum]);
341
342 if (get_voice(card, woinst, voicenum) < 0) {
343 ERROR();
344 emu10k1_waveout_close(wave_dev);
345 return -1;
346 }
347 }
348
349 delay = (48000 * woinst->buffer.fragment_size) /
350 (woinst->format.samplingrate * woinst->format.bytespervoicesample);
351
352 emu10k1_timer_install(card, &woinst->timer, delay);
353 }
354
355 return 0;
356}
357
358void emu10k1_waveout_stop(struct emu10k1_wavedevice *wave_dev)
359{
360 struct emu10k1_card *card = wave_dev->card;
361 struct woinst *woinst = wave_dev->woinst;
362
363 DPF(2, "emu10k1_waveout_stop()\n");
364
365 if (!(woinst->state & WAVE_STATE_STARTED))
366 return;
367
368 emu10k1_timer_disable(card, &woinst->timer);
369
370 /* Stop actual voices */
371 emu10k1_voices_stop(woinst->voice, woinst->num_voices);
372
373 emu10k1_waveout_update(woinst);
374
375 woinst->state &= ~WAVE_STATE_STARTED;
376}
377
378/**
379 * emu10k1_waveout_getxfersize -
380 *
381 * gives the total free bytes on the voice buffer, including silence bytes
382 * (basically: total_free_bytes = free_bytes + silence_bytes).
383 *
384 */
385void emu10k1_waveout_getxfersize(struct woinst *woinst, u32 *total_free_bytes)
386{
387 struct waveout_buffer *buffer = &woinst->buffer;
388 int pending_bytes;
389
390 if (woinst->mmapped) {
391 *total_free_bytes = buffer->free_bytes;
392 return;
393 }
394
395 pending_bytes = buffer->size - buffer->free_bytes;
396
397 buffer->fill_silence = (pending_bytes < (signed) buffer->fragment_size * 2) ? 1 : 0;
398
399 if (pending_bytes > (signed) buffer->silence_bytes) {
400 *total_free_bytes = (buffer->free_bytes + buffer->silence_bytes);
401 } else {
402 *total_free_bytes = buffer->size;
403 buffer->silence_bytes = pending_bytes;
404 if (pending_bytes < 0) {
405 buffer->silence_pos = buffer->hw_pos;
406 buffer->silence_bytes = 0;
407 buffer->free_bytes = buffer->size;
408 DPF(1, "buffer underrun\n");
409 }
410 }
411}
412
413/**
414 * copy_block -
415 *
416 * copies a block of pcm data to a voice buffer.
417 * Notice that the voice buffer is actually a set of disjointed memory pages.
418 *
419 */
420static void copy_block(void **dst, u32 str, u8 __user *src, u32 len)
421{
422 unsigned int pg;
423 unsigned int pgoff;
424 unsigned int k;
425
426 pg = str / PAGE_SIZE;
427 pgoff = str % PAGE_SIZE;
428
429 if (len > PAGE_SIZE - pgoff) {
430 k = PAGE_SIZE - pgoff;
431 if (__copy_from_user((u8 *)dst[pg] + pgoff, src, k))
432 return;
433 len -= k;
434 while (len > PAGE_SIZE) {
435 if (__copy_from_user(dst[++pg], src + k, PAGE_SIZE))
436 return;
437 k += PAGE_SIZE;
438 len -= PAGE_SIZE;
439 }
440 if (__copy_from_user(dst[++pg], src + k, len))
441 return;
442
443 } else
444 __copy_from_user((u8 *)dst[pg] + pgoff, src, len);
445}
446
447/**
448 * copy_ilv_block -
449 *
450 * copies a block of pcm data containing n interleaved channels to n mono voice buffers.
451 * Notice that the voice buffer is actually a set of disjointed memory pages.
452 *
453 */
454static void copy_ilv_block(struct woinst *woinst, u32 str, u8 __user *src, u32 len)
455{
456 unsigned int pg;
457 unsigned int pgoff;
458 unsigned int voice_num;
459 struct emu_voice *voice = woinst->voice;
460
461 pg = str / PAGE_SIZE;
462 pgoff = str % PAGE_SIZE;
463
464 while (len) {
465 for (voice_num = 0; voice_num < woinst->num_voices; voice_num++) {
466 if (__copy_from_user((u8 *)(voice[voice_num].mem.addr[pg]) + pgoff, src, woinst->format.bytespervoicesample))
467 return;
468 src += woinst->format.bytespervoicesample;
469 }
470
471 len -= woinst->format.bytespervoicesample;
472
473 pgoff += woinst->format.bytespervoicesample;
474 if (pgoff >= PAGE_SIZE) {
475 pgoff = 0;
476 pg++;
477 }
478 }
479}
480
481/**
482 * fill_block -
483 *
484 * fills a set voice buffers with a block of a given sample.
485 *
486 */
487static void fill_block(struct woinst *woinst, u32 str, u8 data, u32 len)
488{
489 unsigned int pg;
490 unsigned int pgoff;
491 unsigned int voice_num;
492 struct emu_voice *voice = woinst->voice;
493 unsigned int k;
494
495 pg = str / PAGE_SIZE;
496 pgoff = str % PAGE_SIZE;
497
498 if (len > PAGE_SIZE - pgoff) {
499 k = PAGE_SIZE - pgoff;
500 for (voice_num = 0; voice_num < woinst->num_voices; voice_num++)
501 memset((u8 *)voice[voice_num].mem.addr[pg] + pgoff, data, k);
502 len -= k;
503 while (len > PAGE_SIZE) {
504 pg++;
505 for (voice_num = 0; voice_num < woinst->num_voices; voice_num++)
506 memset(voice[voice_num].mem.addr[pg], data, PAGE_SIZE);
507
508 len -= PAGE_SIZE;
509 }
510 pg++;
511 for (voice_num = 0; voice_num < woinst->num_voices; voice_num++)
512 memset(voice[voice_num].mem.addr[pg], data, len);
513
514 } else {
515 for (voice_num = 0; voice_num < woinst->num_voices; voice_num++)
516 memset((u8 *)voice[voice_num].mem.addr[pg] + pgoff, data, len);
517 }
518}
519
520/**
521 * emu10k1_waveout_xferdata -
522 *
523 * copies pcm data to the voice buffer. Silence samples
524 * previously added to the buffer are overwritten.
525 *
526 */
527void emu10k1_waveout_xferdata(struct woinst *woinst, u8 __user *data, u32 *size)
528{
529 struct waveout_buffer *buffer = &woinst->buffer;
530 struct voice_mem *mem = &woinst->voice[0].mem;
531 u32 sizetocopy, sizetocopy_now, start;
532 unsigned long flags;
533
534 sizetocopy = min_t(u32, buffer->size, *size);
535 *size = sizetocopy;
536
537 if (!sizetocopy)
538 return;
539
540 spin_lock_irqsave(&woinst->lock, flags);
541 start = (buffer->size + buffer->silence_pos - buffer->silence_bytes) % buffer->size;
542
543 if (sizetocopy > buffer->silence_bytes) {
544 buffer->silence_pos += sizetocopy - buffer->silence_bytes;
545 buffer->free_bytes -= sizetocopy - buffer->silence_bytes;
546 buffer->silence_bytes = 0;
547 } else
548 buffer->silence_bytes -= sizetocopy;
549
550 spin_unlock_irqrestore(&woinst->lock, flags);
551
552 sizetocopy_now = buffer->size - start;
553 if (sizetocopy > sizetocopy_now) {
554 sizetocopy -= sizetocopy_now;
555 if (woinst->num_voices > 1) {
556 copy_ilv_block(woinst, start, data, sizetocopy_now);
557 copy_ilv_block(woinst, 0, data + sizetocopy_now * woinst->num_voices, sizetocopy);
558 } else {
559 copy_block(mem->addr, start, data, sizetocopy_now);
560 copy_block(mem->addr, 0, data + sizetocopy_now, sizetocopy);
561 }
562 } else {
563 if (woinst->num_voices > 1)
564 copy_ilv_block(woinst, start, data, sizetocopy);
565 else
566 copy_block(mem->addr, start, data, sizetocopy);
567 }
568}
569
570/**
571 * emu10k1_waveout_fillsilence -
572 *
573 * adds samples of silence to the voice buffer so that we
574 * don't loop over stale pcm data.
575 *
576 */
577void emu10k1_waveout_fillsilence(struct woinst *woinst)
578{
579 struct waveout_buffer *buffer = &woinst->buffer;
580 u32 sizetocopy, sizetocopy_now, start;
581 u8 filldata;
582 unsigned long flags;
583
584 sizetocopy = buffer->fragment_size;
585
586 if (woinst->format.bitsperchannel == 16)
587 filldata = 0x00;
588 else
589 filldata = 0x80;
590
591 spin_lock_irqsave(&woinst->lock, flags);
592 buffer->silence_bytes += sizetocopy;
593 buffer->free_bytes -= sizetocopy;
594 buffer->silence_pos %= buffer->size;
595 start = buffer->silence_pos;
596 buffer->silence_pos += sizetocopy;
597 spin_unlock_irqrestore(&woinst->lock, flags);
598
599 sizetocopy_now = buffer->size - start;
600
601 if (sizetocopy > sizetocopy_now) {
602 sizetocopy -= sizetocopy_now;
603 fill_block(woinst, start, filldata, sizetocopy_now);
604 fill_block(woinst, 0, filldata, sizetocopy);
605 } else {
606 fill_block(woinst, start, filldata, sizetocopy);
607 }
608}
609
610/**
611 * emu10k1_waveout_update -
612 *
613 * updates the position of the voice buffer hardware pointer (hw_pos)
614 * and the number of free bytes on the buffer (free_bytes).
615 * The free bytes _don't_ include silence bytes that may have been
616 * added to the buffer.
617 *
618 */
619void emu10k1_waveout_update(struct woinst *woinst)
620{
621 u32 hw_pos;
622 u32 diff;
623
624 /* There is no actual start yet */
625 if (!(woinst->state & WAVE_STATE_STARTED)) {
626 hw_pos = woinst->buffer.hw_pos;
627 } else {
628 /* hw_pos in sample units */
629 hw_pos = sblive_readptr(woinst->voice[0].card, CCCA_CURRADDR, woinst->voice[0].num);
630
631 if(hw_pos < woinst->voice[0].start)
632 hw_pos += woinst->buffer.size / woinst->format.bytespervoicesample - woinst->voice[0].start;
633 else
634 hw_pos -= woinst->voice[0].start;
635
636 hw_pos *= woinst->format.bytespervoicesample;
637 }
638
639 diff = (woinst->buffer.size + hw_pos - woinst->buffer.hw_pos) % woinst->buffer.size;
640 woinst->total_played += diff;
641 woinst->buffer.free_bytes += diff;
642 woinst->buffer.hw_pos = hw_pos;
643}
diff --git a/sound/oss/emu10k1/cardwo.h b/sound/oss/emu10k1/cardwo.h
deleted file mode 100644
index 1dece8853e5..00000000000
--- a/sound/oss/emu10k1/cardwo.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 **********************************************************************
3 * cardwo.h -- header file for card wave out functions
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _CARDWO_H
33#define _CARDWO_H
34
35#include "icardwav.h"
36#include "audio.h"
37#include "voicemgr.h"
38#include "timer.h"
39
40/* setting this to other than a power of two may break some applications */
41#define WAVEOUT_MAXBUFSIZE MAXBUFSIZE
42
43#define WAVEOUT_DEFAULTFRAGLEN 20 /* Time to play a fragment in ms (latency) */
44#define WAVEOUT_DEFAULTBUFLEN 500 /* Time to play the entire buffer in ms */
45
46#define WAVEOUT_MINFRAGSHIFT 6 /* Minimum fragment size in bytes is 2^6 */
47#define WAVEOUT_MINFRAGS 3 /* _don't_ go bellow 3, it would break silence filling */
48#define WAVEOUT_MAXVOICES 6
49
50struct waveout_buffer {
51 u16 ossfragshift;
52 u32 numfrags;
53 u32 fragment_size; /* in bytes units */
54 u32 size; /* in bytes units */
55 u32 pages; /* buffer size in page units*/
56 u32 silence_pos; /* software cursor position (including silence bytes) */
57 u32 hw_pos; /* hardware cursor position */
58 u32 free_bytes; /* free bytes available on the buffer (not including silence bytes) */
59 u8 fill_silence;
60 u32 silence_bytes; /* silence bytes on the buffer */
61};
62
63struct woinst
64{
65 u8 state;
66 u8 num_voices;
67 struct emu_voice voice[WAVEOUT_MAXVOICES];
68 struct emu_timer timer;
69 struct wave_format format;
70 struct waveout_buffer buffer;
71 wait_queue_head_t wait_queue;
72 u8 mmapped;
73 u32 total_copied; /* total number of bytes written() to the buffer (excluding silence) */
74 u32 total_played; /* total number of bytes played including silence */
75 u32 blocks;
76 u8 device;
77 spinlock_t lock;
78};
79
80int emu10k1_waveout_open(struct emu10k1_wavedevice *);
81void emu10k1_waveout_close(struct emu10k1_wavedevice *);
82void emu10k1_waveout_start(struct emu10k1_wavedevice *);
83void emu10k1_waveout_stop(struct emu10k1_wavedevice *);
84void emu10k1_waveout_getxfersize(struct woinst*, u32 *);
85void emu10k1_waveout_xferdata(struct woinst*, u8 __user *, u32 *);
86void emu10k1_waveout_fillsilence(struct woinst*);
87int emu10k1_waveout_setformat(struct emu10k1_wavedevice*, struct wave_format*);
88void emu10k1_waveout_update(struct woinst*);
89
90#endif /* _CARDWO_H */
diff --git a/sound/oss/emu10k1/ecard.c b/sound/oss/emu10k1/ecard.c
deleted file mode 100644
index 4ae635fe140..00000000000
--- a/sound/oss/emu10k1/ecard.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 **********************************************************************
3 * ecard.c - E-card initialization code
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include "ecard.h"
33#include "hwaccess.h"
34
35/* Private routines */
36static void ecard_setadcgain(struct emu10k1_card *, struct ecard_state *, u16);
37static void ecard_write(struct emu10k1_card *, u32);
38
39/**************************************************************************
40 * @func Set the gain of the ECARD's CS3310 Trim/gain controller. The
41 * trim value consists of a 16bit value which is composed of two
42 * 8 bit gain/trim values, one for the left channel and one for the
43 * right channel. The following table maps from the Gain/Attenuation
44 * value in decibels into the corresponding bit pattern for a single
45 * channel.
46 */
47
48static void ecard_setadcgain(struct emu10k1_card *card, struct ecard_state *ecard, u16 gain)
49{
50 u32 currbit;
51 ecard->adc_gain = gain;
52
53 /* Enable writing to the TRIM registers */
54 ecard_write(card, ecard->control_bits & ~EC_TRIM_CSN);
55
56 /* Do it again to insure that we meet hold time requirements */
57 ecard_write(card, ecard->control_bits & ~EC_TRIM_CSN);
58
59 for (currbit = (1L << 15); currbit; currbit >>= 1) {
60
61 u32 value = ecard->control_bits & ~(EC_TRIM_CSN|EC_TRIM_SDATA);
62
63 if (gain & currbit)
64 value |= EC_TRIM_SDATA;
65
66 /* Clock the bit */
67 ecard_write(card, value);
68 ecard_write(card, value | EC_TRIM_SCLK);
69 ecard_write(card, value);
70 }
71
72 ecard_write(card, ecard->control_bits);
73}
74
75/**************************************************************************
76 * @func Clock bits into the Ecard's control latch. The Ecard uses a
77 * control latch will is loaded bit-serially by toggling the Modem control
78 * lines from function 2 on the E8010. This function hides these details
79 * and presents the illusion that we are actually writing to a distinct
80 * register.
81 */
82static void ecard_write(struct emu10k1_card *card, u32 value)
83{
84 u16 count;
85 u32 data, hcvalue;
86 unsigned long flags;
87
88 spin_lock_irqsave(&card->lock, flags);
89
90 hcvalue = inl(card->iobase + HCFG) & ~(HOOKN_BIT|HANDN_BIT|PULSEN_BIT);
91
92 outl(card->iobase + HCFG, hcvalue);
93
94 for (count = 0 ; count < EC_NUM_CONTROL_BITS; count++) {
95
96 /* Set up the value */
97 data = ((value & 0x1) ? PULSEN_BIT : 0);
98 value >>= 1;
99
100 outl(card->iobase + HCFG, hcvalue | data);
101
102 /* Clock the shift register */
103 outl(card->iobase + HCFG, hcvalue | data | HANDN_BIT);
104 outl(card->iobase + HCFG, hcvalue | data);
105 }
106
107 /* Latch the bits */
108 outl(card->iobase + HCFG, hcvalue | HOOKN_BIT);
109 outl(card->iobase + HCFG, hcvalue);
110
111 spin_unlock_irqrestore(&card->lock, flags);
112}
113
114void __devinit emu10k1_ecard_init(struct emu10k1_card *card)
115{
116 u32 hcvalue;
117 struct ecard_state ecard;
118
119 /* Set up the initial settings */
120 ecard.mux0_setting = EC_DEFAULT_SPDIF0_SEL;
121 ecard.mux1_setting = EC_DEFAULT_SPDIF1_SEL;
122 ecard.mux2_setting = 0;
123 ecard.adc_gain = EC_DEFAULT_ADC_GAIN;
124 ecard.control_bits = EC_RAW_RUN_MODE |
125 EC_SPDIF0_SELECT(ecard.mux0_setting) |
126 EC_SPDIF1_SELECT(ecard.mux1_setting);
127
128
129 /* Step 0: Set the codec type in the hardware control register
130 * and enable audio output */
131 hcvalue = emu10k1_readfn0(card, HCFG);
132 emu10k1_writefn0(card, HCFG, hcvalue | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S);
133
134 /* Step 1: Turn off the led and deassert TRIM_CS */
135 ecard_write(card, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN);
136
137 /* Step 2: Calibrate the ADC and DAC */
138 ecard_write(card, EC_DACCAL | EC_LEDN | EC_TRIM_CSN);
139
140 /* Step 3: Wait for awhile; FIXME: Is this correct? */
141
142 current->state = TASK_INTERRUPTIBLE;
143 schedule_timeout(HZ);
144
145 /* Step 4: Switch off the DAC and ADC calibration. Note
146 * That ADC_CAL is actually an inverted signal, so we assert
147 * it here to stop calibration. */
148 ecard_write(card, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN);
149
150 /* Step 4: Switch into run mode */
151 ecard_write(card, ecard.control_bits);
152
153 /* Step 5: Set the analog input gain */
154 ecard_setadcgain(card, &ecard, ecard.adc_gain);
155}
156
157
diff --git a/sound/oss/emu10k1/ecard.h b/sound/oss/emu10k1/ecard.h
deleted file mode 100644
index 67aead16e8e..00000000000
--- a/sound/oss/emu10k1/ecard.h
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 **********************************************************************
3 * ecard.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
21 * USA.
22 *
23 **********************************************************************
24 */
25
26#ifndef _ECARD_H
27#define _ECARD_H
28
29#include "8010.h"
30#include "hwaccess.h"
31#include <linux/init.h>
32
33/* In A1 Silicon, these bits are in the HC register */
34#define HOOKN_BIT (1L << 12)
35#define HANDN_BIT (1L << 11)
36#define PULSEN_BIT (1L << 10)
37
38#define EC_GDI1 (1 << 13)
39#define EC_GDI0 (1 << 14)
40
41#define EC_NUM_CONTROL_BITS 20
42
43#define EC_AC3_DATA_SELN 0x0001L
44#define EC_EE_DATA_SEL 0x0002L
45#define EC_EE_CNTRL_SELN 0x0004L
46#define EC_EECLK 0x0008L
47#define EC_EECS 0x0010L
48#define EC_EESDO 0x0020L
49#define EC_TRIM_CSN 0x0040L
50#define EC_TRIM_SCLK 0x0080L
51#define EC_TRIM_SDATA 0x0100L
52#define EC_TRIM_MUTEN 0x0200L
53#define EC_ADCCAL 0x0400L
54#define EC_ADCRSTN 0x0800L
55#define EC_DACCAL 0x1000L
56#define EC_DACMUTEN 0x2000L
57#define EC_LEDN 0x4000L
58
59#define EC_SPDIF0_SEL_SHIFT 15
60#define EC_SPDIF1_SEL_SHIFT 17
61#define EC_SPDIF0_SEL_MASK (0x3L << EC_SPDIF0_SEL_SHIFT)
62#define EC_SPDIF1_SEL_MASK (0x7L << EC_SPDIF1_SEL_SHIFT)
63#define EC_SPDIF0_SELECT(_x) (((_x) << EC_SPDIF0_SEL_SHIFT) & EC_SPDIF0_SEL_MASK)
64#define EC_SPDIF1_SELECT(_x) (((_x) << EC_SPDIF1_SEL_SHIFT) & EC_SPDIF1_SEL_MASK)
65#define EC_CURRENT_PROM_VERSION 0x01 /* Self-explanatory. This should
66 * be incremented any time the EEPROM's
67 * format is changed. */
68
69#define EC_EEPROM_SIZE 0x40 /* ECARD EEPROM has 64 16-bit words */
70
71/* Addresses for special values stored in to EEPROM */
72#define EC_PROM_VERSION_ADDR 0x20 /* Address of the current prom version */
73#define EC_BOARDREV0_ADDR 0x21 /* LSW of board rev */
74#define EC_BOARDREV1_ADDR 0x22 /* MSW of board rev */
75
76#define EC_LAST_PROMFILE_ADDR 0x2f
77
78#define EC_SERIALNUM_ADD 0x30 /* First word of serial number. The number
79 * can be up to 30 characters in length
80 * and is stored as a NULL-terminated
81 * ASCII string. Any unused bytes must be
82 * filled with zeros */
83#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */
84
85
86
87/* Most of this stuff is pretty self-evident. According to the hardware
88 * dudes, we need to leave the ADCCAL bit low in order to avoid a DC
89 * offset problem. Weird.
90 */
91#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | EC_TRIM_CSN)
92
93
94#define EC_DEFAULT_ADC_GAIN 0xC4C4
95#define EC_DEFAULT_SPDIF0_SEL 0x0
96#define EC_DEFAULT_SPDIF1_SEL 0x4
97
98#define HC_EA 0x01L
99
100/* ECARD state structure. This structure maintains the state
101 * for various portions of the ECARD's onboard hardware.
102 */
103struct ecard_state {
104 u32 control_bits;
105 u16 adc_gain;
106 u16 mux0_setting;
107 u16 mux1_setting;
108 u16 mux2_setting;
109};
110
111void emu10k1_ecard_init(struct emu10k1_card *) __devinit;
112
113#endif /* _ECARD_H */
diff --git a/sound/oss/emu10k1/efxmgr.c b/sound/oss/emu10k1/efxmgr.c
deleted file mode 100644
index 7d5865de4c2..00000000000
--- a/sound/oss/emu10k1/efxmgr.c
+++ /dev/null
@@ -1,220 +0,0 @@
1/*
2 **********************************************************************
3 * efxmgr.c
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/bitops.h>
33#include "hwaccess.h"
34#include "efxmgr.h"
35
36int emu10k1_find_control_gpr(struct patch_manager *mgr, const char *patch_name, const char *gpr_name)
37{
38 struct dsp_patch *patch;
39 struct dsp_rpatch *rpatch;
40 char s[PATCH_NAME_SIZE + 4];
41 unsigned long *gpr_used;
42 int i;
43
44 DPD(2, "emu10k1_find_control_gpr(): %s %s\n", patch_name, gpr_name);
45
46 rpatch = &mgr->rpatch;
47 if (!strcmp(rpatch->name, patch_name)) {
48 gpr_used = rpatch->gpr_used;
49 goto match;
50 }
51
52 for (i = 0; i < mgr->current_pages * PATCHES_PER_PAGE; i++) {
53 patch = PATCH(mgr, i);
54 sprintf(s,"%s", patch->name);
55
56 if (!strcmp(s, patch_name)) {
57 gpr_used = patch->gpr_used;
58 goto match;
59 }
60 }
61
62 return -1;
63
64 match:
65 for (i = 0; i < NUM_GPRS; i++)
66 if (mgr->gpr[i].type == GPR_TYPE_CONTROL &&
67 test_bit(i, gpr_used) &&
68 !strcmp(mgr->gpr[i].name, gpr_name))
69 return i;
70
71 return -1;
72}
73
74void emu10k1_set_control_gpr(struct emu10k1_card *card, int addr, s32 val, int flag)
75{
76 struct patch_manager *mgr = &card->mgr;
77
78 DPD(2, "emu10k1_set_control_gpr(): %d %x\n", addr, val);
79
80 if (addr < 0 || addr >= NUM_GPRS)
81 return;
82
83 //fixme: once patch manager is up, remember to fix this for the audigy
84 if (card->is_audigy) {
85 sblive_writeptr(card, A_GPR_BASE + addr, 0, val);
86 } else {
87 if (flag)
88 val += sblive_readptr(card, GPR_BASE + addr, 0);
89 if (val > mgr->gpr[addr].max)
90 val = mgr->gpr[addr].max;
91 else if (val < mgr->gpr[addr].min)
92 val = mgr->gpr[addr].min;
93 sblive_writeptr(card, GPR_BASE + addr, 0, val);
94 }
95
96
97}
98
99//TODO: make this configurable:
100#define VOLCTRL_CHANNEL SOUND_MIXER_VOLUME
101#define VOLCTRL_STEP_SIZE 5
102
103//An internal function for setting OSS mixer controls.
104static void emu10k1_set_oss_vol(struct emu10k1_card *card, int oss_mixer,
105 unsigned int left, unsigned int right)
106{
107 extern char volume_params[SOUND_MIXER_NRDEVICES];
108
109 card->ac97->mixer_state[oss_mixer] = (right << 8) | left;
110
111 if (!card->is_aps)
112 card->ac97->write_mixer(card->ac97, oss_mixer, left, right);
113
114 emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][0], left,
115 volume_params[oss_mixer]);
116
117 emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][1], right,
118 volume_params[oss_mixer]);
119}
120
121//FIXME: mute should unmute when pressed a second time
122void emu10k1_mute_irqhandler(struct emu10k1_card *card)
123{
124 int oss_channel = VOLCTRL_CHANNEL;
125 int left, right;
126 static int val;
127
128 if (val) {
129 left = val & 0xff;
130 right = (val >> 8) & 0xff;
131 val = 0;
132 } else {
133 val = card->ac97->mixer_state[oss_channel];
134 left = 0;
135 right = 0;
136 }
137
138 emu10k1_set_oss_vol(card, oss_channel, left, right);
139}
140
141void emu10k1_volincr_irqhandler(struct emu10k1_card *card)
142{
143 int oss_channel = VOLCTRL_CHANNEL;
144 int left, right;
145
146 left = card->ac97->mixer_state[oss_channel] & 0xff;
147 right = (card->ac97->mixer_state[oss_channel] >> 8) & 0xff;
148
149 if ((left += VOLCTRL_STEP_SIZE) > 100)
150 left = 100;
151
152 if ((right += VOLCTRL_STEP_SIZE) > 100)
153 right = 100;
154
155 emu10k1_set_oss_vol(card, oss_channel, left, right);
156}
157
158void emu10k1_voldecr_irqhandler(struct emu10k1_card *card)
159{
160 int oss_channel = VOLCTRL_CHANNEL;
161 int left, right;
162
163 left = card->ac97->mixer_state[oss_channel] & 0xff;
164 right = (card->ac97->mixer_state[oss_channel] >> 8) & 0xff;
165
166 if ((left -= VOLCTRL_STEP_SIZE) < 0)
167 left = 0;
168
169 if ((right -= VOLCTRL_STEP_SIZE) < 0)
170 right = 0;
171
172 emu10k1_set_oss_vol(card, oss_channel, left, right);
173}
174
175void emu10k1_set_volume_gpr(struct emu10k1_card *card, int addr, s32 vol, int scale)
176{
177 struct patch_manager *mgr = &card->mgr;
178 unsigned long flags;
179
180 static const s32 log2lin[4] ={ // attenuation (dB)
181 0x7fffffff, // 0.0
182 0x7fffffff * 0.840896415253715 , // 1.5
183 0x7fffffff * 0.707106781186548, // 3.0
184 0x7fffffff * 0.594603557501361 , // 4.5
185 };
186
187 if (addr < 0)
188 return;
189
190 vol = (100 - vol ) * scale / 100;
191
192 // Thanks to the comp.dsp newsgroup for this neat trick:
193 vol = (vol >= scale) ? 0 : (log2lin[vol & 3] >> (vol >> 2));
194
195 spin_lock_irqsave(&mgr->lock, flags);
196 emu10k1_set_control_gpr(card, addr, vol, 0);
197 spin_unlock_irqrestore(&mgr->lock, flags);
198}
199
200void emu10k1_dsp_irqhandler(struct emu10k1_card *card)
201{
202 unsigned long flags;
203
204 if (card->pt.state != PT_STATE_INACTIVE) {
205 u32 bc;
206 bc = sblive_readptr(card, GPR_BASE + card->pt.intr_gpr, 0);
207 if (bc != 0) {
208 DPD(3, "pt interrupt, bc = %d\n", bc);
209 spin_lock_irqsave(&card->pt.lock, flags);
210 card->pt.blocks_played = bc;
211 if (card->pt.blocks_played >= card->pt.blocks_copied) {
212 DPF(1, "buffer underrun in passthrough playback\n");
213 emu10k1_pt_stop(card);
214 }
215 wake_up_interruptible(&card->pt.wait);
216 spin_unlock_irqrestore(&card->pt.lock, flags);
217 }
218 }
219}
220
diff --git a/sound/oss/emu10k1/efxmgr.h b/sound/oss/emu10k1/efxmgr.h
deleted file mode 100644
index ef48e5c70d1..00000000000
--- a/sound/oss/emu10k1/efxmgr.h
+++ /dev/null
@@ -1,270 +0,0 @@
1/*
2 **********************************************************************
3 * sblive_fx.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _EFXMGR_H
33#define _EFXMGR_H
34
35struct emu_efx_info_t{
36 int opcode_shift;
37 int high_operand_shift;
38 int instruction_start;
39 int gpr_base;
40 int output_base;
41};
42
43
44#define WRITE_EFX(a, b, c) sblive_writeptr((a), emu_efx_info[card->is_audigy].instruction_start + (b), 0, (c))
45
46#define OP(op, z, w, x, y) \
47 do { WRITE_EFX(card, (pc) * 2, ((x) << emu_efx_info[card->is_audigy].high_operand_shift) | (y)); \
48 WRITE_EFX(card, (pc) * 2 + 1, ((op) << emu_efx_info[card->is_audigy].opcode_shift ) | ((z) << emu_efx_info[card->is_audigy].high_operand_shift) | (w)); \
49 ++pc; } while (0)
50
51#define NUM_INPUTS 0x20
52#define NUM_OUTPUTS 0x20
53#define NUM_GPRS 0x100
54
55#define A_NUM_INPUTS 0x60
56#define A_NUM_OUTPUTS 0x60 //fixme: this may or may not be true
57#define A_NUM_GPRS 0x200
58
59#define GPR_NAME_SIZE 32
60#define PATCH_NAME_SIZE 32
61
62struct dsp_rpatch {
63 char name[PATCH_NAME_SIZE];
64 u16 code_start;
65 u16 code_size;
66
67 unsigned long gpr_used[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
68 unsigned long gpr_input[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
69 unsigned long route[NUM_OUTPUTS];
70 unsigned long route_v[NUM_OUTPUTS];
71};
72
73struct dsp_patch {
74 char name[PATCH_NAME_SIZE];
75 u8 id;
76 unsigned long input; /* bitmap of the lines used as inputs */
77 unsigned long output; /* bitmap of the lines used as outputs */
78 u16 code_start;
79 u16 code_size;
80
81 unsigned long gpr_used[NUM_GPRS / (sizeof(unsigned long) * 8) + 1]; /* bitmap of used gprs */
82 unsigned long gpr_input[NUM_GPRS / (sizeof(unsigned long) * 8) + 1];
83 u8 traml_istart; /* starting address of the internal tram lines used */
84 u8 traml_isize; /* number of internal tram lines used */
85
86 u8 traml_estart;
87 u8 traml_esize;
88
89 u16 tramb_istart; /* starting address of the internal tram memory used */
90 u16 tramb_isize; /* amount of internal memory used */
91 u32 tramb_estart;
92 u32 tramb_esize;
93};
94
95struct dsp_gpr {
96 u8 type; /* gpr type, STATIC, DYNAMIC, INPUT, OUTPUT, CONTROL */
97 char name[GPR_NAME_SIZE]; /* gpr value, only valid for control gprs */
98 s32 min, max; /* value range for this gpr, only valid for control gprs */
99 u8 line; /* which input/output line is the gpr attached, only valid for input/output gprs */
100 u8 usage;
101};
102
103enum {
104 GPR_TYPE_NULL = 0,
105 GPR_TYPE_IO,
106 GPR_TYPE_STATIC,
107 GPR_TYPE_DYNAMIC,
108 GPR_TYPE_CONTROL,
109 GPR_TYPE_CONSTANT
110};
111
112#define GPR_BASE 0x100
113#define OUTPUT_BASE 0x20
114
115#define A_GPR_BASE 0x400
116#define A_OUTPUT_BASE 0x60
117
118#define MAX_PATCHES_PAGES 32
119
120struct patch_manager {
121 void *patch[MAX_PATCHES_PAGES];
122 int current_pages;
123 struct dsp_rpatch rpatch;
124 struct dsp_gpr gpr[NUM_GPRS]; /* gpr usage table */
125 spinlock_t lock;
126 s16 ctrl_gpr[SOUND_MIXER_NRDEVICES][2];
127};
128
129#define PATCHES_PER_PAGE (PAGE_SIZE / sizeof(struct dsp_patch))
130
131#define PATCH(mgr, i) ((struct dsp_patch *) (mgr)->patch[(i) / PATCHES_PER_PAGE] + (i) % PATCHES_PER_PAGE)
132
133/* PCM volume control */
134#define TMP_PCM_L 0x100 //temp PCM L (after the vol control)
135#define TMP_PCM_R 0x101
136#define VOL_PCM_L 0x102 //vol PCM
137#define VOL_PCM_R 0x103
138
139/* Routing patch */
140#define TMP_AC_L 0x104 //tmp ac97 out
141#define TMP_AC_R 0x105
142#define TMP_REAR_L 0x106 //output - Temp Rear
143#define TMP_REAR_R 0x107
144#define TMP_DIGI_L 0x108 //output - Temp digital
145#define TMP_DIGI_R 0x109
146#define DSP_VOL_L 0x10a // main dsp volume
147#define DSP_VOL_R 0x10b
148
149/* hw inputs */
150#define PCM_IN_L 0x00
151#define PCM_IN_R 0x01
152
153#define PCM1_IN_L 0x04
154#define PCM1_IN_R 0x05
155//mutilchannel playback stream appear here:
156
157#define MULTI_FRONT_L 0x08
158#define MULTI_FRONT_R 0x09
159#define MULTI_REAR_L 0x0a
160#define MULTI_REAR_R 0x0b
161#define MULTI_CENTER 0x0c
162#define MULTI_LFE 0x0d
163
164#define AC97_IN_L 0x10
165#define AC97_IN_R 0x11
166#define SPDIF_CD_L 0x12
167#define SPDIF_CD_R 0x13
168
169/* hw outputs */
170#define AC97_FRONT_L 0x20
171#define AC97_FRONT_R 0x21
172#define DIGITAL_OUT_L 0x22
173#define DIGITAL_OUT_R 0x23
174#define DIGITAL_CENTER 0x24
175#define DIGITAL_LFE 0x25
176
177#define ANALOG_REAR_L 0x28
178#define ANALOG_REAR_R 0x29
179#define ADC_REC_L 0x2a
180#define ADC_REC_R 0x2b
181
182#define ANALOG_CENTER 0x31
183#define ANALOG_LFE 0x32
184
185
186#define INPUT_PATCH_START(patch, nm, ln, i) \
187do { \
188 patch = PATCH(mgr, patch_n); \
189 strcpy(patch->name, nm); \
190 patch->code_start = pc * 2; \
191 patch->input = (1<<(0x1f&ln)); \
192 patch->output= (1<<(0x1f&ln)); \
193 patch->id = i; \
194} while(0)
195
196#define INPUT_PATCH_END(patch) \
197do { \
198 patch->code_size = pc * 2 - patch->code_start; \
199 patch_n++; \
200} while(0)
201
202
203#define ROUTING_PATCH_START(patch, nm) \
204do { \
205 patch = &mgr->rpatch; \
206 strcpy(patch->name, nm); \
207 patch->code_start = pc * 2; \
208} while(0)
209
210#define ROUTING_PATCH_END(patch) \
211do { \
212 patch->code_size = pc * 2 - patch->code_start; \
213} while(0)
214
215#define CONNECT(input, output) set_bit(input, &rpatch->route[(output) - OUTPUT_BASE]);
216
217#define CONNECT_V(input, output) set_bit(input, &rpatch->route_v[(output) - OUTPUT_BASE]);
218
219#define OUTPUT_PATCH_START(patch, nm, ln, i) \
220do { \
221 patch = PATCH(mgr, patch_n); \
222 strcpy(patch->name, nm); \
223 patch->code_start = pc * 2; \
224 patch->input = (1<<(0x1f&ln)); \
225 patch->output= (1<<(0x1f&ln)); \
226 patch->id = i; \
227} while(0)
228
229#define OUTPUT_PATCH_END(patch) \
230do { \
231 patch->code_size = pc * 2 - patch->code_start; \
232 patch_n++; \
233} while(0)
234
235#define GET_OUTPUT_GPR(patch, g, ln) \
236do { \
237 mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_IO; \
238 mgr->gpr[(g) - GPR_BASE].usage++; \
239 mgr->gpr[(g) - GPR_BASE].line = ln; \
240 set_bit((g) - GPR_BASE, patch->gpr_used); \
241} while(0)
242
243#define GET_INPUT_GPR(patch, g, ln) \
244do { \
245 mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_IO; \
246 mgr->gpr[(g) - GPR_BASE].usage++; \
247 mgr->gpr[(g) - GPR_BASE].line = ln; \
248 set_bit((g) - GPR_BASE, patch->gpr_used); \
249 set_bit((g) - GPR_BASE, patch->gpr_input); \
250} while(0)
251
252#define GET_DYNAMIC_GPR(patch, g) \
253do { \
254 mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_DYNAMIC; \
255 mgr->gpr[(g) - GPR_BASE].usage++; \
256 set_bit((g) - GPR_BASE, patch->gpr_used); \
257} while(0)
258
259#define GET_CONTROL_GPR(patch, g, nm, a, b) \
260do { \
261 strcpy(mgr->gpr[(g) - GPR_BASE].name, nm); \
262 mgr->gpr[(g) - GPR_BASE].type = GPR_TYPE_CONTROL; \
263 mgr->gpr[(g) - GPR_BASE].usage++; \
264 mgr->gpr[(g) - GPR_BASE].min = a; \
265 mgr->gpr[(g) - GPR_BASE].max = b; \
266 sblive_writeptr(card, g, 0, b); \
267 set_bit((g) - GPR_BASE, patch->gpr_used); \
268} while(0)
269
270#endif /* _EFXMGR_H */
diff --git a/sound/oss/emu10k1/emuadxmg.c b/sound/oss/emu10k1/emuadxmg.c
deleted file mode 100644
index d7d2d4caf7b..00000000000
--- a/sound/oss/emu10k1/emuadxmg.c
+++ /dev/null
@@ -1,104 +0,0 @@
1
2/*
3 **********************************************************************
4 * emuadxmg.c - Address space manager for emu10k1 driver
5 * Copyright 1999, 2000 Creative Labs, Inc.
6 *
7 **********************************************************************
8 *
9 * Date Author Summary of changes
10 * ---- ------ ------------------
11 * October 20, 1999 Bertrand Lee base code release
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include "hwaccess.h"
34
35/* Allocates emu address space */
36
37int emu10k1_addxmgr_alloc(u32 size, struct emu10k1_card *card)
38{
39 u16 *pagetable = card->emupagetable;
40 u16 index = 0;
41 u16 numpages;
42 unsigned long flags;
43
44 /* Convert bytes to pages */
45 numpages = (size / EMUPAGESIZE) + ((size % EMUPAGESIZE) ? 1 : 0);
46
47 spin_lock_irqsave(&card->lock, flags);
48
49 while (index < (MAXPAGES - 1)) {
50 if (pagetable[index] & 0x8000) {
51 /* This block of pages is in use, jump to the start of the next block. */
52 index += (pagetable[index] & 0x7fff);
53 } else {
54 /* Found free block */
55 if (pagetable[index] >= numpages) {
56
57 /* Block is large enough */
58
59 /* If free block is larger than the block requested
60 * then adjust the size of the block remaining */
61 if (pagetable[index] > numpages)
62 pagetable[index + numpages] = pagetable[index] - numpages;
63
64 pagetable[index] = (numpages | 0x8000); /* Mark block as used */
65
66 spin_unlock_irqrestore(&card->lock, flags);
67
68 return index;
69 } else {
70 /* Block too small, jump to the start of the next block */
71 index += pagetable[index];
72 }
73 }
74 }
75
76 spin_unlock_irqrestore(&card->lock, flags);
77
78 return -1;
79}
80
81/* Frees a previously allocated emu address space. */
82
83void emu10k1_addxmgr_free(struct emu10k1_card *card, int index)
84{
85 u16 *pagetable = card->emupagetable;
86 u16 origsize = 0;
87 unsigned long flags;
88
89 spin_lock_irqsave(&card->lock, flags);
90
91 if (pagetable[index] & 0x8000) {
92 /* Block is allocated - mark block as free */
93 origsize = pagetable[index] & 0x7fff;
94 pagetable[index] = origsize;
95
96 /* If next block is free, we concat both blocks */
97 if (!(pagetable[index + origsize] & 0x8000))
98 pagetable[index] += pagetable[index + origsize] & 0x7fff;
99 }
100
101 spin_unlock_irqrestore(&card->lock, flags);
102
103 return;
104}
diff --git a/sound/oss/emu10k1/hwaccess.c b/sound/oss/emu10k1/hwaccess.c
deleted file mode 100644
index 2dc16a841fa..00000000000
--- a/sound/oss/emu10k1/hwaccess.c
+++ /dev/null
@@ -1,507 +0,0 @@
1/*
2 **********************************************************************
3 * hwaccess.c -- Hardware access layer
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * December 9, 1999 Jon Taylor rewrote the I/O subsystem
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include <asm/io.h>
34
35#include "hwaccess.h"
36#include "8010.h"
37#include "icardmid.h"
38
39/*************************************************************************
40* Function : srToPitch *
41* Input : sampleRate - sampling rate *
42* Return : pitch value *
43* About : convert sampling rate to pitch *
44* Note : for 8010, sampling rate is at 48kHz, this function should *
45* be changed. *
46*************************************************************************/
47u32 srToPitch(u32 sampleRate)
48{
49 int i;
50
51 /* FIXME: These tables should be defined in a headerfile */
52 static u32 logMagTable[128] = {
53 0x00000, 0x02dfc, 0x05b9e, 0x088e6, 0x0b5d6, 0x0e26f, 0x10eb3, 0x13aa2,
54 0x1663f, 0x1918a, 0x1bc84, 0x1e72e, 0x2118b, 0x23b9a, 0x2655d, 0x28ed5,
55 0x2b803, 0x2e0e8, 0x30985, 0x331db, 0x359eb, 0x381b6, 0x3a93d, 0x3d081,
56 0x3f782, 0x41e42, 0x444c1, 0x46b01, 0x49101, 0x4b6c4, 0x4dc49, 0x50191,
57 0x5269e, 0x54b6f, 0x57006, 0x59463, 0x5b888, 0x5dc74, 0x60029, 0x623a7,
58 0x646ee, 0x66a00, 0x68cdd, 0x6af86, 0x6d1fa, 0x6f43c, 0x7164b, 0x73829,
59 0x759d4, 0x77b4f, 0x79c9a, 0x7bdb5, 0x7dea1, 0x7ff5e, 0x81fed, 0x8404e,
60 0x86082, 0x88089, 0x8a064, 0x8c014, 0x8df98, 0x8fef1, 0x91e20, 0x93d26,
61 0x95c01, 0x97ab4, 0x9993e, 0x9b79f, 0x9d5d9, 0x9f3ec, 0xa11d8, 0xa2f9d,
62 0xa4d3c, 0xa6ab5, 0xa8808, 0xaa537, 0xac241, 0xadf26, 0xafbe7, 0xb1885,
63 0xb3500, 0xb5157, 0xb6d8c, 0xb899f, 0xba58f, 0xbc15e, 0xbdd0c, 0xbf899,
64 0xc1404, 0xc2f50, 0xc4a7b, 0xc6587, 0xc8073, 0xc9b3f, 0xcb5ed, 0xcd07c,
65 0xceaec, 0xd053f, 0xd1f73, 0xd398a, 0xd5384, 0xd6d60, 0xd8720, 0xda0c3,
66 0xdba4a, 0xdd3b4, 0xded03, 0xe0636, 0xe1f4e, 0xe384a, 0xe512c, 0xe69f3,
67 0xe829f, 0xe9b31, 0xeb3a9, 0xecc08, 0xee44c, 0xefc78, 0xf148a, 0xf2c83,
68 0xf4463, 0xf5c2a, 0xf73da, 0xf8b71, 0xfa2f0, 0xfba57, 0xfd1a7, 0xfe8df
69 };
70
71 static char logSlopeTable[128] = {
72 0x5c, 0x5c, 0x5b, 0x5a, 0x5a, 0x59, 0x58, 0x58,
73 0x57, 0x56, 0x56, 0x55, 0x55, 0x54, 0x53, 0x53,
74 0x52, 0x52, 0x51, 0x51, 0x50, 0x50, 0x4f, 0x4f,
75 0x4e, 0x4d, 0x4d, 0x4d, 0x4c, 0x4c, 0x4b, 0x4b,
76 0x4a, 0x4a, 0x49, 0x49, 0x48, 0x48, 0x47, 0x47,
77 0x47, 0x46, 0x46, 0x45, 0x45, 0x45, 0x44, 0x44,
78 0x43, 0x43, 0x43, 0x42, 0x42, 0x42, 0x41, 0x41,
79 0x41, 0x40, 0x40, 0x40, 0x3f, 0x3f, 0x3f, 0x3e,
80 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c, 0x3c,
81 0x3b, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39,
82 0x39, 0x39, 0x39, 0x38, 0x38, 0x38, 0x38, 0x37,
83 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x36, 0x35,
84 0x35, 0x35, 0x35, 0x34, 0x34, 0x34, 0x34, 0x34,
85 0x33, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x32,
86 0x32, 0x31, 0x31, 0x31, 0x31, 0x31, 0x30, 0x30,
87 0x30, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f
88 };
89
90 if (sampleRate == 0)
91 return 0; /* Bail out if no leading "1" */
92
93 sampleRate *= 11185; /* Scale 48000 to 0x20002380 */
94
95 for (i = 31; i > 0; i--) {
96 if (sampleRate & 0x80000000) { /* Detect leading "1" */
97 return (u32) (((s32) (i - 15) << 20) +
98 logMagTable[0x7f & (sampleRate >> 24)] +
99 (0x7f & (sampleRate >> 17)) * logSlopeTable[0x7f & (sampleRate >> 24)]);
100 }
101 sampleRate = sampleRate << 1;
102 }
103
104 DPF(2, "srToPitch: BUG!\n");
105 return 0; /* Should never reach this point */
106}
107
108/*******************************************
109* write/read PCI function 0 registers *
110********************************************/
111void emu10k1_writefn0(struct emu10k1_card *card, u32 reg, u32 data)
112{
113 unsigned long flags;
114
115 if (reg & 0xff000000) {
116 u32 mask;
117 u8 size, offset;
118
119 size = (reg >> 24) & 0x3f;
120 offset = (reg >> 16) & 0x1f;
121 mask = ((1 << size) - 1) << offset;
122 data = (data << offset) & mask;
123 reg &= 0x7f;
124
125 spin_lock_irqsave(&card->lock, flags);
126 data |= inl(card->iobase + reg) & ~mask;
127 outl(data, card->iobase + reg);
128 spin_unlock_irqrestore(&card->lock, flags);
129 } else {
130 spin_lock_irqsave(&card->lock, flags);
131 outl(data, card->iobase + reg);
132 spin_unlock_irqrestore(&card->lock, flags);
133 }
134
135 return;
136}
137
138#ifdef DBGEMU
139void emu10k1_writefn0_2(struct emu10k1_card *card, u32 reg, u32 data, int size)
140{
141 unsigned long flags;
142
143 spin_lock_irqsave(&card->lock, flags);
144
145 if (size == 32)
146 outl(data, card->iobase + (reg & 0x1F));
147 else if (size == 16)
148 outw(data, card->iobase + (reg & 0x1F));
149 else
150 outb(data, card->iobase + (reg & 0x1F));
151
152 spin_unlock_irqrestore(&card->lock, flags);
153
154 return;
155}
156#endif /* DBGEMU */
157
158u32 emu10k1_readfn0(struct emu10k1_card * card, u32 reg)
159{
160 u32 val;
161 unsigned long flags;
162
163 if (reg & 0xff000000) {
164 u32 mask;
165 u8 size, offset;
166
167 size = (reg >> 24) & 0x3f;
168 offset = (reg >> 16) & 0x1f;
169 mask = ((1 << size) - 1) << offset;
170 reg &= 0x7f;
171
172 spin_lock_irqsave(&card->lock, flags);
173 val = inl(card->iobase + reg);
174 spin_unlock_irqrestore(&card->lock, flags);
175
176 return (val & mask) >> offset;
177 } else {
178 spin_lock_irqsave(&card->lock, flags);
179 val = inl(card->iobase + reg);
180 spin_unlock_irqrestore(&card->lock, flags);
181 return val;
182 }
183}
184
185void emu10k1_timer_set(struct emu10k1_card * card, u16 data)
186{
187 unsigned long flags;
188
189 spin_lock_irqsave(&card->lock, flags);
190 outw(data & TIMER_RATE_MASK, card->iobase + TIMER);
191 spin_unlock_irqrestore(&card->lock, flags);
192}
193
194/************************************************************************
195* write/read Emu10k1 pointer-offset register set, accessed through *
196* the PTR and DATA registers *
197*************************************************************************/
198#define A_PTR_ADDRESS_MASK 0x0fff0000
199void sblive_writeptr(struct emu10k1_card *card, u32 reg, u32 channel, u32 data)
200{
201 u32 regptr;
202 unsigned long flags;
203
204 regptr = ((reg << 16) & A_PTR_ADDRESS_MASK) | (channel & PTR_CHANNELNUM_MASK);
205
206 if (reg & 0xff000000) {
207 u32 mask;
208 u8 size, offset;
209
210 size = (reg >> 24) & 0x3f;
211 offset = (reg >> 16) & 0x1f;
212 mask = ((1 << size) - 1) << offset;
213 data = (data << offset) & mask;
214
215 spin_lock_irqsave(&card->lock, flags);
216 outl(regptr, card->iobase + PTR);
217 data |= inl(card->iobase + DATA) & ~mask;
218 outl(data, card->iobase + DATA);
219 spin_unlock_irqrestore(&card->lock, flags);
220 } else {
221 spin_lock_irqsave(&card->lock, flags);
222 outl(regptr, card->iobase + PTR);
223 outl(data, card->iobase + DATA);
224 spin_unlock_irqrestore(&card->lock, flags);
225 }
226}
227
228/* ... : data, reg, ... , TAGLIST_END */
229void sblive_writeptr_tag(struct emu10k1_card *card, u32 channel, ...)
230{
231 va_list args;
232
233 unsigned long flags;
234 u32 reg;
235
236 va_start(args, channel);
237
238 spin_lock_irqsave(&card->lock, flags);
239 while ((reg = va_arg(args, u32)) != TAGLIST_END) {
240 u32 data = va_arg(args, u32);
241 u32 regptr = (((reg << 16) & A_PTR_ADDRESS_MASK)
242 | (channel & PTR_CHANNELNUM_MASK));
243 outl(regptr, card->iobase + PTR);
244 if (reg & 0xff000000) {
245 int size = (reg >> 24) & 0x3f;
246 int offset = (reg >> 16) & 0x1f;
247 u32 mask = ((1 << size) - 1) << offset;
248 data = (data << offset) & mask;
249
250 data |= inl(card->iobase + DATA) & ~mask;
251 }
252 outl(data, card->iobase + DATA);
253 }
254 spin_unlock_irqrestore(&card->lock, flags);
255
256 va_end(args);
257
258 return;
259}
260
261u32 sblive_readptr(struct emu10k1_card * card, u32 reg, u32 channel)
262{
263 u32 regptr, val;
264 unsigned long flags;
265
266 regptr = ((reg << 16) & A_PTR_ADDRESS_MASK) | (channel & PTR_CHANNELNUM_MASK);
267
268 if (reg & 0xff000000) {
269 u32 mask;
270 u8 size, offset;
271
272 size = (reg >> 24) & 0x3f;
273 offset = (reg >> 16) & 0x1f;
274 mask = ((1 << size) - 1) << offset;
275
276 spin_lock_irqsave(&card->lock, flags);
277 outl(regptr, card->iobase + PTR);
278 val = inl(card->iobase + DATA);
279 spin_unlock_irqrestore(&card->lock, flags);
280
281 return (val & mask) >> offset;
282 } else {
283 spin_lock_irqsave(&card->lock, flags);
284 outl(regptr, card->iobase + PTR);
285 val = inl(card->iobase + DATA);
286 spin_unlock_irqrestore(&card->lock, flags);
287
288 return val;
289 }
290}
291
292void emu10k1_irq_enable(struct emu10k1_card *card, u32 irq_mask)
293{
294 u32 val;
295 unsigned long flags;
296
297 DPF(2,"emu10k1_irq_enable()\n");
298
299 spin_lock_irqsave(&card->lock, flags);
300 val = inl(card->iobase + INTE) | irq_mask;
301 outl(val, card->iobase + INTE);
302 spin_unlock_irqrestore(&card->lock, flags);
303 return;
304}
305
306void emu10k1_irq_disable(struct emu10k1_card *card, u32 irq_mask)
307{
308 u32 val;
309 unsigned long flags;
310
311 DPF(2,"emu10k1_irq_disable()\n");
312
313 spin_lock_irqsave(&card->lock, flags);
314 val = inl(card->iobase + INTE) & ~irq_mask;
315 outl(val, card->iobase + INTE);
316 spin_unlock_irqrestore(&card->lock, flags);
317 return;
318}
319
320void emu10k1_clear_stop_on_loop(struct emu10k1_card *card, u32 voicenum)
321{
322 /* Voice interrupt */
323 if (voicenum >= 32)
324 sblive_writeptr(card, SOLEH | ((0x0100 | (voicenum - 32)) << 16), 0, 0);
325 else
326 sblive_writeptr(card, SOLEL | ((0x0100 | voicenum) << 16), 0, 0);
327
328 return;
329}
330
331static void sblive_wcwait(struct emu10k1_card *card, u32 wait)
332{
333 volatile unsigned uCount;
334 u32 newtime = 0, curtime;
335
336 curtime = emu10k1_readfn0(card, WC_SAMPLECOUNTER);
337 while (wait--) {
338 uCount = 0;
339 while (uCount++ < TIMEOUT) {
340 newtime = emu10k1_readfn0(card, WC_SAMPLECOUNTER);
341 if (newtime != curtime)
342 break;
343 }
344
345 if (uCount >= TIMEOUT)
346 break;
347
348 curtime = newtime;
349 }
350}
351
352u16 emu10k1_ac97_read(struct ac97_codec *codec, u8 reg)
353{
354 struct emu10k1_card *card = codec->private_data;
355 u16 data;
356 unsigned long flags;
357
358 spin_lock_irqsave(&card->lock, flags);
359
360 outb(reg, card->iobase + AC97ADDRESS);
361 data = inw(card->iobase + AC97DATA);
362
363 spin_unlock_irqrestore(&card->lock, flags);
364
365 return data;
366}
367
368void emu10k1_ac97_write(struct ac97_codec *codec, u8 reg, u16 value)
369{
370 struct emu10k1_card *card = codec->private_data;
371 unsigned long flags;
372
373 spin_lock_irqsave(&card->lock, flags);
374
375 outb(reg, card->iobase + AC97ADDRESS);
376 outw(value, card->iobase + AC97DATA);
377 outb( AC97_EXTENDED_ID, card->iobase + AC97ADDRESS);
378 spin_unlock_irqrestore(&card->lock, flags);
379}
380
381/*********************************************************
382* MPU access functions *
383**********************************************************/
384
385int emu10k1_mpu_write_data(struct emu10k1_card *card, u8 data)
386{
387 unsigned long flags;
388 int ret;
389
390 if (card->is_audigy) {
391 if ((sblive_readptr(card, A_MUSTAT,0) & MUSTAT_ORDYN) == 0) {
392 sblive_writeptr(card, A_MUDATA, 0, data);
393 ret = 0;
394 } else
395 ret = -1;
396 } else {
397 spin_lock_irqsave(&card->lock, flags);
398
399 if ((inb(card->iobase + MUSTAT) & MUSTAT_ORDYN) == 0) {
400 outb(data, card->iobase + MUDATA);
401 ret = 0;
402 } else
403 ret = -1;
404
405 spin_unlock_irqrestore(&card->lock, flags);
406 }
407
408 return ret;
409}
410
411int emu10k1_mpu_read_data(struct emu10k1_card *card, u8 * data)
412{
413 unsigned long flags;
414 int ret;
415
416 if (card->is_audigy) {
417 if ((sblive_readptr(card, A_MUSTAT,0) & MUSTAT_IRDYN) == 0) {
418 *data = sblive_readptr(card, A_MUDATA,0);
419 ret = 0;
420 } else
421 ret = -1;
422 } else {
423 spin_lock_irqsave(&card->lock, flags);
424
425 if ((inb(card->iobase + MUSTAT) & MUSTAT_IRDYN) == 0) {
426 *data = inb(card->iobase + MUDATA);
427 ret = 0;
428 } else
429 ret = -1;
430
431 spin_unlock_irqrestore(&card->lock, flags);
432 }
433
434 return ret;
435}
436
437int emu10k1_mpu_reset(struct emu10k1_card *card)
438{
439 u8 status;
440 unsigned long flags;
441
442 DPF(2, "emu10k1_mpu_reset()\n");
443 if (card->is_audigy) {
444 if (card->mpuacqcount == 0) {
445 sblive_writeptr(card, A_MUCMD, 0, MUCMD_RESET);
446 sblive_wcwait(card, 8);
447 sblive_writeptr(card, A_MUCMD, 0, MUCMD_RESET);
448 sblive_wcwait(card, 8);
449 sblive_writeptr(card, A_MUCMD, 0, MUCMD_ENTERUARTMODE);
450 sblive_wcwait(card, 8);
451 status = sblive_readptr(card, A_MUDATA, 0);
452 if (status == 0xfe)
453 return 0;
454 else
455 return -1;
456 }
457
458 return 0;
459 } else {
460 if (card->mpuacqcount == 0) {
461 spin_lock_irqsave(&card->lock, flags);
462 outb(MUCMD_RESET, card->iobase + MUCMD);
463 spin_unlock_irqrestore(&card->lock, flags);
464
465 sblive_wcwait(card, 8);
466
467 spin_lock_irqsave(&card->lock, flags);
468 outb(MUCMD_RESET, card->iobase + MUCMD);
469 spin_unlock_irqrestore(&card->lock, flags);
470
471 sblive_wcwait(card, 8);
472
473 spin_lock_irqsave(&card->lock, flags);
474 outb(MUCMD_ENTERUARTMODE, card->iobase + MUCMD);
475 spin_unlock_irqrestore(&card->lock, flags);
476
477 sblive_wcwait(card, 8);
478
479 spin_lock_irqsave(&card->lock, flags);
480 status = inb(card->iobase + MUDATA);
481 spin_unlock_irqrestore(&card->lock, flags);
482
483 if (status == 0xfe)
484 return 0;
485 else
486 return -1;
487 }
488
489 return 0;
490 }
491}
492
493int emu10k1_mpu_acquire(struct emu10k1_card *card)
494{
495 /* FIXME: This should be a macro */
496 ++card->mpuacqcount;
497
498 return 0;
499}
500
501int emu10k1_mpu_release(struct emu10k1_card *card)
502{
503 /* FIXME: this should be a macro */
504 --card->mpuacqcount;
505
506 return 0;
507}
diff --git a/sound/oss/emu10k1/hwaccess.h b/sound/oss/emu10k1/hwaccess.h
deleted file mode 100644
index 85e27bda694..00000000000
--- a/sound/oss/emu10k1/hwaccess.h
+++ /dev/null
@@ -1,247 +0,0 @@
1/*
2 **********************************************************************
3 * hwaccess.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _HWACCESS_H
33#define _HWACCESS_H
34
35#include <linux/fs.h>
36#include <linux/sound.h>
37#include <linux/soundcard.h>
38#include <linux/ac97_codec.h>
39#include <linux/pci.h>
40#include <linux/slab.h>
41#include <linux/sched.h>
42#include <asm/io.h>
43
44#include "efxmgr.h"
45#include "passthrough.h"
46#include "midi.h"
47
48#define EMUPAGESIZE 4096 /* don't change */
49#define NUM_G 64 /* use all channels */
50#define NUM_FXSENDS 4 /* don't change */
51/* setting this to other than a power of two may break some applications */
52#define MAXBUFSIZE 65536
53#define MAXPAGES 8192
54#define BUFMAXPAGES (MAXBUFSIZE / PAGE_SIZE)
55
56#define FLAGS_AVAILABLE 0x0001
57#define FLAGS_READY 0x0002
58
59struct memhandle
60{
61 dma_addr_t dma_handle;
62 void *addr;
63 u32 size;
64};
65
66#define DEBUG_LEVEL 2
67
68#ifdef EMU10K1_DEBUG
69# define DPD(level,x,y...) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ , y );} while(0)
70# define DPF(level,x) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ );} while(0)
71#else
72# define DPD(level,x,y...) do { } while (0) /* not debugging: nothing */
73# define DPF(level,x) do { } while (0)
74#endif /* EMU10K1_DEBUG */
75
76#define ERROR() DPF(1,"error\n")
77
78/* DATA STRUCTURES */
79
80struct emu10k1_waveout
81{
82 u32 send_routing[3];
83 // audigy only:
84 u32 send_routing2[3];
85
86 u32 send_dcba[3];
87 // audigy only:
88 u32 send_hgfe[3];
89};
90#define ROUTE_PCM 0
91#define ROUTE_PT 1
92#define ROUTE_PCM1 2
93
94#define SEND_MONO 0
95#define SEND_LEFT 1
96#define SEND_RIGHT 2
97
98struct emu10k1_wavein
99{
100 struct wiinst *ac97;
101 struct wiinst *mic;
102 struct wiinst *fx;
103
104 u8 recsrc;
105 u32 fxwc;
106};
107
108#define CMD_READ 1
109#define CMD_WRITE 2
110
111struct mixer_private_ioctl {
112 u32 cmd;
113 u32 val[90];
114};
115
116/* bogus ioctls numbers to escape from OSS mixer limitations */
117#define CMD_WRITEFN0 _IOW('D', 0, struct mixer_private_ioctl)
118#define CMD_READFN0 _IOR('D', 1, struct mixer_private_ioctl)
119#define CMD_WRITEPTR _IOW('D', 2, struct mixer_private_ioctl)
120#define CMD_READPTR _IOR('D', 3, struct mixer_private_ioctl)
121#define CMD_SETRECSRC _IOW('D', 4, struct mixer_private_ioctl)
122#define CMD_GETRECSRC _IOR('D', 5, struct mixer_private_ioctl)
123#define CMD_GETVOICEPARAM _IOR('D', 6, struct mixer_private_ioctl)
124#define CMD_SETVOICEPARAM _IOW('D', 7, struct mixer_private_ioctl)
125#define CMD_GETPATCH _IOR('D', 8, struct mixer_private_ioctl)
126#define CMD_GETGPR _IOR('D', 9, struct mixer_private_ioctl)
127#define CMD_GETCTLGPR _IOR('D', 10, struct mixer_private_ioctl)
128#define CMD_SETPATCH _IOW('D', 11, struct mixer_private_ioctl)
129#define CMD_SETGPR _IOW('D', 12, struct mixer_private_ioctl)
130#define CMD_SETCTLGPR _IOW('D', 13, struct mixer_private_ioctl)
131#define CMD_SETGPOUT _IOW('D', 14, struct mixer_private_ioctl)
132#define CMD_GETGPR2OSS _IOR('D', 15, struct mixer_private_ioctl)
133#define CMD_SETGPR2OSS _IOW('D', 16, struct mixer_private_ioctl)
134#define CMD_SETMCH_FX _IOW('D', 17, struct mixer_private_ioctl)
135#define CMD_SETPASSTHROUGH _IOW('D', 18, struct mixer_private_ioctl)
136#define CMD_PRIVATE3_VERSION _IOW('D', 19, struct mixer_private_ioctl)
137#define CMD_AC97_BOOST _IOW('D', 20, struct mixer_private_ioctl)
138
139//up this number when breaking compatibility
140#define PRIVATE3_VERSION 2
141
142struct emu10k1_card
143{
144 struct list_head list;
145
146 struct memhandle virtualpagetable;
147 struct memhandle tankmem;
148 struct memhandle silentpage;
149
150 spinlock_t lock;
151
152 u8 voicetable[NUM_G];
153 u16 emupagetable[MAXPAGES];
154
155 struct list_head timers;
156 u16 timer_delay;
157 spinlock_t timer_lock;
158
159 struct pci_dev *pci_dev;
160 unsigned long iobase;
161 unsigned long length;
162 unsigned short model;
163 unsigned int irq;
164
165 int audio_dev;
166 int audio_dev1;
167 int midi_dev;
168#ifdef EMU10K1_SEQUENCER
169 int seq_dev;
170 struct emu10k1_mididevice *seq_mididev;
171#endif
172
173 struct ac97_codec *ac97;
174 int ac97_supported_mixers;
175 int ac97_stereo_mixers;
176
177 /* Number of first fx voice for multichannel output */
178 u8 mchannel_fx;
179 struct emu10k1_waveout waveout;
180 struct emu10k1_wavein wavein;
181 struct emu10k1_mpuout *mpuout;
182 struct emu10k1_mpuin *mpuin;
183
184 struct mutex open_sem;
185 mode_t open_mode;
186 wait_queue_head_t open_wait;
187
188 u32 mpuacqcount; // Mpu acquire count
189 u32 has_toslink; // TOSLink detection
190
191 u8 chiprev; /* Chip revision */
192 u8 is_audigy;
193 u8 is_aps;
194
195 struct patch_manager mgr;
196 struct pt_data pt;
197};
198
199int emu10k1_addxmgr_alloc(u32, struct emu10k1_card *);
200void emu10k1_addxmgr_free(struct emu10k1_card *, int);
201
202int emu10k1_find_control_gpr(struct patch_manager *, const char *, const char *);
203void emu10k1_set_control_gpr(struct emu10k1_card *, int , s32, int );
204
205void emu10k1_set_volume_gpr(struct emu10k1_card *, int, s32, int);
206
207
208#define VOL_6BIT 0x40
209#define VOL_5BIT 0x20
210#define VOL_4BIT 0x10
211
212#define TIMEOUT 16384
213
214u32 srToPitch(u32);
215
216extern struct list_head emu10k1_devs;
217
218/* Hardware Abstraction Layer access functions */
219
220void emu10k1_writefn0(struct emu10k1_card *, u32, u32);
221void emu10k1_writefn0_2(struct emu10k1_card *, u32, u32, int);
222u32 emu10k1_readfn0(struct emu10k1_card *, u32);
223
224void emu10k1_timer_set(struct emu10k1_card *, u16);
225
226void sblive_writeptr(struct emu10k1_card *, u32, u32, u32);
227void sblive_writeptr_tag(struct emu10k1_card *, u32, ...);
228#define TAGLIST_END 0
229
230u32 sblive_readptr(struct emu10k1_card *, u32 , u32 );
231
232void emu10k1_irq_enable(struct emu10k1_card *, u32);
233void emu10k1_irq_disable(struct emu10k1_card *, u32);
234void emu10k1_clear_stop_on_loop(struct emu10k1_card *, u32);
235
236/* AC97 Codec register access function */
237u16 emu10k1_ac97_read(struct ac97_codec *, u8);
238void emu10k1_ac97_write(struct ac97_codec *, u8, u16);
239
240/* MPU access function*/
241int emu10k1_mpu_write_data(struct emu10k1_card *, u8);
242int emu10k1_mpu_read_data(struct emu10k1_card *, u8 *);
243int emu10k1_mpu_reset(struct emu10k1_card *);
244int emu10k1_mpu_acquire(struct emu10k1_card *);
245int emu10k1_mpu_release(struct emu10k1_card *);
246
247#endif /* _HWACCESS_H */
diff --git a/sound/oss/emu10k1/icardmid.h b/sound/oss/emu10k1/icardmid.h
deleted file mode 100644
index 6a6ef419401..00000000000
--- a/sound/oss/emu10k1/icardmid.h
+++ /dev/null
@@ -1,163 +0,0 @@
1/*
2 **********************************************************************
3 * isblive_mid.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _ICARDMIDI_H
33#define _ICARDMIDI_H
34
35/* MIDI defines */
36#define MIDI_DATA_FIRST 0x00
37#define MIDI_DATA_LAST 0x7F
38#define MIDI_STATUS_FIRST 0x80
39#define MIDI_STATUS_LAST 0xFF
40
41/* Channel status bytes */
42#define MIDI_STATUS_CHANNEL_FIRST 0x80
43#define MIDI_STATUS_CHANNEL_LAST 0xE0
44#define MIDI_STATUS_CHANNEL_MASK 0xF0
45
46/* Channel voice messages */
47#define MIDI_VOICE_NOTE_OFF 0x80
48#define MIDI_VOICE_NOTE_ON 0x90
49#define MIDI_VOICE_POLY_PRESSURE 0xA0
50#define MIDI_VOICE_CONTROL_CHANGE 0xB0
51#define MIDI_VOICE_PROGRAM_CHANGE 0xC0
52#define MIDI_VOICE_CHANNEL_PRESSURE 0xD0
53#define MIDI_VOICE_PITCH_BEND 0xE0
54
55/* Channel mode messages */
56#define MIDI_MODE_CHANNEL MIDI_VOICE_CONTROL_CHANGE
57
58/* System status bytes */
59#define MIDI_STATUS_SYSTEM_FIRST 0xF0
60#define MIDI_STATUS_SYSTEM_LAST 0xFF
61
62/* System exclusive messages */
63#define MIDI_SYSEX_BEGIN 0xF0
64#define MIDI_SYSEX_EOX 0xF7
65
66/* System common messages */
67#define MIDI_COMMON_TCQF 0xF1 /* Time code quarter frame */
68#define MIDI_COMMON_SONG_POSITION 0xF2
69#define MIDI_COMMON_SONG_SELECT 0xF3
70#define MIDI_COMMON_UNDEFINED_F4 0xF4
71#define MIDI_COMMON_UNDEFINED_F5 0xF5
72#define MIDI_COMMON_TUNE_REQUEST 0xF6
73
74/* System real-time messages */
75#define MIDI_RTIME_TIMING_CLOCK 0xF8
76#define MIDI_RTIME_UNDEFINED_F9 0xF9
77#define MIDI_RTIME_START 0xFA
78#define MIDI_RTIME_CONTINUE 0xFB
79#define MIDI_RTIME_STOP 0xFC
80#define MIDI_RTIME_UNDEFINED_FD 0xFD
81#define MIDI_RTIME_ACTIVE_SENSING 0xFE
82#define MIDI_RTIME_SYSTEM_RESET 0xFF
83
84/* Flags for flags parm of midiOutCachePatches(), midiOutCacheDrumPatches() */
85#define MIDI_CACHE_ALL 1
86#define MIDI_CACHE_BESTFIT 2
87#define MIDI_CACHE_QUERY 3
88#define MIDI_UNCACHE 4
89
90/* Event declarations for MPU IRQ Callbacks */
91#define ICARDMIDI_INLONGDATA 0x00000001 /* MIM_LONGDATA */
92#define ICARDMIDI_INLONGERROR 0x00000002 /* MIM_LONGERROR */
93#define ICARDMIDI_OUTLONGDATA 0x00000004 /* MOM_DONE for MPU OUT buffer */
94#define ICARDMIDI_INDATA 0x00000010 /* MIM_DATA */
95#define ICARDMIDI_INDATAERROR 0x00000020 /* MIM_ERROR */
96
97/* Declaration for flags in CARDMIDIBUFFERHDR */
98/* Make it the same as MHDR_DONE, MHDR_INQUEUE in mmsystem.h */
99#define MIDIBUF_DONE 0x00000001
100#define MIDIBUF_INQUEUE 0x00000004
101
102/* Declaration for msg parameter in midiCallbackFn */
103#define ICARDMIDI_OUTBUFFEROK 0x00000001
104#define ICARDMIDI_INMIDIOK 0x00000002
105
106/* Declaration for technology in struct midi_caps */
107#define MT_MIDIPORT 0x00000001 /* In original MIDIOUTCAPS structure */
108#define MT_FMSYNTH 0x00000004 /* In original MIDIOUTCAPS structure */
109#define MT_AWESYNTH 0x00001000
110#define MT_PCISYNTH 0x00002000
111#define MT_PCISYNTH64 0x00004000
112#define CARDMIDI_AWEMASK 0x0000F000
113
114enum LocalErrorCode
115{
116 CTSTATUS_NOTENABLED = 0x7000,
117 CTSTATUS_READY,
118 CTSTATUS_BUSY,
119 CTSTATUS_DATAAVAIL,
120 CTSTATUS_NODATA,
121 CTSTATUS_NEXT_BYTE
122};
123
124/* MIDI data block header */
125struct midi_hdr
126{
127 u8 *reserved; /* Pointer to original locked data block */
128 u32 bufferlength; /* Length of data in data block */
129 u32 bytesrecorded; /* Used for input only */
130 u32 user; /* For client's use */
131 u32 flags; /* Assorted flags (see defines) */
132 struct list_head list; /* Reserved for driver */
133 u8 *data; /* Second copy of first pointer */
134};
135
136/* Enumeration for SetControl */
137enum
138{
139 MIDIOBJVOLUME = 0x1,
140 MIDIQUERYACTIVEINST
141};
142
143struct midi_queue
144{
145 struct midi_queue *next;
146 u32 qtype; /* 0 = short message, 1 = long data */
147 u32 length;
148 u32 sizeLeft;
149 u8 *midibyte;
150 unsigned long refdata;
151};
152
153struct midi_openinfo
154{
155 u32 cbsize;
156 u32 flags;
157 unsigned long refdata;
158 u32 streamid;
159};
160
161int emu10k1_midi_callback(unsigned long , unsigned long, unsigned long *);
162
163#endif /* _ICARDMIDI_H */
diff --git a/sound/oss/emu10k1/icardwav.h b/sound/oss/emu10k1/icardwav.h
deleted file mode 100644
index 25be40928b4..00000000000
--- a/sound/oss/emu10k1/icardwav.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 **********************************************************************
3 * icardwav.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _ICARDWAV_H
33#define _ICARDWAV_H
34
35struct wave_format
36{
37 int id;
38 int samplingrate;
39 u8 bitsperchannel;
40 u8 channels; /* 1 = Mono, 2 = Stereo, 3, ... = Multichannel */
41 u8 bytesperchannel;
42 u8 bytespervoicesample;
43 u8 bytespersample;
44 int bytespersec;
45 u8 passthrough;
46};
47
48/* emu10k1_wave states */
49#define WAVE_STATE_OPEN 0x01
50#define WAVE_STATE_STARTED 0x02
51#define WAVE_STATE_CLOSED 0x04
52
53#endif /* _ICARDWAV_H */
diff --git a/sound/oss/emu10k1/irqmgr.c b/sound/oss/emu10k1/irqmgr.c
deleted file mode 100644
index fb2ce638f01..00000000000
--- a/sound/oss/emu10k1/irqmgr.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 **********************************************************************
3 * irqmgr.c - IRQ manager for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include "hwaccess.h"
33#include "8010.h"
34#include "cardmi.h"
35#include "cardmo.h"
36#include "irqmgr.h"
37
38/* Interrupt handler */
39
40irqreturn_t emu10k1_interrupt(int irq, void *dev_id)
41{
42 struct emu10k1_card *card = (struct emu10k1_card *) dev_id;
43 u32 irqstatus, irqstatus_tmp;
44 int handled = 0;
45
46 DPD(4, "emu10k1_interrupt called, irq = %u\n", irq);
47
48 /*
49 ** NOTE :
50 ** We do a 'while loop' here cos on certain machines, with both
51 ** playback and recording going on at the same time, IRQs will
52 ** stop coming in after a while. Checking IPND indeed shows that
53 ** there are interrupts pending but the PIC says no IRQs pending.
54 ** I suspect that some boards need edge-triggered IRQs but are not
55 ** getting that condition if we don't completely clear the IPND
56 ** (make sure no more interrupts are pending).
57 ** - Eric
58 */
59
60 while ((irqstatus = inl(card->iobase + IPR))) {
61 DPD(4, "irq status %#x\n", irqstatus);
62
63 irqstatus_tmp = irqstatus;
64
65 if (irqstatus & IRQTYPE_TIMER) {
66 emu10k1_timer_irqhandler(card);
67 irqstatus &= ~IRQTYPE_TIMER;
68 }
69
70 if (irqstatus & IRQTYPE_DSP) {
71 emu10k1_dsp_irqhandler(card);
72 irqstatus &= ~IRQTYPE_DSP;
73 }
74
75 if (irqstatus & IRQTYPE_MPUIN) {
76 emu10k1_mpuin_irqhandler(card);
77 irqstatus &= ~IRQTYPE_MPUIN;
78 }
79
80 if (irqstatus & IRQTYPE_MPUOUT) {
81 emu10k1_mpuout_irqhandler(card);
82 irqstatus &= ~IRQTYPE_MPUOUT;
83 }
84
85 if (irqstatus & IPR_MUTE) {
86 emu10k1_mute_irqhandler(card);
87 irqstatus &=~IPR_MUTE;
88 }
89
90 if (irqstatus & IPR_VOLINCR) {
91 emu10k1_volincr_irqhandler(card);
92 irqstatus &=~IPR_VOLINCR;
93 }
94
95 if (irqstatus & IPR_VOLDECR) {
96 emu10k1_voldecr_irqhandler(card);
97 irqstatus &=~IPR_VOLDECR;
98 }
99
100 if (irqstatus){
101 printk(KERN_ERR "emu10k1: Warning, unhandled interrupt: %#08x\n", irqstatus);
102 //make sure any interrupts we don't handle are disabled:
103 emu10k1_irq_disable(card, ~(INTE_MIDIRXENABLE | INTE_MIDITXENABLE | INTE_INTERVALTIMERENB |
104 INTE_VOLDECRENABLE | INTE_VOLINCRENABLE | INTE_MUTEENABLE |
105 INTE_FXDSPENABLE));
106 }
107
108 /* acknowledge interrupt */
109 outl(irqstatus_tmp, card->iobase + IPR);
110 handled = 1;
111 }
112 return IRQ_RETVAL(handled);
113}
diff --git a/sound/oss/emu10k1/irqmgr.h b/sound/oss/emu10k1/irqmgr.h
deleted file mode 100644
index 7e7c9ca1098..00000000000
--- a/sound/oss/emu10k1/irqmgr.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 **********************************************************************
3 * irq.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _IRQ_H
33#define _IRQ_H
34
35/* EMU Irq Types */
36#define IRQTYPE_PCIBUSERROR IPR_PCIERROR
37#define IRQTYPE_MIXERBUTTON (IPR_VOLINCR | IPR_VOLDECR | IPR_MUTE)
38#define IRQTYPE_VOICE (IPR_CHANNELLOOP | IPR_CHANNELNUMBERMASK)
39#define IRQTYPE_RECORD (IPR_ADCBUFFULL | IPR_ADCBUFHALFFULL | IPR_MICBUFFULL | IPR_MICBUFHALFFULL | IPR_EFXBUFFULL | IPR_EFXBUFHALFFULL)
40#define IRQTYPE_MPUOUT (IPR_MIDITRANSBUFEMPTY | A_IPR_MIDITRANSBUFEMPTY2)
41#define IRQTYPE_MPUIN (IPR_MIDIRECVBUFEMPTY | A_IPR_MIDIRECVBUFEMPTY2)
42#define IRQTYPE_TIMER IPR_INTERVALTIMER
43#define IRQTYPE_SPDIF (IPR_GPSPDIFSTATUSCHANGE | IPR_CDROMSTATUSCHANGE)
44#define IRQTYPE_DSP IPR_FXDSP
45
46void emu10k1_timer_irqhandler(struct emu10k1_card *);
47void emu10k1_dsp_irqhandler(struct emu10k1_card *);
48void emu10k1_mute_irqhandler(struct emu10k1_card *);
49void emu10k1_volincr_irqhandler(struct emu10k1_card *);
50void emu10k1_voldecr_irqhandler(struct emu10k1_card *);
51
52#endif /* _IRQ_H */
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
deleted file mode 100644
index 16ac02540a3..00000000000
--- a/sound/oss/emu10k1/main.c
+++ /dev/null
@@ -1,1471 +0,0 @@
1 /*
2 **********************************************************************
3 * main.c - Creative EMU10K1 audio driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up stuff
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 *
32 * Supported devices:
33 * /dev/dsp: Standard /dev/dsp device, OSS-compatible
34 * /dev/dsp1: Routes to rear speakers only
35 * /dev/mixer: Standard /dev/mixer device, OSS-compatible
36 * /dev/midi: Raw MIDI UART device, mostly OSS-compatible
37 * /dev/sequencer: Sequencer Interface (requires sound.o)
38 *
39 * Revision history:
40 * 0.1 beta Initial release
41 * 0.2 Lowered initial mixer vol. Improved on stuttering wave playback. Added MIDI UART support.
42 * 0.3 Fixed mixer routing bug, added APS, joystick support.
43 * 0.4 Added rear-channel, SPDIF support.
44 * 0.5 Source cleanup, SMP fixes, multiopen support, 64 bit arch fixes,
45 * moved bh's to tasklets, moved to the new PCI driver initialization style.
46 * 0.6 Make use of pci_alloc_consistent, improve compatibility layer for 2.2 kernels,
47 * code reorganization and cleanup.
48 * 0.7 Support for the Emu-APS. Bug fixes for voice cache setup, mmaped sound + poll().
49 * Support for setting external TRAM size.
50 * 0.8 Make use of the kernel ac97 interface. Support for a dsp patch manager.
51 * 0.9 Re-enables rear speakers volume controls
52 * 0.10 Initializes rear speaker volume.
53 * Dynamic patch storage allocation.
54 * New private ioctls to change control gpr values.
55 * Enable volume control interrupts.
56 * By default enable dsp routes to digital out.
57 * 0.11 Fixed fx / 4 problem.
58 * 0.12 Implemented mmaped for recording.
59 * Fixed bug: not unreserving mmaped buffer pages.
60 * IRQ handler cleanup.
61 * 0.13 Fixed problem with dsp1
62 * Simplified dsp patch writing (inside the driver)
63 * Fixed several bugs found by the Stanford tools
64 * 0.14 New control gpr to oss mixer mapping feature (Chris Purnell)
65 * Added AC3 Passthrough Support (Juha Yrjola)
66 * Added Support for 5.1 cards (digital out and the third analog out)
67 * 0.15 Added Sequencer Support (Daniel Mack)
68 * Support for multichannel pcm playback (Eduard Hasenleithner)
69 * 0.16 Mixer improvements, added old treble/bass support (Daniel Bertrand)
70 * Small code format cleanup.
71 * Deadlock bug fix for emu10k1_volxxx_irqhandler().
72 * 0.17 Fix for mixer SOUND_MIXER_INFO ioctl.
73 * Fix for HIGHMEM machines (emu10k1 can only do 31 bit bus master)
74 * midi poll initial implementation.
75 * Small mixer fixes/cleanups.
76 * Improved support for 5.1 cards.
77 * 0.18 Fix for possible leak in pci_alloc_consistent()
78 * Cleaned up poll() functions (audio and midi). Don't start input.
79 * Restrict DMA pages used to 512Mib range.
80 * New AC97_BOOST mixer ioctl.
81 * 0.19a Added Support for Audigy Cards
82 * Real fix for kernel with highmem support (cast dma_handle to u32).
83 * Fix recording buffering parameters calculation.
84 * Use unsigned long for variables in bit ops.
85 * 0.20a Fixed recording startup
86 * Fixed timer rate setting (it's a 16-bit register)
87 * 0.21 Converted code to use pci_name() instead of accessing slot_name
88 * directly (Eugene Teo)
89 *********************************************************************/
90
91/* These are only included once per module */
92#include <linux/module.h>
93#include <linux/slab.h>
94#include <linux/init.h>
95#include <linux/delay.h>
96#include <linux/proc_fs.h>
97#include <linux/dma-mapping.h>
98
99#include "hwaccess.h"
100#include "8010.h"
101#include "efxmgr.h"
102#include "cardwo.h"
103#include "cardwi.h"
104#include "cardmo.h"
105#include "cardmi.h"
106#include "recmgr.h"
107#include "ecard.h"
108
109
110#ifdef EMU10K1_SEQUENCER
111#define MIDI_SYNTH_NAME "EMU10K1 MIDI"
112#define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT
113
114#include "../sound_config.h"
115#include "../midi_synth.h"
116
117/* this should be in dev_table.h */
118#define SNDCARD_EMU10K1 46
119#endif
120
121
122/* the emu10k1 _seems_ to only supports 29 bit (512MiB) bit bus master */
123#define EMU10K1_DMA_MASK DMA_29BIT_MASK /* DMA buffer mask for pci_alloc_consist */
124
125#ifndef PCI_VENDOR_ID_CREATIVE
126#define PCI_VENDOR_ID_CREATIVE 0x1102
127#endif
128
129#ifndef PCI_DEVICE_ID_CREATIVE_EMU10K1
130#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
131#endif
132#ifndef PCI_DEVICE_ID_CREATIVE_AUDIGY
133#define PCI_DEVICE_ID_CREATIVE_AUDIGY 0x0004
134#endif
135
136#define EMU_APS_SUBID 0x40011102
137
138enum {
139 EMU10K1 = 0,
140 AUDIGY,
141};
142
143static char *card_names[] __devinitdata = {
144 "EMU10K1",
145 "Audigy",
146};
147
148static struct pci_device_id emu10k1_pci_tbl[] = {
149 {PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_EMU10K1,
150 PCI_ANY_ID, PCI_ANY_ID, 0, 0, EMU10K1},
151 {PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_AUDIGY,
152 PCI_ANY_ID, PCI_ANY_ID, 0, 0, AUDIGY},
153 {0,}
154};
155
156MODULE_DEVICE_TABLE(pci, emu10k1_pci_tbl);
157
158/* Global var instantiation */
159
160LIST_HEAD(emu10k1_devs);
161
162extern struct file_operations emu10k1_audio_fops;
163extern struct file_operations emu10k1_mixer_fops;
164extern struct file_operations emu10k1_midi_fops;
165
166#ifdef EMU10K1_SEQUENCER
167static struct midi_operations emu10k1_midi_operations;
168#endif
169
170extern irqreturn_t emu10k1_interrupt(int, void *);
171
172static int __devinit emu10k1_audio_init(struct emu10k1_card *card)
173{
174 /* Assign default playback voice parameters */
175 if (card->is_audigy)
176 card->mchannel_fx = 0;
177 else
178 card->mchannel_fx = 8;
179
180
181 if (card->is_audigy) {
182 /* mono voice */
183 card->waveout.send_dcba[SEND_MONO] = 0xffffffff;
184 card->waveout.send_hgfe[SEND_MONO] = 0x0000ffff;
185
186 /* stereo voice */
187 /* left */
188 card->waveout.send_dcba[SEND_LEFT] = 0x00ff00ff;
189 card->waveout.send_hgfe[SEND_LEFT] = 0x00007f7f;
190 /* right */
191 card->waveout.send_dcba[SEND_RIGHT] = 0xff00ff00;
192 card->waveout.send_hgfe[SEND_RIGHT] = 0x00007f7f;
193
194 card->waveout.send_routing[ROUTE_PCM] = 0x03020100; // Regular pcm
195 card->waveout.send_routing2[ROUTE_PCM] = 0x07060504;
196
197 card->waveout.send_routing[ROUTE_PT] = 0x3f3f3d3c; // Passthrough
198 card->waveout.send_routing2[ROUTE_PT] = 0x3f3f3f3f;
199
200 card->waveout.send_routing[ROUTE_PCM1] = 0x03020100; // Spare
201 card->waveout.send_routing2[ROUTE_PCM1] = 0x07060404;
202
203 } else {
204 /* mono voice */
205 card->waveout.send_dcba[SEND_MONO] = 0x0000ffff;
206
207 /* stereo voice */
208 /* left */
209 card->waveout.send_dcba[SEND_LEFT] = 0x000000ff;
210 /* right */
211 card->waveout.send_dcba[SEND_RIGHT] = 0x0000ff00;
212
213 card->waveout.send_routing[ROUTE_PCM] = 0x3210; // pcm
214 card->waveout.send_routing[ROUTE_PT] = 0x3210; // passthrough
215 card->waveout.send_routing[ROUTE_PCM1] = 0x7654; // /dev/dsp1
216 }
217
218 /* Assign default recording parameters */
219 /* FIXME */
220 if (card->is_aps)
221 card->wavein.recsrc = WAVERECORD_FX;
222 else
223 card->wavein.recsrc = WAVERECORD_AC97;
224
225 card->wavein.fxwc = 0x0003;
226 return 0;
227}
228
229static void emu10k1_audio_cleanup(struct emu10k1_card *card)
230{
231}
232
233static int __devinit emu10k1_register_devices(struct emu10k1_card *card)
234{
235 card->audio_dev = register_sound_dsp(&emu10k1_audio_fops, -1);
236 if (card->audio_dev < 0) {
237 printk(KERN_ERR "emu10k1: cannot register first audio device!\n");
238 goto err_dev;
239 }
240
241 card->audio_dev1 = register_sound_dsp(&emu10k1_audio_fops, -1);
242 if (card->audio_dev1 < 0) {
243 printk(KERN_ERR "emu10k1: cannot register second audio device!\n");
244 goto err_dev1;
245 }
246
247 card->ac97->dev_mixer = register_sound_mixer(&emu10k1_mixer_fops, -1);
248 if (card->ac97->dev_mixer < 0) {
249 printk(KERN_ERR "emu10k1: cannot register mixer device\n");
250 goto err_mixer;
251 }
252
253 card->midi_dev = register_sound_midi(&emu10k1_midi_fops, -1);
254 if (card->midi_dev < 0) {
255 printk(KERN_ERR "emu10k1: cannot register midi device!\n");
256 goto err_midi;
257 }
258
259#ifdef EMU10K1_SEQUENCER
260 card->seq_dev = sound_alloc_mididev();
261 if (card->seq_dev == -1)
262 printk(KERN_WARNING "emu10k1: unable to register sequencer device!");
263 else {
264 std_midi_synth.midi_dev = card->seq_dev;
265 midi_devs[card->seq_dev] =
266 (struct midi_operations *)
267 kmalloc(sizeof(struct midi_operations), GFP_KERNEL);
268
269 if (midi_devs[card->seq_dev] == NULL) {
270 printk(KERN_ERR "emu10k1: unable to allocate memory!");
271 sound_unload_mididev(card->seq_dev);
272 card->seq_dev = -1;
273 /* return without error */
274 } else {
275 memcpy((char *)midi_devs[card->seq_dev],
276 (char *)&emu10k1_midi_operations,
277 sizeof(struct midi_operations));
278 midi_devs[card->seq_dev]->devc = card;
279 sequencer_init();
280 card->seq_mididev = NULL;
281 }
282 }
283#endif
284 return 0;
285
286err_midi:
287 unregister_sound_mixer(card->ac97->dev_mixer);
288err_mixer:
289 unregister_sound_dsp(card->audio_dev);
290err_dev1:
291 unregister_sound_dsp(card->audio_dev);
292err_dev:
293 return -ENODEV;
294}
295
296static void emu10k1_unregister_devices(struct emu10k1_card *card)
297{
298#ifdef EMU10K1_SEQUENCER
299 if (card->seq_dev > -1) {
300 kfree(midi_devs[card->seq_dev]);
301 midi_devs[card->seq_dev] = NULL;
302 sound_unload_mididev(card->seq_dev);
303 card->seq_dev = -1;
304 }
305#endif
306
307 unregister_sound_midi(card->midi_dev);
308 unregister_sound_mixer(card->ac97->dev_mixer);
309 unregister_sound_dsp(card->audio_dev1);
310 unregister_sound_dsp(card->audio_dev);
311}
312
313static int emu10k1_info_proc (char *page, char **start, off_t off,
314 int count, int *eof, void *data)
315{
316 struct emu10k1_card *card = data;
317 int len = 0;
318
319 if (card == NULL)
320 return -ENODEV;
321
322 len += sprintf (page + len, "Driver Version : %s\n", DRIVER_VERSION);
323 len += sprintf (page + len, "Card type : %s\n", card->is_aps ? "Aps" : (card->is_audigy ? "Audigy" : "Emu10k1"));
324 len += sprintf (page + len, "Revision : %d\n", card->chiprev);
325 len += sprintf (page + len, "Model : %#06x\n", card->model);
326 len += sprintf (page + len, "IO : %#06lx-%#06lx\n", card->iobase, card->iobase + card->length - 1);
327 len += sprintf (page + len, "IRQ : %d\n\n", card->irq);
328
329 len += sprintf (page + len, "Registered /dev Entries:\n");
330 len += sprintf (page + len, "/dev/dsp%d\n", card->audio_dev / 16);
331 len += sprintf (page + len, "/dev/dsp%d\n", card->audio_dev1 / 16);
332 len += sprintf (page + len, "/dev/mixer%d\n", card->ac97->dev_mixer / 16);
333 len += sprintf (page + len, "/dev/midi%d\n", card->midi_dev / 16);
334
335#ifdef EMU10K1_SEQUENCER
336 len += sprintf (page + len, "/dev/sequencer\n");
337#endif
338
339 return len;
340}
341
342static int __devinit emu10k1_proc_init(struct emu10k1_card *card)
343{
344 char s[48];
345
346 if (!proc_mkdir ("driver/emu10k1", NULL)) {
347 printk(KERN_ERR "emu10k1: unable to create proc directory driver/emu10k1\n");
348 goto err_out;
349 }
350
351 sprintf(s, "driver/emu10k1/%s", pci_name(card->pci_dev));
352 if (!proc_mkdir (s, NULL)) {
353 printk(KERN_ERR "emu10k1: unable to create proc directory %s\n", s);
354 goto err_emu10k1_proc;
355 }
356
357 sprintf(s, "driver/emu10k1/%s/info", pci_name(card->pci_dev));
358 if (!create_proc_read_entry (s, 0, NULL, emu10k1_info_proc, card)) {
359 printk(KERN_ERR "emu10k1: unable to create proc entry %s\n", s);
360 goto err_dev_proc;
361 }
362
363 if (!card->is_aps) {
364 sprintf(s, "driver/emu10k1/%s/ac97", pci_name(card->pci_dev));
365 if (!create_proc_read_entry (s, 0, NULL, ac97_read_proc, card->ac97)) {
366 printk(KERN_ERR "emu10k1: unable to create proc entry %s\n", s);
367 goto err_proc_ac97;
368 }
369 }
370
371 return 0;
372
373err_proc_ac97:
374 sprintf(s, "driver/emu10k1/%s/info", pci_name(card->pci_dev));
375 remove_proc_entry(s, NULL);
376
377err_dev_proc:
378 sprintf(s, "driver/emu10k1/%s", pci_name(card->pci_dev));
379 remove_proc_entry(s, NULL);
380
381err_emu10k1_proc:
382 remove_proc_entry("driver/emu10k1", NULL);
383
384err_out:
385 return -EIO;
386}
387
388static void emu10k1_proc_cleanup(struct emu10k1_card *card)
389{
390 char s[48];
391
392 if (!card->is_aps) {
393 sprintf(s, "driver/emu10k1/%s/ac97", pci_name(card->pci_dev));
394 remove_proc_entry(s, NULL);
395 }
396
397 sprintf(s, "driver/emu10k1/%s/info", pci_name(card->pci_dev));
398 remove_proc_entry(s, NULL);
399
400 sprintf(s, "driver/emu10k1/%s", pci_name(card->pci_dev));
401 remove_proc_entry(s, NULL);
402
403 remove_proc_entry("driver/emu10k1", NULL);
404}
405
406static int __devinit emu10k1_mixer_init(struct emu10k1_card *card)
407{
408 struct ac97_codec *codec = ac97_alloc_codec();
409
410 if(codec == NULL)
411 {
412 printk(KERN_ERR "emu10k1: cannot allocate mixer\n");
413 return -EIO;
414 }
415 card->ac97 = codec;
416 card->ac97->private_data = card;
417
418 if (!card->is_aps) {
419 card->ac97->id = 0;
420 card->ac97->codec_read = emu10k1_ac97_read;
421 card->ac97->codec_write = emu10k1_ac97_write;
422
423 if (ac97_probe_codec (card->ac97) == 0) {
424 printk(KERN_ERR "emu10k1: unable to probe AC97 codec\n");
425 goto err_out;
426 }
427 /* 5.1: Enable the additional AC97 Slots and unmute extra channels on AC97 codec */
428 if (codec->codec_read(codec, AC97_EXTENDED_ID) & 0x0080){
429 printk(KERN_INFO "emu10k1: SBLive! 5.1 card detected\n");
430 sblive_writeptr(card, AC97SLOT, 0, AC97SLOT_CNTR | AC97SLOT_LFE);
431 codec->codec_write(codec, AC97_SURROUND_MASTER, 0x0);
432 }
433
434 // Force 5bit:
435 //card->ac97->bit_resolution=5;
436
437 /* these will store the original values and never be modified */
438 card->ac97_supported_mixers = card->ac97->supported_mixers;
439 card->ac97_stereo_mixers = card->ac97->stereo_mixers;
440 }
441
442 return 0;
443
444 err_out:
445 ac97_release_codec(card->ac97);
446 return -EIO;
447}
448
449static void emu10k1_mixer_cleanup(struct emu10k1_card *card)
450{
451 ac97_release_codec(card->ac97);
452}
453
454static int __devinit emu10k1_midi_init(struct emu10k1_card *card)
455{
456 int ret;
457
458 card->mpuout = kzalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL);
459 if (card->mpuout == NULL) {
460 printk(KERN_WARNING "emu10k1: Unable to allocate emu10k1_mpuout: out of memory\n");
461 ret = -ENOMEM;
462 goto err_out1;
463 }
464
465 card->mpuout->intr = 1;
466 card->mpuout->status = FLAGS_AVAILABLE;
467 card->mpuout->state = CARDMIDIOUT_STATE_DEFAULT;
468
469 tasklet_init(&card->mpuout->tasklet, emu10k1_mpuout_bh, (unsigned long) card);
470
471 spin_lock_init(&card->mpuout->lock);
472
473 card->mpuin = kzalloc(sizeof(struct emu10k1_mpuin), GFP_KERNEL);
474 if (card->mpuin == NULL) {
475 printk(KERN_WARNING "emu10k1: Unable to allocate emu10k1_mpuin: out of memory\n");
476 ret = -ENOMEM;
477 goto err_out2;
478 }
479
480 card->mpuin->status = FLAGS_AVAILABLE;
481
482 tasklet_init(&card->mpuin->tasklet, emu10k1_mpuin_bh, (unsigned long) card->mpuin);
483
484 spin_lock_init(&card->mpuin->lock);
485
486 /* Reset the MPU port */
487 if (emu10k1_mpu_reset(card) < 0) {
488 ERROR();
489 ret = -EIO;
490 goto err_out3;
491 }
492
493 return 0;
494
495err_out3:
496 kfree(card->mpuin);
497err_out2:
498 kfree(card->mpuout);
499err_out1:
500 return ret;
501}
502
503static void emu10k1_midi_cleanup(struct emu10k1_card *card)
504{
505 tasklet_kill(&card->mpuout->tasklet);
506 kfree(card->mpuout);
507
508 tasklet_kill(&card->mpuin->tasklet);
509 kfree(card->mpuin);
510}
511
512static void __devinit voice_init(struct emu10k1_card *card)
513{
514 int i;
515
516 for (i = 0; i < NUM_G; i++)
517 card->voicetable[i] = VOICE_USAGE_FREE;
518}
519
520static void __devinit timer_init(struct emu10k1_card *card)
521{
522 INIT_LIST_HEAD(&card->timers);
523 card->timer_delay = TIMER_STOPPED;
524 spin_lock_init(&card->timer_lock);
525}
526
527static void __devinit addxmgr_init(struct emu10k1_card *card)
528{
529 u32 count;
530
531 for (count = 0; count < MAXPAGES; count++)
532 card->emupagetable[count] = 0;
533
534 /* Mark first page as used */
535 /* This page is reserved by the driver */
536 card->emupagetable[0] = 0x8001;
537 card->emupagetable[1] = MAXPAGES - 1;
538}
539
540static void fx_cleanup(struct patch_manager *mgr)
541{
542 int i;
543 for(i = 0; i < mgr->current_pages; i++)
544 free_page((unsigned long) mgr->patch[i]);
545}
546
547static int __devinit fx_init(struct emu10k1_card *card)
548{
549 struct patch_manager *mgr = &card->mgr;
550 struct dsp_patch *patch;
551 struct dsp_rpatch *rpatch;
552 s32 left, right;
553 int i;
554 u32 pc = 0;
555 u32 patch_n=0;
556 struct emu_efx_info_t emu_efx_info[2]=
557 {{ 20, 10, 0x400, 0x100, 0x20 },
558 { 24, 12, 0x600, 0x400, 0x60 },
559 };
560
561
562 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
563 mgr->ctrl_gpr[i][0] = -1;
564 mgr->ctrl_gpr[i][1] = -1;
565 }
566
567
568 if (card->is_audigy)
569 mgr->current_pages = (2 + PATCHES_PER_PAGE - 1) / PATCHES_PER_PAGE;
570 else
571 /* !! The number below must equal the number of patches, currently 11 !! */
572 mgr->current_pages = (11 + PATCHES_PER_PAGE - 1) / PATCHES_PER_PAGE;
573
574 for (i = 0; i < mgr->current_pages; i++) {
575 mgr->patch[i] = (void *)__get_free_page(GFP_KERNEL);
576 if (mgr->patch[i] == NULL) {
577 mgr->current_pages = i;
578 fx_cleanup(mgr);
579 return -ENOMEM;
580 }
581 memset(mgr->patch[i], 0, PAGE_SIZE);
582 }
583
584 if (card->is_audigy) {
585 for (i = 0; i < 1024; i++)
586 OP(0xf, 0x0c0, 0x0c0, 0x0cf, 0x0c0);
587
588 for (i = 0; i < 512 ; i++)
589 sblive_writeptr(card, A_GPR_BASE+i,0,0);
590
591 pc=0;
592
593 //Pcm input volume
594 OP(0, 0x402, 0x0c0, 0x406, 0x000);
595 OP(0, 0x403, 0x0c0, 0x407, 0x001);
596
597 //CD-Digital input Volume
598 OP(0, 0x404, 0x0c0, 0x40d, 0x42);
599 OP(0, 0x405, 0x0c0, 0x40f, 0x43);
600
601 // CD + PCM
602 OP(6, 0x400, 0x0c0, 0x402, 0x404);
603 OP(6, 0x401, 0x0c0, 0x403, 0x405);
604
605 // Front Output + Master Volume
606 OP(0, 0x68, 0x0c0, 0x408, 0x400);
607 OP(0, 0x69, 0x0c0, 0x409, 0x401);
608
609 // Add-in analog inputs for other speakers
610 OP(6, 0x400, 0x40, 0x400, 0xc0);
611 OP(6, 0x401, 0x41, 0x401, 0xc0);
612
613 // Digital Front + Master Volume
614 OP(0, 0x60, 0x0c0, 0x408, 0x400);
615 OP(0, 0x61, 0x0c0, 0x409, 0x401);
616
617 // Rear Output + Rear Volume
618 OP(0, 0x06e, 0x0c0, 0x419, 0x400);
619 OP(0, 0x06f, 0x0c0, 0x41a, 0x401);
620
621 // Digital Rear Output + Rear Volume
622 OP(0, 0x066, 0x0c0, 0x419, 0x400);
623 OP(0, 0x067, 0x0c0, 0x41a, 0x401);
624
625 // Audigy Drive, Headphone out
626 OP(6, 0x64, 0x0c0, 0x0c0, 0x400);
627 OP(6, 0x65, 0x0c0, 0x0c0, 0x401);
628
629 // ac97 Recording
630 OP(6, 0x76, 0x0c0, 0x0c0, 0x40);
631 OP(6, 0x77, 0x0c0, 0x0c0, 0x41);
632
633 // Center = sub = Left/2 + Right/2
634 OP(0xe, 0x400, 0x401, 0xcd, 0x400);
635
636 // center/sub Volume (master)
637 OP(0, 0x06a, 0x0c0, 0x408, 0x400);
638 OP(0, 0x06b, 0x0c0, 0x409, 0x400);
639
640 // Digital center/sub Volume (master)
641 OP(0, 0x062, 0x0c0, 0x408, 0x400);
642 OP(0, 0x063, 0x0c0, 0x409, 0x400);
643
644 ROUTING_PATCH_START(rpatch, "Routing");
645 ROUTING_PATCH_END(rpatch);
646
647 /* delimiter patch */
648 patch = PATCH(mgr, patch_n);
649 patch->code_size = 0;
650
651
652 sblive_writeptr(card, 0x53, 0, 0);
653 } else {
654 for (i = 0; i < 512 ; i++)
655 OP(6, 0x40, 0x40, 0x40, 0x40);
656
657 for (i = 0; i < 256; i++)
658 sblive_writeptr_tag(card, 0,
659 FXGPREGBASE + i, 0,
660 TANKMEMADDRREGBASE + i, 0,
661 TAGLIST_END);
662
663
664 pc = 0;
665
666 //first free GPR = 0x11b
667
668
669 /* FX volume correction and Volume control*/
670 INPUT_PATCH_START(patch, "Pcm L vol", 0x0, 0);
671 GET_OUTPUT_GPR(patch, 0x100, 0x0);
672 GET_CONTROL_GPR(patch, 0x106, "Vol", 0, 0x7fffffff);
673 GET_DYNAMIC_GPR(patch, 0x112);
674
675 OP(4, 0x112, 0x40, PCM_IN_L, 0x44); //*4
676 OP(0, 0x100, 0x040, 0x112, 0x106); //*vol
677 INPUT_PATCH_END(patch);
678
679
680 INPUT_PATCH_START(patch, "Pcm R vol", 0x1, 0);
681 GET_OUTPUT_GPR(patch, 0x101, 0x1);
682 GET_CONTROL_GPR(patch, 0x107, "Vol", 0, 0x7fffffff);
683 GET_DYNAMIC_GPR(patch, 0x112);
684
685 OP(4, 0x112, 0x40, PCM_IN_R, 0x44);
686 OP(0, 0x101, 0x040, 0x112, 0x107);
687
688 INPUT_PATCH_END(patch);
689
690
691 // CD-Digital In Volume control
692 INPUT_PATCH_START(patch, "CD-Digital Vol L", 0x12, 0);
693 GET_OUTPUT_GPR(patch, 0x10c, 0x12);
694 GET_CONTROL_GPR(patch, 0x10d, "Vol", 0, 0x7fffffff);
695
696 OP(0, 0x10c, 0x040, SPDIF_CD_L, 0x10d);
697 INPUT_PATCH_END(patch);
698
699 INPUT_PATCH_START(patch, "CD-Digital Vol R", 0x13, 0);
700 GET_OUTPUT_GPR(patch, 0x10e, 0x13);
701 GET_CONTROL_GPR(patch, 0x10f, "Vol", 0, 0x7fffffff);
702
703 OP(0, 0x10e, 0x040, SPDIF_CD_R, 0x10f);
704 INPUT_PATCH_END(patch);
705
706 //Volume Correction for Multi-channel Inputs
707 INPUT_PATCH_START(patch, "Multi-Channel Gain", 0x08, 0);
708 patch->input=patch->output=0x3F00;
709
710 GET_OUTPUT_GPR(patch, 0x113, MULTI_FRONT_L);
711 GET_OUTPUT_GPR(patch, 0x114, MULTI_FRONT_R);
712 GET_OUTPUT_GPR(patch, 0x115, MULTI_REAR_L);
713 GET_OUTPUT_GPR(patch, 0x116, MULTI_REAR_R);
714 GET_OUTPUT_GPR(patch, 0x117, MULTI_CENTER);
715 GET_OUTPUT_GPR(patch, 0x118, MULTI_LFE);
716
717 OP(4, 0x113, 0x40, MULTI_FRONT_L, 0x44);
718 OP(4, 0x114, 0x40, MULTI_FRONT_R, 0x44);
719 OP(4, 0x115, 0x40, MULTI_REAR_L, 0x44);
720 OP(4, 0x116, 0x40, MULTI_REAR_R, 0x44);
721 OP(4, 0x117, 0x40, MULTI_CENTER, 0x44);
722 OP(4, 0x118, 0x40, MULTI_LFE, 0x44);
723
724 INPUT_PATCH_END(patch);
725
726
727 //Routing patch start
728 ROUTING_PATCH_START(rpatch, "Routing");
729 GET_INPUT_GPR(rpatch, 0x100, 0x0);
730 GET_INPUT_GPR(rpatch, 0x101, 0x1);
731 GET_INPUT_GPR(rpatch, 0x10c, 0x12);
732 GET_INPUT_GPR(rpatch, 0x10e, 0x13);
733 GET_INPUT_GPR(rpatch, 0x113, MULTI_FRONT_L);
734 GET_INPUT_GPR(rpatch, 0x114, MULTI_FRONT_R);
735 GET_INPUT_GPR(rpatch, 0x115, MULTI_REAR_L);
736 GET_INPUT_GPR(rpatch, 0x116, MULTI_REAR_R);
737 GET_INPUT_GPR(rpatch, 0x117, MULTI_CENTER);
738 GET_INPUT_GPR(rpatch, 0x118, MULTI_LFE);
739
740 GET_DYNAMIC_GPR(rpatch, 0x102);
741 GET_DYNAMIC_GPR(rpatch, 0x103);
742
743 GET_OUTPUT_GPR(rpatch, 0x104, 0x8);
744 GET_OUTPUT_GPR(rpatch, 0x105, 0x9);
745 GET_OUTPUT_GPR(rpatch, 0x10a, 0x2);
746 GET_OUTPUT_GPR(rpatch, 0x10b, 0x3);
747
748
749 /* input buffer */
750 OP(6, 0x102, AC97_IN_L, 0x40, 0x40);
751 OP(6, 0x103, AC97_IN_R, 0x40, 0x40);
752
753
754 /* Digital In + PCM + MULTI_FRONT-> AC97 out (front speakers)*/
755 OP(6, AC97_FRONT_L, 0x100, 0x10c, 0x113);
756
757 CONNECT(MULTI_FRONT_L, AC97_FRONT_L);
758 CONNECT(PCM_IN_L, AC97_FRONT_L);
759 CONNECT(SPDIF_CD_L, AC97_FRONT_L);
760
761 OP(6, AC97_FRONT_R, 0x101, 0x10e, 0x114);
762
763 CONNECT(MULTI_FRONT_R, AC97_FRONT_R);
764 CONNECT(PCM_IN_R, AC97_FRONT_R);
765 CONNECT(SPDIF_CD_R, AC97_FRONT_R);
766
767 /* Digital In + PCM + AC97 In + PCM1 + MULTI_REAR --> Rear Channel */
768 OP(6, 0x104, PCM1_IN_L, 0x100, 0x115);
769 OP(6, 0x104, 0x104, 0x10c, 0x102);
770
771 CONNECT(MULTI_REAR_L, ANALOG_REAR_L);
772 CONNECT(AC97_IN_L, ANALOG_REAR_L);
773 CONNECT(PCM_IN_L, ANALOG_REAR_L);
774 CONNECT(SPDIF_CD_L, ANALOG_REAR_L);
775 CONNECT(PCM1_IN_L, ANALOG_REAR_L);
776
777 OP(6, 0x105, PCM1_IN_R, 0x101, 0x116);
778 OP(6, 0x105, 0x105, 0x10e, 0x103);
779
780 CONNECT(MULTI_REAR_R, ANALOG_REAR_R);
781 CONNECT(AC97_IN_R, ANALOG_REAR_R);
782 CONNECT(PCM_IN_R, ANALOG_REAR_R);
783 CONNECT(SPDIF_CD_R, ANALOG_REAR_R);
784 CONNECT(PCM1_IN_R, ANALOG_REAR_R);
785
786 /* Digital In + PCM + AC97 In + MULTI_FRONT --> Digital out */
787 OP(6, 0x10b, 0x100, 0x102, 0x10c);
788 OP(6, 0x10b, 0x10b, 0x113, 0x40);
789
790 CONNECT(MULTI_FRONT_L, DIGITAL_OUT_L);
791 CONNECT(PCM_IN_L, DIGITAL_OUT_L);
792 CONNECT(AC97_IN_L, DIGITAL_OUT_L);
793 CONNECT(SPDIF_CD_L, DIGITAL_OUT_L);
794
795 OP(6, 0x10a, 0x101, 0x103, 0x10e);
796 OP(6, 0x10b, 0x10b, 0x114, 0x40);
797
798 CONNECT(MULTI_FRONT_R, DIGITAL_OUT_R);
799 CONNECT(PCM_IN_R, DIGITAL_OUT_R);
800 CONNECT(AC97_IN_R, DIGITAL_OUT_R);
801 CONNECT(SPDIF_CD_R, DIGITAL_OUT_R);
802
803 /* AC97 In --> ADC Recording Buffer */
804 OP(6, ADC_REC_L, 0x102, 0x40, 0x40);
805
806 CONNECT(AC97_IN_L, ADC_REC_L);
807
808 OP(6, ADC_REC_R, 0x103, 0x40, 0x40);
809
810 CONNECT(AC97_IN_R, ADC_REC_R);
811
812
813 /* fx12:Analog-Center */
814 OP(6, ANALOG_CENTER, 0x117, 0x40, 0x40);
815 CONNECT(MULTI_CENTER, ANALOG_CENTER);
816
817 /* fx11:Analog-LFE */
818 OP(6, ANALOG_LFE, 0x118, 0x40, 0x40);
819 CONNECT(MULTI_LFE, ANALOG_LFE);
820
821 /* fx12:Digital-Center */
822 OP(6, DIGITAL_CENTER, 0x117, 0x40, 0x40);
823 CONNECT(MULTI_CENTER, DIGITAL_CENTER);
824
825 /* fx11:Analog-LFE */
826 OP(6, DIGITAL_LFE, 0x118, 0x40, 0x40);
827 CONNECT(MULTI_LFE, DIGITAL_LFE);
828
829 ROUTING_PATCH_END(rpatch);
830
831
832 // Rear volume control
833 OUTPUT_PATCH_START(patch, "Vol Rear L", 0x8, 0);
834 GET_INPUT_GPR(patch, 0x104, 0x8);
835 GET_CONTROL_GPR(patch, 0x119, "Vol", 0, 0x7fffffff);
836
837 OP(0, ANALOG_REAR_L, 0x040, 0x104, 0x119);
838 OUTPUT_PATCH_END(patch);
839
840 OUTPUT_PATCH_START(patch, "Vol Rear R", 0x9, 0);
841 GET_INPUT_GPR(patch, 0x105, 0x9);
842 GET_CONTROL_GPR(patch, 0x11a, "Vol", 0, 0x7fffffff);
843
844 OP(0, ANALOG_REAR_R, 0x040, 0x105, 0x11a);
845 OUTPUT_PATCH_END(patch);
846
847
848 //Master volume control on front-digital
849 OUTPUT_PATCH_START(patch, "Vol Master L", 0x2, 1);
850 GET_INPUT_GPR(patch, 0x10a, 0x2);
851 GET_CONTROL_GPR(patch, 0x108, "Vol", 0, 0x7fffffff);
852
853 OP(0, DIGITAL_OUT_L, 0x040, 0x10a, 0x108);
854 OUTPUT_PATCH_END(patch);
855
856
857 OUTPUT_PATCH_START(patch, "Vol Master R", 0x3, 1);
858 GET_INPUT_GPR(patch, 0x10b, 0x3);
859 GET_CONTROL_GPR(patch, 0x109, "Vol", 0, 0x7fffffff);
860
861 OP(0, DIGITAL_OUT_R, 0x040, 0x10b, 0x109);
862 OUTPUT_PATCH_END(patch);
863
864
865 /* delimiter patch */
866 patch = PATCH(mgr, patch_n);
867 patch->code_size = 0;
868
869
870 sblive_writeptr(card, DBG, 0, 0);
871 }
872
873 spin_lock_init(&mgr->lock);
874
875 // Set up Volume controls, try to keep this the same for both Audigy and Live
876
877 //Master volume
878 mgr->ctrl_gpr[SOUND_MIXER_VOLUME][0] = 8;
879 mgr->ctrl_gpr[SOUND_MIXER_VOLUME][1] = 9;
880
881 left = card->ac97->mixer_state[SOUND_MIXER_VOLUME] & 0xff;
882 right = (card->ac97->mixer_state[SOUND_MIXER_VOLUME] >> 8) & 0xff;
883
884 emu10k1_set_volume_gpr(card, 8, left, 1 << card->ac97->bit_resolution);
885 emu10k1_set_volume_gpr(card, 9, right, 1 << card->ac97->bit_resolution);
886
887 //Rear volume
888 mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][0] = 0x19;
889 mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][1] = 0x1a;
890
891 left = right = 67;
892 card->ac97->mixer_state[SOUND_MIXER_OGAIN] = (right << 8) | left;
893
894 card->ac97->supported_mixers |= SOUND_MASK_OGAIN;
895 card->ac97->stereo_mixers |= SOUND_MASK_OGAIN;
896
897 emu10k1_set_volume_gpr(card, 0x19, left, VOL_5BIT);
898 emu10k1_set_volume_gpr(card, 0x1a, right, VOL_5BIT);
899
900 //PCM Volume
901 mgr->ctrl_gpr[SOUND_MIXER_PCM][0] = 6;
902 mgr->ctrl_gpr[SOUND_MIXER_PCM][1] = 7;
903
904 left = card->ac97->mixer_state[SOUND_MIXER_PCM] & 0xff;
905 right = (card->ac97->mixer_state[SOUND_MIXER_PCM] >> 8) & 0xff;
906
907 emu10k1_set_volume_gpr(card, 6, left, VOL_5BIT);
908 emu10k1_set_volume_gpr(card, 7, right, VOL_5BIT);
909
910 //CD-Digital Volume
911 mgr->ctrl_gpr[SOUND_MIXER_DIGITAL1][0] = 0xd;
912 mgr->ctrl_gpr[SOUND_MIXER_DIGITAL1][1] = 0xf;
913
914 left = right = 67;
915 card->ac97->mixer_state[SOUND_MIXER_DIGITAL1] = (right << 8) | left;
916
917 card->ac97->supported_mixers |= SOUND_MASK_DIGITAL1;
918 card->ac97->stereo_mixers |= SOUND_MASK_DIGITAL1;
919
920 emu10k1_set_volume_gpr(card, 0xd, left, VOL_5BIT);
921 emu10k1_set_volume_gpr(card, 0xf, right, VOL_5BIT);
922
923
924 //hard wire the ac97's pcm, pcm volume is done above using dsp code.
925 if (card->is_audigy)
926 //for Audigy, we mute it and use the philips 6 channel DAC instead
927 emu10k1_ac97_write(card->ac97, 0x18, 0x8000);
928 else
929 //For the Live we hardwire it to full volume
930 emu10k1_ac97_write(card->ac97, 0x18, 0x0);
931
932 //remove it from the ac97_codec's control
933 card->ac97_supported_mixers &= ~SOUND_MASK_PCM;
934 card->ac97_stereo_mixers &= ~SOUND_MASK_PCM;
935
936 //set Igain to 0dB by default, maybe consider hardwiring it here.
937 emu10k1_ac97_write(card->ac97, AC97_RECORD_GAIN, 0x0000);
938 card->ac97->mixer_state[SOUND_MIXER_IGAIN] = 0x101;
939
940 return 0;
941}
942
943static int __devinit hw_init(struct emu10k1_card *card)
944{
945 int nCh;
946 u32 pagecount; /* tmp */
947 int ret;
948
949 /* Disable audio and lock cache */
950 emu10k1_writefn0(card, HCFG, HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE);
951
952 /* Reset recording buffers */
953 sblive_writeptr_tag(card, 0,
954 MICBS, ADCBS_BUFSIZE_NONE,
955 MICBA, 0,
956 FXBS, ADCBS_BUFSIZE_NONE,
957 FXBA, 0,
958 ADCBS, ADCBS_BUFSIZE_NONE,
959 ADCBA, 0,
960 TAGLIST_END);
961
962 /* Disable channel interrupt */
963 emu10k1_writefn0(card, INTE, 0);
964 sblive_writeptr_tag(card, 0,
965 CLIEL, 0,
966 CLIEH, 0,
967 SOLEL, 0,
968 SOLEH, 0,
969 TAGLIST_END);
970
971 if (card->is_audigy) {
972 sblive_writeptr_tag(card,0,
973 0x5e,0xf00,
974 0x5f,0x3,
975 TAGLIST_END);
976 }
977
978 /* Init envelope engine */
979 for (nCh = 0; nCh < NUM_G; nCh++) {
980 sblive_writeptr_tag(card, nCh,
981 DCYSUSV, 0,
982 IP, 0,
983 VTFT, 0xffff,
984 CVCF, 0xffff,
985 PTRX, 0,
986 //CPF, 0,
987 CCR, 0,
988
989 PSST, 0,
990 DSL, 0x10,
991 CCCA, 0,
992 Z1, 0,
993 Z2, 0,
994 FXRT, 0xd01c0000,
995
996 ATKHLDM, 0,
997 DCYSUSM, 0,
998 IFATN, 0xffff,
999 PEFE, 0,
1000 FMMOD, 0,
1001 TREMFRQ, 24, /* 1 Hz */
1002 FM2FRQ2, 24, /* 1 Hz */
1003 TEMPENV, 0,
1004
1005 /*** These are last so OFF prevents writing ***/
1006 LFOVAL2, 0,
1007 LFOVAL1, 0,
1008 ATKHLDV, 0,
1009 ENVVOL, 0,
1010 ENVVAL, 0,
1011 TAGLIST_END);
1012 sblive_writeptr(card, CPF, nCh, 0);
1013 /*
1014 Audigy FXRT initialization
1015 reversed eng'd, may not be accurate.
1016 */
1017 if (card->is_audigy) {
1018 sblive_writeptr_tag(card,nCh,
1019 0x4c,0x0,
1020 0x4d,0x0,
1021 0x4e,0x0,
1022 0x4f,0x0,
1023 A_FXRT1, 0x3f3f3f3f,
1024 A_FXRT2, 0x3f3f3f3f,
1025 A_SENDAMOUNTS, 0,
1026 TAGLIST_END);
1027 }
1028 }
1029
1030
1031 /*
1032 ** Init to 0x02109204 :
1033 ** Clock accuracy = 0 (1000ppm)
1034 ** Sample Rate = 2 (48kHz)
1035 ** Audio Channel = 1 (Left of 2)
1036 ** Source Number = 0 (Unspecified)
1037 ** Generation Status = 1 (Original for Cat Code 12)
1038 ** Cat Code = 12 (Digital Signal Mixer)
1039 ** Mode = 0 (Mode 0)
1040 ** Emphasis = 0 (None)
1041 ** CP = 1 (Copyright unasserted)
1042 ** AN = 0 (Digital audio)
1043 ** P = 0 (Consumer)
1044 */
1045
1046 sblive_writeptr_tag(card, 0,
1047
1048 /* SPDIF0 */
1049 SPCS0, (SPCS_CLKACCY_1000PPM | 0x002000000 |
1050 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT),
1051
1052 /* SPDIF1 */
1053 SPCS1, (SPCS_CLKACCY_1000PPM | 0x002000000 |
1054 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT),
1055
1056 /* SPDIF2 & SPDIF3 */
1057 SPCS2, (SPCS_CLKACCY_1000PPM | 0x002000000 |
1058 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT),
1059
1060 TAGLIST_END);
1061
1062 if (card->is_audigy && (card->chiprev == 4)) {
1063 /* Hacks for Alice3 to work independent of haP16V driver */
1064 u32 tmp;
1065
1066 //Setup SRCMulti_I2S SamplingRate
1067 tmp = sblive_readptr(card, A_SPDIF_SAMPLERATE, 0);
1068 tmp &= 0xfffff1ff;
1069 tmp |= (0x2<<9);
1070 sblive_writeptr(card, A_SPDIF_SAMPLERATE, 0, tmp);
1071
1072 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */
1073 emu10k1_writefn0(card, 0x20, 0x600000);
1074 emu10k1_writefn0(card, 0x24, 0x14);
1075
1076 /* Setup SRCMulti Input Audio Enable */
1077 emu10k1_writefn0(card, 0x20, 0x6E0000);
1078 emu10k1_writefn0(card, 0x24, 0xFF00FF00);
1079 }
1080
1081 ret = fx_init(card); /* initialize effects engine */
1082 if (ret < 0)
1083 return ret;
1084
1085 card->tankmem.size = 0;
1086
1087 card->virtualpagetable.size = MAXPAGES * sizeof(u32);
1088
1089 card->virtualpagetable.addr = pci_alloc_consistent(card->pci_dev, card->virtualpagetable.size, &card->virtualpagetable.dma_handle);
1090 if (card->virtualpagetable.addr == NULL) {
1091 ERROR();
1092 ret = -ENOMEM;
1093 goto err0;
1094 }
1095
1096 card->silentpage.size = EMUPAGESIZE;
1097
1098 card->silentpage.addr = pci_alloc_consistent(card->pci_dev, card->silentpage.size, &card->silentpage.dma_handle);
1099 if (card->silentpage.addr == NULL) {
1100 ERROR();
1101 ret = -ENOMEM;
1102 goto err1;
1103 }
1104
1105 for (pagecount = 0; pagecount < MAXPAGES; pagecount++)
1106 ((u32 *) card->virtualpagetable.addr)[pagecount] = cpu_to_le32(((u32) card->silentpage.dma_handle * 2) | pagecount);
1107
1108 /* Init page table & tank memory base register */
1109 sblive_writeptr_tag(card, 0,
1110 PTB, (u32) card->virtualpagetable.dma_handle,
1111 TCB, 0,
1112 TCBS, 0,
1113 TAGLIST_END);
1114
1115 for (nCh = 0; nCh < NUM_G; nCh++) {
1116 sblive_writeptr_tag(card, nCh,
1117 MAPA, MAP_PTI_MASK | ((u32) card->silentpage.dma_handle * 2),
1118 MAPB, MAP_PTI_MASK | ((u32) card->silentpage.dma_handle * 2),
1119 TAGLIST_END);
1120 }
1121
1122 /* Hokay, now enable the AUD bit */
1123 /* Enable Audio = 1 */
1124 /* Mute Disable Audio = 0 */
1125 /* Lock Tank Memory = 1 */
1126 /* Lock Sound Memory = 0 */
1127 /* Auto Mute = 1 */
1128 if (card->is_audigy) {
1129 if (card->chiprev == 4)
1130 emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_AC3ENABLE_CDSPDIF | HCFG_AC3ENABLE_GPSPDIF | HCFG_AUTOMUTE | HCFG_JOYENABLE);
1131 else
1132 emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_AUTOMUTE | HCFG_JOYENABLE);
1133 } else {
1134 if (card->model == 0x20 || card->model == 0xc400 ||
1135 (card->model == 0x21 && card->chiprev < 6))
1136 emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE);
1137 else
1138 emu10k1_writefn0(card, HCFG, HCFG_AUDIOENABLE | HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE);
1139 }
1140 /* Enable Vol_Ctrl irqs */
1141 emu10k1_irq_enable(card, INTE_VOLINCRENABLE | INTE_VOLDECRENABLE | INTE_MUTEENABLE | INTE_FXDSPENABLE);
1142
1143 if (card->is_audigy && (card->chiprev == 4)) {
1144 /* Unmute Analog now. Set GPO6 to 1 for Apollo.
1145 * This has to be done after init ALice3 I2SOut beyond 48KHz.
1146 * So, sequence is important. */
1147 u32 tmp = emu10k1_readfn0(card, A_IOCFG);
1148 tmp |= 0x0040;
1149 emu10k1_writefn0(card, A_IOCFG, tmp);
1150 }
1151
1152 /* FIXME: TOSLink detection */
1153 card->has_toslink = 0;
1154
1155 /* Initialize digital passthrough variables */
1156 card->pt.pos_gpr = card->pt.intr_gpr = card->pt.enable_gpr = -1;
1157 card->pt.selected = 0;
1158 card->pt.state = PT_STATE_INACTIVE;
1159 card->pt.spcs_to_use = 0x01;
1160 card->pt.patch_name = "AC3pass";
1161 card->pt.intr_gpr_name = "count";
1162 card->pt.enable_gpr_name = "enable";
1163 card->pt.pos_gpr_name = "ptr";
1164 spin_lock_init(&card->pt.lock);
1165 init_waitqueue_head(&card->pt.wait);
1166
1167/* tmp = sblive_readfn0(card, HCFG);
1168 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) {
1169 sblive_writefn0(card, HCFG, tmp | 0x800);
1170
1171 udelay(512);
1172
1173 if (tmp != (sblive_readfn0(card, HCFG) & ~0x800)) {
1174 card->has_toslink = 1;
1175 sblive_writefn0(card, HCFG, tmp);
1176 }
1177 }
1178*/
1179 return 0;
1180
1181 err1:
1182 pci_free_consistent(card->pci_dev, card->virtualpagetable.size, card->virtualpagetable.addr, card->virtualpagetable.dma_handle);
1183 err0:
1184 fx_cleanup(&card->mgr);
1185
1186 return ret;
1187}
1188
1189static int __devinit emu10k1_init(struct emu10k1_card *card)
1190{
1191 /* Init Card */
1192 if (hw_init(card) < 0)
1193 return -1;
1194
1195 voice_init(card);
1196 timer_init(card);
1197 addxmgr_init(card);
1198
1199 DPD(2, " hw control register -> %#x\n", emu10k1_readfn0(card, HCFG));
1200
1201 return 0;
1202}
1203
1204static void emu10k1_cleanup(struct emu10k1_card *card)
1205{
1206 int ch;
1207
1208 emu10k1_writefn0(card, INTE, 0);
1209
1210 /** Shutdown the chip **/
1211 for (ch = 0; ch < NUM_G; ch++)
1212 sblive_writeptr(card, DCYSUSV, ch, 0);
1213
1214 for (ch = 0; ch < NUM_G; ch++) {
1215 sblive_writeptr_tag(card, ch,
1216 VTFT, 0,
1217 CVCF, 0,
1218 PTRX, 0,
1219 //CPF, 0,
1220 TAGLIST_END);
1221 sblive_writeptr(card, CPF, ch, 0);
1222 }
1223
1224 /* Disable audio and lock cache */
1225 emu10k1_writefn0(card, HCFG, HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE);
1226
1227 sblive_writeptr_tag(card, 0,
1228 PTB, 0,
1229
1230 /* Reset recording buffers */
1231 MICBS, ADCBS_BUFSIZE_NONE,
1232 MICBA, 0,
1233 FXBS, ADCBS_BUFSIZE_NONE,
1234 FXBA, 0,
1235 FXWC, 0,
1236 ADCBS, ADCBS_BUFSIZE_NONE,
1237 ADCBA, 0,
1238 TCBS, 0,
1239 TCB, 0,
1240 DBG, 0x8000,
1241
1242 /* Disable channel interrupt */
1243 CLIEL, 0,
1244 CLIEH, 0,
1245 SOLEL, 0,
1246 SOLEH, 0,
1247 TAGLIST_END);
1248
1249 if (card->is_audigy)
1250 sblive_writeptr(card, 0, A_DBG, A_DBG_SINGLE_STEP);
1251
1252 pci_free_consistent(card->pci_dev, card->virtualpagetable.size, card->virtualpagetable.addr, card->virtualpagetable.dma_handle);
1253 pci_free_consistent(card->pci_dev, card->silentpage.size, card->silentpage.addr, card->silentpage.dma_handle);
1254
1255 if(card->tankmem.size != 0)
1256 pci_free_consistent(card->pci_dev, card->tankmem.size, card->tankmem.addr, card->tankmem.dma_handle);
1257
1258 /* release patch storage memory */
1259 fx_cleanup(&card->mgr);
1260}
1261
1262/* Driver initialization routine */
1263static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
1264{
1265 struct emu10k1_card *card;
1266 u32 subsysvid;
1267 int ret;
1268
1269 if (pci_set_dma_mask(pci_dev, EMU10K1_DMA_MASK)) {
1270 printk(KERN_ERR "emu10k1: architecture does not support 29bit PCI busmaster DMA\n");
1271 return -ENODEV;
1272 }
1273
1274 if (pci_enable_device(pci_dev))
1275 return -EIO;
1276
1277 pci_set_master(pci_dev);
1278
1279 if ((card = kzalloc(sizeof(struct emu10k1_card), GFP_KERNEL)) == NULL) {
1280 printk(KERN_ERR "emu10k1: out of memory\n");
1281 return -ENOMEM;
1282 }
1283
1284 card->iobase = pci_resource_start(pci_dev, 0);
1285 card->length = pci_resource_len(pci_dev, 0);
1286
1287 if (request_region(card->iobase, card->length, card_names[pci_id->driver_data]) == NULL) {
1288 printk(KERN_ERR "emu10k1: IO space in use\n");
1289 ret = -EBUSY;
1290 goto err_region;
1291 }
1292
1293 pci_set_drvdata(pci_dev, card);
1294
1295 card->irq = pci_dev->irq;
1296 card->pci_dev = pci_dev;
1297
1298 /* Reserve IRQ Line */
1299 if (request_irq(card->irq, emu10k1_interrupt, IRQF_SHARED, card_names[pci_id->driver_data], card)) {
1300 printk(KERN_ERR "emu10k1: IRQ in use\n");
1301 ret = -EBUSY;
1302 goto err_irq;
1303 }
1304
1305 pci_read_config_byte(pci_dev, PCI_REVISION_ID, &card->chiprev);
1306 pci_read_config_word(pci_dev, PCI_SUBSYSTEM_ID, &card->model);
1307
1308 printk(KERN_INFO "emu10k1: %s rev %d model %#04x found, IO at %#04lx-%#04lx, IRQ %d\n",
1309 card_names[pci_id->driver_data], card->chiprev, card->model, card->iobase,
1310 card->iobase + card->length - 1, card->irq);
1311
1312 if (pci_id->device == PCI_DEVICE_ID_CREATIVE_AUDIGY)
1313 card->is_audigy = 1;
1314
1315 pci_read_config_dword(pci_dev, PCI_SUBSYSTEM_VENDOR_ID, &subsysvid);
1316 card->is_aps = (subsysvid == EMU_APS_SUBID);
1317
1318 spin_lock_init(&card->lock);
1319 mutex_init(&card->open_sem);
1320 card->open_mode = 0;
1321 init_waitqueue_head(&card->open_wait);
1322
1323 ret = emu10k1_audio_init(card);
1324 if (ret < 0) {
1325 printk(KERN_ERR "emu10k1: cannot initialize audio devices\n");
1326 goto err_audio;
1327 }
1328
1329 ret = emu10k1_mixer_init(card);
1330 if (ret < 0) {
1331 printk(KERN_ERR "emu10k1: cannot initialize AC97 codec\n");
1332 goto err_mixer;
1333 }
1334
1335 ret = emu10k1_midi_init(card);
1336 if (ret < 0) {
1337 printk(KERN_ERR "emu10k1: cannot register midi device\n");
1338 goto err_midi;
1339 }
1340
1341 ret = emu10k1_init(card);
1342 if (ret < 0) {
1343 printk(KERN_ERR "emu10k1: cannot initialize device\n");
1344 goto err_emu10k1_init;
1345 }
1346
1347 if (card->is_aps)
1348 emu10k1_ecard_init(card);
1349
1350 ret = emu10k1_register_devices(card);
1351 if (ret < 0)
1352 goto err_register;
1353
1354 /* proc entries must be created after registering devices, as
1355 * emu10k1_info_proc prints card->audio_dev &co. */
1356 ret = emu10k1_proc_init(card);
1357 if (ret < 0) {
1358 printk(KERN_ERR "emu10k1: cannot initialize proc directory\n");
1359 goto err_proc;
1360 }
1361
1362 list_add(&card->list, &emu10k1_devs);
1363
1364 return 0;
1365
1366err_proc:
1367 emu10k1_unregister_devices(card);
1368
1369err_register:
1370 emu10k1_cleanup(card);
1371
1372err_emu10k1_init:
1373 emu10k1_midi_cleanup(card);
1374
1375err_midi:
1376 emu10k1_mixer_cleanup(card);
1377
1378err_mixer:
1379 emu10k1_audio_cleanup(card);
1380
1381err_audio:
1382 free_irq(card->irq, card);
1383
1384err_irq:
1385 release_region(card->iobase, card->length);
1386 pci_set_drvdata(pci_dev, NULL);
1387
1388err_region:
1389 kfree(card);
1390
1391 return ret;
1392}
1393
1394static void __devexit emu10k1_remove(struct pci_dev *pci_dev)
1395{
1396 struct emu10k1_card *card = pci_get_drvdata(pci_dev);
1397
1398 list_del(&card->list);
1399
1400 emu10k1_unregister_devices(card);
1401 emu10k1_cleanup(card);
1402 emu10k1_midi_cleanup(card);
1403 emu10k1_mixer_cleanup(card);
1404 emu10k1_proc_cleanup(card);
1405 emu10k1_audio_cleanup(card);
1406 free_irq(card->irq, card);
1407 release_region(card->iobase, card->length);
1408 kfree(card);
1409 pci_set_drvdata(pci_dev, NULL);
1410}
1411
1412MODULE_AUTHOR("Bertrand Lee, Cai Ying. (Email to: emu10k1-devel@lists.sourceforge.net)");
1413MODULE_DESCRIPTION("Creative EMU10K1 PCI Audio Driver v" DRIVER_VERSION "\nCopyright (C) 1999 Creative Technology Ltd.");
1414MODULE_LICENSE("GPL");
1415
1416static struct pci_driver emu10k1_pci_driver = {
1417 .name = "emu10k1",
1418 .id_table = emu10k1_pci_tbl,
1419 .probe = emu10k1_probe,
1420 .remove = __devexit_p(emu10k1_remove),
1421};
1422
1423static int __init emu10k1_init_module(void)
1424{
1425 printk(KERN_INFO "Creative EMU10K1 PCI Audio Driver, version " DRIVER_VERSION ", " __TIME__ " " __DATE__ "\n");
1426
1427 return pci_register_driver(&emu10k1_pci_driver);
1428}
1429
1430static void __exit emu10k1_cleanup_module(void)
1431{
1432 pci_unregister_driver(&emu10k1_pci_driver);
1433
1434 return;
1435}
1436
1437module_init(emu10k1_init_module);
1438module_exit(emu10k1_cleanup_module);
1439
1440#ifdef EMU10K1_SEQUENCER
1441
1442/* in midi.c */
1443extern int emu10k1_seq_midi_open(int dev, int mode,
1444 void (*input)(int dev, unsigned char midi_byte),
1445 void (*output)(int dev));
1446extern void emu10k1_seq_midi_close(int dev);
1447extern int emu10k1_seq_midi_out(int dev, unsigned char midi_byte);
1448extern int emu10k1_seq_midi_start_read(int dev);
1449extern int emu10k1_seq_midi_end_read(int dev);
1450extern void emu10k1_seq_midi_kick(int dev);
1451extern int emu10k1_seq_midi_buffer_status(int dev);
1452
1453static struct midi_operations emu10k1_midi_operations =
1454{
1455 THIS_MODULE,
1456 {"EMU10K1 MIDI", 0, 0, SNDCARD_EMU10K1},
1457 &std_midi_synth,
1458 {0},
1459 emu10k1_seq_midi_open,
1460 emu10k1_seq_midi_close,
1461 NULL,
1462 emu10k1_seq_midi_out,
1463 emu10k1_seq_midi_start_read,
1464 emu10k1_seq_midi_end_read,
1465 emu10k1_seq_midi_kick,
1466 NULL,
1467 emu10k1_seq_midi_buffer_status,
1468 NULL
1469};
1470
1471#endif
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
deleted file mode 100644
index df1e990449a..00000000000
--- a/sound/oss/emu10k1/midi.c
+++ /dev/null
@@ -1,614 +0,0 @@
1/*
2 **********************************************************************
3 * midi.c - /dev/midi interface for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/module.h>
33#include <linux/poll.h>
34#include <linux/slab.h>
35#include <linux/sched.h>
36#include <linux/smp_lock.h>
37#include <asm/uaccess.h>
38
39#include "hwaccess.h"
40#include "cardmo.h"
41#include "cardmi.h"
42#include "midi.h"
43
44#ifdef EMU10K1_SEQUENCER
45#include "../sound_config.h"
46#endif
47
48static DEFINE_SPINLOCK(midi_spinlock);
49
50static void init_midi_hdr(struct midi_hdr *midihdr)
51{
52 midihdr->bufferlength = MIDIIN_BUFLEN;
53 midihdr->bytesrecorded = 0;
54 midihdr->flags = 0;
55}
56
57static int midiin_add_buffer(struct emu10k1_mididevice *midi_dev, struct midi_hdr **midihdrptr)
58{
59 struct midi_hdr *midihdr;
60
61 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL) {
62 ERROR();
63 return -EINVAL;
64 }
65
66 init_midi_hdr(midihdr);
67
68 midihdr->data = kmalloc(MIDIIN_BUFLEN, GFP_KERNEL);
69 if (!midihdr->data) {
70 ERROR();
71 kfree(midihdr);
72 return -1;
73 }
74
75 if (emu10k1_mpuin_add_buffer(midi_dev->card->mpuin, midihdr) < 0) {
76 ERROR();
77 kfree(midihdr->data);
78 kfree(midihdr);
79 return -1;
80 }
81
82 *midihdrptr = midihdr;
83 list_add_tail(&midihdr->list, &midi_dev->mid_hdrs);
84
85 return 0;
86}
87
88static int emu10k1_midi_open(struct inode *inode, struct file *file)
89{
90 int minor = iminor(inode);
91 struct emu10k1_card *card = NULL;
92 struct emu10k1_mididevice *midi_dev;
93 struct list_head *entry;
94
95 DPF(2, "emu10k1_midi_open()\n");
96
97 /* Check for correct device to open */
98 list_for_each(entry, &emu10k1_devs) {
99 card = list_entry(entry, struct emu10k1_card, list);
100
101 if (card->midi_dev == minor)
102 goto match;
103 }
104
105 return -ENODEV;
106
107match:
108#ifdef EMU10K1_SEQUENCER
109 if (card->seq_mididev) /* card is opened by sequencer */
110 return -EBUSY;
111#endif
112
113 /* Wait for device to become free */
114 mutex_lock(&card->open_sem);
115 while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
116 if (file->f_flags & O_NONBLOCK) {
117 mutex_unlock(&card->open_sem);
118 return -EBUSY;
119 }
120
121 mutex_unlock(&card->open_sem);
122 interruptible_sleep_on(&card->open_wait);
123
124 if (signal_pending(current)) {
125 return -ERESTARTSYS;
126 }
127
128 mutex_lock(&card->open_sem);
129 }
130
131 if ((midi_dev = kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
132 return -EINVAL;
133
134 midi_dev->card = card;
135 midi_dev->mistate = MIDIIN_STATE_STOPPED;
136 init_waitqueue_head(&midi_dev->oWait);
137 init_waitqueue_head(&midi_dev->iWait);
138 midi_dev->ird = 0;
139 midi_dev->iwr = 0;
140 midi_dev->icnt = 0;
141 INIT_LIST_HEAD(&midi_dev->mid_hdrs);
142
143 if (file->f_mode & FMODE_READ) {
144 struct midi_openinfo dsCardMidiOpenInfo;
145 struct midi_hdr *midihdr1;
146 struct midi_hdr *midihdr2;
147
148 dsCardMidiOpenInfo.refdata = (unsigned long) midi_dev;
149
150 if (emu10k1_mpuin_open(card, &dsCardMidiOpenInfo) < 0) {
151 ERROR();
152 kfree(midi_dev);
153 return -ENODEV;
154 }
155
156 /* Add two buffers to receive sysex buffer */
157 if (midiin_add_buffer(midi_dev, &midihdr1) < 0) {
158 kfree(midi_dev);
159 return -ENODEV;
160 }
161
162 if (midiin_add_buffer(midi_dev, &midihdr2) < 0) {
163 list_del(&midihdr1->list);
164 kfree(midihdr1->data);
165 kfree(midihdr1);
166 kfree(midi_dev);
167 return -ENODEV;
168 }
169 }
170
171 if (file->f_mode & FMODE_WRITE) {
172 struct midi_openinfo dsCardMidiOpenInfo;
173
174 dsCardMidiOpenInfo.refdata = (unsigned long) midi_dev;
175
176 if (emu10k1_mpuout_open(card, &dsCardMidiOpenInfo) < 0) {
177 ERROR();
178 kfree(midi_dev);
179 return -ENODEV;
180 }
181 }
182
183 file->private_data = (void *) midi_dev;
184
185 card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
186
187 mutex_unlock(&card->open_sem);
188
189 return nonseekable_open(inode, file);
190}
191
192static int emu10k1_midi_release(struct inode *inode, struct file *file)
193{
194 struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data;
195 struct emu10k1_card *card;
196
197 lock_kernel();
198
199 card = midi_dev->card;
200 DPF(2, "emu10k1_midi_release()\n");
201
202 if (file->f_mode & FMODE_WRITE) {
203 if (!(file->f_flags & O_NONBLOCK)) {
204
205 while (!signal_pending(current) && (card->mpuout->firstmidiq != NULL)) {
206 DPF(4, "Cannot close - buffers not empty\n");
207
208 interruptible_sleep_on(&midi_dev->oWait);
209
210 }
211 }
212
213 emu10k1_mpuout_close(card);
214 }
215
216 if (file->f_mode & FMODE_READ) {
217 struct midi_hdr *midihdr;
218
219 if (midi_dev->mistate == MIDIIN_STATE_STARTED) {
220 emu10k1_mpuin_stop(card);
221 midi_dev->mistate = MIDIIN_STATE_STOPPED;
222 }
223
224 emu10k1_mpuin_reset(card);
225 emu10k1_mpuin_close(card);
226
227 while (!list_empty(&midi_dev->mid_hdrs)) {
228 midihdr = list_entry(midi_dev->mid_hdrs.next, struct midi_hdr, list);
229
230 list_del(midi_dev->mid_hdrs.next);
231 kfree(midihdr->data);
232 kfree(midihdr);
233 }
234 }
235
236 kfree(midi_dev);
237
238 mutex_lock(&card->open_sem);
239 card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
240 mutex_unlock(&card->open_sem);
241 wake_up_interruptible(&card->open_wait);
242
243 unlock_kernel();
244
245 return 0;
246}
247
248static ssize_t emu10k1_midi_read(struct file *file, char __user *buffer, size_t count, loff_t * pos)
249{
250 struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data;
251 ssize_t ret = 0;
252 u16 cnt;
253 unsigned long flags;
254
255 DPD(4, "emu10k1_midi_read(), count %#x\n", (u32) count);
256
257 if (!access_ok(VERIFY_WRITE, buffer, count))
258 return -EFAULT;
259
260 if (midi_dev->mistate == MIDIIN_STATE_STOPPED) {
261 if (emu10k1_mpuin_start(midi_dev->card) < 0) {
262 ERROR();
263 return -EINVAL;
264 }
265
266 midi_dev->mistate = MIDIIN_STATE_STARTED;
267 }
268
269 while (count > 0) {
270 cnt = MIDIIN_BUFLEN - midi_dev->ird;
271
272 spin_lock_irqsave(&midi_spinlock, flags);
273
274 if (midi_dev->icnt < cnt)
275 cnt = midi_dev->icnt;
276
277 spin_unlock_irqrestore(&midi_spinlock, flags);
278
279 if (cnt > count)
280 cnt = count;
281
282 if (cnt <= 0) {
283 if (file->f_flags & O_NONBLOCK)
284 return ret ? ret : -EAGAIN;
285 DPF(2, " Go to sleep...\n");
286
287 interruptible_sleep_on(&midi_dev->iWait);
288
289 if (signal_pending(current))
290 return ret ? ret : -ERESTARTSYS;
291
292 continue;
293 }
294
295 if (copy_to_user(buffer, midi_dev->iBuf + midi_dev->ird, cnt)) {
296 ERROR();
297 return ret ? ret : -EFAULT;
298 }
299
300 midi_dev->ird += cnt;
301 midi_dev->ird %= MIDIIN_BUFLEN;
302
303 spin_lock_irqsave(&midi_spinlock, flags);
304
305 midi_dev->icnt -= cnt;
306
307 spin_unlock_irqrestore(&midi_spinlock, flags);
308
309 count -= cnt;
310 buffer += cnt;
311 ret += cnt;
312
313 if (midi_dev->icnt == 0)
314 break;
315 }
316
317 return ret;
318}
319
320static ssize_t emu10k1_midi_write(struct file *file, const char __user *buffer, size_t count, loff_t * pos)
321{
322 struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data;
323 struct midi_hdr *midihdr;
324 unsigned long flags;
325
326 DPD(4, "emu10k1_midi_write(), count=%#x\n", (u32) count);
327
328 if (!access_ok(VERIFY_READ, buffer, count))
329 return -EFAULT;
330
331 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL)
332 return -EINVAL;
333
334 midihdr->bufferlength = count;
335 midihdr->bytesrecorded = 0;
336 midihdr->flags = 0;
337
338 midihdr->data = kmalloc(count, GFP_KERNEL);
339 if (!midihdr->data) {
340 ERROR();
341 kfree(midihdr);
342 return -EINVAL;
343 }
344
345 if (copy_from_user(midihdr->data, buffer, count)) {
346 kfree(midihdr->data);
347 kfree(midihdr);
348 return -EFAULT;
349 }
350
351 spin_lock_irqsave(&midi_spinlock, flags);
352
353 if (emu10k1_mpuout_add_buffer(midi_dev->card, midihdr) < 0) {
354 ERROR();
355 kfree(midihdr->data);
356 kfree(midihdr);
357 spin_unlock_irqrestore(&midi_spinlock, flags);
358 return -EINVAL;
359 }
360
361 spin_unlock_irqrestore(&midi_spinlock, flags);
362
363 return count;
364}
365
366static unsigned int emu10k1_midi_poll(struct file *file, struct poll_table_struct *wait)
367{
368 struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data;
369 unsigned long flags;
370 unsigned int mask = 0;
371
372 DPF(4, "emu10k1_midi_poll() called\n");
373
374 if (file->f_mode & FMODE_WRITE)
375 poll_wait(file, &midi_dev->oWait, wait);
376
377 if (file->f_mode & FMODE_READ)
378 poll_wait(file, &midi_dev->iWait, wait);
379
380 spin_lock_irqsave(&midi_spinlock, flags);
381
382 if (file->f_mode & FMODE_WRITE)
383 mask |= POLLOUT | POLLWRNORM;
384
385 if (file->f_mode & FMODE_READ) {
386 if (midi_dev->mistate == MIDIIN_STATE_STARTED)
387 if (midi_dev->icnt > 0)
388 mask |= POLLIN | POLLRDNORM;
389 }
390
391 spin_unlock_irqrestore(&midi_spinlock, flags);
392
393 return mask;
394}
395
396int emu10k1_midi_callback(unsigned long msg, unsigned long refdata, unsigned long *pmsg)
397{
398 struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) refdata;
399 struct midi_hdr *midihdr = NULL;
400 unsigned long flags;
401 int i;
402
403 DPF(4, "emu10k1_midi_callback()\n");
404
405 spin_lock_irqsave(&midi_spinlock, flags);
406
407 switch (msg) {
408 case ICARDMIDI_OUTLONGDATA:
409 midihdr = (struct midi_hdr *) pmsg[2];
410
411 kfree(midihdr->data);
412 kfree(midihdr);
413 wake_up_interruptible(&midi_dev->oWait);
414
415 break;
416
417 case ICARDMIDI_INLONGDATA:
418 midihdr = (struct midi_hdr *) pmsg[2];
419
420 for (i = 0; i < midihdr->bytesrecorded; i++) {
421 midi_dev->iBuf[midi_dev->iwr++] = midihdr->data[i];
422 midi_dev->iwr %= MIDIIN_BUFLEN;
423 }
424
425 midi_dev->icnt += midihdr->bytesrecorded;
426
427 if (midi_dev->mistate == MIDIIN_STATE_STARTED) {
428 init_midi_hdr(midihdr);
429 emu10k1_mpuin_add_buffer(midi_dev->card->mpuin, midihdr);
430 wake_up_interruptible(&midi_dev->iWait);
431 }
432 break;
433
434 case ICARDMIDI_INDATA:
435 {
436 u8 *pBuf = (u8 *) & pmsg[1];
437 u16 bytesvalid = pmsg[2];
438
439 for (i = 0; i < bytesvalid; i++) {
440 midi_dev->iBuf[midi_dev->iwr++] = pBuf[i];
441 midi_dev->iwr %= MIDIIN_BUFLEN;
442 }
443
444 midi_dev->icnt += bytesvalid;
445 }
446
447 wake_up_interruptible(&midi_dev->iWait);
448 break;
449
450 default: /* Unknown message */
451 spin_unlock_irqrestore(&midi_spinlock, flags);
452 return -1;
453 }
454
455 spin_unlock_irqrestore(&midi_spinlock, flags);
456
457 return 0;
458}
459
460/* MIDI file operations */
461const struct file_operations emu10k1_midi_fops = {
462 .owner = THIS_MODULE,
463 .read = emu10k1_midi_read,
464 .write = emu10k1_midi_write,
465 .poll = emu10k1_midi_poll,
466 .open = emu10k1_midi_open,
467 .release = emu10k1_midi_release,
468};
469
470
471#ifdef EMU10K1_SEQUENCER
472
473/* functions used for sequencer access */
474
475int emu10k1_seq_midi_open(int dev, int mode,
476 void (*input) (int dev, unsigned char data),
477 void (*output) (int dev))
478{
479 struct emu10k1_card *card;
480 struct midi_openinfo dsCardMidiOpenInfo;
481 struct emu10k1_mididevice *midi_dev;
482
483 if (midi_devs[dev] == NULL || midi_devs[dev]->devc == NULL)
484 return -EINVAL;
485
486 card = midi_devs[dev]->devc;
487
488 if (card->open_mode) /* card is opened native */
489 return -EBUSY;
490
491 DPF(2, "emu10k1_seq_midi_open()\n");
492
493 if ((midi_dev = kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
494 return -EINVAL;
495
496 midi_dev->card = card;
497 midi_dev->mistate = MIDIIN_STATE_STOPPED;
498 init_waitqueue_head(&midi_dev->oWait);
499 init_waitqueue_head(&midi_dev->iWait);
500 midi_dev->ird = 0;
501 midi_dev->iwr = 0;
502 midi_dev->icnt = 0;
503 INIT_LIST_HEAD(&midi_dev->mid_hdrs);
504
505 dsCardMidiOpenInfo.refdata = (unsigned long) midi_dev;
506
507 if (emu10k1_mpuout_open(card, &dsCardMidiOpenInfo) < 0) {
508 ERROR();
509 return -ENODEV;
510 }
511
512 card->seq_mididev = midi_dev;
513
514 return 0;
515}
516
517void emu10k1_seq_midi_close(int dev)
518{
519 struct emu10k1_card *card;
520
521 DPF(2, "emu10k1_seq_midi_close()\n");
522 if (midi_devs[dev] == NULL || midi_devs[dev]->devc == NULL)
523 return;
524
525 card = midi_devs[dev]->devc;
526 emu10k1_mpuout_close(card);
527
528 kfree(card->seq_mididev);
529 card->seq_mididev = NULL;
530}
531
532int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
533{
534 struct emu10k1_card *card;
535 struct midi_hdr *midihdr;
536 unsigned long flags;
537
538 if (midi_devs[dev] == NULL || midi_devs[dev]->devc == NULL)
539 return -EINVAL;
540
541 card = midi_devs[dev]->devc;
542
543 if ((midihdr = kmalloc(sizeof(struct midi_hdr), GFP_KERNEL)) == NULL)
544 return -EINVAL;
545
546 midihdr->bufferlength = 1;
547 midihdr->bytesrecorded = 0;
548 midihdr->flags = 0;
549
550 midihdr->data = kmalloc(1, GFP_KERNEL);
551 if (!midihdr->data) {
552 ERROR();
553 kfree(midihdr);
554 return -EINVAL;
555 }
556
557 *(midihdr->data) = midi_byte;
558
559 spin_lock_irqsave(&midi_spinlock, flags);
560
561 if (emu10k1_mpuout_add_buffer(card, midihdr) < 0) {
562 ERROR();
563 kfree(midihdr->data);
564 kfree(midihdr);
565 spin_unlock_irqrestore(&midi_spinlock, flags);
566 return -EINVAL;
567 }
568
569 spin_unlock_irqrestore(&midi_spinlock, flags);
570
571 return 1;
572}
573
574int emu10k1_seq_midi_start_read(int dev)
575{
576 return 0;
577}
578
579int emu10k1_seq_midi_end_read(int dev)
580{
581 return 0;
582}
583
584void emu10k1_seq_midi_kick(int dev)
585{
586}
587
588int emu10k1_seq_midi_buffer_status(int dev)
589{
590 int count;
591 struct midi_queue *queue;
592 struct emu10k1_card *card;
593
594 if (midi_devs[dev] == NULL || midi_devs[dev]->devc == NULL)
595 return -EINVAL;
596
597 count = 0;
598
599 card = midi_devs[dev]->devc;
600 queue = card->mpuout->firstmidiq;
601
602 while (queue != NULL) {
603 count++;
604 if (queue == card->mpuout->lastmidiq)
605 break;
606
607 queue = queue->next;
608 }
609
610 return count;
611}
612
613#endif
614
diff --git a/sound/oss/emu10k1/midi.h b/sound/oss/emu10k1/midi.h
deleted file mode 100644
index 2459ec929e8..00000000000
--- a/sound/oss/emu10k1/midi.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 **********************************************************************
3 * midi.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _MIDI_H
33#define _MIDI_H
34
35#define FMODE_MIDI_SHIFT 3
36#define FMODE_MIDI_READ (FMODE_READ << FMODE_MIDI_SHIFT)
37#define FMODE_MIDI_WRITE (FMODE_WRITE << FMODE_MIDI_SHIFT)
38
39#define MIDIIN_STATE_STARTED 0x00000001
40#define MIDIIN_STATE_STOPPED 0x00000002
41
42#define MIDIIN_BUFLEN 1024
43
44struct emu10k1_mididevice
45{
46 struct emu10k1_card *card;
47 u32 mistate;
48 wait_queue_head_t oWait;
49 wait_queue_head_t iWait;
50 s8 iBuf[MIDIIN_BUFLEN];
51 u16 ird, iwr, icnt;
52 struct list_head mid_hdrs;
53};
54
55/* uncomment next line to use midi port on Audigy drive */
56//#define USE_AUDIGY_DRIVE_MIDI
57
58#ifdef USE_AUDIGY_DRIVE_MIDI
59#define A_MUDATA A_MUDATA2
60#define A_MUCMD A_MUCMD2
61#define A_MUSTAT A_MUCMD2
62#define A_IPR_MIDITRANSBUFEMPTY A_IPR_MIDITRANSBUFEMPTY2
63#define A_IPR_MIDIRECVBUFEMPTY A_IPR_MIDIRECVBUFEMPTY2
64#define A_INTE_MIDITXENABLE A_INTE_MIDITXENABLE2
65#define A_INTE_MIDIRXENABLE A_INTE_MIDIRXENABLE2
66#else
67#define A_MUDATA A_MUDATA1
68#define A_MUCMD A_MUCMD1
69#define A_MUSTAT A_MUCMD1
70#define A_IPR_MIDITRANSBUFEMPTY A_IPR_MIDITRANSBUFEMPTY1
71#define A_IPR_MIDIRECVBUFEMPTY A_IPR_MIDIRECVBUFEMPTY1
72#define A_INTE_MIDITXENABLE A_INTE_MIDITXENABLE1
73#define A_INTE_MIDIRXENABLE A_INTE_MIDIRXENABLE1
74#endif
75
76
77#endif /* _MIDI_H */
78
diff --git a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
deleted file mode 100644
index bc3805fb070..00000000000
--- a/sound/oss/emu10k1/mixer.c
+++ /dev/null
@@ -1,690 +0,0 @@
1/*
2 **********************************************************************
3 * mixer.c - /dev/mixer interface for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 * November 2, 1999 Alan Cox cleaned up stuff
12 *
13 **********************************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the Free
27 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
28 * USA.
29 *
30 **********************************************************************
31 */
32
33#include <linux/module.h>
34#include <asm/uaccess.h>
35#include <linux/fs.h>
36
37#include "hwaccess.h"
38#include "8010.h"
39#include "recmgr.h"
40
41
42static const u32 bass_table[41][5] = {
43 { 0x3e4f844f, 0x84ed4cc3, 0x3cc69927, 0x7b03553a, 0xc4da8486 },
44 { 0x3e69a17a, 0x84c280fb, 0x3cd77cd4, 0x7b2f2a6f, 0xc4b08d1d },
45 { 0x3e82ff42, 0x849991d5, 0x3ce7466b, 0x7b5917c6, 0xc48863ee },
46 { 0x3e9bab3c, 0x847267f0, 0x3cf5ffe8, 0x7b813560, 0xc461f22c },
47 { 0x3eb3b275, 0x844ced29, 0x3d03b295, 0x7ba79a1c, 0xc43d223b },
48 { 0x3ecb2174, 0x84290c8b, 0x3d106714, 0x7bcc5ba3, 0xc419dfa5 },
49 { 0x3ee2044b, 0x8406b244, 0x3d1c2561, 0x7bef8e77, 0xc3f8170f },
50 { 0x3ef86698, 0x83e5cb96, 0x3d26f4d8, 0x7c114600, 0xc3d7b625 },
51 { 0x3f0e5390, 0x83c646c9, 0x3d30dc39, 0x7c319498, 0xc3b8ab97 },
52 { 0x3f23d60b, 0x83a81321, 0x3d39e1af, 0x7c508b9c, 0xc39ae704 },
53 { 0x3f38f884, 0x838b20d2, 0x3d420ad2, 0x7c6e3b75, 0xc37e58f1 },
54 { 0x3f4dc52c, 0x836f60ef, 0x3d495cab, 0x7c8ab3a6, 0xc362f2be },
55 { 0x3f6245e8, 0x8354c565, 0x3d4fdbb8, 0x7ca602d6, 0xc348a69b },
56 { 0x3f76845f, 0x833b40ec, 0x3d558bf0, 0x7cc036df, 0xc32f677c },
57 { 0x3f8a8a03, 0x8322c6fb, 0x3d5a70c4, 0x7cd95cd7, 0xc317290b },
58 { 0x3f9e6014, 0x830b4bc3, 0x3d5e8d25, 0x7cf1811a, 0xc2ffdfa5 },
59 { 0x3fb20fae, 0x82f4c420, 0x3d61e37f, 0x7d08af56, 0xc2e9804a },
60 { 0x3fc5a1cc, 0x82df2592, 0x3d6475c3, 0x7d1ef294, 0xc2d40096 },
61 { 0x3fd91f55, 0x82ca6632, 0x3d664564, 0x7d345541, 0xc2bf56b9 },
62 { 0x3fec9120, 0x82b67cac, 0x3d675356, 0x7d48e138, 0xc2ab796e },
63 { 0x40000000, 0x82a36037, 0x3d67a012, 0x7d5c9fc9, 0xc2985fee },
64 { 0x401374c7, 0x8291088a, 0x3d672b93, 0x7d6f99c3, 0xc28601f2 },
65 { 0x4026f857, 0x827f6dd7, 0x3d65f559, 0x7d81d77c, 0xc27457a3 },
66 { 0x403a939f, 0x826e88c5, 0x3d63fc63, 0x7d9360d4, 0xc2635996 },
67 { 0x404e4faf, 0x825e5266, 0x3d613f32, 0x7da43d42, 0xc25300c6 },
68 { 0x406235ba, 0x824ec434, 0x3d5dbbc3, 0x7db473d7, 0xc243468e },
69 { 0x40764f1f, 0x823fd80c, 0x3d596f8f, 0x7dc40b44, 0xc23424a2 },
70 { 0x408aa576, 0x82318824, 0x3d545787, 0x7dd309e2, 0xc2259509 },
71 { 0x409f4296, 0x8223cf0b, 0x3d4e7012, 0x7de175b5, 0xc2179218 },
72 { 0x40b430a0, 0x8216a7a1, 0x3d47b505, 0x7def5475, 0xc20a1670 },
73 { 0x40c97a0a, 0x820a0d12, 0x3d4021a1, 0x7dfcab8d, 0xc1fd1cf5 },
74 { 0x40df29a6, 0x81fdfad6, 0x3d37b08d, 0x7e098028, 0xc1f0a0ca },
75 { 0x40f54ab1, 0x81f26ca9, 0x3d2e5bd1, 0x7e15d72b, 0xc1e49d52 },
76 { 0x410be8da, 0x81e75e89, 0x3d241cce, 0x7e21b544, 0xc1d90e24 },
77 { 0x41231051, 0x81dcccb3, 0x3d18ec37, 0x7e2d1ee6, 0xc1cdef10 },
78 { 0x413acdd0, 0x81d2b39e, 0x3d0cc20a, 0x7e38184e, 0xc1c33c13 },
79 { 0x41532ea7, 0x81c90ffb, 0x3cff9585, 0x7e42a58b, 0xc1b8f15a },
80 { 0x416c40cd, 0x81bfdeb2, 0x3cf15d21, 0x7e4cca7c, 0xc1af0b3f },
81 { 0x418612ea, 0x81b71cdc, 0x3ce20e85, 0x7e568ad3, 0xc1a58640 },
82 { 0x41a0b465, 0x81aec7c5, 0x3cd19e7c, 0x7e5fea1e, 0xc19c5f03 },
83 { 0x41bc3573, 0x81a6dcea, 0x3cc000e9, 0x7e68ebc2, 0xc1939250 }
84};
85
86static const u32 treble_table[41][5] = {
87 { 0x0125cba9, 0xfed5debd, 0x00599b6c, 0x0d2506da, 0xfa85b354 },
88 { 0x0142f67e, 0xfeb03163, 0x0066cd0f, 0x0d14c69d, 0xfa914473 },
89 { 0x016328bd, 0xfe860158, 0x0075b7f2, 0x0d03eb27, 0xfa9d32d2 },
90 { 0x0186b438, 0xfe56c982, 0x00869234, 0x0cf27048, 0xfaa97fca },
91 { 0x01adf358, 0xfe21f5fe, 0x00999842, 0x0ce051c2, 0xfab62ca5 },
92 { 0x01d949fa, 0xfde6e287, 0x00af0d8d, 0x0ccd8b4a, 0xfac33aa7 },
93 { 0x02092669, 0xfda4d8bf, 0x00c73d4c, 0x0cba1884, 0xfad0ab07 },
94 { 0x023e0268, 0xfd5b0e4a, 0x00e27b54, 0x0ca5f509, 0xfade7ef2 },
95 { 0x0278645c, 0xfd08a2b0, 0x01012509, 0x0c911c63, 0xfaecb788 },
96 { 0x02b8e091, 0xfcac9d1a, 0x0123a262, 0x0c7b8a14, 0xfafb55df },
97 { 0x03001a9a, 0xfc45e9ce, 0x014a6709, 0x0c65398f, 0xfb0a5aff },
98 { 0x034ec6d7, 0xfbd3576b, 0x0175f397, 0x0c4e2643, 0xfb19c7e4 },
99 { 0x03a5ac15, 0xfb5393ee, 0x01a6d6ed, 0x0c364b94, 0xfb299d7c },
100 { 0x0405a562, 0xfac52968, 0x01ddafae, 0x0c1da4e2, 0xfb39dca5 },
101 { 0x046fa3fe, 0xfa267a66, 0x021b2ddd, 0x0c042d8d, 0xfb4a8631 },
102 { 0x04e4b17f, 0xf975be0f, 0x0260149f, 0x0be9e0f2, 0xfb5b9ae0 },
103 { 0x0565f220, 0xf8b0fbe5, 0x02ad3c29, 0x0bceba73, 0xfb6d1b60 },
104 { 0x05f4a745, 0xf7d60722, 0x030393d4, 0x0bb2b578, 0xfb7f084d },
105 { 0x06923236, 0xf6e279bd, 0x03642465, 0x0b95cd75, 0xfb916233 },
106 { 0x07401713, 0xf5d3aef9, 0x03d01283, 0x0b77fded, 0xfba42984 },
107 { 0x08000000, 0xf4a6bd88, 0x0448a161, 0x0b594278, 0xfbb75e9f },
108 { 0x08d3c097, 0xf3587131, 0x04cf35a4, 0x0b3996c9, 0xfbcb01cb },
109 { 0x09bd59a2, 0xf1e543f9, 0x05655880, 0x0b18f6b2, 0xfbdf1333 },
110 { 0x0abefd0f, 0xf04956ca, 0x060cbb12, 0x0af75e2c, 0xfbf392e8 },
111 { 0x0bdb123e, 0xee806984, 0x06c739fe, 0x0ad4c962, 0xfc0880dd },
112 { 0x0d143a94, 0xec85d287, 0x0796e150, 0x0ab134b0, 0xfc1ddce5 },
113 { 0x0e6d5664, 0xea547598, 0x087df0a0, 0x0a8c9cb6, 0xfc33a6ad },
114 { 0x0fe98a2a, 0xe7e6ba35, 0x097edf83, 0x0a66fe5b, 0xfc49ddc2 },
115 { 0x118c4421, 0xe536813a, 0x0a9c6248, 0x0a4056d7, 0xfc608185 },
116 { 0x1359422e, 0xe23d19eb, 0x0bd96efb, 0x0a18a3bf, 0xfc77912c },
117 { 0x1554982b, 0xdef33645, 0x0d3942bd, 0x09efe312, 0xfc8f0bc1 },
118 { 0x1782b68a, 0xdb50deb1, 0x0ebf676d, 0x09c6133f, 0xfca6f019 },
119 { 0x19e8715d, 0xd74d64fd, 0x106fb999, 0x099b3337, 0xfcbf3cd6 },
120 { 0x1c8b07b8, 0xd2df56ab, 0x124e6ec8, 0x096f4274, 0xfcd7f060 },
121 { 0x1f702b6d, 0xcdfc6e92, 0x14601c10, 0x0942410b, 0xfcf108e5 },
122 { 0x229e0933, 0xc89985cd, 0x16a9bcfa, 0x09142fb5, 0xfd0a8451 },
123 { 0x261b5118, 0xc2aa8409, 0x1930bab6, 0x08e50fdc, 0xfd24604d },
124 { 0x29ef3f5d, 0xbc224f28, 0x1bfaf396, 0x08b4e3aa, 0xfd3e9a3b },
125 { 0x2e21a59b, 0xb4f2ba46, 0x1f0ec2d6, 0x0883ae15, 0xfd592f33 },
126 { 0x32baf44b, 0xad0c7429, 0x227308a3, 0x085172eb, 0xfd741bfd },
127 { 0x37c4448b, 0xa45ef51d, 0x262f3267, 0x081e36dc, 0xfd8f5d14 }
128};
129
130
131static void set_bass(struct emu10k1_card *card, int l, int r)
132{
133 int i;
134
135 l = (l * 40 + 50) / 100;
136 r = (r * 40 + 50) / 100;
137
138 for (i = 0; i < 5; i++)
139 sblive_writeptr(card, (card->is_audigy ? A_GPR_BASE : GPR_BASE) + card->mgr.ctrl_gpr[SOUND_MIXER_BASS][0] + i, 0, bass_table[l][i]);
140}
141
142static void set_treble(struct emu10k1_card *card, int l, int r)
143{
144 int i;
145
146 l = (l * 40 + 50) / 100;
147 r = (r * 40 + 50) / 100;
148
149 for (i = 0; i < 5; i++)
150 sblive_writeptr(card, (card->is_audigy ? A_GPR_BASE : GPR_BASE) + card->mgr.ctrl_gpr[SOUND_MIXER_TREBLE][0] + i , 0, treble_table[l][i]);
151}
152
153const char volume_params[SOUND_MIXER_NRDEVICES]= {
154/* Used by the ac97 driver */
155 [SOUND_MIXER_VOLUME] = VOL_6BIT,
156 [SOUND_MIXER_BASS] = VOL_4BIT,
157 [SOUND_MIXER_TREBLE] = VOL_4BIT,
158 [SOUND_MIXER_PCM] = VOL_5BIT,
159 [SOUND_MIXER_SPEAKER] = VOL_4BIT,
160 [SOUND_MIXER_LINE] = VOL_5BIT,
161 [SOUND_MIXER_MIC] = VOL_5BIT,
162 [SOUND_MIXER_CD] = VOL_5BIT,
163 [SOUND_MIXER_ALTPCM] = VOL_6BIT,
164 [SOUND_MIXER_IGAIN] = VOL_4BIT,
165 [SOUND_MIXER_LINE1] = VOL_5BIT,
166 [SOUND_MIXER_PHONEIN] = VOL_5BIT,
167 [SOUND_MIXER_PHONEOUT] = VOL_6BIT,
168 [SOUND_MIXER_VIDEO] = VOL_5BIT,
169/* Not used by the ac97 driver */
170 [SOUND_MIXER_SYNTH] = VOL_5BIT,
171 [SOUND_MIXER_IMIX] = VOL_5BIT,
172 [SOUND_MIXER_RECLEV] = VOL_5BIT,
173 [SOUND_MIXER_OGAIN] = VOL_5BIT,
174 [SOUND_MIXER_LINE2] = VOL_5BIT,
175 [SOUND_MIXER_LINE3] = VOL_5BIT,
176 [SOUND_MIXER_DIGITAL1] = VOL_5BIT,
177 [SOUND_MIXER_DIGITAL2] = VOL_5BIT,
178 [SOUND_MIXER_DIGITAL3] = VOL_5BIT,
179 [SOUND_MIXER_RADIO] = VOL_5BIT,
180 [SOUND_MIXER_MONITOR] = VOL_5BIT
181};
182
183/* Mixer file operations */
184static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, unsigned long arg)
185{
186 struct mixer_private_ioctl *ctl;
187 struct dsp_patch *patch;
188 u32 size, page;
189 int addr, size_reg, i, ret;
190 unsigned int id, ch;
191 void __user *argp = (void __user *)arg;
192
193 switch (cmd) {
194
195 case SOUND_MIXER_PRIVATE3:
196
197 ctl = kmalloc(sizeof(struct mixer_private_ioctl), GFP_KERNEL);
198 if (ctl == NULL)
199 return -ENOMEM;
200
201 if (copy_from_user(ctl, argp, sizeof(struct mixer_private_ioctl))) {
202 kfree(ctl);
203 return -EFAULT;
204 }
205
206 ret = 0;
207 switch (ctl->cmd) {
208#ifdef DBGEMU
209 case CMD_WRITEFN0:
210 emu10k1_writefn0_2(card, ctl->val[0], ctl->val[1], ctl->val[2]);
211 break;
212#endif
213 case CMD_WRITEPTR:
214#ifdef DBGEMU
215 if (ctl->val[1] >= 0x40 || ctl->val[0] >= 0x1000) {
216#else
217 if (ctl->val[1] >= 0x40 || ctl->val[0] >= 0x1000 || ((ctl->val[0] < 0x100 ) &&
218 //Any register allowed raw access goes here:
219 (ctl->val[0] != A_SPDIF_SAMPLERATE) && (ctl->val[0] != A_DBG)
220 )
221 ) {
222#endif
223 ret = -EINVAL;
224 break;
225 }
226 sblive_writeptr(card, ctl->val[0], ctl->val[1], ctl->val[2]);
227 break;
228
229 case CMD_READFN0:
230 ctl->val[2] = emu10k1_readfn0(card, ctl->val[0]);
231
232 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
233 ret = -EFAULT;
234
235 break;
236
237 case CMD_READPTR:
238 if (ctl->val[1] >= 0x40 || (ctl->val[0] & 0x7ff) > 0xff) {
239 ret = -EINVAL;
240 break;
241 }
242
243 if ((ctl->val[0] & 0x7ff) > 0x3f)
244 ctl->val[1] = 0x00;
245
246 ctl->val[2] = sblive_readptr(card, ctl->val[0], ctl->val[1]);
247
248 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
249 ret = -EFAULT;
250
251 break;
252
253 case CMD_SETRECSRC:
254 switch (ctl->val[0]) {
255 case WAVERECORD_AC97:
256 if (card->is_aps) {
257 ret = -EINVAL;
258 break;
259 }
260
261 card->wavein.recsrc = WAVERECORD_AC97;
262 break;
263
264 case WAVERECORD_MIC:
265 card->wavein.recsrc = WAVERECORD_MIC;
266 break;
267
268 case WAVERECORD_FX:
269 card->wavein.recsrc = WAVERECORD_FX;
270 card->wavein.fxwc = ctl->val[1] & 0xffff;
271
272 if (!card->wavein.fxwc)
273 ret = -EINVAL;
274
275 break;
276
277 default:
278 ret = -EINVAL;
279 break;
280 }
281 break;
282
283 case CMD_GETRECSRC:
284 ctl->val[0] = card->wavein.recsrc;
285 ctl->val[1] = card->wavein.fxwc;
286 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
287 ret = -EFAULT;
288
289 break;
290
291 case CMD_GETVOICEPARAM:
292 ctl->val[0] = card->waveout.send_routing[0];
293 ctl->val[1] = card->waveout.send_dcba[0];
294
295 ctl->val[2] = card->waveout.send_routing[1];
296 ctl->val[3] = card->waveout.send_dcba[1];
297
298 ctl->val[4] = card->waveout.send_routing[2];
299 ctl->val[5] = card->waveout.send_dcba[2];
300
301 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
302 ret = -EFAULT;
303
304 break;
305
306 case CMD_SETVOICEPARAM:
307 card->waveout.send_routing[0] = ctl->val[0];
308 card->waveout.send_dcba[0] = ctl->val[1];
309
310 card->waveout.send_routing[1] = ctl->val[2];
311 card->waveout.send_dcba[1] = ctl->val[3];
312
313 card->waveout.send_routing[2] = ctl->val[4];
314 card->waveout.send_dcba[2] = ctl->val[5];
315
316 break;
317
318 case CMD_SETMCH_FX:
319 card->mchannel_fx = ctl->val[0] & 0x000f;
320 break;
321
322 case CMD_GETPATCH:
323 if (ctl->val[0] == 0) {
324 if (copy_to_user(argp, &card->mgr.rpatch, sizeof(struct dsp_rpatch)))
325 ret = -EFAULT;
326 } else {
327 if ((ctl->val[0] - 1) / PATCHES_PER_PAGE >= card->mgr.current_pages) {
328 ret = -EINVAL;
329 break;
330 }
331
332 if (copy_to_user(argp, PATCH(&card->mgr, ctl->val[0] - 1), sizeof(struct dsp_patch)))
333 ret = -EFAULT;
334 }
335
336 break;
337
338 case CMD_GETGPR:
339 id = ctl->val[0];
340
341 if (id > NUM_GPRS) {
342 ret = -EINVAL;
343 break;
344 }
345
346 if (copy_to_user(argp, &card->mgr.gpr[id], sizeof(struct dsp_gpr)))
347 ret = -EFAULT;
348
349 break;
350
351 case CMD_GETCTLGPR:
352 addr = emu10k1_find_control_gpr(&card->mgr, (char *) ctl->val, &((char *) ctl->val)[PATCH_NAME_SIZE]);
353 ctl->val[0] = sblive_readptr(card, addr, 0);
354
355 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
356 ret = -EFAULT;
357
358 break;
359
360 case CMD_SETPATCH:
361 if (ctl->val[0] == 0)
362 memcpy(&card->mgr.rpatch, &ctl->val[1], sizeof(struct dsp_rpatch));
363 else {
364 page = (ctl->val[0] - 1) / PATCHES_PER_PAGE;
365 if (page > MAX_PATCHES_PAGES) {
366 ret = -EINVAL;
367 break;
368 }
369
370 if (page >= card->mgr.current_pages) {
371 for (i = card->mgr.current_pages; i < page + 1; i++) {
372 card->mgr.patch[i] = (void *)__get_free_page(GFP_KERNEL);
373 if(card->mgr.patch[i] == NULL) {
374 card->mgr.current_pages = i;
375 ret = -ENOMEM;
376 break;
377 }
378 memset(card->mgr.patch[i], 0, PAGE_SIZE);
379 }
380 card->mgr.current_pages = page + 1;
381 }
382
383 patch = PATCH(&card->mgr, ctl->val[0] - 1);
384
385 memcpy(patch, &ctl->val[1], sizeof(struct dsp_patch));
386
387 if (patch->code_size == 0) {
388 for(i = page + 1; i < card->mgr.current_pages; i++)
389 free_page((unsigned long) card->mgr.patch[i]);
390
391 card->mgr.current_pages = page + 1;
392 }
393 }
394 break;
395
396 case CMD_SETGPR:
397 if (ctl->val[0] > NUM_GPRS) {
398 ret = -EINVAL;
399 break;
400 }
401
402 memcpy(&card->mgr.gpr[ctl->val[0]], &ctl->val[1], sizeof(struct dsp_gpr));
403 break;
404
405 case CMD_SETCTLGPR:
406 addr = emu10k1_find_control_gpr(&card->mgr, (char *) ctl->val, (char *) ctl->val + PATCH_NAME_SIZE);
407 emu10k1_set_control_gpr(card, addr, *((s32 *)((char *) ctl->val + 2 * PATCH_NAME_SIZE)), 0);
408 break;
409
410 case CMD_SETGPOUT:
411 if ( ((ctl->val[0] > 2) && (!card->is_audigy))
412 || (ctl->val[0] > 15) || ctl->val[1] > 1) {
413 ret= -EINVAL;
414 break;
415 }
416
417 if (card->is_audigy)
418 emu10k1_writefn0(card, (1 << 24) | ((ctl->val[0]) << 16) | A_IOCFG, ctl->val[1]);
419 else
420 emu10k1_writefn0(card, (1 << 24) | (((ctl->val[0]) + 10) << 16) | HCFG, ctl->val[1]);
421 break;
422
423 case CMD_GETGPR2OSS:
424 id = ctl->val[0];
425 ch = ctl->val[1];
426
427 if (id >= SOUND_MIXER_NRDEVICES || ch >= 2) {
428 ret = -EINVAL;
429 break;
430 }
431
432 ctl->val[2] = card->mgr.ctrl_gpr[id][ch];
433
434 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
435 ret = -EFAULT;
436
437 break;
438
439 case CMD_SETGPR2OSS:
440 id = ctl->val[0];
441 /* 0 == left, 1 == right */
442 ch = ctl->val[1];
443 addr = ctl->val[2];
444
445 if (id >= SOUND_MIXER_NRDEVICES || ch >= 2) {
446 ret = -EINVAL;
447 break;
448 }
449
450 card->mgr.ctrl_gpr[id][ch] = addr;
451
452 if (card->is_aps)
453 break;
454
455 if (addr >= 0) {
456 unsigned int state = card->ac97->mixer_state[id];
457
458 if (ch == 1) {
459 state >>= 8;
460 card->ac97->stereo_mixers |= (1 << id);
461 }
462
463 card->ac97->supported_mixers |= (1 << id);
464
465 if (id == SOUND_MIXER_TREBLE) {
466 set_treble(card, card->ac97->mixer_state[id] & 0xff, (card->ac97->mixer_state[id] >> 8) & 0xff);
467 } else if (id == SOUND_MIXER_BASS) {
468 set_bass(card, card->ac97->mixer_state[id] & 0xff, (card->ac97->mixer_state[id] >> 8) & 0xff);
469 } else
470 emu10k1_set_volume_gpr(card, addr, state & 0xff,
471 volume_params[id]);
472 } else {
473 card->ac97->stereo_mixers &= ~(1 << id);
474 card->ac97->stereo_mixers |= card->ac97_stereo_mixers;
475
476 if (ch == 0) {
477 card->ac97->supported_mixers &= ~(1 << id);
478 card->ac97->supported_mixers |= card->ac97_supported_mixers;
479 }
480 }
481 break;
482
483 case CMD_SETPASSTHROUGH:
484 card->pt.selected = ctl->val[0] ? 1 : 0;
485 if (card->pt.state != PT_STATE_INACTIVE)
486 break;
487
488 card->pt.spcs_to_use = ctl->val[0] & 0x07;
489 break;
490
491 case CMD_PRIVATE3_VERSION:
492 ctl->val[0] = PRIVATE3_VERSION; //private3 version
493 ctl->val[1] = MAJOR_VER; //major driver version
494 ctl->val[2] = MINOR_VER; //minor driver version
495 ctl->val[3] = card->is_audigy; //1=card is audigy
496
497 if (card->is_audigy)
498 ctl->val[4]=emu10k1_readfn0(card, 0x18);
499
500 if (copy_to_user(argp, ctl, sizeof(struct mixer_private_ioctl)))
501 ret = -EFAULT;
502 break;
503
504 case CMD_AC97_BOOST:
505 if (ctl->val[0])
506 emu10k1_ac97_write(card->ac97, 0x18, 0x0);
507 else
508 emu10k1_ac97_write(card->ac97, 0x18, 0x0808);
509 break;
510 default:
511 ret = -EINVAL;
512 break;
513 }
514
515 kfree(ctl);
516 return ret;
517 break;
518
519 case SOUND_MIXER_PRIVATE4:
520
521 if (copy_from_user(&size, argp, sizeof(size)))
522 return -EFAULT;
523
524 DPD(2, "External tram size %#x\n", size);
525
526 if (size > 0x1fffff)
527 return -EINVAL;
528
529 size_reg = 0;
530
531 if (size != 0) {
532 size = (size - 1) >> 14;
533
534 while (size) {
535 size >>= 1;
536 size_reg++;
537 }
538
539 size = 0x4000 << size_reg;
540 }
541
542 DPD(2, "External tram size %#x %#x\n", size, size_reg);
543
544 if (size != card->tankmem.size) {
545 if (card->tankmem.size > 0) {
546 emu10k1_writefn0(card, HCFG_LOCKTANKCACHE, 1);
547
548 sblive_writeptr_tag(card, 0, TCB, 0, TCBS, 0, TAGLIST_END);
549
550 pci_free_consistent(card->pci_dev, card->tankmem.size, card->tankmem.addr, card->tankmem.dma_handle);
551
552 card->tankmem.size = 0;
553 }
554
555 if (size != 0) {
556 card->tankmem.addr = pci_alloc_consistent(card->pci_dev, size, &card->tankmem.dma_handle);
557 if (card->tankmem.addr == NULL)
558 return -ENOMEM;
559
560 card->tankmem.size = size;
561
562 sblive_writeptr_tag(card, 0, TCB, (u32) card->tankmem.dma_handle, TCBS,(u32) size_reg, TAGLIST_END);
563
564 emu10k1_writefn0(card, HCFG_LOCKTANKCACHE, 0);
565 }
566 }
567 return 0;
568 break;
569
570 default:
571 break;
572 }
573
574 return -EINVAL;
575}
576
577static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer, unsigned long arg)
578{
579 unsigned int left, right;
580 int val;
581 int scale;
582
583 card->ac97->modcnt++;
584
585 if (get_user(val, (int __user *)arg))
586 return -EFAULT;
587
588 /* cleanse input a little */
589 right = ((val >> 8) & 0xff);
590 left = (val & 0xff);
591
592 if (right > 100) right = 100;
593 if (left > 100) left = 100;
594
595 card->ac97->mixer_state[oss_mixer] = (right << 8) | left;
596 if (oss_mixer == SOUND_MIXER_TREBLE) {
597 set_treble(card, left, right);
598 return 0;
599 } if (oss_mixer == SOUND_MIXER_BASS) {
600 set_bass(card, left, right);
601 return 0;
602 }
603
604 if (oss_mixer == SOUND_MIXER_VOLUME)
605 scale = 1 << card->ac97->bit_resolution;
606 else
607 scale = volume_params[oss_mixer];
608
609 emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][0], left, scale);
610 emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][1], right, scale);
611
612 if (card->ac97_supported_mixers & (1 << oss_mixer))
613 card->ac97->write_mixer(card->ac97, oss_mixer, left, right);
614
615 return 0;
616}
617
618static int emu10k1_mixer_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
619{
620 int ret;
621 struct emu10k1_card *card = file->private_data;
622 unsigned int oss_mixer = _IOC_NR(cmd);
623
624 ret = -EINVAL;
625 if (!card->is_aps) {
626 if (cmd == SOUND_MIXER_INFO) {
627 mixer_info info;
628
629 strlcpy(info.id, card->ac97->name, sizeof(info.id));
630
631 if (card->is_audigy)
632 strlcpy(info.name, "Audigy - Emu10k1", sizeof(info.name));
633 else
634 strlcpy(info.name, "Creative SBLive - Emu10k1", sizeof(info.name));
635
636 info.modify_counter = card->ac97->modcnt;
637
638 if (copy_to_user((void __user *)arg, &info, sizeof(info)))
639 return -EFAULT;
640
641 return 0;
642 }
643
644 if ((_SIOC_DIR(cmd) == (_SIOC_WRITE|_SIOC_READ)) && oss_mixer <= SOUND_MIXER_NRDEVICES)
645 ret = emu10k1_dsp_mixer(card, oss_mixer, arg);
646 else
647 ret = card->ac97->mixer_ioctl(card->ac97, cmd, arg);
648 }
649
650 if (ret < 0)
651 ret = emu10k1_private_mixer(card, cmd, arg);
652
653 return ret;
654}
655
656static int emu10k1_mixer_open(struct inode *inode, struct file *file)
657{
658 int minor = iminor(inode);
659 struct emu10k1_card *card = NULL;
660 struct list_head *entry;
661
662 DPF(4, "emu10k1_mixer_open()\n");
663
664 list_for_each(entry, &emu10k1_devs) {
665 card = list_entry(entry, struct emu10k1_card, list);
666
667 if (card->ac97->dev_mixer == minor)
668 goto match;
669 }
670
671 return -ENODEV;
672
673 match:
674 file->private_data = card;
675 return 0;
676}
677
678static int emu10k1_mixer_release(struct inode *inode, struct file *file)
679{
680 DPF(4, "emu10k1_mixer_release()\n");
681 return 0;
682}
683
684const struct file_operations emu10k1_mixer_fops = {
685 .owner = THIS_MODULE,
686 .llseek = no_llseek,
687 .ioctl = emu10k1_mixer_ioctl,
688 .open = emu10k1_mixer_open,
689 .release = emu10k1_mixer_release,
690};
diff --git a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c
deleted file mode 100644
index 6d21d4368de..00000000000
--- a/sound/oss/emu10k1/passthrough.c
+++ /dev/null
@@ -1,240 +0,0 @@
1/*
2 **********************************************************************
3 * passthrough.c -- Emu10k1 digital passthrough
4 * Copyright (C) 2001 Juha Yrjölä <jyrjola@cc.hut.fi>
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * May 15, 2001 Juha Yrjölä base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/module.h>
33#include <linux/poll.h>
34#include <linux/slab.h>
35#include <linux/bitops.h>
36#include <asm/io.h>
37#include <linux/sched.h>
38#include <linux/smp_lock.h>
39
40#include "hwaccess.h"
41#include "cardwo.h"
42#include "cardwi.h"
43#include "recmgr.h"
44#include "irqmgr.h"
45#include "audio.h"
46#include "8010.h"
47
48static void pt_putsamples(struct pt_data *pt, u16 *ptr, u16 left, u16 right)
49{
50 unsigned int idx;
51
52 ptr[pt->copyptr] = left;
53 idx = pt->copyptr + PT_SAMPLES/2;
54 idx %= PT_SAMPLES;
55 ptr[idx] = right;
56}
57
58static inline int pt_can_write(struct pt_data *pt)
59{
60 return pt->blocks_copied < pt->blocks_played + 8;
61}
62
63static int pt_wait_for_write(struct emu10k1_wavedevice *wavedev, int nonblock)
64{
65 struct emu10k1_card *card = wavedev->card;
66 struct pt_data *pt = &card->pt;
67
68 if (nonblock && !pt_can_write(pt))
69 return -EAGAIN;
70 while (!pt_can_write(pt) && pt->state != PT_STATE_INACTIVE) {
71 interruptible_sleep_on(&pt->wait);
72 if (signal_pending(current))
73 return -ERESTARTSYS;
74 }
75 if (pt->state == PT_STATE_INACTIVE)
76 return -EAGAIN;
77
78 return 0;
79}
80
81static int pt_putblock(struct emu10k1_wavedevice *wave_dev, u16 *block, int nonblock)
82{
83 struct woinst *woinst = wave_dev->woinst;
84 struct emu10k1_card *card = wave_dev->card;
85 struct pt_data *pt = &card->pt;
86 u16 *ptr = (u16 *) card->tankmem.addr;
87 int i = 0, r;
88 unsigned long flags;
89
90 r = pt_wait_for_write(wave_dev, nonblock);
91 if (r < 0)
92 return r;
93 spin_lock_irqsave(&card->pt.lock, flags);
94 while (i < PT_BLOCKSAMPLES) {
95 pt_putsamples(pt, ptr, block[2*i], block[2*i+1]);
96 if (pt->copyptr == 0)
97 pt->copyptr = PT_SAMPLES;
98 pt->copyptr--;
99 i++;
100 }
101 woinst->total_copied += PT_BLOCKSIZE;
102 pt->blocks_copied++;
103 if (pt->blocks_copied >= 4 && pt->state != PT_STATE_PLAYING) {
104 DPF(2, "activating digital pass-through playback\n");
105 sblive_writeptr(card, GPR_BASE + pt->enable_gpr, 0, 1);
106 pt->state = PT_STATE_PLAYING;
107 }
108 spin_unlock_irqrestore(&card->pt.lock, flags);
109 return 0;
110}
111
112int emu10k1_pt_setup(struct emu10k1_wavedevice *wave_dev)
113{
114 u32 bits;
115 struct emu10k1_card *card = wave_dev->card;
116 struct pt_data *pt = &card->pt;
117 int i;
118
119 for (i = 0; i < 3; i++) {
120 pt->old_spcs[i] = sblive_readptr(card, SPCS0 + i, 0);
121 if (pt->spcs_to_use & (1 << i)) {
122 DPD(2, "using S/PDIF port %d\n", i);
123 bits = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
124 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS |
125 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT;
126 if (pt->ac3data)
127 bits |= SPCS_NOTAUDIODATA;
128 sblive_writeptr(card, SPCS0 + i, 0, bits);
129 }
130 }
131 return 0;
132}
133
134ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t count)
135{
136 struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
137 struct emu10k1_card *card = wave_dev->card;
138 struct pt_data *pt = &card->pt;
139 int nonblock, i, r, blocks, blocks_copied, bytes_copied = 0;
140
141 DPD(3, "emu10k1_pt_write(): %d bytes\n", count);
142
143 nonblock = file->f_flags & O_NONBLOCK;
144
145 if (card->tankmem.size < PT_SAMPLES*2)
146 return -EFAULT;
147 if (pt->state == PT_STATE_INACTIVE) {
148 DPF(2, "bufptr init\n");
149 pt->playptr = PT_SAMPLES-1;
150 pt->copyptr = PT_INITPTR;
151 pt->blocks_played = pt->blocks_copied = 0;
152 memset(card->tankmem.addr, 0, card->tankmem.size);
153 pt->state = PT_STATE_ACTIVATED;
154 pt->buf = kmalloc(PT_BLOCKSIZE, GFP_KERNEL);
155 pt->prepend_size = 0;
156 if (pt->buf == NULL)
157 return -ENOMEM;
158 emu10k1_pt_setup(wave_dev);
159 }
160 if (pt->prepend_size) {
161 int needed = PT_BLOCKSIZE - pt->prepend_size;
162
163 DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed);
164 if (count < needed) {
165 if (copy_from_user(pt->buf + pt->prepend_size,
166 buffer, count))
167 return -EFAULT;
168 pt->prepend_size += count;
169 DPD(3, "prepend size now %d\n", pt->prepend_size);
170 return count;
171 }
172 if (copy_from_user(pt->buf + pt->prepend_size, buffer, needed))
173 return -EFAULT;
174 r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock);
175 if (r)
176 return r;
177 bytes_copied += needed;
178 pt->prepend_size = 0;
179 }
180 blocks = (count-bytes_copied)/PT_BLOCKSIZE;
181 blocks_copied = 0;
182 while (blocks > 0) {
183 u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2);
184 if (copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE))
185 return -EFAULT;
186 r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock);
187 if (r) {
188 if (bytes_copied)
189 return bytes_copied;
190 else
191 return r;
192 }
193 bytes_copied += PT_BLOCKSIZE;
194 blocks--;
195 blocks_copied++;
196 }
197 i = count - bytes_copied;
198 if (i) {
199 pt->prepend_size = i;
200 if (copy_from_user(pt->buf, buffer + bytes_copied, i))
201 return -EFAULT;
202 bytes_copied += i;
203 DPD(3, "filling prepend buffer with %d bytes", i);
204 }
205 return bytes_copied;
206}
207
208void emu10k1_pt_stop(struct emu10k1_card *card)
209{
210 struct pt_data *pt = &card->pt;
211 int i;
212
213 if (pt->state != PT_STATE_INACTIVE) {
214 DPF(2, "digital pass-through stopped\n");
215 sblive_writeptr(card, (card->is_audigy ? A_GPR_BASE : GPR_BASE) + pt->enable_gpr, 0, 0);
216 for (i = 0; i < 3; i++) {
217 if (pt->spcs_to_use & (1 << i))
218 sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]);
219 }
220 pt->state = PT_STATE_INACTIVE;
221 kfree(pt->buf);
222 }
223}
224
225void emu10k1_pt_waveout_update(struct emu10k1_wavedevice *wave_dev)
226{
227 struct woinst *woinst = wave_dev->woinst;
228 struct pt_data *pt = &wave_dev->card->pt;
229 u32 pos;
230
231 if (pt->state == PT_STATE_PLAYING && pt->pos_gpr >= 0) {
232 pos = sblive_readptr(wave_dev->card, GPR_BASE + pt->pos_gpr, 0);
233 if (pos > PT_BLOCKSAMPLES)
234 pos = PT_BLOCKSAMPLES;
235 pos = 4 * (PT_BLOCKSAMPLES - pos);
236 } else
237 pos = 0;
238 woinst->total_played = pt->blocks_played * woinst->buffer.fragment_size + pos;
239 woinst->buffer.hw_pos = pos;
240}
diff --git a/sound/oss/emu10k1/passthrough.h b/sound/oss/emu10k1/passthrough.h
deleted file mode 100644
index 420cc978425..00000000000
--- a/sound/oss/emu10k1/passthrough.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 **********************************************************************
3 * passthrough.h -- Emu10k1 digital passthrough header file
4 * Copyright (C) 2001 Juha Yrjölä <jyrjola@cc.hut.fi>
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * May 15, 2001 Juha Yrjölä base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _PASSTHROUGH_H
33#define _PASSTHROUGH_H
34
35#include "audio.h"
36
37/* number of 16-bit stereo samples in XTRAM buffer */
38#define PT_SAMPLES 0x8000
39#define PT_BLOCKSAMPLES 0x400
40#define PT_BLOCKSIZE (PT_BLOCKSAMPLES*4)
41#define PT_BLOCKSIZE_LOG2 12
42#define PT_BLOCKCOUNT (PT_SAMPLES/PT_BLOCKSAMPLES)
43#define PT_INITPTR (PT_SAMPLES/2-1)
44
45#define PT_STATE_INACTIVE 0
46#define PT_STATE_ACTIVATED 1
47#define PT_STATE_PLAYING 2
48
49/* passthrough struct */
50struct pt_data
51{
52 u8 selected, state, spcs_to_use;
53 int intr_gpr, enable_gpr, pos_gpr;
54 u32 blocks_played, blocks_copied, old_spcs[3];
55 u32 playptr, copyptr;
56 u32 prepend_size;
57 u8 *buf;
58 u8 ac3data;
59
60 char *patch_name, *intr_gpr_name, *enable_gpr_name, *pos_gpr_name;
61
62 wait_queue_head_t wait;
63 spinlock_t lock;
64};
65
66/*
67 Passthrough can be done in two methods:
68
69 Method 1 : tram
70 In original emu10k1, we couldn't bypass the sample rate converters. Even at 48kHz
71 (the internal sample rate of the emu10k1) the samples would get messed up.
72 To over come this, samples are copied into the tram and a special dsp patch copies
73 the samples out and generates interrupts when a block has finnished playing.
74
75 Method 2 : Interpolator bypass
76
77 Creative fixed the sample rate convert problem in emu10k1 rev 7 and higher
78 (including the emu10k2 (audigy)). This allows us to use the regular, and much simpler
79 playback method.
80
81
82 In both methods, dsp code is used to mux audio and passthrough. This ensures that the spdif
83 doesn't receive audio and pasthrough data at the same time. The spdif flag SPCS_NOTAUDIODATA
84 is set to tell
85
86 */
87
88// emu10k1 revs greater than or equal to 7 can use method2
89
90#define USE_PT_METHOD2 (card->is_audigy)
91#define USE_PT_METHOD1 !USE_PT_METHOD2
92
93ssize_t emu10k1_pt_write(struct file *file, const char __user *buf, size_t count);
94
95int emu10k1_pt_setup(struct emu10k1_wavedevice *wave_dev);
96void emu10k1_pt_stop(struct emu10k1_card *card);
97void emu10k1_pt_waveout_update(struct emu10k1_wavedevice *wave_dev);
98
99#endif /* _PASSTHROUGH_H */
diff --git a/sound/oss/emu10k1/recmgr.c b/sound/oss/emu10k1/recmgr.c
deleted file mode 100644
index 2ce56180e7d..00000000000
--- a/sound/oss/emu10k1/recmgr.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 **********************************************************************
3 * recmgr.c -- Recording manager for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include <linux/delay.h>
33#include "8010.h"
34#include "recmgr.h"
35
36void emu10k1_reset_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
37{
38 DPF(2, "emu10k1_reset_record()\n");
39
40 sblive_writeptr(card, buffer->sizereg, 0, ADCBS_BUFSIZE_NONE);
41
42 sblive_writeptr(card, buffer->sizereg, 0, buffer->sizeregval);
43
44 while (sblive_readptr(card, buffer->idxreg, 0))
45 udelay(5);
46}
47
48void emu10k1_start_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
49{
50 DPF(2, "emu10k1_start_record()\n");
51
52 if (buffer->adcctl)
53 sblive_writeptr(card, ADCCR, 0, buffer->adcctl);
54}
55
56void emu10k1_stop_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
57{
58 DPF(2, "emu10k1_stop_record()\n");
59
60 /* Disable record transfer */
61 if (buffer->adcctl)
62 sblive_writeptr(card, ADCCR, 0, 0);
63}
64
65void emu10k1_set_record_src(struct emu10k1_card *card, struct wiinst *wiinst)
66{
67 struct wavein_buffer *buffer = &wiinst->buffer;
68
69 DPF(2, "emu10k1_set_record_src()\n");
70
71 switch (wiinst->recsrc) {
72
73 case WAVERECORD_AC97:
74 DPF(2, "recording source: AC97\n");
75 buffer->sizereg = ADCBS;
76 buffer->addrreg = ADCBA;
77 buffer->idxreg = card->is_audigy ? A_ADCIDX_IDX : ADCIDX_IDX;
78
79 switch (wiinst->format.samplingrate) {
80 case 0xBB80:
81 buffer->adcctl = ADCCR_SAMPLERATE_48;
82 break;
83 case 0xAC44:
84 buffer->adcctl = ADCCR_SAMPLERATE_44;
85 break;
86 case 0x7D00:
87 buffer->adcctl = ADCCR_SAMPLERATE_32;
88 break;
89 case 0x5DC0:
90 buffer->adcctl = ADCCR_SAMPLERATE_24;
91 break;
92 case 0x5622:
93 buffer->adcctl = ADCCR_SAMPLERATE_22;
94 break;
95 case 0x3E80:
96 buffer->adcctl = ADCCR_SAMPLERATE_16;
97 break;
98 // FIXME: audigy supports 12kHz recording
99 /*
100 case ????:
101 buffer->adcctl = A_ADCCR_SAMPLERATE_12;
102 break;
103 */
104 case 0x2B11:
105 buffer->adcctl = card->is_audigy ? A_ADCCR_SAMPLERATE_11 : ADCCR_SAMPLERATE_11;
106 break;
107 case 0x1F40:
108 buffer->adcctl = card->is_audigy ? A_ADCCR_SAMPLERATE_8 : ADCCR_SAMPLERATE_8;
109 break;
110 default:
111 BUG();
112 break;
113 }
114
115 buffer->adcctl |= card->is_audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE;
116
117 if (wiinst->format.channels == 2)
118 buffer->adcctl |= card->is_audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE;
119
120 break;
121
122 case WAVERECORD_MIC:
123 DPF(2, "recording source: MIC\n");
124 buffer->sizereg = MICBS;
125 buffer->addrreg = MICBA;
126 buffer->idxreg = MICIDX_IDX;
127 buffer->adcctl = 0;
128 break;
129
130 case WAVERECORD_FX:
131 DPF(2, "recording source: FX\n");
132 buffer->sizereg = FXBS;
133 buffer->addrreg = FXBA;
134 buffer->idxreg = FXIDX_IDX;
135 buffer->adcctl = 0;
136
137 sblive_writeptr(card, FXWC, 0, wiinst->fxwc);
138 break;
139 default:
140 BUG();
141 break;
142 }
143
144 DPD(2, "bus addx: %#lx\n", (unsigned long) buffer->dma_handle);
145
146 sblive_writeptr(card, buffer->addrreg, 0, (u32)buffer->dma_handle);
147}
diff --git a/sound/oss/emu10k1/recmgr.h b/sound/oss/emu10k1/recmgr.h
deleted file mode 100644
index a68766ac4fd..00000000000
--- a/sound/oss/emu10k1/recmgr.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 **********************************************************************
3 * recmgr.h
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _RECORDMGR_H
33#define _RECORDMGR_H
34
35#include "hwaccess.h"
36#include "cardwi.h"
37
38/* Recording resources */
39#define WAVERECORD_AC97 0x01
40#define WAVERECORD_MIC 0x02
41#define WAVERECORD_FX 0x03
42
43void emu10k1_reset_record(struct emu10k1_card *card, struct wavein_buffer *buffer);
44void emu10k1_start_record(struct emu10k1_card *, struct wavein_buffer *);
45void emu10k1_stop_record(struct emu10k1_card *, struct wavein_buffer *);
46void emu10k1_set_record_src(struct emu10k1_card *, struct wiinst *wiinst);
47
48#endif /* _RECORDMGR_H */
diff --git a/sound/oss/emu10k1/timer.c b/sound/oss/emu10k1/timer.c
deleted file mode 100644
index d10d30739f4..00000000000
--- a/sound/oss/emu10k1/timer.c
+++ /dev/null
@@ -1,176 +0,0 @@
1
2/*
3 **********************************************************************
4 * timer.c
5 * Copyright (C) 1999, 2000 Creative Labs, inc.
6 *
7 **********************************************************************
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
22 * USA.
23 *
24 **********************************************************************
25 */
26
27/* 3/6/2000 Improved support for different timer delays Rui Sousa */
28
29/* 4/3/2000 Implemented timer list using list.h Rui Sousa */
30
31#include "hwaccess.h"
32#include "8010.h"
33#include "irqmgr.h"
34#include "timer.h"
35
36/* Try to schedule only once per fragment */
37
38void emu10k1_timer_irqhandler(struct emu10k1_card *card)
39{
40 struct emu_timer *t;
41 struct list_head *entry;
42
43 spin_lock(&card->timer_lock);
44
45 list_for_each(entry, &card->timers) {
46 t = list_entry(entry, struct emu_timer, list);
47
48 if (t->state & TIMER_STATE_ACTIVE) {
49 t->count++;
50 if (t->count == t->count_max) {
51 t->count = 0;
52 tasklet_hi_schedule(&t->tasklet);
53 }
54 }
55 }
56
57 spin_unlock(&card->timer_lock);
58
59 return;
60}
61
62void emu10k1_timer_install(struct emu10k1_card *card, struct emu_timer *timer, u16 delay)
63{
64 struct emu_timer *t;
65 struct list_head *entry;
66 unsigned long flags;
67
68 if (delay < 5)
69 delay = 5;
70
71 timer->delay = delay;
72 timer->state = TIMER_STATE_INSTALLED;
73
74 spin_lock_irqsave(&card->timer_lock, flags);
75
76 timer->count_max = timer->delay / (card->timer_delay < 1024 ? card->timer_delay : 1024);
77 timer->count = timer->count_max - 1;
78
79 list_add(&timer->list, &card->timers);
80
81 if (card->timer_delay > delay) {
82 if (card->timer_delay == TIMER_STOPPED)
83 emu10k1_irq_enable(card, INTE_INTERVALTIMERENB);
84
85 card->timer_delay = delay;
86 delay = (delay < 1024 ? delay : 1024);
87
88 emu10k1_timer_set(card, delay);
89
90 list_for_each(entry, &card->timers) {
91 t = list_entry(entry, struct emu_timer, list);
92
93 t->count_max = t->delay / delay;
94 /* don't want to think much, just force scheduling
95 on the next interrupt */
96 t->count = t->count_max - 1;
97 }
98
99 DPD(2, "timer rate --> %u\n", delay);
100 }
101
102 spin_unlock_irqrestore(&card->timer_lock, flags);
103
104 return;
105}
106
107void emu10k1_timer_uninstall(struct emu10k1_card *card, struct emu_timer *timer)
108{
109 struct emu_timer *t;
110 struct list_head *entry;
111 u16 delay = TIMER_STOPPED;
112 unsigned long flags;
113
114 if (timer->state == TIMER_STATE_UNINSTALLED)
115 return;
116
117 spin_lock_irqsave(&card->timer_lock, flags);
118
119 list_del(&timer->list);
120
121 list_for_each(entry, &card->timers) {
122 t = list_entry(entry, struct emu_timer, list);
123
124 if (t->delay < delay)
125 delay = t->delay;
126 }
127
128 if (card->timer_delay != delay) {
129 card->timer_delay = delay;
130
131 if (delay == TIMER_STOPPED)
132 emu10k1_irq_disable(card, INTE_INTERVALTIMERENB);
133 else {
134 delay = (delay < 1024 ? delay : 1024);
135
136 emu10k1_timer_set(card, delay);
137
138 list_for_each(entry, &card->timers) {
139 t = list_entry(entry, struct emu_timer, list);
140
141 t->count_max = t->delay / delay;
142 t->count = t->count_max - 1;
143 }
144 }
145
146 DPD(2, "timer rate --> %u\n", delay);
147 }
148
149 spin_unlock_irqrestore(&card->timer_lock, flags);
150
151 timer->state = TIMER_STATE_UNINSTALLED;
152
153 return;
154}
155
156void emu10k1_timer_enable(struct emu10k1_card *card, struct emu_timer *timer)
157{
158 unsigned long flags;
159
160 spin_lock_irqsave(&card->timer_lock, flags);
161 timer->state |= TIMER_STATE_ACTIVE;
162 spin_unlock_irqrestore(&card->timer_lock, flags);
163
164 return;
165}
166
167void emu10k1_timer_disable(struct emu10k1_card *card, struct emu_timer *timer)
168{
169 unsigned long flags;
170
171 spin_lock_irqsave(&card->timer_lock, flags);
172 timer->state &= ~TIMER_STATE_ACTIVE;
173 spin_unlock_irqrestore(&card->timer_lock, flags);
174
175 return;
176}
diff --git a/sound/oss/emu10k1/timer.h b/sound/oss/emu10k1/timer.h
deleted file mode 100644
index b2543b4d53a..00000000000
--- a/sound/oss/emu10k1/timer.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 **********************************************************************
3 * timer.h
4 * Copyright (C) 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
21 * USA.
22 *
23 **********************************************************************
24 */
25
26
27#ifndef _TIMER_H
28#define _TIMER_H
29
30#include <linux/sched.h>
31#include <linux/interrupt.h>
32#include "hwaccess.h"
33
34struct emu_timer
35{
36 struct list_head list;
37 struct tasklet_struct tasklet;
38 u8 state;
39 u16 count; /* current number of interrupts */
40 u16 count_max; /* number of interrupts needed to schedule the bh */
41 u16 delay; /* timer delay */
42};
43
44void emu10k1_timer_install(struct emu10k1_card *, struct emu_timer *, u16);
45void emu10k1_timer_uninstall(struct emu10k1_card *, struct emu_timer *);
46void emu10k1_timer_enable(struct emu10k1_card *, struct emu_timer *);
47void emu10k1_timer_disable(struct emu10k1_card *, struct emu_timer *);
48
49#define TIMER_STOPPED 0xffff
50#define TIMER_STATE_INSTALLED 0x01
51#define TIMER_STATE_ACTIVE 0x02
52#define TIMER_STATE_UNINSTALLED 0x04
53
54#endif /* _TIMER_H */
diff --git a/sound/oss/emu10k1/voicemgr.c b/sound/oss/emu10k1/voicemgr.c
deleted file mode 100644
index d88b602c07c..00000000000
--- a/sound/oss/emu10k1/voicemgr.c
+++ /dev/null
@@ -1,398 +0,0 @@
1/*
2 **********************************************************************
3 * voicemgr.c - Voice manager for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#include "voicemgr.h"
33#include "8010.h"
34
35#define PITCH_48000 0x00004000
36#define PITCH_96000 0x00008000
37#define PITCH_85000 0x00007155
38#define PITCH_80726 0x00006ba2
39#define PITCH_67882 0x00005a82
40#define PITCH_57081 0x00004c1c
41
42static u32 emu10k1_select_interprom(struct emu10k1_card *card,
43 struct emu_voice *voice)
44{
45 if(voice->pitch_target==PITCH_48000)
46 return CCCA_INTERPROM_0;
47 else if(voice->pitch_target<PITCH_48000)
48 return CCCA_INTERPROM_1;
49 else if(voice->pitch_target>=PITCH_96000)
50 return CCCA_INTERPROM_0;
51 else if(voice->pitch_target>=PITCH_85000)
52 return CCCA_INTERPROM_6;
53 else if(voice->pitch_target>=PITCH_80726)
54 return CCCA_INTERPROM_5;
55 else if(voice->pitch_target>=PITCH_67882)
56 return CCCA_INTERPROM_4;
57 else if(voice->pitch_target>=PITCH_57081)
58 return CCCA_INTERPROM_3;
59 else
60 return CCCA_INTERPROM_2;
61}
62
63
64/**
65 * emu10k1_voice_alloc_buffer -
66 *
67 * allocates the memory buffer for a voice. Two page tables are kept for each buffer.
68 * One (dma_handle) keeps track of the host memory pages used and the other (virtualpagetable)
69 * is passed to the device so that it can do DMA to host memory.
70 *
71 */
72int emu10k1_voice_alloc_buffer(struct emu10k1_card *card, struct voice_mem *mem, u32 pages)
73{
74 u32 pageindex, pagecount;
75 u32 busaddx;
76 int i;
77
78 DPD(2, "requested pages is: %d\n", pages);
79
80 if ((mem->emupageindex = emu10k1_addxmgr_alloc(pages * PAGE_SIZE, card)) < 0)
81 {
82 DPF(1, "couldn't allocate emu10k1 address space\n");
83 return -1;
84 }
85
86 /* Fill in virtual memory table */
87 for (pagecount = 0; pagecount < pages; pagecount++) {
88 if ((mem->addr[pagecount] = pci_alloc_consistent(card->pci_dev, PAGE_SIZE, &mem->dma_handle[pagecount]))
89 == NULL) {
90 mem->pages = pagecount;
91 DPF(1, "couldn't allocate dma memory\n");
92 return -1;
93 }
94
95 DPD(2, "Virtual Addx: %p\n", mem->addr[pagecount]);
96
97 for (i = 0; i < PAGE_SIZE / EMUPAGESIZE; i++) {
98 busaddx = (u32) mem->dma_handle[pagecount] + i * EMUPAGESIZE;
99
100 DPD(3, "Bus Addx: %#x\n", busaddx);
101
102 pageindex = mem->emupageindex + pagecount * PAGE_SIZE / EMUPAGESIZE + i;
103
104 ((u32 *) card->virtualpagetable.addr)[pageindex] = cpu_to_le32((busaddx * 2) | pageindex);
105 }
106 }
107
108 mem->pages = pagecount;
109
110 return 0;
111}
112
113/**
114 * emu10k1_voice_free_buffer -
115 *
116 * frees the memory buffer for a voice.
117 */
118void emu10k1_voice_free_buffer(struct emu10k1_card *card, struct voice_mem *mem)
119{
120 u32 pagecount, pageindex;
121 int i;
122
123 if (mem->emupageindex < 0)
124 return;
125
126 for (pagecount = 0; pagecount < mem->pages; pagecount++) {
127 pci_free_consistent(card->pci_dev, PAGE_SIZE,
128 mem->addr[pagecount],
129 mem->dma_handle[pagecount]);
130
131 for (i = 0; i < PAGE_SIZE / EMUPAGESIZE; i++) {
132 pageindex = mem->emupageindex + pagecount * PAGE_SIZE / EMUPAGESIZE + i;
133 ((u32 *) card->virtualpagetable.addr)[pageindex] =
134 cpu_to_le32(((u32) card->silentpage.dma_handle * 2) | pageindex);
135 }
136 }
137
138 emu10k1_addxmgr_free(card, mem->emupageindex);
139 mem->emupageindex = -1;
140}
141
142int emu10k1_voice_alloc(struct emu10k1_card *card, struct emu_voice *voice)
143{
144 u8 *voicetable = card->voicetable;
145 int i;
146 unsigned long flags;
147
148 DPF(2, "emu10k1_voice_alloc()\n");
149
150 spin_lock_irqsave(&card->lock, flags);
151
152 if (voice->flags & VOICE_FLAGS_STEREO) {
153 for (i = 0; i < NUM_G; i += 2)
154 if ((voicetable[i] == VOICE_USAGE_FREE) && (voicetable[i + 1] == VOICE_USAGE_FREE)) {
155 voicetable[i] = voice->usage;
156 voicetable[i + 1] = voice->usage;
157 break;
158 }
159 } else {
160 for (i = 0; i < NUM_G; i++)
161 if (voicetable[i] == VOICE_USAGE_FREE) {
162 voicetable[i] = voice->usage;
163 break;
164 }
165 }
166
167 spin_unlock_irqrestore(&card->lock, flags);
168
169 if (i >= NUM_G)
170 return -1;
171
172 voice->card = card;
173 voice->num = i;
174
175 for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
176 DPD(2, " voice allocated -> %d\n", voice->num + i);
177
178 sblive_writeptr_tag(card, voice->num + i, IFATN, 0xffff,
179 DCYSUSV, 0,
180 VTFT, 0x0000ffff,
181 PTRX, 0,
182 TAGLIST_END);
183 }
184
185 return 0;
186}
187
188void emu10k1_voice_free(struct emu_voice *voice)
189{
190 struct emu10k1_card *card = voice->card;
191 int i;
192 unsigned long flags;
193
194 DPF(2, "emu10k1_voice_free()\n");
195
196 if (voice->usage == VOICE_USAGE_FREE)
197 return;
198
199 for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
200 DPD(2, " voice released -> %d\n", voice->num + i);
201
202 sblive_writeptr_tag(card, voice->num + i, DCYSUSV, 0,
203 VTFT, 0x0000ffff,
204 PTRX_PITCHTARGET, 0,
205 CVCF, 0x0000ffff,
206 //CPF, 0,
207 TAGLIST_END);
208
209 sblive_writeptr(card, CPF, voice->num + i, 0);
210 }
211
212 voice->usage = VOICE_USAGE_FREE;
213
214 spin_lock_irqsave(&card->lock, flags);
215
216 card->voicetable[voice->num] = VOICE_USAGE_FREE;
217
218 if (voice->flags & VOICE_FLAGS_STEREO)
219 card->voicetable[voice->num + 1] = VOICE_USAGE_FREE;
220
221 spin_unlock_irqrestore(&card->lock, flags);
222}
223
224void emu10k1_voice_playback_setup(struct emu_voice *voice)
225{
226 struct emu10k1_card *card = voice->card;
227 u32 start;
228 int i;
229
230 DPF(2, "emu10k1_voice_playback_setup()\n");
231
232 if (voice->flags & VOICE_FLAGS_STEREO) {
233 /* Set stereo bit */
234 start = 28;
235 sblive_writeptr(card, CPF, voice->num, CPF_STEREO_MASK);
236 sblive_writeptr(card, CPF, voice->num + 1, CPF_STEREO_MASK);
237 } else {
238 start = 30;
239 sblive_writeptr(card, CPF, voice->num, 0);
240 }
241
242 if(!(voice->flags & VOICE_FLAGS_16BIT))
243 start *= 2;
244
245 voice->start += start;
246
247 for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
248 if (card->is_audigy) {
249 sblive_writeptr(card, A_FXRT1, voice->num + i, voice->params[i].send_routing);
250 sblive_writeptr(card, A_FXRT2, voice->num + i, voice->params[i].send_routing2);
251 sblive_writeptr(card, A_SENDAMOUNTS, voice->num + i, voice->params[i].send_hgfe);
252 } else {
253 sblive_writeptr(card, FXRT, voice->num + i, voice->params[i].send_routing << 16);
254 }
255
256 /* Stop CA */
257 /* Assumption that PT is already 0 so no harm overwriting */
258 sblive_writeptr(card, PTRX, voice->num + i, ((voice->params[i].send_dcba & 0xff) << 8)
259 | ((voice->params[i].send_dcba & 0xff00) >> 8));
260
261 sblive_writeptr_tag(card, voice->num + i,
262 /* CSL, ST, CA */
263 DSL, voice->endloop | (voice->params[i].send_dcba & 0xff000000),
264 PSST, voice->startloop | ((voice->params[i].send_dcba & 0x00ff0000) << 8),
265 CCCA, (voice->start) | emu10k1_select_interprom(card,voice) |
266 ((voice->flags & VOICE_FLAGS_16BIT) ? 0 : CCCA_8BITSELECT),
267 /* Clear filter delay memory */
268 Z1, 0,
269 Z2, 0,
270 /* Invalidate maps */
271 MAPA, MAP_PTI_MASK | ((u32) card->silentpage.dma_handle * 2),
272 MAPB, MAP_PTI_MASK | ((u32) card->silentpage.dma_handle * 2),
273 /* modulation envelope */
274 CVCF, 0x0000ffff,
275 VTFT, 0x0000ffff,
276 ATKHLDM, 0,
277 DCYSUSM, 0x007f,
278 LFOVAL1, 0x8000,
279 LFOVAL2, 0x8000,
280 FMMOD, 0,
281 TREMFRQ, 0,
282 FM2FRQ2, 0,
283 ENVVAL, 0x8000,
284 /* volume envelope */
285 ATKHLDV, 0x7f7f,
286 ENVVOL, 0x8000,
287 /* filter envelope */
288 PEFE_FILTERAMOUNT, 0x7f,
289 /* pitch envelope */
290 PEFE_PITCHAMOUNT, 0, TAGLIST_END);
291
292 voice->params[i].fc_target = 0xffff;
293 }
294}
295
296void emu10k1_voices_start(struct emu_voice *first_voice, unsigned int num_voices, int set)
297{
298 struct emu10k1_card *card = first_voice->card;
299 struct emu_voice *voice;
300 unsigned int voicenum;
301 int j;
302
303 DPF(2, "emu10k1_voices_start()\n");
304
305 for (voicenum = 0; voicenum < num_voices; voicenum++)
306 {
307 voice = first_voice + voicenum;
308
309 if (!set) {
310 u32 cra, ccis, cs, sample;
311 if (voice->flags & VOICE_FLAGS_STEREO) {
312 cra = 64;
313 ccis = 28;
314 cs = 4;
315 } else {
316 cra = 64;
317 ccis = 30;
318 cs = 2;
319 }
320
321 if(voice->flags & VOICE_FLAGS_16BIT) {
322 sample = 0x00000000;
323 } else {
324 sample = 0x80808080;
325 ccis *= 2;
326 }
327
328 for(j = 0; j < cs; j++)
329 sblive_writeptr(card, CD0 + j, voice->num, sample);
330
331 /* Reset cache */
332 sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num, 0);
333 if (voice->flags & VOICE_FLAGS_STEREO)
334 sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num + 1, 0);
335
336 sblive_writeptr(card, CCR_READADDRESS, voice->num, cra);
337
338 if (voice->flags & VOICE_FLAGS_STEREO)
339 sblive_writeptr(card, CCR_READADDRESS, voice->num + 1, cra);
340
341 /* Fill cache */
342 sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num, ccis);
343 }
344
345 for (j = 0; j < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); j++) {
346 sblive_writeptr_tag(card, voice->num + j,
347 IFATN, (voice->params[j].initial_fc << 8) | voice->params[j].initial_attn,
348 VTFT, (voice->params[j].volume_target << 16) | voice->params[j].fc_target,
349 CVCF, (voice->params[j].volume_target << 16) | voice->params[j].fc_target,
350 DCYSUSV, (voice->params[j].byampl_env_sustain << 8) | voice->params[j].byampl_env_decay,
351 TAGLIST_END);
352
353 emu10k1_clear_stop_on_loop(card, voice->num + j);
354 }
355 }
356
357
358 for (voicenum = 0; voicenum < num_voices; voicenum++)
359 {
360 voice = first_voice + voicenum;
361
362 for (j = 0; j < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); j++) {
363 sblive_writeptr(card, PTRX_PITCHTARGET, voice->num + j, voice->pitch_target);
364
365 if (j == 0)
366 sblive_writeptr(card, CPF_CURRENTPITCH, voice->num, voice->pitch_target);
367
368 sblive_writeptr(card, IP, voice->num + j, voice->initial_pitch);
369 }
370 }
371}
372
373void emu10k1_voices_stop(struct emu_voice *first_voice, int num_voices)
374{
375 struct emu10k1_card *card = first_voice->card;
376 struct emu_voice *voice;
377 unsigned int voice_num;
378 int j;
379
380 DPF(2, "emu10k1_voice_stop()\n");
381
382 for (voice_num = 0; voice_num < num_voices; voice_num++)
383 {
384 voice = first_voice + voice_num;
385
386 for (j = 0; j < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); j++) {
387 sblive_writeptr_tag(card, voice->num + j,
388 PTRX_PITCHTARGET, 0,
389 CPF_CURRENTPITCH, 0,
390 IFATN, 0xffff,
391 VTFT, 0x0000ffff,
392 CVCF, 0x0000ffff,
393 IP, 0,
394 TAGLIST_END);
395 }
396 }
397}
398
diff --git a/sound/oss/emu10k1/voicemgr.h b/sound/oss/emu10k1/voicemgr.h
deleted file mode 100644
index 099a8cb7f2c..00000000000
--- a/sound/oss/emu10k1/voicemgr.h
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 **********************************************************************
3 * sblive_voice.h -- EMU Voice Resource Manager header file
4 * Copyright 1999, 2000 Creative Labs, Inc.
5 *
6 **********************************************************************
7 *
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
11 *
12 **********************************************************************
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
27 * USA.
28 *
29 **********************************************************************
30 */
31
32#ifndef _VOICEMGR_H
33#define _VOICEMGR_H
34
35#include "hwaccess.h"
36
37/* struct emu_voice.usage flags */
38#define VOICE_USAGE_FREE 0x01
39#define VOICE_USAGE_MIDI 0x02
40#define VOICE_USAGE_PLAYBACK 0x04
41
42/* struct emu_voice.flags flags */
43#define VOICE_FLAGS_STEREO 0x02
44#define VOICE_FLAGS_16BIT 0x04
45
46struct voice_param
47{
48 /* FX bus amount send */
49
50 u32 send_routing;
51 // audigy only:
52 u32 send_routing2;
53
54 u32 send_dcba;
55 // audigy only:
56 u32 send_hgfe;
57
58
59 u32 initial_fc;
60 u32 fc_target;
61
62 u32 initial_attn;
63 u32 volume_target;
64
65 u32 byampl_env_sustain;
66 u32 byampl_env_decay;
67};
68
69struct voice_mem {
70 int emupageindex;
71 void *addr[BUFMAXPAGES];
72 dma_addr_t dma_handle[BUFMAXPAGES];
73 u32 pages;
74};
75
76struct emu_voice
77{
78 struct emu10k1_card *card;
79 u8 usage; /* Free, MIDI, playback */
80 u8 num; /* Voice ID */
81 u8 flags; /* Stereo/mono, 8/16 bit */
82
83 u32 startloop;
84 u32 endloop;
85 u32 start;
86
87 u32 initial_pitch;
88 u32 pitch_target;
89
90 struct voice_param params[2];
91
92 struct voice_mem mem;
93};
94
95int emu10k1_voice_alloc_buffer(struct emu10k1_card *, struct voice_mem *, u32);
96void emu10k1_voice_free_buffer(struct emu10k1_card *, struct voice_mem *);
97int emu10k1_voice_alloc(struct emu10k1_card *, struct emu_voice *);
98void emu10k1_voice_free(struct emu_voice *);
99void emu10k1_voice_playback_setup(struct emu_voice *);
100void emu10k1_voices_start(struct emu_voice *, unsigned int, int);
101void emu10k1_voices_stop(struct emu_voice *, int);
102
103#endif /* _VOICEMGR_H */
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 974dd732b14..52648573f60 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -100,7 +100,7 @@
100 * Tjeerd Mulder <tjeerd.mulder@fujitsu-siemens.com> 100 * Tjeerd Mulder <tjeerd.mulder@fujitsu-siemens.com>
101 * 05.01.2001 0.29 Hopefully updates will not be required anymore when Creative bumps 101 * 05.01.2001 0.29 Hopefully updates will not be required anymore when Creative bumps
102 * the CT5880 revision. 102 * the CT5880 revision.
103 * suggested by Stephan Müller <smueller@chronox.de> 103 * suggested by Stephan Müller <smueller@chronox.de>
104 * 31.01.2001 0.30 Register/Unregister gameport 104 * 31.01.2001 0.30 Register/Unregister gameport
105 * Fix SETTRIGGER non OSS API conformity 105 * Fix SETTRIGGER non OSS API conformity
106 * 14.07.2001 0.31 Add list of laptops needing amplifier control 106 * 14.07.2001 0.31 Add list of laptops needing amplifier control
@@ -2894,7 +2894,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2894 s->irq = pcidev->irq; 2894 s->irq = pcidev->irq;
2895 s->vendor = pcidev->vendor; 2895 s->vendor = pcidev->vendor;
2896 s->device = pcidev->device; 2896 s->device = pcidev->device;
2897 pci_read_config_byte(pcidev, PCI_REVISION_ID, &s->rev); 2897 s->rev = pcidev->revision;
2898 s->codec->private_data = s; 2898 s->codec->private_data = s;
2899 s->codec->id = 0; 2899 s->codec->id = 0;
2900 s->codec->codec_read = rdcodec; 2900 s->codec->codec_read = rdcodec;
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
index 2796c0ef985..a690ca57adb 100644
--- a/sound/oss/mpu401.c
+++ b/sound/oss/mpu401.c
@@ -1003,7 +1003,8 @@ int attach_mpu401(struct address_info *hw_config, struct module *owner)
1003 } 1003 }
1004 if (!devc->shared_irq) 1004 if (!devc->shared_irq)
1005 { 1005 {
1006 if (request_irq(devc->irq, mpuintr, 0, "mpu401", (void *)m) < 0) 1006 if (request_irq(devc->irq, mpuintr, 0, "mpu401",
1007 hw_config) < 0)
1007 { 1008 {
1008 printk(KERN_WARNING "mpu401: Failed to allocate IRQ%d\n", devc->irq); 1009 printk(KERN_WARNING "mpu401: Failed to allocate IRQ%d\n", devc->irq);
1009 ret = -ENOMEM; 1010 ret = -ENOMEM;
@@ -1112,7 +1113,7 @@ int attach_mpu401(struct address_info *hw_config, struct module *owner)
1112 return 0; 1113 return 0;
1113 1114
1114out_irq: 1115out_irq:
1115 free_irq(devc->irq, (void *)m); 1116 free_irq(devc->irq, hw_config);
1116out_mididev: 1117out_mididev:
1117 sound_unload_mididev(m); 1118 sound_unload_mididev(m);
1118out_err: 1119out_err:
@@ -1227,7 +1228,7 @@ void unload_mpu401(struct address_info *hw_config)
1227 if (n != -1) { 1228 if (n != -1) {
1228 release_region(hw_config->io_base, 2); 1229 release_region(hw_config->io_base, 2);
1229 if (hw_config->always_detect == 0 && hw_config->irq > 0) 1230 if (hw_config->always_detect == 0 && hw_config->irq > 0)
1230 free_irq(hw_config->irq, (void *)n); 1231 free_irq(hw_config->irq, hw_config);
1231 p=mpu401_synth_operations[n]; 1232 p=mpu401_synth_operations[n];
1232 sound_unload_mididev(n); 1233 sound_unload_mididev(n);
1233 sound_unload_timerdev(hw_config->slots[2]); 1234 sound_unload_timerdev(hw_config->slots[2]);
diff --git a/sound/oss/nm256.h b/sound/oss/nm256.h
deleted file mode 100644
index 1dade903399..00000000000
--- a/sound/oss/nm256.h
+++ /dev/null
@@ -1,292 +0,0 @@
1#ifndef _NM256_H_
2#define _NM256_H_
3
4#include <linux/spinlock.h>
5#include <linux/interrupt.h>
6
7#include "ac97.h"
8
9/* The revisions that we currently handle. */
10enum nm256rev {
11 REV_NM256AV, REV_NM256ZX
12};
13
14/* Per-card structure. */
15struct nm256_info
16{
17 /* Magic number used to verify that this struct is valid. */
18#define NM_MAGIC_SIG 0x55aa00ff
19 int magsig;
20
21 /* Revision number */
22 enum nm256rev rev;
23
24 struct ac97_hwint mdev;
25
26 /* Our audio device numbers. */
27 int dev[2];
28
29 /* The # of times each device has been opened. (Should only be
30 0 or 1). */
31 int opencnt[2];
32
33 /* We use two devices, because we can do simultaneous play and record.
34 This keeps track of which device is being used for what purpose;
35 these are the actual device numbers. */
36 int dev_for_play;
37 int dev_for_record;
38
39 spinlock_t lock;
40
41 /* The mixer device. */
42 int mixer_oss_dev;
43
44 /*
45 * Can only be opened once for each operation. These aren't set
46 * until an actual I/O operation is performed; this allows one
47 * device to be open for read/write without inhibiting I/O to
48 * the other device.
49 */
50 int is_open_play;
51 int is_open_record;
52
53 /* Non-zero if we're currently playing a sample. */
54 int playing;
55 /* Ditto for recording a sample. */
56 int recording;
57
58 /* The two memory ports. */
59 struct nm256_ports {
60 /* Physical address of the port. */
61 u32 physaddr;
62 /* Our mapped-in pointer. */
63 char __iomem *ptr;
64 /* PTR's offset within the physical port. */
65 u32 start_offset;
66 /* And the offset of the end of the buffer. */
67 u32 end_offset;
68 } port[2];
69
70 /* The following are offsets within memory port 1. */
71 u32 coeffBuf;
72 u32 allCoeffBuf;
73
74 /* Record and playback buffers. */
75 u32 abuf1, abuf2;
76
77 /* Offset of the AC97 mixer in memory port 2. */
78 u32 mixer;
79
80 /* Offset of the mixer status register in memory port 2. */
81 u32 mixer_status_offset;
82
83 /* Non-zero if we have written initial values to the mixer. */
84 u8 mixer_values_init;
85
86 /*
87 * Status mask bit; (*mixer_status_loc & mixer_status_mask) == 0 means
88 * it's ready.
89 */
90 u16 mixer_status_mask;
91
92 /* The sizes of the playback and record ring buffers. */
93 u32 playbackBufferSize;
94 u32 recordBufferSize;
95
96 /* Are the coefficient values in the memory cache current? */
97 u8 coeffsCurrent;
98
99 /* For writes, the amount we last wrote. */
100 u32 requested_amt;
101 /* The start of the block currently playing. */
102 u32 curPlayPos;
103
104 /* The amount of data we were requested to record. */
105 u32 requestedRecAmt;
106 /* The offset of the currently-recording block. */
107 u32 curRecPos;
108 /* The destination buffer. */
109 char *recBuf;
110
111 /* Our IRQ number. */
112 int irq;
113
114 /* A flag indicating how many times we've grabbed the IRQ. */
115 int has_irq;
116
117 /* The card interrupt service routine. */
118 irq_handler_t introutine;
119
120 /* Current audio config, cached. */
121 struct sinfo {
122 u32 samplerate;
123 u8 bits;
124 u8 stereo;
125 } sinfo[2]; /* goes with each device */
126
127 /* The cards are stored in a chain; this is the next card. */
128 struct nm256_info *next_card;
129};
130
131/* The BIOS signature. */
132#define NM_SIGNATURE 0x4e4d0000
133/* Signature mask. */
134#define NM_SIG_MASK 0xffff0000
135
136/* Size of the second memory area. */
137#define NM_PORT2_SIZE 4096
138
139/* The base offset of the mixer in the second memory area. */
140#define NM_MIXER_OFFSET 0x600
141
142/* The maximum size of a coefficient entry. */
143#define NM_MAX_COEFFICIENT 0x5000
144
145/* The interrupt register. */
146#define NM_INT_REG 0xa04
147/* And its bits. */
148#define NM_PLAYBACK_INT 0x40
149#define NM_RECORD_INT 0x100
150#define NM_MISC_INT_1 0x4000
151#define NM_MISC_INT_2 0x1
152#define NM_ACK_INT(CARD, X) nm256_writePort16((CARD), 2, NM_INT_REG, (X) << 1)
153
154/* The AV's "mixer ready" status bit and location. */
155#define NM_MIXER_STATUS_OFFSET 0xa04
156#define NM_MIXER_READY_MASK 0x0800
157#define NM_MIXER_PRESENCE 0xa06
158#define NM_PRESENCE_MASK 0x0050
159#define NM_PRESENCE_VALUE 0x0040
160
161/*
162 * For the ZX. It uses the same interrupt register, but it holds 32
163 * bits instead of 16.
164 */
165#define NM2_PLAYBACK_INT 0x10000
166#define NM2_RECORD_INT 0x80000
167#define NM2_MISC_INT_1 0x8
168#define NM2_MISC_INT_2 0x2
169#define NM2_ACK_INT(CARD, X) nm256_writePort32((CARD), 2, NM_INT_REG, (X))
170
171/* The ZX's "mixer ready" status bit and location. */
172#define NM2_MIXER_STATUS_OFFSET 0xa06
173#define NM2_MIXER_READY_MASK 0x0800
174
175/* The playback registers start from here. */
176#define NM_PLAYBACK_REG_OFFSET 0x0
177/* The record registers start from here. */
178#define NM_RECORD_REG_OFFSET 0x200
179
180/* The rate register is located 2 bytes from the start of the register area. */
181#define NM_RATE_REG_OFFSET 2
182
183/* Mono/stereo flag, number of bits on playback, and rate mask. */
184#define NM_RATE_STEREO 1
185#define NM_RATE_BITS_16 2
186#define NM_RATE_MASK 0xf0
187
188/* Playback enable register. */
189#define NM_PLAYBACK_ENABLE_REG (NM_PLAYBACK_REG_OFFSET + 0x1)
190#define NM_PLAYBACK_ENABLE_FLAG 1
191#define NM_PLAYBACK_ONESHOT 2
192#define NM_PLAYBACK_FREERUN 4
193
194/* Mutes the audio output. */
195#define NM_AUDIO_MUTE_REG (NM_PLAYBACK_REG_OFFSET + 0x18)
196#define NM_AUDIO_MUTE_LEFT 0x8000
197#define NM_AUDIO_MUTE_RIGHT 0x0080
198
199/* Recording enable register. */
200#define NM_RECORD_ENABLE_REG (NM_RECORD_REG_OFFSET + 0)
201#define NM_RECORD_ENABLE_FLAG 1
202#define NM_RECORD_FREERUN 2
203
204#define NM_RBUFFER_START (NM_RECORD_REG_OFFSET + 0x4)
205#define NM_RBUFFER_END (NM_RECORD_REG_OFFSET + 0x10)
206#define NM_RBUFFER_WMARK (NM_RECORD_REG_OFFSET + 0xc)
207#define NM_RBUFFER_CURRP (NM_RECORD_REG_OFFSET + 0x8)
208
209#define NM_PBUFFER_START (NM_PLAYBACK_REG_OFFSET + 0x4)
210#define NM_PBUFFER_END (NM_PLAYBACK_REG_OFFSET + 0x14)
211#define NM_PBUFFER_WMARK (NM_PLAYBACK_REG_OFFSET + 0xc)
212#define NM_PBUFFER_CURRP (NM_PLAYBACK_REG_OFFSET + 0x8)
213
214/* A few trivial routines to make it easier to work with the registers
215 on the chip. */
216
217/* This is a common code portion used to fix up the port offsets. */
218#define NM_FIX_PORT \
219 if (port < 1 || port > 2 || card == NULL) \
220 return -1; \
221\
222 if (offset < card->port[port - 1].start_offset \
223 || offset >= card->port[port - 1].end_offset) { \
224 printk (KERN_ERR "Bad access: port %d, offset 0x%x\n", port, offset); \
225 return -1; \
226 } \
227 offset -= card->port[port - 1].start_offset;
228
229#define DEFwritePortX(X, func) \
230static inline int nm256_writePort##X (struct nm256_info *card,\
231 int port, int offset, int value)\
232{\
233 u##X __iomem *addr;\
234\
235 if (nm256_debug > 1)\
236 printk (KERN_DEBUG "Writing 0x%x to %d:0x%x\n", value, port, offset);\
237\
238 NM_FIX_PORT;\
239\
240 addr = (u##X __iomem *)(card->port[port - 1].ptr + offset);\
241 func (value, addr);\
242 return 0;\
243}
244
245DEFwritePortX (8, writeb)
246DEFwritePortX (16, writew)
247DEFwritePortX (32, writel)
248
249#define DEFreadPortX(X, func) \
250static inline u##X nm256_readPort##X (struct nm256_info *card,\
251 int port, int offset)\
252{\
253 u##X __iomem *addr;\
254\
255 NM_FIX_PORT\
256\
257 addr = (u##X __iomem *)(card->port[port - 1].ptr + offset);\
258 return func(addr);\
259}
260
261DEFreadPortX (8, readb)
262DEFreadPortX (16, readw)
263DEFreadPortX (32, readl)
264
265static inline int
266nm256_writeBuffer8 (struct nm256_info *card, u8 *src, int port, int offset,
267 int amt)
268{
269 NM_FIX_PORT;
270 memcpy_toio (card->port[port - 1].ptr + offset, src, amt);
271 return 0;
272}
273
274static inline int
275nm256_readBuffer8 (struct nm256_info *card, u8 *dst, int port, int offset,
276 int amt)
277{
278 NM_FIX_PORT;
279 memcpy_fromio (dst, card->port[port - 1].ptr + offset, amt);
280 return 0;
281}
282
283/* Returns a non-zero value if we should use the coefficient cache. */
284static int nm256_cachedCoefficients (struct nm256_info *card);
285
286#endif
287
288/*
289 * Local variables:
290 * c-basic-offset: 4
291 * End:
292 */
diff --git a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c
deleted file mode 100644
index 44cd1550500..00000000000
--- a/sound/oss/nm256_audio.c
+++ /dev/null
@@ -1,1662 +0,0 @@
1/*
2 * Audio driver for the NeoMagic 256AV and 256ZX chipsets in native
3 * mode, with AC97 mixer support.
4 *
5 * Overall design and parts of this code stolen from vidc_*.c and
6 * skeleton.c.
7 *
8 * Yeah, there are a lot of magic constants in here. You tell ME what
9 * they are. I just get this stuff psychically, remember?
10 *
11 * This driver was written by someone who wishes to remain anonymous.
12 * It is in the public domain, so share and enjoy. Try to make a profit
13 * off of it; go on, I dare you.
14 *
15 * Changes:
16 * 11-10-2000 Bartlomiej Zolnierkiewicz <bkz@linux-ide.org>
17 * Added some __init
18 * 19-04-2001 Marcus Meissner <mm@caldera.de>
19 * Ported to 2.4 PCI API.
20 */
21
22#include <linux/pci.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/delay.h>
28#include <linux/spinlock.h>
29#include "sound_config.h"
30
31static int nm256_debug;
32static int force_load;
33
34#include "nm256.h"
35#include "nm256_coeff.h"
36
37/*
38 * The size of the playback reserve. When the playback buffer has less
39 * than NM256_PLAY_WMARK_SIZE bytes to output, we request a new
40 * buffer.
41 */
42#define NM256_PLAY_WMARK_SIZE 512
43
44static struct audio_driver nm256_audio_driver;
45
46static int nm256_grabInterrupt (struct nm256_info *card);
47static int nm256_releaseInterrupt (struct nm256_info *card);
48static irqreturn_t nm256_interrupt (int irq, void *dev_id);
49static irqreturn_t nm256_interrupt_zx (int irq, void *dev_id);
50
51/* These belong in linux/pci.h. */
52#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
53#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006
54#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016
55
56/* List of cards. */
57static struct nm256_info *nmcard_list;
58
59/* Release the mapped-in memory for CARD. */
60static void
61nm256_release_ports (struct nm256_info *card)
62{
63 int x;
64
65 for (x = 0; x < 2; x++) {
66 if (card->port[x].ptr != NULL) {
67 iounmap (card->port[x].ptr);
68 card->port[x].ptr = NULL;
69 }
70 }
71}
72
73/*
74 * Map in the memory ports for CARD, if they aren't already mapped in
75 * and have been configured. If successful, a zero value is returned;
76 * otherwise any previously mapped-in areas are released and a non-zero
77 * value is returned.
78 *
79 * This is invoked twice, once for each port. Ideally it would only be
80 * called once, but we now need to map in the second port in order to
81 * check how much memory the card has on the 256ZX.
82 */
83static int
84nm256_remap_ports (struct nm256_info *card)
85{
86 int x;
87
88 for (x = 0; x < 2; x++) {
89 if (card->port[x].ptr == NULL && card->port[x].end_offset > 0) {
90 u32 physaddr
91 = card->port[x].physaddr + card->port[x].start_offset;
92 u32 size
93 = card->port[x].end_offset - card->port[x].start_offset;
94
95 card->port[x].ptr = ioremap_nocache (physaddr, size);
96
97 if (card->port[x].ptr == NULL) {
98 printk (KERN_ERR "NM256: Unable to remap port %d\n", x + 1);
99 nm256_release_ports (card);
100 return -1;
101 }
102 }
103 }
104 return 0;
105}
106
107/* Locate the card in our list. */
108static struct nm256_info *
109nm256_find_card (int dev)
110{
111 struct nm256_info *card;
112
113 for (card = nmcard_list; card != NULL; card = card->next_card)
114 if (card->dev[0] == dev || card->dev[1] == dev)
115 return card;
116
117 return NULL;
118}
119
120/*
121 * Ditto, but find the card struct corresponding to the mixer device DEV
122 * instead.
123 */
124static struct nm256_info *
125nm256_find_card_for_mixer (int dev)
126{
127 struct nm256_info *card;
128
129 for (card = nmcard_list; card != NULL; card = card->next_card)
130 if (card->mixer_oss_dev == dev)
131 return card;
132
133 return NULL;
134}
135
136static int usecache;
137static int buffertop;
138
139/* Check to see if we're using the bank of cached coefficients. */
140static int
141nm256_cachedCoefficients (struct nm256_info *card)
142{
143 return usecache;
144}
145
146/* The actual rates supported by the card. */
147static int samplerates[9] = {
148 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 99999999
149};
150
151/*
152 * Set the card samplerate, word size and stereo mode to correspond to
153 * the settings in the CARD struct for the specified device in DEV.
154 * We keep two separate sets of information, one for each device; the
155 * hardware is not actually configured until a read or write is
156 * attempted.
157 */
158
159static int
160nm256_setInfo (int dev, struct nm256_info *card)
161{
162 int x;
163 int w;
164 int targetrate;
165
166 if (card->dev[0] == dev)
167 w = 0;
168 else if (card->dev[1] == dev)
169 w = 1;
170 else
171 return -ENODEV;
172
173 targetrate = card->sinfo[w].samplerate;
174
175 if ((card->sinfo[w].bits != 8 && card->sinfo[w].bits != 16)
176 || targetrate < samplerates[0]
177 || targetrate > samplerates[7])
178 return -EINVAL;
179
180 for (x = 0; x < 8; x++)
181 if (targetrate < ((samplerates[x] + samplerates[x + 1]) / 2))
182 break;
183
184 if (x < 8) {
185 u8 ratebits = ((x << 4) & NM_RATE_MASK);
186 if (card->sinfo[w].bits == 16)
187 ratebits |= NM_RATE_BITS_16;
188 if (card->sinfo[w].stereo)
189 ratebits |= NM_RATE_STEREO;
190
191 card->sinfo[w].samplerate = samplerates[x];
192
193
194 if (card->dev_for_play == dev && card->playing) {
195 if (nm256_debug)
196 printk (KERN_DEBUG "Setting play ratebits to 0x%x\n",
197 ratebits);
198 nm256_loadCoefficient (card, 0, x);
199 nm256_writePort8 (card, 2,
200 NM_PLAYBACK_REG_OFFSET + NM_RATE_REG_OFFSET,
201 ratebits);
202 }
203
204 if (card->dev_for_record == dev && card->recording) {
205 if (nm256_debug)
206 printk (KERN_DEBUG "Setting record ratebits to 0x%x\n",
207 ratebits);
208 nm256_loadCoefficient (card, 1, x);
209 nm256_writePort8 (card, 2,
210 NM_RECORD_REG_OFFSET + NM_RATE_REG_OFFSET,
211 ratebits);
212 }
213 return 0;
214 }
215 else
216 return -EINVAL;
217}
218
219/* Start the play process going. */
220static void
221startPlay (struct nm256_info *card)
222{
223 if (! card->playing) {
224 card->playing = 1;
225 if (nm256_grabInterrupt (card) == 0) {
226 nm256_setInfo (card->dev_for_play, card);
227
228 /* Enable playback engine and interrupts. */
229 nm256_writePort8 (card, 2, NM_PLAYBACK_ENABLE_REG,
230 NM_PLAYBACK_ENABLE_FLAG | NM_PLAYBACK_FREERUN);
231
232 /* Enable both channels. */
233 nm256_writePort16 (card, 2, NM_AUDIO_MUTE_REG, 0x0);
234 }
235 }
236}
237
238/*
239 * Request one chunk of AMT bytes from the recording device. When the
240 * operation is complete, the data will be copied into BUFFER and the
241 * function DMAbuf_inputintr will be invoked.
242 */
243
244static void
245nm256_startRecording (struct nm256_info *card, char *buffer, u32 amt)
246{
247 u32 endpos;
248 int enableEngine = 0;
249 u32 ringsize = card->recordBufferSize;
250 unsigned long flags;
251
252 if (amt > (ringsize / 2)) {
253 /*
254 * Of course this won't actually work right, because the
255 * caller is going to assume we will give what we got asked
256 * for.
257 */
258 printk (KERN_ERR "NM256: Read request too large: %d\n", amt);
259 amt = ringsize / 2;
260 }
261
262 if (amt < 8) {
263 printk (KERN_ERR "NM256: Read request too small; %d\n", amt);
264 return;
265 }
266
267 spin_lock_irqsave(&card->lock,flags);
268 /*
269 * If we're not currently recording, set up the start and end registers
270 * for the recording engine.
271 */
272 if (! card->recording) {
273 card->recording = 1;
274 if (nm256_grabInterrupt (card) == 0) {
275 card->curRecPos = 0;
276 nm256_setInfo (card->dev_for_record, card);
277 nm256_writePort32 (card, 2, NM_RBUFFER_START, card->abuf2);
278 nm256_writePort32 (card, 2, NM_RBUFFER_END,
279 card->abuf2 + ringsize);
280
281 nm256_writePort32 (card, 2, NM_RBUFFER_CURRP,
282 card->abuf2 + card->curRecPos);
283 enableEngine = 1;
284 }
285 else {
286 /* Not sure what else to do here. */
287 spin_unlock_irqrestore(&card->lock,flags);
288 return;
289 }
290 }
291
292 /*
293 * If we happen to go past the end of the buffer a bit (due to a
294 * delayed interrupt) it's OK. So might as well set the watermark
295 * right at the end of the data we want.
296 */
297 endpos = card->abuf2 + ((card->curRecPos + amt) % ringsize);
298
299 card->recBuf = buffer;
300 card->requestedRecAmt = amt;
301 nm256_writePort32 (card, 2, NM_RBUFFER_WMARK, endpos);
302 /* Enable recording engine and interrupts. */
303 if (enableEngine)
304 nm256_writePort8 (card, 2, NM_RECORD_ENABLE_REG,
305 NM_RECORD_ENABLE_FLAG | NM_RECORD_FREERUN);
306
307 spin_unlock_irqrestore(&card->lock,flags);
308}
309
310/* Stop the play engine. */
311static void
312stopPlay (struct nm256_info *card)
313{
314 /* Shut off sound from both channels. */
315 nm256_writePort16 (card, 2, NM_AUDIO_MUTE_REG,
316 NM_AUDIO_MUTE_LEFT | NM_AUDIO_MUTE_RIGHT);
317 /* Disable play engine. */
318 nm256_writePort8 (card, 2, NM_PLAYBACK_ENABLE_REG, 0);
319 if (card->playing) {
320 nm256_releaseInterrupt (card);
321
322 /* Reset the relevant state bits. */
323 card->playing = 0;
324 card->curPlayPos = 0;
325 }
326}
327
328/* Stop recording. */
329static void
330stopRecord (struct nm256_info *card)
331{
332 /* Disable recording engine. */
333 nm256_writePort8 (card, 2, NM_RECORD_ENABLE_REG, 0);
334
335 if (card->recording) {
336 nm256_releaseInterrupt (card);
337
338 card->recording = 0;
339 card->curRecPos = 0;
340 }
341}
342
343/*
344 * Ring buffers, man. That's where the hip-hop, wild-n-wooly action's at.
345 * 1972? (Well, I suppose it was cheep-n-easy to implement.)
346 *
347 * Write AMT bytes of BUFFER to the playback ring buffer, and start the
348 * playback engine running. It will only accept up to 1/2 of the total
349 * size of the ring buffer. No check is made that we're about to overwrite
350 * the currently-playing sample.
351 */
352
353static void
354nm256_write_block (struct nm256_info *card, char *buffer, u32 amt)
355{
356 u32 ringsize = card->playbackBufferSize;
357 u32 endstop;
358 unsigned long flags;
359
360 if (amt > (ringsize / 2)) {
361 printk (KERN_ERR "NM256: Write request too large: %d\n", amt);
362 amt = (ringsize / 2);
363 }
364
365 if (amt < NM256_PLAY_WMARK_SIZE) {
366 printk (KERN_ERR "NM256: Write request too small: %d\n", amt);
367 return;
368 }
369
370 card->curPlayPos %= ringsize;
371
372 card->requested_amt = amt;
373
374 spin_lock_irqsave(&card->lock,flags);
375
376 if ((card->curPlayPos + amt) >= ringsize) {
377 u32 rem = ringsize - card->curPlayPos;
378
379 nm256_writeBuffer8 (card, buffer, 1,
380 card->abuf1 + card->curPlayPos,
381 rem);
382 if (amt > rem)
383 nm256_writeBuffer8 (card, buffer + rem, 1, card->abuf1,
384 amt - rem);
385 }
386 else
387 nm256_writeBuffer8 (card, buffer, 1,
388 card->abuf1 + card->curPlayPos,
389 amt);
390
391 /*
392 * Setup the start-n-stop-n-limit registers, and start that engine
393 * goin'.
394 *
395 * Normally we just let it wrap around to avoid the click-click
396 * action scene.
397 */
398 if (! card->playing) {
399 /* The PBUFFER_END register in this case points to one sample
400 before the end of the buffer. */
401 int w = (card->dev_for_play == card->dev[0] ? 0 : 1);
402 int sampsize = (card->sinfo[w].bits == 16 ? 2 : 1);
403
404 if (card->sinfo[w].stereo)
405 sampsize *= 2;
406
407 /* Need to set the not-normally-changing-registers up. */
408 nm256_writePort32 (card, 2, NM_PBUFFER_START,
409 card->abuf1 + card->curPlayPos);
410 nm256_writePort32 (card, 2, NM_PBUFFER_END,
411 card->abuf1 + ringsize - sampsize);
412 nm256_writePort32 (card, 2, NM_PBUFFER_CURRP,
413 card->abuf1 + card->curPlayPos);
414 }
415 endstop = (card->curPlayPos + amt - NM256_PLAY_WMARK_SIZE) % ringsize;
416 nm256_writePort32 (card, 2, NM_PBUFFER_WMARK, card->abuf1 + endstop);
417
418 if (! card->playing)
419 startPlay (card);
420
421 spin_unlock_irqrestore(&card->lock,flags);
422}
423
424/* We just got a card playback interrupt; process it. */
425static void
426nm256_get_new_block (struct nm256_info *card)
427{
428 /* Check to see how much got played so far. */
429 u32 amt = nm256_readPort32 (card, 2, NM_PBUFFER_CURRP) - card->abuf1;
430
431 if (amt >= card->playbackBufferSize) {
432 printk (KERN_ERR "NM256: Sound playback pointer invalid!\n");
433 amt = 0;
434 }
435
436 if (amt < card->curPlayPos)
437 amt = (card->playbackBufferSize - card->curPlayPos) + amt;
438 else
439 amt -= card->curPlayPos;
440
441 if (card->requested_amt > (amt + NM256_PLAY_WMARK_SIZE)) {
442 u32 endstop =
443 card->curPlayPos + card->requested_amt - NM256_PLAY_WMARK_SIZE;
444 nm256_writePort32 (card, 2, NM_PBUFFER_WMARK, card->abuf1 + endstop);
445 }
446 else {
447 card->curPlayPos += card->requested_amt;
448 /* Get a new block to write. This will eventually invoke
449 nm256_write_block () or stopPlay (). */
450 DMAbuf_outputintr (card->dev_for_play, 1);
451 }
452}
453
454/*
455 * Read the last-recorded block from the ring buffer, copy it into the
456 * saved buffer pointer, and invoke DMAuf_inputintr() with the recording
457 * device.
458 */
459
460static void
461nm256_read_block (struct nm256_info *card)
462{
463 /* Grab the current position of the recording pointer. */
464 u32 currptr = nm256_readPort32 (card, 2, NM_RBUFFER_CURRP) - card->abuf2;
465 u32 amtToRead = card->requestedRecAmt;
466 u32 ringsize = card->recordBufferSize;
467
468 if (currptr >= card->recordBufferSize) {
469 printk (KERN_ERR "NM256: Sound buffer record pointer invalid!\n");
470 currptr = 0;
471 }
472
473 /*
474 * This test is probably redundant; we shouldn't be here unless
475 * it's true.
476 */
477 if (card->recording) {
478 /* If we wrapped around, copy everything from the start of our
479 recording buffer to the end of the buffer. */
480 if (currptr < card->curRecPos) {
481 u32 amt = min (ringsize - card->curRecPos, amtToRead);
482
483 nm256_readBuffer8 (card, card->recBuf, 1,
484 card->abuf2 + card->curRecPos,
485 amt);
486 amtToRead -= amt;
487 card->curRecPos += amt;
488 card->recBuf += amt;
489 if (card->curRecPos == ringsize)
490 card->curRecPos = 0;
491 }
492
493 if ((card->curRecPos < currptr) && (amtToRead > 0)) {
494 u32 amt = min (currptr - card->curRecPos, amtToRead);
495 nm256_readBuffer8 (card, card->recBuf, 1,
496 card->abuf2 + card->curRecPos, amt);
497 card->curRecPos = ((card->curRecPos + amt) % ringsize);
498 }
499 card->recBuf = NULL;
500 card->requestedRecAmt = 0;
501 DMAbuf_inputintr (card->dev_for_record);
502 }
503}
504
505/*
506 * Initialize the hardware.
507 */
508static void
509nm256_initHw (struct nm256_info *card)
510{
511 /* Reset everything. */
512 nm256_writePort8 (card, 2, 0x0, 0x11);
513 nm256_writePort16 (card, 2, 0x214, 0);
514
515 stopRecord (card);
516 stopPlay (card);
517}
518
519/*
520 * Handle a potential interrupt for the device referred to by DEV_ID.
521 *
522 * I don't like the cut-n-paste job here either between the two routines,
523 * but there are sufficient differences between the two interrupt handlers
524 * that parameterizing it isn't all that great either. (Could use a macro,
525 * I suppose...yucky bleah.)
526 */
527
528static irqreturn_t
529nm256_interrupt (int irq, void *dev_id)
530{
531 struct nm256_info *card = (struct nm256_info *)dev_id;
532 u16 status;
533 static int badintrcount;
534 int handled = 0;
535
536 if ((card == NULL) || (card->magsig != NM_MAGIC_SIG)) {
537 printk (KERN_ERR "NM256: Bad card pointer\n");
538 return IRQ_NONE;
539 }
540
541 status = nm256_readPort16 (card, 2, NM_INT_REG);
542
543 /* Not ours. */
544 if (status == 0) {
545 if (badintrcount++ > 1000) {
546 /*
547 * I'm not sure if the best thing is to stop the card from
548 * playing or just release the interrupt (after all, we're in
549 * a bad situation, so doing fancy stuff may not be such a good
550 * idea).
551 *
552 * I worry about the card engine continuing to play noise
553 * over and over, however--that could become a very
554 * obnoxious problem. And we know that when this usually
555 * happens things are fairly safe, it just means the user's
556 * inserted a PCMCIA card and someone's spamming us with IRQ 9s.
557 */
558
559 handled = 1;
560 if (card->playing)
561 stopPlay (card);
562 if (card->recording)
563 stopRecord (card);
564 badintrcount = 0;
565 }
566 return IRQ_RETVAL(handled);
567 }
568
569 badintrcount = 0;
570
571 /* Rather boring; check for individual interrupts and process them. */
572
573 if (status & NM_PLAYBACK_INT) {
574 handled = 1;
575 status &= ~NM_PLAYBACK_INT;
576 NM_ACK_INT (card, NM_PLAYBACK_INT);
577
578 if (card->playing)
579 nm256_get_new_block (card);
580 }
581
582 if (status & NM_RECORD_INT) {
583 handled = 1;
584 status &= ~NM_RECORD_INT;
585 NM_ACK_INT (card, NM_RECORD_INT);
586
587 if (card->recording)
588 nm256_read_block (card);
589 }
590
591 if (status & NM_MISC_INT_1) {
592 u8 cbyte;
593
594 handled = 1;
595 status &= ~NM_MISC_INT_1;
596 printk (KERN_ERR "NM256: Got misc interrupt #1\n");
597 NM_ACK_INT (card, NM_MISC_INT_1);
598 nm256_writePort16 (card, 2, NM_INT_REG, 0x8000);
599 cbyte = nm256_readPort8 (card, 2, 0x400);
600 nm256_writePort8 (card, 2, 0x400, cbyte | 2);
601 }
602
603 if (status & NM_MISC_INT_2) {
604 u8 cbyte;
605
606 handled = 1;
607 status &= ~NM_MISC_INT_2;
608 printk (KERN_ERR "NM256: Got misc interrupt #2\n");
609 NM_ACK_INT (card, NM_MISC_INT_2);
610 cbyte = nm256_readPort8 (card, 2, 0x400);
611 nm256_writePort8 (card, 2, 0x400, cbyte & ~2);
612 }
613
614 /* Unknown interrupt. */
615 if (status) {
616 handled = 1;
617 printk (KERN_ERR "NM256: Fire in the hole! Unknown status 0x%x\n",
618 status);
619 /* Pray. */
620 NM_ACK_INT (card, status);
621 }
622 return IRQ_RETVAL(handled);
623}
624
625/*
626 * Handle a potential interrupt for the device referred to by DEV_ID.
627 * This handler is for the 256ZX, and is very similar to the non-ZX
628 * routine.
629 */
630
631static irqreturn_t
632nm256_interrupt_zx (int irq, void *dev_id)
633{
634 struct nm256_info *card = (struct nm256_info *)dev_id;
635 u32 status;
636 static int badintrcount;
637 int handled = 0;
638
639 if ((card == NULL) || (card->magsig != NM_MAGIC_SIG)) {
640 printk (KERN_ERR "NM256: Bad card pointer\n");
641 return IRQ_NONE;
642 }
643
644 status = nm256_readPort32 (card, 2, NM_INT_REG);
645
646 /* Not ours. */
647 if (status == 0) {
648 if (badintrcount++ > 1000) {
649 printk (KERN_ERR "NM256: Releasing interrupt, over 1000 invalid interrupts\n");
650 /*
651 * I'm not sure if the best thing is to stop the card from
652 * playing or just release the interrupt (after all, we're in
653 * a bad situation, so doing fancy stuff may not be such a good
654 * idea).
655 *
656 * I worry about the card engine continuing to play noise
657 * over and over, however--that could become a very
658 * obnoxious problem. And we know that when this usually
659 * happens things are fairly safe, it just means the user's
660 * inserted a PCMCIA card and someone's spamming us with
661 * IRQ 9s.
662 */
663
664 handled = 1;
665 if (card->playing)
666 stopPlay (card);
667 if (card->recording)
668 stopRecord (card);
669 badintrcount = 0;
670 }
671 return IRQ_RETVAL(handled);
672 }
673
674 badintrcount = 0;
675
676 /* Rather boring; check for individual interrupts and process them. */
677
678 if (status & NM2_PLAYBACK_INT) {
679 handled = 1;
680 status &= ~NM2_PLAYBACK_INT;
681 NM2_ACK_INT (card, NM2_PLAYBACK_INT);
682
683 if (card->playing)
684 nm256_get_new_block (card);
685 }
686
687 if (status & NM2_RECORD_INT) {
688 handled = 1;
689 status &= ~NM2_RECORD_INT;
690 NM2_ACK_INT (card, NM2_RECORD_INT);
691
692 if (card->recording)
693 nm256_read_block (card);
694 }
695
696 if (status & NM2_MISC_INT_1) {
697 u8 cbyte;
698
699 handled = 1;
700 status &= ~NM2_MISC_INT_1;
701 printk (KERN_ERR "NM256: Got misc interrupt #1\n");
702 NM2_ACK_INT (card, NM2_MISC_INT_1);
703 cbyte = nm256_readPort8 (card, 2, 0x400);
704 nm256_writePort8 (card, 2, 0x400, cbyte | 2);
705 }
706
707 if (status & NM2_MISC_INT_2) {
708 u8 cbyte;
709
710 handled = 1;
711 status &= ~NM2_MISC_INT_2;
712 printk (KERN_ERR "NM256: Got misc interrupt #2\n");
713 NM2_ACK_INT (card, NM2_MISC_INT_2);
714 cbyte = nm256_readPort8 (card, 2, 0x400);
715 nm256_writePort8 (card, 2, 0x400, cbyte & ~2);
716 }
717
718 /* Unknown interrupt. */
719 if (status) {
720 handled = 1;
721 printk (KERN_ERR "NM256: Fire in the hole! Unknown status 0x%x\n",
722 status);
723 /* Pray. */
724 NM2_ACK_INT (card, status);
725 }
726 return IRQ_RETVAL(handled);
727}
728
729/*
730 * Request our interrupt.
731 */
732static int
733nm256_grabInterrupt (struct nm256_info *card)
734{
735 if (card->has_irq++ == 0) {
736 if (request_irq (card->irq, card->introutine, IRQF_SHARED,
737 "NM256_audio", card) < 0) {
738 printk (KERN_ERR "NM256: can't obtain IRQ %d\n", card->irq);
739 return -1;
740 }
741 }
742 return 0;
743}
744
745/*
746 * Release our interrupt.
747 */
748static int
749nm256_releaseInterrupt (struct nm256_info *card)
750{
751 if (card->has_irq <= 0) {
752 printk (KERN_ERR "nm256: too many calls to releaseInterrupt\n");
753 return -1;
754 }
755 card->has_irq--;
756 if (card->has_irq == 0) {
757 free_irq (card->irq, card);
758 }
759 return 0;
760}
761
762/*
763 * Waits for the mixer to become ready to be written; returns a zero value
764 * if it timed out.
765 */
766
767static int
768nm256_isReady (struct ac97_hwint *dev)
769{
770 struct nm256_info *card = (struct nm256_info *)dev->driver_private;
771 int t2 = 10;
772 u32 testaddr;
773 u16 testb;
774 int done = 0;
775
776 if (card->magsig != NM_MAGIC_SIG) {
777 printk (KERN_ERR "NM256: Bad magic signature in isReady!\n");
778 return 0;
779 }
780
781 testaddr = card->mixer_status_offset;
782 testb = card->mixer_status_mask;
783
784 /*
785 * Loop around waiting for the mixer to become ready.
786 */
787 while (! done && t2-- > 0) {
788 if ((nm256_readPort16 (card, 2, testaddr) & testb) == 0)
789 done = 1;
790 else
791 udelay (100);
792 }
793 return done;
794}
795
796/*
797 * Return the contents of the AC97 mixer register REG. Returns a positive
798 * value if successful, or a negative error code.
799 */
800static int
801nm256_readAC97Reg (struct ac97_hwint *dev, u8 reg)
802{
803 struct nm256_info *card = (struct nm256_info *)dev->driver_private;
804
805 if (card->magsig != NM_MAGIC_SIG) {
806 printk (KERN_ERR "NM256: Bad magic signature in readAC97Reg!\n");
807 return -EINVAL;
808 }
809
810 if (reg < 128) {
811 int res;
812
813 nm256_isReady (dev);
814 res = nm256_readPort16 (card, 2, card->mixer + reg);
815 /* Magic delay. Bleah yucky. */
816 udelay (1000);
817 return res;
818 }
819 else
820 return -EINVAL;
821}
822
823/*
824 * Writes VALUE to AC97 mixer register REG. Returns 0 if successful, or
825 * a negative error code.
826 */
827static int
828nm256_writeAC97Reg (struct ac97_hwint *dev, u8 reg, u16 value)
829{
830 unsigned long flags;
831 int tries = 2;
832 int done = 0;
833 u32 base;
834
835 struct nm256_info *card = (struct nm256_info *)dev->driver_private;
836
837 if (card->magsig != NM_MAGIC_SIG) {
838 printk (KERN_ERR "NM256: Bad magic signature in writeAC97Reg!\n");
839 return -EINVAL;
840 }
841
842 base = card->mixer;
843
844 spin_lock_irqsave(&card->lock,flags);
845
846 nm256_isReady (dev);
847
848 /* Wait for the write to take, too. */
849 while ((tries-- > 0) && !done) {
850 nm256_writePort16 (card, 2, base + reg, value);
851 if (nm256_isReady (dev)) {
852 done = 1;
853 break;
854 }
855
856 }
857
858 spin_unlock_irqrestore(&card->lock,flags);
859 udelay (1000);
860
861 return ! done;
862}
863
864/*
865 * Initial register values to be written to the AC97 mixer.
866 * While most of these are identical to the reset values, we do this
867 * so that we have most of the register contents cached--this avoids
868 * reading from the mixer directly (which seems to be problematic,
869 * probably due to ignorance).
870 */
871struct initialValues
872{
873 unsigned short port;
874 unsigned short value;
875};
876
877static struct initialValues nm256_ac97_initial_values[] =
878{
879 { AC97_MASTER_VOL_STEREO, 0x8000 },
880 { AC97_HEADPHONE_VOL, 0x8000 },
881 { AC97_MASTER_VOL_MONO, 0x0000 },
882 { AC97_PCBEEP_VOL, 0x0000 },
883 { AC97_PHONE_VOL, 0x0008 },
884 { AC97_MIC_VOL, 0x8000 },
885 { AC97_LINEIN_VOL, 0x8808 },
886 { AC97_CD_VOL, 0x8808 },
887 { AC97_VIDEO_VOL, 0x8808 },
888 { AC97_AUX_VOL, 0x8808 },
889 { AC97_PCMOUT_VOL, 0x0808 },
890 { AC97_RECORD_SELECT, 0x0000 },
891 { AC97_RECORD_GAIN, 0x0B0B },
892 { AC97_GENERAL_PURPOSE, 0x0000 },
893 { 0xffff, 0xffff }
894};
895
896/* Initialize the AC97 into a known state. */
897static int
898nm256_resetAC97 (struct ac97_hwint *dev)
899{
900 struct nm256_info *card = (struct nm256_info *)dev->driver_private;
901 int x;
902
903 if (card->magsig != NM_MAGIC_SIG) {
904 printk (KERN_ERR "NM256: Bad magic signature in resetAC97!\n");
905 return -EINVAL;
906 }
907
908 /* Reset the mixer. 'Tis magic! */
909 nm256_writePort8 (card, 2, 0x6c0, 1);
910// nm256_writePort8 (card, 2, 0x6cc, 0x87); /* This crashes Dell latitudes */
911 nm256_writePort8 (card, 2, 0x6cc, 0x80);
912 nm256_writePort8 (card, 2, 0x6cc, 0x0);
913
914 if (! card->mixer_values_init) {
915 for (x = 0; nm256_ac97_initial_values[x].port != 0xffff; x++) {
916 ac97_put_register (dev,
917 nm256_ac97_initial_values[x].port,
918 nm256_ac97_initial_values[x].value);
919 card->mixer_values_init = 1;
920 }
921 }
922
923 return 0;
924}
925
926/*
927 * We don't do anything particularly special here; it just passes the
928 * mixer ioctl to the AC97 driver.
929 */
930static int
931nm256_default_mixer_ioctl (int dev, unsigned int cmd, void __user *arg)
932{
933 struct nm256_info *card = nm256_find_card_for_mixer (dev);
934 if (card != NULL)
935 return ac97_mixer_ioctl (&(card->mdev), cmd, arg);
936 else
937 return -ENODEV;
938}
939
940static struct mixer_operations nm256_mixer_operations = {
941 .owner = THIS_MODULE,
942 .id = "NeoMagic",
943 .name = "NM256AC97Mixer",
944 .ioctl = nm256_default_mixer_ioctl
945};
946
947/*
948 * Default settings for the OSS mixer. These are set last, after the
949 * mixer is initialized.
950 *
951 * I "love" C sometimes. Got braces?
952 */
953static struct ac97_mixer_value_list mixer_defaults[] = {
954 { SOUND_MIXER_VOLUME, { { 85, 85 } } },
955 { SOUND_MIXER_SPEAKER, { { 100 } } },
956 { SOUND_MIXER_PCM, { { 65, 65 } } },
957 { SOUND_MIXER_CD, { { 65, 65 } } },
958 { -1, { { 0, 0 } } }
959};
960
961
962/* Installs the AC97 mixer into CARD. */
963static int __devinit
964nm256_install_mixer (struct nm256_info *card)
965{
966 int mixer;
967
968 card->mdev.reset_device = nm256_resetAC97;
969 card->mdev.read_reg = nm256_readAC97Reg;
970 card->mdev.write_reg = nm256_writeAC97Reg;
971 card->mdev.driver_private = (void *)card;
972
973 if (ac97_init (&(card->mdev)))
974 return -1;
975
976 mixer = sound_alloc_mixerdev();
977 if (num_mixers >= MAX_MIXER_DEV) {
978 printk ("NM256 mixer: Unable to alloc mixerdev\n");
979 return -1;
980 }
981
982 mixer_devs[mixer] = &nm256_mixer_operations;
983 card->mixer_oss_dev = mixer;
984
985 /* Some reasonable default values. */
986 ac97_set_values (&(card->mdev), mixer_defaults);
987
988 printk(KERN_INFO "Initialized AC97 mixer\n");
989 return 0;
990}
991
992/*
993 * See if the signature left by the NM256 BIOS is intact; if so, we use
994 * the associated address as the end of our audio buffer in the video
995 * RAM.
996 */
997
998static void __devinit
999nm256_peek_for_sig (struct nm256_info *card)
1000{
1001 u32 port1offset
1002 = card->port[0].physaddr + card->port[0].end_offset - 0x0400;
1003 /* The signature is located 1K below the end of video RAM. */
1004 char __iomem *temp = ioremap_nocache (port1offset, 16);
1005 /* Default buffer end is 5120 bytes below the top of RAM. */
1006 u32 default_value = card->port[0].end_offset - 0x1400;
1007 u32 sig;
1008
1009 /* Install the default value first, so we don't have to repeatedly
1010 do it if there is a problem. */
1011 card->port[0].end_offset = default_value;
1012
1013 if (temp == NULL) {
1014 printk (KERN_ERR "NM256: Unable to scan for card signature in video RAM\n");
1015 return;
1016 }
1017 sig = readl (temp);
1018 if ((sig & NM_SIG_MASK) == NM_SIGNATURE) {
1019 u32 pointer = readl (temp + 4);
1020
1021 /*
1022 * If it's obviously invalid, don't use it (the port already has a
1023 * suitable default value set).
1024 */
1025 if (pointer != 0xffffffff)
1026 card->port[0].end_offset = pointer;
1027
1028 printk (KERN_INFO "NM256: Found card signature in video RAM: 0x%x\n",
1029 pointer);
1030 }
1031
1032 iounmap (temp);
1033}
1034
1035/*
1036 * Install a driver for the PCI device referenced by PCIDEV.
1037 * VERSTR is a human-readable version string.
1038 */
1039
1040static int __devinit
1041nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
1042{
1043 struct nm256_info *card;
1044 int x;
1045
1046 if (pci_enable_device(pcidev))
1047 return 0;
1048
1049 card = kmalloc (sizeof (struct nm256_info), GFP_KERNEL);
1050 if (card == NULL) {
1051 printk (KERN_ERR "NM256: out of memory!\n");
1052 return 0;
1053 }
1054
1055 card->magsig = NM_MAGIC_SIG;
1056 card->playing = 0;
1057 card->recording = 0;
1058 card->rev = rev;
1059 spin_lock_init(&card->lock);
1060
1061 /* Init the memory port info. */
1062 for (x = 0; x < 2; x++) {
1063 card->port[x].physaddr = pci_resource_start (pcidev, x);
1064 card->port[x].ptr = NULL;
1065 card->port[x].start_offset = 0;
1066 card->port[x].end_offset = 0;
1067 }
1068
1069 /* Port 2 is easy. */
1070 card->port[1].start_offset = 0;
1071 card->port[1].end_offset = NM_PORT2_SIZE;
1072
1073 /* Yuck. But we have to map in port 2 so we can check how much RAM the
1074 card has. */
1075 if (nm256_remap_ports (card)) {
1076 kfree (card);
1077 return 0;
1078 }
1079
1080 /*
1081 * The NM256 has two memory ports. The first port is nothing
1082 * more than a chunk of video RAM, which is used as the I/O ring
1083 * buffer. The second port has the actual juicy stuff (like the
1084 * mixer and the playback engine control registers).
1085 */
1086
1087 if (card->rev == REV_NM256AV) {
1088 /* Ok, try to see if this is a non-AC97 version of the hardware. */
1089 int pval = nm256_readPort16 (card, 2, NM_MIXER_PRESENCE);
1090 if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) {
1091 if (! force_load) {
1092 printk (KERN_ERR "NM256: This doesn't look to me like the AC97-compatible version.\n");
1093 printk (KERN_ERR " You can force the driver to load by passing in the module\n");
1094 printk (KERN_ERR " parameter:\n");
1095 printk (KERN_ERR " force_load = 1\n");
1096 printk (KERN_ERR "\n");
1097 printk (KERN_ERR " More likely, you should be using the appropriate SB-16 or\n");
1098 printk (KERN_ERR " CS4232 driver instead. (If your BIOS has settings for\n");
1099 printk (KERN_ERR " IRQ and/or DMA for the sound card, this is *not* the correct\n");
1100 printk (KERN_ERR " driver to use.)\n");
1101 nm256_release_ports (card);
1102 kfree (card);
1103 return 0;
1104 }
1105 else {
1106 printk (KERN_INFO "NM256: Forcing driver load as per user request.\n");
1107 }
1108 }
1109 else {
1110 /* printk (KERN_INFO "NM256: Congratulations. You're not running Eunice.\n")*/;
1111 }
1112 card->port[0].end_offset = 2560 * 1024;
1113 card->introutine = nm256_interrupt;
1114 card->mixer_status_offset = NM_MIXER_STATUS_OFFSET;
1115 card->mixer_status_mask = NM_MIXER_READY_MASK;
1116 }
1117 else {
1118 /* Not sure if there is any relevant detect for the ZX or not. */
1119 if (nm256_readPort8 (card, 2, 0xa0b) != 0)
1120 card->port[0].end_offset = 6144 * 1024;
1121 else
1122 card->port[0].end_offset = 4096 * 1024;
1123
1124 card->introutine = nm256_interrupt_zx;
1125 card->mixer_status_offset = NM2_MIXER_STATUS_OFFSET;
1126 card->mixer_status_mask = NM2_MIXER_READY_MASK;
1127 }
1128
1129 if (buffertop >= 98304 && buffertop < card->port[0].end_offset)
1130 card->port[0].end_offset = buffertop;
1131 else
1132 nm256_peek_for_sig (card);
1133
1134 card->port[0].start_offset = card->port[0].end_offset - 98304;
1135
1136 printk (KERN_INFO "NM256: Mapping port 1 from 0x%x - 0x%x\n",
1137 card->port[0].start_offset, card->port[0].end_offset);
1138
1139 if (nm256_remap_ports (card)) {
1140 kfree (card);
1141 return 0;
1142 }
1143
1144 /* See if we can get the interrupt. */
1145
1146 card->irq = pcidev->irq;
1147 card->has_irq = 0;
1148
1149 if (nm256_grabInterrupt (card) != 0) {
1150 nm256_release_ports (card);
1151 kfree (card);
1152 return 0;
1153 }
1154
1155 nm256_releaseInterrupt (card);
1156
1157 /*
1158 * Init the board.
1159 */
1160
1161 card->playbackBufferSize = 16384;
1162 card->recordBufferSize = 16384;
1163
1164 card->coeffBuf = card->port[0].end_offset - NM_MAX_COEFFICIENT;
1165 card->abuf2 = card->coeffBuf - card->recordBufferSize;
1166 card->abuf1 = card->abuf2 - card->playbackBufferSize;
1167 card->allCoeffBuf = card->abuf2 - (NM_TOTAL_COEFF_COUNT * 4);
1168
1169 /* Fixed setting. */
1170 card->mixer = NM_MIXER_OFFSET;
1171 card->mixer_values_init = 0;
1172
1173 card->is_open_play = 0;
1174 card->is_open_record = 0;
1175
1176 card->coeffsCurrent = 0;
1177
1178 card->opencnt[0] = 0; card->opencnt[1] = 0;
1179
1180 /* Reasonable default settings, but largely unnecessary. */
1181 for (x = 0; x < 2; x++) {
1182 card->sinfo[x].bits = 8;
1183 card->sinfo[x].stereo = 0;
1184 card->sinfo[x].samplerate = 8000;
1185 }
1186
1187 nm256_initHw (card);
1188
1189 for (x = 0; x < 2; x++) {
1190 if ((card->dev[x] =
1191 sound_install_audiodrv(AUDIO_DRIVER_VERSION,
1192 "NM256", &nm256_audio_driver,
1193 sizeof(struct audio_driver),
1194 DMA_NODMA, AFMT_U8 | AFMT_S16_LE,
1195 NULL, -1, -1)) >= 0) {
1196 /* 1K minimum buffer size. */
1197 audio_devs[card->dev[x]]->min_fragment = 10;
1198 /* Maximum of 8K buffer size. */
1199 audio_devs[card->dev[x]]->max_fragment = 13;
1200 }
1201 else {
1202 printk(KERN_ERR "NM256: Too many PCM devices available\n");
1203 nm256_release_ports (card);
1204 kfree (card);
1205 return 0;
1206 }
1207 }
1208
1209 pci_set_drvdata(pcidev,card);
1210
1211 /* Insert the card in the list. */
1212 card->next_card = nmcard_list;
1213 nmcard_list = card;
1214
1215 printk(KERN_INFO "Initialized NeoMagic %s audio in PCI native mode\n",
1216 verstr);
1217
1218 /*
1219 * And our mixer. (We should allow support for other mixers, maybe.)
1220 */
1221
1222 nm256_install_mixer (card);
1223
1224 return 1;
1225}
1226
1227
1228static int __devinit
1229nm256_probe(struct pci_dev *pcidev,const struct pci_device_id *pciid)
1230{
1231 if (pcidev->device == PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO)
1232 return nm256_install(pcidev, REV_NM256AV, "256AV");
1233 if (pcidev->device == PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO)
1234 return nm256_install(pcidev, REV_NM256ZX, "256ZX");
1235 if (pcidev->device == PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO)
1236 return nm256_install(pcidev, REV_NM256ZX, "256XL+");
1237 return -1; /* should not come here ... */
1238}
1239
1240static void __devinit
1241nm256_remove(struct pci_dev *pcidev) {
1242 struct nm256_info *xcard = pci_get_drvdata(pcidev);
1243 struct nm256_info *card,*next_card = NULL;
1244
1245 for (card = nmcard_list; card != NULL; card = next_card) {
1246 next_card = card->next_card;
1247 if (card == xcard) {
1248 stopPlay (card);
1249 stopRecord (card);
1250 if (card->has_irq)
1251 free_irq (card->irq, card);
1252 nm256_release_ports (card);
1253 sound_unload_mixerdev (card->mixer_oss_dev);
1254 sound_unload_audiodev (card->dev[0]);
1255 sound_unload_audiodev (card->dev[1]);
1256 kfree (card);
1257 break;
1258 }
1259 }
1260 if (nmcard_list == card)
1261 nmcard_list = next_card;
1262}
1263
1264/*
1265 * Open the device
1266 *
1267 * DEV - device
1268 * MODE - mode to open device (logical OR of OPEN_READ and OPEN_WRITE)
1269 *
1270 * Called when opening the DMAbuf (dmabuf.c:259)
1271 */
1272static int
1273nm256_audio_open(int dev, int mode)
1274{
1275 struct nm256_info *card = nm256_find_card (dev);
1276 int w;
1277
1278 if (card == NULL)
1279 return -ENODEV;
1280
1281 if (card->dev[0] == dev)
1282 w = 0;
1283 else if (card->dev[1] == dev)
1284 w = 1;
1285 else
1286 return -ENODEV;
1287
1288 if (card->opencnt[w] > 0)
1289 return -EBUSY;
1290
1291 /* No bits set? Huh? */
1292 if (! ((mode & OPEN_READ) || (mode & OPEN_WRITE)))
1293 return -EIO;
1294
1295 /*
1296 * If it's open for both read and write, and the card's currently
1297 * being read or written to, then do the opposite of what has
1298 * already been done. Otherwise, don't specify any mode until the
1299 * user actually tries to do I/O. (Some programs open the device
1300 * for both read and write, but only actually do reading or writing.)
1301 */
1302
1303 if ((mode & OPEN_WRITE) && (mode & OPEN_READ)) {
1304 if (card->is_open_play)
1305 mode = OPEN_WRITE;
1306 else if (card->is_open_record)
1307 mode = OPEN_READ;
1308 else mode = 0;
1309 }
1310
1311 if (mode & OPEN_WRITE) {
1312 if (card->is_open_play == 0) {
1313 card->dev_for_play = dev;
1314 card->is_open_play = 1;
1315 }
1316 else
1317 return -EBUSY;
1318 }
1319
1320 if (mode & OPEN_READ) {
1321 if (card->is_open_record == 0) {
1322 card->dev_for_record = dev;
1323 card->is_open_record = 1;
1324 }
1325 else
1326 return -EBUSY;
1327 }
1328
1329 card->opencnt[w]++;
1330 return 0;
1331}
1332
1333/*
1334 * Close the device
1335 *
1336 * DEV - device
1337 *
1338 * Called when closing the DMAbuf (dmabuf.c:477)
1339 * after halt_xfer
1340 */
1341static void
1342nm256_audio_close(int dev)
1343{
1344 struct nm256_info *card = nm256_find_card (dev);
1345
1346 if (card != NULL) {
1347 int w;
1348
1349 if (card->dev[0] == dev)
1350 w = 0;
1351 else if (card->dev[1] == dev)
1352 w = 1;
1353 else
1354 return;
1355
1356 card->opencnt[w]--;
1357 if (card->opencnt[w] <= 0) {
1358 card->opencnt[w] = 0;
1359
1360 if (card->dev_for_play == dev) {
1361 stopPlay (card);
1362 card->is_open_play = 0;
1363 card->dev_for_play = -1;
1364 }
1365
1366 if (card->dev_for_record == dev) {
1367 stopRecord (card);
1368 card->is_open_record = 0;
1369 card->dev_for_record = -1;
1370 }
1371 }
1372 }
1373}
1374
1375/* Standard ioctl handler. */
1376static int
1377nm256_audio_ioctl(int dev, unsigned int cmd, void __user *arg)
1378{
1379 int ret;
1380 u32 oldinfo;
1381 int w;
1382
1383 struct nm256_info *card = nm256_find_card (dev);
1384
1385 if (card == NULL)
1386 return -ENODEV;
1387
1388 if (dev == card->dev[0])
1389 w = 0;
1390 else
1391 w = 1;
1392
1393 /*
1394 * The code here is messy. There are probably better ways to do
1395 * it. (It should be possible to handle it the same way the AC97 mixer
1396 * is done.)
1397 */
1398 switch (cmd)
1399 {
1400 case SOUND_PCM_WRITE_RATE:
1401 if (get_user(ret, (int __user *) arg))
1402 return -EFAULT;
1403
1404 if (ret != 0) {
1405 oldinfo = card->sinfo[w].samplerate;
1406 card->sinfo[w].samplerate = ret;
1407 ret = nm256_setInfo(dev, card);
1408 if (ret != 0)
1409 card->sinfo[w].samplerate = oldinfo;
1410 }
1411 if (ret == 0)
1412 ret = card->sinfo[w].samplerate;
1413 break;
1414
1415 case SOUND_PCM_READ_RATE:
1416 ret = card->sinfo[w].samplerate;
1417 break;
1418
1419 case SNDCTL_DSP_STEREO:
1420 if (get_user(ret, (int __user *) arg))
1421 return -EFAULT;
1422
1423 card->sinfo[w].stereo = ret ? 1 : 0;
1424 ret = nm256_setInfo (dev, card);
1425 if (ret == 0)
1426 ret = card->sinfo[w].stereo;
1427
1428 break;
1429
1430 case SOUND_PCM_WRITE_CHANNELS:
1431 if (get_user(ret, (int __user *) arg))
1432 return -EFAULT;
1433
1434 if (ret < 1 || ret > 3)
1435 ret = card->sinfo[w].stereo + 1;
1436 else {
1437 card->sinfo[w].stereo = ret - 1;
1438 ret = nm256_setInfo (dev, card);
1439 if (ret == 0)
1440 ret = card->sinfo[w].stereo + 1;
1441 }
1442 break;
1443
1444 case SOUND_PCM_READ_CHANNELS:
1445 ret = card->sinfo[w].stereo + 1;
1446 break;
1447
1448 case SNDCTL_DSP_SETFMT:
1449 if (get_user(ret, (int __user *) arg))
1450 return -EFAULT;
1451
1452 if (ret != 0) {
1453 oldinfo = card->sinfo[w].bits;
1454 card->sinfo[w].bits = ret;
1455 ret = nm256_setInfo (dev, card);
1456 if (ret != 0)
1457 card->sinfo[w].bits = oldinfo;
1458 }
1459 if (ret == 0)
1460 ret = card->sinfo[w].bits;
1461 break;
1462
1463 case SOUND_PCM_READ_BITS:
1464 ret = card->sinfo[w].bits;
1465 break;
1466
1467 default:
1468 return -EINVAL;
1469 }
1470 return put_user(ret, (int __user *) arg);
1471}
1472
1473/*
1474 * Given the sound device DEV and an associated physical buffer PHYSBUF,
1475 * return a pointer to the actual buffer in kernel space.
1476 *
1477 * This routine should exist as part of the soundcore routines.
1478 */
1479
1480static char *
1481nm256_getDMAbuffer (int dev, unsigned long physbuf)
1482{
1483 struct audio_operations *adev = audio_devs[dev];
1484 struct dma_buffparms *dmap = adev->dmap_out;
1485 char *dma_start =
1486 (char *)(physbuf - (unsigned long)dmap->raw_buf_phys
1487 + (unsigned long)dmap->raw_buf);
1488
1489 return dma_start;
1490}
1491
1492
1493/*
1494 * Output a block to sound device
1495 *
1496 * dev - device number
1497 * buf - physical address of buffer
1498 * total_count - total byte count in buffer
1499 * intrflag - set if this has been called from an interrupt
1500 * (via DMAbuf_outputintr)
1501 * restart_dma - set if engine needs to be re-initialised
1502 *
1503 * Called when:
1504 * 1. Starting output (dmabuf.c:1327)
1505 * 2. (dmabuf.c:1504)
1506 * 3. A new buffer needs to be sent to the device (dmabuf.c:1579)
1507 */
1508static void
1509nm256_audio_output_block(int dev, unsigned long physbuf,
1510 int total_count, int intrflag)
1511{
1512 struct nm256_info *card = nm256_find_card (dev);
1513
1514 if (card != NULL) {
1515 char *dma_buf = nm256_getDMAbuffer (dev, physbuf);
1516 card->is_open_play = 1;
1517 card->dev_for_play = dev;
1518 nm256_write_block (card, dma_buf, total_count);
1519 }
1520}
1521
1522/* Ditto, but do recording instead. */
1523static void
1524nm256_audio_start_input(int dev, unsigned long physbuf, int count,
1525 int intrflag)
1526{
1527 struct nm256_info *card = nm256_find_card (dev);
1528
1529 if (card != NULL) {
1530 char *dma_buf = nm256_getDMAbuffer (dev, physbuf);
1531 card->is_open_record = 1;
1532 card->dev_for_record = dev;
1533 nm256_startRecording (card, dma_buf, count);
1534 }
1535}
1536
1537/*
1538 * Prepare for inputting samples to DEV.
1539 * Each requested buffer will be BSIZE byes long, with a total of
1540 * BCOUNT buffers.
1541 */
1542
1543static int
1544nm256_audio_prepare_for_input(int dev, int bsize, int bcount)
1545{
1546 struct nm256_info *card = nm256_find_card (dev);
1547
1548 if (card == NULL)
1549 return -ENODEV;
1550
1551 if (card->is_open_record && card->dev_for_record != dev)
1552 return -EBUSY;
1553
1554 audio_devs[dev]->dmap_in->flags |= DMA_NODMA;
1555 return 0;
1556}
1557
1558/*
1559 * Prepare for outputting samples to `dev'
1560 *
1561 * Each buffer that will be passed will be `bsize' bytes long,
1562 * with a total of `bcount' buffers.
1563 *
1564 * Called when:
1565 * 1. A trigger enables audio output (dmabuf.c:978)
1566 * 2. We get a write buffer without dma_mode setup (dmabuf.c:1152)
1567 * 3. We restart a transfer (dmabuf.c:1324)
1568 */
1569
1570static int
1571nm256_audio_prepare_for_output(int dev, int bsize, int bcount)
1572{
1573 struct nm256_info *card = nm256_find_card (dev);
1574
1575 if (card == NULL)
1576 return -ENODEV;
1577
1578 if (card->is_open_play && card->dev_for_play != dev)
1579 return -EBUSY;
1580
1581 audio_devs[dev]->dmap_out->flags |= DMA_NODMA;
1582 return 0;
1583}
1584
1585/* Stop the current operations associated with DEV. */
1586static void
1587nm256_audio_reset(int dev)
1588{
1589 struct nm256_info *card = nm256_find_card (dev);
1590
1591 if (card != NULL) {
1592 if (card->dev_for_play == dev)
1593 stopPlay (card);
1594 if (card->dev_for_record == dev)
1595 stopRecord (card);
1596 }
1597}
1598
1599static int
1600nm256_audio_local_qlen(int dev)
1601{
1602 return 0;
1603}
1604
1605static struct audio_driver nm256_audio_driver =
1606{
1607 .owner = THIS_MODULE,
1608 .open = nm256_audio_open,
1609 .close = nm256_audio_close,
1610 .output_block = nm256_audio_output_block,
1611 .start_input = nm256_audio_start_input,
1612 .ioctl = nm256_audio_ioctl,
1613 .prepare_for_input = nm256_audio_prepare_for_input,
1614 .prepare_for_output = nm256_audio_prepare_for_output,
1615 .halt_io = nm256_audio_reset,
1616 .local_qlen = nm256_audio_local_qlen,
1617};
1618
1619static struct pci_device_id nm256_pci_tbl[] = {
1620 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO,
1621 PCI_ANY_ID, PCI_ANY_ID, 0, 0},
1622 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO,
1623 PCI_ANY_ID, PCI_ANY_ID, 0, 0},
1624 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO,
1625 PCI_ANY_ID, PCI_ANY_ID, 0, 0},
1626 {0,}
1627};
1628MODULE_DEVICE_TABLE(pci, nm256_pci_tbl);
1629MODULE_LICENSE("GPL");
1630
1631
1632static struct pci_driver nm256_pci_driver = {
1633 .name = "nm256_audio",
1634 .id_table = nm256_pci_tbl,
1635 .probe = nm256_probe,
1636 .remove = nm256_remove,
1637};
1638
1639module_param(usecache, bool, 0);
1640module_param(buffertop, int, 0);
1641module_param(nm256_debug, bool, 0644);
1642module_param(force_load, bool, 0);
1643
1644static int __init do_init_nm256(void)
1645{
1646 printk (KERN_INFO "NeoMagic 256AV/256ZX audio driver, version 1.1p\n");
1647 return pci_register_driver(&nm256_pci_driver);
1648}
1649
1650static void __exit cleanup_nm256 (void)
1651{
1652 pci_unregister_driver(&nm256_pci_driver);
1653}
1654
1655module_init(do_init_nm256);
1656module_exit(cleanup_nm256);
1657
1658/*
1659 * Local variables:
1660 * c-basic-offset: 4
1661 * End:
1662 */
diff --git a/sound/oss/nm256_coeff.h b/sound/oss/nm256_coeff.h
deleted file mode 100644
index 6fc07f3cb33..00000000000
--- a/sound/oss/nm256_coeff.h
+++ /dev/null
@@ -1,4697 +0,0 @@
1#ifndef NM256_COEFF_H
2#define NM256_COEFF_H
3
4#define NM_TOTAL_COEFF_COUNT 0x3158
5
6static char coefficients[NM_TOTAL_COEFF_COUNT * 4] = {
7 0xFF, 0xFF, 0x2F, 0x00, 0x4B, 0xFF, 0xA5, 0x01, 0xEF, 0xFC, 0x21,
8 0x05, 0x87, 0xF7, 0x62, 0x11, 0xE9, 0x45, 0x5E, 0xF9, 0xB5, 0x01,
9 0xDE, 0xFF, 0xA4, 0xFF, 0x60, 0x00, 0xCA, 0xFF, 0x0D, 0x00, 0xFD,
10 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3D, 0xFC, 0xD6, 0x06,
11 0x4C, 0xF3, 0xED, 0x20, 0x3D, 0x3D, 0x4A, 0xF3, 0x4E, 0x05, 0xB1,
12 0xFD, 0xE1, 0x00, 0xC3, 0xFF, 0x05, 0x00, 0x02, 0x00, 0xFD, 0xFF,
13 0x2A, 0x00, 0x5C, 0xFF, 0xAA, 0x01, 0x71, 0xFC, 0x07, 0x07, 0x7E,
14 0xF1, 0x44, 0x30, 0x44, 0x30, 0x7E, 0xF1, 0x07, 0x07, 0x71, 0xFC,
15 0xAA, 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0xFD, 0xFF, 0x02, 0x00, 0x05,
16 0x00, 0xC3, 0xFF, 0xE1, 0x00, 0xB1, 0xFD, 0x4E, 0x05, 0x4A, 0xF3,
17 0x3D, 0x3D, 0xED, 0x20, 0x4C, 0xF3, 0xD6, 0x06, 0x3D, 0xFC, 0xE6,
18 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x0D, 0x00, 0xCA, 0xFF,
19 0x60, 0x00, 0xA4, 0xFF, 0xDE, 0xFF, 0xB5, 0x01, 0x5E, 0xF9, 0xE9,
20 0x45, 0x62, 0x11, 0x87, 0xF7, 0x21, 0x05, 0xEF, 0xFC, 0xA5, 0x01,
21 0x4B, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1E, 0x00, 0x84,
22 0xFF, 0x11, 0x01, 0x34, 0xFE, 0x8F, 0x02, 0xC7, 0xFC, 0xAE, 0x03,
23 0xF7, 0x48, 0xAE, 0x03, 0xC7, 0xFC, 0x8F, 0x02, 0x34, 0xFE, 0x11,
24 0x01, 0x84, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3D, 0xFF,
25 0xCA, 0x01, 0x95, 0xFC, 0xEA, 0x05, 0xBB, 0xF5, 0x25, 0x17, 0x3C,
26 0x43, 0x8D, 0xF6, 0x43, 0x03, 0xF5, 0xFE, 0x26, 0x00, 0x20, 0x00,
27 0xE2, 0xFF, 0x08, 0x00, 0xFD, 0xFF, 0x30, 0x00, 0x4D, 0xFF, 0xC5,
28 0x01, 0x4C, 0xFC, 0x26, 0x07, 0xA3, 0xF1, 0xAB, 0x2C, 0xBB, 0x33,
29 0x8F, 0xF1, 0xCA, 0x06, 0xA6, 0xFC, 0x85, 0x01, 0x6F, 0xFF, 0x24,
30 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFE, 0xFF, 0xD5, 0xFF, 0xBC, 0x00,
31 0xF0, 0xFD, 0xEC, 0x04, 0xD9, 0xF3, 0xB1, 0x3E, 0xCD, 0x1E, 0xC1,
32 0xF3, 0xAF, 0x06, 0x49, 0xFC, 0xE4, 0x01, 0x36, 0xFF, 0x36, 0x00,
33 0xFE, 0xFF, 0x16, 0x00, 0xA6, 0xFF, 0xBB, 0x00, 0xE9, 0xFE, 0x38,
34 0x01, 0x4B, 0xFF, 0x28, 0xFE, 0x3A, 0x48, 0x04, 0x0A, 0x2E, 0xFA,
35 0xDF, 0x03, 0x8A, 0xFD, 0x60, 0x01, 0x65, 0xFF, 0x27, 0x00, 0x00,
36 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x50, 0xFF, 0x98, 0x01, 0x0D, 0xFD,
37 0xE0, 0x04, 0x14, 0xF8, 0xC3, 0x0F, 0x89, 0x46, 0x4C, 0xFA, 0x38,
38 0x01, 0x25, 0x00, 0x7D, 0xFF, 0x73, 0x00, 0xC2, 0xFF, 0x0F, 0x00,
39 0xFD, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xE3, 0x01, 0x31, 0xFC, 0x0F,
40 0x07, 0x84, 0xF2, 0x29, 0x25, 0x1A, 0x3A, 0x67, 0xF2, 0xF6, 0x05,
41 0x41, 0xFD, 0x24, 0x01, 0xA1, 0xFF, 0x12, 0x00, 0x00, 0x00, 0xFF,
42 0xFF, 0x15, 0x00, 0x97, 0xFF, 0x37, 0x01, 0x22, 0xFD, 0x23, 0x06,
43 0x2F, 0xF2, 0x11, 0x39, 0x7B, 0x26, 0x50, 0xF2, 0x1B, 0x07, 0x32,
44 0xFC, 0xE1, 0x01, 0x3C, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0E, 0x00,
45 0xC8, 0xFF, 0x64, 0x00, 0x9B, 0xFF, 0xEE, 0xFF, 0x98, 0x01, 0x93,
46 0xF9, 0x10, 0x46, 0x03, 0x11, 0xA7, 0xF7, 0x12, 0x05, 0xF6, 0xFC,
47 0xA2, 0x01, 0x4C, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x26,
48 0x00, 0x6A, 0xFF, 0x53, 0x01, 0xA6, 0xFD, 0xA6, 0x03, 0xA1, 0xFA,
49 0xDE, 0x08, 0x76, 0x48, 0x0C, 0xFF, 0xDE, 0xFE, 0x73, 0x01, 0xC9,
50 0xFE, 0xCA, 0x00, 0xA0, 0xFF, 0x17, 0x00, 0xFE, 0xFF, 0x36, 0x00,
51 0x36, 0xFF, 0xE1, 0x01, 0x52, 0xFC, 0x93, 0x06, 0x10, 0xF4, 0x78,
52 0x1D, 0x90, 0x3F, 0x3E, 0xF4, 0xAA, 0x04, 0x19, 0xFE, 0xA4, 0x00,
53 0xE2, 0xFF, 0xFA, 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x26, 0x00, 0x68,
54 0xFF, 0x93, 0x01, 0x92, 0xFC, 0xE2, 0x06, 0x83, 0xF1, 0x8C, 0x32,
55 0xED, 0x2D, 0x90, 0xF1, 0x1E, 0x07, 0x57, 0xFC, 0xBD, 0x01, 0x51,
56 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE8, 0xFF, 0x12, 0x00,
57 0x42, 0x00, 0xC4, 0xFE, 0x94, 0x03, 0x02, 0xF6, 0x89, 0x42, 0x76,
58 0x18, 0x5C, 0xF5, 0x12, 0x06, 0x84, 0xFC, 0xD1, 0x01, 0x3B, 0xFF,
59 0x34, 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x8A, 0xFF, 0x03, 0x01, 0x53,
60 0xFE, 0x53, 0x02, 0x39, 0xFD, 0xA9, 0x02, 0xF2, 0x48, 0xB9, 0x04,
61 0x54, 0xFC, 0xCA, 0x02, 0x16, 0xFE, 0x20, 0x01, 0x7F, 0xFF, 0x20,
62 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x40, 0xFF, 0xC3, 0x01,
63 0xA7, 0xFC, 0xC0, 0x05, 0x1E, 0xF6, 0xD8, 0x15, 0xE7, 0x43, 0x20,
64 0xF7, 0xEF, 0x02, 0x27, 0xFF, 0x0A, 0x00, 0x2E, 0x00, 0xDD, 0xFF,
65 0x09, 0x00, 0xFD, 0xFF, 0x31, 0x00, 0x48, 0xFF, 0xCD, 0x01, 0x43,
66 0xFC, 0x2A, 0x07, 0xBC, 0xF1, 0x64, 0x2B, 0xE3, 0x34, 0xA3, 0xF1,
67 0xAE, 0x06, 0xBD, 0xFC, 0x77, 0x01, 0x77, 0xFF, 0x21, 0x00, 0xFE,
68 0xFF, 0x02, 0x00, 0x03, 0x00, 0xCA, 0xFF, 0xD4, 0x00, 0xC8, 0xFD,
69 0x2A, 0x05, 0x7D, 0xF3, 0xCA, 0x3D, 0x22, 0x20, 0x76, 0xF3, 0xC8,
70 0x06, 0x41, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
71 0x14, 0x00, 0xAC, 0xFF, 0xAC, 0x00, 0x08, 0xFF, 0xFD, 0x00, 0xB5,
72 0xFF, 0x4B, 0xFD, 0xF4, 0x47, 0x30, 0x0B, 0xBC, 0xF9, 0x17, 0x04,
73 0x6E, 0xFD, 0x6D, 0x01, 0x60, 0xFF, 0x29, 0x00, 0x00, 0x00, 0xFF,
74 0xFF, 0x2C, 0x00, 0x54, 0xFF, 0x8D, 0x01, 0x26, 0xFD, 0xAD, 0x04,
75 0x82, 0xF8, 0x87, 0x0E, 0xF9, 0x46, 0x0C, 0xFB, 0xD4, 0x00, 0x5D,
76 0x00, 0x5E, 0xFF, 0x82, 0x00, 0xBD, 0xFF, 0x10, 0x00, 0xFD, 0xFF,
77 0x36, 0x00, 0x38, 0xFF, 0xE5, 0x01, 0x33, 0xFC, 0x01, 0x07, 0xBE,
78 0xF2, 0xD6, 0x23, 0x1F, 0x3B, 0xA5, 0xF2, 0xC5, 0x05, 0x62, 0xFD,
79 0x10, 0x01, 0xAB, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x19,
80 0x00, 0x8E, 0xFF, 0x49, 0x01, 0x04, 0xFD, 0x4D, 0x06, 0x00, 0xF2,
81 0xFE, 0x37, 0xCB, 0x27, 0x21, 0xF2, 0x23, 0x07, 0x34, 0xFC, 0xDD,
82 0x01, 0x3F, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0C, 0x00, 0xCE, 0xFF,
83 0x56, 0x00, 0xB9, 0xFF, 0xB8, 0xFF, 0xF7, 0x01, 0xE2, 0xF8, 0x8D,
84 0x45, 0x46, 0x12, 0x3C, 0xF7, 0x43, 0x05, 0xDF, 0xFC, 0xAC, 0x01,
85 0x48, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x24, 0x00, 0x70,
86 0xFF, 0x46, 0x01, 0xC3, 0xFD, 0x6D, 0x03, 0x14, 0xFB, 0xBE, 0x07,
87 0xA6, 0x48, 0xF8, 0xFF, 0x70, 0xFE, 0xAE, 0x01, 0xAA, 0xFE, 0xD9,
88 0x00, 0x9A, 0xFF, 0x19, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF,
89 0xDE, 0x01, 0x5D, 0xFC, 0x74, 0x06, 0x63, 0xF4, 0x23, 0x1C, 0x66,
90 0x40, 0xAA, 0xF4, 0x65, 0x04, 0x44, 0xFE, 0x8B, 0x00, 0xEE, 0xFF,
91 0xF5, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x29, 0x00, 0x61, 0xFF, 0x9F,
92 0x01, 0x80, 0xFC, 0xF7, 0x06, 0x7D, 0xF1, 0x5A, 0x31, 0x2C, 0x2F,
93 0x83, 0xF1, 0x13, 0x07, 0x64, 0xFC, 0xB3, 0x01, 0x57, 0xFF, 0x2C,
94 0x00, 0xFD, 0xFF, 0x06, 0x00, 0xED, 0xFF, 0x05, 0x00, 0x5D, 0x00,
95 0x95, 0xFE, 0xE2, 0x03, 0x7F, 0xF5, 0xCC, 0x41, 0xC7, 0x19, 0xFF,
96 0xF4, 0x37, 0x06, 0x75, 0xFC, 0xD6, 0x01, 0x39, 0xFF, 0x35, 0x00,
97 0xFE, 0xFF, 0x1B, 0x00, 0x90, 0xFF, 0xF4, 0x00, 0x72, 0xFE, 0x18,
98 0x02, 0xAA, 0xFD, 0xAB, 0x01, 0xDF, 0x48, 0xCA, 0x05, 0xE1, 0xFB,
99 0x05, 0x03, 0xF7, 0xFD, 0x2E, 0x01, 0x79, 0xFF, 0x21, 0x00, 0x00,
100 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x43, 0xFF, 0xBB, 0x01, 0xBA, 0xFC,
101 0x95, 0x05, 0x83, 0xF6, 0x8C, 0x14, 0x87, 0x44, 0xBB, 0xF7, 0x98,
102 0x02, 0x5A, 0xFF, 0xEE, 0xFF, 0x3C, 0x00, 0xD8, 0xFF, 0x0A, 0x00,
103 0xFD, 0xFF, 0x32, 0x00, 0x44, 0xFF, 0xD3, 0x01, 0x3C, 0xFC, 0x2A,
104 0x07, 0xDC, 0xF1, 0x1A, 0x2A, 0x06, 0x36, 0xBE, 0xF1, 0x8E, 0x06,
105 0xD5, 0xFC, 0x67, 0x01, 0x7F, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x01,
106 0x00, 0x07, 0x00, 0xBE, 0xFF, 0xEA, 0x00, 0xA2, 0xFD, 0x65, 0x05,
107 0x28, 0xF3, 0xDB, 0x3C, 0x78, 0x21, 0x30, 0xF3, 0xDF, 0x06, 0x3A,
108 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x13, 0x00,
109 0xB2, 0xFF, 0x9D, 0x00, 0x27, 0xFF, 0xC3, 0x00, 0x1F, 0x00, 0x76,
110 0xFC, 0xA3, 0x47, 0x60, 0x0C, 0x4A, 0xF9, 0x4E, 0x04, 0x53, 0xFD,
111 0x79, 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B,
112 0x00, 0x58, 0xFF, 0x82, 0x01, 0x3F, 0xFD, 0x78, 0x04, 0xF2, 0xF8,
113 0x50, 0x0D, 0x5E, 0x47, 0xD5, 0xFB, 0x6F, 0x00, 0x96, 0x00, 0x40,
114 0xFF, 0x91, 0x00, 0xB7, 0xFF, 0x12, 0x00, 0xFD, 0xFF, 0x36, 0x00,
115 0x37, 0xFF, 0xE6, 0x01, 0x36, 0xFC, 0xEF, 0x06, 0xFC, 0xF2, 0x81,
116 0x22, 0x1C, 0x3C, 0xEC, 0xF2, 0x90, 0x05, 0x85, 0xFD, 0xFB, 0x00,
117 0xB6, 0xFF, 0x0A, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x85,
118 0xFF, 0x5B, 0x01, 0xE9, 0xFC, 0x73, 0x06, 0xD8, 0xF1, 0xE5, 0x36,
119 0x19, 0x29, 0xF8, 0xF1, 0x29, 0x07, 0x37, 0xFC, 0xD8, 0x01, 0x42,
120 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x0B, 0x00, 0xD3, 0xFF, 0x47, 0x00,
121 0xD7, 0xFF, 0x82, 0xFF, 0x53, 0x02, 0x39, 0xF8, 0xFD, 0x44, 0x8D,
122 0x13, 0xD3, 0xF6, 0x72, 0x05, 0xCA, 0xFC, 0xB5, 0x01, 0x45, 0xFF,
123 0x31, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x23, 0x00, 0x75, 0xFF, 0x39,
124 0x01, 0xE0, 0xFD, 0x33, 0x03, 0x87, 0xFB, 0xA2, 0x06, 0xCB, 0x48,
125 0xEA, 0x00, 0x01, 0xFE, 0xE9, 0x01, 0x8A, 0xFE, 0xE8, 0x00, 0x95,
126 0xFF, 0x1A, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x38, 0xFF, 0xDA, 0x01,
127 0x6A, 0xFC, 0x53, 0x06, 0xBA, 0xF4, 0xCE, 0x1A, 0x32, 0x41, 0x1F,
128 0xF5, 0x1D, 0x04, 0x71, 0xFE, 0x71, 0x00, 0xFB, 0xFF, 0xF0, 0xFF,
129 0x05, 0x00, 0xFD, 0xFF, 0x2B, 0x00, 0x5B, 0xFF, 0xAB, 0x01, 0x6F,
130 0xFC, 0x08, 0x07, 0x7E, 0xF1, 0x21, 0x30, 0x67, 0x30, 0x7D, 0xF1,
131 0x05, 0x07, 0x73, 0xFC, 0xA8, 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0xFD,
132 0xFF, 0x05, 0x00, 0xF2, 0xFF, 0xF8, 0xFF, 0x77, 0x00, 0x67, 0xFE,
133 0x2D, 0x04, 0x04, 0xF5, 0x07, 0x41, 0x1B, 0x1B, 0xA6, 0xF4, 0x5A,
134 0x06, 0x67, 0xFC, 0xDB, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF,
135 0x1A, 0x00, 0x96, 0xFF, 0xE5, 0x00, 0x91, 0xFE, 0xDC, 0x01, 0x1A,
136 0xFE, 0xB3, 0x00, 0xC3, 0x48, 0xE1, 0x06, 0x6E, 0xFB, 0x40, 0x03,
137 0xDA, 0xFD, 0x3C, 0x01, 0x74, 0xFF, 0x23, 0x00, 0x00, 0x00, 0xFF,
138 0xFF, 0x31, 0x00, 0x46, 0xFF, 0xB3, 0x01, 0xCF, 0xFC, 0x67, 0x05,
139 0xEA, 0xF6, 0x44, 0x13, 0x1E, 0x45, 0x5E, 0xF8, 0x3F, 0x02, 0x8E,
140 0xFF, 0xD0, 0xFF, 0x4A, 0x00, 0xD2, 0xFF, 0x0B, 0x00, 0xFD, 0xFF,
141 0x33, 0x00, 0x41, 0xFF, 0xD9, 0x01, 0x36, 0xFC, 0x28, 0x07, 0x01,
142 0xF2, 0xCE, 0x28, 0x23, 0x37, 0xE0, 0xF1, 0x6B, 0x06, 0xEF, 0xFC,
143 0x57, 0x01, 0x87, 0xFF, 0x1B, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x0B,
144 0x00, 0xB4, 0xFF, 0x00, 0x01, 0x7E, 0xFD, 0x9C, 0x05, 0xDC, 0xF2,
145 0xE4, 0x3B, 0xCD, 0x22, 0xEE, 0xF2, 0xF3, 0x06, 0x35, 0xFC, 0xE6,
146 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x11, 0x00, 0xB8, 0xFF,
147 0x8E, 0x00, 0x46, 0xFF, 0x8A, 0x00, 0x86, 0x00, 0xA7, 0xFB, 0x48,
148 0x47, 0x95, 0x0D, 0xD9, 0xF8, 0x84, 0x04, 0x39, 0xFD, 0x85, 0x01,
149 0x57, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5D,
150 0xFF, 0x76, 0x01, 0x59, 0xFD, 0x42, 0x04, 0x63, 0xF9, 0x1C, 0x0C,
151 0xB6, 0x47, 0xA4, 0xFC, 0x07, 0x00, 0xD0, 0x00, 0x20, 0xFF, 0xA0,
152 0x00, 0xB1, 0xFF, 0x13, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF,
153 0xE6, 0x01, 0x3B, 0xFC, 0xDA, 0x06, 0x3F, 0xF3, 0x2C, 0x21, 0x11,
154 0x3D, 0x3A, 0xF3, 0x58, 0x05, 0xAA, 0xFD, 0xE5, 0x00, 0xC1, 0xFF,
155 0x06, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1F, 0x00, 0x7D, 0xFF, 0x6B,
156 0x01, 0xCF, 0xFC, 0x96, 0x06, 0xB7, 0xF1, 0xC6, 0x35, 0x64, 0x2A,
157 0xD4, 0xF1, 0x2B, 0x07, 0x3D, 0xFC, 0xD2, 0x01, 0x45, 0xFF, 0x32,
158 0x00, 0xFD, 0xFF, 0x0A, 0x00, 0xD9, 0xFF, 0x39, 0x00, 0xF4, 0xFF,
159 0x4E, 0xFF, 0xAC, 0x02, 0x98, 0xF7, 0x65, 0x44, 0xD6, 0x14, 0x6C,
160 0xF6, 0x9F, 0x05, 0xB6, 0xFC, 0xBD, 0x01, 0x42, 0xFF, 0x32, 0x00,
161 0xFF, 0xFF, 0x00, 0x00, 0x21, 0x00, 0x7A, 0xFF, 0x2B, 0x01, 0xFE,
162 0xFD, 0xF8, 0x02, 0xFB, 0xFB, 0x8D, 0x05, 0xE5, 0x48, 0xE3, 0x01,
163 0x91, 0xFD, 0x25, 0x02, 0x6B, 0xFE, 0xF7, 0x00, 0x8F, 0xFF, 0x1C,
164 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD5, 0x01, 0x78, 0xFC,
165 0x2F, 0x06, 0x13, 0xF5, 0x7C, 0x19, 0xF7, 0x41, 0x9B, 0xF5, 0xD1,
166 0x03, 0x9F, 0xFE, 0x57, 0x00, 0x08, 0x00, 0xEC, 0xFF, 0x06, 0x00,
167 0xFD, 0xFF, 0x2D, 0x00, 0x55, 0xFF, 0xB5, 0x01, 0x61, 0xFC, 0x16,
168 0x07, 0x85, 0xF1, 0xE6, 0x2E, 0x9E, 0x31, 0x7D, 0xF1, 0xF3, 0x06,
169 0x84, 0xFC, 0x9D, 0x01, 0x63, 0xFF, 0x28, 0x00, 0xFD, 0xFF, 0x04,
170 0x00, 0xF6, 0xFF, 0xEB, 0xFF, 0x91, 0x00, 0x3B, 0xFE, 0x75, 0x04,
171 0x92, 0xF4, 0x36, 0x40, 0x6E, 0x1C, 0x50, 0xF4, 0x7B, 0x06, 0x5B,
172 0xFC, 0xDF, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x18, 0x00,
173 0x9C, 0xFF, 0xD6, 0x00, 0xB1, 0xFE, 0xA1, 0x01, 0x89, 0xFE, 0xC3,
174 0xFF, 0x9C, 0x48, 0xFD, 0x07, 0xFA, 0xFA, 0x7A, 0x03, 0xBC, 0xFD,
175 0x49, 0x01, 0x6E, 0xFF, 0x24, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30,
176 0x00, 0x49, 0xFF, 0xAA, 0x01, 0xE4, 0xFC, 0x38, 0x05, 0x54, 0xF7,
177 0xFE, 0x11, 0xAA, 0x45, 0x09, 0xF9, 0xE2, 0x01, 0xC4, 0xFF, 0xB3,
178 0xFF, 0x59, 0x00, 0xCD, 0xFF, 0x0D, 0x00, 0xFD, 0xFF, 0x34, 0x00,
179 0x3E, 0xFF, 0xDE, 0x01, 0x33, 0xFC, 0x22, 0x07, 0x2B, 0xF2, 0x80,
180 0x27, 0x3B, 0x38, 0x0A, 0xF2, 0x44, 0x06, 0x0B, 0xFD, 0x45, 0x01,
181 0x90, 0xFF, 0x18, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0F, 0x00, 0xA9,
182 0xFF, 0x15, 0x01, 0x5B, 0xFD, 0xD0, 0x05, 0x97, 0xF2, 0xE6, 0x3A,
183 0x21, 0x24, 0xB1, 0xF2, 0x04, 0x07, 0x33, 0xFC, 0xE5, 0x01, 0x39,
184 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x10, 0x00, 0xBE, 0xFF, 0x7F, 0x00,
185 0x65, 0xFF, 0x51, 0x00, 0xEB, 0x00, 0xE1, 0xFA, 0xE1, 0x46, 0xCD,
186 0x0E, 0x6A, 0xF8, 0xB8, 0x04, 0x20, 0xFD, 0x90, 0x01, 0x53, 0xFF,
187 0x2D, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x28, 0x00, 0x62, 0xFF, 0x6A,
188 0x01, 0x74, 0xFD, 0x0A, 0x04, 0xD5, 0xF9, 0xED, 0x0A, 0x03, 0x48,
189 0x7C, 0xFD, 0x9E, 0xFF, 0x0A, 0x01, 0x01, 0xFF, 0xAF, 0x00, 0xAB,
190 0xFF, 0x14, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE5, 0x01,
191 0x42, 0xFC, 0xC3, 0x06, 0x87, 0xF3, 0xD7, 0x1F, 0xFE, 0x3D, 0x91,
192 0xF3, 0x1D, 0x05, 0xD1, 0xFD, 0xCE, 0x00, 0xCC, 0xFF, 0x02, 0x00,
193 0x02, 0x00, 0xFE, 0xFF, 0x22, 0x00, 0x75, 0xFF, 0x7A, 0x01, 0xB8,
194 0xFC, 0xB4, 0x06, 0x9E, 0xF1, 0xA2, 0x34, 0xAD, 0x2B, 0xB6, 0xF1,
195 0x29, 0x07, 0x45, 0xFC, 0xCB, 0x01, 0x49, 0xFF, 0x31, 0x00, 0xFD,
196 0xFF, 0x09, 0x00, 0xDE, 0xFF, 0x2B, 0x00, 0x11, 0x00, 0x1B, 0xFF,
197 0x02, 0x03, 0xFE, 0xF6, 0xC3, 0x43, 0x22, 0x16, 0x07, 0xF6, 0xCA,
198 0x05, 0xA3, 0xFC, 0xC5, 0x01, 0x3F, 0xFF, 0x33, 0x00, 0xFF, 0xFF,
199 0x00, 0x00, 0x20, 0x00, 0x80, 0xFF, 0x1C, 0x01, 0x1C, 0xFE, 0xBD,
200 0x02, 0x6E, 0xFC, 0x7D, 0x04, 0xF3, 0x48, 0xE2, 0x02, 0x1F, 0xFD,
201 0x60, 0x02, 0x4C, 0xFE, 0x06, 0x01, 0x89, 0xFF, 0x1D, 0x00, 0xFE,
202 0xFF, 0x34, 0x00, 0x3C, 0xFF, 0xCF, 0x01, 0x88, 0xFC, 0x09, 0x06,
203 0x71, 0xF5, 0x2B, 0x18, 0xB2, 0x42, 0x20, 0xF6, 0x83, 0x03, 0xCF,
204 0xFE, 0x3C, 0x00, 0x15, 0x00, 0xE6, 0xFF, 0x07, 0x00, 0xFD, 0xFF,
205 0x2E, 0x00, 0x50, 0xFF, 0xBF, 0x01, 0x54, 0xFC, 0x20, 0x07, 0x94,
206 0xF1, 0xA6, 0x2D, 0xD0, 0x32, 0x85, 0xF1, 0xDD, 0x06, 0x96, 0xFC,
207 0x90, 0x01, 0x69, 0xFF, 0x26, 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFB,
208 0xFF, 0xDF, 0xFF, 0xA9, 0x00, 0x10, 0xFE, 0xB9, 0x04, 0x27, 0xF4,
209 0x5E, 0x3F, 0xC3, 0x1D, 0xFE, 0xF3, 0x99, 0x06, 0x50, 0xFC, 0xE2,
210 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x17, 0x00, 0xA2, 0xFF,
211 0xC7, 0x00, 0xD0, 0xFE, 0x65, 0x01, 0xF6, 0xFE, 0xD9, 0xFE, 0x6A,
212 0x48, 0x1F, 0x09, 0x87, 0xFA, 0xB3, 0x03, 0xA0, 0xFD, 0x56, 0x01,
213 0x69, 0xFF, 0x26, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4D,
214 0xFF, 0xA0, 0x01, 0xFB, 0xFC, 0x07, 0x05, 0xBF, 0xF7, 0xBB, 0x10,
215 0x2B, 0x46, 0xBB, 0xF9, 0x83, 0x01, 0xFA, 0xFF, 0x95, 0xFF, 0x68,
216 0x00, 0xC7, 0xFF, 0x0E, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3C, 0xFF,
217 0xE1, 0x01, 0x31, 0xFC, 0x19, 0x07, 0x5B, 0xF2, 0x30, 0x26, 0x4B,
218 0x39, 0x3B, 0xF2, 0x1A, 0x06, 0x29, 0xFD, 0x33, 0x01, 0x99, 0xFF,
219 0x15, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x13, 0x00, 0x9F, 0xFF, 0x28,
220 0x01, 0x3A, 0xFD, 0x00, 0x06, 0x5A, 0xF2, 0xDF, 0x39, 0x73, 0x25,
221 0x79, 0xF2, 0x12, 0x07, 0x31, 0xFC, 0xE3, 0x01, 0x3B, 0xFF, 0x35,
222 0x00, 0xFD, 0xFF, 0x0F, 0x00, 0xC4, 0xFF, 0x70, 0x00, 0x84, 0xFF,
223 0x19, 0x00, 0x4D, 0x01, 0x22, 0xFA, 0x70, 0x46, 0x0A, 0x10, 0xFC,
224 0xF7, 0xEB, 0x04, 0x08, 0xFD, 0x9A, 0x01, 0x4F, 0xFF, 0x2E, 0x00,
225 0xFF, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x66, 0xFF, 0x5E, 0x01, 0x90,
226 0xFD, 0xD2, 0x03, 0x47, 0xFA, 0xC3, 0x09, 0x48, 0x48, 0x5A, 0xFE,
227 0x33, 0xFF, 0x45, 0x01, 0xE2, 0xFE, 0xBE, 0x00, 0xA5, 0xFF, 0x16,
228 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE3, 0x01, 0x4B, 0xFC,
229 0xA9, 0x06, 0xD2, 0xF3, 0x81, 0x1E, 0xE4, 0x3E, 0xEF, 0xF3, 0xDE,
230 0x04, 0xF9, 0xFD, 0xB7, 0x00, 0xD8, 0xFF, 0xFD, 0xFF, 0x03, 0x00,
231 0xFD, 0xFF, 0x24, 0x00, 0x6D, 0xFF, 0x88, 0x01, 0xA2, 0xFC, 0xD0,
232 0x06, 0x8C, 0xF1, 0x78, 0x33, 0xF2, 0x2C, 0x9E, 0xF1, 0x24, 0x07,
233 0x4E, 0xFC, 0xC3, 0x01, 0x4E, 0xFF, 0x2F, 0x00, 0xFD, 0xFF, 0x08,
234 0x00, 0xE4, 0xFF, 0x1D, 0x00, 0x2D, 0x00, 0xEA, 0xFE, 0x56, 0x03,
235 0x6D, 0xF6, 0x17, 0x43, 0x70, 0x17, 0xA6, 0xF5, 0xF3, 0x05, 0x91,
236 0xFC, 0xCC, 0x01, 0x3D, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x1E, 0x00,
237 0x86, 0xFF, 0x0E, 0x01, 0x3B, 0xFE, 0x82, 0x02, 0xE0, 0xFC, 0x73,
238 0x03, 0xF6, 0x48, 0xE9, 0x03, 0xAD, 0xFC, 0x9C, 0x02, 0x2D, 0xFE,
239 0x14, 0x01, 0x83, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33,
240 0x00, 0x3E, 0xFF, 0xC9, 0x01, 0x99, 0xFC, 0xE1, 0x05, 0xD1, 0xF5,
241 0xDC, 0x16, 0x65, 0x43, 0xAD, 0xF6, 0x31, 0x03, 0x00, 0xFF, 0x20,
242 0x00, 0x23, 0x00, 0xE1, 0xFF, 0x08, 0x00, 0xFD, 0xFF, 0x30, 0x00,
243 0x4C, 0xFF, 0xC7, 0x01, 0x4A, 0xFC, 0x27, 0x07, 0xA8, 0xF1, 0x62,
244 0x2C, 0xFD, 0x33, 0x93, 0xF1, 0xC4, 0x06, 0xAB, 0xFC, 0x82, 0x01,
245 0x71, 0xFF, 0x23, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0xD3,
246 0xFF, 0xC1, 0x00, 0xE7, 0xFD, 0xFA, 0x04, 0xC4, 0xF3, 0x7E, 0x3E,
247 0x19, 0x1F, 0xB0, 0xF3, 0xB5, 0x06, 0x47, 0xFC, 0xE4, 0x01, 0x36,
248 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x15, 0x00, 0xA8, 0xFF, 0xB8, 0x00,
249 0xF0, 0xFE, 0x2B, 0x01, 0x63, 0xFF, 0xF6, 0xFD, 0x2C, 0x48, 0x47,
250 0x0A, 0x14, 0xFA, 0xEB, 0x03, 0x84, 0xFD, 0x63, 0x01, 0x64, 0xFF,
251 0x27, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2D, 0x00, 0x51, 0xFF, 0x96,
252 0x01, 0x13, 0xFD, 0xD5, 0x04, 0x2C, 0xF8, 0x7D, 0x0F, 0xA3, 0x46,
253 0x76, 0xFA, 0x22, 0x01, 0x32, 0x00, 0x76, 0xFF, 0x76, 0x00, 0xC1,
254 0xFF, 0x0F, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x3A, 0xFF, 0xE4, 0x01,
255 0x32, 0xFC, 0x0C, 0x07, 0x91, 0xF2, 0xDD, 0x24, 0x54, 0x3A, 0x74,
256 0xF2, 0xEB, 0x05, 0x49, 0xFD, 0x20, 0x01, 0xA3, 0xFF, 0x11, 0x00,
257 0x00, 0x00, 0xFF, 0xFF, 0x16, 0x00, 0x95, 0xFF, 0x3B, 0x01, 0x1B,
258 0xFD, 0x2D, 0x06, 0x24, 0xF2, 0xD3, 0x38, 0xC6, 0x26, 0x45, 0xF2,
259 0x1D, 0x07, 0x32, 0xFC, 0xE0, 0x01, 0x3D, 0xFF, 0x35, 0x00, 0xFD,
260 0xFF, 0x0D, 0x00, 0xC9, 0xFF, 0x61, 0x00, 0xA2, 0xFF, 0xE2, 0xFF,
261 0xAE, 0x01, 0x6B, 0xF9, 0xF2, 0x45, 0x4A, 0x11, 0x8F, 0xF7, 0x1D,
262 0x05, 0xF1, 0xFC, 0xA4, 0x01, 0x4B, 0xFF, 0x2F, 0x00, 0xFF, 0xFF,
263 0x00, 0x00, 0x25, 0x00, 0x6C, 0xFF, 0x51, 0x01, 0xAC, 0xFD, 0x9A,
264 0x03, 0xBA, 0xFA, 0x9E, 0x08, 0x81, 0x48, 0x40, 0xFF, 0xC6, 0xFE,
265 0x80, 0x01, 0xC2, 0xFE, 0xCE, 0x00, 0x9F, 0xFF, 0x17, 0x00, 0xFE,
266 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE1, 0x01, 0x55, 0xFC, 0x8C, 0x06,
267 0x22, 0xF4, 0x2C, 0x1D, 0xC0, 0x3F, 0x55, 0xF4, 0x9B, 0x04, 0x23,
268 0xFE, 0x9F, 0x00, 0xE4, 0xFF, 0xF9, 0xFF, 0x04, 0x00, 0xFD, 0xFF,
269 0x27, 0x00, 0x66, 0xFF, 0x96, 0x01, 0x8E, 0xFC, 0xE7, 0x06, 0x81,
270 0xF1, 0x48, 0x32, 0x34, 0x2E, 0x8D, 0xF1, 0x1C, 0x07, 0x5A, 0xFC,
271 0xBB, 0x01, 0x53, 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE9,
272 0xFF, 0x0F, 0x00, 0x48, 0x00, 0xB9, 0xFE, 0xA6, 0x03, 0xE4, 0xF5,
273 0x60, 0x42, 0xC1, 0x18, 0x47, 0xF5, 0x1A, 0x06, 0x81, 0xFC, 0xD2,
274 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x8B, 0xFF,
275 0xFF, 0x00, 0x5A, 0xFE, 0x46, 0x02, 0x52, 0xFD, 0x70, 0x02, 0xED,
276 0x48, 0xF5, 0x04, 0x3B, 0xFC, 0xD7, 0x02, 0x0F, 0xFE, 0x23, 0x01,
277 0x7E, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x40,
278 0xFF, 0xC1, 0x01, 0xAB, 0xFC, 0xB7, 0x05, 0x34, 0xF6, 0x8E, 0x15,
279 0x0B, 0x44, 0x42, 0xF7, 0xDC, 0x02, 0x32, 0xFF, 0x04, 0x00, 0x31,
280 0x00, 0xDC, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x31, 0x00, 0x47, 0xFF,
281 0xCE, 0x01, 0x41, 0xFC, 0x2A, 0x07, 0xC2, 0xF1, 0x1B, 0x2B, 0x25,
282 0x35, 0xA8, 0xF1, 0xA7, 0x06, 0xC2, 0xFC, 0x74, 0x01, 0x78, 0xFF,
283 0x20, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x04, 0x00, 0xC7, 0xFF, 0xD9,
284 0x00, 0xBF, 0xFD, 0x38, 0x05, 0x69, 0xF3, 0x96, 0x3D, 0x6F, 0x20,
285 0x66, 0xF3, 0xCE, 0x06, 0x3F, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36,
286 0x00, 0xFD, 0xFF, 0x14, 0x00, 0xAE, 0xFF, 0xA9, 0x00, 0x0F, 0xFF,
287 0xF0, 0x00, 0xCD, 0xFF, 0x1B, 0xFD, 0xE4, 0x47, 0x73, 0x0B, 0xA2,
288 0xF9, 0x23, 0x04, 0x68, 0xFD, 0x70, 0x01, 0x5F, 0xFF, 0x29, 0x00,
289 0x00, 0x00, 0xFF, 0xFF, 0x2C, 0x00, 0x55, 0xFF, 0x8B, 0x01, 0x2B,
290 0xFD, 0xA1, 0x04, 0x9B, 0xF8, 0x42, 0x0E, 0x0F, 0x47, 0x38, 0xFB,
291 0xBE, 0x00, 0x6A, 0x00, 0x58, 0xFF, 0x85, 0x00, 0xBB, 0xFF, 0x10,
292 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE6, 0x01, 0x34, 0xFC,
293 0xFD, 0x06, 0xCB, 0xF2, 0x8A, 0x23, 0x58, 0x3B, 0xB4, 0xF2, 0xBA,
294 0x05, 0x6A, 0xFD, 0x0B, 0x01, 0xAE, 0xFF, 0x0D, 0x00, 0x00, 0x00,
295 0xFF, 0xFF, 0x19, 0x00, 0x8C, 0xFF, 0x4D, 0x01, 0xFE, 0xFC, 0x56,
296 0x06, 0xF7, 0xF1, 0xBF, 0x37, 0x15, 0x28, 0x18, 0xF2, 0x25, 0x07,
297 0x34, 0xFC, 0xDC, 0x01, 0x3F, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0C,
298 0x00, 0xCF, 0xFF, 0x52, 0x00, 0xC0, 0xFF, 0xAC, 0xFF, 0x0C, 0x02,
299 0xBC, 0xF8, 0x6D, 0x45, 0x8E, 0x12, 0x24, 0xF7, 0x4D, 0x05, 0xDB,
300 0xFC, 0xAE, 0x01, 0x48, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00,
301 0x24, 0x00, 0x71, 0xFF, 0x43, 0x01, 0xC9, 0xFD, 0x60, 0x03, 0x2E,
302 0xFB, 0x7E, 0x07, 0xAF, 0x48, 0x2D, 0x00, 0x58, 0xFE, 0xBB, 0x01,
303 0xA3, 0xFE, 0xDD, 0x00, 0x99, 0xFF, 0x19, 0x00, 0xFE, 0xFF, 0x36,
304 0x00, 0x37, 0xFF, 0xDD, 0x01, 0x60, 0xFC, 0x6D, 0x06, 0x76, 0xF4,
305 0xD8, 0x1B, 0x95, 0x40, 0xC3, 0xF4, 0x56, 0x04, 0x4E, 0xFE, 0x85,
306 0x00, 0xF1, 0xFF, 0xF4, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x29, 0x00,
307 0x60, 0xFF, 0xA2, 0x01, 0x7C, 0xFC, 0xFB, 0x06, 0x7C, 0xF1, 0x15,
308 0x31, 0x73, 0x2F, 0x81, 0xF1, 0x10, 0x07, 0x67, 0xFC, 0xB1, 0x01,
309 0x58, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0x06, 0x00, 0xEE, 0xFF, 0x02,
310 0x00, 0x63, 0x00, 0x8A, 0xFE, 0xF3, 0x03, 0x63, 0xF5, 0xA1, 0x41,
311 0x12, 0x1A, 0xEB, 0xF4, 0x3F, 0x06, 0x72, 0xFC, 0xD7, 0x01, 0x39,
312 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x91, 0xFF, 0xF1, 0x00,
313 0x79, 0xFE, 0x0A, 0x02, 0xC3, 0xFD, 0x73, 0x01, 0xDB, 0x48, 0x07,
314 0x06, 0xC7, 0xFB, 0x12, 0x03, 0xF1, 0xFD, 0x31, 0x01, 0x78, 0xFF,
315 0x22, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x43, 0xFF, 0xBA,
316 0x01, 0xBF, 0xFC, 0x8B, 0x05, 0x99, 0xF6, 0x43, 0x14, 0xA9, 0x44,
317 0xDE, 0xF7, 0x85, 0x02, 0x65, 0xFF, 0xE7, 0xFF, 0x3F, 0x00, 0xD6,
318 0xFF, 0x0A, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x44, 0xFF, 0xD5, 0x01,
319 0x3A, 0xFC, 0x2A, 0x07, 0xE3, 0xF1, 0xD1, 0x29, 0x46, 0x36, 0xC5,
320 0xF1, 0x87, 0x06, 0xDA, 0xFC, 0x64, 0x01, 0x80, 0xFF, 0x1E, 0x00,
321 0xFE, 0xFF, 0x01, 0x00, 0x08, 0x00, 0xBC, 0xFF, 0xEF, 0x00, 0x9A,
322 0xFD, 0x72, 0x05, 0x16, 0xF3, 0xA5, 0x3C, 0xC4, 0x21, 0x21, 0xF3,
323 0xE4, 0x06, 0x39, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD,
324 0xFF, 0x12, 0x00, 0xB3, 0xFF, 0x99, 0x00, 0x2E, 0xFF, 0xB6, 0x00,
325 0x36, 0x00, 0x47, 0xFC, 0x90, 0x47, 0xA4, 0x0C, 0x31, 0xF9, 0x5A,
326 0x04, 0x4E, 0xFD, 0x7C, 0x01, 0x5B, 0xFF, 0x2A, 0x00, 0x00, 0x00,
327 0x00, 0x00, 0x2B, 0x00, 0x59, 0xFF, 0x80, 0x01, 0x45, 0xFD, 0x6C,
328 0x04, 0x0B, 0xF9, 0x0B, 0x0D, 0x73, 0x47, 0x02, 0xFC, 0x58, 0x00,
329 0xA3, 0x00, 0x39, 0xFF, 0x94, 0x00, 0xB5, 0xFF, 0x12, 0x00, 0xFD,
330 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x37, 0xFC, 0xEB, 0x06,
331 0x0B, 0xF3, 0x35, 0x22, 0x52, 0x3C, 0xFD, 0xF2, 0x84, 0x05, 0x8D,
332 0xFD, 0xF6, 0x00, 0xB8, 0xFF, 0x09, 0x00, 0x01, 0x00, 0xFE, 0xFF,
333 0x1D, 0x00, 0x83, 0xFF, 0x5E, 0x01, 0xE3, 0xFC, 0x7B, 0x06, 0xD0,
334 0xF1, 0xA5, 0x36, 0x62, 0x29, 0xEF, 0xF1, 0x29, 0x07, 0x39, 0xFC,
335 0xD7, 0x01, 0x42, 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x0B, 0x00, 0xD5,
336 0xFF, 0x44, 0x00, 0xDD, 0xFF, 0x77, 0xFF, 0x67, 0x02, 0x14, 0xF8,
337 0xDC, 0x44, 0xD5, 0x13, 0xBC, 0xF6, 0x7C, 0x05, 0xC5, 0xFC, 0xB7,
338 0x01, 0x44, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x22, 0x00,
339 0x76, 0xFF, 0x35, 0x01, 0xE7, 0xFD, 0x26, 0x03, 0xA1, 0xFB, 0x64,
340 0x06, 0xD2, 0x48, 0x21, 0x01, 0xE8, 0xFD, 0xF7, 0x01, 0x83, 0xFE,
341 0xEC, 0x00, 0x93, 0xFF, 0x1A, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x39,
342 0xFF, 0xD9, 0x01, 0x6D, 0xFC, 0x4B, 0x06, 0xCD, 0xF4, 0x83, 0x1A,
343 0x5F, 0x41, 0x3A, 0xF5, 0x0C, 0x04, 0x7B, 0xFE, 0x6C, 0x00, 0xFE,
344 0xFF, 0xEF, 0xFF, 0x05, 0x00, 0xFD, 0xFF, 0x2B, 0x00, 0x5A, 0xFF,
345 0xAD, 0x01, 0x6C, 0xFC, 0x0C, 0x07, 0x7F, 0xF1, 0xDC, 0x2F, 0xAD,
346 0x30, 0x7D, 0xF1, 0x01, 0x07, 0x76, 0xFC, 0xA6, 0x01, 0x5E, 0xFF,
347 0x2A, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xF3, 0xFF, 0xF5, 0xFF, 0x7D,
348 0x00, 0x5D, 0xFE, 0x3E, 0x04, 0xEA, 0xF4, 0xD9, 0x40, 0x66, 0x1B,
349 0x93, 0xF4, 0x62, 0x06, 0x64, 0xFC, 0xDC, 0x01, 0x38, 0xFF, 0x36,
350 0x00, 0xFE, 0xFF, 0x19, 0x00, 0x97, 0xFF, 0xE2, 0x00, 0x98, 0xFE,
351 0xCF, 0x01, 0x33, 0xFE, 0x7D, 0x00, 0xBB, 0x48, 0x1F, 0x07, 0x54,
352 0xFB, 0x4C, 0x03, 0xD3, 0xFD, 0x3F, 0x01, 0x73, 0xFF, 0x23, 0x00,
353 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x46, 0xFF, 0xB1, 0x01, 0xD3,
354 0xFC, 0x5D, 0x05, 0x01, 0xF7, 0xFB, 0x12, 0x3F, 0x45, 0x83, 0xF8,
355 0x2A, 0x02, 0x9A, 0xFF, 0xCA, 0xFF, 0x4E, 0x00, 0xD1, 0xFF, 0x0C,
356 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x40, 0xFF, 0xDA, 0x01, 0x35, 0xFC,
357 0x27, 0x07, 0x09, 0xF2, 0x85, 0x28, 0x63, 0x37, 0xE9, 0xF1, 0x63,
358 0x06, 0xF5, 0xFC, 0x53, 0x01, 0x89, 0xFF, 0x1A, 0x00, 0xFE, 0xFF,
359 0x00, 0x00, 0x0C, 0x00, 0xB1, 0xFF, 0x04, 0x01, 0x76, 0xFD, 0xA8,
360 0x05, 0xCC, 0xF2, 0xAB, 0x3B, 0x18, 0x23, 0xE0, 0xF2, 0xF7, 0x06,
361 0x35, 0xFC, 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x11,
362 0x00, 0xB9, 0xFF, 0x8A, 0x00, 0x4D, 0xFF, 0x7D, 0x00, 0x9C, 0x00,
363 0x7B, 0xFB, 0x31, 0x47, 0xD9, 0x0D, 0xC0, 0xF8, 0x8F, 0x04, 0x34,
364 0xFD, 0x87, 0x01, 0x56, 0xFF, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00,
365 0x29, 0x00, 0x5E, 0xFF, 0x74, 0x01, 0x5F, 0xFD, 0x35, 0x04, 0x7C,
366 0xF9, 0xD8, 0x0B, 0xC9, 0x47, 0xD4, 0xFC, 0xF0, 0xFF, 0xDD, 0x00,
367 0x19, 0xFF, 0xA4, 0x00, 0xAF, 0xFF, 0x13, 0x00, 0xFD, 0xFF, 0x36,
368 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3D, 0xFC, 0xD5, 0x06, 0x4F, 0xF3,
369 0xE0, 0x20, 0x45, 0x3D, 0x4D, 0xF3, 0x4B, 0x05, 0xB3, 0xFD, 0xE0,
370 0x00, 0xC3, 0xFF, 0x05, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x20, 0x00,
371 0x7B, 0xFF, 0x6E, 0x01, 0xCA, 0xFC, 0x9D, 0x06, 0xB1, 0xF1, 0x86,
372 0x35, 0xAE, 0x2A, 0xCD, 0xF1, 0x2B, 0x07, 0x3F, 0xFC, 0xD1, 0x01,
373 0x46, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x0A, 0x00, 0xDA, 0xFF, 0x36,
374 0x00, 0xFA, 0xFF, 0x43, 0xFF, 0xBF, 0x02, 0x75, 0xF7, 0x42, 0x44,
375 0x20, 0x15, 0x55, 0xF6, 0xA9, 0x05, 0xB2, 0xFC, 0xBF, 0x01, 0x41,
376 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x21, 0x00, 0x7C, 0xFF,
377 0x27, 0x01, 0x05, 0xFE, 0xEB, 0x02, 0x14, 0xFC, 0x50, 0x05, 0xEA,
378 0x48, 0x1B, 0x02, 0x78, 0xFD, 0x32, 0x02, 0x64, 0xFE, 0xFA, 0x00,
379 0x8D, 0xFF, 0x1C, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD4,
380 0x01, 0x7C, 0xFC, 0x27, 0x06, 0x28, 0xF5, 0x31, 0x19, 0x21, 0x42,
381 0xB8, 0xF5, 0xC0, 0x03, 0xAA, 0xFE, 0x51, 0x00, 0x0B, 0x00, 0xEA,
382 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2D, 0x00, 0x54, 0xFF, 0xB7, 0x01,
383 0x5E, 0xFC, 0x19, 0x07, 0x88, 0xF1, 0x9F, 0x2E, 0xE3, 0x31, 0x7E,
384 0xF1, 0xEE, 0x06, 0x88, 0xFC, 0x9A, 0x01, 0x64, 0xFF, 0x28, 0x00,
385 0xFD, 0xFF, 0x04, 0x00, 0xF7, 0xFF, 0xE8, 0xFF, 0x96, 0x00, 0x31,
386 0xFE, 0x84, 0x04, 0x79, 0xF4, 0x07, 0x40, 0xBA, 0x1C, 0x3E, 0xF4,
387 0x82, 0x06, 0x58, 0xFC, 0xE0, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE,
388 0xFF, 0x18, 0x00, 0x9D, 0xFF, 0xD3, 0x00, 0xB8, 0xFE, 0x93, 0x01,
389 0xA1, 0xFE, 0x8E, 0xFF, 0x92, 0x48, 0x3D, 0x08, 0xE1, 0xFA, 0x86,
390 0x03, 0xB6, 0xFD, 0x4C, 0x01, 0x6D, 0xFF, 0x25, 0x00, 0x00, 0x00,
391 0xFF, 0xFF, 0x30, 0x00, 0x4A, 0xFF, 0xA8, 0x01, 0xE9, 0xFC, 0x2D,
392 0x05, 0x6B, 0xF7, 0xB6, 0x11, 0xC8, 0x45, 0x30, 0xF9, 0xCD, 0x01,
393 0xD0, 0xFF, 0xAC, 0xFF, 0x5C, 0x00, 0xCB, 0xFF, 0x0D, 0x00, 0xFD,
394 0xFF, 0x34, 0x00, 0x3E, 0xFF, 0xDF, 0x01, 0x33, 0xFC, 0x20, 0x07,
395 0x35, 0xF2, 0x36, 0x27, 0x78, 0x38, 0x14, 0xF2, 0x3B, 0x06, 0x11,
396 0xFD, 0x41, 0x01, 0x92, 0xFF, 0x17, 0x00, 0xFF, 0xFF, 0x00, 0x00,
397 0x10, 0x00, 0xA7, 0xFF, 0x19, 0x01, 0x53, 0xFD, 0xDB, 0x05, 0x88,
398 0xF2, 0xAD, 0x3A, 0x6D, 0x24, 0xA4, 0xF2, 0x08, 0x07, 0x32, 0xFC,
399 0xE5, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x10, 0x00, 0xBF,
400 0xFF, 0x7B, 0x00, 0x6C, 0xFF, 0x44, 0x00, 0x01, 0x01, 0xB6, 0xFA,
401 0xC8, 0x46, 0x13, 0x0F, 0x51, 0xF8, 0xC4, 0x04, 0x1B, 0xFD, 0x92,
402 0x01, 0x52, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x28, 0x00,
403 0x63, 0xFF, 0x67, 0x01, 0x7A, 0xFD, 0xFE, 0x03, 0xEE, 0xF9, 0xAA,
404 0x0A, 0x16, 0x48, 0xAC, 0xFD, 0x86, 0xFF, 0x17, 0x01, 0xFA, 0xFE,
405 0xB3, 0x00, 0xAA, 0xFF, 0x15, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36,
406 0xFF, 0xE5, 0x01, 0x44, 0xFC, 0xBD, 0x06, 0x97, 0xF3, 0x8A, 0x1F,
407 0x31, 0x3E, 0xA5, 0xF3, 0x0F, 0x05, 0xDA, 0xFD, 0xC9, 0x00, 0xCF,
408 0xFF, 0x01, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x22, 0x00, 0x73, 0xFF,
409 0x7D, 0x01, 0xB3, 0xFC, 0xBB, 0x06, 0x9A, 0xF1, 0x60, 0x34, 0xF5,
410 0x2B, 0xB0, 0xF1, 0x28, 0x07, 0x47, 0xFC, 0xCA, 0x01, 0x4A, 0xFF,
411 0x30, 0x00, 0xFD, 0xFF, 0x09, 0x00, 0xDF, 0xFF, 0x28, 0x00, 0x17,
412 0x00, 0x10, 0xFF, 0x15, 0x03, 0xDD, 0xF6, 0x9E, 0x43, 0x6C, 0x16,
413 0xF1, 0xF5, 0xD3, 0x05, 0x9F, 0xFC, 0xC6, 0x01, 0x3F, 0xFF, 0x33,
414 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x81, 0xFF, 0x19, 0x01,
415 0x23, 0xFE, 0xB0, 0x02, 0x87, 0xFC, 0x41, 0x04, 0xF4, 0x48, 0x1C,
416 0x03, 0x06, 0xFD, 0x6E, 0x02, 0x45, 0xFE, 0x09, 0x01, 0x88, 0xFF,
417 0x1D, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3C, 0xFF, 0xCE, 0x01, 0x8C,
418 0xFC, 0x00, 0x06, 0x86, 0xF5, 0xE0, 0x17, 0xDB, 0x42, 0x3F, 0xF6,
419 0x71, 0x03, 0xD9, 0xFE, 0x36, 0x00, 0x18, 0x00, 0xE5, 0xFF, 0x07,
420 0x00, 0xFD, 0xFF, 0x2F, 0x00, 0x4F, 0xFF, 0xC1, 0x01, 0x52, 0xFC,
421 0x22, 0x07, 0x98, 0xF1, 0x5E, 0x2D, 0x13, 0x33, 0x87, 0xF1, 0xD8,
422 0x06, 0x9B, 0xFC, 0x8D, 0x01, 0x6B, 0xFF, 0x25, 0x00, 0xFD, 0xFF,
423 0x03, 0x00, 0xFC, 0xFF, 0xDC, 0xFF, 0xAF, 0x00, 0x07, 0xFE, 0xC8,
424 0x04, 0x10, 0xF4, 0x2D, 0x3F, 0x0F, 0x1E, 0xED, 0xF3, 0xA0, 0x06,
425 0x4E, 0xFC, 0xE3, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x16,
426 0x00, 0xA3, 0xFF, 0xC3, 0x00, 0xD7, 0xFE, 0x58, 0x01, 0x0F, 0xFF,
427 0xA6, 0xFE, 0x5D, 0x48, 0x61, 0x09, 0x6E, 0xFA, 0xC0, 0x03, 0x99,
428 0xFD, 0x59, 0x01, 0x68, 0xFF, 0x26, 0x00, 0x00, 0x00, 0xFF, 0xFF,
429 0x2E, 0x00, 0x4E, 0xFF, 0x9E, 0x01, 0x00, 0xFD, 0xFC, 0x04, 0xD7,
430 0xF7, 0x75, 0x10, 0x48, 0x46, 0xE4, 0xF9, 0x6E, 0x01, 0x06, 0x00,
431 0x8E, 0xFF, 0x6B, 0x00, 0xC6, 0xFF, 0x0E, 0x00, 0xFD, 0xFF, 0x35,
432 0x00, 0x3B, 0xFF, 0xE2, 0x01, 0x31, 0xFC, 0x16, 0x07, 0x67, 0xF2,
433 0xE5, 0x25, 0x87, 0x39, 0x47, 0xF2, 0x10, 0x06, 0x30, 0xFD, 0x2F,
434 0x01, 0x9C, 0xFF, 0x14, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x13, 0x00,
435 0x9D, 0xFF, 0x2D, 0x01, 0x33, 0xFD, 0x0B, 0x06, 0x4D, 0xF2, 0xA5,
436 0x39, 0xBF, 0x25, 0x6D, 0xF2, 0x15, 0x07, 0x31, 0xFC, 0xE2, 0x01,
437 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0E, 0x00, 0xC5, 0xFF, 0x6D,
438 0x00, 0x8B, 0xFF, 0x0D, 0x00, 0x63, 0x01, 0xF9, 0xF9, 0x55, 0x46,
439 0x51, 0x10, 0xE3, 0xF7, 0xF7, 0x04, 0x03, 0xFD, 0x9D, 0x01, 0x4E,
440 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x26, 0x00, 0x68, 0xFF,
441 0x5B, 0x01, 0x96, 0xFD, 0xC6, 0x03, 0x61, 0xFA, 0x81, 0x09, 0x57,
442 0x48, 0x8D, 0xFE, 0x1B, 0xFF, 0x52, 0x01, 0xDB, 0xFE, 0xC2, 0x00,
443 0xA4, 0xFF, 0x16, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE3,
444 0x01, 0x4D, 0xFC, 0xA3, 0x06, 0xE4, 0xF3, 0x36, 0x1E, 0x16, 0x3F,
445 0x05, 0xF4, 0xCF, 0x04, 0x02, 0xFE, 0xB2, 0x00, 0xDB, 0xFF, 0xFC,
446 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x25, 0x00, 0x6C, 0xFF, 0x8B, 0x01,
447 0x9D, 0xFC, 0xD5, 0x06, 0x89, 0xF1, 0x35, 0x33, 0x3A, 0x2D, 0x9A,
448 0xF1, 0x23, 0x07, 0x51, 0xFC, 0xC2, 0x01, 0x4F, 0xFF, 0x2F, 0x00,
449 0xFD, 0xFF, 0x07, 0x00, 0xE5, 0xFF, 0x1A, 0x00, 0x33, 0x00, 0xDF,
450 0xFE, 0x68, 0x03, 0x4E, 0xF6, 0xEE, 0x42, 0xBB, 0x17, 0x90, 0xF5,
451 0xFC, 0x05, 0x8E, 0xFC, 0xCD, 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE,
452 0xFF, 0x1E, 0x00, 0x87, 0xFF, 0x0B, 0x01, 0x42, 0xFE, 0x74, 0x02,
453 0xF9, 0xFC, 0x39, 0x03, 0xF5, 0x48, 0x24, 0x04, 0x94, 0xFC, 0xA9,
454 0x02, 0x27, 0xFE, 0x18, 0x01, 0x82, 0xFF, 0x1F, 0x00, 0x00, 0x00,
455 0xFF, 0xFF, 0x33, 0x00, 0x3E, 0xFF, 0xC7, 0x01, 0x9D, 0xFC, 0xD8,
456 0x05, 0xE7, 0xF5, 0x91, 0x16, 0x89, 0x43, 0xCD, 0xF6, 0x1E, 0x03,
457 0x0B, 0xFF, 0x1A, 0x00, 0x26, 0x00, 0xE0, 0xFF, 0x08, 0x00, 0xFD,
458 0xFF, 0x30, 0x00, 0x4B, 0xFF, 0xC9, 0x01, 0x48, 0xFC, 0x28, 0x07,
459 0xAD, 0xF1, 0x19, 0x2C, 0x3F, 0x34, 0x97, 0xF1, 0xBE, 0x06, 0xB0,
460 0xFC, 0x7F, 0x01, 0x72, 0xFF, 0x23, 0x00, 0xFE, 0xFF, 0x02, 0x00,
461 0x00, 0x00, 0xD0, 0xFF, 0xC7, 0x00, 0xDE, 0xFD, 0x08, 0x05, 0xB0,
462 0xF3, 0x4A, 0x3E, 0x64, 0x1F, 0xA0, 0xF3, 0xBB, 0x06, 0x45, 0xFC,
463 0xE5, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x15, 0x00, 0xA9,
464 0xFF, 0xB4, 0x00, 0xF7, 0xFE, 0x1D, 0x01, 0x7A, 0xFF, 0xC5, 0xFD,
465 0x1D, 0x48, 0x89, 0x0A, 0xFB, 0xF9, 0xF8, 0x03, 0x7D, 0xFD, 0x66,
466 0x01, 0x63, 0xFF, 0x28, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2D, 0x00,
467 0x52, 0xFF, 0x93, 0x01, 0x18, 0xFD, 0xC9, 0x04, 0x45, 0xF8, 0x36,
468 0x0F, 0xBB, 0x46, 0xA1, 0xFA, 0x0C, 0x01, 0x3E, 0x00, 0x70, 0xFF,
469 0x7A, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39,
470 0xFF, 0xE4, 0x01, 0x32, 0xFC, 0x09, 0x07, 0x9D, 0xF2, 0x92, 0x24,
471 0x8F, 0x3A, 0x82, 0xF2, 0xE1, 0x05, 0x50, 0xFD, 0x1B, 0x01, 0xA6,
472 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x17, 0x00, 0x93, 0xFF,
473 0x3F, 0x01, 0x15, 0xFD, 0x36, 0x06, 0x19, 0xF2, 0x97, 0x38, 0x11,
474 0x27, 0x3B, 0xF2, 0x1F, 0x07, 0x32, 0xFC, 0xDF, 0x01, 0x3D, 0xFF,
475 0x34, 0x00, 0xFD, 0xFF, 0x0D, 0x00, 0xCB, 0xFF, 0x5E, 0x00, 0xA9,
476 0xFF, 0xD6, 0xFF, 0xC3, 0x01, 0x43, 0xF9, 0xD7, 0x45, 0x92, 0x11,
477 0x77, 0xF7, 0x28, 0x05, 0xEC, 0xFC, 0xA7, 0x01, 0x4A, 0xFF, 0x2F,
478 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6D, 0xFF, 0x4E, 0x01,
479 0xB3, 0xFD, 0x8D, 0x03, 0xD4, 0xFA, 0x5D, 0x08, 0x8D, 0x48, 0x74,
480 0xFF, 0xAE, 0xFE, 0x8D, 0x01, 0xBB, 0xFE, 0xD1, 0x00, 0x9E, 0xFF,
481 0x18, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE0, 0x01, 0x57,
482 0xFC, 0x85, 0x06, 0x34, 0xF4, 0xE0, 0x1C, 0xF0, 0x3F, 0x6D, 0xF4,
483 0x8C, 0x04, 0x2C, 0xFE, 0x99, 0x00, 0xE7, 0xFF, 0xF8, 0xFF, 0x04,
484 0x00, 0xFD, 0xFF, 0x27, 0x00, 0x65, 0xFF, 0x98, 0x01, 0x8A, 0xFC,
485 0xEC, 0x06, 0x7F, 0xF1, 0x04, 0x32, 0x7B, 0x2E, 0x8A, 0xF1, 0x1A,
486 0x07, 0x5D, 0xFC, 0xB8, 0x01, 0x54, 0xFF, 0x2D, 0x00, 0xFD, 0xFF,
487 0x06, 0x00, 0xEA, 0xFF, 0x0C, 0x00, 0x4E, 0x00, 0xAF, 0xFE, 0xB8,
488 0x03, 0xC7, 0xF5, 0x38, 0x42, 0x0C, 0x19, 0x32, 0xF5, 0x23, 0x06,
489 0x7D, 0xFC, 0xD3, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1C,
490 0x00, 0x8D, 0xFF, 0xFC, 0x00, 0x61, 0xFE, 0x39, 0x02, 0x6B, 0xFD,
491 0x37, 0x02, 0xEB, 0x48, 0x31, 0x05, 0x21, 0xFC, 0xE4, 0x02, 0x08,
492 0xFE, 0x26, 0x01, 0x7C, 0xFF, 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF,
493 0x32, 0x00, 0x41, 0xFF, 0xC0, 0x01, 0xAF, 0xFC, 0xAD, 0x05, 0x4A,
494 0xF6, 0x44, 0x15, 0x2F, 0x44, 0x64, 0xF7, 0xC9, 0x02, 0x3D, 0xFF,
495 0xFE, 0xFF, 0x34, 0x00, 0xDB, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x32,
496 0x00, 0x47, 0xFF, 0xD0, 0x01, 0x40, 0xFC, 0x2A, 0x07, 0xCA, 0xF1,
497 0xD1, 0x2A, 0x65, 0x35, 0xAE, 0xF1, 0xA0, 0x06, 0xC7, 0xFC, 0x70,
498 0x01, 0x7A, 0xFF, 0x20, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x05, 0x00,
499 0xC5, 0xFF, 0xDE, 0x00, 0xB7, 0xFD, 0x45, 0x05, 0x56, 0xF3, 0x61,
500 0x3D, 0xBA, 0x20, 0x56, 0xF3, 0xD3, 0x06, 0x3E, 0xFC, 0xE6, 0x01,
501 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x13, 0x00, 0xAF, 0xFF, 0xA5,
502 0x00, 0x16, 0xFF, 0xE3, 0x00, 0xE4, 0xFF, 0xEB, 0xFC, 0xD2, 0x47,
503 0xB6, 0x0B, 0x89, 0xF9, 0x2F, 0x04, 0x62, 0xFD, 0x72, 0x01, 0x5E,
504 0xFF, 0x29, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2C, 0x00, 0x56, 0xFF,
505 0x88, 0x01, 0x31, 0xFD, 0x95, 0x04, 0xB4, 0xF8, 0xFC, 0x0D, 0x26,
506 0x47, 0x64, 0xFB, 0xA7, 0x00, 0x77, 0x00, 0x51, 0xFF, 0x89, 0x00,
507 0xBA, 0xFF, 0x11, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE6,
508 0x01, 0x34, 0xFC, 0xF9, 0x06, 0xD9, 0xF2, 0x3F, 0x23, 0x90, 0x3B,
509 0xC4, 0xF2, 0xAE, 0x05, 0x72, 0xFD, 0x07, 0x01, 0xB0, 0xFF, 0x0C,
510 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x1A, 0x00, 0x8A, 0xFF, 0x51, 0x01,
511 0xF8, 0xFC, 0x5E, 0x06, 0xED, 0xF1, 0x82, 0x37, 0x60, 0x28, 0x0E,
512 0xF2, 0x26, 0x07, 0x35, 0xFC, 0xDB, 0x01, 0x40, 0xFF, 0x34, 0x00,
513 0xFD, 0xFF, 0x0C, 0x00, 0xD0, 0xFF, 0x4F, 0x00, 0xC7, 0xFF, 0xA0,
514 0xFF, 0x20, 0x02, 0x96, 0xF8, 0x4E, 0x45, 0xD7, 0x12, 0x0D, 0xF7,
515 0x58, 0x05, 0xD6, 0xFC, 0xB0, 0x01, 0x47, 0xFF, 0x30, 0x00, 0xFF,
516 0xFF, 0x00, 0x00, 0x23, 0x00, 0x72, 0xFF, 0x40, 0x01, 0xD0, 0xFD,
517 0x53, 0x03, 0x47, 0xFB, 0x3F, 0x07, 0xB8, 0x48, 0x62, 0x00, 0x3F,
518 0xFE, 0xC8, 0x01, 0x9C, 0xFE, 0xE0, 0x00, 0x98, 0xFF, 0x19, 0x00,
519 0xFE, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xDC, 0x01, 0x63, 0xFC, 0x66,
520 0x06, 0x89, 0xF4, 0x8C, 0x1B, 0xC3, 0x40, 0xDD, 0xF4, 0x46, 0x04,
521 0x58, 0xFE, 0x80, 0x00, 0xF4, 0xFF, 0xF3, 0xFF, 0x05, 0x00, 0xFD,
522 0xFF, 0x29, 0x00, 0x5F, 0xFF, 0xA5, 0x01, 0x78, 0xFC, 0xFF, 0x06,
523 0x7D, 0xF1, 0xCF, 0x30, 0xB8, 0x2F, 0x80, 0xF1, 0x0D, 0x07, 0x6A,
524 0xFC, 0xAE, 0x01, 0x59, 0xFF, 0x2B, 0x00, 0xFD, 0xFF, 0x05, 0x00,
525 0xEF, 0xFF, 0xFF, 0xFF, 0x69, 0x00, 0x80, 0xFE, 0x04, 0x04, 0x48,
526 0xF5, 0x74, 0x41, 0x5D, 0x1A, 0xD7, 0xF4, 0x47, 0x06, 0x6F, 0xFC,
527 0xD8, 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x93,
528 0xFF, 0xED, 0x00, 0x80, 0xFE, 0xFD, 0x01, 0xDC, 0xFD, 0x3C, 0x01,
529 0xD5, 0x48, 0x45, 0x06, 0xAE, 0xFB, 0x1F, 0x03, 0xEA, 0xFD, 0x34,
530 0x01, 0x77, 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00,
531 0x44, 0xFF, 0xB8, 0x01, 0xC3, 0xFC, 0x81, 0x05, 0xB0, 0xF6, 0xFA,
532 0x13, 0xCC, 0x44, 0x02, 0xF8, 0x71, 0x02, 0x71, 0xFF, 0xE1, 0xFF,
533 0x42, 0x00, 0xD5, 0xFF, 0x0B, 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x43,
534 0xFF, 0xD6, 0x01, 0x39, 0xFC, 0x2A, 0x07, 0xEB, 0xF1, 0x87, 0x29,
535 0x85, 0x36, 0xCC, 0xF1, 0x7F, 0x06, 0xE0, 0xFC, 0x60, 0x01, 0x82,
536 0xFF, 0x1D, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x09, 0x00, 0xBA, 0xFF,
537 0xF4, 0x00, 0x91, 0xFD, 0x7E, 0x05, 0x05, 0xF3, 0x6E, 0x3C, 0x10,
538 0x22, 0x12, 0xF3, 0xE9, 0x06, 0x38, 0xFC, 0xE6, 0x01, 0x37, 0xFF,
539 0x36, 0x00, 0xFD, 0xFF, 0x12, 0x00, 0xB5, 0xFF, 0x96, 0x00, 0x35,
540 0xFF, 0xA9, 0x00, 0x4D, 0x00, 0x19, 0xFC, 0x7C, 0x47, 0xE8, 0x0C,
541 0x18, 0xF9, 0x66, 0x04, 0x48, 0xFD, 0x7E, 0x01, 0x5A, 0xFF, 0x2B,
542 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5A, 0xFF, 0x7D, 0x01,
543 0x4B, 0xFD, 0x60, 0x04, 0x24, 0xF9, 0xC6, 0x0C, 0x86, 0x47, 0x30,
544 0xFC, 0x41, 0x00, 0xB0, 0x00, 0x32, 0xFF, 0x98, 0x00, 0xB4, 0xFF,
545 0x12, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x38,
546 0xFC, 0xE6, 0x06, 0x19, 0xF3, 0xEA, 0x21, 0x8A, 0x3C, 0x0E, 0xF3,
547 0x78, 0x05, 0x96, 0xFD, 0xF1, 0x00, 0xBB, 0xFF, 0x08, 0x00, 0x01,
548 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x81, 0xFF, 0x62, 0x01, 0xDD, 0xFC,
549 0x83, 0x06, 0xC9, 0xF1, 0x66, 0x36, 0xAC, 0x29, 0xE7, 0xF1, 0x2A,
550 0x07, 0x3A, 0xFC, 0xD5, 0x01, 0x43, 0xFF, 0x33, 0x00, 0xFD, 0xFF,
551 0x0B, 0x00, 0xD6, 0xFF, 0x41, 0x00, 0xE4, 0xFF, 0x6B, 0xFF, 0x7B,
552 0x02, 0xF0, 0xF7, 0xBA, 0x44, 0x1E, 0x14, 0xA5, 0xF6, 0x86, 0x05,
553 0xC1, 0xFC, 0xB9, 0x01, 0x44, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00,
554 0x00, 0x22, 0x00, 0x77, 0xFF, 0x32, 0x01, 0xED, 0xFD, 0x19, 0x03,
555 0xBB, 0xFB, 0x26, 0x06, 0xD7, 0x48, 0x58, 0x01, 0xCF, 0xFD, 0x04,
556 0x02, 0x7D, 0xFE, 0xEF, 0x00, 0x92, 0xFF, 0x1B, 0x00, 0xFE, 0xFF,
557 0x35, 0x00, 0x39, 0xFF, 0xD8, 0x01, 0x70, 0xFC, 0x43, 0x06, 0xE1,
558 0xF4, 0x38, 0x1A, 0x8C, 0x41, 0x55, 0xF5, 0xFC, 0x03, 0x85, 0xFE,
559 0x66, 0x00, 0x01, 0x00, 0xEE, 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2B,
560 0x00, 0x59, 0xFF, 0xB0, 0x01, 0x69, 0xFC, 0x0F, 0x07, 0x80, 0xF1,
561 0x96, 0x2F, 0xF2, 0x30, 0x7C, 0xF1, 0xFD, 0x06, 0x7A, 0xFC, 0xA3,
562 0x01, 0x5F, 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xF4, 0xFF,
563 0xF2, 0xFF, 0x83, 0x00, 0x53, 0xFE, 0x4E, 0x04, 0xD0, 0xF4, 0xAB,
564 0x40, 0xB2, 0x1B, 0x7F, 0xF4, 0x69, 0x06, 0x62, 0xFC, 0xDD, 0x01,
565 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x19, 0x00, 0x98, 0xFF, 0xDE,
566 0x00, 0x9F, 0xFE, 0xC2, 0x01, 0x4B, 0xFE, 0x48, 0x00, 0xB3, 0x48,
567 0x5E, 0x07, 0x3B, 0xFB, 0x59, 0x03, 0xCD, 0xFD, 0x42, 0x01, 0x71,
568 0xFF, 0x24, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0x00, 0x47, 0xFF,
569 0xAF, 0x01, 0xD8, 0xFC, 0x52, 0x05, 0x19, 0xF7, 0xB2, 0x12, 0x5C,
570 0x45, 0xA9, 0xF8, 0x16, 0x02, 0xA6, 0xFF, 0xC3, 0xFF, 0x51, 0x00,
571 0xD0, 0xFF, 0x0C, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x40, 0xFF, 0xDB,
572 0x01, 0x35, 0xFC, 0x25, 0x07, 0x13, 0xF2, 0x3A, 0x28, 0xA0, 0x37,
573 0xF2, 0xF1, 0x5A, 0x06, 0xFB, 0xFC, 0x4F, 0x01, 0x8B, 0xFF, 0x1A,
574 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0D, 0x00, 0xAF, 0xFF, 0x09, 0x01,
575 0x6E, 0xFD, 0xB4, 0x05, 0xBC, 0xF2, 0x73, 0x3B, 0x64, 0x23, 0xD2,
576 0xF2, 0xFB, 0x06, 0x34, 0xFC, 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00,
577 0xFD, 0xFF, 0x11, 0x00, 0xBB, 0xFF, 0x87, 0x00, 0x54, 0xFF, 0x70,
578 0x00, 0xB3, 0x00, 0x4E, 0xFB, 0x1A, 0x47, 0x1F, 0x0E, 0xA8, 0xF8,
579 0x9B, 0x04, 0x2E, 0xFD, 0x8A, 0x01, 0x55, 0xFF, 0x2C, 0x00, 0xFF,
580 0xFF, 0x00, 0x00, 0x29, 0x00, 0x5F, 0xFF, 0x71, 0x01, 0x65, 0xFD,
581 0x29, 0x04, 0x96, 0xF9, 0x95, 0x0B, 0xDC, 0x47, 0x03, 0xFD, 0xD9,
582 0xFF, 0xEA, 0x00, 0x12, 0xFF, 0xA7, 0x00, 0xAE, 0xFF, 0x14, 0x00,
583 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3E, 0xFC, 0xD0,
584 0x06, 0x5E, 0xF3, 0x94, 0x20, 0x7B, 0x3D, 0x60, 0xF3, 0x3E, 0x05,
585 0xBB, 0xFD, 0xDB, 0x00, 0xC6, 0xFF, 0x04, 0x00, 0x02, 0x00, 0xFE,
586 0xFF, 0x20, 0x00, 0x79, 0xFF, 0x72, 0x01, 0xC4, 0xFC, 0xA4, 0x06,
587 0xAB, 0xF1, 0x46, 0x35, 0xF7, 0x2A, 0xC6, 0xF1, 0x2A, 0x07, 0x40,
588 0xFC, 0xCF, 0x01, 0x47, 0xFF, 0x31, 0x00, 0xFD, 0xFF, 0x09, 0x00,
589 0xDB, 0xFF, 0x33, 0x00, 0x01, 0x00, 0x38, 0xFF, 0xD3, 0x02, 0x53,
590 0xF7, 0x1F, 0x44, 0x69, 0x15, 0x3F, 0xF6, 0xB2, 0x05, 0xAD, 0xFC,
591 0xC1, 0x01, 0x41, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x20,
592 0x00, 0x7D, 0xFF, 0x24, 0x01, 0x0C, 0xFE, 0xDE, 0x02, 0x2E, 0xFC,
593 0x13, 0x05, 0xEC, 0x48, 0x54, 0x02, 0x5E, 0xFD, 0x3F, 0x02, 0x5D,
594 0xFE, 0xFE, 0x00, 0x8C, 0xFF, 0x1C, 0x00, 0xFE, 0xFF, 0x35, 0x00,
595 0x3B, 0xFF, 0xD3, 0x01, 0x7F, 0xFC, 0x1F, 0x06, 0x3C, 0xF5, 0xE6,
596 0x18, 0x4D, 0x42, 0xD5, 0xF5, 0xAF, 0x03, 0xB4, 0xFE, 0x4B, 0x00,
597 0x0E, 0x00, 0xE9, 0xFF, 0x07, 0x00, 0xFD, 0xFF, 0x2D, 0x00, 0x53,
598 0xFF, 0xBA, 0x01, 0x5B, 0xFC, 0x1B, 0x07, 0x8B, 0xF1, 0x58, 0x2E,
599 0x26, 0x32, 0x80, 0xF1, 0xEA, 0x06, 0x8C, 0xFC, 0x97, 0x01, 0x66,
600 0xFF, 0x27, 0x00, 0xFD, 0xFF, 0x04, 0x00, 0xF8, 0xFF, 0xE6, 0xFF,
601 0x9C, 0x00, 0x27, 0xFE, 0x94, 0x04, 0x61, 0xF4, 0xD7, 0x3F, 0x06,
602 0x1D, 0x2B, 0xF4, 0x89, 0x06, 0x56, 0xFC, 0xE0, 0x01, 0x37, 0xFF,
603 0x36, 0x00, 0xFE, 0xFF, 0x17, 0x00, 0x9E, 0xFF, 0xCF, 0x00, 0xBF,
604 0xFE, 0x86, 0x01, 0xBA, 0xFE, 0x5A, 0xFF, 0x86, 0x48, 0x7D, 0x08,
605 0xC7, 0xFA, 0x93, 0x03, 0xB0, 0xFD, 0x4F, 0x01, 0x6C, 0xFF, 0x25,
606 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4B, 0xFF, 0xA6, 0x01,
607 0xEE, 0xFC, 0x23, 0x05, 0x83, 0xF7, 0x6E, 0x11, 0xE5, 0x45, 0x57,
608 0xF9, 0xB8, 0x01, 0xDC, 0xFF, 0xA5, 0xFF, 0x5F, 0x00, 0xCA, 0xFF,
609 0x0D, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3D, 0xFF, 0xDF, 0x01, 0x32,
610 0xFC, 0x1E, 0x07, 0x40, 0xF2, 0xEB, 0x26, 0xB5, 0x38, 0x1F, 0xF2,
611 0x32, 0x06, 0x18, 0xFD, 0x3D, 0x01, 0x94, 0xFF, 0x16, 0x00, 0xFF,
612 0xFF, 0x00, 0x00, 0x11, 0x00, 0xA4, 0xFF, 0x1D, 0x01, 0x4C, 0xFD,
613 0xE6, 0x05, 0x7B, 0xF2, 0x71, 0x3A, 0xB8, 0x24, 0x97, 0xF2, 0x0B,
614 0x07, 0x32, 0xFC, 0xE4, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
615 0x0F, 0x00, 0xC0, 0xFF, 0x78, 0x00, 0x73, 0xFF, 0x38, 0x00, 0x17,
616 0x01, 0x8B, 0xFA, 0xAF, 0x46, 0x59, 0x0F, 0x39, 0xF8, 0xCF, 0x04,
617 0x15, 0xFD, 0x95, 0x01, 0x51, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x00,
618 0x00, 0x28, 0x00, 0x64, 0xFF, 0x65, 0x01, 0x81, 0xFD, 0xF2, 0x03,
619 0x08, 0xFA, 0x68, 0x0A, 0x25, 0x48, 0xDE, 0xFD, 0x6E, 0xFF, 0x24,
620 0x01, 0xF3, 0xFE, 0xB6, 0x00, 0xA8, 0xFF, 0x15, 0x00, 0xFD, 0xFF,
621 0x36, 0x00, 0x36, 0xFF, 0xE5, 0x01, 0x46, 0xFC, 0xB8, 0x06, 0xA8,
622 0xF3, 0x3F, 0x1F, 0x64, 0x3E, 0xBA, 0xF3, 0x01, 0x05, 0xE2, 0xFD,
623 0xC4, 0x00, 0xD2, 0xFF, 0x00, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x23,
624 0x00, 0x71, 0xFF, 0x81, 0x01, 0xAE, 0xFC, 0xC1, 0x06, 0x95, 0xF1,
625 0x1E, 0x34, 0x3E, 0x2C, 0xAB, 0xF1, 0x27, 0x07, 0x49, 0xFC, 0xC8,
626 0x01, 0x4B, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x08, 0x00, 0xE1, 0xFF,
627 0x25, 0x00, 0x1D, 0x00, 0x05, 0xFF, 0x28, 0x03, 0xBD, 0xF6, 0x77,
628 0x43, 0xB6, 0x16, 0xDC, 0xF5, 0xDD, 0x05, 0x9B, 0xFC, 0xC8, 0x01,
629 0x3E, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x83,
630 0xFF, 0x16, 0x01, 0x2A, 0xFE, 0xA3, 0x02, 0xA1, 0xFC, 0x06, 0x04,
631 0xF5, 0x48, 0x56, 0x03, 0xED, 0xFC, 0x7B, 0x02, 0x3E, 0xFE, 0x0C,
632 0x01, 0x86, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3D, 0xFF,
633 0xCC, 0x01, 0x8F, 0xFC, 0xF8, 0x05, 0x9B, 0xF5, 0x96, 0x17, 0x02,
634 0x43, 0x5E, 0xF6, 0x5F, 0x03, 0xE4, 0xFE, 0x30, 0x00, 0x1B, 0x00,
635 0xE4, 0xFF, 0x08, 0x00, 0xFD, 0xFF, 0x2F, 0x00, 0x4E, 0xFF, 0xC3,
636 0x01, 0x4F, 0xFC, 0x24, 0x07, 0x9C, 0xF1, 0x17, 0x2D, 0x57, 0x33,
637 0x8A, 0xF1, 0xD3, 0x06, 0x9F, 0xFC, 0x8A, 0x01, 0x6D, 0xFF, 0x25,
638 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0xD9, 0xFF, 0xB4, 0x00,
639 0xFD, 0xFD, 0xD7, 0x04, 0xFA, 0xF3, 0xFC, 0x3E, 0x5B, 0x1E, 0xDB,
640 0xF3, 0xA6, 0x06, 0x4C, 0xFC, 0xE3, 0x01, 0x36, 0xFF, 0x36, 0x00,
641 0xFE, 0xFF, 0x16, 0x00, 0xA4, 0xFF, 0xC0, 0x00, 0xDE, 0xFE, 0x4B,
642 0x01, 0x27, 0xFF, 0x73, 0xFE, 0x4F, 0x48, 0xA2, 0x09, 0x54, 0xFA,
643 0xCC, 0x03, 0x93, 0xFD, 0x5C, 0x01, 0x67, 0xFF, 0x27, 0x00, 0x00,
644 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x4E, 0xFF, 0x9C, 0x01, 0x05, 0xFD,
645 0xF1, 0x04, 0xF0, 0xF7, 0x2D, 0x10, 0x61, 0x46, 0x0D, 0xFA, 0x58,
646 0x01, 0x13, 0x00, 0x87, 0xFF, 0x6E, 0x00, 0xC4, 0xFF, 0x0E, 0x00,
647 0xFD, 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xE3, 0x01, 0x31, 0xFC, 0x14,
648 0x07, 0x73, 0xF2, 0x99, 0x25, 0xC2, 0x39, 0x54, 0xF2, 0x05, 0x06,
649 0x37, 0xFD, 0x2B, 0x01, 0x9E, 0xFF, 0x13, 0x00, 0xFF, 0xFF, 0xFF,
650 0xFF, 0x14, 0x00, 0x9B, 0xFF, 0x31, 0x01, 0x2C, 0xFD, 0x15, 0x06,
651 0x41, 0xF2, 0x6A, 0x39, 0x0A, 0x26, 0x61, 0xF2, 0x17, 0x07, 0x31,
652 0xFC, 0xE2, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0E, 0x00,
653 0xC6, 0xFF, 0x69, 0x00, 0x91, 0xFF, 0x00, 0x00, 0x78, 0x01, 0xD0,
654 0xF9, 0x39, 0x46, 0x98, 0x10, 0xCB, 0xF7, 0x02, 0x05, 0xFE, 0xFC,
655 0x9F, 0x01, 0x4D, 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x26,
656 0x00, 0x69, 0xFF, 0x58, 0x01, 0x9D, 0xFD, 0xB9, 0x03, 0x7B, 0xFA,
657 0x40, 0x09, 0x63, 0x48, 0xBF, 0xFE, 0x03, 0xFF, 0x5F, 0x01, 0xD4,
658 0xFE, 0xC5, 0x00, 0xA2, 0xFF, 0x16, 0x00, 0xFE, 0xFF, 0x36, 0x00,
659 0x36, 0xFF, 0xE2, 0x01, 0x4F, 0xFC, 0x9C, 0x06, 0xF5, 0xF3, 0xEA,
660 0x1D, 0x47, 0x3F, 0x1B, 0xF4, 0xC1, 0x04, 0x0B, 0xFE, 0xAC, 0x00,
661 0xDE, 0xFF, 0xFB, 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x25, 0x00, 0x6A,
662 0xFF, 0x8E, 0x01, 0x99, 0xFC, 0xDB, 0x06, 0x86, 0xF1, 0xF2, 0x32,
663 0x82, 0x2D, 0x96, 0xF1, 0x21, 0x07, 0x53, 0xFC, 0xC0, 0x01, 0x50,
664 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE6, 0xFF, 0x17, 0x00,
665 0x39, 0x00, 0xD4, 0xFE, 0x7A, 0x03, 0x2F, 0xF6, 0xC7, 0x42, 0x06,
666 0x18, 0x7B, 0xF5, 0x05, 0x06, 0x8A, 0xFC, 0xCF, 0x01, 0x3C, 0xFF,
667 0x34, 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x88, 0xFF, 0x07, 0x01, 0x49,
668 0xFE, 0x67, 0x02, 0x13, 0xFD, 0xFF, 0x02, 0xF4, 0x48, 0x5F, 0x04,
669 0x7A, 0xFC, 0xB6, 0x02, 0x20, 0xFE, 0x1B, 0x01, 0x81, 0xFF, 0x1F,
670 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x3F, 0xFF, 0xC6, 0x01,
671 0xA1, 0xFC, 0xCF, 0x05, 0xFC, 0xF5, 0x47, 0x16, 0xB0, 0x43, 0xEE,
672 0xF6, 0x0C, 0x03, 0x16, 0xFF, 0x14, 0x00, 0x29, 0x00, 0xDF, 0xFF,
673 0x09, 0x00, 0xFD, 0xFF, 0x30, 0x00, 0x4A, 0xFF, 0xCA, 0x01, 0x46,
674 0xFC, 0x29, 0x07, 0xB3, 0xF1, 0xD1, 0x2B, 0x81, 0x34, 0x9C, 0xF1,
675 0xB8, 0x06, 0xB5, 0xFC, 0x7C, 0x01, 0x74, 0xFF, 0x22, 0x00, 0xFE,
676 0xFF, 0x02, 0x00, 0x01, 0x00, 0xCE, 0xFF, 0xCC, 0x00, 0xD5, 0xFD,
677 0x16, 0x05, 0x9B, 0xF3, 0x18, 0x3E, 0xB1, 0x1F, 0x8F, 0xF3, 0xC0,
678 0x06, 0x43, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
679 0x15, 0x00, 0xAA, 0xFF, 0xB1, 0x00, 0xFE, 0xFE, 0x10, 0x01, 0x92,
680 0xFF, 0x94, 0xFD, 0x0D, 0x48, 0xCB, 0x0A, 0xE2, 0xF9, 0x04, 0x04,
681 0x77, 0xFD, 0x69, 0x01, 0x62, 0xFF, 0x28, 0x00, 0x00, 0x00, 0xFF,
682 0xFF, 0x2D, 0x00, 0x52, 0xFF, 0x91, 0x01, 0x1E, 0xFD, 0xBE, 0x04,
683 0x5E, 0xF8, 0xF0, 0x0E, 0xD3, 0x46, 0xCB, 0xFA, 0xF6, 0x00, 0x4B,
684 0x00, 0x69, 0xFF, 0x7D, 0x00, 0xBE, 0xFF, 0x10, 0x00, 0xFD, 0xFF,
685 0x36, 0x00, 0x39, 0xFF, 0xE5, 0x01, 0x32, 0xFC, 0x06, 0x07, 0xAA,
686 0xF2, 0x46, 0x24, 0xC8, 0x3A, 0x90, 0xF2, 0xD6, 0x05, 0x57, 0xFD,
687 0x17, 0x01, 0xA8, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18,
688 0x00, 0x91, 0xFF, 0x43, 0x01, 0x0E, 0xFD, 0x40, 0x06, 0x0F, 0xF2,
689 0x5B, 0x38, 0x5C, 0x27, 0x30, 0xF2, 0x21, 0x07, 0x33, 0xFC, 0xDE,
690 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0D, 0x00, 0xCC, 0xFF,
691 0x5A, 0x00, 0xAF, 0xFF, 0xCA, 0xFF, 0xD8, 0x01, 0x1C, 0xF9, 0xB8,
692 0x45, 0xDA, 0x11, 0x60, 0xF7, 0x33, 0x05, 0xE7, 0xFC, 0xA9, 0x01,
693 0x4A, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6E,
694 0xFF, 0x4B, 0x01, 0xB9, 0xFD, 0x80, 0x03, 0xEE, 0xFA, 0x1D, 0x08,
695 0x98, 0x48, 0xA8, 0xFF, 0x95, 0xFE, 0x9A, 0x01, 0xB4, 0xFE, 0xD4,
696 0x00, 0x9C, 0xFF, 0x18, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF,
697 0xDF, 0x01, 0x5A, 0xFC, 0x7E, 0x06, 0x47, 0xF4, 0x94, 0x1C, 0x1F,
698 0x40, 0x85, 0xF4, 0x7D, 0x04, 0x36, 0xFE, 0x93, 0x00, 0xEA, 0xFF,
699 0xF7, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x28, 0x00, 0x63, 0xFF, 0x9B,
700 0x01, 0x86, 0xFC, 0xF1, 0x06, 0x7E, 0xF1, 0xC0, 0x31, 0xC2, 0x2E,
701 0x87, 0xF1, 0x17, 0x07, 0x5F, 0xFC, 0xB6, 0x01, 0x55, 0xFF, 0x2D,
702 0x00, 0xFD, 0xFF, 0x06, 0x00, 0xEB, 0xFF, 0x09, 0x00, 0x54, 0x00,
703 0xA4, 0xFE, 0xC9, 0x03, 0xAA, 0xF5, 0x0C, 0x42, 0x56, 0x19, 0x1E,
704 0xF5, 0x2B, 0x06, 0x7A, 0xFC, 0xD4, 0x01, 0x3A, 0xFF, 0x35, 0x00,
705 0xFE, 0xFF, 0x1C, 0x00, 0x8E, 0xFF, 0xF9, 0x00, 0x68, 0xFE, 0x2C,
706 0x02, 0x84, 0xFD, 0xFF, 0x01, 0xE6, 0x48, 0x6E, 0x05, 0x07, 0xFC,
707 0xF1, 0x02, 0x01, 0xFE, 0x29, 0x01, 0x7B, 0xFF, 0x21, 0x00, 0x00,
708 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x42, 0xFF, 0xBE, 0x01, 0xB4, 0xFC,
709 0xA4, 0x05, 0x61, 0xF6, 0xFB, 0x14, 0x53, 0x44, 0x86, 0xF7, 0xB6,
710 0x02, 0x49, 0xFF, 0xF7, 0xFF, 0x37, 0x00, 0xD9, 0xFF, 0x0A, 0x00,
711 0xFD, 0xFF, 0x32, 0x00, 0x46, 0xFF, 0xD1, 0x01, 0x3E, 0xFC, 0x2B,
712 0x07, 0xD0, 0xF1, 0x89, 0x2A, 0xA6, 0x35, 0xB4, 0xF1, 0x99, 0x06,
713 0xCD, 0xFC, 0x6D, 0x01, 0x7C, 0xFF, 0x1F, 0x00, 0xFE, 0xFF, 0x01,
714 0x00, 0x06, 0x00, 0xC2, 0xFF, 0xE3, 0x00, 0xAE, 0xFD, 0x52, 0x05,
715 0x44, 0xF3, 0x2A, 0x3D, 0x06, 0x21, 0x47, 0xF3, 0xD8, 0x06, 0x3C,
716 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x13, 0x00,
717 0xB0, 0xFF, 0xA2, 0x00, 0x1D, 0xFF, 0xD6, 0x00, 0xFC, 0xFF, 0xBC,
718 0xFC, 0xC0, 0x47, 0xFA, 0x0B, 0x70, 0xF9, 0x3C, 0x04, 0x5C, 0xFD,
719 0x75, 0x01, 0x5D, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B,
720 0x00, 0x57, 0xFF, 0x86, 0x01, 0x36, 0xFD, 0x89, 0x04, 0xCD, 0xF8,
721 0xB7, 0x0D, 0x3D, 0x47, 0x91, 0xFB, 0x91, 0x00, 0x83, 0x00, 0x4A,
722 0xFF, 0x8C, 0x00, 0xB9, 0xFF, 0x11, 0x00, 0xFD, 0xFF, 0x36, 0x00,
723 0x38, 0xFF, 0xE6, 0x01, 0x35, 0xFC, 0xF5, 0x06, 0xE7, 0xF2, 0xF2,
724 0x22, 0xC7, 0x3B, 0xD4, 0xF2, 0xA2, 0x05, 0x7A, 0xFD, 0x02, 0x01,
725 0xB2, 0xFF, 0x0B, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x88,
726 0xFF, 0x55, 0x01, 0xF2, 0xFC, 0x67, 0x06, 0xE4, 0xF1, 0x44, 0x37,
727 0xAA, 0x28, 0x05, 0xF2, 0x27, 0x07, 0x36, 0xFC, 0xDA, 0x01, 0x41,
728 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x0B, 0x00, 0xD2, 0xFF, 0x4C, 0x00,
729 0xCD, 0xFF, 0x94, 0xFF, 0x34, 0x02, 0x70, 0xF8, 0x2E, 0x45, 0x20,
730 0x13, 0xF6, 0xF6, 0x62, 0x05, 0xD1, 0xFC, 0xB2, 0x01, 0x46, 0xFF,
731 0x31, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x23, 0x00, 0x73, 0xFF, 0x3D,
732 0x01, 0xD6, 0xFD, 0x46, 0x03, 0x61, 0xFB, 0x00, 0x07, 0xBF, 0x48,
733 0x98, 0x00, 0x26, 0xFE, 0xD5, 0x01, 0x95, 0xFE, 0xE3, 0x00, 0x96,
734 0xFF, 0x1A, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xDB, 0x01,
735 0x66, 0xFC, 0x5E, 0x06, 0x9C, 0xF4, 0x40, 0x1B, 0xEF, 0x40, 0xF7,
736 0xF4, 0x35, 0x04, 0x62, 0xFE, 0x7A, 0x00, 0xF7, 0xFF, 0xF2, 0xFF,
737 0x05, 0x00, 0xFD, 0xFF, 0x2A, 0x00, 0x5D, 0xFF, 0xA7, 0x01, 0x75,
738 0xFC, 0x03, 0x07, 0x7D, 0xF1, 0x8A, 0x30, 0xFF, 0x2F, 0x7E, 0xF1,
739 0x0A, 0x07, 0x6E, 0xFC, 0xAC, 0x01, 0x5A, 0xFF, 0x2B, 0x00, 0xFD,
740 0xFF, 0x05, 0x00, 0xF0, 0xFF, 0xFC, 0xFF, 0x6E, 0x00, 0x76, 0xFE,
741 0x15, 0x04, 0x2C, 0xF5, 0x49, 0x41, 0xA9, 0x1A, 0xC3, 0xF4, 0x4F,
742 0x06, 0x6C, 0xFC, 0xD9, 0x01, 0x38, 0xFF, 0x35, 0x00, 0xFE, 0xFF,
743 0x1A, 0x00, 0x94, 0xFF, 0xEA, 0x00, 0x87, 0xFE, 0xF0, 0x01, 0xF5,
744 0xFD, 0x05, 0x01, 0xCE, 0x48, 0x83, 0x06, 0x94, 0xFB, 0x2C, 0x03,
745 0xE4, 0xFD, 0x37, 0x01, 0x76, 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFF,
746 0xFF, 0x31, 0x00, 0x45, 0xFF, 0xB6, 0x01, 0xC8, 0xFC, 0x77, 0x05,
747 0xC7, 0xF6, 0xB1, 0x13, 0xED, 0x44, 0x26, 0xF8, 0x5D, 0x02, 0x7D,
748 0xFF, 0xDA, 0xFF, 0x46, 0x00, 0xD4, 0xFF, 0x0B, 0x00, 0xFD, 0xFF,
749 0x33, 0x00, 0x42, 0xFF, 0xD7, 0x01, 0x38, 0xFC, 0x29, 0x07, 0xF3,
750 0xF1, 0x3E, 0x29, 0xC6, 0x36, 0xD4, 0xF1, 0x77, 0x06, 0xE6, 0xFC,
751 0x5C, 0x01, 0x84, 0xFF, 0x1C, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x0A,
752 0x00, 0xB7, 0xFF, 0xF9, 0x00, 0x89, 0xFD, 0x8A, 0x05, 0xF4, 0xF2,
753 0x37, 0x3C, 0x5B, 0x22, 0x03, 0xF3, 0xED, 0x06, 0x37, 0xFC, 0xE6,
754 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x12, 0x00, 0xB6, 0xFF,
755 0x93, 0x00, 0x3C, 0xFF, 0x9D, 0x00, 0x63, 0x00, 0xEB, 0xFB, 0x69,
756 0x47, 0x2D, 0x0D, 0xFF, 0xF8, 0x72, 0x04, 0x42, 0xFD, 0x81, 0x01,
757 0x59, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5B,
758 0xFF, 0x7A, 0x01, 0x50, 0xFD, 0x54, 0x04, 0x3D, 0xF9, 0x82, 0x0C,
759 0x9A, 0x47, 0x5E, 0xFC, 0x2A, 0x00, 0xBD, 0x00, 0x2B, 0xFF, 0x9B,
760 0x00, 0xB3, 0xFF, 0x12, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF,
761 0xE6, 0x01, 0x3A, 0xFC, 0xE2, 0x06, 0x28, 0xF3, 0x9E, 0x21, 0xC0,
762 0x3C, 0x1F, 0xF3, 0x6C, 0x05, 0x9E, 0xFD, 0xED, 0x00, 0xBD, 0xFF,
763 0x07, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1E, 0x00, 0x80, 0xFF, 0x66,
764 0x01, 0xD8, 0xFC, 0x8B, 0x06, 0xC1, 0xF1, 0x27, 0x36, 0xF6, 0x29,
765 0xDF, 0xF1, 0x2A, 0x07, 0x3B, 0xFC, 0xD4, 0x01, 0x44, 0xFF, 0x32,
766 0x00, 0xFD, 0xFF, 0x0A, 0x00, 0xD7, 0xFF, 0x3E, 0x00, 0xEA, 0xFF,
767 0x60, 0xFF, 0x8F, 0x02, 0xCD, 0xF7, 0x99, 0x44, 0x68, 0x14, 0x8E,
768 0xF6, 0x90, 0x05, 0xBC, 0xFC, 0xBA, 0x01, 0x43, 0xFF, 0x32, 0x00,
769 0xFF, 0xFF, 0x00, 0x00, 0x22, 0x00, 0x79, 0xFF, 0x2F, 0x01, 0xF4,
770 0xFD, 0x0C, 0x03, 0xD4, 0xFB, 0xE9, 0x05, 0xDE, 0x48, 0x8F, 0x01,
771 0xB6, 0xFD, 0x11, 0x02, 0x76, 0xFE, 0xF2, 0x00, 0x91, 0xFF, 0x1B,
772 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD7, 0x01, 0x73, 0xFC,
773 0x3B, 0x06, 0xF5, 0xF4, 0xED, 0x19, 0xB7, 0x41, 0x71, 0xF5, 0xEB,
774 0x03, 0x90, 0xFE, 0x60, 0x00, 0x04, 0x00, 0xED, 0xFF, 0x06, 0x00,
775 0xFD, 0xFF, 0x2C, 0x00, 0x57, 0xFF, 0xB2, 0x01, 0x65, 0xFC, 0x12,
776 0x07, 0x82, 0xF1, 0x50, 0x2F, 0x38, 0x31, 0x7C, 0xF1, 0xF9, 0x06,
777 0x7E, 0xFC, 0xA1, 0x01, 0x61, 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0x04,
778 0x00, 0xF5, 0xFF, 0xEF, 0xFF, 0x88, 0x00, 0x49, 0xFE, 0x5D, 0x04,
779 0xB7, 0xF4, 0x7D, 0x40, 0xFD, 0x1B, 0x6C, 0xF4, 0x70, 0x06, 0x5F,
780 0xFC, 0xDE, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x19, 0x00,
781 0x9A, 0xFF, 0xDB, 0x00, 0xA6, 0xFE, 0xB4, 0x01, 0x64, 0xFE, 0x12,
782 0x00, 0xAA, 0x48, 0x9E, 0x07, 0x21, 0xFB, 0x66, 0x03, 0xC6, 0xFD,
783 0x45, 0x01, 0x70, 0xFF, 0x24, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30,
784 0x00, 0x48, 0xFF, 0xAD, 0x01, 0xDD, 0xFC, 0x48, 0x05, 0x30, 0xF7,
785 0x6B, 0x12, 0x7D, 0x45, 0xCF, 0xF8, 0x01, 0x02, 0xB2, 0xFF, 0xBD,
786 0xFF, 0x54, 0x00, 0xCE, 0xFF, 0x0C, 0x00, 0xFD, 0xFF, 0x34, 0x00,
787 0x3F, 0xFF, 0xDC, 0x01, 0x34, 0xFC, 0x24, 0x07, 0x1C, 0xF2, 0xF0,
788 0x27, 0xDF, 0x37, 0xFB, 0xF1, 0x51, 0x06, 0x01, 0xFD, 0x4B, 0x01,
789 0x8D, 0xFF, 0x19, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0E, 0x00, 0xAC,
790 0xFF, 0x0E, 0x01, 0x66, 0xFD, 0xBF, 0x05, 0xAD, 0xF2, 0x3B, 0x3B,
791 0xB0, 0x23, 0xC4, 0xF2, 0xFF, 0x06, 0x33, 0xFC, 0xE5, 0x01, 0x38,
792 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x10, 0x00, 0xBC, 0xFF, 0x84, 0x00,
793 0x5B, 0xFF, 0x64, 0x00, 0xC9, 0x00, 0x22, 0xFB, 0x02, 0x47, 0x64,
794 0x0E, 0x8F, 0xF8, 0xA7, 0x04, 0x29, 0xFD, 0x8C, 0x01, 0x54, 0xFF,
795 0x2C, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x29, 0x00, 0x60, 0xFF, 0x6E,
796 0x01, 0x6B, 0xFD, 0x1D, 0x04, 0xAF, 0xF9, 0x51, 0x0B, 0xEC, 0x47,
797 0x33, 0xFD, 0xC1, 0xFF, 0xF7, 0x00, 0x0C, 0xFF, 0xAA, 0x00, 0xAD,
798 0xFF, 0x14, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01,
799 0x40, 0xFC, 0xCB, 0x06, 0x6E, 0xF3, 0x49, 0x20, 0xB0, 0x3D, 0x73,
800 0xF3, 0x31, 0x05, 0xC4, 0xFD, 0xD6, 0x00, 0xC8, 0xFF, 0x03, 0x00,
801 0x02, 0x00, 0xFE, 0xFF, 0x21, 0x00, 0x77, 0xFF, 0x75, 0x01, 0xBF,
802 0xFC, 0xAB, 0x06, 0xA6, 0xF1, 0x05, 0x35, 0x40, 0x2B, 0xBF, 0xF1,
803 0x2A, 0x07, 0x42, 0xFC, 0xCE, 0x01, 0x48, 0xFF, 0x31, 0x00, 0xFD,
804 0xFF, 0x09, 0x00, 0xDC, 0xFF, 0x2F, 0x00, 0x07, 0x00, 0x2C, 0xFF,
805 0xE6, 0x02, 0x31, 0xF7, 0xFA, 0x43, 0xB3, 0x15, 0x29, 0xF6, 0xBC,
806 0x05, 0xA9, 0xFC, 0xC2, 0x01, 0x40, 0xFF, 0x33, 0x00, 0xFF, 0xFF,
807 0x00, 0x00, 0x20, 0x00, 0x7E, 0xFF, 0x21, 0x01, 0x12, 0xFE, 0xD1,
808 0x02, 0x47, 0xFC, 0xD7, 0x04, 0xF0, 0x48, 0x8D, 0x02, 0x45, 0xFD,
809 0x4D, 0x02, 0x56, 0xFE, 0x01, 0x01, 0x8B, 0xFF, 0x1D, 0x00, 0xFE,
810 0xFF, 0x34, 0x00, 0x3B, 0xFF, 0xD1, 0x01, 0x83, 0xFC, 0x16, 0x06,
811 0x51, 0xF5, 0x9B, 0x18, 0x75, 0x42, 0xF3, 0xF5, 0x9D, 0x03, 0xBF,
812 0xFE, 0x45, 0x00, 0x11, 0x00, 0xE8, 0xFF, 0x07, 0x00, 0xFD, 0xFF,
813 0x2E, 0x00, 0x52, 0xFF, 0xBC, 0x01, 0x58, 0xFC, 0x1D, 0x07, 0x8E,
814 0xF1, 0x11, 0x2E, 0x6B, 0x32, 0x81, 0xF1, 0xE5, 0x06, 0x90, 0xFC,
815 0x94, 0x01, 0x67, 0xFF, 0x26, 0x00, 0xFD, 0xFF, 0x04, 0x00, 0xF9,
816 0xFF, 0xE3, 0xFF, 0xA1, 0x00, 0x1E, 0xFE, 0xA3, 0x04, 0x49, 0xF4,
817 0xA8, 0x3F, 0x52, 0x1D, 0x19, 0xF4, 0x90, 0x06, 0x53, 0xFC, 0xE1,
818 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x17, 0x00, 0xA0, 0xFF,
819 0xCC, 0x00, 0xC6, 0xFE, 0x79, 0x01, 0xD2, 0xFE, 0x26, 0xFF, 0x7C,
820 0x48, 0xBE, 0x08, 0xAE, 0xFA, 0xA0, 0x03, 0xA9, 0xFD, 0x52, 0x01,
821 0x6B, 0xFF, 0x25, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4C,
822 0xFF, 0xA3, 0x01, 0xF3, 0xFC, 0x18, 0x05, 0x9B, 0xF7, 0x27, 0x11,
823 0x02, 0x46, 0x7F, 0xF9, 0xA3, 0x01, 0xE8, 0xFF, 0x9F, 0xFF, 0x63,
824 0x00, 0xC9, 0xFF, 0x0D, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3C, 0xFF,
825 0xE0, 0x01, 0x32, 0xFC, 0x1C, 0x07, 0x4B, 0xF2, 0xA0, 0x26, 0xF2,
826 0x38, 0x2A, 0xF2, 0x28, 0x06, 0x1F, 0xFD, 0x39, 0x01, 0x96, 0xFF,
827 0x16, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x11, 0x00, 0xA2, 0xFF, 0x22,
828 0x01, 0x45, 0xFD, 0xF1, 0x05, 0x6D, 0xF2, 0x38, 0x3A, 0x03, 0x25,
829 0x8B, 0xF2, 0x0E, 0x07, 0x32, 0xFC, 0xE4, 0x01, 0x3A, 0xFF, 0x36,
830 0x00, 0xFD, 0xFF, 0x0F, 0x00, 0xC2, 0xFF, 0x75, 0x00, 0x7A, 0xFF,
831 0x2B, 0x00, 0x2D, 0x01, 0x61, 0xFA, 0x97, 0x46, 0xA0, 0x0F, 0x20,
832 0xF8, 0xDA, 0x04, 0x10, 0xFD, 0x97, 0x01, 0x50, 0xFF, 0x2E, 0x00,
833 0xFF, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x65, 0xFF, 0x62, 0x01, 0x87,
834 0xFD, 0xE5, 0x03, 0x21, 0xFA, 0x25, 0x0A, 0x33, 0x48, 0x0F, 0xFE,
835 0x57, 0xFF, 0x31, 0x01, 0xEC, 0xFE, 0xB9, 0x00, 0xA7, 0xFF, 0x15,
836 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4, 0x01, 0x48, 0xFC,
837 0xB2, 0x06, 0xB9, 0xF3, 0xF3, 0x1E, 0x98, 0x3E, 0xCF, 0xF3, 0xF3,
838 0x04, 0xEB, 0xFD, 0xBF, 0x00, 0xD4, 0xFF, 0xFF, 0xFF, 0x03, 0x00,
839 0xFE, 0xFF, 0x23, 0x00, 0x70, 0xFF, 0x84, 0x01, 0xA9, 0xFC, 0xC7,
840 0x06, 0x91, 0xF1, 0xDC, 0x33, 0x87, 0x2C, 0xA5, 0xF1, 0x26, 0x07,
841 0x4B, 0xFC, 0xC6, 0x01, 0x4C, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x08,
842 0x00, 0xE2, 0xFF, 0x21, 0x00, 0x23, 0x00, 0xFA, 0xFE, 0x3A, 0x03,
843 0x9D, 0xF6, 0x50, 0x43, 0x00, 0x17, 0xC6, 0xF5, 0xE6, 0x05, 0x97,
844 0xFC, 0xC9, 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x00, 0x00,
845 0x1E, 0x00, 0x84, 0xFF, 0x13, 0x01, 0x31, 0xFE, 0x95, 0x02, 0xBA,
846 0xFC, 0xCB, 0x03, 0xF7, 0x48, 0x91, 0x03, 0xD3, 0xFC, 0x88, 0x02,
847 0x38, 0xFE, 0x10, 0x01, 0x85, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x34,
848 0x00, 0x3D, 0xFF, 0xCB, 0x01, 0x93, 0xFC, 0xEF, 0x05, 0xB0, 0xF5,
849 0x4B, 0x17, 0x2A, 0x43, 0x7D, 0xF6, 0x4D, 0x03, 0xEF, 0xFE, 0x2A,
850 0x00, 0x1E, 0x00, 0xE3, 0xFF, 0x08, 0x00, 0xFD, 0xFF, 0x2F, 0x00,
851 0x4D, 0xFF, 0xC4, 0x01, 0x4D, 0xFC, 0x25, 0x07, 0xA1, 0xF1, 0xCE,
852 0x2C, 0x99, 0x33, 0x8E, 0xF1, 0xCD, 0x06, 0xA4, 0xFC, 0x87, 0x01,
853 0x6E, 0xFF, 0x24, 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFE, 0xFF, 0xD7,
854 0xFF, 0xBA, 0x00, 0xF4, 0xFD, 0xE5, 0x04, 0xE4, 0xF3, 0xCA, 0x3E,
855 0xA7, 0x1E, 0xCA, 0xF3, 0xAC, 0x06, 0x4A, 0xFC, 0xE4, 0x01, 0x36,
856 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x16, 0x00, 0xA6, 0xFF, 0xBD, 0x00,
857 0xE5, 0xFE, 0x3E, 0x01, 0x3F, 0xFF, 0x41, 0xFE, 0x41, 0x48, 0xE4,
858 0x09, 0x3B, 0xFA, 0xD9, 0x03, 0x8D, 0xFD, 0x5F, 0x01, 0x66, 0xFF,
859 0x27, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x4F, 0xFF, 0x99,
860 0x01, 0x0B, 0xFD, 0xE6, 0x04, 0x08, 0xF8, 0xE7, 0x0F, 0x7C, 0x46,
861 0x37, 0xFA, 0x42, 0x01, 0x1F, 0x00, 0x81, 0xFF, 0x71, 0x00, 0xC3,
862 0xFF, 0x0F, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xE3, 0x01,
863 0x31, 0xFC, 0x11, 0x07, 0x7F, 0xF2, 0x4E, 0x25, 0xFD, 0x39, 0x60,
864 0xF2, 0xFB, 0x05, 0x3E, 0xFD, 0x26, 0x01, 0xA0, 0xFF, 0x12, 0x00,
865 0x00, 0x00, 0xFF, 0xFF, 0x15, 0x00, 0x98, 0xFF, 0x35, 0x01, 0x25,
866 0xFD, 0x1E, 0x06, 0x35, 0xF2, 0x2E, 0x39, 0x55, 0x26, 0x56, 0xF2,
867 0x1A, 0x07, 0x31, 0xFC, 0xE1, 0x01, 0x3C, 0xFF, 0x35, 0x00, 0xFD,
868 0xFF, 0x0E, 0x00, 0xC7, 0xFF, 0x66, 0x00, 0x98, 0xFF, 0xF4, 0xFF,
869 0x8E, 0x01, 0xA7, 0xF9, 0x1D, 0x46, 0xDF, 0x10, 0xB3, 0xF7, 0x0D,
870 0x05, 0xF8, 0xFC, 0xA1, 0x01, 0x4C, 0xFF, 0x2F, 0x00, 0xFF, 0xFF,
871 0x00, 0x00, 0x26, 0x00, 0x6A, 0xFF, 0x55, 0x01, 0xA3, 0xFD, 0xAD,
872 0x03, 0x94, 0xFA, 0xFF, 0x08, 0x70, 0x48, 0xF3, 0xFE, 0xEA, 0xFE,
873 0x6C, 0x01, 0xCD, 0xFE, 0xC9, 0x00, 0xA1, 0xFF, 0x17, 0x00, 0xFE,
874 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE2, 0x01, 0x51, 0xFC, 0x96, 0x06,
875 0x07, 0xF4, 0x9E, 0x1D, 0x77, 0x3F, 0x32, 0xF4, 0xB2, 0x04, 0x15,
876 0xFE, 0xA7, 0x00, 0xE0, 0xFF, 0xFA, 0xFF, 0x03, 0x00, 0xFD, 0xFF,
877 0x26, 0x00, 0x69, 0xFF, 0x91, 0x01, 0x94, 0xFC, 0xE0, 0x06, 0x84,
878 0xF1, 0xAF, 0x32, 0xCA, 0x2D, 0x92, 0xF1, 0x1F, 0x07, 0x56, 0xFC,
879 0xBE, 0x01, 0x51, 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE7,
880 0xFF, 0x14, 0x00, 0x3F, 0x00, 0xC9, 0xFE, 0x8C, 0x03, 0x11, 0xF6,
881 0x9E, 0x42, 0x50, 0x18, 0x66, 0xF5, 0x0D, 0x06, 0x86, 0xFC, 0xD0,
882 0x01, 0x3B, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x8A, 0xFF,
883 0x04, 0x01, 0x50, 0xFE, 0x5A, 0x02, 0x2C, 0xFD, 0xC6, 0x02, 0xF2,
884 0x48, 0x9B, 0x04, 0x61, 0xFC, 0xC3, 0x02, 0x19, 0xFE, 0x1E, 0x01,
885 0x7F, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x40,
886 0xFF, 0xC4, 0x01, 0xA5, 0xFC, 0xC5, 0x05, 0x13, 0xF6, 0xFD, 0x15,
887 0xD4, 0x43, 0x0F, 0xF7, 0xF9, 0x02, 0x21, 0xFF, 0x0D, 0x00, 0x2C,
888 0x00, 0xDE, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x31, 0x00, 0x49, 0xFF,
889 0xCC, 0x01, 0x44, 0xFC, 0x29, 0x07, 0xB9, 0xF1, 0x89, 0x2B, 0xC3,
890 0x34, 0xA0, 0xF1, 0xB1, 0x06, 0xBA, 0xFC, 0x79, 0x01, 0x76, 0xFF,
891 0x21, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x02, 0x00, 0xCB, 0xFF, 0xD1,
892 0x00, 0xCC, 0xFD, 0x24, 0x05, 0x87, 0xF3, 0xE4, 0x3D, 0xFD, 0x1F,
893 0x7F, 0xF3, 0xC6, 0x06, 0x41, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36,
894 0x00, 0xFD, 0xFF, 0x14, 0x00, 0xAC, 0xFF, 0xAE, 0x00, 0x05, 0xFF,
895 0x03, 0x01, 0xAA, 0xFF, 0x63, 0xFD, 0xFD, 0x47, 0x0E, 0x0B, 0xC8,
896 0xF9, 0x11, 0x04, 0x71, 0xFD, 0x6C, 0x01, 0x61, 0xFF, 0x28, 0x00,
897 0x00, 0x00, 0xFF, 0xFF, 0x2D, 0x00, 0x53, 0xFF, 0x8F, 0x01, 0x23,
898 0xFD, 0xB2, 0x04, 0x76, 0xF8, 0xAA, 0x0E, 0xED, 0x46, 0xF7, 0xFA,
899 0xDF, 0x00, 0x57, 0x00, 0x62, 0xFF, 0x80, 0x00, 0xBD, 0xFF, 0x10,
900 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE5, 0x01, 0x33, 0xFC,
901 0x03, 0x07, 0xB7, 0xF2, 0xFC, 0x23, 0x03, 0x3B, 0x9E, 0xF2, 0xCB,
902 0x05, 0x5F, 0xFD, 0x12, 0x01, 0xAA, 0xFF, 0x0E, 0x00, 0x00, 0x00,
903 0xFF, 0xFF, 0x18, 0x00, 0x8F, 0xFF, 0x47, 0x01, 0x08, 0xFD, 0x49,
904 0x06, 0x05, 0xF2, 0x1D, 0x38, 0xA6, 0x27, 0x26, 0xF2, 0x23, 0x07,
905 0x33, 0xFC, 0xDD, 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0C,
906 0x00, 0xCD, 0xFF, 0x57, 0x00, 0xB6, 0xFF, 0xBE, 0xFF, 0xED, 0x01,
907 0xF5, 0xF8, 0x9B, 0x45, 0x22, 0x12, 0x48, 0xF7, 0x3D, 0x05, 0xE2,
908 0xFC, 0xAB, 0x01, 0x49, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00,
909 0x24, 0x00, 0x6F, 0xFF, 0x48, 0x01, 0xC0, 0xFD, 0x73, 0x03, 0x07,
910 0xFB, 0xDD, 0x07, 0xA1, 0x48, 0xDD, 0xFF, 0x7D, 0xFE, 0xA7, 0x01,
911 0xAD, 0xFE, 0xD8, 0x00, 0x9B, 0xFF, 0x18, 0x00, 0xFE, 0xFF, 0x36,
912 0x00, 0x37, 0xFF, 0xDF, 0x01, 0x5C, 0xFC, 0x78, 0x06, 0x5A, 0xF4,
913 0x49, 0x1C, 0x4E, 0x40, 0x9E, 0xF4, 0x6D, 0x04, 0x3F, 0xFE, 0x8E,
914 0x00, 0xED, 0xFF, 0xF6, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x28, 0x00,
915 0x62, 0xFF, 0x9E, 0x01, 0x82, 0xFC, 0xF5, 0x06, 0x7D, 0xF1, 0x7B,
916 0x31, 0x09, 0x2F, 0x84, 0xF1, 0x15, 0x07, 0x62, 0xFC, 0xB4, 0x01,
917 0x56, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0x06, 0x00, 0xEC, 0xFF, 0x06,
918 0x00, 0x5A, 0x00, 0x9A, 0xFE, 0xDA, 0x03, 0x8D, 0xF5, 0xE1, 0x41,
919 0xA1, 0x19, 0x09, 0xF5, 0x33, 0x06, 0x77, 0xFC, 0xD6, 0x01, 0x3A,
920 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x8F, 0xFF, 0xF5, 0x00,
921 0x6F, 0xFE, 0x1E, 0x02, 0x9D, 0xFD, 0xC7, 0x01, 0xE1, 0x48, 0xAB,
922 0x05, 0xEE, 0xFB, 0xFE, 0x02, 0xFB, 0xFD, 0x2C, 0x01, 0x7A, 0xFF,
923 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x42, 0xFF, 0xBC,
924 0x01, 0xB8, 0xFC, 0x9A, 0x05, 0x77, 0xF6, 0xB1, 0x14, 0x77, 0x44,
925 0xA9, 0xF7, 0xA2, 0x02, 0x54, 0xFF, 0xF1, 0xFF, 0x3A, 0x00, 0xD8,
926 0xFF, 0x0A, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x45, 0xFF, 0xD3, 0x01,
927 0x3C, 0xFC, 0x2A, 0x07, 0xD8, 0xF1, 0x3F, 0x2A, 0xE6, 0x35, 0xBB,
928 0xF1, 0x92, 0x06, 0xD2, 0xFC, 0x69, 0x01, 0x7E, 0xFF, 0x1F, 0x00,
929 0xFE, 0xFF, 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xE8, 0x00, 0xA6,
930 0xFD, 0x5F, 0x05, 0x31, 0xF3, 0xF6, 0x3C, 0x52, 0x21, 0x37, 0xF3,
931 0xDD, 0x06, 0x3B, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD,
932 0xFF, 0x13, 0x00, 0xB1, 0xFF, 0x9F, 0x00, 0x24, 0xFF, 0xC9, 0x00,
933 0x13, 0x00, 0x8D, 0xFC, 0xAE, 0x47, 0x3E, 0x0C, 0x56, 0xF9, 0x48,
934 0x04, 0x56, 0xFD, 0x78, 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0x00, 0x00,
935 0x00, 0x00, 0x2B, 0x00, 0x58, 0xFF, 0x83, 0x01, 0x3C, 0xFD, 0x7E,
936 0x04, 0xE6, 0xF8, 0x72, 0x0D, 0x52, 0x47, 0xBE, 0xFB, 0x7A, 0x00,
937 0x90, 0x00, 0x43, 0xFF, 0x8F, 0x00, 0xB7, 0xFF, 0x11, 0x00, 0xFD,
938 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x36, 0xFC, 0xF1, 0x06,
939 0xF5, 0xF2, 0xA7, 0x22, 0xFF, 0x3B, 0xE4, 0xF2, 0x96, 0x05, 0x81,
940 0xFD, 0xFD, 0x00, 0xB5, 0xFF, 0x0B, 0x00, 0x01, 0x00, 0xFE, 0xFF,
941 0x1C, 0x00, 0x86, 0xFF, 0x59, 0x01, 0xEC, 0xFC, 0x6F, 0x06, 0xDC,
942 0xF1, 0x04, 0x37, 0xF3, 0x28, 0xFC, 0xF1, 0x28, 0x07, 0x37, 0xFC,
943 0xD8, 0x01, 0x41, 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x0B, 0x00, 0xD3,
944 0xFF, 0x49, 0x00, 0xD4, 0xFF, 0x88, 0xFF, 0x49, 0x02, 0x4B, 0xF8,
945 0x0D, 0x45, 0x68, 0x13, 0xDF, 0xF6, 0x6C, 0x05, 0xCC, 0xFC, 0xB4,
946 0x01, 0x45, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x23, 0x00,
947 0x74, 0xFF, 0x3A, 0x01, 0xDD, 0xFD, 0x39, 0x03, 0x7B, 0xFB, 0xC1,
948 0x06, 0xC7, 0x48, 0xCF, 0x00, 0x0D, 0xFE, 0xE3, 0x01, 0x8E, 0xFE,
949 0xE7, 0x00, 0x95, 0xFF, 0x1A, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x38,
950 0xFF, 0xDA, 0x01, 0x69, 0xFC, 0x57, 0x06, 0xAF, 0xF4, 0xF5, 0x1A,
951 0x1D, 0x41, 0x11, 0xF5, 0x25, 0x04, 0x6C, 0xFE, 0x74, 0x00, 0xF9,
952 0xFF, 0xF1, 0xFF, 0x05, 0x00, 0xFD, 0xFF, 0x2A, 0x00, 0x5C, 0xFF,
953 0xAA, 0x01, 0x71, 0xFC, 0x07, 0x07, 0x7E, 0xF1, 0x44, 0x30, 0x44,
954 0x30, 0x7E, 0xF1, 0x07, 0x07, 0x71, 0xFC, 0xAA, 0x01, 0x5C, 0xFF,
955 0x2A, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xF1, 0xFF, 0xF9, 0xFF, 0x74,
956 0x00, 0x6C, 0xFE, 0x25, 0x04, 0x11, 0xF5, 0x1D, 0x41, 0xF5, 0x1A,
957 0xAF, 0xF4, 0x57, 0x06, 0x69, 0xFC, 0xDA, 0x01, 0x38, 0xFF, 0x36,
958 0x00, 0xFE, 0xFF, 0x1A, 0x00, 0x95, 0xFF, 0xE7, 0x00, 0x8E, 0xFE,
959 0xE3, 0x01, 0x0D, 0xFE, 0xCF, 0x00, 0xC7, 0x48, 0xC1, 0x06, 0x7B,
960 0xFB, 0x39, 0x03, 0xDD, 0xFD, 0x3A, 0x01, 0x74, 0xFF, 0x23, 0x00,
961 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x45, 0xFF, 0xB4, 0x01, 0xCC,
962 0xFC, 0x6C, 0x05, 0xDF, 0xF6, 0x68, 0x13, 0x0D, 0x45, 0x4B, 0xF8,
963 0x49, 0x02, 0x88, 0xFF, 0xD4, 0xFF, 0x49, 0x00, 0xD3, 0xFF, 0x0B,
964 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x41, 0xFF, 0xD8, 0x01, 0x37, 0xFC,
965 0x28, 0x07, 0xFC, 0xF1, 0xF3, 0x28, 0x04, 0x37, 0xDC, 0xF1, 0x6F,
966 0x06, 0xEC, 0xFC, 0x59, 0x01, 0x86, 0xFF, 0x1C, 0x00, 0xFE, 0xFF,
967 0x01, 0x00, 0x0B, 0x00, 0xB5, 0xFF, 0xFD, 0x00, 0x81, 0xFD, 0x96,
968 0x05, 0xE4, 0xF2, 0xFF, 0x3B, 0xA7, 0x22, 0xF5, 0xF2, 0xF1, 0x06,
969 0x36, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x11,
970 0x00, 0xB7, 0xFF, 0x8F, 0x00, 0x43, 0xFF, 0x90, 0x00, 0x7A, 0x00,
971 0xBE, 0xFB, 0x52, 0x47, 0x72, 0x0D, 0xE6, 0xF8, 0x7E, 0x04, 0x3C,
972 0xFD, 0x83, 0x01, 0x58, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00,
973 0x2A, 0x00, 0x5C, 0xFF, 0x78, 0x01, 0x56, 0xFD, 0x48, 0x04, 0x56,
974 0xF9, 0x3E, 0x0C, 0xAE, 0x47, 0x8D, 0xFC, 0x13, 0x00, 0xC9, 0x00,
975 0x24, 0xFF, 0x9F, 0x00, 0xB1, 0xFF, 0x13, 0x00, 0xFD, 0xFF, 0x36,
976 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3B, 0xFC, 0xDD, 0x06, 0x37, 0xF3,
977 0x52, 0x21, 0xF6, 0x3C, 0x31, 0xF3, 0x5F, 0x05, 0xA6, 0xFD, 0xE8,
978 0x00, 0xC0, 0xFF, 0x07, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1F, 0x00,
979 0x7E, 0xFF, 0x69, 0x01, 0xD2, 0xFC, 0x92, 0x06, 0xBB, 0xF1, 0xE6,
980 0x35, 0x3F, 0x2A, 0xD8, 0xF1, 0x2A, 0x07, 0x3C, 0xFC, 0xD3, 0x01,
981 0x45, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x0A, 0x00, 0xD8, 0xFF, 0x3A,
982 0x00, 0xF1, 0xFF, 0x54, 0xFF, 0xA2, 0x02, 0xA9, 0xF7, 0x77, 0x44,
983 0xB1, 0x14, 0x77, 0xF6, 0x9A, 0x05, 0xB8, 0xFC, 0xBC, 0x01, 0x42,
984 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x21, 0x00, 0x7A, 0xFF,
985 0x2C, 0x01, 0xFB, 0xFD, 0xFE, 0x02, 0xEE, 0xFB, 0xAB, 0x05, 0xE1,
986 0x48, 0xC7, 0x01, 0x9D, 0xFD, 0x1E, 0x02, 0x6F, 0xFE, 0xF5, 0x00,
987 0x8F, 0xFF, 0x1B, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD6,
988 0x01, 0x77, 0xFC, 0x33, 0x06, 0x09, 0xF5, 0xA1, 0x19, 0xE1, 0x41,
989 0x8D, 0xF5, 0xDA, 0x03, 0x9A, 0xFE, 0x5A, 0x00, 0x06, 0x00, 0xEC,
990 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2C, 0x00, 0x56, 0xFF, 0xB4, 0x01,
991 0x62, 0xFC, 0x15, 0x07, 0x84, 0xF1, 0x09, 0x2F, 0x7B, 0x31, 0x7D,
992 0xF1, 0xF5, 0x06, 0x82, 0xFC, 0x9E, 0x01, 0x62, 0xFF, 0x28, 0x00,
993 0xFD, 0xFF, 0x04, 0x00, 0xF6, 0xFF, 0xED, 0xFF, 0x8E, 0x00, 0x3F,
994 0xFE, 0x6D, 0x04, 0x9E, 0xF4, 0x4E, 0x40, 0x49, 0x1C, 0x5A, 0xF4,
995 0x78, 0x06, 0x5C, 0xFC, 0xDF, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE,
996 0xFF, 0x18, 0x00, 0x9B, 0xFF, 0xD8, 0x00, 0xAD, 0xFE, 0xA7, 0x01,
997 0x7D, 0xFE, 0xDD, 0xFF, 0xA1, 0x48, 0xDD, 0x07, 0x07, 0xFB, 0x73,
998 0x03, 0xC0, 0xFD, 0x48, 0x01, 0x6F, 0xFF, 0x24, 0x00, 0x00, 0x00,
999 0xFF, 0xFF, 0x30, 0x00, 0x49, 0xFF, 0xAB, 0x01, 0xE2, 0xFC, 0x3D,
1000 0x05, 0x48, 0xF7, 0x22, 0x12, 0x9B, 0x45, 0xF5, 0xF8, 0xED, 0x01,
1001 0xBE, 0xFF, 0xB6, 0xFF, 0x57, 0x00, 0xCD, 0xFF, 0x0C, 0x00, 0xFD,
1002 0xFF, 0x34, 0x00, 0x3E, 0xFF, 0xDD, 0x01, 0x33, 0xFC, 0x23, 0x07,
1003 0x26, 0xF2, 0xA6, 0x27, 0x1D, 0x38, 0x05, 0xF2, 0x49, 0x06, 0x08,
1004 0xFD, 0x47, 0x01, 0x8F, 0xFF, 0x18, 0x00, 0xFF, 0xFF, 0x00, 0x00,
1005 0x0E, 0x00, 0xAA, 0xFF, 0x12, 0x01, 0x5F, 0xFD, 0xCB, 0x05, 0x9E,
1006 0xF2, 0x03, 0x3B, 0xFC, 0x23, 0xB7, 0xF2, 0x03, 0x07, 0x33, 0xFC,
1007 0xE5, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x10, 0x00, 0xBD,
1008 0xFF, 0x80, 0x00, 0x62, 0xFF, 0x57, 0x00, 0xDF, 0x00, 0xF7, 0xFA,
1009 0xED, 0x46, 0xAA, 0x0E, 0x76, 0xF8, 0xB2, 0x04, 0x23, 0xFD, 0x8F,
1010 0x01, 0x53, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x28, 0x00,
1011 0x61, 0xFF, 0x6C, 0x01, 0x71, 0xFD, 0x11, 0x04, 0xC8, 0xF9, 0x0E,
1012 0x0B, 0xFD, 0x47, 0x63, 0xFD, 0xAA, 0xFF, 0x03, 0x01, 0x05, 0xFF,
1013 0xAE, 0x00, 0xAC, 0xFF, 0x14, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36,
1014 0xFF, 0xE5, 0x01, 0x41, 0xFC, 0xC6, 0x06, 0x7F, 0xF3, 0xFD, 0x1F,
1015 0xE4, 0x3D, 0x87, 0xF3, 0x24, 0x05, 0xCC, 0xFD, 0xD1, 0x00, 0xCB,
1016 0xFF, 0x02, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x21, 0x00, 0x76, 0xFF,
1017 0x79, 0x01, 0xBA, 0xFC, 0xB1, 0x06, 0xA0, 0xF1, 0xC3, 0x34, 0x89,
1018 0x2B, 0xB9, 0xF1, 0x29, 0x07, 0x44, 0xFC, 0xCC, 0x01, 0x49, 0xFF,
1019 0x31, 0x00, 0xFD, 0xFF, 0x09, 0x00, 0xDE, 0xFF, 0x2C, 0x00, 0x0D,
1020 0x00, 0x21, 0xFF, 0xF9, 0x02, 0x0F, 0xF7, 0xD4, 0x43, 0xFD, 0x15,
1021 0x13, 0xF6, 0xC5, 0x05, 0xA5, 0xFC, 0xC4, 0x01, 0x40, 0xFF, 0x33,
1022 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x20, 0x00, 0x7F, 0xFF, 0x1E, 0x01,
1023 0x19, 0xFE, 0xC3, 0x02, 0x61, 0xFC, 0x9B, 0x04, 0xF2, 0x48, 0xC6,
1024 0x02, 0x2C, 0xFD, 0x5A, 0x02, 0x50, 0xFE, 0x04, 0x01, 0x8A, 0xFF,
1025 0x1D, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3B, 0xFF, 0xD0, 0x01, 0x86,
1026 0xFC, 0x0D, 0x06, 0x66, 0xF5, 0x50, 0x18, 0x9E, 0x42, 0x11, 0xF6,
1027 0x8C, 0x03, 0xC9, 0xFE, 0x3F, 0x00, 0x14, 0x00, 0xE7, 0xFF, 0x07,
1028 0x00, 0xFD, 0xFF, 0x2E, 0x00, 0x51, 0xFF, 0xBE, 0x01, 0x56, 0xFC,
1029 0x1F, 0x07, 0x92, 0xF1, 0xCA, 0x2D, 0xAF, 0x32, 0x84, 0xF1, 0xE0,
1030 0x06, 0x94, 0xFC, 0x91, 0x01, 0x69, 0xFF, 0x26, 0x00, 0xFD, 0xFF,
1031 0x03, 0x00, 0xFA, 0xFF, 0xE0, 0xFF, 0xA7, 0x00, 0x15, 0xFE, 0xB2,
1032 0x04, 0x32, 0xF4, 0x77, 0x3F, 0x9E, 0x1D, 0x07, 0xF4, 0x96, 0x06,
1033 0x51, 0xFC, 0xE2, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x17,
1034 0x00, 0xA1, 0xFF, 0xC9, 0x00, 0xCD, 0xFE, 0x6C, 0x01, 0xEA, 0xFE,
1035 0xF3, 0xFE, 0x70, 0x48, 0xFF, 0x08, 0x94, 0xFA, 0xAD, 0x03, 0xA3,
1036 0xFD, 0x55, 0x01, 0x6A, 0xFF, 0x26, 0x00, 0x00, 0x00, 0xFF, 0xFF,
1037 0x2F, 0x00, 0x4C, 0xFF, 0xA1, 0x01, 0xF8, 0xFC, 0x0D, 0x05, 0xB3,
1038 0xF7, 0xDF, 0x10, 0x1D, 0x46, 0xA7, 0xF9, 0x8E, 0x01, 0xF4, 0xFF,
1039 0x98, 0xFF, 0x66, 0x00, 0xC7, 0xFF, 0x0E, 0x00, 0xFD, 0xFF, 0x35,
1040 0x00, 0x3C, 0xFF, 0xE1, 0x01, 0x31, 0xFC, 0x1A, 0x07, 0x56, 0xF2,
1041 0x55, 0x26, 0x2E, 0x39, 0x35, 0xF2, 0x1E, 0x06, 0x25, 0xFD, 0x35,
1042 0x01, 0x98, 0xFF, 0x15, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x12, 0x00,
1043 0xA0, 0xFF, 0x26, 0x01, 0x3E, 0xFD, 0xFB, 0x05, 0x60, 0xF2, 0xFD,
1044 0x39, 0x4E, 0x25, 0x7F, 0xF2, 0x11, 0x07, 0x31, 0xFC, 0xE3, 0x01,
1045 0x3A, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0F, 0x00, 0xC3, 0xFF, 0x71,
1046 0x00, 0x81, 0xFF, 0x1F, 0x00, 0x42, 0x01, 0x37, 0xFA, 0x7C, 0x46,
1047 0xE7, 0x0F, 0x08, 0xF8, 0xE6, 0x04, 0x0B, 0xFD, 0x99, 0x01, 0x4F,
1048 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x66, 0xFF,
1049 0x5F, 0x01, 0x8D, 0xFD, 0xD9, 0x03, 0x3B, 0xFA, 0xE4, 0x09, 0x41,
1050 0x48, 0x41, 0xFE, 0x3F, 0xFF, 0x3E, 0x01, 0xE5, 0xFE, 0xBD, 0x00,
1051 0xA6, 0xFF, 0x16, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4,
1052 0x01, 0x4A, 0xFC, 0xAC, 0x06, 0xCA, 0xF3, 0xA7, 0x1E, 0xCA, 0x3E,
1053 0xE4, 0xF3, 0xE5, 0x04, 0xF4, 0xFD, 0xBA, 0x00, 0xD7, 0xFF, 0xFE,
1054 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x24, 0x00, 0x6E, 0xFF, 0x87, 0x01,
1055 0xA4, 0xFC, 0xCD, 0x06, 0x8E, 0xF1, 0x99, 0x33, 0xCE, 0x2C, 0xA1,
1056 0xF1, 0x25, 0x07, 0x4D, 0xFC, 0xC4, 0x01, 0x4D, 0xFF, 0x2F, 0x00,
1057 0xFD, 0xFF, 0x08, 0x00, 0xE3, 0xFF, 0x1E, 0x00, 0x2A, 0x00, 0xEF,
1058 0xFE, 0x4D, 0x03, 0x7D, 0xF6, 0x2A, 0x43, 0x4B, 0x17, 0xB0, 0xF5,
1059 0xEF, 0x05, 0x93, 0xFC, 0xCB, 0x01, 0x3D, 0xFF, 0x34, 0x00, 0xFE,
1060 0xFF, 0x1E, 0x00, 0x85, 0xFF, 0x10, 0x01, 0x38, 0xFE, 0x88, 0x02,
1061 0xD3, 0xFC, 0x91, 0x03, 0xF7, 0x48, 0xCB, 0x03, 0xBA, 0xFC, 0x95,
1062 0x02, 0x31, 0xFE, 0x13, 0x01, 0x84, 0xFF, 0x1E, 0x00, 0x00, 0x00,
1063 0xFE, 0xFF, 0x34, 0x00, 0x3E, 0xFF, 0xC9, 0x01, 0x97, 0xFC, 0xE6,
1064 0x05, 0xC6, 0xF5, 0x00, 0x17, 0x50, 0x43, 0x9D, 0xF6, 0x3A, 0x03,
1065 0xFA, 0xFE, 0x23, 0x00, 0x21, 0x00, 0xE2, 0xFF, 0x08, 0x00, 0xFD,
1066 0xFF, 0x30, 0x00, 0x4C, 0xFF, 0xC6, 0x01, 0x4B, 0xFC, 0x26, 0x07,
1067 0xA5, 0xF1, 0x87, 0x2C, 0xDC, 0x33, 0x91, 0xF1, 0xC7, 0x06, 0xA9,
1068 0xFC, 0x84, 0x01, 0x70, 0xFF, 0x23, 0x00, 0xFE, 0xFF, 0x03, 0x00,
1069 0xFF, 0xFF, 0xD4, 0xFF, 0xBF, 0x00, 0xEB, 0xFD, 0xF3, 0x04, 0xCF,
1070 0xF3, 0x98, 0x3E, 0xF3, 0x1E, 0xB9, 0xF3, 0xB2, 0x06, 0x48, 0xFC,
1071 0xE4, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x15, 0x00, 0xA7,
1072 0xFF, 0xB9, 0x00, 0xEC, 0xFE, 0x31, 0x01, 0x57, 0xFF, 0x0F, 0xFE,
1073 0x33, 0x48, 0x25, 0x0A, 0x21, 0xFA, 0xE5, 0x03, 0x87, 0xFD, 0x62,
1074 0x01, 0x65, 0xFF, 0x27, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2E, 0x00,
1075 0x50, 0xFF, 0x97, 0x01, 0x10, 0xFD, 0xDA, 0x04, 0x20, 0xF8, 0xA0,
1076 0x0F, 0x97, 0x46, 0x61, 0xFA, 0x2D, 0x01, 0x2B, 0x00, 0x7A, 0xFF,
1077 0x75, 0x00, 0xC2, 0xFF, 0x0F, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x3A,
1078 0xFF, 0xE4, 0x01, 0x32, 0xFC, 0x0E, 0x07, 0x8B, 0xF2, 0x03, 0x25,
1079 0x38, 0x3A, 0x6D, 0xF2, 0xF1, 0x05, 0x45, 0xFD, 0x22, 0x01, 0xA2,
1080 0xFF, 0x11, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x16, 0x00, 0x96, 0xFF,
1081 0x39, 0x01, 0x1F, 0xFD, 0x28, 0x06, 0x2A, 0xF2, 0xF2, 0x38, 0xA0,
1082 0x26, 0x4B, 0xF2, 0x1C, 0x07, 0x32, 0xFC, 0xE0, 0x01, 0x3C, 0xFF,
1083 0x35, 0x00, 0xFD, 0xFF, 0x0D, 0x00, 0xC9, 0xFF, 0x63, 0x00, 0x9F,
1084 0xFF, 0xE8, 0xFF, 0xA3, 0x01, 0x7F, 0xF9, 0x02, 0x46, 0x27, 0x11,
1085 0x9B, 0xF7, 0x18, 0x05, 0xF3, 0xFC, 0xA3, 0x01, 0x4C, 0xFF, 0x2F,
1086 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6B, 0xFF, 0x52, 0x01,
1087 0xA9, 0xFD, 0xA0, 0x03, 0xAE, 0xFA, 0xBE, 0x08, 0x7C, 0x48, 0x26,
1088 0xFF, 0xD2, 0xFE, 0x79, 0x01, 0xC6, 0xFE, 0xCC, 0x00, 0xA0, 0xFF,
1089 0x17, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE1, 0x01, 0x53,
1090 0xFC, 0x90, 0x06, 0x19, 0xF4, 0x52, 0x1D, 0xA8, 0x3F, 0x49, 0xF4,
1091 0xA3, 0x04, 0x1E, 0xFE, 0xA1, 0x00, 0xE3, 0xFF, 0xF9, 0xFF, 0x04,
1092 0x00, 0xFD, 0xFF, 0x26, 0x00, 0x67, 0xFF, 0x94, 0x01, 0x90, 0xFC,
1093 0xE5, 0x06, 0x81, 0xF1, 0x6B, 0x32, 0x11, 0x2E, 0x8E, 0xF1, 0x1D,
1094 0x07, 0x58, 0xFC, 0xBC, 0x01, 0x52, 0xFF, 0x2E, 0x00, 0xFD, 0xFF,
1095 0x07, 0x00, 0xE8, 0xFF, 0x11, 0x00, 0x45, 0x00, 0xBF, 0xFE, 0x9D,
1096 0x03, 0xF3, 0xF5, 0x75, 0x42, 0x9B, 0x18, 0x51, 0xF5, 0x16, 0x06,
1097 0x83, 0xFC, 0xD1, 0x01, 0x3B, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x1D,
1098 0x00, 0x8B, 0xFF, 0x01, 0x01, 0x56, 0xFE, 0x4D, 0x02, 0x45, 0xFD,
1099 0x8D, 0x02, 0xF0, 0x48, 0xD7, 0x04, 0x47, 0xFC, 0xD1, 0x02, 0x12,
1100 0xFE, 0x21, 0x01, 0x7E, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF,
1101 0x33, 0x00, 0x40, 0xFF, 0xC2, 0x01, 0xA9, 0xFC, 0xBC, 0x05, 0x29,
1102 0xF6, 0xB3, 0x15, 0xFA, 0x43, 0x31, 0xF7, 0xE6, 0x02, 0x2C, 0xFF,
1103 0x07, 0x00, 0x2F, 0x00, 0xDC, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x31,
1104 0x00, 0x48, 0xFF, 0xCE, 0x01, 0x42, 0xFC, 0x2A, 0x07, 0xBF, 0xF1,
1105 0x40, 0x2B, 0x05, 0x35, 0xA6, 0xF1, 0xAB, 0x06, 0xBF, 0xFC, 0x75,
1106 0x01, 0x77, 0xFF, 0x21, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x03, 0x00,
1107 0xC8, 0xFF, 0xD6, 0x00, 0xC4, 0xFD, 0x31, 0x05, 0x73, 0xF3, 0xB0,
1108 0x3D, 0x49, 0x20, 0x6E, 0xF3, 0xCB, 0x06, 0x40, 0xFC, 0xE6, 0x01,
1109 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x14, 0x00, 0xAD, 0xFF, 0xAA,
1110 0x00, 0x0C, 0xFF, 0xF7, 0x00, 0xC1, 0xFF, 0x33, 0xFD, 0xEC, 0x47,
1111 0x51, 0x0B, 0xAF, 0xF9, 0x1D, 0x04, 0x6B, 0xFD, 0x6E, 0x01, 0x60,
1112 0xFF, 0x29, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2C, 0x00, 0x54, 0xFF,
1113 0x8C, 0x01, 0x29, 0xFD, 0xA7, 0x04, 0x8F, 0xF8, 0x64, 0x0E, 0x02,
1114 0x47, 0x22, 0xFB, 0xC9, 0x00, 0x64, 0x00, 0x5B, 0xFF, 0x84, 0x00,
1115 0xBC, 0xFF, 0x10, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE5,
1116 0x01, 0x33, 0xFC, 0xFF, 0x06, 0xC4, 0xF2, 0xB0, 0x23, 0x3B, 0x3B,
1117 0xAD, 0xF2, 0xBF, 0x05, 0x66, 0xFD, 0x0E, 0x01, 0xAC, 0xFF, 0x0E,
1118 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x19, 0x00, 0x8D, 0xFF, 0x4B, 0x01,
1119 0x01, 0xFD, 0x51, 0x06, 0xFB, 0xF1, 0xDF, 0x37, 0xF0, 0x27, 0x1C,
1120 0xF2, 0x24, 0x07, 0x34, 0xFC, 0xDC, 0x01, 0x3F, 0xFF, 0x34, 0x00,
1121 0xFD, 0xFF, 0x0C, 0x00, 0xCE, 0xFF, 0x54, 0x00, 0xBD, 0xFF, 0xB2,
1122 0xFF, 0x01, 0x02, 0xCF, 0xF8, 0x7D, 0x45, 0x6B, 0x12, 0x30, 0xF7,
1123 0x48, 0x05, 0xDD, 0xFC, 0xAD, 0x01, 0x48, 0xFF, 0x30, 0x00, 0xFF,
1124 0xFF, 0x00, 0x00, 0x24, 0x00, 0x70, 0xFF, 0x45, 0x01, 0xC6, 0xFD,
1125 0x66, 0x03, 0x21, 0xFB, 0x9E, 0x07, 0xAA, 0x48, 0x12, 0x00, 0x64,
1126 0xFE, 0xB4, 0x01, 0xA6, 0xFE, 0xDB, 0x00, 0x9A, 0xFF, 0x19, 0x00,
1127 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xDE, 0x01, 0x5F, 0xFC, 0x70,
1128 0x06, 0x6C, 0xF4, 0xFD, 0x1B, 0x7D, 0x40, 0xB7, 0xF4, 0x5D, 0x04,
1129 0x49, 0xFE, 0x88, 0x00, 0xEF, 0xFF, 0xF5, 0xFF, 0x04, 0x00, 0xFD,
1130 0xFF, 0x29, 0x00, 0x61, 0xFF, 0xA1, 0x01, 0x7E, 0xFC, 0xF9, 0x06,
1131 0x7C, 0xF1, 0x38, 0x31, 0x50, 0x2F, 0x82, 0xF1, 0x12, 0x07, 0x65,
1132 0xFC, 0xB2, 0x01, 0x57, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0x06, 0x00,
1133 0xED, 0xFF, 0x04, 0x00, 0x60, 0x00, 0x90, 0xFE, 0xEB, 0x03, 0x71,
1134 0xF5, 0xB7, 0x41, 0xED, 0x19, 0xF5, 0xF4, 0x3B, 0x06, 0x73, 0xFC,
1135 0xD7, 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x91,
1136 0xFF, 0xF2, 0x00, 0x76, 0xFE, 0x11, 0x02, 0xB6, 0xFD, 0x8F, 0x01,
1137 0xDE, 0x48, 0xE9, 0x05, 0xD4, 0xFB, 0x0C, 0x03, 0xF4, 0xFD, 0x2F,
1138 0x01, 0x79, 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x32, 0x00,
1139 0x43, 0xFF, 0xBA, 0x01, 0xBC, 0xFC, 0x90, 0x05, 0x8E, 0xF6, 0x68,
1140 0x14, 0x99, 0x44, 0xCD, 0xF7, 0x8F, 0x02, 0x60, 0xFF, 0xEA, 0xFF,
1141 0x3E, 0x00, 0xD7, 0xFF, 0x0A, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x44,
1142 0xFF, 0xD4, 0x01, 0x3B, 0xFC, 0x2A, 0x07, 0xDF, 0xF1, 0xF6, 0x29,
1143 0x27, 0x36, 0xC1, 0xF1, 0x8B, 0x06, 0xD8, 0xFC, 0x66, 0x01, 0x80,
1144 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x07, 0x00, 0xBD, 0xFF,
1145 0xED, 0x00, 0x9E, 0xFD, 0x6C, 0x05, 0x1F, 0xF3, 0xC0, 0x3C, 0x9E,
1146 0x21, 0x28, 0xF3, 0xE2, 0x06, 0x3A, 0xFC, 0xE6, 0x01, 0x37, 0xFF,
1147 0x36, 0x00, 0xFD, 0xFF, 0x12, 0x00, 0xB3, 0xFF, 0x9B, 0x00, 0x2B,
1148 0xFF, 0xBD, 0x00, 0x2A, 0x00, 0x5E, 0xFC, 0x9A, 0x47, 0x82, 0x0C,
1149 0x3D, 0xF9, 0x54, 0x04, 0x50, 0xFD, 0x7A, 0x01, 0x5B, 0xFF, 0x2A,
1150 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x59, 0xFF, 0x81, 0x01,
1151 0x42, 0xFD, 0x72, 0x04, 0xFF, 0xF8, 0x2D, 0x0D, 0x69, 0x47, 0xEB,
1152 0xFB, 0x63, 0x00, 0x9D, 0x00, 0x3C, 0xFF, 0x93, 0x00, 0xB6, 0xFF,
1153 0x12, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x37,
1154 0xFC, 0xED, 0x06, 0x03, 0xF3, 0x5B, 0x22, 0x37, 0x3C, 0xF4, 0xF2,
1155 0x8A, 0x05, 0x89, 0xFD, 0xF9, 0x00, 0xB7, 0xFF, 0x0A, 0x00, 0x01,
1156 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x84, 0xFF, 0x5C, 0x01, 0xE6, 0xFC,
1157 0x77, 0x06, 0xD4, 0xF1, 0xC6, 0x36, 0x3E, 0x29, 0xF3, 0xF1, 0x29,
1158 0x07, 0x38, 0xFC, 0xD7, 0x01, 0x42, 0xFF, 0x33, 0x00, 0xFD, 0xFF,
1159 0x0B, 0x00, 0xD4, 0xFF, 0x46, 0x00, 0xDA, 0xFF, 0x7D, 0xFF, 0x5D,
1160 0x02, 0x26, 0xF8, 0xED, 0x44, 0xB1, 0x13, 0xC7, 0xF6, 0x77, 0x05,
1161 0xC8, 0xFC, 0xB6, 0x01, 0x45, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x00,
1162 0x00, 0x22, 0x00, 0x76, 0xFF, 0x37, 0x01, 0xE4, 0xFD, 0x2C, 0x03,
1163 0x94, 0xFB, 0x83, 0x06, 0xCE, 0x48, 0x05, 0x01, 0xF5, 0xFD, 0xF0,
1164 0x01, 0x87, 0xFE, 0xEA, 0x00, 0x94, 0xFF, 0x1A, 0x00, 0xFE, 0xFF,
1165 0x35, 0x00, 0x38, 0xFF, 0xD9, 0x01, 0x6C, 0xFC, 0x4F, 0x06, 0xC3,
1166 0xF4, 0xA9, 0x1A, 0x49, 0x41, 0x2C, 0xF5, 0x15, 0x04, 0x76, 0xFE,
1167 0x6E, 0x00, 0xFC, 0xFF, 0xF0, 0xFF, 0x05, 0x00, 0xFD, 0xFF, 0x2B,
1168 0x00, 0x5A, 0xFF, 0xAC, 0x01, 0x6E, 0xFC, 0x0A, 0x07, 0x7E, 0xF1,
1169 0xFF, 0x2F, 0x8A, 0x30, 0x7D, 0xF1, 0x03, 0x07, 0x75, 0xFC, 0xA7,
1170 0x01, 0x5D, 0xFF, 0x2A, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xF2, 0xFF,
1171 0xF7, 0xFF, 0x7A, 0x00, 0x62, 0xFE, 0x35, 0x04, 0xF7, 0xF4, 0xEF,
1172 0x40, 0x40, 0x1B, 0x9C, 0xF4, 0x5E, 0x06, 0x66, 0xFC, 0xDB, 0x01,
1173 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x1A, 0x00, 0x96, 0xFF, 0xE3,
1174 0x00, 0x95, 0xFE, 0xD5, 0x01, 0x26, 0xFE, 0x98, 0x00, 0xBF, 0x48,
1175 0x00, 0x07, 0x61, 0xFB, 0x46, 0x03, 0xD6, 0xFD, 0x3D, 0x01, 0x73,
1176 0xFF, 0x23, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x46, 0xFF,
1177 0xB2, 0x01, 0xD1, 0xFC, 0x62, 0x05, 0xF6, 0xF6, 0x20, 0x13, 0x2E,
1178 0x45, 0x70, 0xF8, 0x34, 0x02, 0x94, 0xFF, 0xCD, 0xFF, 0x4C, 0x00,
1179 0xD2, 0xFF, 0x0B, 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x41, 0xFF, 0xDA,
1180 0x01, 0x36, 0xFC, 0x27, 0x07, 0x05, 0xF2, 0xAA, 0x28, 0x44, 0x37,
1181 0xE4, 0xF1, 0x67, 0x06, 0xF2, 0xFC, 0x55, 0x01, 0x88, 0xFF, 0x1B,
1182 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x0B, 0x00, 0xB2, 0xFF, 0x02, 0x01,
1183 0x7A, 0xFD, 0xA2, 0x05, 0xD4, 0xF2, 0xC7, 0x3B, 0xF2, 0x22, 0xE7,
1184 0xF2, 0xF5, 0x06, 0x35, 0xFC, 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00,
1185 0xFD, 0xFF, 0x11, 0x00, 0xB9, 0xFF, 0x8C, 0x00, 0x4A, 0xFF, 0x83,
1186 0x00, 0x91, 0x00, 0x91, 0xFB, 0x3D, 0x47, 0xB7, 0x0D, 0xCD, 0xF8,
1187 0x89, 0x04, 0x36, 0xFD, 0x86, 0x01, 0x57, 0xFF, 0x2B, 0x00, 0x00,
1188 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5D, 0xFF, 0x75, 0x01, 0x5C, 0xFD,
1189 0x3C, 0x04, 0x70, 0xF9, 0xFA, 0x0B, 0xC0, 0x47, 0xBC, 0xFC, 0xFC,
1190 0xFF, 0xD6, 0x00, 0x1D, 0xFF, 0xA2, 0x00, 0xB0, 0xFF, 0x13, 0x00,
1191 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3C, 0xFC, 0xD8,
1192 0x06, 0x47, 0xF3, 0x06, 0x21, 0x2A, 0x3D, 0x44, 0xF3, 0x52, 0x05,
1193 0xAE, 0xFD, 0xE3, 0x00, 0xC2, 0xFF, 0x06, 0x00, 0x01, 0x00, 0xFE,
1194 0xFF, 0x1F, 0x00, 0x7C, 0xFF, 0x6D, 0x01, 0xCD, 0xFC, 0x99, 0x06,
1195 0xB4, 0xF1, 0xA6, 0x35, 0x89, 0x2A, 0xD0, 0xF1, 0x2B, 0x07, 0x3E,
1196 0xFC, 0xD1, 0x01, 0x46, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x0A, 0x00,
1197 0xD9, 0xFF, 0x37, 0x00, 0xF7, 0xFF, 0x49, 0xFF, 0xB6, 0x02, 0x86,
1198 0xF7, 0x53, 0x44, 0xFB, 0x14, 0x61, 0xF6, 0xA4, 0x05, 0xB4, 0xFC,
1199 0xBE, 0x01, 0x42, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x21,
1200 0x00, 0x7B, 0xFF, 0x29, 0x01, 0x01, 0xFE, 0xF1, 0x02, 0x07, 0xFC,
1201 0x6E, 0x05, 0xE6, 0x48, 0xFF, 0x01, 0x84, 0xFD, 0x2C, 0x02, 0x68,
1202 0xFE, 0xF9, 0x00, 0x8E, 0xFF, 0x1C, 0x00, 0xFE, 0xFF, 0x35, 0x00,
1203 0x3A, 0xFF, 0xD4, 0x01, 0x7A, 0xFC, 0x2B, 0x06, 0x1E, 0xF5, 0x56,
1204 0x19, 0x0C, 0x42, 0xAA, 0xF5, 0xC9, 0x03, 0xA4, 0xFE, 0x54, 0x00,
1205 0x09, 0x00, 0xEB, 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2D, 0x00, 0x55,
1206 0xFF, 0xB6, 0x01, 0x5F, 0xFC, 0x17, 0x07, 0x87, 0xF1, 0xC2, 0x2E,
1207 0xC0, 0x31, 0x7E, 0xF1, 0xF1, 0x06, 0x86, 0xFC, 0x9B, 0x01, 0x63,
1208 0xFF, 0x28, 0x00, 0xFD, 0xFF, 0x04, 0x00, 0xF7, 0xFF, 0xEA, 0xFF,
1209 0x93, 0x00, 0x36, 0xFE, 0x7D, 0x04, 0x85, 0xF4, 0x1F, 0x40, 0x94,
1210 0x1C, 0x47, 0xF4, 0x7E, 0x06, 0x5A, 0xFC, 0xDF, 0x01, 0x37, 0xFF,
1211 0x36, 0x00, 0xFE, 0xFF, 0x18, 0x00, 0x9C, 0xFF, 0xD4, 0x00, 0xB4,
1212 0xFE, 0x9A, 0x01, 0x95, 0xFE, 0xA8, 0xFF, 0x98, 0x48, 0x1D, 0x08,
1213 0xEE, 0xFA, 0x80, 0x03, 0xB9, 0xFD, 0x4B, 0x01, 0x6E, 0xFF, 0x25,
1214 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0x00, 0x4A, 0xFF, 0xA9, 0x01,
1215 0xE7, 0xFC, 0x33, 0x05, 0x60, 0xF7, 0xDA, 0x11, 0xB8, 0x45, 0x1C,
1216 0xF9, 0xD8, 0x01, 0xCA, 0xFF, 0xAF, 0xFF, 0x5A, 0x00, 0xCC, 0xFF,
1217 0x0D, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x3E, 0xFF, 0xDE, 0x01, 0x33,
1218 0xFC, 0x21, 0x07, 0x30, 0xF2, 0x5C, 0x27, 0x5B, 0x38, 0x0F, 0xF2,
1219 0x40, 0x06, 0x0E, 0xFD, 0x43, 0x01, 0x91, 0xFF, 0x18, 0x00, 0xFF,
1220 0xFF, 0x00, 0x00, 0x0F, 0x00, 0xA8, 0xFF, 0x17, 0x01, 0x57, 0xFD,
1221 0xD6, 0x05, 0x90, 0xF2, 0xC8, 0x3A, 0x46, 0x24, 0xAA, 0xF2, 0x06,
1222 0x07, 0x32, 0xFC, 0xE5, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
1223 0x10, 0x00, 0xBE, 0xFF, 0x7D, 0x00, 0x69, 0xFF, 0x4B, 0x00, 0xF6,
1224 0x00, 0xCB, 0xFA, 0xD3, 0x46, 0xF0, 0x0E, 0x5E, 0xF8, 0xBE, 0x04,
1225 0x1E, 0xFD, 0x91, 0x01, 0x52, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x00,
1226 0x00, 0x28, 0x00, 0x62, 0xFF, 0x69, 0x01, 0x77, 0xFD, 0x04, 0x04,
1227 0xE2, 0xF9, 0xCB, 0x0A, 0x0D, 0x48, 0x94, 0xFD, 0x92, 0xFF, 0x10,
1228 0x01, 0xFE, 0xFE, 0xB1, 0x00, 0xAA, 0xFF, 0x15, 0x00, 0xFD, 0xFF,
1229 0x36, 0x00, 0x36, 0xFF, 0xE5, 0x01, 0x43, 0xFC, 0xC0, 0x06, 0x8F,
1230 0xF3, 0xB1, 0x1F, 0x18, 0x3E, 0x9B, 0xF3, 0x16, 0x05, 0xD5, 0xFD,
1231 0xCC, 0x00, 0xCE, 0xFF, 0x01, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x22,
1232 0x00, 0x74, 0xFF, 0x7C, 0x01, 0xB5, 0xFC, 0xB8, 0x06, 0x9C, 0xF1,
1233 0x81, 0x34, 0xD1, 0x2B, 0xB3, 0xF1, 0x29, 0x07, 0x46, 0xFC, 0xCA,
1234 0x01, 0x4A, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x09, 0x00, 0xDF, 0xFF,
1235 0x29, 0x00, 0x14, 0x00, 0x16, 0xFF, 0x0C, 0x03, 0xEE, 0xF6, 0xB0,
1236 0x43, 0x47, 0x16, 0xFC, 0xF5, 0xCF, 0x05, 0xA1, 0xFC, 0xC6, 0x01,
1237 0x3F, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x81,
1238 0xFF, 0x1B, 0x01, 0x20, 0xFE, 0xB6, 0x02, 0x7A, 0xFC, 0x5F, 0x04,
1239 0xF4, 0x48, 0xFF, 0x02, 0x13, 0xFD, 0x67, 0x02, 0x49, 0xFE, 0x07,
1240 0x01, 0x88, 0xFF, 0x1D, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3C, 0xFF,
1241 0xCF, 0x01, 0x8A, 0xFC, 0x05, 0x06, 0x7B, 0xF5, 0x06, 0x18, 0xC7,
1242 0x42, 0x2F, 0xF6, 0x7A, 0x03, 0xD4, 0xFE, 0x39, 0x00, 0x17, 0x00,
1243 0xE6, 0xFF, 0x07, 0x00, 0xFD, 0xFF, 0x2E, 0x00, 0x50, 0xFF, 0xC0,
1244 0x01, 0x53, 0xFC, 0x21, 0x07, 0x96, 0xF1, 0x82, 0x2D, 0xF2, 0x32,
1245 0x86, 0xF1, 0xDB, 0x06, 0x99, 0xFC, 0x8E, 0x01, 0x6A, 0xFF, 0x25,
1246 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFB, 0xFF, 0xDE, 0xFF, 0xAC, 0x00,
1247 0x0B, 0xFE, 0xC1, 0x04, 0x1B, 0xF4, 0x47, 0x3F, 0xEA, 0x1D, 0xF5,
1248 0xF3, 0x9C, 0x06, 0x4F, 0xFC, 0xE2, 0x01, 0x36, 0xFF, 0x36, 0x00,
1249 0xFE, 0xFF, 0x16, 0x00, 0xA2, 0xFF, 0xC5, 0x00, 0xD4, 0xFE, 0x5F,
1250 0x01, 0x03, 0xFF, 0xBF, 0xFE, 0x63, 0x48, 0x40, 0x09, 0x7B, 0xFA,
1251 0xB9, 0x03, 0x9D, 0xFD, 0x58, 0x01, 0x69, 0xFF, 0x26, 0x00, 0x00,
1252 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x4D, 0xFF, 0x9F, 0x01, 0xFE, 0xFC,
1253 0x02, 0x05, 0xCB, 0xF7, 0x98, 0x10, 0x39, 0x46, 0xD0, 0xF9, 0x78,
1254 0x01, 0x00, 0x00, 0x91, 0xFF, 0x69, 0x00, 0xC6, 0xFF, 0x0E, 0x00,
1255 0xFD, 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xE2, 0x01, 0x31, 0xFC, 0x17,
1256 0x07, 0x61, 0xF2, 0x0A, 0x26, 0x6A, 0x39, 0x41, 0xF2, 0x15, 0x06,
1257 0x2C, 0xFD, 0x31, 0x01, 0x9B, 0xFF, 0x14, 0x00, 0xFF, 0xFF, 0xFF,
1258 0xFF, 0x13, 0x00, 0x9E, 0xFF, 0x2B, 0x01, 0x37, 0xFD, 0x05, 0x06,
1259 0x54, 0xF2, 0xC2, 0x39, 0x99, 0x25, 0x73, 0xF2, 0x14, 0x07, 0x31,
1260 0xFC, 0xE3, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0E, 0x00,
1261 0xC4, 0xFF, 0x6E, 0x00, 0x87, 0xFF, 0x13, 0x00, 0x58, 0x01, 0x0D,
1262 0xFA, 0x61, 0x46, 0x2D, 0x10, 0xF0, 0xF7, 0xF1, 0x04, 0x05, 0xFD,
1263 0x9C, 0x01, 0x4E, 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x27,
1264 0x00, 0x67, 0xFF, 0x5C, 0x01, 0x93, 0xFD, 0xCC, 0x03, 0x54, 0xFA,
1265 0xA2, 0x09, 0x4F, 0x48, 0x73, 0xFE, 0x27, 0xFF, 0x4B, 0x01, 0xDE,
1266 0xFE, 0xC0, 0x00, 0xA4, 0xFF, 0x16, 0x00, 0xFE, 0xFF, 0x36, 0x00,
1267 0x36, 0xFF, 0xE3, 0x01, 0x4C, 0xFC, 0xA6, 0x06, 0xDB, 0xF3, 0x5B,
1268 0x1E, 0xFC, 0x3E, 0xFA, 0xF3, 0xD7, 0x04, 0xFD, 0xFD, 0xB4, 0x00,
1269 0xD9, 0xFF, 0xFD, 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x25, 0x00, 0x6D,
1270 0xFF, 0x8A, 0x01, 0x9F, 0xFC, 0xD3, 0x06, 0x8A, 0xF1, 0x57, 0x33,
1271 0x17, 0x2D, 0x9C, 0xF1, 0x24, 0x07, 0x4F, 0xFC, 0xC3, 0x01, 0x4E,
1272 0xFF, 0x2F, 0x00, 0xFD, 0xFF, 0x08, 0x00, 0xE4, 0xFF, 0x1B, 0x00,
1273 0x30, 0x00, 0xE4, 0xFE, 0x5F, 0x03, 0x5E, 0xF6, 0x02, 0x43, 0x96,
1274 0x17, 0x9B, 0xF5, 0xF8, 0x05, 0x8F, 0xFC, 0xCC, 0x01, 0x3D, 0xFF,
1275 0x34, 0x00, 0xFE, 0xFF, 0x1E, 0x00, 0x86, 0xFF, 0x0C, 0x01, 0x3E,
1276 0xFE, 0x7B, 0x02, 0xED, 0xFC, 0x56, 0x03, 0xF5, 0x48, 0x06, 0x04,
1277 0xA1, 0xFC, 0xA3, 0x02, 0x2A, 0xFE, 0x16, 0x01, 0x83, 0xFF, 0x1F,
1278 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x3E, 0xFF, 0xC8, 0x01,
1279 0x9B, 0xFC, 0xDD, 0x05, 0xDC, 0xF5, 0xB6, 0x16, 0x77, 0x43, 0xBD,
1280 0xF6, 0x28, 0x03, 0x05, 0xFF, 0x1D, 0x00, 0x25, 0x00, 0xE1, 0xFF,
1281 0x08, 0x00, 0xFD, 0xFF, 0x30, 0x00, 0x4B, 0xFF, 0xC8, 0x01, 0x49,
1282 0xFC, 0x27, 0x07, 0xAB, 0xF1, 0x3E, 0x2C, 0x1E, 0x34, 0x95, 0xF1,
1283 0xC1, 0x06, 0xAE, 0xFC, 0x81, 0x01, 0x71, 0xFF, 0x23, 0x00, 0xFE,
1284 0xFF, 0x02, 0x00, 0x00, 0x00, 0xD2, 0xFF, 0xC4, 0x00, 0xE2, 0xFD,
1285 0x01, 0x05, 0xBA, 0xF3, 0x64, 0x3E, 0x3F, 0x1F, 0xA8, 0xF3, 0xB8,
1286 0x06, 0x46, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
1287 0x15, 0x00, 0xA8, 0xFF, 0xB6, 0x00, 0xF3, 0xFE, 0x24, 0x01, 0x6E,
1288 0xFF, 0xDE, 0xFD, 0x25, 0x48, 0x68, 0x0A, 0x08, 0xFA, 0xF2, 0x03,
1289 0x81, 0xFD, 0x65, 0x01, 0x64, 0xFF, 0x28, 0x00, 0x00, 0x00, 0xFF,
1290 0xFF, 0x2D, 0x00, 0x51, 0xFF, 0x95, 0x01, 0x15, 0xFD, 0xCF, 0x04,
1291 0x39, 0xF8, 0x59, 0x0F, 0xAF, 0x46, 0x8B, 0xFA, 0x17, 0x01, 0x38,
1292 0x00, 0x73, 0xFF, 0x78, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0xFD, 0xFF,
1293 0x36, 0x00, 0x39, 0xFF, 0xE4, 0x01, 0x32, 0xFC, 0x0B, 0x07, 0x97,
1294 0xF2, 0xB8, 0x24, 0x71, 0x3A, 0x7B, 0xF2, 0xE6, 0x05, 0x4C, 0xFD,
1295 0x1D, 0x01, 0xA4, 0xFF, 0x11, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x16,
1296 0x00, 0x94, 0xFF, 0x3D, 0x01, 0x18, 0xFD, 0x32, 0x06, 0x1F, 0xF2,
1297 0xB5, 0x38, 0xEB, 0x26, 0x40, 0xF2, 0x1E, 0x07, 0x32, 0xFC, 0xDF,
1298 0x01, 0x3D, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0D, 0x00, 0xCA, 0xFF,
1299 0x5F, 0x00, 0xA5, 0xFF, 0xDC, 0xFF, 0xB8, 0x01, 0x57, 0xF9, 0xE5,
1300 0x45, 0x6E, 0x11, 0x83, 0xF7, 0x23, 0x05, 0xEE, 0xFC, 0xA6, 0x01,
1301 0x4B, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6C,
1302 0xFF, 0x4F, 0x01, 0xB0, 0xFD, 0x93, 0x03, 0xC7, 0xFA, 0x7D, 0x08,
1303 0x86, 0x48, 0x5A, 0xFF, 0xBA, 0xFE, 0x86, 0x01, 0xBF, 0xFE, 0xCF,
1304 0x00, 0x9E, 0xFF, 0x17, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF,
1305 0xE0, 0x01, 0x56, 0xFC, 0x89, 0x06, 0x2B, 0xF4, 0x06, 0x1D, 0xD7,
1306 0x3F, 0x61, 0xF4, 0x94, 0x04, 0x27, 0xFE, 0x9C, 0x00, 0xE6, 0xFF,
1307 0xF8, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x27, 0x00, 0x66, 0xFF, 0x97,
1308 0x01, 0x8C, 0xFC, 0xEA, 0x06, 0x80, 0xF1, 0x26, 0x32, 0x58, 0x2E,
1309 0x8B, 0xF1, 0x1B, 0x07, 0x5B, 0xFC, 0xBA, 0x01, 0x53, 0xFF, 0x2D,
1310 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE9, 0xFF, 0x0E, 0x00, 0x4B, 0x00,
1311 0xB4, 0xFE, 0xAF, 0x03, 0xD5, 0xF5, 0x4D, 0x42, 0xE6, 0x18, 0x3C,
1312 0xF5, 0x1F, 0x06, 0x7F, 0xFC, 0xD3, 0x01, 0x3B, 0xFF, 0x35, 0x00,
1313 0xFE, 0xFF, 0x1C, 0x00, 0x8C, 0xFF, 0xFE, 0x00, 0x5D, 0xFE, 0x3F,
1314 0x02, 0x5E, 0xFD, 0x54, 0x02, 0xEC, 0x48, 0x13, 0x05, 0x2E, 0xFC,
1315 0xDE, 0x02, 0x0C, 0xFE, 0x24, 0x01, 0x7D, 0xFF, 0x20, 0x00, 0x00,
1316 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x41, 0xFF, 0xC1, 0x01, 0xAD, 0xFC,
1317 0xB2, 0x05, 0x3F, 0xF6, 0x69, 0x15, 0x1F, 0x44, 0x53, 0xF7, 0xD3,
1318 0x02, 0x38, 0xFF, 0x01, 0x00, 0x33, 0x00, 0xDB, 0xFF, 0x09, 0x00,
1319 0xFD, 0xFF, 0x31, 0x00, 0x47, 0xFF, 0xCF, 0x01, 0x40, 0xFC, 0x2A,
1320 0x07, 0xC6, 0xF1, 0xF7, 0x2A, 0x46, 0x35, 0xAB, 0xF1, 0xA4, 0x06,
1321 0xC4, 0xFC, 0x72, 0x01, 0x79, 0xFF, 0x20, 0x00, 0xFE, 0xFF, 0x02,
1322 0x00, 0x04, 0x00, 0xC6, 0xFF, 0xDB, 0x00, 0xBB, 0xFD, 0x3E, 0x05,
1323 0x60, 0xF3, 0x7B, 0x3D, 0x94, 0x20, 0x5E, 0xF3, 0xD0, 0x06, 0x3E,
1324 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x14, 0x00,
1325 0xAE, 0xFF, 0xA7, 0x00, 0x12, 0xFF, 0xEA, 0x00, 0xD9, 0xFF, 0x03,
1326 0xFD, 0xDC, 0x47, 0x95, 0x0B, 0x96, 0xF9, 0x29, 0x04, 0x65, 0xFD,
1327 0x71, 0x01, 0x5F, 0xFF, 0x29, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2C,
1328 0x00, 0x55, 0xFF, 0x8A, 0x01, 0x2E, 0xFD, 0x9B, 0x04, 0xA8, 0xF8,
1329 0x1F, 0x0E, 0x1A, 0x47, 0x4E, 0xFB, 0xB3, 0x00, 0x70, 0x00, 0x54,
1330 0xFF, 0x87, 0x00, 0xBB, 0xFF, 0x11, 0x00, 0xFD, 0xFF, 0x36, 0x00,
1331 0x38, 0xFF, 0xE6, 0x01, 0x34, 0xFC, 0xFB, 0x06, 0xD2, 0xF2, 0x64,
1332 0x23, 0x73, 0x3B, 0xBC, 0xF2, 0xB4, 0x05, 0x6E, 0xFD, 0x09, 0x01,
1333 0xAF, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x1A, 0x00, 0x8B,
1334 0xFF, 0x4F, 0x01, 0xFB, 0xFC, 0x5A, 0x06, 0xF2, 0xF1, 0xA0, 0x37,
1335 0x3A, 0x28, 0x13, 0xF2, 0x25, 0x07, 0x35, 0xFC, 0xDB, 0x01, 0x40,
1336 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0C, 0x00, 0xD0, 0xFF, 0x51, 0x00,
1337 0xC3, 0xFF, 0xA6, 0xFF, 0x16, 0x02, 0xA9, 0xF8, 0x5C, 0x45, 0xB2,
1338 0x12, 0x19, 0xF7, 0x52, 0x05, 0xD8, 0xFC, 0xAF, 0x01, 0x47, 0xFF,
1339 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x24, 0x00, 0x71, 0xFF, 0x42,
1340 0x01, 0xCD, 0xFD, 0x59, 0x03, 0x3B, 0xFB, 0x5E, 0x07, 0xB3, 0x48,
1341 0x48, 0x00, 0x4B, 0xFE, 0xC2, 0x01, 0x9F, 0xFE, 0xDE, 0x00, 0x98,
1342 0xFF, 0x19, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xDD, 0x01,
1343 0x62, 0xFC, 0x69, 0x06, 0x7F, 0xF4, 0xB2, 0x1B, 0xAB, 0x40, 0xD0,
1344 0xF4, 0x4E, 0x04, 0x53, 0xFE, 0x83, 0x00, 0xF2, 0xFF, 0xF4, 0xFF,
1345 0x05, 0x00, 0xFD, 0xFF, 0x29, 0x00, 0x5F, 0xFF, 0xA3, 0x01, 0x7A,
1346 0xFC, 0xFD, 0x06, 0x7C, 0xF1, 0xF2, 0x30, 0x96, 0x2F, 0x80, 0xF1,
1347 0x0F, 0x07, 0x69, 0xFC, 0xB0, 0x01, 0x59, 0xFF, 0x2B, 0x00, 0xFD,
1348 0xFF, 0x06, 0x00, 0xEE, 0xFF, 0x01, 0x00, 0x66, 0x00, 0x85, 0xFE,
1349 0xFC, 0x03, 0x55, 0xF5, 0x8C, 0x41, 0x38, 0x1A, 0xE1, 0xF4, 0x43,
1350 0x06, 0x70, 0xFC, 0xD8, 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE, 0xFF,
1351 0x1B, 0x00, 0x92, 0xFF, 0xEF, 0x00, 0x7D, 0xFE, 0x04, 0x02, 0xCF,
1352 0xFD, 0x58, 0x01, 0xD7, 0x48, 0x26, 0x06, 0xBB, 0xFB, 0x19, 0x03,
1353 0xED, 0xFD, 0x32, 0x01, 0x77, 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFF,
1354 0xFF, 0x32, 0x00, 0x44, 0xFF, 0xB9, 0x01, 0xC1, 0xFC, 0x86, 0x05,
1355 0xA5, 0xF6, 0x1E, 0x14, 0xBA, 0x44, 0xF0, 0xF7, 0x7B, 0x02, 0x6B,
1356 0xFF, 0xE4, 0xFF, 0x41, 0x00, 0xD6, 0xFF, 0x0B, 0x00, 0xFD, 0xFF,
1357 0x33, 0x00, 0x43, 0xFF, 0xD5, 0x01, 0x3A, 0xFC, 0x2A, 0x07, 0xE7,
1358 0xF1, 0xAC, 0x29, 0x66, 0x36, 0xC9, 0xF1, 0x83, 0x06, 0xDD, 0xFC,
1359 0x62, 0x01, 0x81, 0xFF, 0x1D, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x08,
1360 0x00, 0xBB, 0xFF, 0xF1, 0x00, 0x96, 0xFD, 0x78, 0x05, 0x0E, 0xF3,
1361 0x8A, 0x3C, 0xEA, 0x21, 0x19, 0xF3, 0xE6, 0x06, 0x38, 0xFC, 0xE6,
1362 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x12, 0x00, 0xB4, 0xFF,
1363 0x98, 0x00, 0x32, 0xFF, 0xB0, 0x00, 0x41, 0x00, 0x30, 0xFC, 0x86,
1364 0x47, 0xC6, 0x0C, 0x24, 0xF9, 0x60, 0x04, 0x4B, 0xFD, 0x7D, 0x01,
1365 0x5A, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x5A,
1366 0xFF, 0x7E, 0x01, 0x48, 0xFD, 0x66, 0x04, 0x18, 0xF9, 0xE8, 0x0C,
1367 0x7C, 0x47, 0x19, 0xFC, 0x4D, 0x00, 0xA9, 0x00, 0x35, 0xFF, 0x96,
1368 0x00, 0xB5, 0xFF, 0x12, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF,
1369 0xE6, 0x01, 0x38, 0xFC, 0xE9, 0x06, 0x12, 0xF3, 0x10, 0x22, 0x6E,
1370 0x3C, 0x05, 0xF3, 0x7E, 0x05, 0x91, 0xFD, 0xF4, 0x00, 0xBA, 0xFF,
1371 0x09, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x82, 0xFF, 0x60,
1372 0x01, 0xE0, 0xFC, 0x7F, 0x06, 0xCC, 0xF1, 0x85, 0x36, 0x87, 0x29,
1373 0xEB, 0xF1, 0x2A, 0x07, 0x39, 0xFC, 0xD6, 0x01, 0x43, 0xFF, 0x33,
1374 0x00, 0xFD, 0xFF, 0x0B, 0x00, 0xD5, 0xFF, 0x42, 0x00, 0xE1, 0xFF,
1375 0x71, 0xFF, 0x71, 0x02, 0x02, 0xF8, 0xCC, 0x44, 0xFA, 0x13, 0xB0,
1376 0xF6, 0x81, 0x05, 0xC3, 0xFC, 0xB8, 0x01, 0x44, 0xFF, 0x31, 0x00,
1377 0xFF, 0xFF, 0x00, 0x00, 0x22, 0x00, 0x77, 0xFF, 0x34, 0x01, 0xEA,
1378 0xFD, 0x1F, 0x03, 0xAE, 0xFB, 0x45, 0x06, 0xD5, 0x48, 0x3C, 0x01,
1379 0xDC, 0xFD, 0xFD, 0x01, 0x80, 0xFE, 0xED, 0x00, 0x93, 0xFF, 0x1B,
1380 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD8, 0x01, 0x6F, 0xFC,
1381 0x47, 0x06, 0xD7, 0xF4, 0x5D, 0x1A, 0x74, 0x41, 0x48, 0xF5, 0x04,
1382 0x04, 0x80, 0xFE, 0x69, 0x00, 0xFF, 0xFF, 0xEF, 0xFF, 0x05, 0x00,
1383 0xFD, 0xFF, 0x2B, 0x00, 0x59, 0xFF, 0xAE, 0x01, 0x6A, 0xFC, 0x0D,
1384 0x07, 0x80, 0xF1, 0xB8, 0x2F, 0xCF, 0x30, 0x7D, 0xF1, 0xFF, 0x06,
1385 0x78, 0xFC, 0xA5, 0x01, 0x5F, 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0x05,
1386 0x00, 0xF3, 0xFF, 0xF4, 0xFF, 0x80, 0x00, 0x58, 0xFE, 0x46, 0x04,
1387 0xDD, 0xF4, 0xC3, 0x40, 0x8C, 0x1B, 0x89, 0xF4, 0x66, 0x06, 0x63,
1388 0xFC, 0xDC, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x19, 0x00,
1389 0x98, 0xFF, 0xE0, 0x00, 0x9C, 0xFE, 0xC8, 0x01, 0x3F, 0xFE, 0x62,
1390 0x00, 0xB8, 0x48, 0x3F, 0x07, 0x47, 0xFB, 0x53, 0x03, 0xD0, 0xFD,
1391 0x40, 0x01, 0x72, 0xFF, 0x23, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30,
1392 0x00, 0x47, 0xFF, 0xB0, 0x01, 0xD6, 0xFC, 0x58, 0x05, 0x0D, 0xF7,
1393 0xD7, 0x12, 0x4E, 0x45, 0x96, 0xF8, 0x20, 0x02, 0xA0, 0xFF, 0xC7,
1394 0xFF, 0x4F, 0x00, 0xD0, 0xFF, 0x0C, 0x00, 0xFD, 0xFF, 0x34, 0x00,
1395 0x40, 0xFF, 0xDB, 0x01, 0x35, 0xFC, 0x26, 0x07, 0x0E, 0xF2, 0x60,
1396 0x28, 0x82, 0x37, 0xED, 0xF1, 0x5E, 0x06, 0xF8, 0xFC, 0x51, 0x01,
1397 0x8A, 0xFF, 0x1A, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 0xB0,
1398 0xFF, 0x07, 0x01, 0x72, 0xFD, 0xAE, 0x05, 0xC4, 0xF2, 0x90, 0x3B,
1399 0x3F, 0x23, 0xD9, 0xF2, 0xF9, 0x06, 0x34, 0xFC, 0xE6, 0x01, 0x38,
1400 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x11, 0x00, 0xBA, 0xFF, 0x89, 0x00,
1401 0x51, 0xFF, 0x77, 0x00, 0xA7, 0x00, 0x64, 0xFB, 0x26, 0x47, 0xFC,
1402 0x0D, 0xB4, 0xF8, 0x95, 0x04, 0x31, 0xFD, 0x88, 0x01, 0x56, 0xFF,
1403 0x2C, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x29, 0x00, 0x5E, 0xFF, 0x72,
1404 0x01, 0x62, 0xFD, 0x2F, 0x04, 0x89, 0xF9, 0xB6, 0x0B, 0xD2, 0x47,
1405 0xEB, 0xFC, 0xE4, 0xFF, 0xE3, 0x00, 0x16, 0xFF, 0xA5, 0x00, 0xAF,
1406 0xFF, 0x13, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01,
1407 0x3E, 0xFC, 0xD3, 0x06, 0x56, 0xF3, 0xBA, 0x20, 0x61, 0x3D, 0x56,
1408 0xF3, 0x45, 0x05, 0xB7, 0xFD, 0xDE, 0x00, 0xC5, 0xFF, 0x05, 0x00,
1409 0x02, 0x00, 0xFE, 0xFF, 0x20, 0x00, 0x7A, 0xFF, 0x70, 0x01, 0xC7,
1410 0xFC, 0xA0, 0x06, 0xAE, 0xF1, 0x65, 0x35, 0xD1, 0x2A, 0xCA, 0xF1,
1411 0x2A, 0x07, 0x40, 0xFC, 0xD0, 0x01, 0x47, 0xFF, 0x32, 0x00, 0xFD,
1412 0xFF, 0x09, 0x00, 0xDB, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x3D, 0xFF,
1413 0xC9, 0x02, 0x64, 0xF7, 0x2F, 0x44, 0x44, 0x15, 0x4A, 0xF6, 0xAD,
1414 0x05, 0xAF, 0xFC, 0xC0, 0x01, 0x41, 0xFF, 0x32, 0x00, 0xFF, 0xFF,
1415 0x00, 0x00, 0x21, 0x00, 0x7C, 0xFF, 0x26, 0x01, 0x08, 0xFE, 0xE4,
1416 0x02, 0x21, 0xFC, 0x31, 0x05, 0xEB, 0x48, 0x37, 0x02, 0x6B, 0xFD,
1417 0x39, 0x02, 0x61, 0xFE, 0xFC, 0x00, 0x8D, 0xFF, 0x1C, 0x00, 0xFE,
1418 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD3, 0x01, 0x7D, 0xFC, 0x23, 0x06,
1419 0x32, 0xF5, 0x0C, 0x19, 0x38, 0x42, 0xC7, 0xF5, 0xB8, 0x03, 0xAF,
1420 0xFE, 0x4E, 0x00, 0x0C, 0x00, 0xEA, 0xFF, 0x06, 0x00, 0xFD, 0xFF,
1421 0x2D, 0x00, 0x54, 0xFF, 0xB8, 0x01, 0x5D, 0xFC, 0x1A, 0x07, 0x8A,
1422 0xF1, 0x7B, 0x2E, 0x04, 0x32, 0x7F, 0xF1, 0xEC, 0x06, 0x8A, 0xFC,
1423 0x98, 0x01, 0x65, 0xFF, 0x27, 0x00, 0xFD, 0xFF, 0x04, 0x00, 0xF8,
1424 0xFF, 0xE7, 0xFF, 0x99, 0x00, 0x2C, 0xFE, 0x8C, 0x04, 0x6D, 0xF4,
1425 0xF0, 0x3F, 0xE0, 0x1C, 0x34, 0xF4, 0x85, 0x06, 0x57, 0xFC, 0xE0,
1426 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x18, 0x00, 0x9E, 0xFF,
1427 0xD1, 0x00, 0xBB, 0xFE, 0x8D, 0x01, 0xAE, 0xFE, 0x74, 0xFF, 0x8D,
1428 0x48, 0x5D, 0x08, 0xD4, 0xFA, 0x8D, 0x03, 0xB3, 0xFD, 0x4E, 0x01,
1429 0x6D, 0xFF, 0x25, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4A,
1430 0xFF, 0xA7, 0x01, 0xEC, 0xFC, 0x28, 0x05, 0x77, 0xF7, 0x92, 0x11,
1431 0xD7, 0x45, 0x43, 0xF9, 0xC3, 0x01, 0xD6, 0xFF, 0xA9, 0xFF, 0x5E,
1432 0x00, 0xCB, 0xFF, 0x0D, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x3D, 0xFF,
1433 0xDF, 0x01, 0x32, 0xFC, 0x1F, 0x07, 0x3B, 0xF2, 0x11, 0x27, 0x97,
1434 0x38, 0x19, 0xF2, 0x36, 0x06, 0x15, 0xFD, 0x3F, 0x01, 0x93, 0xFF,
1435 0x17, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x10, 0x00, 0xA6, 0xFF, 0x1B,
1436 0x01, 0x50, 0xFD, 0xE1, 0x05, 0x82, 0xF2, 0x8F, 0x3A, 0x92, 0x24,
1437 0x9D, 0xF2, 0x09, 0x07, 0x32, 0xFC, 0xE4, 0x01, 0x39, 0xFF, 0x36,
1438 0x00, 0xFD, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0x7A, 0x00, 0x70, 0xFF,
1439 0x3E, 0x00, 0x0C, 0x01, 0xA1, 0xFA, 0xBB, 0x46, 0x36, 0x0F, 0x45,
1440 0xF8, 0xC9, 0x04, 0x18, 0xFD, 0x93, 0x01, 0x52, 0xFF, 0x2D, 0x00,
1441 0xFF, 0xFF, 0x00, 0x00, 0x28, 0x00, 0x63, 0xFF, 0x66, 0x01, 0x7D,
1442 0xFD, 0xF8, 0x03, 0xFB, 0xF9, 0x89, 0x0A, 0x1D, 0x48, 0xC5, 0xFD,
1443 0x7A, 0xFF, 0x1D, 0x01, 0xF7, 0xFE, 0xB4, 0x00, 0xA9, 0xFF, 0x15,
1444 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE5, 0x01, 0x45, 0xFC,
1445 0xBB, 0x06, 0xA0, 0xF3, 0x64, 0x1F, 0x4A, 0x3E, 0xB0, 0xF3, 0x08,
1446 0x05, 0xDE, 0xFD, 0xC7, 0x00, 0xD0, 0xFF, 0x00, 0x00, 0x02, 0x00,
1447 0xFE, 0xFF, 0x23, 0x00, 0x72, 0xFF, 0x7F, 0x01, 0xB0, 0xFC, 0xBE,
1448 0x06, 0x97, 0xF1, 0x3F, 0x34, 0x19, 0x2C, 0xAD, 0xF1, 0x28, 0x07,
1449 0x48, 0xFC, 0xC9, 0x01, 0x4B, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x08,
1450 0x00, 0xE0, 0xFF, 0x26, 0x00, 0x1A, 0x00, 0x0B, 0xFF, 0x1E, 0x03,
1451 0xCD, 0xF6, 0x89, 0x43, 0x91, 0x16, 0xE7, 0xF5, 0xD8, 0x05, 0x9D,
1452 0xFC, 0xC7, 0x01, 0x3E, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x00, 0x00,
1453 0x1F, 0x00, 0x82, 0xFF, 0x18, 0x01, 0x27, 0xFE, 0xA9, 0x02, 0x94,
1454 0xFC, 0x24, 0x04, 0xF5, 0x48, 0x39, 0x03, 0xF9, 0xFC, 0x74, 0x02,
1455 0x42, 0xFE, 0x0B, 0x01, 0x87, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x34,
1456 0x00, 0x3C, 0xFF, 0xCD, 0x01, 0x8E, 0xFC, 0xFC, 0x05, 0x90, 0xF5,
1457 0xBB, 0x17, 0xEE, 0x42, 0x4E, 0xF6, 0x68, 0x03, 0xDF, 0xFE, 0x33,
1458 0x00, 0x1A, 0x00, 0xE5, 0xFF, 0x07, 0x00, 0xFD, 0xFF, 0x2F, 0x00,
1459 0x4F, 0xFF, 0xC2, 0x01, 0x51, 0xFC, 0x23, 0x07, 0x9A, 0xF1, 0x3A,
1460 0x2D, 0x35, 0x33, 0x89, 0xF1, 0xD5, 0x06, 0x9D, 0xFC, 0x8B, 0x01,
1461 0x6C, 0xFF, 0x25, 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFC, 0xFF, 0xDB,
1462 0xFF, 0xB2, 0x00, 0x02, 0xFE, 0xCF, 0x04, 0x05, 0xF4, 0x16, 0x3F,
1463 0x36, 0x1E, 0xE4, 0xF3, 0xA3, 0x06, 0x4D, 0xFC, 0xE3, 0x01, 0x36,
1464 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x16, 0x00, 0xA4, 0xFF, 0xC2, 0x00,
1465 0xDB, 0xFE, 0x52, 0x01, 0x1B, 0xFF, 0x8D, 0xFE, 0x57, 0x48, 0x81,
1466 0x09, 0x61, 0xFA, 0xC6, 0x03, 0x96, 0xFD, 0x5B, 0x01, 0x68, 0xFF,
1467 0x26, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x4E, 0xFF, 0x9D,
1468 0x01, 0x03, 0xFD, 0xF7, 0x04, 0xE3, 0xF7, 0x51, 0x10, 0x55, 0x46,
1469 0xF9, 0xF9, 0x63, 0x01, 0x0D, 0x00, 0x8B, 0xFF, 0x6D, 0x00, 0xC5,
1470 0xFF, 0x0E, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xE2, 0x01,
1471 0x31, 0xFC, 0x15, 0x07, 0x6D, 0xF2, 0xBF, 0x25, 0xA5, 0x39, 0x4D,
1472 0xF2, 0x0B, 0x06, 0x33, 0xFD, 0x2D, 0x01, 0x9D, 0xFF, 0x13, 0x00,
1473 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0x00, 0x9C, 0xFF, 0x2F, 0x01, 0x30,
1474 0xFD, 0x10, 0x06, 0x47, 0xF2, 0x87, 0x39, 0xE5, 0x25, 0x67, 0xF2,
1475 0x16, 0x07, 0x31, 0xFC, 0xE2, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFD,
1476 0xFF, 0x0E, 0x00, 0xC6, 0xFF, 0x6B, 0x00, 0x8E, 0xFF, 0x06, 0x00,
1477 0x6E, 0x01, 0xE4, 0xF9, 0x48, 0x46, 0x75, 0x10, 0xD7, 0xF7, 0xFC,
1478 0x04, 0x00, 0xFD, 0x9E, 0x01, 0x4E, 0xFF, 0x2E, 0x00, 0xFF, 0xFF,
1479 0x00, 0x00, 0x26, 0x00, 0x68, 0xFF, 0x59, 0x01, 0x99, 0xFD, 0xC0,
1480 0x03, 0x6E, 0xFA, 0x61, 0x09, 0x5D, 0x48, 0xA6, 0xFE, 0x0F, 0xFF,
1481 0x58, 0x01, 0xD7, 0xFE, 0xC3, 0x00, 0xA3, 0xFF, 0x16, 0x00, 0xFE,
1482 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE3, 0x01, 0x4E, 0xFC, 0xA0, 0x06,
1483 0xED, 0xF3, 0x0F, 0x1E, 0x2D, 0x3F, 0x10, 0xF4, 0xC8, 0x04, 0x07,
1484 0xFE, 0xAF, 0x00, 0xDC, 0xFF, 0xFC, 0xFF, 0x03, 0x00, 0xFD, 0xFF,
1485 0x25, 0x00, 0x6B, 0xFF, 0x8D, 0x01, 0x9B, 0xFC, 0xD8, 0x06, 0x87,
1486 0xF1, 0x13, 0x33, 0x5E, 0x2D, 0x98, 0xF1, 0x22, 0x07, 0x52, 0xFC,
1487 0xC1, 0x01, 0x4F, 0xFF, 0x2F, 0x00, 0xFD, 0xFF, 0x07, 0x00, 0xE5,
1488 0xFF, 0x18, 0x00, 0x36, 0x00, 0xD9, 0xFE, 0x71, 0x03, 0x3F, 0xF6,
1489 0xDB, 0x42, 0xE0, 0x17, 0x86, 0xF5, 0x00, 0x06, 0x8C, 0xFC, 0xCE,
1490 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x1D, 0x00, 0x88, 0xFF,
1491 0x09, 0x01, 0x45, 0xFE, 0x6E, 0x02, 0x06, 0xFD, 0x1C, 0x03, 0xF4,
1492 0x48, 0x41, 0x04, 0x87, 0xFC, 0xB0, 0x02, 0x23, 0xFE, 0x19, 0x01,
1493 0x81, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x3F,
1494 0xFF, 0xC6, 0x01, 0x9F, 0xFC, 0xD3, 0x05, 0xF1, 0xF5, 0x6C, 0x16,
1495 0x9E, 0x43, 0xDD, 0xF6, 0x15, 0x03, 0x10, 0xFF, 0x17, 0x00, 0x28,
1496 0x00, 0xDF, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x30, 0x00, 0x4A, 0xFF,
1497 0xCA, 0x01, 0x47, 0xFC, 0x28, 0x07, 0xB0, 0xF1, 0xF5, 0x2B, 0x60,
1498 0x34, 0x9A, 0xF1, 0xBB, 0x06, 0xB3, 0xFC, 0x7D, 0x01, 0x73, 0xFF,
1499 0x22, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x01, 0x00, 0xCF, 0xFF, 0xC9,
1500 0x00, 0xDA, 0xFD, 0x0F, 0x05, 0xA5, 0xF3, 0x31, 0x3E, 0x8A, 0x1F,
1501 0x97, 0xF3, 0xBD, 0x06, 0x44, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36,
1502 0x00, 0xFD, 0xFF, 0x15, 0x00, 0xAA, 0xFF, 0xB3, 0x00, 0xFA, 0xFE,
1503 0x17, 0x01, 0x86, 0xFF, 0xAC, 0xFD, 0x16, 0x48, 0xAA, 0x0A, 0xEE,
1504 0xF9, 0xFE, 0x03, 0x7A, 0xFD, 0x67, 0x01, 0x63, 0xFF, 0x28, 0x00,
1505 0x00, 0x00, 0xFF, 0xFF, 0x2D, 0x00, 0x52, 0xFF, 0x92, 0x01, 0x1B,
1506 0xFD, 0xC4, 0x04, 0x51, 0xF8, 0x13, 0x0F, 0xC8, 0x46, 0xB6, 0xFA,
1507 0x01, 0x01, 0x44, 0x00, 0x6C, 0xFF, 0x7B, 0x00, 0xBF, 0xFF, 0x10,
1508 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE5, 0x01, 0x32, 0xFC,
1509 0x08, 0x07, 0xA4, 0xF2, 0x6D, 0x24, 0xAD, 0x3A, 0x88, 0xF2, 0xDB,
1510 0x05, 0x53, 0xFD, 0x19, 0x01, 0xA7, 0xFF, 0x10, 0x00, 0x00, 0x00,
1511 0xFF, 0xFF, 0x17, 0x00, 0x92, 0xFF, 0x41, 0x01, 0x11, 0xFD, 0x3B,
1512 0x06, 0x14, 0xF2, 0x78, 0x38, 0x36, 0x27, 0x35, 0xF2, 0x20, 0x07,
1513 0x33, 0xFC, 0xDF, 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0D,
1514 0x00, 0xCB, 0xFF, 0x5C, 0x00, 0xAC, 0xFF, 0xD0, 0xFF, 0xCD, 0x01,
1515 0x30, 0xF9, 0xC8, 0x45, 0xB6, 0x11, 0x6B, 0xF7, 0x2D, 0x05, 0xE9,
1516 0xFC, 0xA8, 0x01, 0x4A, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x00, 0x00,
1517 0x25, 0x00, 0x6D, 0xFF, 0x4C, 0x01, 0xB6, 0xFD, 0x86, 0x03, 0xE1,
1518 0xFA, 0x3D, 0x08, 0x92, 0x48, 0x8E, 0xFF, 0xA1, 0xFE, 0x93, 0x01,
1519 0xB8, 0xFE, 0xD3, 0x00, 0x9D, 0xFF, 0x18, 0x00, 0xFE, 0xFF, 0x36,
1520 0x00, 0x37, 0xFF, 0xE0, 0x01, 0x58, 0xFC, 0x82, 0x06, 0x3E, 0xF4,
1521 0xBA, 0x1C, 0x07, 0x40, 0x79, 0xF4, 0x84, 0x04, 0x31, 0xFE, 0x96,
1522 0x00, 0xE8, 0xFF, 0xF7, 0xFF, 0x04, 0x00, 0xFD, 0xFF, 0x28, 0x00,
1523 0x64, 0xFF, 0x9A, 0x01, 0x88, 0xFC, 0xEE, 0x06, 0x7E, 0xF1, 0xE3,
1524 0x31, 0x9F, 0x2E, 0x88, 0xF1, 0x19, 0x07, 0x5E, 0xFC, 0xB7, 0x01,
1525 0x54, 0xFF, 0x2D, 0x00, 0xFD, 0xFF, 0x06, 0x00, 0xEA, 0xFF, 0x0B,
1526 0x00, 0x51, 0x00, 0xAA, 0xFE, 0xC0, 0x03, 0xB8, 0xF5, 0x21, 0x42,
1527 0x31, 0x19, 0x28, 0xF5, 0x27, 0x06, 0x7C, 0xFC, 0xD4, 0x01, 0x3A,
1528 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x8D, 0xFF, 0xFA, 0x00,
1529 0x64, 0xFE, 0x32, 0x02, 0x78, 0xFD, 0x1B, 0x02, 0xEA, 0x48, 0x50,
1530 0x05, 0x14, 0xFC, 0xEB, 0x02, 0x05, 0xFE, 0x27, 0x01, 0x7C, 0xFF,
1531 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x41, 0xFF, 0xBF,
1532 0x01, 0xB2, 0xFC, 0xA9, 0x05, 0x55, 0xF6, 0x20, 0x15, 0x42, 0x44,
1533 0x75, 0xF7, 0xBF, 0x02, 0x43, 0xFF, 0xFA, 0xFF, 0x36, 0x00, 0xDA,
1534 0xFF, 0x0A, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x46, 0xFF, 0xD1, 0x01,
1535 0x3F, 0xFC, 0x2B, 0x07, 0xCD, 0xF1, 0xAE, 0x2A, 0x86, 0x35, 0xB1,
1536 0xF1, 0x9D, 0x06, 0xCA, 0xFC, 0x6E, 0x01, 0x7B, 0xFF, 0x20, 0x00,
1537 0xFE, 0xFF, 0x02, 0x00, 0x05, 0x00, 0xC3, 0xFF, 0xE0, 0x00, 0xB3,
1538 0xFD, 0x4B, 0x05, 0x4D, 0xF3, 0x45, 0x3D, 0xE0, 0x20, 0x4F, 0xF3,
1539 0xD5, 0x06, 0x3D, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD,
1540 0xFF, 0x13, 0x00, 0xAF, 0xFF, 0xA4, 0x00, 0x19, 0xFF, 0xDD, 0x00,
1541 0xF0, 0xFF, 0xD4, 0xFC, 0xC9, 0x47, 0xD8, 0x0B, 0x7C, 0xF9, 0x35,
1542 0x04, 0x5F, 0xFD, 0x74, 0x01, 0x5E, 0xFF, 0x29, 0x00, 0x00, 0x00,
1543 0x00, 0x00, 0x2C, 0x00, 0x56, 0xFF, 0x87, 0x01, 0x34, 0xFD, 0x8F,
1544 0x04, 0xC0, 0xF8, 0xD9, 0x0D, 0x31, 0x47, 0x7B, 0xFB, 0x9C, 0x00,
1545 0x7D, 0x00, 0x4D, 0xFF, 0x8A, 0x00, 0xB9, 0xFF, 0x11, 0x00, 0xFD,
1546 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE6, 0x01, 0x35, 0xFC, 0xF7, 0x06,
1547 0xE0, 0xF2, 0x18, 0x23, 0xAB, 0x3B, 0xCC, 0xF2, 0xA8, 0x05, 0x76,
1548 0xFD, 0x04, 0x01, 0xB1, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0xFE, 0xFF,
1549 0x1A, 0x00, 0x89, 0xFF, 0x53, 0x01, 0xF5, 0xFC, 0x63, 0x06, 0xE9,
1550 0xF1, 0x63, 0x37, 0x85, 0x28, 0x09, 0xF2, 0x27, 0x07, 0x35, 0xFC,
1551 0xDA, 0x01, 0x40, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x0C, 0x00, 0xD1,
1552 0xFF, 0x4E, 0x00, 0xCA, 0xFF, 0x9A, 0xFF, 0x2A, 0x02, 0x83, 0xF8,
1553 0x3F, 0x45, 0xFB, 0x12, 0x01, 0xF7, 0x5D, 0x05, 0xD3, 0xFC, 0xB1,
1554 0x01, 0x46, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x23, 0x00,
1555 0x73, 0xFF, 0x3F, 0x01, 0xD3, 0xFD, 0x4C, 0x03, 0x54, 0xFB, 0x1F,
1556 0x07, 0xBB, 0x48, 0x7D, 0x00, 0x33, 0xFE, 0xCF, 0x01, 0x98, 0xFE,
1557 0xE2, 0x00, 0x97, 0xFF, 0x19, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x38,
1558 0xFF, 0xDC, 0x01, 0x64, 0xFC, 0x62, 0x06, 0x93, 0xF4, 0x66, 0x1B,
1559 0xD9, 0x40, 0xEA, 0xF4, 0x3E, 0x04, 0x5D, 0xFE, 0x7D, 0x00, 0xF5,
1560 0xFF, 0xF3, 0xFF, 0x05, 0x00, 0xFD, 0xFF, 0x2A, 0x00, 0x5E, 0xFF,
1561 0xA6, 0x01, 0x76, 0xFC, 0x01, 0x07, 0x7D, 0xF1, 0xAD, 0x30, 0xDC,
1562 0x2F, 0x7F, 0xF1, 0x0C, 0x07, 0x6C, 0xFC, 0xAD, 0x01, 0x5A, 0xFF,
1563 0x2B, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xEF, 0xFF, 0xFE, 0xFF, 0x6C,
1564 0x00, 0x7B, 0xFE, 0x0C, 0x04, 0x3A, 0xF5, 0x5F, 0x41, 0x83, 0x1A,
1565 0xCD, 0xF4, 0x4B, 0x06, 0x6D, 0xFC, 0xD9, 0x01, 0x39, 0xFF, 0x35,
1566 0x00, 0xFE, 0xFF, 0x1A, 0x00, 0x93, 0xFF, 0xEC, 0x00, 0x83, 0xFE,
1567 0xF7, 0x01, 0xE8, 0xFD, 0x21, 0x01, 0xD2, 0x48, 0x64, 0x06, 0xA1,
1568 0xFB, 0x26, 0x03, 0xE7, 0xFD, 0x35, 0x01, 0x76, 0xFF, 0x22, 0x00,
1569 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x44, 0xFF, 0xB7, 0x01, 0xC5,
1570 0xFC, 0x7C, 0x05, 0xBC, 0xF6, 0xD5, 0x13, 0xDC, 0x44, 0x14, 0xF8,
1571 0x67, 0x02, 0x77, 0xFF, 0xDD, 0xFF, 0x44, 0x00, 0xD5, 0xFF, 0x0B,
1572 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x42, 0xFF, 0xD7, 0x01, 0x39, 0xFC,
1573 0x29, 0x07, 0xEF, 0xF1, 0x62, 0x29, 0xA5, 0x36, 0xD0, 0xF1, 0x7B,
1574 0x06, 0xE3, 0xFC, 0x5E, 0x01, 0x83, 0xFF, 0x1D, 0x00, 0xFE, 0xFF,
1575 0x01, 0x00, 0x09, 0x00, 0xB8, 0xFF, 0xF6, 0x00, 0x8D, 0xFD, 0x84,
1576 0x05, 0xFD, 0xF2, 0x52, 0x3C, 0x35, 0x22, 0x0B, 0xF3, 0xEB, 0x06,
1577 0x37, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x12,
1578 0x00, 0xB5, 0xFF, 0x94, 0x00, 0x39, 0xFF, 0xA3, 0x00, 0x58, 0x00,
1579 0x02, 0xFC, 0x73, 0x47, 0x0B, 0x0D, 0x0B, 0xF9, 0x6C, 0x04, 0x45,
1580 0xFD, 0x80, 0x01, 0x59, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00,
1581 0x2A, 0x00, 0x5B, 0xFF, 0x7C, 0x01, 0x4E, 0xFD, 0x5A, 0x04, 0x31,
1582 0xF9, 0xA4, 0x0C, 0x90, 0x47, 0x47, 0xFC, 0x36, 0x00, 0xB6, 0x00,
1583 0x2E, 0xFF, 0x99, 0x00, 0xB3, 0xFF, 0x12, 0x00, 0xFD, 0xFF, 0x36,
1584 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x39, 0xFC, 0xE4, 0x06, 0x21, 0xF3,
1585 0xC4, 0x21, 0xA5, 0x3C, 0x16, 0xF3, 0x72, 0x05, 0x9A, 0xFD, 0xEF,
1586 0x00, 0xBC, 0xFF, 0x08, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x1E, 0x00,
1587 0x80, 0xFF, 0x64, 0x01, 0xDA, 0xFC, 0x87, 0x06, 0xC5, 0xF1, 0x46,
1588 0x36, 0xD1, 0x29, 0xE3, 0xF1, 0x2A, 0x07, 0x3A, 0xFC, 0xD5, 0x01,
1589 0x44, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x0A, 0x00, 0xD6, 0xFF, 0x3F,
1590 0x00, 0xE7, 0xFF, 0x65, 0xFF, 0x85, 0x02, 0xDE, 0xF7, 0xA9, 0x44,
1591 0x43, 0x14, 0x99, 0xF6, 0x8B, 0x05, 0xBF, 0xFC, 0xBA, 0x01, 0x43,
1592 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x22, 0x00, 0x78, 0xFF,
1593 0x31, 0x01, 0xF1, 0xFD, 0x12, 0x03, 0xC7, 0xFB, 0x07, 0x06, 0xDB,
1594 0x48, 0x73, 0x01, 0xC3, 0xFD, 0x0A, 0x02, 0x79, 0xFE, 0xF1, 0x00,
1595 0x91, 0xFF, 0x1B, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD7,
1596 0x01, 0x72, 0xFC, 0x3F, 0x06, 0xEB, 0xF4, 0x12, 0x1A, 0xA1, 0x41,
1597 0x63, 0xF5, 0xF3, 0x03, 0x8A, 0xFE, 0x63, 0x00, 0x02, 0x00, 0xEE,
1598 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2C, 0x00, 0x58, 0xFF, 0xB1, 0x01,
1599 0x67, 0xFC, 0x10, 0x07, 0x81, 0xF1, 0x73, 0x2F, 0x15, 0x31, 0x7C,
1600 0xF1, 0xFB, 0x06, 0x7C, 0xFC, 0xA2, 0x01, 0x60, 0xFF, 0x29, 0x00,
1601 0xFD, 0xFF, 0x04, 0x00, 0xF4, 0xFF, 0xF1, 0xFF, 0x85, 0x00, 0x4E,
1602 0xFE, 0x56, 0x04, 0xC3, 0xF4, 0x95, 0x40, 0xD8, 0x1B, 0x76, 0xF4,
1603 0x6D, 0x06, 0x60, 0xFC, 0xDD, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE,
1604 0xFF, 0x19, 0x00, 0x99, 0xFF, 0xDD, 0x00, 0xA3, 0xFE, 0xBB, 0x01,
1605 0x58, 0xFE, 0x2D, 0x00, 0xAF, 0x48, 0x7E, 0x07, 0x2E, 0xFB, 0x60,
1606 0x03, 0xC9, 0xFD, 0x43, 0x01, 0x71, 0xFF, 0x24, 0x00, 0x00, 0x00,
1607 0xFF, 0xFF, 0x30, 0x00, 0x48, 0xFF, 0xAE, 0x01, 0xDB, 0xFC, 0x4D,
1608 0x05, 0x24, 0xF7, 0x8E, 0x12, 0x6D, 0x45, 0xBC, 0xF8, 0x0C, 0x02,
1609 0xAC, 0xFF, 0xC0, 0xFF, 0x52, 0x00, 0xCF, 0xFF, 0x0C, 0x00, 0xFD,
1610 0xFF, 0x34, 0x00, 0x3F, 0xFF, 0xDC, 0x01, 0x34, 0xFC, 0x25, 0x07,
1611 0x18, 0xF2, 0x15, 0x28, 0xBF, 0x37, 0xF7, 0xF1, 0x56, 0x06, 0xFE,
1612 0xFC, 0x4D, 0x01, 0x8C, 0xFF, 0x19, 0x00, 0xFF, 0xFF, 0x00, 0x00,
1613 0x0D, 0x00, 0xAE, 0xFF, 0x0B, 0x01, 0x6A, 0xFD, 0xBA, 0x05, 0xB4,
1614 0xF2, 0x58, 0x3B, 0x8A, 0x23, 0xCB, 0xF2, 0xFD, 0x06, 0x34, 0xFC,
1615 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x10, 0x00, 0xBB,
1616 0xFF, 0x85, 0x00, 0x58, 0xFF, 0x6A, 0x00, 0xBE, 0x00, 0x38, 0xFB,
1617 0x0F, 0x47, 0x42, 0x0E, 0x9B, 0xF8, 0xA1, 0x04, 0x2B, 0xFD, 0x8B,
1618 0x01, 0x55, 0xFF, 0x2C, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x29, 0x00,
1619 0x5F, 0xFF, 0x70, 0x01, 0x68, 0xFD, 0x23, 0x04, 0xA2, 0xF9, 0x73,
1620 0x0B, 0xE4, 0x47, 0x1B, 0xFD, 0xCD, 0xFF, 0xF0, 0x00, 0x0F, 0xFF,
1621 0xA9, 0x00, 0xAE, 0xFF, 0x14, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36,
1622 0xFF, 0xE6, 0x01, 0x3F, 0xFC, 0xCE, 0x06, 0x66, 0xF3, 0x6F, 0x20,
1623 0x96, 0x3D, 0x69, 0xF3, 0x38, 0x05, 0xBF, 0xFD, 0xD9, 0x00, 0xC7,
1624 0xFF, 0x04, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x20, 0x00, 0x78, 0xFF,
1625 0x74, 0x01, 0xC2, 0xFC, 0xA7, 0x06, 0xA8, 0xF1, 0x25, 0x35, 0x1B,
1626 0x2B, 0xC2, 0xF1, 0x2A, 0x07, 0x41, 0xFC, 0xCE, 0x01, 0x47, 0xFF,
1627 0x31, 0x00, 0xFD, 0xFF, 0x09, 0x00, 0xDC, 0xFF, 0x31, 0x00, 0x04,
1628 0x00, 0x32, 0xFF, 0xDC, 0x02, 0x42, 0xF7, 0x0B, 0x44, 0x8E, 0x15,
1629 0x34, 0xF6, 0xB7, 0x05, 0xAB, 0xFC, 0xC1, 0x01, 0x40, 0xFF, 0x33,
1630 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x20, 0x00, 0x7E, 0xFF, 0x23, 0x01,
1631 0x0F, 0xFE, 0xD7, 0x02, 0x3B, 0xFC, 0xF5, 0x04, 0xED, 0x48, 0x70,
1632 0x02, 0x52, 0xFD, 0x46, 0x02, 0x5A, 0xFE, 0xFF, 0x00, 0x8B, 0xFF,
1633 0x1C, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xD2, 0x01, 0x81,
1634 0xFC, 0x1A, 0x06, 0x47, 0xF5, 0xC1, 0x18, 0x60, 0x42, 0xE4, 0xF5,
1635 0xA6, 0x03, 0xB9, 0xFE, 0x48, 0x00, 0x0F, 0x00, 0xE9, 0xFF, 0x07,
1636 0x00, 0xFD, 0xFF, 0x2E, 0x00, 0x53, 0xFF, 0xBB, 0x01, 0x5A, 0xFC,
1637 0x1C, 0x07, 0x8D, 0xF1, 0x34, 0x2E, 0x48, 0x32, 0x81, 0xF1, 0xE7,
1638 0x06, 0x8E, 0xFC, 0x96, 0x01, 0x66, 0xFF, 0x27, 0x00, 0xFD, 0xFF,
1639 0x04, 0x00, 0xF9, 0xFF, 0xE4, 0xFF, 0x9F, 0x00, 0x23, 0xFE, 0x9B,
1640 0x04, 0x55, 0xF4, 0xC0, 0x3F, 0x2C, 0x1D, 0x22, 0xF4, 0x8C, 0x06,
1641 0x55, 0xFC, 0xE1, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x17,
1642 0x00, 0x9F, 0xFF, 0xCE, 0x00, 0xC2, 0xFE, 0x80, 0x01, 0xC6, 0xFE,
1643 0x40, 0xFF, 0x81, 0x48, 0x9E, 0x08, 0xBA, 0xFA, 0x9A, 0x03, 0xAC,
1644 0xFD, 0x51, 0x01, 0x6C, 0xFF, 0x25, 0x00, 0x00, 0x00, 0xFF, 0xFF,
1645 0x2F, 0x00, 0x4B, 0xFF, 0xA4, 0x01, 0xF1, 0xFC, 0x1D, 0x05, 0x8F,
1646 0xF7, 0x4A, 0x11, 0xF2, 0x45, 0x6B, 0xF9, 0xAE, 0x01, 0xE2, 0xFF,
1647 0xA2, 0xFF, 0x61, 0x00, 0xC9, 0xFF, 0x0D, 0x00, 0xFD, 0xFF, 0x35,
1648 0x00, 0x3D, 0xFF, 0xE0, 0x01, 0x32, 0xFC, 0x1D, 0x07, 0x45, 0xF2,
1649 0xC6, 0x26, 0xD3, 0x38, 0x24, 0xF2, 0x2D, 0x06, 0x1B, 0xFD, 0x3B,
1650 0x01, 0x95, 0xFF, 0x16, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x11, 0x00,
1651 0xA3, 0xFF, 0x20, 0x01, 0x49, 0xFD, 0xEB, 0x05, 0x74, 0xF2, 0x54,
1652 0x3A, 0xDD, 0x24, 0x91, 0xF2, 0x0C, 0x07, 0x32, 0xFC, 0xE4, 0x01,
1653 0x3A, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x0F, 0x00, 0xC1, 0xFF, 0x76,
1654 0x00, 0x76, 0xFF, 0x32, 0x00, 0x22, 0x01, 0x76, 0xFA, 0xA3, 0x46,
1655 0x7D, 0x0F, 0x2C, 0xF8, 0xD5, 0x04, 0x13, 0xFD, 0x96, 0x01, 0x51,
1656 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x64, 0xFF,
1657 0x63, 0x01, 0x84, 0xFD, 0xEB, 0x03, 0x14, 0xFA, 0x47, 0x0A, 0x2C,
1658 0x48, 0xF6, 0xFD, 0x63, 0xFF, 0x2B, 0x01, 0xF0, 0xFE, 0xB8, 0x00,
1659 0xA8, 0xFF, 0x15, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4,
1660 0x01, 0x47, 0xFC, 0xB5, 0x06, 0xB0, 0xF3, 0x19, 0x1F, 0x7E, 0x3E,
1661 0xC4, 0xF3, 0xFA, 0x04, 0xE7, 0xFD, 0xC1, 0x00, 0xD3, 0xFF, 0xFF,
1662 0xFF, 0x02, 0x00, 0xFE, 0xFF, 0x23, 0x00, 0x71, 0xFF, 0x82, 0x01,
1663 0xAB, 0xFC, 0xC4, 0x06, 0x93, 0xF1, 0xFD, 0x33, 0x62, 0x2C, 0xA8,
1664 0xF1, 0x27, 0x07, 0x4A, 0xFC, 0xC7, 0x01, 0x4C, 0xFF, 0x30, 0x00,
1665 0xFD, 0xFF, 0x08, 0x00, 0xE1, 0xFF, 0x23, 0x00, 0x20, 0x00, 0x00,
1666 0xFF, 0x31, 0x03, 0xAD, 0xF6, 0x65, 0x43, 0xDC, 0x16, 0xD1, 0xF5,
1667 0xE1, 0x05, 0x99, 0xFC, 0xC9, 0x01, 0x3E, 0xFF, 0x33, 0x00, 0xFF,
1668 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x83, 0xFF, 0x14, 0x01, 0x2D, 0xFE,
1669 0x9C, 0x02, 0xAD, 0xFC, 0xE9, 0x03, 0xF6, 0x48, 0x73, 0x03, 0xE0,
1670 0xFC, 0x82, 0x02, 0x3B, 0xFE, 0x0E, 0x01, 0x86, 0xFF, 0x1E, 0x00,
1671 0xFE, 0xFF, 0x34, 0x00, 0x3D, 0xFF, 0xCC, 0x01, 0x91, 0xFC, 0xF3,
1672 0x05, 0xA6, 0xF5, 0x70, 0x17, 0x17, 0x43, 0x6D, 0xF6, 0x56, 0x03,
1673 0xEA, 0xFE, 0x2D, 0x00, 0x1D, 0x00, 0xE4, 0xFF, 0x08, 0x00, 0xFD,
1674 0xFF, 0x2F, 0x00, 0x4E, 0xFF, 0xC3, 0x01, 0x4E, 0xFC, 0x24, 0x07,
1675 0x9E, 0xF1, 0xF2, 0x2C, 0x78, 0x33, 0x8C, 0xF1, 0xD0, 0x06, 0xA2,
1676 0xFC, 0x88, 0x01, 0x6D, 0xFF, 0x24, 0x00, 0xFD, 0xFF, 0x03, 0x00,
1677 0xFD, 0xFF, 0xD8, 0xFF, 0xB7, 0x00, 0xF9, 0xFD, 0xDE, 0x04, 0xEF,
1678 0xF3, 0xE4, 0x3E, 0x81, 0x1E, 0xD2, 0xF3, 0xA9, 0x06, 0x4B, 0xFC,
1679 0xE3, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x16, 0x00, 0xA5,
1680 0xFF, 0xBE, 0x00, 0xE2, 0xFE, 0x45, 0x01, 0x33, 0xFF, 0x5A, 0xFE,
1681 0x48, 0x48, 0xC3, 0x09, 0x47, 0xFA, 0xD2, 0x03, 0x90, 0xFD, 0x5E,
1682 0x01, 0x66, 0xFF, 0x27, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2E, 0x00,
1683 0x4F, 0xFF, 0x9A, 0x01, 0x08, 0xFD, 0xEB, 0x04, 0xFC, 0xF7, 0x0A,
1684 0x10, 0x70, 0x46, 0x22, 0xFA, 0x4D, 0x01, 0x19, 0x00, 0x84, 0xFF,
1685 0x70, 0x00, 0xC4, 0xFF, 0x0F, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3B,
1686 0xFF, 0xE3, 0x01, 0x31, 0xFC, 0x12, 0x07, 0x79, 0xF2, 0x73, 0x25,
1687 0xDF, 0x39, 0x5A, 0xF2, 0x00, 0x06, 0x3A, 0xFD, 0x28, 0x01, 0x9F,
1688 0xFF, 0x13, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x15, 0x00, 0x99, 0xFF,
1689 0x33, 0x01, 0x29, 0xFD, 0x1A, 0x06, 0x3B, 0xF2, 0x4B, 0x39, 0x30,
1690 0x26, 0x5B, 0xF2, 0x19, 0x07, 0x31, 0xFC, 0xE1, 0x01, 0x3C, 0xFF,
1691 0x35, 0x00, 0xFD, 0xFF, 0x0E, 0x00, 0xC7, 0xFF, 0x68, 0x00, 0x95,
1692 0xFF, 0xFA, 0xFF, 0x83, 0x01, 0xBB, 0xF9, 0x2B, 0x46, 0xBB, 0x10,
1693 0xBF, 0xF7, 0x07, 0x05, 0xFB, 0xFC, 0xA0, 0x01, 0x4D, 0xFF, 0x2F,
1694 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x26, 0x00, 0x69, 0xFF, 0x56, 0x01,
1695 0xA0, 0xFD, 0xB3, 0x03, 0x87, 0xFA, 0x1F, 0x09, 0x6A, 0x48, 0xD9,
1696 0xFE, 0xF6, 0xFE, 0x65, 0x01, 0xD0, 0xFE, 0xC7, 0x00, 0xA2, 0xFF,
1697 0x17, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE2, 0x01, 0x50,
1698 0xFC, 0x99, 0x06, 0xFE, 0xF3, 0xC3, 0x1D, 0x5E, 0x3F, 0x27, 0xF4,
1699 0xB9, 0x04, 0x10, 0xFE, 0xA9, 0x00, 0xDF, 0xFF, 0xFB, 0xFF, 0x03,
1700 0x00, 0xFD, 0xFF, 0x26, 0x00, 0x69, 0xFF, 0x90, 0x01, 0x96, 0xFC,
1701 0xDD, 0x06, 0x85, 0xF1, 0xD0, 0x32, 0xA6, 0x2D, 0x94, 0xF1, 0x20,
1702 0x07, 0x54, 0xFC, 0xBF, 0x01, 0x50, 0xFF, 0x2E, 0x00, 0xFD, 0xFF,
1703 0x07, 0x00, 0xE6, 0xFF, 0x15, 0x00, 0x3C, 0x00, 0xCF, 0xFE, 0x83,
1704 0x03, 0x20, 0xF6, 0xB2, 0x42, 0x2B, 0x18, 0x71, 0xF5, 0x09, 0x06,
1705 0x88, 0xFC, 0xCF, 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0x1D,
1706 0x00, 0x89, 0xFF, 0x06, 0x01, 0x4C, 0xFE, 0x60, 0x02, 0x1F, 0xFD,
1707 0xE2, 0x02, 0xF3, 0x48, 0x7D, 0x04, 0x6E, 0xFC, 0xBD, 0x02, 0x1C,
1708 0xFE, 0x1C, 0x01, 0x80, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF,
1709 0x33, 0x00, 0x3F, 0xFF, 0xC5, 0x01, 0xA3, 0xFC, 0xCA, 0x05, 0x07,
1710 0xF6, 0x22, 0x16, 0xC3, 0x43, 0xFE, 0xF6, 0x02, 0x03, 0x1B, 0xFF,
1711 0x11, 0x00, 0x2B, 0x00, 0xDE, 0xFF, 0x09, 0x00, 0xFD, 0xFF, 0x31,
1712 0x00, 0x49, 0xFF, 0xCB, 0x01, 0x45, 0xFC, 0x29, 0x07, 0xB6, 0xF1,
1713 0xAD, 0x2B, 0xA2, 0x34, 0x9E, 0xF1, 0xB4, 0x06, 0xB8, 0xFC, 0x7A,
1714 0x01, 0x75, 0xFF, 0x22, 0x00, 0xFE, 0xFF, 0x02, 0x00, 0x02, 0x00,
1715 0xCC, 0xFF, 0xCE, 0x00, 0xD1, 0xFD, 0x1D, 0x05, 0x91, 0xF3, 0xFE,
1716 0x3D, 0xD7, 0x1F, 0x87, 0xF3, 0xC3, 0x06, 0x42, 0xFC, 0xE5, 0x01,
1717 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x14, 0x00, 0xAB, 0xFF, 0xAF,
1718 0x00, 0x01, 0xFF, 0x0A, 0x01, 0x9E, 0xFF, 0x7C, 0xFD, 0x03, 0x48,
1719 0xED, 0x0A, 0xD5, 0xF9, 0x0A, 0x04, 0x74, 0xFD, 0x6A, 0x01, 0x62,
1720 0xFF, 0x28, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x2D, 0x00, 0x53, 0xFF,
1721 0x90, 0x01, 0x20, 0xFD, 0xB8, 0x04, 0x6A, 0xF8, 0xCD, 0x0E, 0xE1,
1722 0x46, 0xE1, 0xFA, 0xEB, 0x00, 0x51, 0x00, 0x65, 0xFF, 0x7F, 0x00,
1723 0xBE, 0xFF, 0x10, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE5,
1724 0x01, 0x33, 0xFC, 0x04, 0x07, 0xB1, 0xF2, 0x21, 0x24, 0xE6, 0x3A,
1725 0x97, 0xF2, 0xD0, 0x05, 0x5B, 0xFD, 0x15, 0x01, 0xA9, 0xFF, 0x0F,
1726 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x00, 0x90, 0xFF, 0x45, 0x01,
1727 0x0B, 0xFD, 0x44, 0x06, 0x0A, 0xF2, 0x3B, 0x38, 0x80, 0x27, 0x2B,
1728 0xF2, 0x22, 0x07, 0x33, 0xFC, 0xDE, 0x01, 0x3E, 0xFF, 0x34, 0x00,
1729 0xFD, 0xFF, 0x0D, 0x00, 0xCD, 0xFF, 0x59, 0x00, 0xB3, 0xFF, 0xC4,
1730 0xFF, 0xE2, 0x01, 0x09, 0xF9, 0xAA, 0x45, 0xFE, 0x11, 0x54, 0xF7,
1731 0x38, 0x05, 0xE4, 0xFC, 0xAA, 0x01, 0x49, 0xFF, 0x30, 0x00, 0xFF,
1732 0xFF, 0x00, 0x00, 0x24, 0x00, 0x6E, 0xFF, 0x49, 0x01, 0xBC, 0xFD,
1733 0x7A, 0x03, 0xFA, 0xFA, 0xFD, 0x07, 0x9C, 0x48, 0xC3, 0xFF, 0x89,
1734 0xFE, 0xA1, 0x01, 0xB1, 0xFE, 0xD6, 0x00, 0x9C, 0xFF, 0x18, 0x00,
1735 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xDF, 0x01, 0x5B, 0xFC, 0x7B,
1736 0x06, 0x50, 0xF4, 0x6E, 0x1C, 0x36, 0x40, 0x92, 0xF4, 0x75, 0x04,
1737 0x3B, 0xFE, 0x91, 0x00, 0xEB, 0xFF, 0xF6, 0xFF, 0x04, 0x00, 0xFD,
1738 0xFF, 0x28, 0x00, 0x63, 0xFF, 0x9D, 0x01, 0x84, 0xFC, 0xF3, 0x06,
1739 0x7D, 0xF1, 0x9E, 0x31, 0xE6, 0x2E, 0x85, 0xF1, 0x16, 0x07, 0x61,
1740 0xFC, 0xB5, 0x01, 0x55, 0xFF, 0x2D, 0x00, 0xFD, 0xFF, 0x06, 0x00,
1741 0xEC, 0xFF, 0x08, 0x00, 0x57, 0x00, 0x9F, 0xFE, 0xD1, 0x03, 0x9B,
1742 0xF5, 0xF7, 0x41, 0x7C, 0x19, 0x13, 0xF5, 0x2F, 0x06, 0x78, 0xFC,
1743 0xD5, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x8F,
1744 0xFF, 0xF7, 0x00, 0x6B, 0xFE, 0x25, 0x02, 0x91, 0xFD, 0xE3, 0x01,
1745 0xE5, 0x48, 0x8D, 0x05, 0xFB, 0xFB, 0xF8, 0x02, 0xFE, 0xFD, 0x2B,
1746 0x01, 0x7A, 0xFF, 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x32, 0x00,
1747 0x42, 0xFF, 0xBD, 0x01, 0xB6, 0xFC, 0x9F, 0x05, 0x6C, 0xF6, 0xD6,
1748 0x14, 0x65, 0x44, 0x98, 0xF7, 0xAC, 0x02, 0x4E, 0xFF, 0xF4, 0xFF,
1749 0x39, 0x00, 0xD9, 0xFF, 0x0A, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x45,
1750 0xFF, 0xD2, 0x01, 0x3D, 0xFC, 0x2B, 0x07, 0xD4, 0xF1, 0x64, 0x2A,
1751 0xC6, 0x35, 0xB7, 0xF1, 0x96, 0x06, 0xCF, 0xFC, 0x6B, 0x01, 0x7D,
1752 0xFF, 0x1F, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x06, 0x00, 0xC1, 0xFF,
1753 0xE5, 0x00, 0xAA, 0xFD, 0x58, 0x05, 0x3A, 0xF3, 0x11, 0x3D, 0x2C,
1754 0x21, 0x3F, 0xF3, 0xDA, 0x06, 0x3B, 0xFC, 0xE6, 0x01, 0x36, 0xFF,
1755 0x36, 0x00, 0xFD, 0xFF, 0x13, 0x00, 0xB1, 0xFF, 0xA0, 0x00, 0x20,
1756 0xFF, 0xD0, 0x00, 0x07, 0x00, 0xA4, 0xFC, 0xB6, 0x47, 0x1C, 0x0C,
1757 0x63, 0xF9, 0x42, 0x04, 0x59, 0xFD, 0x76, 0x01, 0x5D, 0xFF, 0x2A,
1758 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x57, 0xFF, 0x85, 0x01,
1759 0x39, 0xFD, 0x84, 0x04, 0xD9, 0xF8, 0x95, 0x0D, 0x48, 0x47, 0xA7,
1760 0xFB, 0x86, 0x00, 0x8A, 0x00, 0x46, 0xFF, 0x8E, 0x00, 0xB8, 0xFF,
1761 0x11, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x35,
1762 0xFC, 0xF3, 0x06, 0xEE, 0xF2, 0xCD, 0x22, 0xE4, 0x3B, 0xDC, 0xF2,
1763 0x9C, 0x05, 0x7E, 0xFD, 0x00, 0x01, 0xB4, 0xFF, 0x0B, 0x00, 0x01,
1764 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x87, 0xFF, 0x57, 0x01, 0xEF, 0xFC,
1765 0x6B, 0x06, 0xE0, 0xF1, 0x23, 0x37, 0xCE, 0x28, 0x01, 0xF2, 0x28,
1766 0x07, 0x36, 0xFC, 0xD9, 0x01, 0x41, 0xFF, 0x33, 0x00, 0xFD, 0xFF,
1767 0x0B, 0x00, 0xD2, 0xFF, 0x4A, 0x00, 0xD0, 0xFF, 0x8E, 0xFF, 0x3F,
1768 0x02, 0x5E, 0xF8, 0x1E, 0x45, 0x44, 0x13, 0xEA, 0xF6, 0x67, 0x05,
1769 0xCF, 0xFC, 0xB3, 0x01, 0x46, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x00,
1770 0x00, 0x23, 0x00, 0x74, 0xFF, 0x3C, 0x01, 0xDA, 0xFD, 0x40, 0x03,
1771 0x6E, 0xFB, 0xE1, 0x06, 0xC3, 0x48, 0xB3, 0x00, 0x1A, 0xFE, 0xDC,
1772 0x01, 0x91, 0xFE, 0xE5, 0x00, 0x96, 0xFF, 0x1A, 0x00, 0xFE, 0xFF,
1773 0x36, 0x00, 0x38, 0xFF, 0xDB, 0x01, 0x67, 0xFC, 0x5A, 0x06, 0xA6,
1774 0xF4, 0x1B, 0x1B, 0x07, 0x41, 0x04, 0xF5, 0x2D, 0x04, 0x67, 0xFE,
1775 0x77, 0x00, 0xF8, 0xFF, 0xF2, 0xFF, 0x05, 0x00, 0xFD, 0xFF, 0x2A,
1776 0x00, 0x5C, 0xFF, 0xA8, 0x01, 0x73, 0xFC, 0x05, 0x07, 0x7D, 0xF1,
1777 0x67, 0x30, 0x21, 0x30, 0x7E, 0xF1, 0x08, 0x07, 0x6F, 0xFC, 0xAB,
1778 0x01, 0x5B, 0xFF, 0x2B, 0x00, 0xFD, 0xFF, 0x05, 0x00, 0xF0, 0xFF,
1779 0xFB, 0xFF, 0x71, 0x00, 0x71, 0xFE, 0x1D, 0x04, 0x1F, 0xF5, 0x32,
1780 0x41, 0xCE, 0x1A, 0xBA, 0xF4, 0x53, 0x06, 0x6A, 0xFC, 0xDA, 0x01,
1781 0x38, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x1A, 0x00, 0x95, 0xFF, 0xE8,
1782 0x00, 0x8A, 0xFE, 0xE9, 0x01, 0x01, 0xFE, 0xEA, 0x00, 0xCB, 0x48,
1783 0xA2, 0x06, 0x87, 0xFB, 0x33, 0x03, 0xE0, 0xFD, 0x39, 0x01, 0x75,
1784 0xFF, 0x23, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x45, 0xFF,
1785 0xB5, 0x01, 0xCA, 0xFC, 0x72, 0x05, 0xD3, 0xF6, 0x8D, 0x13, 0xFD,
1786 0x44, 0x39, 0xF8, 0x53, 0x02, 0x82, 0xFF, 0xD7, 0xFF, 0x47, 0x00,
1787 0xD3, 0xFF, 0x0B, 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x42, 0xFF, 0xD8,
1788 0x01, 0x37, 0xFC, 0x29, 0x07, 0xF8, 0xF1, 0x19, 0x29, 0xE5, 0x36,
1789 0xD8, 0xF1, 0x73, 0x06, 0xE9, 0xFC, 0x5B, 0x01, 0x85, 0xFF, 0x1C,
1790 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x0A, 0x00, 0xB6, 0xFF, 0xFB, 0x00,
1791 0x85, 0xFD, 0x90, 0x05, 0xEC, 0xF2, 0x1C, 0x3C, 0x81, 0x22, 0xFC,
1792 0xF2, 0xEF, 0x06, 0x36, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00,
1793 0xFD, 0xFF, 0x12, 0x00, 0xB7, 0xFF, 0x91, 0x00, 0x40, 0xFF, 0x96,
1794 0x00, 0x6F, 0x00, 0xD5, 0xFB, 0x5E, 0x47, 0x50, 0x0D, 0xF2, 0xF8,
1795 0x78, 0x04, 0x3F, 0xFD, 0x82, 0x01, 0x58, 0xFF, 0x2B, 0x00, 0x00,
1796 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5C, 0xFF, 0x79, 0x01, 0x53, 0xFD,
1797 0x4E, 0x04, 0x4A, 0xF9, 0x60, 0x0C, 0xA3, 0x47, 0x76, 0xFC, 0x1F,
1798 0x00, 0xC3, 0x00, 0x27, 0xFF, 0x9D, 0x00, 0xB2, 0xFF, 0x13, 0x00,
1799 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x3A, 0xFC, 0xDF,
1800 0x06, 0x30, 0xF3, 0x78, 0x21, 0xDB, 0x3C, 0x28, 0xF3, 0x65, 0x05,
1801 0xA2, 0xFD, 0xEA, 0x00, 0xBE, 0xFF, 0x07, 0x00, 0x01, 0x00, 0xFE,
1802 0xFF, 0x1E, 0x00, 0x7F, 0xFF, 0x67, 0x01, 0xD5, 0xFC, 0x8E, 0x06,
1803 0xBE, 0xF1, 0x06, 0x36, 0x1A, 0x2A, 0xDC, 0xF1, 0x2A, 0x07, 0x3C,
1804 0xFC, 0xD3, 0x01, 0x44, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x0A, 0x00,
1805 0xD8, 0xFF, 0x3C, 0x00, 0xEE, 0xFF, 0x5A, 0xFF, 0x98, 0x02, 0xBB,
1806 0xF7, 0x87, 0x44, 0x8C, 0x14, 0x83, 0xF6, 0x95, 0x05, 0xBA, 0xFC,
1807 0xBB, 0x01, 0x43, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x21,
1808 0x00, 0x79, 0xFF, 0x2E, 0x01, 0xF7, 0xFD, 0x05, 0x03, 0xE1, 0xFB,
1809 0xCA, 0x05, 0xDF, 0x48, 0xAB, 0x01, 0xAA, 0xFD, 0x18, 0x02, 0x72,
1810 0xFE, 0xF4, 0x00, 0x90, 0xFF, 0x1B, 0x00, 0xFE, 0xFF, 0x35, 0x00,
1811 0x39, 0xFF, 0xD6, 0x01, 0x75, 0xFC, 0x37, 0x06, 0xFF, 0xF4, 0xC7,
1812 0x19, 0xCC, 0x41, 0x7F, 0xF5, 0xE2, 0x03, 0x95, 0xFE, 0x5D, 0x00,
1813 0x05, 0x00, 0xED, 0xFF, 0x06, 0x00, 0xFD, 0xFF, 0x2C, 0x00, 0x57,
1814 0xFF, 0xB3, 0x01, 0x64, 0xFC, 0x13, 0x07, 0x83, 0xF1, 0x2C, 0x2F,
1815 0x5A, 0x31, 0x7D, 0xF1, 0xF7, 0x06, 0x80, 0xFC, 0x9F, 0x01, 0x61,
1816 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0x04, 0x00, 0xF5, 0xFF, 0xEE, 0xFF,
1817 0x8B, 0x00, 0x44, 0xFE, 0x65, 0x04, 0xAA, 0xF4, 0x66, 0x40, 0x23,
1818 0x1C, 0x63, 0xF4, 0x74, 0x06, 0x5D, 0xFC, 0xDE, 0x01, 0x37, 0xFF,
1819 0x36, 0x00, 0xFE, 0xFF, 0x19, 0x00, 0x9A, 0xFF, 0xD9, 0x00, 0xAA,
1820 0xFE, 0xAE, 0x01, 0x70, 0xFE, 0xF8, 0xFF, 0xA6, 0x48, 0xBE, 0x07,
1821 0x14, 0xFB, 0x6D, 0x03, 0xC3, 0xFD, 0x46, 0x01, 0x70, 0xFF, 0x24,
1822 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0x00, 0x48, 0xFF, 0xAC, 0x01,
1823 0xDF, 0xFC, 0x43, 0x05, 0x3C, 0xF7, 0x46, 0x12, 0x8D, 0x45, 0xE2,
1824 0xF8, 0xF7, 0x01, 0xB8, 0xFF, 0xB9, 0xFF, 0x56, 0x00, 0xCE, 0xFF,
1825 0x0C, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x3F, 0xFF, 0xDD, 0x01, 0x34,
1826 0xFC, 0x23, 0x07, 0x21, 0xF2, 0xCB, 0x27, 0xFE, 0x37, 0x00, 0xF2,
1827 0x4D, 0x06, 0x04, 0xFD, 0x49, 0x01, 0x8E, 0xFF, 0x19, 0x00, 0xFF,
1828 0xFF, 0x00, 0x00, 0x0E, 0x00, 0xAB, 0xFF, 0x10, 0x01, 0x62, 0xFD,
1829 0xC5, 0x05, 0xA5, 0xF2, 0x1F, 0x3B, 0xD6, 0x23, 0xBE, 0xF2, 0x01,
1830 0x07, 0x33, 0xFC, 0xE5, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
1831 0x10, 0x00, 0xBD, 0xFF, 0x82, 0x00, 0x5E, 0xFF, 0x5D, 0x00, 0xD4,
1832 0x00, 0x0C, 0xFB, 0xF9, 0x46, 0x87, 0x0E, 0x82, 0xF8, 0xAD, 0x04,
1833 0x26, 0xFD, 0x8D, 0x01, 0x54, 0xFF, 0x2C, 0x00, 0xFF, 0xFF, 0x00,
1834 0x00, 0x29, 0x00, 0x60, 0xFF, 0x6D, 0x01, 0x6E, 0xFD, 0x17, 0x04,
1835 0xBC, 0xF9, 0x30, 0x0B, 0xF4, 0x47, 0x4B, 0xFD, 0xB5, 0xFF, 0xFD,
1836 0x00, 0x08, 0xFF, 0xAC, 0x00, 0xAC, 0xFF, 0x14, 0x00, 0xFD, 0xFF,
1837 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x41, 0xFC, 0xC8, 0x06, 0x76,
1838 0xF3, 0x22, 0x20, 0xCA, 0x3D, 0x7D, 0xF3, 0x2A, 0x05, 0xC8, 0xFD,
1839 0xD4, 0x00, 0xCA, 0xFF, 0x03, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x21,
1840 0x00, 0x77, 0xFF, 0x77, 0x01, 0xBD, 0xFC, 0xAE, 0x06, 0xA3, 0xF1,
1841 0xE3, 0x34, 0x64, 0x2B, 0xBC, 0xF1, 0x2A, 0x07, 0x43, 0xFC, 0xCD,
1842 0x01, 0x48, 0xFF, 0x31, 0x00, 0xFD, 0xFF, 0x09, 0x00, 0xDD, 0xFF,
1843 0x2E, 0x00, 0x0A, 0x00, 0x27, 0xFF, 0xEF, 0x02, 0x20, 0xF7, 0xE7,
1844 0x43, 0xD8, 0x15, 0x1E, 0xF6, 0xC0, 0x05, 0xA7, 0xFC, 0xC3, 0x01,
1845 0x40, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x20, 0x00, 0x7F,
1846 0xFF, 0x20, 0x01, 0x16, 0xFE, 0xCA, 0x02, 0x54, 0xFC, 0xB9, 0x04,
1847 0xF2, 0x48, 0xA9, 0x02, 0x39, 0xFD, 0x53, 0x02, 0x53, 0xFE, 0x03,
1848 0x01, 0x8A, 0xFF, 0x1D, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3B, 0xFF,
1849 0xD1, 0x01, 0x84, 0xFC, 0x12, 0x06, 0x5C, 0xF5, 0x76, 0x18, 0x89,
1850 0x42, 0x02, 0xF6, 0x94, 0x03, 0xC4, 0xFE, 0x42, 0x00, 0x12, 0x00,
1851 0xE8, 0xFF, 0x07, 0x00, 0xFD, 0xFF, 0x2E, 0x00, 0x51, 0xFF, 0xBD,
1852 0x01, 0x57, 0xFC, 0x1E, 0x07, 0x90, 0xF1, 0xED, 0x2D, 0x8C, 0x32,
1853 0x83, 0xF1, 0xE2, 0x06, 0x92, 0xFC, 0x93, 0x01, 0x68, 0xFF, 0x26,
1854 0x00, 0xFD, 0xFF, 0x03, 0x00, 0xFA, 0xFF, 0xE2, 0xFF, 0xA4, 0x00,
1855 0x19, 0xFE, 0xAA, 0x04, 0x3E, 0xF4, 0x90, 0x3F, 0x78, 0x1D, 0x10,
1856 0xF4, 0x93, 0x06, 0x52, 0xFC, 0xE1, 0x01, 0x36, 0xFF, 0x36, 0x00,
1857 0xFE, 0xFF, 0x17, 0x00, 0xA0, 0xFF, 0xCA, 0x00, 0xC9, 0xFE, 0x73,
1858 0x01, 0xDE, 0xFE, 0x0C, 0xFF, 0x76, 0x48, 0xDE, 0x08, 0xA1, 0xFA,
1859 0xA6, 0x03, 0xA6, 0xFD, 0x53, 0x01, 0x6A, 0xFF, 0x26, 0x00, 0x00,
1860 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4C, 0xFF, 0xA2, 0x01, 0xF6, 0xFC,
1861 0x12, 0x05, 0xA7, 0xF7, 0x03, 0x11, 0x10, 0x46, 0x93, 0xF9, 0x98,
1862 0x01, 0xEE, 0xFF, 0x9B, 0xFF, 0x64, 0x00, 0xC8, 0xFF, 0x0E, 0x00,
1863 0xFD, 0xFF, 0x35, 0x00, 0x3C, 0xFF, 0xE1, 0x01, 0x32, 0xFC, 0x1B,
1864 0x07, 0x50, 0xF2, 0x7B, 0x26, 0x11, 0x39, 0x2F, 0xF2, 0x23, 0x06,
1865 0x22, 0xFD, 0x37, 0x01, 0x97, 0xFF, 0x15, 0x00, 0xFF, 0xFF, 0x00,
1866 0x00, 0x12, 0x00, 0xA1, 0xFF, 0x24, 0x01, 0x41, 0xFD, 0xF6, 0x05,
1867 0x67, 0xF2, 0x1A, 0x3A, 0x29, 0x25, 0x84, 0xF2, 0x0F, 0x07, 0x31,
1868 0xFC, 0xE3, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x0F, 0x00,
1869 0xC2, 0xFF, 0x73, 0x00, 0x7D, 0xFF, 0x25, 0x00, 0x38, 0x01, 0x4C,
1870 0xFA, 0x89, 0x46, 0xC3, 0x0F, 0x14, 0xF8, 0xE0, 0x04, 0x0D, 0xFD,
1871 0x98, 0x01, 0x50, 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x27,
1872 0x00, 0x65, 0xFF, 0x60, 0x01, 0x8A, 0xFD, 0xDF, 0x03, 0x2E, 0xFA,
1873 0x04, 0x0A, 0x3A, 0x48, 0x28, 0xFE, 0x4B, 0xFF, 0x38, 0x01, 0xE9,
1874 0xFE, 0xBB, 0x00, 0xA6, 0xFF, 0x16, 0x00, 0xFE, 0xFF, 0x36, 0x00,
1875 0x36, 0xFF, 0xE4, 0x01, 0x49, 0xFC, 0xAF, 0x06, 0xC1, 0xF3, 0xCD,
1876 0x1E, 0xB1, 0x3E, 0xD9, 0xF3, 0xEC, 0x04, 0xF0, 0xFD, 0xBC, 0x00,
1877 0xD5, 0xFF, 0xFE, 0xFF, 0x03, 0x00, 0xFD, 0xFF, 0x24, 0x00, 0x6F,
1878 0xFF, 0x85, 0x01, 0xA6, 0xFC, 0xCA, 0x06, 0x8F, 0xF1, 0xBB, 0x33,
1879 0xAB, 0x2C, 0xA3, 0xF1, 0x26, 0x07, 0x4C, 0xFC, 0xC5, 0x01, 0x4D,
1880 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x08, 0x00, 0xE2, 0xFF, 0x20, 0x00,
1881 0x26, 0x00, 0xF5, 0xFE, 0x43, 0x03, 0x8D, 0xF6, 0x3C, 0x43, 0x25,
1882 0x17, 0xBB, 0xF5, 0xEA, 0x05, 0x95, 0xFC, 0xCA, 0x01, 0x3D, 0xFF,
1883 0x34, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x1E, 0x00, 0x84, 0xFF, 0x11,
1884 0x01, 0x34, 0xFE, 0x8F, 0x02, 0xC7, 0xFC, 0xAE, 0x03, 0xF7, 0x48,
1885 0xAE, 0x03, 0xC7, 0xFC, 0x8F, 0x02, 0x34, 0xFE, 0x11, 0x01, 0x84,
1886 0xFF, 0x1E, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01,
1887 0x3D, 0xFC, 0xD6, 0x06, 0x4C, 0xF3, 0xED, 0x20, 0x3D, 0x3D, 0x4A,
1888 0xF3, 0x4E, 0x05, 0xB1, 0xFD, 0xE1, 0x00, 0xC3, 0xFF, 0x05, 0x00,
1889 0x02, 0x00, 0x02, 0x00, 0x05, 0x00, 0xC3, 0xFF, 0xE1, 0x00, 0xB1,
1890 0xFD, 0x4E, 0x05, 0x4A, 0xF3, 0x3D, 0x3D, 0xED, 0x20, 0x4C, 0xF3,
1891 0xD6, 0x06, 0x3D, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD,
1892 0xFF, 0x00, 0x00, 0x1E, 0x00, 0x84, 0xFF, 0x11, 0x01, 0x34, 0xFE,
1893 0x8F, 0x02, 0xC7, 0xFC, 0xAE, 0x03, 0xF7, 0x48, 0xAE, 0x03, 0xC7,
1894 0xFC, 0x8F, 0x02, 0x34, 0xFE, 0x11, 0x01, 0x84, 0xFF, 0x1E, 0x00,
1895 0xFD, 0xFF, 0x30, 0x00, 0x4D, 0xFF, 0xC5, 0x01, 0x4C, 0xFC, 0x26,
1896 0x07, 0xA3, 0xF1, 0xAB, 0x2C, 0xBB, 0x33, 0x8F, 0xF1, 0xCA, 0x06,
1897 0xA6, 0xFC, 0x85, 0x01, 0x6F, 0xFF, 0x24, 0x00, 0xFD, 0xFF, 0x16,
1898 0x00, 0xA6, 0xFF, 0xBB, 0x00, 0xE9, 0xFE, 0x38, 0x01, 0x4B, 0xFF,
1899 0x28, 0xFE, 0x3A, 0x48, 0x04, 0x0A, 0x2E, 0xFA, 0xDF, 0x03, 0x8A,
1900 0xFD, 0x60, 0x01, 0x65, 0xFF, 0x27, 0x00, 0x00, 0x00, 0xFD, 0xFF,
1901 0x35, 0x00, 0x3A, 0xFF, 0xE3, 0x01, 0x31, 0xFC, 0x0F, 0x07, 0x84,
1902 0xF2, 0x29, 0x25, 0x1A, 0x3A, 0x67, 0xF2, 0xF6, 0x05, 0x41, 0xFD,
1903 0x24, 0x01, 0xA1, 0xFF, 0x12, 0x00, 0x00, 0x00, 0x0E, 0x00, 0xC8,
1904 0xFF, 0x64, 0x00, 0x9B, 0xFF, 0xEE, 0xFF, 0x98, 0x01, 0x93, 0xF9,
1905 0x10, 0x46, 0x03, 0x11, 0xA7, 0xF7, 0x12, 0x05, 0xF6, 0xFC, 0xA2,
1906 0x01, 0x4C, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00,
1907 0x36, 0xFF, 0xE1, 0x01, 0x52, 0xFC, 0x93, 0x06, 0x10, 0xF4, 0x78,
1908 0x1D, 0x90, 0x3F, 0x3E, 0xF4, 0xAA, 0x04, 0x19, 0xFE, 0xA4, 0x00,
1909 0xE2, 0xFF, 0xFA, 0xFF, 0x03, 0x00, 0x07, 0x00, 0xE8, 0xFF, 0x12,
1910 0x00, 0x42, 0x00, 0xC4, 0xFE, 0x94, 0x03, 0x02, 0xF6, 0x89, 0x42,
1911 0x76, 0x18, 0x5C, 0xF5, 0x12, 0x06, 0x84, 0xFC, 0xD1, 0x01, 0x3B,
1912 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x33, 0x00, 0x40, 0xFF,
1913 0xC3, 0x01, 0xA7, 0xFC, 0xC0, 0x05, 0x1E, 0xF6, 0xD8, 0x15, 0xE7,
1914 0x43, 0x20, 0xF7, 0xEF, 0x02, 0x27, 0xFF, 0x0A, 0x00, 0x2E, 0x00,
1915 0xDD, 0xFF, 0x09, 0x00, 0x02, 0x00, 0x03, 0x00, 0xCA, 0xFF, 0xD4,
1916 0x00, 0xC8, 0xFD, 0x2A, 0x05, 0x7D, 0xF3, 0xCA, 0x3D, 0x22, 0x20,
1917 0x76, 0xF3, 0xC8, 0x06, 0x41, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36,
1918 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x2C, 0x00, 0x54, 0xFF, 0x8D, 0x01,
1919 0x26, 0xFD, 0xAD, 0x04, 0x82, 0xF8, 0x87, 0x0E, 0xF9, 0x46, 0x0C,
1920 0xFB, 0xD4, 0x00, 0x5D, 0x00, 0x5E, 0xFF, 0x82, 0x00, 0xBD, 0xFF,
1921 0x10, 0x00, 0xFF, 0xFF, 0x19, 0x00, 0x8E, 0xFF, 0x49, 0x01, 0x04,
1922 0xFD, 0x4D, 0x06, 0x00, 0xF2, 0xFE, 0x37, 0xCB, 0x27, 0x21, 0xF2,
1923 0x23, 0x07, 0x34, 0xFC, 0xDD, 0x01, 0x3F, 0xFF, 0x34, 0x00, 0xFD,
1924 0xFF, 0x00, 0x00, 0x24, 0x00, 0x70, 0xFF, 0x46, 0x01, 0xC3, 0xFD,
1925 0x6D, 0x03, 0x14, 0xFB, 0xBE, 0x07, 0xA6, 0x48, 0xF8, 0xFF, 0x70,
1926 0xFE, 0xAE, 0x01, 0xAA, 0xFE, 0xD9, 0x00, 0x9A, 0xFF, 0x19, 0x00,
1927 0xFD, 0xFF, 0x29, 0x00, 0x61, 0xFF, 0x9F, 0x01, 0x80, 0xFC, 0xF7,
1928 0x06, 0x7D, 0xF1, 0x5A, 0x31, 0x2C, 0x2F, 0x83, 0xF1, 0x13, 0x07,
1929 0x64, 0xFC, 0xB3, 0x01, 0x57, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0x1B,
1930 0x00, 0x90, 0xFF, 0xF4, 0x00, 0x72, 0xFE, 0x18, 0x02, 0xAA, 0xFD,
1931 0xAB, 0x01, 0xDF, 0x48, 0xCA, 0x05, 0xE1, 0xFB, 0x05, 0x03, 0xF7,
1932 0xFD, 0x2E, 0x01, 0x79, 0xFF, 0x21, 0x00, 0x00, 0x00, 0xFD, 0xFF,
1933 0x32, 0x00, 0x44, 0xFF, 0xD3, 0x01, 0x3C, 0xFC, 0x2A, 0x07, 0xDC,
1934 0xF1, 0x1A, 0x2A, 0x06, 0x36, 0xBE, 0xF1, 0x8E, 0x06, 0xD5, 0xFC,
1935 0x67, 0x01, 0x7F, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0x13, 0x00, 0xB2,
1936 0xFF, 0x9D, 0x00, 0x27, 0xFF, 0xC3, 0x00, 0x1F, 0x00, 0x76, 0xFC,
1937 0xA3, 0x47, 0x60, 0x0C, 0x4A, 0xF9, 0x4E, 0x04, 0x53, 0xFD, 0x79,
1938 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00,
1939 0x37, 0xFF, 0xE6, 0x01, 0x36, 0xFC, 0xEF, 0x06, 0xFC, 0xF2, 0x81,
1940 0x22, 0x1C, 0x3C, 0xEC, 0xF2, 0x90, 0x05, 0x85, 0xFD, 0xFB, 0x00,
1941 0xB6, 0xFF, 0x0A, 0x00, 0x01, 0x00, 0x0B, 0x00, 0xD3, 0xFF, 0x47,
1942 0x00, 0xD7, 0xFF, 0x82, 0xFF, 0x53, 0x02, 0x39, 0xF8, 0xFD, 0x44,
1943 0x8D, 0x13, 0xD3, 0xF6, 0x72, 0x05, 0xCA, 0xFC, 0xB5, 0x01, 0x45,
1944 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x35, 0x00, 0x38, 0xFF,
1945 0xDA, 0x01, 0x6A, 0xFC, 0x53, 0x06, 0xBA, 0xF4, 0xCE, 0x1A, 0x32,
1946 0x41, 0x1F, 0xF5, 0x1D, 0x04, 0x71, 0xFE, 0x71, 0x00, 0xFB, 0xFF,
1947 0xF0, 0xFF, 0x05, 0x00, 0x05, 0x00, 0xF2, 0xFF, 0xF8, 0xFF, 0x77,
1948 0x00, 0x67, 0xFE, 0x2D, 0x04, 0x04, 0xF5, 0x07, 0x41, 0x1B, 0x1B,
1949 0xA6, 0xF4, 0x5A, 0x06, 0x67, 0xFC, 0xDB, 0x01, 0x38, 0xFF, 0x36,
1950 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x31, 0x00, 0x46, 0xFF, 0xB3, 0x01,
1951 0xCF, 0xFC, 0x67, 0x05, 0xEA, 0xF6, 0x44, 0x13, 0x1E, 0x45, 0x5E,
1952 0xF8, 0x3F, 0x02, 0x8E, 0xFF, 0xD0, 0xFF, 0x4A, 0x00, 0xD2, 0xFF,
1953 0x0B, 0x00, 0x01, 0x00, 0x0B, 0x00, 0xB4, 0xFF, 0x00, 0x01, 0x7E,
1954 0xFD, 0x9C, 0x05, 0xDC, 0xF2, 0xE4, 0x3B, 0xCD, 0x22, 0xEE, 0xF2,
1955 0xF3, 0x06, 0x35, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD,
1956 0xFF, 0x00, 0x00, 0x2A, 0x00, 0x5D, 0xFF, 0x76, 0x01, 0x59, 0xFD,
1957 0x42, 0x04, 0x63, 0xF9, 0x1C, 0x0C, 0xB6, 0x47, 0xA4, 0xFC, 0x07,
1958 0x00, 0xD0, 0x00, 0x20, 0xFF, 0xA0, 0x00, 0xB1, 0xFF, 0x13, 0x00,
1959 0xFE, 0xFF, 0x1F, 0x00, 0x7D, 0xFF, 0x6B, 0x01, 0xCF, 0xFC, 0x96,
1960 0x06, 0xB7, 0xF1, 0xC6, 0x35, 0x64, 0x2A, 0xD4, 0xF1, 0x2B, 0x07,
1961 0x3D, 0xFC, 0xD2, 0x01, 0x45, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x00,
1962 0x00, 0x21, 0x00, 0x7A, 0xFF, 0x2B, 0x01, 0xFE, 0xFD, 0xF8, 0x02,
1963 0xFB, 0xFB, 0x8D, 0x05, 0xE5, 0x48, 0xE3, 0x01, 0x91, 0xFD, 0x25,
1964 0x02, 0x6B, 0xFE, 0xF7, 0x00, 0x8F, 0xFF, 0x1C, 0x00, 0xFD, 0xFF,
1965 0x2D, 0x00, 0x55, 0xFF, 0xB5, 0x01, 0x61, 0xFC, 0x16, 0x07, 0x85,
1966 0xF1, 0xE6, 0x2E, 0x9E, 0x31, 0x7D, 0xF1, 0xF3, 0x06, 0x84, 0xFC,
1967 0x9D, 0x01, 0x63, 0xFF, 0x28, 0x00, 0xFD, 0xFF, 0x18, 0x00, 0x9C,
1968 0xFF, 0xD6, 0x00, 0xB1, 0xFE, 0xA1, 0x01, 0x89, 0xFE, 0xC3, 0xFF,
1969 0x9C, 0x48, 0xFD, 0x07, 0xFA, 0xFA, 0x7A, 0x03, 0xBC, 0xFD, 0x49,
1970 0x01, 0x6E, 0xFF, 0x24, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x34, 0x00,
1971 0x3E, 0xFF, 0xDE, 0x01, 0x33, 0xFC, 0x22, 0x07, 0x2B, 0xF2, 0x80,
1972 0x27, 0x3B, 0x38, 0x0A, 0xF2, 0x44, 0x06, 0x0B, 0xFD, 0x45, 0x01,
1973 0x90, 0xFF, 0x18, 0x00, 0xFF, 0xFF, 0x10, 0x00, 0xBE, 0xFF, 0x7F,
1974 0x00, 0x65, 0xFF, 0x51, 0x00, 0xEB, 0x00, 0xE1, 0xFA, 0xE1, 0x46,
1975 0xCD, 0x0E, 0x6A, 0xF8, 0xB8, 0x04, 0x20, 0xFD, 0x90, 0x01, 0x53,
1976 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF,
1977 0xE5, 0x01, 0x42, 0xFC, 0xC3, 0x06, 0x87, 0xF3, 0xD7, 0x1F, 0xFE,
1978 0x3D, 0x91, 0xF3, 0x1D, 0x05, 0xD1, 0xFD, 0xCE, 0x00, 0xCC, 0xFF,
1979 0x02, 0x00, 0x02, 0x00, 0x09, 0x00, 0xDE, 0xFF, 0x2B, 0x00, 0x11,
1980 0x00, 0x1B, 0xFF, 0x02, 0x03, 0xFE, 0xF6, 0xC3, 0x43, 0x22, 0x16,
1981 0x07, 0xF6, 0xCA, 0x05, 0xA3, 0xFC, 0xC5, 0x01, 0x3F, 0xFF, 0x33,
1982 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x34, 0x00, 0x3C, 0xFF, 0xCF, 0x01,
1983 0x88, 0xFC, 0x09, 0x06, 0x71, 0xF5, 0x2B, 0x18, 0xB2, 0x42, 0x20,
1984 0xF6, 0x83, 0x03, 0xCF, 0xFE, 0x3C, 0x00, 0x15, 0x00, 0xE6, 0xFF,
1985 0x07, 0x00, 0x03, 0x00, 0xFB, 0xFF, 0xDF, 0xFF, 0xA9, 0x00, 0x10,
1986 0xFE, 0xB9, 0x04, 0x27, 0xF4, 0x5E, 0x3F, 0xC3, 0x1D, 0xFE, 0xF3,
1987 0x99, 0x06, 0x50, 0xFC, 0xE2, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE,
1988 0xFF, 0xFF, 0xFF, 0x2F, 0x00, 0x4D, 0xFF, 0xA0, 0x01, 0xFB, 0xFC,
1989 0x07, 0x05, 0xBF, 0xF7, 0xBB, 0x10, 0x2B, 0x46, 0xBB, 0xF9, 0x83,
1990 0x01, 0xFA, 0xFF, 0x95, 0xFF, 0x68, 0x00, 0xC7, 0xFF, 0x0E, 0x00,
1991 0x00, 0x00, 0x13, 0x00, 0x9F, 0xFF, 0x28, 0x01, 0x3A, 0xFD, 0x00,
1992 0x06, 0x5A, 0xF2, 0xDF, 0x39, 0x73, 0x25, 0x79, 0xF2, 0x12, 0x07,
1993 0x31, 0xFC, 0xE3, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x00,
1994 0x00, 0x27, 0x00, 0x66, 0xFF, 0x5E, 0x01, 0x90, 0xFD, 0xD2, 0x03,
1995 0x47, 0xFA, 0xC3, 0x09, 0x48, 0x48, 0x5A, 0xFE, 0x33, 0xFF, 0x45,
1996 0x01, 0xE2, 0xFE, 0xBE, 0x00, 0xA5, 0xFF, 0x16, 0x00, 0xFD, 0xFF,
1997 0x24, 0x00, 0x6D, 0xFF, 0x88, 0x01, 0xA2, 0xFC, 0xD0, 0x06, 0x8C,
1998 0xF1, 0x78, 0x33, 0xF2, 0x2C, 0x9E, 0xF1, 0x24, 0x07, 0x4E, 0xFC,
1999 0xC3, 0x01, 0x4E, 0xFF, 0x2F, 0x00, 0xFD, 0xFF, 0x1E, 0x00, 0x86,
2000 0xFF, 0x0E, 0x01, 0x3B, 0xFE, 0x82, 0x02, 0xE0, 0xFC, 0x73, 0x03,
2001 0xF6, 0x48, 0xE9, 0x03, 0xAD, 0xFC, 0x9C, 0x02, 0x2D, 0xFE, 0x14,
2002 0x01, 0x83, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x30, 0x00,
2003 0x4C, 0xFF, 0xC7, 0x01, 0x4A, 0xFC, 0x27, 0x07, 0xA8, 0xF1, 0x62,
2004 0x2C, 0xFD, 0x33, 0x93, 0xF1, 0xC4, 0x06, 0xAB, 0xFC, 0x82, 0x01,
2005 0x71, 0xFF, 0x23, 0x00, 0xFE, 0xFF, 0x15, 0x00, 0xA8, 0xFF, 0xB8,
2006 0x00, 0xF0, 0xFE, 0x2B, 0x01, 0x63, 0xFF, 0xF6, 0xFD, 0x2C, 0x48,
2007 0x47, 0x0A, 0x14, 0xFA, 0xEB, 0x03, 0x84, 0xFD, 0x63, 0x01, 0x64,
2008 0xFF, 0x27, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x3A, 0xFF,
2009 0xE4, 0x01, 0x32, 0xFC, 0x0C, 0x07, 0x91, 0xF2, 0xDD, 0x24, 0x54,
2010 0x3A, 0x74, 0xF2, 0xEB, 0x05, 0x49, 0xFD, 0x20, 0x01, 0xA3, 0xFF,
2011 0x11, 0x00, 0x00, 0x00, 0x0D, 0x00, 0xC9, 0xFF, 0x61, 0x00, 0xA2,
2012 0xFF, 0xE2, 0xFF, 0xAE, 0x01, 0x6B, 0xF9, 0xF2, 0x45, 0x4A, 0x11,
2013 0x8F, 0xF7, 0x1D, 0x05, 0xF1, 0xFC, 0xA4, 0x01, 0x4B, 0xFF, 0x2F,
2014 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE1, 0x01,
2015 0x55, 0xFC, 0x8C, 0x06, 0x22, 0xF4, 0x2C, 0x1D, 0xC0, 0x3F, 0x55,
2016 0xF4, 0x9B, 0x04, 0x23, 0xFE, 0x9F, 0x00, 0xE4, 0xFF, 0xF9, 0xFF,
2017 0x04, 0x00, 0x07, 0x00, 0xE9, 0xFF, 0x0F, 0x00, 0x48, 0x00, 0xB9,
2018 0xFE, 0xA6, 0x03, 0xE4, 0xF5, 0x60, 0x42, 0xC1, 0x18, 0x47, 0xF5,
2019 0x1A, 0x06, 0x81, 0xFC, 0xD2, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFE,
2020 0xFF, 0xFF, 0xFF, 0x33, 0x00, 0x40, 0xFF, 0xC1, 0x01, 0xAB, 0xFC,
2021 0xB7, 0x05, 0x34, 0xF6, 0x8E, 0x15, 0x0B, 0x44, 0x42, 0xF7, 0xDC,
2022 0x02, 0x32, 0xFF, 0x04, 0x00, 0x31, 0x00, 0xDC, 0xFF, 0x09, 0x00,
2023 0x02, 0x00, 0x04, 0x00, 0xC7, 0xFF, 0xD9, 0x00, 0xBF, 0xFD, 0x38,
2024 0x05, 0x69, 0xF3, 0x96, 0x3D, 0x6F, 0x20, 0x66, 0xF3, 0xCE, 0x06,
2025 0x3F, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF,
2026 0xFF, 0x2C, 0x00, 0x55, 0xFF, 0x8B, 0x01, 0x2B, 0xFD, 0xA1, 0x04,
2027 0x9B, 0xF8, 0x42, 0x0E, 0x0F, 0x47, 0x38, 0xFB, 0xBE, 0x00, 0x6A,
2028 0x00, 0x58, 0xFF, 0x85, 0x00, 0xBB, 0xFF, 0x10, 0x00, 0xFF, 0xFF,
2029 0x19, 0x00, 0x8C, 0xFF, 0x4D, 0x01, 0xFE, 0xFC, 0x56, 0x06, 0xF7,
2030 0xF1, 0xBF, 0x37, 0x15, 0x28, 0x18, 0xF2, 0x25, 0x07, 0x34, 0xFC,
2031 0xDC, 0x01, 0x3F, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x24,
2032 0x00, 0x71, 0xFF, 0x43, 0x01, 0xC9, 0xFD, 0x60, 0x03, 0x2E, 0xFB,
2033 0x7E, 0x07, 0xAF, 0x48, 0x2D, 0x00, 0x58, 0xFE, 0xBB, 0x01, 0xA3,
2034 0xFE, 0xDD, 0x00, 0x99, 0xFF, 0x19, 0x00, 0xFD, 0xFF, 0x29, 0x00,
2035 0x60, 0xFF, 0xA2, 0x01, 0x7C, 0xFC, 0xFB, 0x06, 0x7C, 0xF1, 0x15,
2036 0x31, 0x73, 0x2F, 0x81, 0xF1, 0x10, 0x07, 0x67, 0xFC, 0xB1, 0x01,
2037 0x58, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0x1B, 0x00, 0x91, 0xFF, 0xF1,
2038 0x00, 0x79, 0xFE, 0x0A, 0x02, 0xC3, 0xFD, 0x73, 0x01, 0xDB, 0x48,
2039 0x07, 0x06, 0xC7, 0xFB, 0x12, 0x03, 0xF1, 0xFD, 0x31, 0x01, 0x78,
2040 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x44, 0xFF,
2041 0xD5, 0x01, 0x3A, 0xFC, 0x2A, 0x07, 0xE3, 0xF1, 0xD1, 0x29, 0x46,
2042 0x36, 0xC5, 0xF1, 0x87, 0x06, 0xDA, 0xFC, 0x64, 0x01, 0x80, 0xFF,
2043 0x1E, 0x00, 0xFE, 0xFF, 0x12, 0x00, 0xB3, 0xFF, 0x99, 0x00, 0x2E,
2044 0xFF, 0xB6, 0x00, 0x36, 0x00, 0x47, 0xFC, 0x90, 0x47, 0xA4, 0x0C,
2045 0x31, 0xF9, 0x5A, 0x04, 0x4E, 0xFD, 0x7C, 0x01, 0x5B, 0xFF, 0x2A,
2046 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01,
2047 0x37, 0xFC, 0xEB, 0x06, 0x0B, 0xF3, 0x35, 0x22, 0x52, 0x3C, 0xFD,
2048 0xF2, 0x84, 0x05, 0x8D, 0xFD, 0xF6, 0x00, 0xB8, 0xFF, 0x09, 0x00,
2049 0x01, 0x00, 0x0B, 0x00, 0xD5, 0xFF, 0x44, 0x00, 0xDD, 0xFF, 0x77,
2050 0xFF, 0x67, 0x02, 0x14, 0xF8, 0xDC, 0x44, 0xD5, 0x13, 0xBC, 0xF6,
2051 0x7C, 0x05, 0xC5, 0xFC, 0xB7, 0x01, 0x44, 0xFF, 0x31, 0x00, 0xFF,
2052 0xFF, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD9, 0x01, 0x6D, 0xFC,
2053 0x4B, 0x06, 0xCD, 0xF4, 0x83, 0x1A, 0x5F, 0x41, 0x3A, 0xF5, 0x0C,
2054 0x04, 0x7B, 0xFE, 0x6C, 0x00, 0xFE, 0xFF, 0xEF, 0xFF, 0x05, 0x00,
2055 0x05, 0x00, 0xF3, 0xFF, 0xF5, 0xFF, 0x7D, 0x00, 0x5D, 0xFE, 0x3E,
2056 0x04, 0xEA, 0xF4, 0xD9, 0x40, 0x66, 0x1B, 0x93, 0xF4, 0x62, 0x06,
2057 0x64, 0xFC, 0xDC, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF,
2058 0xFF, 0x31, 0x00, 0x46, 0xFF, 0xB1, 0x01, 0xD3, 0xFC, 0x5D, 0x05,
2059 0x01, 0xF7, 0xFB, 0x12, 0x3F, 0x45, 0x83, 0xF8, 0x2A, 0x02, 0x9A,
2060 0xFF, 0xCA, 0xFF, 0x4E, 0x00, 0xD1, 0xFF, 0x0C, 0x00, 0x00, 0x00,
2061 0x0C, 0x00, 0xB1, 0xFF, 0x04, 0x01, 0x76, 0xFD, 0xA8, 0x05, 0xCC,
2062 0xF2, 0xAB, 0x3B, 0x18, 0x23, 0xE0, 0xF2, 0xF7, 0x06, 0x35, 0xFC,
2063 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x29,
2064 0x00, 0x5E, 0xFF, 0x74, 0x01, 0x5F, 0xFD, 0x35, 0x04, 0x7C, 0xF9,
2065 0xD8, 0x0B, 0xC9, 0x47, 0xD4, 0xFC, 0xF0, 0xFF, 0xDD, 0x00, 0x19,
2066 0xFF, 0xA4, 0x00, 0xAF, 0xFF, 0x13, 0x00, 0xFE, 0xFF, 0x20, 0x00,
2067 0x7B, 0xFF, 0x6E, 0x01, 0xCA, 0xFC, 0x9D, 0x06, 0xB1, 0xF1, 0x86,
2068 0x35, 0xAE, 0x2A, 0xCD, 0xF1, 0x2B, 0x07, 0x3F, 0xFC, 0xD1, 0x01,
2069 0x46, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x21, 0x00, 0x7C,
2070 0xFF, 0x27, 0x01, 0x05, 0xFE, 0xEB, 0x02, 0x14, 0xFC, 0x50, 0x05,
2071 0xEA, 0x48, 0x1B, 0x02, 0x78, 0xFD, 0x32, 0x02, 0x64, 0xFE, 0xFA,
2072 0x00, 0x8D, 0xFF, 0x1C, 0x00, 0xFD, 0xFF, 0x2D, 0x00, 0x54, 0xFF,
2073 0xB7, 0x01, 0x5E, 0xFC, 0x19, 0x07, 0x88, 0xF1, 0x9F, 0x2E, 0xE3,
2074 0x31, 0x7E, 0xF1, 0xEE, 0x06, 0x88, 0xFC, 0x9A, 0x01, 0x64, 0xFF,
2075 0x28, 0x00, 0xFD, 0xFF, 0x18, 0x00, 0x9D, 0xFF, 0xD3, 0x00, 0xB8,
2076 0xFE, 0x93, 0x01, 0xA1, 0xFE, 0x8E, 0xFF, 0x92, 0x48, 0x3D, 0x08,
2077 0xE1, 0xFA, 0x86, 0x03, 0xB6, 0xFD, 0x4C, 0x01, 0x6D, 0xFF, 0x25,
2078 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x3E, 0xFF, 0xDF, 0x01,
2079 0x33, 0xFC, 0x20, 0x07, 0x35, 0xF2, 0x36, 0x27, 0x78, 0x38, 0x14,
2080 0xF2, 0x3B, 0x06, 0x11, 0xFD, 0x41, 0x01, 0x92, 0xFF, 0x17, 0x00,
2081 0xFF, 0xFF, 0x10, 0x00, 0xBF, 0xFF, 0x7B, 0x00, 0x6C, 0xFF, 0x44,
2082 0x00, 0x01, 0x01, 0xB6, 0xFA, 0xC8, 0x46, 0x13, 0x0F, 0x51, 0xF8,
2083 0xC4, 0x04, 0x1B, 0xFD, 0x92, 0x01, 0x52, 0xFF, 0x2D, 0x00, 0xFF,
2084 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE5, 0x01, 0x44, 0xFC,
2085 0xBD, 0x06, 0x97, 0xF3, 0x8A, 0x1F, 0x31, 0x3E, 0xA5, 0xF3, 0x0F,
2086 0x05, 0xDA, 0xFD, 0xC9, 0x00, 0xCF, 0xFF, 0x01, 0x00, 0x02, 0x00,
2087 0x09, 0x00, 0xDF, 0xFF, 0x28, 0x00, 0x17, 0x00, 0x10, 0xFF, 0x15,
2088 0x03, 0xDD, 0xF6, 0x9E, 0x43, 0x6C, 0x16, 0xF1, 0xF5, 0xD3, 0x05,
2089 0x9F, 0xFC, 0xC6, 0x01, 0x3F, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0xFE,
2090 0xFF, 0x34, 0x00, 0x3C, 0xFF, 0xCE, 0x01, 0x8C, 0xFC, 0x00, 0x06,
2091 0x86, 0xF5, 0xE0, 0x17, 0xDB, 0x42, 0x3F, 0xF6, 0x71, 0x03, 0xD9,
2092 0xFE, 0x36, 0x00, 0x18, 0x00, 0xE5, 0xFF, 0x07, 0x00, 0x03, 0x00,
2093 0xFC, 0xFF, 0xDC, 0xFF, 0xAF, 0x00, 0x07, 0xFE, 0xC8, 0x04, 0x10,
2094 0xF4, 0x2D, 0x3F, 0x0F, 0x1E, 0xED, 0xF3, 0xA0, 0x06, 0x4E, 0xFC,
2095 0xE3, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x2E,
2096 0x00, 0x4E, 0xFF, 0x9E, 0x01, 0x00, 0xFD, 0xFC, 0x04, 0xD7, 0xF7,
2097 0x75, 0x10, 0x48, 0x46, 0xE4, 0xF9, 0x6E, 0x01, 0x06, 0x00, 0x8E,
2098 0xFF, 0x6B, 0x00, 0xC6, 0xFF, 0x0E, 0x00, 0xFF, 0xFF, 0x13, 0x00,
2099 0x9D, 0xFF, 0x2D, 0x01, 0x33, 0xFD, 0x0B, 0x06, 0x4D, 0xF2, 0xA5,
2100 0x39, 0xBF, 0x25, 0x6D, 0xF2, 0x15, 0x07, 0x31, 0xFC, 0xE2, 0x01,
2101 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x26, 0x00, 0x68,
2102 0xFF, 0x5B, 0x01, 0x96, 0xFD, 0xC6, 0x03, 0x61, 0xFA, 0x81, 0x09,
2103 0x57, 0x48, 0x8D, 0xFE, 0x1B, 0xFF, 0x52, 0x01, 0xDB, 0xFE, 0xC2,
2104 0x00, 0xA4, 0xFF, 0x16, 0x00, 0xFD, 0xFF, 0x25, 0x00, 0x6C, 0xFF,
2105 0x8B, 0x01, 0x9D, 0xFC, 0xD5, 0x06, 0x89, 0xF1, 0x35, 0x33, 0x3A,
2106 0x2D, 0x9A, 0xF1, 0x23, 0x07, 0x51, 0xFC, 0xC2, 0x01, 0x4F, 0xFF,
2107 0x2F, 0x00, 0xFD, 0xFF, 0x1E, 0x00, 0x87, 0xFF, 0x0B, 0x01, 0x42,
2108 0xFE, 0x74, 0x02, 0xF9, 0xFC, 0x39, 0x03, 0xF5, 0x48, 0x24, 0x04,
2109 0x94, 0xFC, 0xA9, 0x02, 0x27, 0xFE, 0x18, 0x01, 0x82, 0xFF, 0x1F,
2110 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x30, 0x00, 0x4B, 0xFF, 0xC9, 0x01,
2111 0x48, 0xFC, 0x28, 0x07, 0xAD, 0xF1, 0x19, 0x2C, 0x3F, 0x34, 0x97,
2112 0xF1, 0xBE, 0x06, 0xB0, 0xFC, 0x7F, 0x01, 0x72, 0xFF, 0x23, 0x00,
2113 0xFE, 0xFF, 0x15, 0x00, 0xA9, 0xFF, 0xB4, 0x00, 0xF7, 0xFE, 0x1D,
2114 0x01, 0x7A, 0xFF, 0xC5, 0xFD, 0x1D, 0x48, 0x89, 0x0A, 0xFB, 0xF9,
2115 0xF8, 0x03, 0x7D, 0xFD, 0x66, 0x01, 0x63, 0xFF, 0x28, 0x00, 0x00,
2116 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE4, 0x01, 0x32, 0xFC,
2117 0x09, 0x07, 0x9D, 0xF2, 0x92, 0x24, 0x8F, 0x3A, 0x82, 0xF2, 0xE1,
2118 0x05, 0x50, 0xFD, 0x1B, 0x01, 0xA6, 0xFF, 0x10, 0x00, 0x00, 0x00,
2119 0x0D, 0x00, 0xCB, 0xFF, 0x5E, 0x00, 0xA9, 0xFF, 0xD6, 0xFF, 0xC3,
2120 0x01, 0x43, 0xF9, 0xD7, 0x45, 0x92, 0x11, 0x77, 0xF7, 0x28, 0x05,
2121 0xEC, 0xFC, 0xA7, 0x01, 0x4A, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0xFE,
2122 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE0, 0x01, 0x57, 0xFC, 0x85, 0x06,
2123 0x34, 0xF4, 0xE0, 0x1C, 0xF0, 0x3F, 0x6D, 0xF4, 0x8C, 0x04, 0x2C,
2124 0xFE, 0x99, 0x00, 0xE7, 0xFF, 0xF8, 0xFF, 0x04, 0x00, 0x06, 0x00,
2125 0xEA, 0xFF, 0x0C, 0x00, 0x4E, 0x00, 0xAF, 0xFE, 0xB8, 0x03, 0xC7,
2126 0xF5, 0x38, 0x42, 0x0C, 0x19, 0x32, 0xF5, 0x23, 0x06, 0x7D, 0xFC,
2127 0xD3, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x32,
2128 0x00, 0x41, 0xFF, 0xC0, 0x01, 0xAF, 0xFC, 0xAD, 0x05, 0x4A, 0xF6,
2129 0x44, 0x15, 0x2F, 0x44, 0x64, 0xF7, 0xC9, 0x02, 0x3D, 0xFF, 0xFE,
2130 0xFF, 0x34, 0x00, 0xDB, 0xFF, 0x09, 0x00, 0x02, 0x00, 0x05, 0x00,
2131 0xC5, 0xFF, 0xDE, 0x00, 0xB7, 0xFD, 0x45, 0x05, 0x56, 0xF3, 0x61,
2132 0x3D, 0xBA, 0x20, 0x56, 0xF3, 0xD3, 0x06, 0x3E, 0xFC, 0xE6, 0x01,
2133 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x2C, 0x00, 0x56,
2134 0xFF, 0x88, 0x01, 0x31, 0xFD, 0x95, 0x04, 0xB4, 0xF8, 0xFC, 0x0D,
2135 0x26, 0x47, 0x64, 0xFB, 0xA7, 0x00, 0x77, 0x00, 0x51, 0xFF, 0x89,
2136 0x00, 0xBA, 0xFF, 0x11, 0x00, 0xFF, 0xFF, 0x1A, 0x00, 0x8A, 0xFF,
2137 0x51, 0x01, 0xF8, 0xFC, 0x5E, 0x06, 0xED, 0xF1, 0x82, 0x37, 0x60,
2138 0x28, 0x0E, 0xF2, 0x26, 0x07, 0x35, 0xFC, 0xDB, 0x01, 0x40, 0xFF,
2139 0x34, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x23, 0x00, 0x72, 0xFF, 0x40,
2140 0x01, 0xD0, 0xFD, 0x53, 0x03, 0x47, 0xFB, 0x3F, 0x07, 0xB8, 0x48,
2141 0x62, 0x00, 0x3F, 0xFE, 0xC8, 0x01, 0x9C, 0xFE, 0xE0, 0x00, 0x98,
2142 0xFF, 0x19, 0x00, 0xFD, 0xFF, 0x29, 0x00, 0x5F, 0xFF, 0xA5, 0x01,
2143 0x78, 0xFC, 0xFF, 0x06, 0x7D, 0xF1, 0xCF, 0x30, 0xB8, 0x2F, 0x80,
2144 0xF1, 0x0D, 0x07, 0x6A, 0xFC, 0xAE, 0x01, 0x59, 0xFF, 0x2B, 0x00,
2145 0xFD, 0xFF, 0x1B, 0x00, 0x93, 0xFF, 0xED, 0x00, 0x80, 0xFE, 0xFD,
2146 0x01, 0xDC, 0xFD, 0x3C, 0x01, 0xD5, 0x48, 0x45, 0x06, 0xAE, 0xFB,
2147 0x1F, 0x03, 0xEA, 0xFD, 0x34, 0x01, 0x77, 0xFF, 0x22, 0x00, 0x00,
2148 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x43, 0xFF, 0xD6, 0x01, 0x39, 0xFC,
2149 0x2A, 0x07, 0xEB, 0xF1, 0x87, 0x29, 0x85, 0x36, 0xCC, 0xF1, 0x7F,
2150 0x06, 0xE0, 0xFC, 0x60, 0x01, 0x82, 0xFF, 0x1D, 0x00, 0xFE, 0xFF,
2151 0x12, 0x00, 0xB5, 0xFF, 0x96, 0x00, 0x35, 0xFF, 0xA9, 0x00, 0x4D,
2152 0x00, 0x19, 0xFC, 0x7C, 0x47, 0xE8, 0x0C, 0x18, 0xF9, 0x66, 0x04,
2153 0x48, 0xFD, 0x7E, 0x01, 0x5A, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0xFD,
2154 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x38, 0xFC, 0xE6, 0x06,
2155 0x19, 0xF3, 0xEA, 0x21, 0x8A, 0x3C, 0x0E, 0xF3, 0x78, 0x05, 0x96,
2156 0xFD, 0xF1, 0x00, 0xBB, 0xFF, 0x08, 0x00, 0x01, 0x00, 0x0B, 0x00,
2157 0xD6, 0xFF, 0x41, 0x00, 0xE4, 0xFF, 0x6B, 0xFF, 0x7B, 0x02, 0xF0,
2158 0xF7, 0xBA, 0x44, 0x1E, 0x14, 0xA5, 0xF6, 0x86, 0x05, 0xC1, 0xFC,
2159 0xB9, 0x01, 0x44, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x35,
2160 0x00, 0x39, 0xFF, 0xD8, 0x01, 0x70, 0xFC, 0x43, 0x06, 0xE1, 0xF4,
2161 0x38, 0x1A, 0x8C, 0x41, 0x55, 0xF5, 0xFC, 0x03, 0x85, 0xFE, 0x66,
2162 0x00, 0x01, 0x00, 0xEE, 0xFF, 0x06, 0x00, 0x05, 0x00, 0xF4, 0xFF,
2163 0xF2, 0xFF, 0x83, 0x00, 0x53, 0xFE, 0x4E, 0x04, 0xD0, 0xF4, 0xAB,
2164 0x40, 0xB2, 0x1B, 0x7F, 0xF4, 0x69, 0x06, 0x62, 0xFC, 0xDD, 0x01,
2165 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x47,
2166 0xFF, 0xAF, 0x01, 0xD8, 0xFC, 0x52, 0x05, 0x19, 0xF7, 0xB2, 0x12,
2167 0x5C, 0x45, 0xA9, 0xF8, 0x16, 0x02, 0xA6, 0xFF, 0xC3, 0xFF, 0x51,
2168 0x00, 0xD0, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0xAF, 0xFF,
2169 0x09, 0x01, 0x6E, 0xFD, 0xB4, 0x05, 0xBC, 0xF2, 0x73, 0x3B, 0x64,
2170 0x23, 0xD2, 0xF2, 0xFB, 0x06, 0x34, 0xFC, 0xE6, 0x01, 0x38, 0xFF,
2171 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x29, 0x00, 0x5F, 0xFF, 0x71,
2172 0x01, 0x65, 0xFD, 0x29, 0x04, 0x96, 0xF9, 0x95, 0x0B, 0xDC, 0x47,
2173 0x03, 0xFD, 0xD9, 0xFF, 0xEA, 0x00, 0x12, 0xFF, 0xA7, 0x00, 0xAE,
2174 0xFF, 0x14, 0x00, 0xFE, 0xFF, 0x20, 0x00, 0x79, 0xFF, 0x72, 0x01,
2175 0xC4, 0xFC, 0xA4, 0x06, 0xAB, 0xF1, 0x46, 0x35, 0xF7, 0x2A, 0xC6,
2176 0xF1, 0x2A, 0x07, 0x40, 0xFC, 0xCF, 0x01, 0x47, 0xFF, 0x31, 0x00,
2177 0xFD, 0xFF, 0x00, 0x00, 0x20, 0x00, 0x7D, 0xFF, 0x24, 0x01, 0x0C,
2178 0xFE, 0xDE, 0x02, 0x2E, 0xFC, 0x13, 0x05, 0xEC, 0x48, 0x54, 0x02,
2179 0x5E, 0xFD, 0x3F, 0x02, 0x5D, 0xFE, 0xFE, 0x00, 0x8C, 0xFF, 0x1C,
2180 0x00, 0xFD, 0xFF, 0x2D, 0x00, 0x53, 0xFF, 0xBA, 0x01, 0x5B, 0xFC,
2181 0x1B, 0x07, 0x8B, 0xF1, 0x58, 0x2E, 0x26, 0x32, 0x80, 0xF1, 0xEA,
2182 0x06, 0x8C, 0xFC, 0x97, 0x01, 0x66, 0xFF, 0x27, 0x00, 0xFD, 0xFF,
2183 0x17, 0x00, 0x9E, 0xFF, 0xCF, 0x00, 0xBF, 0xFE, 0x86, 0x01, 0xBA,
2184 0xFE, 0x5A, 0xFF, 0x86, 0x48, 0x7D, 0x08, 0xC7, 0xFA, 0x93, 0x03,
2185 0xB0, 0xFD, 0x4F, 0x01, 0x6C, 0xFF, 0x25, 0x00, 0x00, 0x00, 0xFD,
2186 0xFF, 0x35, 0x00, 0x3D, 0xFF, 0xDF, 0x01, 0x32, 0xFC, 0x1E, 0x07,
2187 0x40, 0xF2, 0xEB, 0x26, 0xB5, 0x38, 0x1F, 0xF2, 0x32, 0x06, 0x18,
2188 0xFD, 0x3D, 0x01, 0x94, 0xFF, 0x16, 0x00, 0xFF, 0xFF, 0x0F, 0x00,
2189 0xC0, 0xFF, 0x78, 0x00, 0x73, 0xFF, 0x38, 0x00, 0x17, 0x01, 0x8B,
2190 0xFA, 0xAF, 0x46, 0x59, 0x0F, 0x39, 0xF8, 0xCF, 0x04, 0x15, 0xFD,
2191 0x95, 0x01, 0x51, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36,
2192 0x00, 0x36, 0xFF, 0xE5, 0x01, 0x46, 0xFC, 0xB8, 0x06, 0xA8, 0xF3,
2193 0x3F, 0x1F, 0x64, 0x3E, 0xBA, 0xF3, 0x01, 0x05, 0xE2, 0xFD, 0xC4,
2194 0x00, 0xD2, 0xFF, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0xE1, 0xFF,
2195 0x25, 0x00, 0x1D, 0x00, 0x05, 0xFF, 0x28, 0x03, 0xBD, 0xF6, 0x77,
2196 0x43, 0xB6, 0x16, 0xDC, 0xF5, 0xDD, 0x05, 0x9B, 0xFC, 0xC8, 0x01,
2197 0x3E, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x34, 0x00, 0x3D,
2198 0xFF, 0xCC, 0x01, 0x8F, 0xFC, 0xF8, 0x05, 0x9B, 0xF5, 0x96, 0x17,
2199 0x02, 0x43, 0x5E, 0xF6, 0x5F, 0x03, 0xE4, 0xFE, 0x30, 0x00, 0x1B,
2200 0x00, 0xE4, 0xFF, 0x08, 0x00, 0x03, 0x00, 0xFD, 0xFF, 0xD9, 0xFF,
2201 0xB4, 0x00, 0xFD, 0xFD, 0xD7, 0x04, 0xFA, 0xF3, 0xFC, 0x3E, 0x5B,
2202 0x1E, 0xDB, 0xF3, 0xA6, 0x06, 0x4C, 0xFC, 0xE3, 0x01, 0x36, 0xFF,
2203 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x2E, 0x00, 0x4E, 0xFF, 0x9C,
2204 0x01, 0x05, 0xFD, 0xF1, 0x04, 0xF0, 0xF7, 0x2D, 0x10, 0x61, 0x46,
2205 0x0D, 0xFA, 0x58, 0x01, 0x13, 0x00, 0x87, 0xFF, 0x6E, 0x00, 0xC4,
2206 0xFF, 0x0E, 0x00, 0xFF, 0xFF, 0x14, 0x00, 0x9B, 0xFF, 0x31, 0x01,
2207 0x2C, 0xFD, 0x15, 0x06, 0x41, 0xF2, 0x6A, 0x39, 0x0A, 0x26, 0x61,
2208 0xF2, 0x17, 0x07, 0x31, 0xFC, 0xE2, 0x01, 0x3B, 0xFF, 0x35, 0x00,
2209 0xFD, 0xFF, 0x00, 0x00, 0x26, 0x00, 0x69, 0xFF, 0x58, 0x01, 0x9D,
2210 0xFD, 0xB9, 0x03, 0x7B, 0xFA, 0x40, 0x09, 0x63, 0x48, 0xBF, 0xFE,
2211 0x03, 0xFF, 0x5F, 0x01, 0xD4, 0xFE, 0xC5, 0x00, 0xA2, 0xFF, 0x16,
2212 0x00, 0xFD, 0xFF, 0x25, 0x00, 0x6A, 0xFF, 0x8E, 0x01, 0x99, 0xFC,
2213 0xDB, 0x06, 0x86, 0xF1, 0xF2, 0x32, 0x82, 0x2D, 0x96, 0xF1, 0x21,
2214 0x07, 0x53, 0xFC, 0xC0, 0x01, 0x50, 0xFF, 0x2E, 0x00, 0xFD, 0xFF,
2215 0x1D, 0x00, 0x88, 0xFF, 0x07, 0x01, 0x49, 0xFE, 0x67, 0x02, 0x13,
2216 0xFD, 0xFF, 0x02, 0xF4, 0x48, 0x5F, 0x04, 0x7A, 0xFC, 0xB6, 0x02,
2217 0x20, 0xFE, 0x1B, 0x01, 0x81, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0xFD,
2218 0xFF, 0x30, 0x00, 0x4A, 0xFF, 0xCA, 0x01, 0x46, 0xFC, 0x29, 0x07,
2219 0xB3, 0xF1, 0xD1, 0x2B, 0x81, 0x34, 0x9C, 0xF1, 0xB8, 0x06, 0xB5,
2220 0xFC, 0x7C, 0x01, 0x74, 0xFF, 0x22, 0x00, 0xFE, 0xFF, 0x15, 0x00,
2221 0xAA, 0xFF, 0xB1, 0x00, 0xFE, 0xFE, 0x10, 0x01, 0x92, 0xFF, 0x94,
2222 0xFD, 0x0D, 0x48, 0xCB, 0x0A, 0xE2, 0xF9, 0x04, 0x04, 0x77, 0xFD,
2223 0x69, 0x01, 0x62, 0xFF, 0x28, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36,
2224 0x00, 0x39, 0xFF, 0xE5, 0x01, 0x32, 0xFC, 0x06, 0x07, 0xAA, 0xF2,
2225 0x46, 0x24, 0xC8, 0x3A, 0x90, 0xF2, 0xD6, 0x05, 0x57, 0xFD, 0x17,
2226 0x01, 0xA8, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x0D, 0x00, 0xCC, 0xFF,
2227 0x5A, 0x00, 0xAF, 0xFF, 0xCA, 0xFF, 0xD8, 0x01, 0x1C, 0xF9, 0xB8,
2228 0x45, 0xDA, 0x11, 0x60, 0xF7, 0x33, 0x05, 0xE7, 0xFC, 0xA9, 0x01,
2229 0x4A, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x37,
2230 0xFF, 0xDF, 0x01, 0x5A, 0xFC, 0x7E, 0x06, 0x47, 0xF4, 0x94, 0x1C,
2231 0x1F, 0x40, 0x85, 0xF4, 0x7D, 0x04, 0x36, 0xFE, 0x93, 0x00, 0xEA,
2232 0xFF, 0xF7, 0xFF, 0x04, 0x00, 0x06, 0x00, 0xEB, 0xFF, 0x09, 0x00,
2233 0x54, 0x00, 0xA4, 0xFE, 0xC9, 0x03, 0xAA, 0xF5, 0x0C, 0x42, 0x56,
2234 0x19, 0x1E, 0xF5, 0x2B, 0x06, 0x7A, 0xFC, 0xD4, 0x01, 0x3A, 0xFF,
2235 0x35, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x32, 0x00, 0x42, 0xFF, 0xBE,
2236 0x01, 0xB4, 0xFC, 0xA4, 0x05, 0x61, 0xF6, 0xFB, 0x14, 0x53, 0x44,
2237 0x86, 0xF7, 0xB6, 0x02, 0x49, 0xFF, 0xF7, 0xFF, 0x37, 0x00, 0xD9,
2238 0xFF, 0x0A, 0x00, 0x01, 0x00, 0x06, 0x00, 0xC2, 0xFF, 0xE3, 0x00,
2239 0xAE, 0xFD, 0x52, 0x05, 0x44, 0xF3, 0x2A, 0x3D, 0x06, 0x21, 0x47,
2240 0xF3, 0xD8, 0x06, 0x3C, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00,
2241 0xFD, 0xFF, 0x00, 0x00, 0x2B, 0x00, 0x57, 0xFF, 0x86, 0x01, 0x36,
2242 0xFD, 0x89, 0x04, 0xCD, 0xF8, 0xB7, 0x0D, 0x3D, 0x47, 0x91, 0xFB,
2243 0x91, 0x00, 0x83, 0x00, 0x4A, 0xFF, 0x8C, 0x00, 0xB9, 0xFF, 0x11,
2244 0x00, 0xFE, 0xFF, 0x1B, 0x00, 0x88, 0xFF, 0x55, 0x01, 0xF2, 0xFC,
2245 0x67, 0x06, 0xE4, 0xF1, 0x44, 0x37, 0xAA, 0x28, 0x05, 0xF2, 0x27,
2246 0x07, 0x36, 0xFC, 0xDA, 0x01, 0x41, 0xFF, 0x33, 0x00, 0xFD, 0xFF,
2247 0x00, 0x00, 0x23, 0x00, 0x73, 0xFF, 0x3D, 0x01, 0xD6, 0xFD, 0x46,
2248 0x03, 0x61, 0xFB, 0x00, 0x07, 0xBF, 0x48, 0x98, 0x00, 0x26, 0xFE,
2249 0xD5, 0x01, 0x95, 0xFE, 0xE3, 0x00, 0x96, 0xFF, 0x1A, 0x00, 0xFD,
2250 0xFF, 0x2A, 0x00, 0x5D, 0xFF, 0xA7, 0x01, 0x75, 0xFC, 0x03, 0x07,
2251 0x7D, 0xF1, 0x8A, 0x30, 0xFF, 0x2F, 0x7E, 0xF1, 0x0A, 0x07, 0x6E,
2252 0xFC, 0xAC, 0x01, 0x5A, 0xFF, 0x2B, 0x00, 0xFD, 0xFF, 0x1A, 0x00,
2253 0x94, 0xFF, 0xEA, 0x00, 0x87, 0xFE, 0xF0, 0x01, 0xF5, 0xFD, 0x05,
2254 0x01, 0xCE, 0x48, 0x83, 0x06, 0x94, 0xFB, 0x2C, 0x03, 0xE4, 0xFD,
2255 0x37, 0x01, 0x76, 0xFF, 0x22, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x33,
2256 0x00, 0x42, 0xFF, 0xD7, 0x01, 0x38, 0xFC, 0x29, 0x07, 0xF3, 0xF1,
2257 0x3E, 0x29, 0xC6, 0x36, 0xD4, 0xF1, 0x77, 0x06, 0xE6, 0xFC, 0x5C,
2258 0x01, 0x84, 0xFF, 0x1C, 0x00, 0xFE, 0xFF, 0x12, 0x00, 0xB6, 0xFF,
2259 0x93, 0x00, 0x3C, 0xFF, 0x9D, 0x00, 0x63, 0x00, 0xEB, 0xFB, 0x69,
2260 0x47, 0x2D, 0x0D, 0xFF, 0xF8, 0x72, 0x04, 0x42, 0xFD, 0x81, 0x01,
2261 0x59, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x37,
2262 0xFF, 0xE6, 0x01, 0x3A, 0xFC, 0xE2, 0x06, 0x28, 0xF3, 0x9E, 0x21,
2263 0xC0, 0x3C, 0x1F, 0xF3, 0x6C, 0x05, 0x9E, 0xFD, 0xED, 0x00, 0xBD,
2264 0xFF, 0x07, 0x00, 0x01, 0x00, 0x0A, 0x00, 0xD7, 0xFF, 0x3E, 0x00,
2265 0xEA, 0xFF, 0x60, 0xFF, 0x8F, 0x02, 0xCD, 0xF7, 0x99, 0x44, 0x68,
2266 0x14, 0x8E, 0xF6, 0x90, 0x05, 0xBC, 0xFC, 0xBA, 0x01, 0x43, 0xFF,
2267 0x32, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD7,
2268 0x01, 0x73, 0xFC, 0x3B, 0x06, 0xF5, 0xF4, 0xED, 0x19, 0xB7, 0x41,
2269 0x71, 0xF5, 0xEB, 0x03, 0x90, 0xFE, 0x60, 0x00, 0x04, 0x00, 0xED,
2270 0xFF, 0x06, 0x00, 0x04, 0x00, 0xF5, 0xFF, 0xEF, 0xFF, 0x88, 0x00,
2271 0x49, 0xFE, 0x5D, 0x04, 0xB7, 0xF4, 0x7D, 0x40, 0xFD, 0x1B, 0x6C,
2272 0xF4, 0x70, 0x06, 0x5F, 0xFC, 0xDE, 0x01, 0x37, 0xFF, 0x36, 0x00,
2273 0xFE, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x48, 0xFF, 0xAD, 0x01, 0xDD,
2274 0xFC, 0x48, 0x05, 0x30, 0xF7, 0x6B, 0x12, 0x7D, 0x45, 0xCF, 0xF8,
2275 0x01, 0x02, 0xB2, 0xFF, 0xBD, 0xFF, 0x54, 0x00, 0xCE, 0xFF, 0x0C,
2276 0x00, 0x00, 0x00, 0x0E, 0x00, 0xAC, 0xFF, 0x0E, 0x01, 0x66, 0xFD,
2277 0xBF, 0x05, 0xAD, 0xF2, 0x3B, 0x3B, 0xB0, 0x23, 0xC4, 0xF2, 0xFF,
2278 0x06, 0x33, 0xFC, 0xE5, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
2279 0x00, 0x00, 0x29, 0x00, 0x60, 0xFF, 0x6E, 0x01, 0x6B, 0xFD, 0x1D,
2280 0x04, 0xAF, 0xF9, 0x51, 0x0B, 0xEC, 0x47, 0x33, 0xFD, 0xC1, 0xFF,
2281 0xF7, 0x00, 0x0C, 0xFF, 0xAA, 0x00, 0xAD, 0xFF, 0x14, 0x00, 0xFE,
2282 0xFF, 0x21, 0x00, 0x77, 0xFF, 0x75, 0x01, 0xBF, 0xFC, 0xAB, 0x06,
2283 0xA6, 0xF1, 0x05, 0x35, 0x40, 0x2B, 0xBF, 0xF1, 0x2A, 0x07, 0x42,
2284 0xFC, 0xCE, 0x01, 0x48, 0xFF, 0x31, 0x00, 0xFD, 0xFF, 0x00, 0x00,
2285 0x20, 0x00, 0x7E, 0xFF, 0x21, 0x01, 0x12, 0xFE, 0xD1, 0x02, 0x47,
2286 0xFC, 0xD7, 0x04, 0xF0, 0x48, 0x8D, 0x02, 0x45, 0xFD, 0x4D, 0x02,
2287 0x56, 0xFE, 0x01, 0x01, 0x8B, 0xFF, 0x1D, 0x00, 0xFD, 0xFF, 0x2E,
2288 0x00, 0x52, 0xFF, 0xBC, 0x01, 0x58, 0xFC, 0x1D, 0x07, 0x8E, 0xF1,
2289 0x11, 0x2E, 0x6B, 0x32, 0x81, 0xF1, 0xE5, 0x06, 0x90, 0xFC, 0x94,
2290 0x01, 0x67, 0xFF, 0x26, 0x00, 0xFD, 0xFF, 0x17, 0x00, 0xA0, 0xFF,
2291 0xCC, 0x00, 0xC6, 0xFE, 0x79, 0x01, 0xD2, 0xFE, 0x26, 0xFF, 0x7C,
2292 0x48, 0xBE, 0x08, 0xAE, 0xFA, 0xA0, 0x03, 0xA9, 0xFD, 0x52, 0x01,
2293 0x6B, 0xFF, 0x25, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3C,
2294 0xFF, 0xE0, 0x01, 0x32, 0xFC, 0x1C, 0x07, 0x4B, 0xF2, 0xA0, 0x26,
2295 0xF2, 0x38, 0x2A, 0xF2, 0x28, 0x06, 0x1F, 0xFD, 0x39, 0x01, 0x96,
2296 0xFF, 0x16, 0x00, 0xFF, 0xFF, 0x0F, 0x00, 0xC2, 0xFF, 0x75, 0x00,
2297 0x7A, 0xFF, 0x2B, 0x00, 0x2D, 0x01, 0x61, 0xFA, 0x97, 0x46, 0xA0,
2298 0x0F, 0x20, 0xF8, 0xDA, 0x04, 0x10, 0xFD, 0x97, 0x01, 0x50, 0xFF,
2299 0x2E, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4,
2300 0x01, 0x48, 0xFC, 0xB2, 0x06, 0xB9, 0xF3, 0xF3, 0x1E, 0x98, 0x3E,
2301 0xCF, 0xF3, 0xF3, 0x04, 0xEB, 0xFD, 0xBF, 0x00, 0xD4, 0xFF, 0xFF,
2302 0xFF, 0x03, 0x00, 0x08, 0x00, 0xE2, 0xFF, 0x21, 0x00, 0x23, 0x00,
2303 0xFA, 0xFE, 0x3A, 0x03, 0x9D, 0xF6, 0x50, 0x43, 0x00, 0x17, 0xC6,
2304 0xF5, 0xE6, 0x05, 0x97, 0xFC, 0xC9, 0x01, 0x3E, 0xFF, 0x34, 0x00,
2305 0xFE, 0xFF, 0xFE, 0xFF, 0x34, 0x00, 0x3D, 0xFF, 0xCB, 0x01, 0x93,
2306 0xFC, 0xEF, 0x05, 0xB0, 0xF5, 0x4B, 0x17, 0x2A, 0x43, 0x7D, 0xF6,
2307 0x4D, 0x03, 0xEF, 0xFE, 0x2A, 0x00, 0x1E, 0x00, 0xE3, 0xFF, 0x08,
2308 0x00, 0x03, 0x00, 0xFE, 0xFF, 0xD7, 0xFF, 0xBA, 0x00, 0xF4, 0xFD,
2309 0xE5, 0x04, 0xE4, 0xF3, 0xCA, 0x3E, 0xA7, 0x1E, 0xCA, 0xF3, 0xAC,
2310 0x06, 0x4A, 0xFC, 0xE4, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF,
2311 0xFF, 0xFF, 0x2E, 0x00, 0x4F, 0xFF, 0x99, 0x01, 0x0B, 0xFD, 0xE6,
2312 0x04, 0x08, 0xF8, 0xE7, 0x0F, 0x7C, 0x46, 0x37, 0xFA, 0x42, 0x01,
2313 0x1F, 0x00, 0x81, 0xFF, 0x71, 0x00, 0xC3, 0xFF, 0x0F, 0x00, 0xFF,
2314 0xFF, 0x15, 0x00, 0x98, 0xFF, 0x35, 0x01, 0x25, 0xFD, 0x1E, 0x06,
2315 0x35, 0xF2, 0x2E, 0x39, 0x55, 0x26, 0x56, 0xF2, 0x1A, 0x07, 0x31,
2316 0xFC, 0xE1, 0x01, 0x3C, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x00, 0x00,
2317 0x26, 0x00, 0x6A, 0xFF, 0x55, 0x01, 0xA3, 0xFD, 0xAD, 0x03, 0x94,
2318 0xFA, 0xFF, 0x08, 0x70, 0x48, 0xF3, 0xFE, 0xEA, 0xFE, 0x6C, 0x01,
2319 0xCD, 0xFE, 0xC9, 0x00, 0xA1, 0xFF, 0x17, 0x00, 0xFD, 0xFF, 0x26,
2320 0x00, 0x69, 0xFF, 0x91, 0x01, 0x94, 0xFC, 0xE0, 0x06, 0x84, 0xF1,
2321 0xAF, 0x32, 0xCA, 0x2D, 0x92, 0xF1, 0x1F, 0x07, 0x56, 0xFC, 0xBE,
2322 0x01, 0x51, 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0x1D, 0x00, 0x8A, 0xFF,
2323 0x04, 0x01, 0x50, 0xFE, 0x5A, 0x02, 0x2C, 0xFD, 0xC6, 0x02, 0xF2,
2324 0x48, 0x9B, 0x04, 0x61, 0xFC, 0xC3, 0x02, 0x19, 0xFE, 0x1E, 0x01,
2325 0x7F, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x31, 0x00, 0x49,
2326 0xFF, 0xCC, 0x01, 0x44, 0xFC, 0x29, 0x07, 0xB9, 0xF1, 0x89, 0x2B,
2327 0xC3, 0x34, 0xA0, 0xF1, 0xB1, 0x06, 0xBA, 0xFC, 0x79, 0x01, 0x76,
2328 0xFF, 0x21, 0x00, 0xFE, 0xFF, 0x14, 0x00, 0xAC, 0xFF, 0xAE, 0x00,
2329 0x05, 0xFF, 0x03, 0x01, 0xAA, 0xFF, 0x63, 0xFD, 0xFD, 0x47, 0x0E,
2330 0x0B, 0xC8, 0xF9, 0x11, 0x04, 0x71, 0xFD, 0x6C, 0x01, 0x61, 0xFF,
2331 0x28, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE5,
2332 0x01, 0x33, 0xFC, 0x03, 0x07, 0xB7, 0xF2, 0xFC, 0x23, 0x03, 0x3B,
2333 0x9E, 0xF2, 0xCB, 0x05, 0x5F, 0xFD, 0x12, 0x01, 0xAA, 0xFF, 0x0E,
2334 0x00, 0x00, 0x00, 0x0C, 0x00, 0xCD, 0xFF, 0x57, 0x00, 0xB6, 0xFF,
2335 0xBE, 0xFF, 0xED, 0x01, 0xF5, 0xF8, 0x9B, 0x45, 0x22, 0x12, 0x48,
2336 0xF7, 0x3D, 0x05, 0xE2, 0xFC, 0xAB, 0x01, 0x49, 0xFF, 0x30, 0x00,
2337 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xDF, 0x01, 0x5C,
2338 0xFC, 0x78, 0x06, 0x5A, 0xF4, 0x49, 0x1C, 0x4E, 0x40, 0x9E, 0xF4,
2339 0x6D, 0x04, 0x3F, 0xFE, 0x8E, 0x00, 0xED, 0xFF, 0xF6, 0xFF, 0x04,
2340 0x00, 0x06, 0x00, 0xEC, 0xFF, 0x06, 0x00, 0x5A, 0x00, 0x9A, 0xFE,
2341 0xDA, 0x03, 0x8D, 0xF5, 0xE1, 0x41, 0xA1, 0x19, 0x09, 0xF5, 0x33,
2342 0x06, 0x77, 0xFC, 0xD6, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFE, 0xFF,
2343 0xFF, 0xFF, 0x32, 0x00, 0x42, 0xFF, 0xBC, 0x01, 0xB8, 0xFC, 0x9A,
2344 0x05, 0x77, 0xF6, 0xB1, 0x14, 0x77, 0x44, 0xA9, 0xF7, 0xA2, 0x02,
2345 0x54, 0xFF, 0xF1, 0xFF, 0x3A, 0x00, 0xD8, 0xFF, 0x0A, 0x00, 0x01,
2346 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xE8, 0x00, 0xA6, 0xFD, 0x5F, 0x05,
2347 0x31, 0xF3, 0xF6, 0x3C, 0x52, 0x21, 0x37, 0xF3, 0xDD, 0x06, 0x3B,
2348 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00,
2349 0x2B, 0x00, 0x58, 0xFF, 0x83, 0x01, 0x3C, 0xFD, 0x7E, 0x04, 0xE6,
2350 0xF8, 0x72, 0x0D, 0x52, 0x47, 0xBE, 0xFB, 0x7A, 0x00, 0x90, 0x00,
2351 0x43, 0xFF, 0x8F, 0x00, 0xB7, 0xFF, 0x11, 0x00, 0xFE, 0xFF, 0x1C,
2352 0x00, 0x86, 0xFF, 0x59, 0x01, 0xEC, 0xFC, 0x6F, 0x06, 0xDC, 0xF1,
2353 0x04, 0x37, 0xF3, 0x28, 0xFC, 0xF1, 0x28, 0x07, 0x37, 0xFC, 0xD8,
2354 0x01, 0x41, 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x23, 0x00,
2355 0x74, 0xFF, 0x3A, 0x01, 0xDD, 0xFD, 0x39, 0x03, 0x7B, 0xFB, 0xC1,
2356 0x06, 0xC7, 0x48, 0xCF, 0x00, 0x0D, 0xFE, 0xE3, 0x01, 0x8E, 0xFE,
2357 0xE7, 0x00, 0x95, 0xFF, 0x1A, 0x00, 0xFD, 0xFF, 0x2A, 0x00, 0x5C,
2358 0xFF, 0xAA, 0x01, 0x71, 0xFC, 0x07, 0x07, 0x7E, 0xF1, 0x44, 0x30,
2359 0x44, 0x30, 0x7E, 0xF1, 0x07, 0x07, 0x71, 0xFC, 0xAA, 0x01, 0x5C,
2360 0xFF, 0x2A, 0x00, 0xFD, 0xFF, 0x1A, 0x00, 0x95, 0xFF, 0xE7, 0x00,
2361 0x8E, 0xFE, 0xE3, 0x01, 0x0D, 0xFE, 0xCF, 0x00, 0xC7, 0x48, 0xC1,
2362 0x06, 0x7B, 0xFB, 0x39, 0x03, 0xDD, 0xFD, 0x3A, 0x01, 0x74, 0xFF,
2363 0x23, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x33, 0x00, 0x41, 0xFF, 0xD8,
2364 0x01, 0x37, 0xFC, 0x28, 0x07, 0xFC, 0xF1, 0xF3, 0x28, 0x04, 0x37,
2365 0xDC, 0xF1, 0x6F, 0x06, 0xEC, 0xFC, 0x59, 0x01, 0x86, 0xFF, 0x1C,
2366 0x00, 0xFE, 0xFF, 0x11, 0x00, 0xB7, 0xFF, 0x8F, 0x00, 0x43, 0xFF,
2367 0x90, 0x00, 0x7A, 0x00, 0xBE, 0xFB, 0x52, 0x47, 0x72, 0x0D, 0xE6,
2368 0xF8, 0x7E, 0x04, 0x3C, 0xFD, 0x83, 0x01, 0x58, 0xFF, 0x2B, 0x00,
2369 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3B,
2370 0xFC, 0xDD, 0x06, 0x37, 0xF3, 0x52, 0x21, 0xF6, 0x3C, 0x31, 0xF3,
2371 0x5F, 0x05, 0xA6, 0xFD, 0xE8, 0x00, 0xC0, 0xFF, 0x07, 0x00, 0x01,
2372 0x00, 0x0A, 0x00, 0xD8, 0xFF, 0x3A, 0x00, 0xF1, 0xFF, 0x54, 0xFF,
2373 0xA2, 0x02, 0xA9, 0xF7, 0x77, 0x44, 0xB1, 0x14, 0x77, 0xF6, 0x9A,
2374 0x05, 0xB8, 0xFC, 0xBC, 0x01, 0x42, 0xFF, 0x32, 0x00, 0xFF, 0xFF,
2375 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD6, 0x01, 0x77, 0xFC, 0x33,
2376 0x06, 0x09, 0xF5, 0xA1, 0x19, 0xE1, 0x41, 0x8D, 0xF5, 0xDA, 0x03,
2377 0x9A, 0xFE, 0x5A, 0x00, 0x06, 0x00, 0xEC, 0xFF, 0x06, 0x00, 0x04,
2378 0x00, 0xF6, 0xFF, 0xED, 0xFF, 0x8E, 0x00, 0x3F, 0xFE, 0x6D, 0x04,
2379 0x9E, 0xF4, 0x4E, 0x40, 0x49, 0x1C, 0x5A, 0xF4, 0x78, 0x06, 0x5C,
2380 0xFC, 0xDF, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF,
2381 0x30, 0x00, 0x49, 0xFF, 0xAB, 0x01, 0xE2, 0xFC, 0x3D, 0x05, 0x48,
2382 0xF7, 0x22, 0x12, 0x9B, 0x45, 0xF5, 0xF8, 0xED, 0x01, 0xBE, 0xFF,
2383 0xB6, 0xFF, 0x57, 0x00, 0xCD, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x0E,
2384 0x00, 0xAA, 0xFF, 0x12, 0x01, 0x5F, 0xFD, 0xCB, 0x05, 0x9E, 0xF2,
2385 0x03, 0x3B, 0xFC, 0x23, 0xB7, 0xF2, 0x03, 0x07, 0x33, 0xFC, 0xE5,
2386 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x28, 0x00,
2387 0x61, 0xFF, 0x6C, 0x01, 0x71, 0xFD, 0x11, 0x04, 0xC8, 0xF9, 0x0E,
2388 0x0B, 0xFD, 0x47, 0x63, 0xFD, 0xAA, 0xFF, 0x03, 0x01, 0x05, 0xFF,
2389 0xAE, 0x00, 0xAC, 0xFF, 0x14, 0x00, 0xFE, 0xFF, 0x21, 0x00, 0x76,
2390 0xFF, 0x79, 0x01, 0xBA, 0xFC, 0xB1, 0x06, 0xA0, 0xF1, 0xC3, 0x34,
2391 0x89, 0x2B, 0xB9, 0xF1, 0x29, 0x07, 0x44, 0xFC, 0xCC, 0x01, 0x49,
2392 0xFF, 0x31, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x20, 0x00, 0x7F, 0xFF,
2393 0x1E, 0x01, 0x19, 0xFE, 0xC3, 0x02, 0x61, 0xFC, 0x9B, 0x04, 0xF2,
2394 0x48, 0xC6, 0x02, 0x2C, 0xFD, 0x5A, 0x02, 0x50, 0xFE, 0x04, 0x01,
2395 0x8A, 0xFF, 0x1D, 0x00, 0xFD, 0xFF, 0x2E, 0x00, 0x51, 0xFF, 0xBE,
2396 0x01, 0x56, 0xFC, 0x1F, 0x07, 0x92, 0xF1, 0xCA, 0x2D, 0xAF, 0x32,
2397 0x84, 0xF1, 0xE0, 0x06, 0x94, 0xFC, 0x91, 0x01, 0x69, 0xFF, 0x26,
2398 0x00, 0xFD, 0xFF, 0x17, 0x00, 0xA1, 0xFF, 0xC9, 0x00, 0xCD, 0xFE,
2399 0x6C, 0x01, 0xEA, 0xFE, 0xF3, 0xFE, 0x70, 0x48, 0xFF, 0x08, 0x94,
2400 0xFA, 0xAD, 0x03, 0xA3, 0xFD, 0x55, 0x01, 0x6A, 0xFF, 0x26, 0x00,
2401 0x00, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3C, 0xFF, 0xE1, 0x01, 0x31,
2402 0xFC, 0x1A, 0x07, 0x56, 0xF2, 0x55, 0x26, 0x2E, 0x39, 0x35, 0xF2,
2403 0x1E, 0x06, 0x25, 0xFD, 0x35, 0x01, 0x98, 0xFF, 0x15, 0x00, 0xFF,
2404 0xFF, 0x0F, 0x00, 0xC3, 0xFF, 0x71, 0x00, 0x81, 0xFF, 0x1F, 0x00,
2405 0x42, 0x01, 0x37, 0xFA, 0x7C, 0x46, 0xE7, 0x0F, 0x08, 0xF8, 0xE6,
2406 0x04, 0x0B, 0xFD, 0x99, 0x01, 0x4F, 0xFF, 0x2E, 0x00, 0xFF, 0xFF,
2407 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4, 0x01, 0x4A, 0xFC, 0xAC,
2408 0x06, 0xCA, 0xF3, 0xA7, 0x1E, 0xCA, 0x3E, 0xE4, 0xF3, 0xE5, 0x04,
2409 0xF4, 0xFD, 0xBA, 0x00, 0xD7, 0xFF, 0xFE, 0xFF, 0x03, 0x00, 0x08,
2410 0x00, 0xE3, 0xFF, 0x1E, 0x00, 0x2A, 0x00, 0xEF, 0xFE, 0x4D, 0x03,
2411 0x7D, 0xF6, 0x2A, 0x43, 0x4B, 0x17, 0xB0, 0xF5, 0xEF, 0x05, 0x93,
2412 0xFC, 0xCB, 0x01, 0x3D, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0xFE, 0xFF,
2413 0x34, 0x00, 0x3E, 0xFF, 0xC9, 0x01, 0x97, 0xFC, 0xE6, 0x05, 0xC6,
2414 0xF5, 0x00, 0x17, 0x50, 0x43, 0x9D, 0xF6, 0x3A, 0x03, 0xFA, 0xFE,
2415 0x23, 0x00, 0x21, 0x00, 0xE2, 0xFF, 0x08, 0x00, 0x03, 0x00, 0xFF,
2416 0xFF, 0xD4, 0xFF, 0xBF, 0x00, 0xEB, 0xFD, 0xF3, 0x04, 0xCF, 0xF3,
2417 0x98, 0x3E, 0xF3, 0x1E, 0xB9, 0xF3, 0xB2, 0x06, 0x48, 0xFC, 0xE4,
2418 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x2E, 0x00,
2419 0x50, 0xFF, 0x97, 0x01, 0x10, 0xFD, 0xDA, 0x04, 0x20, 0xF8, 0xA0,
2420 0x0F, 0x97, 0x46, 0x61, 0xFA, 0x2D, 0x01, 0x2B, 0x00, 0x7A, 0xFF,
2421 0x75, 0x00, 0xC2, 0xFF, 0x0F, 0x00, 0xFF, 0xFF, 0x16, 0x00, 0x96,
2422 0xFF, 0x39, 0x01, 0x1F, 0xFD, 0x28, 0x06, 0x2A, 0xF2, 0xF2, 0x38,
2423 0xA0, 0x26, 0x4B, 0xF2, 0x1C, 0x07, 0x32, 0xFC, 0xE0, 0x01, 0x3C,
2424 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6B, 0xFF,
2425 0x52, 0x01, 0xA9, 0xFD, 0xA0, 0x03, 0xAE, 0xFA, 0xBE, 0x08, 0x7C,
2426 0x48, 0x26, 0xFF, 0xD2, 0xFE, 0x79, 0x01, 0xC6, 0xFE, 0xCC, 0x00,
2427 0xA0, 0xFF, 0x17, 0x00, 0xFD, 0xFF, 0x26, 0x00, 0x67, 0xFF, 0x94,
2428 0x01, 0x90, 0xFC, 0xE5, 0x06, 0x81, 0xF1, 0x6B, 0x32, 0x11, 0x2E,
2429 0x8E, 0xF1, 0x1D, 0x07, 0x58, 0xFC, 0xBC, 0x01, 0x52, 0xFF, 0x2E,
2430 0x00, 0xFD, 0xFF, 0x1D, 0x00, 0x8B, 0xFF, 0x01, 0x01, 0x56, 0xFE,
2431 0x4D, 0x02, 0x45, 0xFD, 0x8D, 0x02, 0xF0, 0x48, 0xD7, 0x04, 0x47,
2432 0xFC, 0xD1, 0x02, 0x12, 0xFE, 0x21, 0x01, 0x7E, 0xFF, 0x20, 0x00,
2433 0x00, 0x00, 0xFD, 0xFF, 0x31, 0x00, 0x48, 0xFF, 0xCE, 0x01, 0x42,
2434 0xFC, 0x2A, 0x07, 0xBF, 0xF1, 0x40, 0x2B, 0x05, 0x35, 0xA6, 0xF1,
2435 0xAB, 0x06, 0xBF, 0xFC, 0x75, 0x01, 0x77, 0xFF, 0x21, 0x00, 0xFE,
2436 0xFF, 0x14, 0x00, 0xAD, 0xFF, 0xAA, 0x00, 0x0C, 0xFF, 0xF7, 0x00,
2437 0xC1, 0xFF, 0x33, 0xFD, 0xEC, 0x47, 0x51, 0x0B, 0xAF, 0xF9, 0x1D,
2438 0x04, 0x6B, 0xFD, 0x6E, 0x01, 0x60, 0xFF, 0x29, 0x00, 0x00, 0x00,
2439 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE5, 0x01, 0x33, 0xFC, 0xFF,
2440 0x06, 0xC4, 0xF2, 0xB0, 0x23, 0x3B, 0x3B, 0xAD, 0xF2, 0xBF, 0x05,
2441 0x66, 0xFD, 0x0E, 0x01, 0xAC, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x0C,
2442 0x00, 0xCE, 0xFF, 0x54, 0x00, 0xBD, 0xFF, 0xB2, 0xFF, 0x01, 0x02,
2443 0xCF, 0xF8, 0x7D, 0x45, 0x6B, 0x12, 0x30, 0xF7, 0x48, 0x05, 0xDD,
2444 0xFC, 0xAD, 0x01, 0x48, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0xFE, 0xFF,
2445 0x36, 0x00, 0x37, 0xFF, 0xDE, 0x01, 0x5F, 0xFC, 0x70, 0x06, 0x6C,
2446 0xF4, 0xFD, 0x1B, 0x7D, 0x40, 0xB7, 0xF4, 0x5D, 0x04, 0x49, 0xFE,
2447 0x88, 0x00, 0xEF, 0xFF, 0xF5, 0xFF, 0x04, 0x00, 0x06, 0x00, 0xED,
2448 0xFF, 0x04, 0x00, 0x60, 0x00, 0x90, 0xFE, 0xEB, 0x03, 0x71, 0xF5,
2449 0xB7, 0x41, 0xED, 0x19, 0xF5, 0xF4, 0x3B, 0x06, 0x73, 0xFC, 0xD7,
2450 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x32, 0x00,
2451 0x43, 0xFF, 0xBA, 0x01, 0xBC, 0xFC, 0x90, 0x05, 0x8E, 0xF6, 0x68,
2452 0x14, 0x99, 0x44, 0xCD, 0xF7, 0x8F, 0x02, 0x60, 0xFF, 0xEA, 0xFF,
2453 0x3E, 0x00, 0xD7, 0xFF, 0x0A, 0x00, 0x01, 0x00, 0x07, 0x00, 0xBD,
2454 0xFF, 0xED, 0x00, 0x9E, 0xFD, 0x6C, 0x05, 0x1F, 0xF3, 0xC0, 0x3C,
2455 0x9E, 0x21, 0x28, 0xF3, 0xE2, 0x06, 0x3A, 0xFC, 0xE6, 0x01, 0x37,
2456 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x2B, 0x00, 0x59, 0xFF,
2457 0x81, 0x01, 0x42, 0xFD, 0x72, 0x04, 0xFF, 0xF8, 0x2D, 0x0D, 0x69,
2458 0x47, 0xEB, 0xFB, 0x63, 0x00, 0x9D, 0x00, 0x3C, 0xFF, 0x93, 0x00,
2459 0xB6, 0xFF, 0x12, 0x00, 0xFE, 0xFF, 0x1C, 0x00, 0x84, 0xFF, 0x5C,
2460 0x01, 0xE6, 0xFC, 0x77, 0x06, 0xD4, 0xF1, 0xC6, 0x36, 0x3E, 0x29,
2461 0xF3, 0xF1, 0x29, 0x07, 0x38, 0xFC, 0xD7, 0x01, 0x42, 0xFF, 0x33,
2462 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x22, 0x00, 0x76, 0xFF, 0x37, 0x01,
2463 0xE4, 0xFD, 0x2C, 0x03, 0x94, 0xFB, 0x83, 0x06, 0xCE, 0x48, 0x05,
2464 0x01, 0xF5, 0xFD, 0xF0, 0x01, 0x87, 0xFE, 0xEA, 0x00, 0x94, 0xFF,
2465 0x1A, 0x00, 0xFD, 0xFF, 0x2B, 0x00, 0x5A, 0xFF, 0xAC, 0x01, 0x6E,
2466 0xFC, 0x0A, 0x07, 0x7E, 0xF1, 0xFF, 0x2F, 0x8A, 0x30, 0x7D, 0xF1,
2467 0x03, 0x07, 0x75, 0xFC, 0xA7, 0x01, 0x5D, 0xFF, 0x2A, 0x00, 0xFD,
2468 0xFF, 0x1A, 0x00, 0x96, 0xFF, 0xE3, 0x00, 0x95, 0xFE, 0xD5, 0x01,
2469 0x26, 0xFE, 0x98, 0x00, 0xBF, 0x48, 0x00, 0x07, 0x61, 0xFB, 0x46,
2470 0x03, 0xD6, 0xFD, 0x3D, 0x01, 0x73, 0xFF, 0x23, 0x00, 0x00, 0x00,
2471 0xFD, 0xFF, 0x33, 0x00, 0x41, 0xFF, 0xDA, 0x01, 0x36, 0xFC, 0x27,
2472 0x07, 0x05, 0xF2, 0xAA, 0x28, 0x44, 0x37, 0xE4, 0xF1, 0x67, 0x06,
2473 0xF2, 0xFC, 0x55, 0x01, 0x88, 0xFF, 0x1B, 0x00, 0xFE, 0xFF, 0x11,
2474 0x00, 0xB9, 0xFF, 0x8C, 0x00, 0x4A, 0xFF, 0x83, 0x00, 0x91, 0x00,
2475 0x91, 0xFB, 0x3D, 0x47, 0xB7, 0x0D, 0xCD, 0xF8, 0x89, 0x04, 0x36,
2476 0xFD, 0x86, 0x01, 0x57, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0xFD, 0xFF,
2477 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3C, 0xFC, 0xD8, 0x06, 0x47,
2478 0xF3, 0x06, 0x21, 0x2A, 0x3D, 0x44, 0xF3, 0x52, 0x05, 0xAE, 0xFD,
2479 0xE3, 0x00, 0xC2, 0xFF, 0x06, 0x00, 0x01, 0x00, 0x0A, 0x00, 0xD9,
2480 0xFF, 0x37, 0x00, 0xF7, 0xFF, 0x49, 0xFF, 0xB6, 0x02, 0x86, 0xF7,
2481 0x53, 0x44, 0xFB, 0x14, 0x61, 0xF6, 0xA4, 0x05, 0xB4, 0xFC, 0xBE,
2482 0x01, 0x42, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x35, 0x00,
2483 0x3A, 0xFF, 0xD4, 0x01, 0x7A, 0xFC, 0x2B, 0x06, 0x1E, 0xF5, 0x56,
2484 0x19, 0x0C, 0x42, 0xAA, 0xF5, 0xC9, 0x03, 0xA4, 0xFE, 0x54, 0x00,
2485 0x09, 0x00, 0xEB, 0xFF, 0x06, 0x00, 0x04, 0x00, 0xF7, 0xFF, 0xEA,
2486 0xFF, 0x93, 0x00, 0x36, 0xFE, 0x7D, 0x04, 0x85, 0xF4, 0x1F, 0x40,
2487 0x94, 0x1C, 0x47, 0xF4, 0x7E, 0x06, 0x5A, 0xFC, 0xDF, 0x01, 0x37,
2488 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x30, 0x00, 0x4A, 0xFF,
2489 0xA9, 0x01, 0xE7, 0xFC, 0x33, 0x05, 0x60, 0xF7, 0xDA, 0x11, 0xB8,
2490 0x45, 0x1C, 0xF9, 0xD8, 0x01, 0xCA, 0xFF, 0xAF, 0xFF, 0x5A, 0x00,
2491 0xCC, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xA8, 0xFF, 0x17,
2492 0x01, 0x57, 0xFD, 0xD6, 0x05, 0x90, 0xF2, 0xC8, 0x3A, 0x46, 0x24,
2493 0xAA, 0xF2, 0x06, 0x07, 0x32, 0xFC, 0xE5, 0x01, 0x39, 0xFF, 0x36,
2494 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x28, 0x00, 0x62, 0xFF, 0x69, 0x01,
2495 0x77, 0xFD, 0x04, 0x04, 0xE2, 0xF9, 0xCB, 0x0A, 0x0D, 0x48, 0x94,
2496 0xFD, 0x92, 0xFF, 0x10, 0x01, 0xFE, 0xFE, 0xB1, 0x00, 0xAA, 0xFF,
2497 0x15, 0x00, 0xFE, 0xFF, 0x22, 0x00, 0x74, 0xFF, 0x7C, 0x01, 0xB5,
2498 0xFC, 0xB8, 0x06, 0x9C, 0xF1, 0x81, 0x34, 0xD1, 0x2B, 0xB3, 0xF1,
2499 0x29, 0x07, 0x46, 0xFC, 0xCA, 0x01, 0x4A, 0xFF, 0x30, 0x00, 0xFD,
2500 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x81, 0xFF, 0x1B, 0x01, 0x20, 0xFE,
2501 0xB6, 0x02, 0x7A, 0xFC, 0x5F, 0x04, 0xF4, 0x48, 0xFF, 0x02, 0x13,
2502 0xFD, 0x67, 0x02, 0x49, 0xFE, 0x07, 0x01, 0x88, 0xFF, 0x1D, 0x00,
2503 0xFD, 0xFF, 0x2E, 0x00, 0x50, 0xFF, 0xC0, 0x01, 0x53, 0xFC, 0x21,
2504 0x07, 0x96, 0xF1, 0x82, 0x2D, 0xF2, 0x32, 0x86, 0xF1, 0xDB, 0x06,
2505 0x99, 0xFC, 0x8E, 0x01, 0x6A, 0xFF, 0x25, 0x00, 0xFD, 0xFF, 0x16,
2506 0x00, 0xA2, 0xFF, 0xC5, 0x00, 0xD4, 0xFE, 0x5F, 0x01, 0x03, 0xFF,
2507 0xBF, 0xFE, 0x63, 0x48, 0x40, 0x09, 0x7B, 0xFA, 0xB9, 0x03, 0x9D,
2508 0xFD, 0x58, 0x01, 0x69, 0xFF, 0x26, 0x00, 0x00, 0x00, 0xFD, 0xFF,
2509 0x35, 0x00, 0x3B, 0xFF, 0xE2, 0x01, 0x31, 0xFC, 0x17, 0x07, 0x61,
2510 0xF2, 0x0A, 0x26, 0x6A, 0x39, 0x41, 0xF2, 0x15, 0x06, 0x2C, 0xFD,
2511 0x31, 0x01, 0x9B, 0xFF, 0x14, 0x00, 0xFF, 0xFF, 0x0E, 0x00, 0xC4,
2512 0xFF, 0x6E, 0x00, 0x87, 0xFF, 0x13, 0x00, 0x58, 0x01, 0x0D, 0xFA,
2513 0x61, 0x46, 0x2D, 0x10, 0xF0, 0xF7, 0xF1, 0x04, 0x05, 0xFD, 0x9C,
2514 0x01, 0x4E, 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00,
2515 0x36, 0xFF, 0xE3, 0x01, 0x4C, 0xFC, 0xA6, 0x06, 0xDB, 0xF3, 0x5B,
2516 0x1E, 0xFC, 0x3E, 0xFA, 0xF3, 0xD7, 0x04, 0xFD, 0xFD, 0xB4, 0x00,
2517 0xD9, 0xFF, 0xFD, 0xFF, 0x03, 0x00, 0x08, 0x00, 0xE4, 0xFF, 0x1B,
2518 0x00, 0x30, 0x00, 0xE4, 0xFE, 0x5F, 0x03, 0x5E, 0xF6, 0x02, 0x43,
2519 0x96, 0x17, 0x9B, 0xF5, 0xF8, 0x05, 0x8F, 0xFC, 0xCC, 0x01, 0x3D,
2520 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x33, 0x00, 0x3E, 0xFF,
2521 0xC8, 0x01, 0x9B, 0xFC, 0xDD, 0x05, 0xDC, 0xF5, 0xB6, 0x16, 0x77,
2522 0x43, 0xBD, 0xF6, 0x28, 0x03, 0x05, 0xFF, 0x1D, 0x00, 0x25, 0x00,
2523 0xE1, 0xFF, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0xD2, 0xFF, 0xC4,
2524 0x00, 0xE2, 0xFD, 0x01, 0x05, 0xBA, 0xF3, 0x64, 0x3E, 0x3F, 0x1F,
2525 0xA8, 0xF3, 0xB8, 0x06, 0x46, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36,
2526 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x2D, 0x00, 0x51, 0xFF, 0x95, 0x01,
2527 0x15, 0xFD, 0xCF, 0x04, 0x39, 0xF8, 0x59, 0x0F, 0xAF, 0x46, 0x8B,
2528 0xFA, 0x17, 0x01, 0x38, 0x00, 0x73, 0xFF, 0x78, 0x00, 0xC0, 0xFF,
2529 0x0F, 0x00, 0xFF, 0xFF, 0x16, 0x00, 0x94, 0xFF, 0x3D, 0x01, 0x18,
2530 0xFD, 0x32, 0x06, 0x1F, 0xF2, 0xB5, 0x38, 0xEB, 0x26, 0x40, 0xF2,
2531 0x1E, 0x07, 0x32, 0xFC, 0xDF, 0x01, 0x3D, 0xFF, 0x35, 0x00, 0xFD,
2532 0xFF, 0x00, 0x00, 0x25, 0x00, 0x6C, 0xFF, 0x4F, 0x01, 0xB0, 0xFD,
2533 0x93, 0x03, 0xC7, 0xFA, 0x7D, 0x08, 0x86, 0x48, 0x5A, 0xFF, 0xBA,
2534 0xFE, 0x86, 0x01, 0xBF, 0xFE, 0xCF, 0x00, 0x9E, 0xFF, 0x17, 0x00,
2535 0xFD, 0xFF, 0x27, 0x00, 0x66, 0xFF, 0x97, 0x01, 0x8C, 0xFC, 0xEA,
2536 0x06, 0x80, 0xF1, 0x26, 0x32, 0x58, 0x2E, 0x8B, 0xF1, 0x1B, 0x07,
2537 0x5B, 0xFC, 0xBA, 0x01, 0x53, 0xFF, 0x2D, 0x00, 0xFD, 0xFF, 0x1C,
2538 0x00, 0x8C, 0xFF, 0xFE, 0x00, 0x5D, 0xFE, 0x3F, 0x02, 0x5E, 0xFD,
2539 0x54, 0x02, 0xEC, 0x48, 0x13, 0x05, 0x2E, 0xFC, 0xDE, 0x02, 0x0C,
2540 0xFE, 0x24, 0x01, 0x7D, 0xFF, 0x20, 0x00, 0x00, 0x00, 0xFD, 0xFF,
2541 0x31, 0x00, 0x47, 0xFF, 0xCF, 0x01, 0x40, 0xFC, 0x2A, 0x07, 0xC6,
2542 0xF1, 0xF7, 0x2A, 0x46, 0x35, 0xAB, 0xF1, 0xA4, 0x06, 0xC4, 0xFC,
2543 0x72, 0x01, 0x79, 0xFF, 0x20, 0x00, 0xFE, 0xFF, 0x14, 0x00, 0xAE,
2544 0xFF, 0xA7, 0x00, 0x12, 0xFF, 0xEA, 0x00, 0xD9, 0xFF, 0x03, 0xFD,
2545 0xDC, 0x47, 0x95, 0x0B, 0x96, 0xF9, 0x29, 0x04, 0x65, 0xFD, 0x71,
2546 0x01, 0x5F, 0xFF, 0x29, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00,
2547 0x38, 0xFF, 0xE6, 0x01, 0x34, 0xFC, 0xFB, 0x06, 0xD2, 0xF2, 0x64,
2548 0x23, 0x73, 0x3B, 0xBC, 0xF2, 0xB4, 0x05, 0x6E, 0xFD, 0x09, 0x01,
2549 0xAF, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x0C, 0x00, 0xD0, 0xFF, 0x51,
2550 0x00, 0xC3, 0xFF, 0xA6, 0xFF, 0x16, 0x02, 0xA9, 0xF8, 0x5C, 0x45,
2551 0xB2, 0x12, 0x19, 0xF7, 0x52, 0x05, 0xD8, 0xFC, 0xAF, 0x01, 0x47,
2552 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x38, 0xFF,
2553 0xDD, 0x01, 0x62, 0xFC, 0x69, 0x06, 0x7F, 0xF4, 0xB2, 0x1B, 0xAB,
2554 0x40, 0xD0, 0xF4, 0x4E, 0x04, 0x53, 0xFE, 0x83, 0x00, 0xF2, 0xFF,
2555 0xF4, 0xFF, 0x05, 0x00, 0x06, 0x00, 0xEE, 0xFF, 0x01, 0x00, 0x66,
2556 0x00, 0x85, 0xFE, 0xFC, 0x03, 0x55, 0xF5, 0x8C, 0x41, 0x38, 0x1A,
2557 0xE1, 0xF4, 0x43, 0x06, 0x70, 0xFC, 0xD8, 0x01, 0x39, 0xFF, 0x35,
2558 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x32, 0x00, 0x44, 0xFF, 0xB9, 0x01,
2559 0xC1, 0xFC, 0x86, 0x05, 0xA5, 0xF6, 0x1E, 0x14, 0xBA, 0x44, 0xF0,
2560 0xF7, 0x7B, 0x02, 0x6B, 0xFF, 0xE4, 0xFF, 0x41, 0x00, 0xD6, 0xFF,
2561 0x0B, 0x00, 0x01, 0x00, 0x08, 0x00, 0xBB, 0xFF, 0xF1, 0x00, 0x96,
2562 0xFD, 0x78, 0x05, 0x0E, 0xF3, 0x8A, 0x3C, 0xEA, 0x21, 0x19, 0xF3,
2563 0xE6, 0x06, 0x38, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD,
2564 0xFF, 0x00, 0x00, 0x2B, 0x00, 0x5A, 0xFF, 0x7E, 0x01, 0x48, 0xFD,
2565 0x66, 0x04, 0x18, 0xF9, 0xE8, 0x0C, 0x7C, 0x47, 0x19, 0xFC, 0x4D,
2566 0x00, 0xA9, 0x00, 0x35, 0xFF, 0x96, 0x00, 0xB5, 0xFF, 0x12, 0x00,
2567 0xFE, 0xFF, 0x1D, 0x00, 0x82, 0xFF, 0x60, 0x01, 0xE0, 0xFC, 0x7F,
2568 0x06, 0xCC, 0xF1, 0x85, 0x36, 0x87, 0x29, 0xEB, 0xF1, 0x2A, 0x07,
2569 0x39, 0xFC, 0xD6, 0x01, 0x43, 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0x00,
2570 0x00, 0x22, 0x00, 0x77, 0xFF, 0x34, 0x01, 0xEA, 0xFD, 0x1F, 0x03,
2571 0xAE, 0xFB, 0x45, 0x06, 0xD5, 0x48, 0x3C, 0x01, 0xDC, 0xFD, 0xFD,
2572 0x01, 0x80, 0xFE, 0xED, 0x00, 0x93, 0xFF, 0x1B, 0x00, 0xFD, 0xFF,
2573 0x2B, 0x00, 0x59, 0xFF, 0xAE, 0x01, 0x6A, 0xFC, 0x0D, 0x07, 0x80,
2574 0xF1, 0xB8, 0x2F, 0xCF, 0x30, 0x7D, 0xF1, 0xFF, 0x06, 0x78, 0xFC,
2575 0xA5, 0x01, 0x5F, 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0x19, 0x00, 0x98,
2576 0xFF, 0xE0, 0x00, 0x9C, 0xFE, 0xC8, 0x01, 0x3F, 0xFE, 0x62, 0x00,
2577 0xB8, 0x48, 0x3F, 0x07, 0x47, 0xFB, 0x53, 0x03, 0xD0, 0xFD, 0x40,
2578 0x01, 0x72, 0xFF, 0x23, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x34, 0x00,
2579 0x40, 0xFF, 0xDB, 0x01, 0x35, 0xFC, 0x26, 0x07, 0x0E, 0xF2, 0x60,
2580 0x28, 0x82, 0x37, 0xED, 0xF1, 0x5E, 0x06, 0xF8, 0xFC, 0x51, 0x01,
2581 0x8A, 0xFF, 0x1A, 0x00, 0xFF, 0xFF, 0x11, 0x00, 0xBA, 0xFF, 0x89,
2582 0x00, 0x51, 0xFF, 0x77, 0x00, 0xA7, 0x00, 0x64, 0xFB, 0x26, 0x47,
2583 0xFC, 0x0D, 0xB4, 0xF8, 0x95, 0x04, 0x31, 0xFD, 0x88, 0x01, 0x56,
2584 0xFF, 0x2C, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF,
2585 0xE6, 0x01, 0x3E, 0xFC, 0xD3, 0x06, 0x56, 0xF3, 0xBA, 0x20, 0x61,
2586 0x3D, 0x56, 0xF3, 0x45, 0x05, 0xB7, 0xFD, 0xDE, 0x00, 0xC5, 0xFF,
2587 0x05, 0x00, 0x02, 0x00, 0x09, 0x00, 0xDB, 0xFF, 0x34, 0x00, 0xFE,
2588 0xFF, 0x3D, 0xFF, 0xC9, 0x02, 0x64, 0xF7, 0x2F, 0x44, 0x44, 0x15,
2589 0x4A, 0xF6, 0xAD, 0x05, 0xAF, 0xFC, 0xC0, 0x01, 0x41, 0xFF, 0x32,
2590 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD3, 0x01,
2591 0x7D, 0xFC, 0x23, 0x06, 0x32, 0xF5, 0x0C, 0x19, 0x38, 0x42, 0xC7,
2592 0xF5, 0xB8, 0x03, 0xAF, 0xFE, 0x4E, 0x00, 0x0C, 0x00, 0xEA, 0xFF,
2593 0x06, 0x00, 0x04, 0x00, 0xF8, 0xFF, 0xE7, 0xFF, 0x99, 0x00, 0x2C,
2594 0xFE, 0x8C, 0x04, 0x6D, 0xF4, 0xF0, 0x3F, 0xE0, 0x1C, 0x34, 0xF4,
2595 0x85, 0x06, 0x57, 0xFC, 0xE0, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE,
2596 0xFF, 0xFF, 0xFF, 0x2F, 0x00, 0x4A, 0xFF, 0xA7, 0x01, 0xEC, 0xFC,
2597 0x28, 0x05, 0x77, 0xF7, 0x92, 0x11, 0xD7, 0x45, 0x43, 0xF9, 0xC3,
2598 0x01, 0xD6, 0xFF, 0xA9, 0xFF, 0x5E, 0x00, 0xCB, 0xFF, 0x0D, 0x00,
2599 0x00, 0x00, 0x10, 0x00, 0xA6, 0xFF, 0x1B, 0x01, 0x50, 0xFD, 0xE1,
2600 0x05, 0x82, 0xF2, 0x8F, 0x3A, 0x92, 0x24, 0x9D, 0xF2, 0x09, 0x07,
2601 0x32, 0xFC, 0xE4, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00,
2602 0x00, 0x28, 0x00, 0x63, 0xFF, 0x66, 0x01, 0x7D, 0xFD, 0xF8, 0x03,
2603 0xFB, 0xF9, 0x89, 0x0A, 0x1D, 0x48, 0xC5, 0xFD, 0x7A, 0xFF, 0x1D,
2604 0x01, 0xF7, 0xFE, 0xB4, 0x00, 0xA9, 0xFF, 0x15, 0x00, 0xFE, 0xFF,
2605 0x23, 0x00, 0x72, 0xFF, 0x7F, 0x01, 0xB0, 0xFC, 0xBE, 0x06, 0x97,
2606 0xF1, 0x3F, 0x34, 0x19, 0x2C, 0xAD, 0xF1, 0x28, 0x07, 0x48, 0xFC,
2607 0xC9, 0x01, 0x4B, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x1F,
2608 0x00, 0x82, 0xFF, 0x18, 0x01, 0x27, 0xFE, 0xA9, 0x02, 0x94, 0xFC,
2609 0x24, 0x04, 0xF5, 0x48, 0x39, 0x03, 0xF9, 0xFC, 0x74, 0x02, 0x42,
2610 0xFE, 0x0B, 0x01, 0x87, 0xFF, 0x1E, 0x00, 0xFD, 0xFF, 0x2F, 0x00,
2611 0x4F, 0xFF, 0xC2, 0x01, 0x51, 0xFC, 0x23, 0x07, 0x9A, 0xF1, 0x3A,
2612 0x2D, 0x35, 0x33, 0x89, 0xF1, 0xD5, 0x06, 0x9D, 0xFC, 0x8B, 0x01,
2613 0x6C, 0xFF, 0x25, 0x00, 0xFD, 0xFF, 0x16, 0x00, 0xA4, 0xFF, 0xC2,
2614 0x00, 0xDB, 0xFE, 0x52, 0x01, 0x1B, 0xFF, 0x8D, 0xFE, 0x57, 0x48,
2615 0x81, 0x09, 0x61, 0xFA, 0xC6, 0x03, 0x96, 0xFD, 0x5B, 0x01, 0x68,
2616 0xFF, 0x26, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3B, 0xFF,
2617 0xE2, 0x01, 0x31, 0xFC, 0x15, 0x07, 0x6D, 0xF2, 0xBF, 0x25, 0xA5,
2618 0x39, 0x4D, 0xF2, 0x0B, 0x06, 0x33, 0xFD, 0x2D, 0x01, 0x9D, 0xFF,
2619 0x13, 0x00, 0xFF, 0xFF, 0x0E, 0x00, 0xC6, 0xFF, 0x6B, 0x00, 0x8E,
2620 0xFF, 0x06, 0x00, 0x6E, 0x01, 0xE4, 0xF9, 0x48, 0x46, 0x75, 0x10,
2621 0xD7, 0xF7, 0xFC, 0x04, 0x00, 0xFD, 0x9E, 0x01, 0x4E, 0xFF, 0x2E,
2622 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE3, 0x01,
2623 0x4E, 0xFC, 0xA0, 0x06, 0xED, 0xF3, 0x0F, 0x1E, 0x2D, 0x3F, 0x10,
2624 0xF4, 0xC8, 0x04, 0x07, 0xFE, 0xAF, 0x00, 0xDC, 0xFF, 0xFC, 0xFF,
2625 0x03, 0x00, 0x07, 0x00, 0xE5, 0xFF, 0x18, 0x00, 0x36, 0x00, 0xD9,
2626 0xFE, 0x71, 0x03, 0x3F, 0xF6, 0xDB, 0x42, 0xE0, 0x17, 0x86, 0xF5,
2627 0x00, 0x06, 0x8C, 0xFC, 0xCE, 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE,
2628 0xFF, 0xFF, 0xFF, 0x33, 0x00, 0x3F, 0xFF, 0xC6, 0x01, 0x9F, 0xFC,
2629 0xD3, 0x05, 0xF1, 0xF5, 0x6C, 0x16, 0x9E, 0x43, 0xDD, 0xF6, 0x15,
2630 0x03, 0x10, 0xFF, 0x17, 0x00, 0x28, 0x00, 0xDF, 0xFF, 0x09, 0x00,
2631 0x02, 0x00, 0x01, 0x00, 0xCF, 0xFF, 0xC9, 0x00, 0xDA, 0xFD, 0x0F,
2632 0x05, 0xA5, 0xF3, 0x31, 0x3E, 0x8A, 0x1F, 0x97, 0xF3, 0xBD, 0x06,
2633 0x44, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF,
2634 0xFF, 0x2D, 0x00, 0x52, 0xFF, 0x92, 0x01, 0x1B, 0xFD, 0xC4, 0x04,
2635 0x51, 0xF8, 0x13, 0x0F, 0xC8, 0x46, 0xB6, 0xFA, 0x01, 0x01, 0x44,
2636 0x00, 0x6C, 0xFF, 0x7B, 0x00, 0xBF, 0xFF, 0x10, 0x00, 0xFF, 0xFF,
2637 0x17, 0x00, 0x92, 0xFF, 0x41, 0x01, 0x11, 0xFD, 0x3B, 0x06, 0x14,
2638 0xF2, 0x78, 0x38, 0x36, 0x27, 0x35, 0xF2, 0x20, 0x07, 0x33, 0xFC,
2639 0xDF, 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x25,
2640 0x00, 0x6D, 0xFF, 0x4C, 0x01, 0xB6, 0xFD, 0x86, 0x03, 0xE1, 0xFA,
2641 0x3D, 0x08, 0x92, 0x48, 0x8E, 0xFF, 0xA1, 0xFE, 0x93, 0x01, 0xB8,
2642 0xFE, 0xD3, 0x00, 0x9D, 0xFF, 0x18, 0x00, 0xFD, 0xFF, 0x28, 0x00,
2643 0x64, 0xFF, 0x9A, 0x01, 0x88, 0xFC, 0xEE, 0x06, 0x7E, 0xF1, 0xE3,
2644 0x31, 0x9F, 0x2E, 0x88, 0xF1, 0x19, 0x07, 0x5E, 0xFC, 0xB7, 0x01,
2645 0x54, 0xFF, 0x2D, 0x00, 0xFD, 0xFF, 0x1C, 0x00, 0x8D, 0xFF, 0xFA,
2646 0x00, 0x64, 0xFE, 0x32, 0x02, 0x78, 0xFD, 0x1B, 0x02, 0xEA, 0x48,
2647 0x50, 0x05, 0x14, 0xFC, 0xEB, 0x02, 0x05, 0xFE, 0x27, 0x01, 0x7C,
2648 0xFF, 0x21, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x46, 0xFF,
2649 0xD1, 0x01, 0x3F, 0xFC, 0x2B, 0x07, 0xCD, 0xF1, 0xAE, 0x2A, 0x86,
2650 0x35, 0xB1, 0xF1, 0x9D, 0x06, 0xCA, 0xFC, 0x6E, 0x01, 0x7B, 0xFF,
2651 0x20, 0x00, 0xFE, 0xFF, 0x13, 0x00, 0xAF, 0xFF, 0xA4, 0x00, 0x19,
2652 0xFF, 0xDD, 0x00, 0xF0, 0xFF, 0xD4, 0xFC, 0xC9, 0x47, 0xD8, 0x0B,
2653 0x7C, 0xF9, 0x35, 0x04, 0x5F, 0xFD, 0x74, 0x01, 0x5E, 0xFF, 0x29,
2654 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE6, 0x01,
2655 0x35, 0xFC, 0xF7, 0x06, 0xE0, 0xF2, 0x18, 0x23, 0xAB, 0x3B, 0xCC,
2656 0xF2, 0xA8, 0x05, 0x76, 0xFD, 0x04, 0x01, 0xB1, 0xFF, 0x0C, 0x00,
2657 0x00, 0x00, 0x0C, 0x00, 0xD1, 0xFF, 0x4E, 0x00, 0xCA, 0xFF, 0x9A,
2658 0xFF, 0x2A, 0x02, 0x83, 0xF8, 0x3F, 0x45, 0xFB, 0x12, 0x01, 0xF7,
2659 0x5D, 0x05, 0xD3, 0xFC, 0xB1, 0x01, 0x46, 0xFF, 0x31, 0x00, 0xFF,
2660 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xDC, 0x01, 0x64, 0xFC,
2661 0x62, 0x06, 0x93, 0xF4, 0x66, 0x1B, 0xD9, 0x40, 0xEA, 0xF4, 0x3E,
2662 0x04, 0x5D, 0xFE, 0x7D, 0x00, 0xF5, 0xFF, 0xF3, 0xFF, 0x05, 0x00,
2663 0x05, 0x00, 0xEF, 0xFF, 0xFE, 0xFF, 0x6C, 0x00, 0x7B, 0xFE, 0x0C,
2664 0x04, 0x3A, 0xF5, 0x5F, 0x41, 0x83, 0x1A, 0xCD, 0xF4, 0x4B, 0x06,
2665 0x6D, 0xFC, 0xD9, 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0xFF,
2666 0xFF, 0x31, 0x00, 0x44, 0xFF, 0xB7, 0x01, 0xC5, 0xFC, 0x7C, 0x05,
2667 0xBC, 0xF6, 0xD5, 0x13, 0xDC, 0x44, 0x14, 0xF8, 0x67, 0x02, 0x77,
2668 0xFF, 0xDD, 0xFF, 0x44, 0x00, 0xD5, 0xFF, 0x0B, 0x00, 0x01, 0x00,
2669 0x09, 0x00, 0xB8, 0xFF, 0xF6, 0x00, 0x8D, 0xFD, 0x84, 0x05, 0xFD,
2670 0xF2, 0x52, 0x3C, 0x35, 0x22, 0x0B, 0xF3, 0xEB, 0x06, 0x37, 0xFC,
2671 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x2A,
2672 0x00, 0x5B, 0xFF, 0x7C, 0x01, 0x4E, 0xFD, 0x5A, 0x04, 0x31, 0xF9,
2673 0xA4, 0x0C, 0x90, 0x47, 0x47, 0xFC, 0x36, 0x00, 0xB6, 0x00, 0x2E,
2674 0xFF, 0x99, 0x00, 0xB3, 0xFF, 0x12, 0x00, 0xFE, 0xFF, 0x1E, 0x00,
2675 0x80, 0xFF, 0x64, 0x01, 0xDA, 0xFC, 0x87, 0x06, 0xC5, 0xF1, 0x46,
2676 0x36, 0xD1, 0x29, 0xE3, 0xF1, 0x2A, 0x07, 0x3A, 0xFC, 0xD5, 0x01,
2677 0x44, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x22, 0x00, 0x78,
2678 0xFF, 0x31, 0x01, 0xF1, 0xFD, 0x12, 0x03, 0xC7, 0xFB, 0x07, 0x06,
2679 0xDB, 0x48, 0x73, 0x01, 0xC3, 0xFD, 0x0A, 0x02, 0x79, 0xFE, 0xF1,
2680 0x00, 0x91, 0xFF, 0x1B, 0x00, 0xFD, 0xFF, 0x2C, 0x00, 0x58, 0xFF,
2681 0xB1, 0x01, 0x67, 0xFC, 0x10, 0x07, 0x81, 0xF1, 0x73, 0x2F, 0x15,
2682 0x31, 0x7C, 0xF1, 0xFB, 0x06, 0x7C, 0xFC, 0xA2, 0x01, 0x60, 0xFF,
2683 0x29, 0x00, 0xFD, 0xFF, 0x19, 0x00, 0x99, 0xFF, 0xDD, 0x00, 0xA3,
2684 0xFE, 0xBB, 0x01, 0x58, 0xFE, 0x2D, 0x00, 0xAF, 0x48, 0x7E, 0x07,
2685 0x2E, 0xFB, 0x60, 0x03, 0xC9, 0xFD, 0x43, 0x01, 0x71, 0xFF, 0x24,
2686 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x34, 0x00, 0x3F, 0xFF, 0xDC, 0x01,
2687 0x34, 0xFC, 0x25, 0x07, 0x18, 0xF2, 0x15, 0x28, 0xBF, 0x37, 0xF7,
2688 0xF1, 0x56, 0x06, 0xFE, 0xFC, 0x4D, 0x01, 0x8C, 0xFF, 0x19, 0x00,
2689 0xFF, 0xFF, 0x10, 0x00, 0xBB, 0xFF, 0x85, 0x00, 0x58, 0xFF, 0x6A,
2690 0x00, 0xBE, 0x00, 0x38, 0xFB, 0x0F, 0x47, 0x42, 0x0E, 0x9B, 0xF8,
2691 0xA1, 0x04, 0x2B, 0xFD, 0x8B, 0x01, 0x55, 0xFF, 0x2C, 0x00, 0xFF,
2692 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3F, 0xFC,
2693 0xCE, 0x06, 0x66, 0xF3, 0x6F, 0x20, 0x96, 0x3D, 0x69, 0xF3, 0x38,
2694 0x05, 0xBF, 0xFD, 0xD9, 0x00, 0xC7, 0xFF, 0x04, 0x00, 0x02, 0x00,
2695 0x09, 0x00, 0xDC, 0xFF, 0x31, 0x00, 0x04, 0x00, 0x32, 0xFF, 0xDC,
2696 0x02, 0x42, 0xF7, 0x0B, 0x44, 0x8E, 0x15, 0x34, 0xF6, 0xB7, 0x05,
2697 0xAB, 0xFC, 0xC1, 0x01, 0x40, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0xFE,
2698 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xD2, 0x01, 0x81, 0xFC, 0x1A, 0x06,
2699 0x47, 0xF5, 0xC1, 0x18, 0x60, 0x42, 0xE4, 0xF5, 0xA6, 0x03, 0xB9,
2700 0xFE, 0x48, 0x00, 0x0F, 0x00, 0xE9, 0xFF, 0x07, 0x00, 0x04, 0x00,
2701 0xF9, 0xFF, 0xE4, 0xFF, 0x9F, 0x00, 0x23, 0xFE, 0x9B, 0x04, 0x55,
2702 0xF4, 0xC0, 0x3F, 0x2C, 0x1D, 0x22, 0xF4, 0x8C, 0x06, 0x55, 0xFC,
2703 0xE1, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x2F,
2704 0x00, 0x4B, 0xFF, 0xA4, 0x01, 0xF1, 0xFC, 0x1D, 0x05, 0x8F, 0xF7,
2705 0x4A, 0x11, 0xF2, 0x45, 0x6B, 0xF9, 0xAE, 0x01, 0xE2, 0xFF, 0xA2,
2706 0xFF, 0x61, 0x00, 0xC9, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x11, 0x00,
2707 0xA3, 0xFF, 0x20, 0x01, 0x49, 0xFD, 0xEB, 0x05, 0x74, 0xF2, 0x54,
2708 0x3A, 0xDD, 0x24, 0x91, 0xF2, 0x0C, 0x07, 0x32, 0xFC, 0xE4, 0x01,
2709 0x3A, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x64,
2710 0xFF, 0x63, 0x01, 0x84, 0xFD, 0xEB, 0x03, 0x14, 0xFA, 0x47, 0x0A,
2711 0x2C, 0x48, 0xF6, 0xFD, 0x63, 0xFF, 0x2B, 0x01, 0xF0, 0xFE, 0xB8,
2712 0x00, 0xA8, 0xFF, 0x15, 0x00, 0xFE, 0xFF, 0x23, 0x00, 0x71, 0xFF,
2713 0x82, 0x01, 0xAB, 0xFC, 0xC4, 0x06, 0x93, 0xF1, 0xFD, 0x33, 0x62,
2714 0x2C, 0xA8, 0xF1, 0x27, 0x07, 0x4A, 0xFC, 0xC7, 0x01, 0x4C, 0xFF,
2715 0x30, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x1F, 0x00, 0x83, 0xFF, 0x14,
2716 0x01, 0x2D, 0xFE, 0x9C, 0x02, 0xAD, 0xFC, 0xE9, 0x03, 0xF6, 0x48,
2717 0x73, 0x03, 0xE0, 0xFC, 0x82, 0x02, 0x3B, 0xFE, 0x0E, 0x01, 0x86,
2718 0xFF, 0x1E, 0x00, 0xFD, 0xFF, 0x2F, 0x00, 0x4E, 0xFF, 0xC3, 0x01,
2719 0x4E, 0xFC, 0x24, 0x07, 0x9E, 0xF1, 0xF2, 0x2C, 0x78, 0x33, 0x8C,
2720 0xF1, 0xD0, 0x06, 0xA2, 0xFC, 0x88, 0x01, 0x6D, 0xFF, 0x24, 0x00,
2721 0xFD, 0xFF, 0x16, 0x00, 0xA5, 0xFF, 0xBE, 0x00, 0xE2, 0xFE, 0x45,
2722 0x01, 0x33, 0xFF, 0x5A, 0xFE, 0x48, 0x48, 0xC3, 0x09, 0x47, 0xFA,
2723 0xD2, 0x03, 0x90, 0xFD, 0x5E, 0x01, 0x66, 0xFF, 0x27, 0x00, 0x00,
2724 0x00, 0xFD, 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xE3, 0x01, 0x31, 0xFC,
2725 0x12, 0x07, 0x79, 0xF2, 0x73, 0x25, 0xDF, 0x39, 0x5A, 0xF2, 0x00,
2726 0x06, 0x3A, 0xFD, 0x28, 0x01, 0x9F, 0xFF, 0x13, 0x00, 0x00, 0x00,
2727 0x0E, 0x00, 0xC7, 0xFF, 0x68, 0x00, 0x95, 0xFF, 0xFA, 0xFF, 0x83,
2728 0x01, 0xBB, 0xF9, 0x2B, 0x46, 0xBB, 0x10, 0xBF, 0xF7, 0x07, 0x05,
2729 0xFB, 0xFC, 0xA0, 0x01, 0x4D, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0xFE,
2730 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE2, 0x01, 0x50, 0xFC, 0x99, 0x06,
2731 0xFE, 0xF3, 0xC3, 0x1D, 0x5E, 0x3F, 0x27, 0xF4, 0xB9, 0x04, 0x10,
2732 0xFE, 0xA9, 0x00, 0xDF, 0xFF, 0xFB, 0xFF, 0x03, 0x00, 0x07, 0x00,
2733 0xE6, 0xFF, 0x15, 0x00, 0x3C, 0x00, 0xCF, 0xFE, 0x83, 0x03, 0x20,
2734 0xF6, 0xB2, 0x42, 0x2B, 0x18, 0x71, 0xF5, 0x09, 0x06, 0x88, 0xFC,
2735 0xCF, 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x33,
2736 0x00, 0x3F, 0xFF, 0xC5, 0x01, 0xA3, 0xFC, 0xCA, 0x05, 0x07, 0xF6,
2737 0x22, 0x16, 0xC3, 0x43, 0xFE, 0xF6, 0x02, 0x03, 0x1B, 0xFF, 0x11,
2738 0x00, 0x2B, 0x00, 0xDE, 0xFF, 0x09, 0x00, 0x02, 0x00, 0x02, 0x00,
2739 0xCC, 0xFF, 0xCE, 0x00, 0xD1, 0xFD, 0x1D, 0x05, 0x91, 0xF3, 0xFE,
2740 0x3D, 0xD7, 0x1F, 0x87, 0xF3, 0xC3, 0x06, 0x42, 0xFC, 0xE5, 0x01,
2741 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x2D, 0x00, 0x53,
2742 0xFF, 0x90, 0x01, 0x20, 0xFD, 0xB8, 0x04, 0x6A, 0xF8, 0xCD, 0x0E,
2743 0xE1, 0x46, 0xE1, 0xFA, 0xEB, 0x00, 0x51, 0x00, 0x65, 0xFF, 0x7F,
2744 0x00, 0xBE, 0xFF, 0x10, 0x00, 0xFF, 0xFF, 0x18, 0x00, 0x90, 0xFF,
2745 0x45, 0x01, 0x0B, 0xFD, 0x44, 0x06, 0x0A, 0xF2, 0x3B, 0x38, 0x80,
2746 0x27, 0x2B, 0xF2, 0x22, 0x07, 0x33, 0xFC, 0xDE, 0x01, 0x3E, 0xFF,
2747 0x34, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x24, 0x00, 0x6E, 0xFF, 0x49,
2748 0x01, 0xBC, 0xFD, 0x7A, 0x03, 0xFA, 0xFA, 0xFD, 0x07, 0x9C, 0x48,
2749 0xC3, 0xFF, 0x89, 0xFE, 0xA1, 0x01, 0xB1, 0xFE, 0xD6, 0x00, 0x9C,
2750 0xFF, 0x18, 0x00, 0xFD, 0xFF, 0x28, 0x00, 0x63, 0xFF, 0x9D, 0x01,
2751 0x84, 0xFC, 0xF3, 0x06, 0x7D, 0xF1, 0x9E, 0x31, 0xE6, 0x2E, 0x85,
2752 0xF1, 0x16, 0x07, 0x61, 0xFC, 0xB5, 0x01, 0x55, 0xFF, 0x2D, 0x00,
2753 0xFD, 0xFF, 0x1C, 0x00, 0x8F, 0xFF, 0xF7, 0x00, 0x6B, 0xFE, 0x25,
2754 0x02, 0x91, 0xFD, 0xE3, 0x01, 0xE5, 0x48, 0x8D, 0x05, 0xFB, 0xFB,
2755 0xF8, 0x02, 0xFE, 0xFD, 0x2B, 0x01, 0x7A, 0xFF, 0x21, 0x00, 0x00,
2756 0x00, 0xFD, 0xFF, 0x32, 0x00, 0x45, 0xFF, 0xD2, 0x01, 0x3D, 0xFC,
2757 0x2B, 0x07, 0xD4, 0xF1, 0x64, 0x2A, 0xC6, 0x35, 0xB7, 0xF1, 0x96,
2758 0x06, 0xCF, 0xFC, 0x6B, 0x01, 0x7D, 0xFF, 0x1F, 0x00, 0xFE, 0xFF,
2759 0x13, 0x00, 0xB1, 0xFF, 0xA0, 0x00, 0x20, 0xFF, 0xD0, 0x00, 0x07,
2760 0x00, 0xA4, 0xFC, 0xB6, 0x47, 0x1C, 0x0C, 0x63, 0xF9, 0x42, 0x04,
2761 0x59, 0xFD, 0x76, 0x01, 0x5D, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0xFD,
2762 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x35, 0xFC, 0xF3, 0x06,
2763 0xEE, 0xF2, 0xCD, 0x22, 0xE4, 0x3B, 0xDC, 0xF2, 0x9C, 0x05, 0x7E,
2764 0xFD, 0x00, 0x01, 0xB4, 0xFF, 0x0B, 0x00, 0x01, 0x00, 0x0B, 0x00,
2765 0xD2, 0xFF, 0x4A, 0x00, 0xD0, 0xFF, 0x8E, 0xFF, 0x3F, 0x02, 0x5E,
2766 0xF8, 0x1E, 0x45, 0x44, 0x13, 0xEA, 0xF6, 0x67, 0x05, 0xCF, 0xFC,
2767 0xB3, 0x01, 0x46, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x36,
2768 0x00, 0x38, 0xFF, 0xDB, 0x01, 0x67, 0xFC, 0x5A, 0x06, 0xA6, 0xF4,
2769 0x1B, 0x1B, 0x07, 0x41, 0x04, 0xF5, 0x2D, 0x04, 0x67, 0xFE, 0x77,
2770 0x00, 0xF8, 0xFF, 0xF2, 0xFF, 0x05, 0x00, 0x05, 0x00, 0xF0, 0xFF,
2771 0xFB, 0xFF, 0x71, 0x00, 0x71, 0xFE, 0x1D, 0x04, 0x1F, 0xF5, 0x32,
2772 0x41, 0xCE, 0x1A, 0xBA, 0xF4, 0x53, 0x06, 0x6A, 0xFC, 0xDA, 0x01,
2773 0x38, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x31, 0x00, 0x45,
2774 0xFF, 0xB5, 0x01, 0xCA, 0xFC, 0x72, 0x05, 0xD3, 0xF6, 0x8D, 0x13,
2775 0xFD, 0x44, 0x39, 0xF8, 0x53, 0x02, 0x82, 0xFF, 0xD7, 0xFF, 0x47,
2776 0x00, 0xD3, 0xFF, 0x0B, 0x00, 0x01, 0x00, 0x0A, 0x00, 0xB6, 0xFF,
2777 0xFB, 0x00, 0x85, 0xFD, 0x90, 0x05, 0xEC, 0xF2, 0x1C, 0x3C, 0x81,
2778 0x22, 0xFC, 0xF2, 0xEF, 0x06, 0x36, 0xFC, 0xE6, 0x01, 0x37, 0xFF,
2779 0x36, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x2A, 0x00, 0x5C, 0xFF, 0x79,
2780 0x01, 0x53, 0xFD, 0x4E, 0x04, 0x4A, 0xF9, 0x60, 0x0C, 0xA3, 0x47,
2781 0x76, 0xFC, 0x1F, 0x00, 0xC3, 0x00, 0x27, 0xFF, 0x9D, 0x00, 0xB2,
2782 0xFF, 0x13, 0x00, 0xFE, 0xFF, 0x1E, 0x00, 0x7F, 0xFF, 0x67, 0x01,
2783 0xD5, 0xFC, 0x8E, 0x06, 0xBE, 0xF1, 0x06, 0x36, 0x1A, 0x2A, 0xDC,
2784 0xF1, 0x2A, 0x07, 0x3C, 0xFC, 0xD3, 0x01, 0x44, 0xFF, 0x32, 0x00,
2785 0xFD, 0xFF, 0x00, 0x00, 0x21, 0x00, 0x79, 0xFF, 0x2E, 0x01, 0xF7,
2786 0xFD, 0x05, 0x03, 0xE1, 0xFB, 0xCA, 0x05, 0xDF, 0x48, 0xAB, 0x01,
2787 0xAA, 0xFD, 0x18, 0x02, 0x72, 0xFE, 0xF4, 0x00, 0x90, 0xFF, 0x1B,
2788 0x00, 0xFD, 0xFF, 0x2C, 0x00, 0x57, 0xFF, 0xB3, 0x01, 0x64, 0xFC,
2789 0x13, 0x07, 0x83, 0xF1, 0x2C, 0x2F, 0x5A, 0x31, 0x7D, 0xF1, 0xF7,
2790 0x06, 0x80, 0xFC, 0x9F, 0x01, 0x61, 0xFF, 0x29, 0x00, 0xFD, 0xFF,
2791 0x19, 0x00, 0x9A, 0xFF, 0xD9, 0x00, 0xAA, 0xFE, 0xAE, 0x01, 0x70,
2792 0xFE, 0xF8, 0xFF, 0xA6, 0x48, 0xBE, 0x07, 0x14, 0xFB, 0x6D, 0x03,
2793 0xC3, 0xFD, 0x46, 0x01, 0x70, 0xFF, 0x24, 0x00, 0x00, 0x00, 0xFD,
2794 0xFF, 0x34, 0x00, 0x3F, 0xFF, 0xDD, 0x01, 0x34, 0xFC, 0x23, 0x07,
2795 0x21, 0xF2, 0xCB, 0x27, 0xFE, 0x37, 0x00, 0xF2, 0x4D, 0x06, 0x04,
2796 0xFD, 0x49, 0x01, 0x8E, 0xFF, 0x19, 0x00, 0xFF, 0xFF, 0x10, 0x00,
2797 0xBD, 0xFF, 0x82, 0x00, 0x5E, 0xFF, 0x5D, 0x00, 0xD4, 0x00, 0x0C,
2798 0xFB, 0xF9, 0x46, 0x87, 0x0E, 0x82, 0xF8, 0xAD, 0x04, 0x26, 0xFD,
2799 0x8D, 0x01, 0x54, 0xFF, 0x2C, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36,
2800 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x41, 0xFC, 0xC8, 0x06, 0x76, 0xF3,
2801 0x22, 0x20, 0xCA, 0x3D, 0x7D, 0xF3, 0x2A, 0x05, 0xC8, 0xFD, 0xD4,
2802 0x00, 0xCA, 0xFF, 0x03, 0x00, 0x02, 0x00, 0x09, 0x00, 0xDD, 0xFF,
2803 0x2E, 0x00, 0x0A, 0x00, 0x27, 0xFF, 0xEF, 0x02, 0x20, 0xF7, 0xE7,
2804 0x43, 0xD8, 0x15, 0x1E, 0xF6, 0xC0, 0x05, 0xA7, 0xFC, 0xC3, 0x01,
2805 0x40, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0xFE, 0xFF, 0x34, 0x00, 0x3B,
2806 0xFF, 0xD1, 0x01, 0x84, 0xFC, 0x12, 0x06, 0x5C, 0xF5, 0x76, 0x18,
2807 0x89, 0x42, 0x02, 0xF6, 0x94, 0x03, 0xC4, 0xFE, 0x42, 0x00, 0x12,
2808 0x00, 0xE8, 0xFF, 0x07, 0x00, 0x03, 0x00, 0xFA, 0xFF, 0xE2, 0xFF,
2809 0xA4, 0x00, 0x19, 0xFE, 0xAA, 0x04, 0x3E, 0xF4, 0x90, 0x3F, 0x78,
2810 0x1D, 0x10, 0xF4, 0x93, 0x06, 0x52, 0xFC, 0xE1, 0x01, 0x36, 0xFF,
2811 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x2F, 0x00, 0x4C, 0xFF, 0xA2,
2812 0x01, 0xF6, 0xFC, 0x12, 0x05, 0xA7, 0xF7, 0x03, 0x11, 0x10, 0x46,
2813 0x93, 0xF9, 0x98, 0x01, 0xEE, 0xFF, 0x9B, 0xFF, 0x64, 0x00, 0xC8,
2814 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA1, 0xFF, 0x24, 0x01,
2815 0x41, 0xFD, 0xF6, 0x05, 0x67, 0xF2, 0x1A, 0x3A, 0x29, 0x25, 0x84,
2816 0xF2, 0x0F, 0x07, 0x31, 0xFC, 0xE3, 0x01, 0x3A, 0xFF, 0x35, 0x00,
2817 0xFD, 0xFF, 0x00, 0x00, 0x27, 0x00, 0x65, 0xFF, 0x60, 0x01, 0x8A,
2818 0xFD, 0xDF, 0x03, 0x2E, 0xFA, 0x04, 0x0A, 0x3A, 0x48, 0x28, 0xFE,
2819 0x4B, 0xFF, 0x38, 0x01, 0xE9, 0xFE, 0xBB, 0x00, 0xA6, 0xFF, 0x16,
2820 0x00, 0xFD, 0xFF, 0x24, 0x00, 0x6F, 0xFF, 0x85, 0x01, 0xA6, 0xFC,
2821 0xCA, 0x06, 0x8F, 0xF1, 0xBB, 0x33, 0xAB, 0x2C, 0xA3, 0xF1, 0x26,
2822 0x07, 0x4C, 0xFC, 0xC5, 0x01, 0x4D, 0xFF, 0x30, 0x00, 0xFD, 0xFF,
2823 0x00, 0x00, 0x1E, 0x00, 0x84, 0xFF, 0x11, 0x01, 0x34, 0xFE, 0x8F,
2824 0x02, 0xC7, 0xFC, 0xAE, 0x03, 0xF7, 0x48, 0xAE, 0x03, 0xC7, 0xFC,
2825 0x8F, 0x02, 0x34, 0xFE, 0x11, 0x01, 0x84, 0xFF, 0x1E, 0x00, 0xFD,
2826 0xFF, 0x2A, 0x00, 0x5C, 0xFF, 0xAA, 0x01, 0x71, 0xFC, 0x07, 0x07,
2827 0x7E, 0xF1, 0x44, 0x30, 0x44, 0x30, 0x7E, 0xF1, 0x07, 0x07, 0x71,
2828 0xFC, 0xAA, 0x01, 0x5C, 0xFF, 0x2A, 0x00, 0xFD, 0xFF, 0x00, 0x00,
2829 0x1E, 0x00, 0x84, 0xFF, 0x11, 0x01, 0x34, 0xFE, 0x8F, 0x02, 0xC7,
2830 0xFC, 0xAE, 0x03, 0xF7, 0x48, 0xAE, 0x03, 0xC7, 0xFC, 0x8F, 0x02,
2831 0x34, 0xFE, 0x11, 0x01, 0x84, 0xFF, 0x1E, 0x00, 0x02, 0x00, 0x05,
2832 0x00, 0xC3, 0xFF, 0xE1, 0x00, 0xB1, 0xFD, 0x4E, 0x05, 0x4A, 0xF3,
2833 0x3D, 0x3D, 0xED, 0x20, 0x4C, 0xF3, 0xD6, 0x06, 0x3D, 0xFC, 0xE6,
2834 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x36, 0x00,
2835 0x36, 0xFF, 0xE6, 0x01, 0x3D, 0xFC, 0xD6, 0x06, 0x4C, 0xF3, 0xED,
2836 0x20, 0x3D, 0x3D, 0x4A, 0xF3, 0x4E, 0x05, 0xB1, 0xFD, 0xE1, 0x00,
2837 0xC3, 0xFF, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x84,
2838 0xFF, 0x11, 0x01, 0x34, 0xFE, 0x8F, 0x02, 0xC7, 0xFC, 0xAE, 0x03,
2839 0xF7, 0x48, 0xAE, 0x03, 0xC7, 0xFC, 0x8F, 0x02, 0x34, 0xFE, 0x11,
2840 0x01, 0x84, 0xFF, 0x1E, 0x00, 0x16, 0x00, 0xA6, 0xFF, 0xBB, 0x00,
2841 0xE9, 0xFE, 0x38, 0x01, 0x4B, 0xFF, 0x28, 0xFE, 0x3A, 0x48, 0x04,
2842 0x0A, 0x2E, 0xFA, 0xDF, 0x03, 0x8A, 0xFD, 0x60, 0x01, 0x65, 0xFF,
2843 0x27, 0x00, 0x00, 0x00, 0x0E, 0x00, 0xC8, 0xFF, 0x64, 0x00, 0x9B,
2844 0xFF, 0xEE, 0xFF, 0x98, 0x01, 0x93, 0xF9, 0x10, 0x46, 0x03, 0x11,
2845 0xA7, 0xF7, 0x12, 0x05, 0xF6, 0xFC, 0xA2, 0x01, 0x4C, 0xFF, 0x2F,
2846 0x00, 0xFF, 0xFF, 0x07, 0x00, 0xE8, 0xFF, 0x12, 0x00, 0x42, 0x00,
2847 0xC4, 0xFE, 0x94, 0x03, 0x02, 0xF6, 0x89, 0x42, 0x76, 0x18, 0x5C,
2848 0xF5, 0x12, 0x06, 0x84, 0xFC, 0xD1, 0x01, 0x3B, 0xFF, 0x34, 0x00,
2849 0xFE, 0xFF, 0x02, 0x00, 0x03, 0x00, 0xCA, 0xFF, 0xD4, 0x00, 0xC8,
2850 0xFD, 0x2A, 0x05, 0x7D, 0xF3, 0xCA, 0x3D, 0x22, 0x20, 0x76, 0xF3,
2851 0xC8, 0x06, 0x41, 0xFC, 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD,
2852 0xFF, 0xFF, 0xFF, 0x19, 0x00, 0x8E, 0xFF, 0x49, 0x01, 0x04, 0xFD,
2853 0x4D, 0x06, 0x00, 0xF2, 0xFE, 0x37, 0xCB, 0x27, 0x21, 0xF2, 0x23,
2854 0x07, 0x34, 0xFC, 0xDD, 0x01, 0x3F, 0xFF, 0x34, 0x00, 0xFD, 0xFF,
2855 0xFD, 0xFF, 0x29, 0x00, 0x61, 0xFF, 0x9F, 0x01, 0x80, 0xFC, 0xF7,
2856 0x06, 0x7D, 0xF1, 0x5A, 0x31, 0x2C, 0x2F, 0x83, 0xF1, 0x13, 0x07,
2857 0x64, 0xFC, 0xB3, 0x01, 0x57, 0xFF, 0x2C, 0x00, 0xFD, 0xFF, 0xFD,
2858 0xFF, 0x32, 0x00, 0x44, 0xFF, 0xD3, 0x01, 0x3C, 0xFC, 0x2A, 0x07,
2859 0xDC, 0xF1, 0x1A, 0x2A, 0x06, 0x36, 0xBE, 0xF1, 0x8E, 0x06, 0xD5,
2860 0xFC, 0x67, 0x01, 0x7F, 0xFF, 0x1E, 0x00, 0xFE, 0xFF, 0xFD, 0xFF,
2861 0x36, 0x00, 0x37, 0xFF, 0xE6, 0x01, 0x36, 0xFC, 0xEF, 0x06, 0xFC,
2862 0xF2, 0x81, 0x22, 0x1C, 0x3C, 0xEC, 0xF2, 0x90, 0x05, 0x85, 0xFD,
2863 0xFB, 0x00, 0xB6, 0xFF, 0x0A, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x35,
2864 0x00, 0x38, 0xFF, 0xDA, 0x01, 0x6A, 0xFC, 0x53, 0x06, 0xBA, 0xF4,
2865 0xCE, 0x1A, 0x32, 0x41, 0x1F, 0xF5, 0x1D, 0x04, 0x71, 0xFE, 0x71,
2866 0x00, 0xFB, 0xFF, 0xF0, 0xFF, 0x05, 0x00, 0xFF, 0xFF, 0x31, 0x00,
2867 0x46, 0xFF, 0xB3, 0x01, 0xCF, 0xFC, 0x67, 0x05, 0xEA, 0xF6, 0x44,
2868 0x13, 0x1E, 0x45, 0x5E, 0xF8, 0x3F, 0x02, 0x8E, 0xFF, 0xD0, 0xFF,
2869 0x4A, 0x00, 0xD2, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5D,
2870 0xFF, 0x76, 0x01, 0x59, 0xFD, 0x42, 0x04, 0x63, 0xF9, 0x1C, 0x0C,
2871 0xB6, 0x47, 0xA4, 0xFC, 0x07, 0x00, 0xD0, 0x00, 0x20, 0xFF, 0xA0,
2872 0x00, 0xB1, 0xFF, 0x13, 0x00, 0x00, 0x00, 0x21, 0x00, 0x7A, 0xFF,
2873 0x2B, 0x01, 0xFE, 0xFD, 0xF8, 0x02, 0xFB, 0xFB, 0x8D, 0x05, 0xE5,
2874 0x48, 0xE3, 0x01, 0x91, 0xFD, 0x25, 0x02, 0x6B, 0xFE, 0xF7, 0x00,
2875 0x8F, 0xFF, 0x1C, 0x00, 0x18, 0x00, 0x9C, 0xFF, 0xD6, 0x00, 0xB1,
2876 0xFE, 0xA1, 0x01, 0x89, 0xFE, 0xC3, 0xFF, 0x9C, 0x48, 0xFD, 0x07,
2877 0xFA, 0xFA, 0x7A, 0x03, 0xBC, 0xFD, 0x49, 0x01, 0x6E, 0xFF, 0x24,
2878 0x00, 0x00, 0x00, 0x10, 0x00, 0xBE, 0xFF, 0x7F, 0x00, 0x65, 0xFF,
2879 0x51, 0x00, 0xEB, 0x00, 0xE1, 0xFA, 0xE1, 0x46, 0xCD, 0x0E, 0x6A,
2880 0xF8, 0xB8, 0x04, 0x20, 0xFD, 0x90, 0x01, 0x53, 0xFF, 0x2D, 0x00,
2881 0xFF, 0xFF, 0x09, 0x00, 0xDE, 0xFF, 0x2B, 0x00, 0x11, 0x00, 0x1B,
2882 0xFF, 0x02, 0x03, 0xFE, 0xF6, 0xC3, 0x43, 0x22, 0x16, 0x07, 0xF6,
2883 0xCA, 0x05, 0xA3, 0xFC, 0xC5, 0x01, 0x3F, 0xFF, 0x33, 0x00, 0xFF,
2884 0xFF, 0x03, 0x00, 0xFB, 0xFF, 0xDF, 0xFF, 0xA9, 0x00, 0x10, 0xFE,
2885 0xB9, 0x04, 0x27, 0xF4, 0x5E, 0x3F, 0xC3, 0x1D, 0xFE, 0xF3, 0x99,
2886 0x06, 0x50, 0xFC, 0xE2, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF,
2887 0x00, 0x00, 0x13, 0x00, 0x9F, 0xFF, 0x28, 0x01, 0x3A, 0xFD, 0x00,
2888 0x06, 0x5A, 0xF2, 0xDF, 0x39, 0x73, 0x25, 0x79, 0xF2, 0x12, 0x07,
2889 0x31, 0xFC, 0xE3, 0x01, 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0xFD,
2890 0xFF, 0x24, 0x00, 0x6D, 0xFF, 0x88, 0x01, 0xA2, 0xFC, 0xD0, 0x06,
2891 0x8C, 0xF1, 0x78, 0x33, 0xF2, 0x2C, 0x9E, 0xF1, 0x24, 0x07, 0x4E,
2892 0xFC, 0xC3, 0x01, 0x4E, 0xFF, 0x2F, 0x00, 0xFD, 0xFF, 0xFD, 0xFF,
2893 0x30, 0x00, 0x4C, 0xFF, 0xC7, 0x01, 0x4A, 0xFC, 0x27, 0x07, 0xA8,
2894 0xF1, 0x62, 0x2C, 0xFD, 0x33, 0x93, 0xF1, 0xC4, 0x06, 0xAB, 0xFC,
2895 0x82, 0x01, 0x71, 0xFF, 0x23, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, 0x36,
2896 0x00, 0x3A, 0xFF, 0xE4, 0x01, 0x32, 0xFC, 0x0C, 0x07, 0x91, 0xF2,
2897 0xDD, 0x24, 0x54, 0x3A, 0x74, 0xF2, 0xEB, 0x05, 0x49, 0xFD, 0x20,
2898 0x01, 0xA3, 0xFF, 0x11, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x36, 0x00,
2899 0x37, 0xFF, 0xE1, 0x01, 0x55, 0xFC, 0x8C, 0x06, 0x22, 0xF4, 0x2C,
2900 0x1D, 0xC0, 0x3F, 0x55, 0xF4, 0x9B, 0x04, 0x23, 0xFE, 0x9F, 0x00,
2901 0xE4, 0xFF, 0xF9, 0xFF, 0x04, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x40,
2902 0xFF, 0xC1, 0x01, 0xAB, 0xFC, 0xB7, 0x05, 0x34, 0xF6, 0x8E, 0x15,
2903 0x0B, 0x44, 0x42, 0xF7, 0xDC, 0x02, 0x32, 0xFF, 0x04, 0x00, 0x31,
2904 0x00, 0xDC, 0xFF, 0x09, 0x00, 0xFF, 0xFF, 0x2C, 0x00, 0x55, 0xFF,
2905 0x8B, 0x01, 0x2B, 0xFD, 0xA1, 0x04, 0x9B, 0xF8, 0x42, 0x0E, 0x0F,
2906 0x47, 0x38, 0xFB, 0xBE, 0x00, 0x6A, 0x00, 0x58, 0xFF, 0x85, 0x00,
2907 0xBB, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x24, 0x00, 0x71, 0xFF, 0x43,
2908 0x01, 0xC9, 0xFD, 0x60, 0x03, 0x2E, 0xFB, 0x7E, 0x07, 0xAF, 0x48,
2909 0x2D, 0x00, 0x58, 0xFE, 0xBB, 0x01, 0xA3, 0xFE, 0xDD, 0x00, 0x99,
2910 0xFF, 0x19, 0x00, 0x1B, 0x00, 0x91, 0xFF, 0xF1, 0x00, 0x79, 0xFE,
2911 0x0A, 0x02, 0xC3, 0xFD, 0x73, 0x01, 0xDB, 0x48, 0x07, 0x06, 0xC7,
2912 0xFB, 0x12, 0x03, 0xF1, 0xFD, 0x31, 0x01, 0x78, 0xFF, 0x22, 0x00,
2913 0x00, 0x00, 0x12, 0x00, 0xB3, 0xFF, 0x99, 0x00, 0x2E, 0xFF, 0xB6,
2914 0x00, 0x36, 0x00, 0x47, 0xFC, 0x90, 0x47, 0xA4, 0x0C, 0x31, 0xF9,
2915 0x5A, 0x04, 0x4E, 0xFD, 0x7C, 0x01, 0x5B, 0xFF, 0x2A, 0x00, 0x00,
2916 0x00, 0x0B, 0x00, 0xD5, 0xFF, 0x44, 0x00, 0xDD, 0xFF, 0x77, 0xFF,
2917 0x67, 0x02, 0x14, 0xF8, 0xDC, 0x44, 0xD5, 0x13, 0xBC, 0xF6, 0x7C,
2918 0x05, 0xC5, 0xFC, 0xB7, 0x01, 0x44, 0xFF, 0x31, 0x00, 0xFF, 0xFF,
2919 0x05, 0x00, 0xF3, 0xFF, 0xF5, 0xFF, 0x7D, 0x00, 0x5D, 0xFE, 0x3E,
2920 0x04, 0xEA, 0xF4, 0xD9, 0x40, 0x66, 0x1B, 0x93, 0xF4, 0x62, 0x06,
2921 0x64, 0xFC, 0xDC, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x00,
2922 0x00, 0x0C, 0x00, 0xB1, 0xFF, 0x04, 0x01, 0x76, 0xFD, 0xA8, 0x05,
2923 0xCC, 0xF2, 0xAB, 0x3B, 0x18, 0x23, 0xE0, 0xF2, 0xF7, 0x06, 0x35,
2924 0xFC, 0xE6, 0x01, 0x38, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFE, 0xFF,
2925 0x20, 0x00, 0x7B, 0xFF, 0x6E, 0x01, 0xCA, 0xFC, 0x9D, 0x06, 0xB1,
2926 0xF1, 0x86, 0x35, 0xAE, 0x2A, 0xCD, 0xF1, 0x2B, 0x07, 0x3F, 0xFC,
2927 0xD1, 0x01, 0x46, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x2D,
2928 0x00, 0x54, 0xFF, 0xB7, 0x01, 0x5E, 0xFC, 0x19, 0x07, 0x88, 0xF1,
2929 0x9F, 0x2E, 0xE3, 0x31, 0x7E, 0xF1, 0xEE, 0x06, 0x88, 0xFC, 0x9A,
2930 0x01, 0x64, 0xFF, 0x28, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x34, 0x00,
2931 0x3E, 0xFF, 0xDF, 0x01, 0x33, 0xFC, 0x20, 0x07, 0x35, 0xF2, 0x36,
2932 0x27, 0x78, 0x38, 0x14, 0xF2, 0x3B, 0x06, 0x11, 0xFD, 0x41, 0x01,
2933 0x92, 0xFF, 0x17, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36,
2934 0xFF, 0xE5, 0x01, 0x44, 0xFC, 0xBD, 0x06, 0x97, 0xF3, 0x8A, 0x1F,
2935 0x31, 0x3E, 0xA5, 0xF3, 0x0F, 0x05, 0xDA, 0xFD, 0xC9, 0x00, 0xCF,
2936 0xFF, 0x01, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3C, 0xFF,
2937 0xCE, 0x01, 0x8C, 0xFC, 0x00, 0x06, 0x86, 0xF5, 0xE0, 0x17, 0xDB,
2938 0x42, 0x3F, 0xF6, 0x71, 0x03, 0xD9, 0xFE, 0x36, 0x00, 0x18, 0x00,
2939 0xE5, 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0x2E, 0x00, 0x4E, 0xFF, 0x9E,
2940 0x01, 0x00, 0xFD, 0xFC, 0x04, 0xD7, 0xF7, 0x75, 0x10, 0x48, 0x46,
2941 0xE4, 0xF9, 0x6E, 0x01, 0x06, 0x00, 0x8E, 0xFF, 0x6B, 0x00, 0xC6,
2942 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x26, 0x00, 0x68, 0xFF, 0x5B, 0x01,
2943 0x96, 0xFD, 0xC6, 0x03, 0x61, 0xFA, 0x81, 0x09, 0x57, 0x48, 0x8D,
2944 0xFE, 0x1B, 0xFF, 0x52, 0x01, 0xDB, 0xFE, 0xC2, 0x00, 0xA4, 0xFF,
2945 0x16, 0x00, 0x1E, 0x00, 0x87, 0xFF, 0x0B, 0x01, 0x42, 0xFE, 0x74,
2946 0x02, 0xF9, 0xFC, 0x39, 0x03, 0xF5, 0x48, 0x24, 0x04, 0x94, 0xFC,
2947 0xA9, 0x02, 0x27, 0xFE, 0x18, 0x01, 0x82, 0xFF, 0x1F, 0x00, 0x00,
2948 0x00, 0x15, 0x00, 0xA9, 0xFF, 0xB4, 0x00, 0xF7, 0xFE, 0x1D, 0x01,
2949 0x7A, 0xFF, 0xC5, 0xFD, 0x1D, 0x48, 0x89, 0x0A, 0xFB, 0xF9, 0xF8,
2950 0x03, 0x7D, 0xFD, 0x66, 0x01, 0x63, 0xFF, 0x28, 0x00, 0x00, 0x00,
2951 0x0D, 0x00, 0xCB, 0xFF, 0x5E, 0x00, 0xA9, 0xFF, 0xD6, 0xFF, 0xC3,
2952 0x01, 0x43, 0xF9, 0xD7, 0x45, 0x92, 0x11, 0x77, 0xF7, 0x28, 0x05,
2953 0xEC, 0xFC, 0xA7, 0x01, 0x4A, 0xFF, 0x2F, 0x00, 0xFF, 0xFF, 0x06,
2954 0x00, 0xEA, 0xFF, 0x0C, 0x00, 0x4E, 0x00, 0xAF, 0xFE, 0xB8, 0x03,
2955 0xC7, 0xF5, 0x38, 0x42, 0x0C, 0x19, 0x32, 0xF5, 0x23, 0x06, 0x7D,
2956 0xFC, 0xD3, 0x01, 0x3A, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x02, 0x00,
2957 0x05, 0x00, 0xC5, 0xFF, 0xDE, 0x00, 0xB7, 0xFD, 0x45, 0x05, 0x56,
2958 0xF3, 0x61, 0x3D, 0xBA, 0x20, 0x56, 0xF3, 0xD3, 0x06, 0x3E, 0xFC,
2959 0xE6, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x1A,
2960 0x00, 0x8A, 0xFF, 0x51, 0x01, 0xF8, 0xFC, 0x5E, 0x06, 0xED, 0xF1,
2961 0x82, 0x37, 0x60, 0x28, 0x0E, 0xF2, 0x26, 0x07, 0x35, 0xFC, 0xDB,
2962 0x01, 0x40, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x29, 0x00,
2963 0x5F, 0xFF, 0xA5, 0x01, 0x78, 0xFC, 0xFF, 0x06, 0x7D, 0xF1, 0xCF,
2964 0x30, 0xB8, 0x2F, 0x80, 0xF1, 0x0D, 0x07, 0x6A, 0xFC, 0xAE, 0x01,
2965 0x59, 0xFF, 0x2B, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x33, 0x00, 0x43,
2966 0xFF, 0xD6, 0x01, 0x39, 0xFC, 0x2A, 0x07, 0xEB, 0xF1, 0x87, 0x29,
2967 0x85, 0x36, 0xCC, 0xF1, 0x7F, 0x06, 0xE0, 0xFC, 0x60, 0x01, 0x82,
2968 0xFF, 0x1D, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x37, 0xFF,
2969 0xE6, 0x01, 0x38, 0xFC, 0xE6, 0x06, 0x19, 0xF3, 0xEA, 0x21, 0x8A,
2970 0x3C, 0x0E, 0xF3, 0x78, 0x05, 0x96, 0xFD, 0xF1, 0x00, 0xBB, 0xFF,
2971 0x08, 0x00, 0x01, 0x00, 0xFE, 0xFF, 0x35, 0x00, 0x39, 0xFF, 0xD8,
2972 0x01, 0x70, 0xFC, 0x43, 0x06, 0xE1, 0xF4, 0x38, 0x1A, 0x8C, 0x41,
2973 0x55, 0xF5, 0xFC, 0x03, 0x85, 0xFE, 0x66, 0x00, 0x01, 0x00, 0xEE,
2974 0xFF, 0x06, 0x00, 0xFF, 0xFF, 0x30, 0x00, 0x47, 0xFF, 0xAF, 0x01,
2975 0xD8, 0xFC, 0x52, 0x05, 0x19, 0xF7, 0xB2, 0x12, 0x5C, 0x45, 0xA9,
2976 0xF8, 0x16, 0x02, 0xA6, 0xFF, 0xC3, 0xFF, 0x51, 0x00, 0xD0, 0xFF,
2977 0x0C, 0x00, 0x00, 0x00, 0x29, 0x00, 0x5F, 0xFF, 0x71, 0x01, 0x65,
2978 0xFD, 0x29, 0x04, 0x96, 0xF9, 0x95, 0x0B, 0xDC, 0x47, 0x03, 0xFD,
2979 0xD9, 0xFF, 0xEA, 0x00, 0x12, 0xFF, 0xA7, 0x00, 0xAE, 0xFF, 0x14,
2980 0x00, 0x00, 0x00, 0x20, 0x00, 0x7D, 0xFF, 0x24, 0x01, 0x0C, 0xFE,
2981 0xDE, 0x02, 0x2E, 0xFC, 0x13, 0x05, 0xEC, 0x48, 0x54, 0x02, 0x5E,
2982 0xFD, 0x3F, 0x02, 0x5D, 0xFE, 0xFE, 0x00, 0x8C, 0xFF, 0x1C, 0x00,
2983 0x17, 0x00, 0x9E, 0xFF, 0xCF, 0x00, 0xBF, 0xFE, 0x86, 0x01, 0xBA,
2984 0xFE, 0x5A, 0xFF, 0x86, 0x48, 0x7D, 0x08, 0xC7, 0xFA, 0x93, 0x03,
2985 0xB0, 0xFD, 0x4F, 0x01, 0x6C, 0xFF, 0x25, 0x00, 0x00, 0x00, 0x0F,
2986 0x00, 0xC0, 0xFF, 0x78, 0x00, 0x73, 0xFF, 0x38, 0x00, 0x17, 0x01,
2987 0x8B, 0xFA, 0xAF, 0x46, 0x59, 0x0F, 0x39, 0xF8, 0xCF, 0x04, 0x15,
2988 0xFD, 0x95, 0x01, 0x51, 0xFF, 0x2D, 0x00, 0xFF, 0xFF, 0x08, 0x00,
2989 0xE1, 0xFF, 0x25, 0x00, 0x1D, 0x00, 0x05, 0xFF, 0x28, 0x03, 0xBD,
2990 0xF6, 0x77, 0x43, 0xB6, 0x16, 0xDC, 0xF5, 0xDD, 0x05, 0x9B, 0xFC,
2991 0xC8, 0x01, 0x3E, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x03, 0x00, 0xFD,
2992 0xFF, 0xD9, 0xFF, 0xB4, 0x00, 0xFD, 0xFD, 0xD7, 0x04, 0xFA, 0xF3,
2993 0xFC, 0x3E, 0x5B, 0x1E, 0xDB, 0xF3, 0xA6, 0x06, 0x4C, 0xFC, 0xE3,
2994 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x14, 0x00,
2995 0x9B, 0xFF, 0x31, 0x01, 0x2C, 0xFD, 0x15, 0x06, 0x41, 0xF2, 0x6A,
2996 0x39, 0x0A, 0x26, 0x61, 0xF2, 0x17, 0x07, 0x31, 0xFC, 0xE2, 0x01,
2997 0x3B, 0xFF, 0x35, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x25, 0x00, 0x6A,
2998 0xFF, 0x8E, 0x01, 0x99, 0xFC, 0xDB, 0x06, 0x86, 0xF1, 0xF2, 0x32,
2999 0x82, 0x2D, 0x96, 0xF1, 0x21, 0x07, 0x53, 0xFC, 0xC0, 0x01, 0x50,
3000 0xFF, 0x2E, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x30, 0x00, 0x4A, 0xFF,
3001 0xCA, 0x01, 0x46, 0xFC, 0x29, 0x07, 0xB3, 0xF1, 0xD1, 0x2B, 0x81,
3002 0x34, 0x9C, 0xF1, 0xB8, 0x06, 0xB5, 0xFC, 0x7C, 0x01, 0x74, 0xFF,
3003 0x22, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x39, 0xFF, 0xE5,
3004 0x01, 0x32, 0xFC, 0x06, 0x07, 0xAA, 0xF2, 0x46, 0x24, 0xC8, 0x3A,
3005 0x90, 0xF2, 0xD6, 0x05, 0x57, 0xFD, 0x17, 0x01, 0xA8, 0xFF, 0x0F,
3006 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xDF, 0x01,
3007 0x5A, 0xFC, 0x7E, 0x06, 0x47, 0xF4, 0x94, 0x1C, 0x1F, 0x40, 0x85,
3008 0xF4, 0x7D, 0x04, 0x36, 0xFE, 0x93, 0x00, 0xEA, 0xFF, 0xF7, 0xFF,
3009 0x04, 0x00, 0xFF, 0xFF, 0x32, 0x00, 0x42, 0xFF, 0xBE, 0x01, 0xB4,
3010 0xFC, 0xA4, 0x05, 0x61, 0xF6, 0xFB, 0x14, 0x53, 0x44, 0x86, 0xF7,
3011 0xB6, 0x02, 0x49, 0xFF, 0xF7, 0xFF, 0x37, 0x00, 0xD9, 0xFF, 0x0A,
3012 0x00, 0x00, 0x00, 0x2B, 0x00, 0x57, 0xFF, 0x86, 0x01, 0x36, 0xFD,
3013 0x89, 0x04, 0xCD, 0xF8, 0xB7, 0x0D, 0x3D, 0x47, 0x91, 0xFB, 0x91,
3014 0x00, 0x83, 0x00, 0x4A, 0xFF, 0x8C, 0x00, 0xB9, 0xFF, 0x11, 0x00,
3015 0x00, 0x00, 0x23, 0x00, 0x73, 0xFF, 0x3D, 0x01, 0xD6, 0xFD, 0x46,
3016 0x03, 0x61, 0xFB, 0x00, 0x07, 0xBF, 0x48, 0x98, 0x00, 0x26, 0xFE,
3017 0xD5, 0x01, 0x95, 0xFE, 0xE3, 0x00, 0x96, 0xFF, 0x1A, 0x00, 0x1A,
3018 0x00, 0x94, 0xFF, 0xEA, 0x00, 0x87, 0xFE, 0xF0, 0x01, 0xF5, 0xFD,
3019 0x05, 0x01, 0xCE, 0x48, 0x83, 0x06, 0x94, 0xFB, 0x2C, 0x03, 0xE4,
3020 0xFD, 0x37, 0x01, 0x76, 0xFF, 0x22, 0x00, 0x00, 0x00, 0x12, 0x00,
3021 0xB6, 0xFF, 0x93, 0x00, 0x3C, 0xFF, 0x9D, 0x00, 0x63, 0x00, 0xEB,
3022 0xFB, 0x69, 0x47, 0x2D, 0x0D, 0xFF, 0xF8, 0x72, 0x04, 0x42, 0xFD,
3023 0x81, 0x01, 0x59, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0xD7,
3024 0xFF, 0x3E, 0x00, 0xEA, 0xFF, 0x60, 0xFF, 0x8F, 0x02, 0xCD, 0xF7,
3025 0x99, 0x44, 0x68, 0x14, 0x8E, 0xF6, 0x90, 0x05, 0xBC, 0xFC, 0xBA,
3026 0x01, 0x43, 0xFF, 0x32, 0x00, 0xFF, 0xFF, 0x04, 0x00, 0xF5, 0xFF,
3027 0xEF, 0xFF, 0x88, 0x00, 0x49, 0xFE, 0x5D, 0x04, 0xB7, 0xF4, 0x7D,
3028 0x40, 0xFD, 0x1B, 0x6C, 0xF4, 0x70, 0x06, 0x5F, 0xFC, 0xDE, 0x01,
3029 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x0E, 0x00, 0xAC,
3030 0xFF, 0x0E, 0x01, 0x66, 0xFD, 0xBF, 0x05, 0xAD, 0xF2, 0x3B, 0x3B,
3031 0xB0, 0x23, 0xC4, 0xF2, 0xFF, 0x06, 0x33, 0xFC, 0xE5, 0x01, 0x38,
3032 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFE, 0xFF, 0x21, 0x00, 0x77, 0xFF,
3033 0x75, 0x01, 0xBF, 0xFC, 0xAB, 0x06, 0xA6, 0xF1, 0x05, 0x35, 0x40,
3034 0x2B, 0xBF, 0xF1, 0x2A, 0x07, 0x42, 0xFC, 0xCE, 0x01, 0x48, 0xFF,
3035 0x31, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x2E, 0x00, 0x52, 0xFF, 0xBC,
3036 0x01, 0x58, 0xFC, 0x1D, 0x07, 0x8E, 0xF1, 0x11, 0x2E, 0x6B, 0x32,
3037 0x81, 0xF1, 0xE5, 0x06, 0x90, 0xFC, 0x94, 0x01, 0x67, 0xFF, 0x26,
3038 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x35, 0x00, 0x3C, 0xFF, 0xE0, 0x01,
3039 0x32, 0xFC, 0x1C, 0x07, 0x4B, 0xF2, 0xA0, 0x26, 0xF2, 0x38, 0x2A,
3040 0xF2, 0x28, 0x06, 0x1F, 0xFD, 0x39, 0x01, 0x96, 0xFF, 0x16, 0x00,
3041 0xFF, 0xFF, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE4, 0x01, 0x48,
3042 0xFC, 0xB2, 0x06, 0xB9, 0xF3, 0xF3, 0x1E, 0x98, 0x3E, 0xCF, 0xF3,
3043 0xF3, 0x04, 0xEB, 0xFD, 0xBF, 0x00, 0xD4, 0xFF, 0xFF, 0xFF, 0x03,
3044 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3D, 0xFF, 0xCB, 0x01, 0x93, 0xFC,
3045 0xEF, 0x05, 0xB0, 0xF5, 0x4B, 0x17, 0x2A, 0x43, 0x7D, 0xF6, 0x4D,
3046 0x03, 0xEF, 0xFE, 0x2A, 0x00, 0x1E, 0x00, 0xE3, 0xFF, 0x08, 0x00,
3047 0xFF, 0xFF, 0x2E, 0x00, 0x4F, 0xFF, 0x99, 0x01, 0x0B, 0xFD, 0xE6,
3048 0x04, 0x08, 0xF8, 0xE7, 0x0F, 0x7C, 0x46, 0x37, 0xFA, 0x42, 0x01,
3049 0x1F, 0x00, 0x81, 0xFF, 0x71, 0x00, 0xC3, 0xFF, 0x0F, 0x00, 0x00,
3050 0x00, 0x26, 0x00, 0x6A, 0xFF, 0x55, 0x01, 0xA3, 0xFD, 0xAD, 0x03,
3051 0x94, 0xFA, 0xFF, 0x08, 0x70, 0x48, 0xF3, 0xFE, 0xEA, 0xFE, 0x6C,
3052 0x01, 0xCD, 0xFE, 0xC9, 0x00, 0xA1, 0xFF, 0x17, 0x00, 0x1D, 0x00,
3053 0x8A, 0xFF, 0x04, 0x01, 0x50, 0xFE, 0x5A, 0x02, 0x2C, 0xFD, 0xC6,
3054 0x02, 0xF2, 0x48, 0x9B, 0x04, 0x61, 0xFC, 0xC3, 0x02, 0x19, 0xFE,
3055 0x1E, 0x01, 0x7F, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0xAC,
3056 0xFF, 0xAE, 0x00, 0x05, 0xFF, 0x03, 0x01, 0xAA, 0xFF, 0x63, 0xFD,
3057 0xFD, 0x47, 0x0E, 0x0B, 0xC8, 0xF9, 0x11, 0x04, 0x71, 0xFD, 0x6C,
3058 0x01, 0x61, 0xFF, 0x28, 0x00, 0x00, 0x00, 0x0C, 0x00, 0xCD, 0xFF,
3059 0x57, 0x00, 0xB6, 0xFF, 0xBE, 0xFF, 0xED, 0x01, 0xF5, 0xF8, 0x9B,
3060 0x45, 0x22, 0x12, 0x48, 0xF7, 0x3D, 0x05, 0xE2, 0xFC, 0xAB, 0x01,
3061 0x49, 0xFF, 0x30, 0x00, 0xFF, 0xFF, 0x06, 0x00, 0xEC, 0xFF, 0x06,
3062 0x00, 0x5A, 0x00, 0x9A, 0xFE, 0xDA, 0x03, 0x8D, 0xF5, 0xE1, 0x41,
3063 0xA1, 0x19, 0x09, 0xF5, 0x33, 0x06, 0x77, 0xFC, 0xD6, 0x01, 0x3A,
3064 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF,
3065 0xE8, 0x00, 0xA6, 0xFD, 0x5F, 0x05, 0x31, 0xF3, 0xF6, 0x3C, 0x52,
3066 0x21, 0x37, 0xF3, 0xDD, 0x06, 0x3B, 0xFC, 0xE6, 0x01, 0x36, 0xFF,
3067 0x36, 0x00, 0xFD, 0xFF, 0xFE, 0xFF, 0x1C, 0x00, 0x86, 0xFF, 0x59,
3068 0x01, 0xEC, 0xFC, 0x6F, 0x06, 0xDC, 0xF1, 0x04, 0x37, 0xF3, 0x28,
3069 0xFC, 0xF1, 0x28, 0x07, 0x37, 0xFC, 0xD8, 0x01, 0x41, 0xFF, 0x33,
3070 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x2A, 0x00, 0x5C, 0xFF, 0xAA, 0x01,
3071 0x71, 0xFC, 0x07, 0x07, 0x7E, 0xF1, 0x44, 0x30, 0x44, 0x30, 0x7E,
3072 0xF1, 0x07, 0x07, 0x71, 0xFC, 0xAA, 0x01, 0x5C, 0xFF, 0x2A, 0x00,
3073 0xFD, 0xFF, 0xFD, 0xFF, 0x33, 0x00, 0x41, 0xFF, 0xD8, 0x01, 0x37,
3074 0xFC, 0x28, 0x07, 0xFC, 0xF1, 0xF3, 0x28, 0x04, 0x37, 0xDC, 0xF1,
3075 0x6F, 0x06, 0xEC, 0xFC, 0x59, 0x01, 0x86, 0xFF, 0x1C, 0x00, 0xFE,
3076 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3B, 0xFC,
3077 0xDD, 0x06, 0x37, 0xF3, 0x52, 0x21, 0xF6, 0x3C, 0x31, 0xF3, 0x5F,
3078 0x05, 0xA6, 0xFD, 0xE8, 0x00, 0xC0, 0xFF, 0x07, 0x00, 0x01, 0x00,
3079 0xFE, 0xFF, 0x35, 0x00, 0x3A, 0xFF, 0xD6, 0x01, 0x77, 0xFC, 0x33,
3080 0x06, 0x09, 0xF5, 0xA1, 0x19, 0xE1, 0x41, 0x8D, 0xF5, 0xDA, 0x03,
3081 0x9A, 0xFE, 0x5A, 0x00, 0x06, 0x00, 0xEC, 0xFF, 0x06, 0x00, 0xFF,
3082 0xFF, 0x30, 0x00, 0x49, 0xFF, 0xAB, 0x01, 0xE2, 0xFC, 0x3D, 0x05,
3083 0x48, 0xF7, 0x22, 0x12, 0x9B, 0x45, 0xF5, 0xF8, 0xED, 0x01, 0xBE,
3084 0xFF, 0xB6, 0xFF, 0x57, 0x00, 0xCD, 0xFF, 0x0C, 0x00, 0x00, 0x00,
3085 0x28, 0x00, 0x61, 0xFF, 0x6C, 0x01, 0x71, 0xFD, 0x11, 0x04, 0xC8,
3086 0xF9, 0x0E, 0x0B, 0xFD, 0x47, 0x63, 0xFD, 0xAA, 0xFF, 0x03, 0x01,
3087 0x05, 0xFF, 0xAE, 0x00, 0xAC, 0xFF, 0x14, 0x00, 0x00, 0x00, 0x20,
3088 0x00, 0x7F, 0xFF, 0x1E, 0x01, 0x19, 0xFE, 0xC3, 0x02, 0x61, 0xFC,
3089 0x9B, 0x04, 0xF2, 0x48, 0xC6, 0x02, 0x2C, 0xFD, 0x5A, 0x02, 0x50,
3090 0xFE, 0x04, 0x01, 0x8A, 0xFF, 0x1D, 0x00, 0x17, 0x00, 0xA1, 0xFF,
3091 0xC9, 0x00, 0xCD, 0xFE, 0x6C, 0x01, 0xEA, 0xFE, 0xF3, 0xFE, 0x70,
3092 0x48, 0xFF, 0x08, 0x94, 0xFA, 0xAD, 0x03, 0xA3, 0xFD, 0x55, 0x01,
3093 0x6A, 0xFF, 0x26, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xC3, 0xFF, 0x71,
3094 0x00, 0x81, 0xFF, 0x1F, 0x00, 0x42, 0x01, 0x37, 0xFA, 0x7C, 0x46,
3095 0xE7, 0x0F, 0x08, 0xF8, 0xE6, 0x04, 0x0B, 0xFD, 0x99, 0x01, 0x4F,
3096 0xFF, 0x2E, 0x00, 0xFF, 0xFF, 0x08, 0x00, 0xE3, 0xFF, 0x1E, 0x00,
3097 0x2A, 0x00, 0xEF, 0xFE, 0x4D, 0x03, 0x7D, 0xF6, 0x2A, 0x43, 0x4B,
3098 0x17, 0xB0, 0xF5, 0xEF, 0x05, 0x93, 0xFC, 0xCB, 0x01, 0x3D, 0xFF,
3099 0x34, 0x00, 0xFE, 0xFF, 0x03, 0x00, 0xFF, 0xFF, 0xD4, 0xFF, 0xBF,
3100 0x00, 0xEB, 0xFD, 0xF3, 0x04, 0xCF, 0xF3, 0x98, 0x3E, 0xF3, 0x1E,
3101 0xB9, 0xF3, 0xB2, 0x06, 0x48, 0xFC, 0xE4, 0x01, 0x36, 0xFF, 0x36,
3102 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x16, 0x00, 0x96, 0xFF, 0x39, 0x01,
3103 0x1F, 0xFD, 0x28, 0x06, 0x2A, 0xF2, 0xF2, 0x38, 0xA0, 0x26, 0x4B,
3104 0xF2, 0x1C, 0x07, 0x32, 0xFC, 0xE0, 0x01, 0x3C, 0xFF, 0x35, 0x00,
3105 0xFD, 0xFF, 0xFD, 0xFF, 0x26, 0x00, 0x67, 0xFF, 0x94, 0x01, 0x90,
3106 0xFC, 0xE5, 0x06, 0x81, 0xF1, 0x6B, 0x32, 0x11, 0x2E, 0x8E, 0xF1,
3107 0x1D, 0x07, 0x58, 0xFC, 0xBC, 0x01, 0x52, 0xFF, 0x2E, 0x00, 0xFD,
3108 0xFF, 0xFD, 0xFF, 0x31, 0x00, 0x48, 0xFF, 0xCE, 0x01, 0x42, 0xFC,
3109 0x2A, 0x07, 0xBF, 0xF1, 0x40, 0x2B, 0x05, 0x35, 0xA6, 0xF1, 0xAB,
3110 0x06, 0xBF, 0xFC, 0x75, 0x01, 0x77, 0xFF, 0x21, 0x00, 0xFE, 0xFF,
3111 0xFD, 0xFF, 0x36, 0x00, 0x38, 0xFF, 0xE5, 0x01, 0x33, 0xFC, 0xFF,
3112 0x06, 0xC4, 0xF2, 0xB0, 0x23, 0x3B, 0x3B, 0xAD, 0xF2, 0xBF, 0x05,
3113 0x66, 0xFD, 0x0E, 0x01, 0xAC, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0xFE,
3114 0xFF, 0x36, 0x00, 0x37, 0xFF, 0xDE, 0x01, 0x5F, 0xFC, 0x70, 0x06,
3115 0x6C, 0xF4, 0xFD, 0x1B, 0x7D, 0x40, 0xB7, 0xF4, 0x5D, 0x04, 0x49,
3116 0xFE, 0x88, 0x00, 0xEF, 0xFF, 0xF5, 0xFF, 0x04, 0x00, 0xFF, 0xFF,
3117 0x32, 0x00, 0x43, 0xFF, 0xBA, 0x01, 0xBC, 0xFC, 0x90, 0x05, 0x8E,
3118 0xF6, 0x68, 0x14, 0x99, 0x44, 0xCD, 0xF7, 0x8F, 0x02, 0x60, 0xFF,
3119 0xEA, 0xFF, 0x3E, 0x00, 0xD7, 0xFF, 0x0A, 0x00, 0x00, 0x00, 0x2B,
3120 0x00, 0x59, 0xFF, 0x81, 0x01, 0x42, 0xFD, 0x72, 0x04, 0xFF, 0xF8,
3121 0x2D, 0x0D, 0x69, 0x47, 0xEB, 0xFB, 0x63, 0x00, 0x9D, 0x00, 0x3C,
3122 0xFF, 0x93, 0x00, 0xB6, 0xFF, 0x12, 0x00, 0x00, 0x00, 0x22, 0x00,
3123 0x76, 0xFF, 0x37, 0x01, 0xE4, 0xFD, 0x2C, 0x03, 0x94, 0xFB, 0x83,
3124 0x06, 0xCE, 0x48, 0x05, 0x01, 0xF5, 0xFD, 0xF0, 0x01, 0x87, 0xFE,
3125 0xEA, 0x00, 0x94, 0xFF, 0x1A, 0x00, 0x1A, 0x00, 0x96, 0xFF, 0xE3,
3126 0x00, 0x95, 0xFE, 0xD5, 0x01, 0x26, 0xFE, 0x98, 0x00, 0xBF, 0x48,
3127 0x00, 0x07, 0x61, 0xFB, 0x46, 0x03, 0xD6, 0xFD, 0x3D, 0x01, 0x73,
3128 0xFF, 0x23, 0x00, 0x00, 0x00, 0x11, 0x00, 0xB9, 0xFF, 0x8C, 0x00,
3129 0x4A, 0xFF, 0x83, 0x00, 0x91, 0x00, 0x91, 0xFB, 0x3D, 0x47, 0xB7,
3130 0x0D, 0xCD, 0xF8, 0x89, 0x04, 0x36, 0xFD, 0x86, 0x01, 0x57, 0xFF,
3131 0x2B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0xD9, 0xFF, 0x37, 0x00, 0xF7,
3132 0xFF, 0x49, 0xFF, 0xB6, 0x02, 0x86, 0xF7, 0x53, 0x44, 0xFB, 0x14,
3133 0x61, 0xF6, 0xA4, 0x05, 0xB4, 0xFC, 0xBE, 0x01, 0x42, 0xFF, 0x32,
3134 0x00, 0xFF, 0xFF, 0x04, 0x00, 0xF7, 0xFF, 0xEA, 0xFF, 0x93, 0x00,
3135 0x36, 0xFE, 0x7D, 0x04, 0x85, 0xF4, 0x1F, 0x40, 0x94, 0x1C, 0x47,
3136 0xF4, 0x7E, 0x06, 0x5A, 0xFC, 0xDF, 0x01, 0x37, 0xFF, 0x36, 0x00,
3137 0xFE, 0xFF, 0x00, 0x00, 0x0F, 0x00, 0xA8, 0xFF, 0x17, 0x01, 0x57,
3138 0xFD, 0xD6, 0x05, 0x90, 0xF2, 0xC8, 0x3A, 0x46, 0x24, 0xAA, 0xF2,
3139 0x06, 0x07, 0x32, 0xFC, 0xE5, 0x01, 0x39, 0xFF, 0x36, 0x00, 0xFD,
3140 0xFF, 0xFE, 0xFF, 0x22, 0x00, 0x74, 0xFF, 0x7C, 0x01, 0xB5, 0xFC,
3141 0xB8, 0x06, 0x9C, 0xF1, 0x81, 0x34, 0xD1, 0x2B, 0xB3, 0xF1, 0x29,
3142 0x07, 0x46, 0xFC, 0xCA, 0x01, 0x4A, 0xFF, 0x30, 0x00, 0xFD, 0xFF,
3143 0xFD, 0xFF, 0x2E, 0x00, 0x50, 0xFF, 0xC0, 0x01, 0x53, 0xFC, 0x21,
3144 0x07, 0x96, 0xF1, 0x82, 0x2D, 0xF2, 0x32, 0x86, 0xF1, 0xDB, 0x06,
3145 0x99, 0xFC, 0x8E, 0x01, 0x6A, 0xFF, 0x25, 0x00, 0xFD, 0xFF, 0xFD,
3146 0xFF, 0x35, 0x00, 0x3B, 0xFF, 0xE2, 0x01, 0x31, 0xFC, 0x17, 0x07,
3147 0x61, 0xF2, 0x0A, 0x26, 0x6A, 0x39, 0x41, 0xF2, 0x15, 0x06, 0x2C,
3148 0xFD, 0x31, 0x01, 0x9B, 0xFF, 0x14, 0x00, 0xFF, 0xFF, 0xFE, 0xFF,
3149 0x36, 0x00, 0x36, 0xFF, 0xE3, 0x01, 0x4C, 0xFC, 0xA6, 0x06, 0xDB,
3150 0xF3, 0x5B, 0x1E, 0xFC, 0x3E, 0xFA, 0xF3, 0xD7, 0x04, 0xFD, 0xFD,
3151 0xB4, 0x00, 0xD9, 0xFF, 0xFD, 0xFF, 0x03, 0x00, 0xFF, 0xFF, 0x33,
3152 0x00, 0x3E, 0xFF, 0xC8, 0x01, 0x9B, 0xFC, 0xDD, 0x05, 0xDC, 0xF5,
3153 0xB6, 0x16, 0x77, 0x43, 0xBD, 0xF6, 0x28, 0x03, 0x05, 0xFF, 0x1D,
3154 0x00, 0x25, 0x00, 0xE1, 0xFF, 0x08, 0x00, 0xFF, 0xFF, 0x2D, 0x00,
3155 0x51, 0xFF, 0x95, 0x01, 0x15, 0xFD, 0xCF, 0x04, 0x39, 0xF8, 0x59,
3156 0x0F, 0xAF, 0x46, 0x8B, 0xFA, 0x17, 0x01, 0x38, 0x00, 0x73, 0xFF,
3157 0x78, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x25, 0x00, 0x6C,
3158 0xFF, 0x4F, 0x01, 0xB0, 0xFD, 0x93, 0x03, 0xC7, 0xFA, 0x7D, 0x08,
3159 0x86, 0x48, 0x5A, 0xFF, 0xBA, 0xFE, 0x86, 0x01, 0xBF, 0xFE, 0xCF,
3160 0x00, 0x9E, 0xFF, 0x17, 0x00, 0x1C, 0x00, 0x8C, 0xFF, 0xFE, 0x00,
3161 0x5D, 0xFE, 0x3F, 0x02, 0x5E, 0xFD, 0x54, 0x02, 0xEC, 0x48, 0x13,
3162 0x05, 0x2E, 0xFC, 0xDE, 0x02, 0x0C, 0xFE, 0x24, 0x01, 0x7D, 0xFF,
3163 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0xAE, 0xFF, 0xA7, 0x00, 0x12,
3164 0xFF, 0xEA, 0x00, 0xD9, 0xFF, 0x03, 0xFD, 0xDC, 0x47, 0x95, 0x0B,
3165 0x96, 0xF9, 0x29, 0x04, 0x65, 0xFD, 0x71, 0x01, 0x5F, 0xFF, 0x29,
3166 0x00, 0x00, 0x00, 0x0C, 0x00, 0xD0, 0xFF, 0x51, 0x00, 0xC3, 0xFF,
3167 0xA6, 0xFF, 0x16, 0x02, 0xA9, 0xF8, 0x5C, 0x45, 0xB2, 0x12, 0x19,
3168 0xF7, 0x52, 0x05, 0xD8, 0xFC, 0xAF, 0x01, 0x47, 0xFF, 0x30, 0x00,
3169 0xFF, 0xFF, 0x06, 0x00, 0xEE, 0xFF, 0x01, 0x00, 0x66, 0x00, 0x85,
3170 0xFE, 0xFC, 0x03, 0x55, 0xF5, 0x8C, 0x41, 0x38, 0x1A, 0xE1, 0xF4,
3171 0x43, 0x06, 0x70, 0xFC, 0xD8, 0x01, 0x39, 0xFF, 0x35, 0x00, 0xFE,
3172 0xFF, 0x01, 0x00, 0x08, 0x00, 0xBB, 0xFF, 0xF1, 0x00, 0x96, 0xFD,
3173 0x78, 0x05, 0x0E, 0xF3, 0x8A, 0x3C, 0xEA, 0x21, 0x19, 0xF3, 0xE6,
3174 0x06, 0x38, 0xFC, 0xE6, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF,
3175 0xFE, 0xFF, 0x1D, 0x00, 0x82, 0xFF, 0x60, 0x01, 0xE0, 0xFC, 0x7F,
3176 0x06, 0xCC, 0xF1, 0x85, 0x36, 0x87, 0x29, 0xEB, 0xF1, 0x2A, 0x07,
3177 0x39, 0xFC, 0xD6, 0x01, 0x43, 0xFF, 0x33, 0x00, 0xFD, 0xFF, 0xFD,
3178 0xFF, 0x2B, 0x00, 0x59, 0xFF, 0xAE, 0x01, 0x6A, 0xFC, 0x0D, 0x07,
3179 0x80, 0xF1, 0xB8, 0x2F, 0xCF, 0x30, 0x7D, 0xF1, 0xFF, 0x06, 0x78,
3180 0xFC, 0xA5, 0x01, 0x5F, 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0xFD, 0xFF,
3181 0x34, 0x00, 0x40, 0xFF, 0xDB, 0x01, 0x35, 0xFC, 0x26, 0x07, 0x0E,
3182 0xF2, 0x60, 0x28, 0x82, 0x37, 0xED, 0xF1, 0x5E, 0x06, 0xF8, 0xFC,
3183 0x51, 0x01, 0x8A, 0xFF, 0x1A, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36,
3184 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3E, 0xFC, 0xD3, 0x06, 0x56, 0xF3,
3185 0xBA, 0x20, 0x61, 0x3D, 0x56, 0xF3, 0x45, 0x05, 0xB7, 0xFD, 0xDE,
3186 0x00, 0xC5, 0xFF, 0x05, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x35, 0x00,
3187 0x3A, 0xFF, 0xD3, 0x01, 0x7D, 0xFC, 0x23, 0x06, 0x32, 0xF5, 0x0C,
3188 0x19, 0x38, 0x42, 0xC7, 0xF5, 0xB8, 0x03, 0xAF, 0xFE, 0x4E, 0x00,
3189 0x0C, 0x00, 0xEA, 0xFF, 0x06, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4A,
3190 0xFF, 0xA7, 0x01, 0xEC, 0xFC, 0x28, 0x05, 0x77, 0xF7, 0x92, 0x11,
3191 0xD7, 0x45, 0x43, 0xF9, 0xC3, 0x01, 0xD6, 0xFF, 0xA9, 0xFF, 0x5E,
3192 0x00, 0xCB, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x28, 0x00, 0x63, 0xFF,
3193 0x66, 0x01, 0x7D, 0xFD, 0xF8, 0x03, 0xFB, 0xF9, 0x89, 0x0A, 0x1D,
3194 0x48, 0xC5, 0xFD, 0x7A, 0xFF, 0x1D, 0x01, 0xF7, 0xFE, 0xB4, 0x00,
3195 0xA9, 0xFF, 0x15, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x82, 0xFF, 0x18,
3196 0x01, 0x27, 0xFE, 0xA9, 0x02, 0x94, 0xFC, 0x24, 0x04, 0xF5, 0x48,
3197 0x39, 0x03, 0xF9, 0xFC, 0x74, 0x02, 0x42, 0xFE, 0x0B, 0x01, 0x87,
3198 0xFF, 0x1E, 0x00, 0x16, 0x00, 0xA4, 0xFF, 0xC2, 0x00, 0xDB, 0xFE,
3199 0x52, 0x01, 0x1B, 0xFF, 0x8D, 0xFE, 0x57, 0x48, 0x81, 0x09, 0x61,
3200 0xFA, 0xC6, 0x03, 0x96, 0xFD, 0x5B, 0x01, 0x68, 0xFF, 0x26, 0x00,
3201 0x00, 0x00, 0x0E, 0x00, 0xC6, 0xFF, 0x6B, 0x00, 0x8E, 0xFF, 0x06,
3202 0x00, 0x6E, 0x01, 0xE4, 0xF9, 0x48, 0x46, 0x75, 0x10, 0xD7, 0xF7,
3203 0xFC, 0x04, 0x00, 0xFD, 0x9E, 0x01, 0x4E, 0xFF, 0x2E, 0x00, 0xFF,
3204 0xFF, 0x07, 0x00, 0xE5, 0xFF, 0x18, 0x00, 0x36, 0x00, 0xD9, 0xFE,
3205 0x71, 0x03, 0x3F, 0xF6, 0xDB, 0x42, 0xE0, 0x17, 0x86, 0xF5, 0x00,
3206 0x06, 0x8C, 0xFC, 0xCE, 0x01, 0x3C, 0xFF, 0x34, 0x00, 0xFE, 0xFF,
3207 0x02, 0x00, 0x01, 0x00, 0xCF, 0xFF, 0xC9, 0x00, 0xDA, 0xFD, 0x0F,
3208 0x05, 0xA5, 0xF3, 0x31, 0x3E, 0x8A, 0x1F, 0x97, 0xF3, 0xBD, 0x06,
3209 0x44, 0xFC, 0xE5, 0x01, 0x36, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFF,
3210 0xFF, 0x17, 0x00, 0x92, 0xFF, 0x41, 0x01, 0x11, 0xFD, 0x3B, 0x06,
3211 0x14, 0xF2, 0x78, 0x38, 0x36, 0x27, 0x35, 0xF2, 0x20, 0x07, 0x33,
3212 0xFC, 0xDF, 0x01, 0x3E, 0xFF, 0x34, 0x00, 0xFD, 0xFF, 0xFD, 0xFF,
3213 0x28, 0x00, 0x64, 0xFF, 0x9A, 0x01, 0x88, 0xFC, 0xEE, 0x06, 0x7E,
3214 0xF1, 0xE3, 0x31, 0x9F, 0x2E, 0x88, 0xF1, 0x19, 0x07, 0x5E, 0xFC,
3215 0xB7, 0x01, 0x54, 0xFF, 0x2D, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x32,
3216 0x00, 0x46, 0xFF, 0xD1, 0x01, 0x3F, 0xFC, 0x2B, 0x07, 0xCD, 0xF1,
3217 0xAE, 0x2A, 0x86, 0x35, 0xB1, 0xF1, 0x9D, 0x06, 0xCA, 0xFC, 0x6E,
3218 0x01, 0x7B, 0xFF, 0x20, 0x00, 0xFE, 0xFF, 0xFD, 0xFF, 0x36, 0x00,
3219 0x38, 0xFF, 0xE6, 0x01, 0x35, 0xFC, 0xF7, 0x06, 0xE0, 0xF2, 0x18,
3220 0x23, 0xAB, 0x3B, 0xCC, 0xF2, 0xA8, 0x05, 0x76, 0xFD, 0x04, 0x01,
3221 0xB1, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x38,
3222 0xFF, 0xDC, 0x01, 0x64, 0xFC, 0x62, 0x06, 0x93, 0xF4, 0x66, 0x1B,
3223 0xD9, 0x40, 0xEA, 0xF4, 0x3E, 0x04, 0x5D, 0xFE, 0x7D, 0x00, 0xF5,
3224 0xFF, 0xF3, 0xFF, 0x05, 0x00, 0xFF, 0xFF, 0x31, 0x00, 0x44, 0xFF,
3225 0xB7, 0x01, 0xC5, 0xFC, 0x7C, 0x05, 0xBC, 0xF6, 0xD5, 0x13, 0xDC,
3226 0x44, 0x14, 0xF8, 0x67, 0x02, 0x77, 0xFF, 0xDD, 0xFF, 0x44, 0x00,
3227 0xD5, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x5B, 0xFF, 0x7C,
3228 0x01, 0x4E, 0xFD, 0x5A, 0x04, 0x31, 0xF9, 0xA4, 0x0C, 0x90, 0x47,
3229 0x47, 0xFC, 0x36, 0x00, 0xB6, 0x00, 0x2E, 0xFF, 0x99, 0x00, 0xB3,
3230 0xFF, 0x12, 0x00, 0x00, 0x00, 0x22, 0x00, 0x78, 0xFF, 0x31, 0x01,
3231 0xF1, 0xFD, 0x12, 0x03, 0xC7, 0xFB, 0x07, 0x06, 0xDB, 0x48, 0x73,
3232 0x01, 0xC3, 0xFD, 0x0A, 0x02, 0x79, 0xFE, 0xF1, 0x00, 0x91, 0xFF,
3233 0x1B, 0x00, 0x19, 0x00, 0x99, 0xFF, 0xDD, 0x00, 0xA3, 0xFE, 0xBB,
3234 0x01, 0x58, 0xFE, 0x2D, 0x00, 0xAF, 0x48, 0x7E, 0x07, 0x2E, 0xFB,
3235 0x60, 0x03, 0xC9, 0xFD, 0x43, 0x01, 0x71, 0xFF, 0x24, 0x00, 0x00,
3236 0x00, 0x10, 0x00, 0xBB, 0xFF, 0x85, 0x00, 0x58, 0xFF, 0x6A, 0x00,
3237 0xBE, 0x00, 0x38, 0xFB, 0x0F, 0x47, 0x42, 0x0E, 0x9B, 0xF8, 0xA1,
3238 0x04, 0x2B, 0xFD, 0x8B, 0x01, 0x55, 0xFF, 0x2C, 0x00, 0xFF, 0xFF,
3239 0x09, 0x00, 0xDC, 0xFF, 0x31, 0x00, 0x04, 0x00, 0x32, 0xFF, 0xDC,
3240 0x02, 0x42, 0xF7, 0x0B, 0x44, 0x8E, 0x15, 0x34, 0xF6, 0xB7, 0x05,
3241 0xAB, 0xFC, 0xC1, 0x01, 0x40, 0xFF, 0x33, 0x00, 0xFF, 0xFF, 0x04,
3242 0x00, 0xF9, 0xFF, 0xE4, 0xFF, 0x9F, 0x00, 0x23, 0xFE, 0x9B, 0x04,
3243 0x55, 0xF4, 0xC0, 0x3F, 0x2C, 0x1D, 0x22, 0xF4, 0x8C, 0x06, 0x55,
3244 0xFC, 0xE1, 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFE, 0xFF, 0x00, 0x00,
3245 0x11, 0x00, 0xA3, 0xFF, 0x20, 0x01, 0x49, 0xFD, 0xEB, 0x05, 0x74,
3246 0xF2, 0x54, 0x3A, 0xDD, 0x24, 0x91, 0xF2, 0x0C, 0x07, 0x32, 0xFC,
3247 0xE4, 0x01, 0x3A, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFE, 0xFF, 0x23,
3248 0x00, 0x71, 0xFF, 0x82, 0x01, 0xAB, 0xFC, 0xC4, 0x06, 0x93, 0xF1,
3249 0xFD, 0x33, 0x62, 0x2C, 0xA8, 0xF1, 0x27, 0x07, 0x4A, 0xFC, 0xC7,
3250 0x01, 0x4C, 0xFF, 0x30, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x2F, 0x00,
3251 0x4E, 0xFF, 0xC3, 0x01, 0x4E, 0xFC, 0x24, 0x07, 0x9E, 0xF1, 0xF2,
3252 0x2C, 0x78, 0x33, 0x8C, 0xF1, 0xD0, 0x06, 0xA2, 0xFC, 0x88, 0x01,
3253 0x6D, 0xFF, 0x24, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x35, 0x00, 0x3B,
3254 0xFF, 0xE3, 0x01, 0x31, 0xFC, 0x12, 0x07, 0x79, 0xF2, 0x73, 0x25,
3255 0xDF, 0x39, 0x5A, 0xF2, 0x00, 0x06, 0x3A, 0xFD, 0x28, 0x01, 0x9F,
3256 0xFF, 0x13, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x36, 0x00, 0x36, 0xFF,
3257 0xE2, 0x01, 0x50, 0xFC, 0x99, 0x06, 0xFE, 0xF3, 0xC3, 0x1D, 0x5E,
3258 0x3F, 0x27, 0xF4, 0xB9, 0x04, 0x10, 0xFE, 0xA9, 0x00, 0xDF, 0xFF,
3259 0xFB, 0xFF, 0x03, 0x00, 0xFF, 0xFF, 0x33, 0x00, 0x3F, 0xFF, 0xC5,
3260 0x01, 0xA3, 0xFC, 0xCA, 0x05, 0x07, 0xF6, 0x22, 0x16, 0xC3, 0x43,
3261 0xFE, 0xF6, 0x02, 0x03, 0x1B, 0xFF, 0x11, 0x00, 0x2B, 0x00, 0xDE,
3262 0xFF, 0x09, 0x00, 0xFF, 0xFF, 0x2D, 0x00, 0x53, 0xFF, 0x90, 0x01,
3263 0x20, 0xFD, 0xB8, 0x04, 0x6A, 0xF8, 0xCD, 0x0E, 0xE1, 0x46, 0xE1,
3264 0xFA, 0xEB, 0x00, 0x51, 0x00, 0x65, 0xFF, 0x7F, 0x00, 0xBE, 0xFF,
3265 0x10, 0x00, 0x00, 0x00, 0x24, 0x00, 0x6E, 0xFF, 0x49, 0x01, 0xBC,
3266 0xFD, 0x7A, 0x03, 0xFA, 0xFA, 0xFD, 0x07, 0x9C, 0x48, 0xC3, 0xFF,
3267 0x89, 0xFE, 0xA1, 0x01, 0xB1, 0xFE, 0xD6, 0x00, 0x9C, 0xFF, 0x18,
3268 0x00, 0x1C, 0x00, 0x8F, 0xFF, 0xF7, 0x00, 0x6B, 0xFE, 0x25, 0x02,
3269 0x91, 0xFD, 0xE3, 0x01, 0xE5, 0x48, 0x8D, 0x05, 0xFB, 0xFB, 0xF8,
3270 0x02, 0xFE, 0xFD, 0x2B, 0x01, 0x7A, 0xFF, 0x21, 0x00, 0x00, 0x00,
3271 0x13, 0x00, 0xB1, 0xFF, 0xA0, 0x00, 0x20, 0xFF, 0xD0, 0x00, 0x07,
3272 0x00, 0xA4, 0xFC, 0xB6, 0x47, 0x1C, 0x0C, 0x63, 0xF9, 0x42, 0x04,
3273 0x59, 0xFD, 0x76, 0x01, 0x5D, 0xFF, 0x2A, 0x00, 0x00, 0x00, 0x0B,
3274 0x00, 0xD2, 0xFF, 0x4A, 0x00, 0xD0, 0xFF, 0x8E, 0xFF, 0x3F, 0x02,
3275 0x5E, 0xF8, 0x1E, 0x45, 0x44, 0x13, 0xEA, 0xF6, 0x67, 0x05, 0xCF,
3276 0xFC, 0xB3, 0x01, 0x46, 0xFF, 0x31, 0x00, 0xFF, 0xFF, 0x05, 0x00,
3277 0xF0, 0xFF, 0xFB, 0xFF, 0x71, 0x00, 0x71, 0xFE, 0x1D, 0x04, 0x1F,
3278 0xF5, 0x32, 0x41, 0xCE, 0x1A, 0xBA, 0xF4, 0x53, 0x06, 0x6A, 0xFC,
3279 0xDA, 0x01, 0x38, 0xFF, 0x35, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x0A,
3280 0x00, 0xB6, 0xFF, 0xFB, 0x00, 0x85, 0xFD, 0x90, 0x05, 0xEC, 0xF2,
3281 0x1C, 0x3C, 0x81, 0x22, 0xFC, 0xF2, 0xEF, 0x06, 0x36, 0xFC, 0xE6,
3282 0x01, 0x37, 0xFF, 0x36, 0x00, 0xFD, 0xFF, 0xFE, 0xFF, 0x1E, 0x00,
3283 0x7F, 0xFF, 0x67, 0x01, 0xD5, 0xFC, 0x8E, 0x06, 0xBE, 0xF1, 0x06,
3284 0x36, 0x1A, 0x2A, 0xDC, 0xF1, 0x2A, 0x07, 0x3C, 0xFC, 0xD3, 0x01,
3285 0x44, 0xFF, 0x32, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x2C, 0x00, 0x57,
3286 0xFF, 0xB3, 0x01, 0x64, 0xFC, 0x13, 0x07, 0x83, 0xF1, 0x2C, 0x2F,
3287 0x5A, 0x31, 0x7D, 0xF1, 0xF7, 0x06, 0x80, 0xFC, 0x9F, 0x01, 0x61,
3288 0xFF, 0x29, 0x00, 0xFD, 0xFF, 0xFD, 0xFF, 0x34, 0x00, 0x3F, 0xFF,
3289 0xDD, 0x01, 0x34, 0xFC, 0x23, 0x07, 0x21, 0xF2, 0xCB, 0x27, 0xFE,
3290 0x37, 0x00, 0xF2, 0x4D, 0x06, 0x04, 0xFD, 0x49, 0x01, 0x8E, 0xFF,
3291 0x19, 0x00, 0xFF, 0xFF, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6,
3292 0x01, 0x41, 0xFC, 0xC8, 0x06, 0x76, 0xF3, 0x22, 0x20, 0xCA, 0x3D,
3293 0x7D, 0xF3, 0x2A, 0x05, 0xC8, 0xFD, 0xD4, 0x00, 0xCA, 0xFF, 0x03,
3294 0x00, 0x02, 0x00, 0xFE, 0xFF, 0x34, 0x00, 0x3B, 0xFF, 0xD1, 0x01,
3295 0x84, 0xFC, 0x12, 0x06, 0x5C, 0xF5, 0x76, 0x18, 0x89, 0x42, 0x02,
3296 0xF6, 0x94, 0x03, 0xC4, 0xFE, 0x42, 0x00, 0x12, 0x00, 0xE8, 0xFF,
3297 0x07, 0x00, 0xFF, 0xFF, 0x2F, 0x00, 0x4C, 0xFF, 0xA2, 0x01, 0xF6,
3298 0xFC, 0x12, 0x05, 0xA7, 0xF7, 0x03, 0x11, 0x10, 0x46, 0x93, 0xF9,
3299 0x98, 0x01, 0xEE, 0xFF, 0x9B, 0xFF, 0x64, 0x00, 0xC8, 0xFF, 0x0E,
3300 0x00, 0x00, 0x00, 0x27, 0x00, 0x65, 0xFF, 0x60, 0x01, 0x8A, 0xFD,
3301 0xDF, 0x03, 0x2E, 0xFA, 0x04, 0x0A, 0x3A, 0x48, 0x28, 0xFE, 0x4B,
3302 0xFF, 0x38, 0x01, 0xE9, 0xFE, 0xBB, 0x00, 0xA6, 0xFF, 0x16, 0x00,
3303 0x00, 0x00, 0x1E, 0x00, 0x84, 0xFF, 0x11, 0x01, 0x34, 0xFE, 0x8F,
3304 0x02, 0xC7, 0xFC, 0xAE, 0x03, 0xF7, 0x48, 0xAE, 0x03, 0xC7, 0xFC,
3305 0x8F, 0x02, 0x34, 0xFE, 0x11, 0x01, 0x84, 0xFF, 0x1E, 0x00, 0x00,
3306 0x00, 0xF4, 0xFF, 0x1A, 0x00, 0xFF, 0x00, 0x07, 0x03, 0x16, 0x06,
3307 0x7C, 0x09, 0x2A, 0x0C, 0x2E, 0x0D, 0x2A, 0x0C, 0x7C, 0x09, 0x16,
3308 0x06, 0x07, 0x03, 0xFF, 0x00, 0x1A, 0x00, 0xF4, 0xFF, 0xF2, 0xFF,
3309 0xA0, 0xFF, 0x71, 0xFF, 0x71, 0x00, 0x86, 0x03, 0x73, 0x08, 0x88,
3310 0x0D, 0x78, 0x10, 0xC9, 0x0F, 0xD5, 0x0B, 0x8B, 0x06, 0x28, 0x02,
3311 0xDF, 0xFF, 0x6F, 0xFF, 0xC3, 0xFF, 0xFD, 0xFF, 0x00, 0x00, 0xDC,
3312 0xFF, 0x80, 0xFF, 0x9A, 0xFF, 0x46, 0x01, 0x1E, 0x05, 0x5A, 0x0A,
3313 0xED, 0x0E, 0xAA, 0x10, 0xAF, 0x0E, 0xFD, 0x09, 0xCB, 0x04, 0x18,
3314 0x01, 0x8E, 0xFF, 0x85, 0xFF, 0xE1, 0xFF, 0xFC, 0xFF, 0xBD, 0xFF,
3315 0x6D, 0xFF, 0xF6, 0xFF, 0x65, 0x02, 0xE5, 0x06, 0x2B, 0x0C, 0xF3,
3316 0x0F, 0x60, 0x10, 0x3B, 0x0D, 0x16, 0x08, 0x3F, 0x03, 0x50, 0x00,
3317 0x6E, 0xFF, 0xA7, 0xFF, 0xF5, 0xFF, 0xEF, 0xFF, 0x9A, 0xFF, 0x75,
3318 0xFF, 0x91, 0x00, 0xC9, 0x03, 0xC8, 0x08, 0xCC, 0x0D, 0x89, 0x10,
3319 0x9F, 0x0F, 0x85, 0x0B, 0x3B, 0x06, 0xF4, 0x01, 0xCD, 0xFF, 0x72,
3320 0xFF, 0xC9, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xD7, 0xFF, 0x7B, 0xFF,
3321 0xA5, 0xFF, 0x73, 0x01, 0x6A, 0x05, 0xAD, 0x0A, 0x21, 0x0F, 0xA6,
3322 0x10, 0x74, 0x0E, 0xA9, 0x09, 0x83, 0x04, 0xF0, 0x00, 0x85, 0xFF,
3323 0x8B, 0xFF, 0xE5, 0xFF, 0xFA, 0xFF, 0xB7, 0xFF, 0x6C, 0xFF, 0x0C,
3324 0x00, 0x9D, 0x02, 0x37, 0x07, 0x78, 0x0C, 0x15, 0x10, 0x47, 0x10,
3325 0xF3, 0x0C, 0xC2, 0x07, 0x01, 0x03, 0x35, 0x00, 0x6D, 0xFF, 0xAD,
3326 0xFF, 0xF7, 0xFF, 0xEB, 0xFF, 0x94, 0xFF, 0x7A, 0xFF, 0xB3, 0x00,
3327 0x0D, 0x04, 0x1C, 0x09, 0x0D, 0x0E, 0x97, 0x10, 0x73, 0x0F, 0x35,
3328 0x0B, 0xEB, 0x05, 0xC1, 0x01, 0xBD, 0xFF, 0x75, 0xFF, 0xCE, 0xFF,
3329 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, 0xFF, 0x77, 0xFF, 0xB3, 0xFF, 0xA1,
3330 0x01, 0xB7, 0x05, 0xFF, 0x0A, 0x53, 0x0F, 0x9E, 0x10, 0x37, 0x0E,
3331 0x55, 0x09, 0x3B, 0x04, 0xCB, 0x00, 0x7E, 0xFF, 0x90, 0xFF, 0xE9,
3332 0xFF, 0xF8, 0xFF, 0xB1, 0xFF, 0x6C, 0xFF, 0x24, 0x00, 0xD8, 0x02,
3333 0x8A, 0x07, 0xC2, 0x0C, 0x34, 0x10, 0x2A, 0x10, 0xAA, 0x0C, 0x6F,
3334 0x07, 0xC4, 0x02, 0x1C, 0x00, 0x6C, 0xFF, 0xB3, 0xFF, 0xF9, 0xFF,
3335 0xE8, 0xFF, 0x8E, 0xFF, 0x80, 0xFF, 0xD7, 0x00, 0x53, 0x04, 0x71,
3336 0x09, 0x4C, 0x0E, 0xA1, 0x10, 0x43, 0x0F, 0xE3, 0x0A, 0x9D, 0x05,
3337 0x91, 0x01, 0xAE, 0xFF, 0x79, 0xFF, 0xD4, 0xFF, 0x00, 0x00, 0xFF,
3338 0xFF, 0xCD, 0xFF, 0x74, 0xFF, 0xC2, 0xFF, 0xD2, 0x01, 0x06, 0x06,
3339 0x50, 0x0B, 0x82, 0x0F, 0x93, 0x10, 0xF8, 0x0D, 0x00, 0x09, 0xF6,
3340 0x03, 0xA7, 0x00, 0x78, 0xFF, 0x96, 0xFF, 0xEC, 0xFF, 0xF6, 0xFF,
3341 0xAB, 0xFF, 0x6D, 0xFF, 0x3E, 0x00, 0x15, 0x03, 0xDE, 0x07, 0x0B,
3342 0x0D, 0x50, 0x10, 0x0A, 0x10, 0x5E, 0x0C, 0x1C, 0x07, 0x8A, 0x02,
3343 0x04, 0x00, 0x6C, 0xFF, 0xB9, 0xFF, 0xFB, 0xFF, 0xE4, 0xFF, 0x89,
3344 0xFF, 0x88, 0xFF, 0xFD, 0x00, 0x9B, 0x04, 0xC5, 0x09, 0x88, 0x0E,
3345 0xA8, 0x10, 0x10, 0x0F, 0x91, 0x0A, 0x50, 0x05, 0x64, 0x01, 0xA1,
3346 0xFF, 0x7D, 0xFF, 0xD9, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0xFF,
3347 0x71, 0xFF, 0xD3, 0xFF, 0x05, 0x02, 0x55, 0x06, 0xA0, 0x0B, 0xAD,
3348 0x0F, 0x84, 0x10, 0xB6, 0x0D, 0xAC, 0x08, 0xB3, 0x03, 0x86, 0x00,
3349 0x74, 0xFF, 0x9C, 0xFF, 0xF0, 0xFF, 0xF4, 0xFF, 0xA5, 0xFF, 0x6F,
3350 0xFF, 0x5A, 0x00, 0x54, 0x03, 0x32, 0x08, 0x52, 0x0D, 0x68, 0x10,
3351 0xE6, 0x0F, 0x11, 0x0C, 0xCA, 0x06, 0x52, 0x02, 0xEF, 0xFF, 0x6E,
3352 0xFF, 0xBF, 0xFF, 0xFC, 0xFF, 0xDF, 0xFF, 0x84, 0xFF, 0x91, 0xFF,
3353 0x25, 0x01, 0xE4, 0x04, 0x19, 0x0A, 0xC2, 0x0E, 0xAA, 0x10, 0xDA,
3354 0x0E, 0x3E, 0x0A, 0x05, 0x05, 0x38, 0x01, 0x96, 0xFF, 0x81, 0xFF,
3355 0xDD, 0xFF, 0x00, 0x00, 0xFD, 0xFF, 0xC1, 0xFF, 0x6E, 0xFF, 0xE6,
3356 0xFF, 0x3A, 0x02, 0xA6, 0x06, 0xEF, 0x0B, 0xD6, 0x0F, 0x71, 0x10,
3357 0x71, 0x0D, 0x57, 0x08, 0x71, 0x03, 0x67, 0x00, 0x70, 0xFF, 0xA2,
3358 0xFF, 0xF3, 0xFF, 0xF1, 0xFF, 0x9F, 0xFF, 0x72, 0xFF, 0x78, 0x00,
3359 0x95, 0x03, 0x86, 0x08, 0x98, 0x0D, 0x7C, 0x10, 0xC0, 0x0F, 0xC3,
3360 0x0B, 0x79, 0x06, 0x1C, 0x02, 0xDB, 0xFF, 0x70, 0xFF, 0xC5, 0xFF,
3361 0xFE, 0xFF, 0x00, 0x00, 0xDB, 0xFF, 0x7F, 0xFF, 0x9C, 0xFF, 0x50,
3362 0x01, 0x2F, 0x05, 0x6C, 0x0A, 0xF9, 0x0E, 0xA9, 0x10, 0xA2, 0x0E,
3363 0xEA, 0x09, 0xBB, 0x04, 0x0F, 0x01, 0x8C, 0xFF, 0x87, 0xFF, 0xE2,
3364 0xFF, 0xFC, 0xFF, 0xBC, 0xFF, 0x6D, 0xFF, 0xFA, 0xFF, 0x71, 0x02,
3365 0xF7, 0x06, 0x3C, 0x0C, 0xFB, 0x0F, 0x5B, 0x10, 0x2B, 0x0D, 0x03,
3366 0x08, 0x31, 0x03, 0x4A, 0x00, 0x6E, 0xFF, 0xA8, 0xFF, 0xF5, 0xFF,
3367 0xEE, 0xFF, 0x99, 0xFF, 0x76, 0xFF, 0x98, 0x00, 0xD8, 0x03, 0xDB,
3368 0x08, 0xDB, 0x0D, 0x8D, 0x10, 0x96, 0x0F, 0x73, 0x0B, 0x29, 0x06,
3369 0xE8, 0x01, 0xC9, 0xFF, 0x72, 0xFF, 0xCA, 0xFF, 0xFE, 0xFF, 0x00,
3370 0x00, 0xD6, 0xFF, 0x7A, 0xFF, 0xA8, 0xFF, 0x7D, 0x01, 0x7B, 0x05,
3371 0xBF, 0x0A, 0x2D, 0x0F, 0xA5, 0x10, 0x67, 0x0E, 0x96, 0x09, 0x73,
3372 0x04, 0xE7, 0x00, 0x84, 0xFF, 0x8C, 0xFF, 0xE6, 0xFF, 0xFA, 0xFF,
3373 0xB6, 0xFF, 0x6C, 0xFF, 0x11, 0x00, 0xAA, 0x02, 0x4A, 0x07, 0x88,
3374 0x0C, 0x1C, 0x10, 0x41, 0x10, 0xE3, 0x0C, 0xAF, 0x07, 0xF3, 0x02,
3375 0x2F, 0x00, 0x6C, 0xFF, 0xAE, 0xFF, 0xF7, 0xFF, 0xEA, 0xFF, 0x93,
3376 0xFF, 0x7B, 0xFF, 0xBB, 0x00, 0x1C, 0x04, 0x2F, 0x09, 0x1B, 0x0E,
3377 0x9A, 0x10, 0x68, 0x0F, 0x23, 0x0B, 0xDA, 0x05, 0xB7, 0x01, 0xB9,
3378 0xFF, 0x76, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD1, 0xFF,
3379 0x76, 0xFF, 0xB6, 0xFF, 0xAC, 0x01, 0xC8, 0x05, 0x11, 0x0B, 0x5E,
3380 0x0F, 0x9C, 0x10, 0x29, 0x0E, 0x42, 0x09, 0x2C, 0x04, 0xC2, 0x00,
3381 0x7D, 0xFF, 0x92, 0xFF, 0xEA, 0xFF, 0xF8, 0xFF, 0xB0, 0xFF, 0x6C,
3382 0xFF, 0x29, 0x00, 0xE6, 0x02, 0x9D, 0x07, 0xD3, 0x0C, 0x3B, 0x10,
3383 0x23, 0x10, 0x99, 0x0C, 0x5C, 0x07, 0xB7, 0x02, 0x16, 0x00, 0x6C,
3384 0xFF, 0xB4, 0xFF, 0xF9, 0xFF, 0xE7, 0xFF, 0x8D, 0xFF, 0x82, 0xFF,
3385 0xDF, 0x00, 0x63, 0x04, 0x84, 0x09, 0x59, 0x0E, 0xA3, 0x10, 0x38,
3386 0x0F, 0xD1, 0x0A, 0x8C, 0x05, 0x87, 0x01, 0xAB, 0xFF, 0x79, 0xFF,
3387 0xD5, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xCB, 0xFF, 0x73, 0xFF, 0xC6,
3388 0xFF, 0xDD, 0x01, 0x17, 0x06, 0x62, 0x0B, 0x8C, 0x0F, 0x90, 0x10,
3389 0xE9, 0x0D, 0xED, 0x08, 0xE7, 0x03, 0xA0, 0x00, 0x77, 0xFF, 0x97,
3390 0xFF, 0xED, 0xFF, 0xF6, 0xFF, 0xA9, 0xFF, 0x6D, 0xFF, 0x44, 0x00,
3391 0x23, 0x03, 0xF1, 0x07, 0x1B, 0x0D, 0x55, 0x10, 0x02, 0x10, 0x4D,
3392 0x0C, 0x0A, 0x07, 0x7E, 0x02, 0xFF, 0xFF, 0x6D, 0xFF, 0xBA, 0xFF,
3393 0xFB, 0xFF, 0xE3, 0xFF, 0x88, 0xFF, 0x8A, 0xFF, 0x06, 0x01, 0xAB,
3394 0x04, 0xD8, 0x09, 0x95, 0x0E, 0xA9, 0x10, 0x05, 0x0F, 0x7F, 0x0A,
3395 0x40, 0x05, 0x5A, 0x01, 0x9F, 0xFF, 0x7E, 0xFF, 0xDA, 0xFF, 0x00,
3396 0x00, 0xFE, 0xFF, 0xC6, 0xFF, 0x70, 0xFF, 0xD7, 0xFF, 0x10, 0x02,
3397 0x67, 0x06, 0xB1, 0x0B, 0xB7, 0x0F, 0x80, 0x10, 0xA7, 0x0D, 0x99,
3398 0x08, 0xA4, 0x03, 0x7F, 0x00, 0x73, 0xFF, 0x9D, 0xFF, 0xF0, 0xFF,
3399 0xF3, 0xFF, 0xA3, 0xFF, 0x70, 0xFF, 0x60, 0x00, 0x62, 0x03, 0x45,
3400 0x08, 0x62, 0x0D, 0x6C, 0x10, 0xDE, 0x0F, 0x00, 0x0C, 0xB8, 0x06,
3401 0x46, 0x02, 0xEA, 0xFF, 0x6E, 0xFF, 0xC0, 0xFF, 0xFD, 0xFF, 0x00,
3402 0x00, 0xDE, 0xFF, 0x83, 0xFF, 0x94, 0xFF, 0x2F, 0x01, 0xF4, 0x04,
3403 0x2B, 0x0A, 0xCE, 0x0E, 0xAA, 0x10, 0xCE, 0x0E, 0x2B, 0x0A, 0xF4,
3404 0x04, 0x2F, 0x01, 0x94, 0xFF, 0x83, 0xFF, 0xDE, 0xFF, 0xFD, 0xFF,
3405 0xC0, 0xFF, 0x6E, 0xFF, 0xEA, 0xFF, 0x46, 0x02, 0xB8, 0x06, 0x00,
3406 0x0C, 0xDE, 0x0F, 0x6C, 0x10, 0x62, 0x0D, 0x45, 0x08, 0x62, 0x03,
3407 0x60, 0x00, 0x70, 0xFF, 0xA3, 0xFF, 0xF3, 0xFF, 0xF0, 0xFF, 0x9D,
3408 0xFF, 0x73, 0xFF, 0x7F, 0x00, 0xA4, 0x03, 0x99, 0x08, 0xA7, 0x0D,
3409 0x80, 0x10, 0xB7, 0x0F, 0xB1, 0x0B, 0x67, 0x06, 0x10, 0x02, 0xD7,
3410 0xFF, 0x70, 0xFF, 0xC6, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xDA, 0xFF,
3411 0x7E, 0xFF, 0x9F, 0xFF, 0x5A, 0x01, 0x40, 0x05, 0x7F, 0x0A, 0x05,
3412 0x0F, 0xA9, 0x10, 0x95, 0x0E, 0xD8, 0x09, 0xAB, 0x04, 0x06, 0x01,
3413 0x8A, 0xFF, 0x88, 0xFF, 0xE3, 0xFF, 0xFB, 0xFF, 0xBA, 0xFF, 0x6D,
3414 0xFF, 0xFF, 0xFF, 0x7E, 0x02, 0x0A, 0x07, 0x4D, 0x0C, 0x02, 0x10,
3415 0x55, 0x10, 0x1B, 0x0D, 0xF1, 0x07, 0x23, 0x03, 0x44, 0x00, 0x6D,
3416 0xFF, 0xA9, 0xFF, 0xF6, 0xFF, 0xED, 0xFF, 0x97, 0xFF, 0x77, 0xFF,
3417 0xA0, 0x00, 0xE7, 0x03, 0xED, 0x08, 0xE9, 0x0D, 0x90, 0x10, 0x8C,
3418 0x0F, 0x62, 0x0B, 0x17, 0x06, 0xDD, 0x01, 0xC6, 0xFF, 0x73, 0xFF,
3419 0xCB, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xD5, 0xFF, 0x79, 0xFF, 0xAB,
3420 0xFF, 0x87, 0x01, 0x8C, 0x05, 0xD1, 0x0A, 0x38, 0x0F, 0xA3, 0x10,
3421 0x59, 0x0E, 0x84, 0x09, 0x63, 0x04, 0xDF, 0x00, 0x82, 0xFF, 0x8D,
3422 0xFF, 0xE7, 0xFF, 0xF9, 0xFF, 0xB4, 0xFF, 0x6C, 0xFF, 0x16, 0x00,
3423 0xB7, 0x02, 0x5C, 0x07, 0x99, 0x0C, 0x23, 0x10, 0x3B, 0x10, 0xD3,
3424 0x0C, 0x9D, 0x07, 0xE6, 0x02, 0x29, 0x00, 0x6C, 0xFF, 0xB0, 0xFF,
3425 0xF8, 0xFF, 0xEA, 0xFF, 0x92, 0xFF, 0x7D, 0xFF, 0xC2, 0x00, 0x2C,
3426 0x04, 0x42, 0x09, 0x29, 0x0E, 0x9C, 0x10, 0x5E, 0x0F, 0x11, 0x0B,
3427 0xC8, 0x05, 0xAC, 0x01, 0xB6, 0xFF, 0x76, 0xFF, 0xD1, 0xFF, 0xFF,
3428 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0x76, 0xFF, 0xB9, 0xFF, 0xB7, 0x01,
3429 0xDA, 0x05, 0x23, 0x0B, 0x68, 0x0F, 0x9A, 0x10, 0x1B, 0x0E, 0x2F,
3430 0x09, 0x1C, 0x04, 0xBB, 0x00, 0x7B, 0xFF, 0x93, 0xFF, 0xEA, 0xFF,
3431 0xF7, 0xFF, 0xAE, 0xFF, 0x6C, 0xFF, 0x2F, 0x00, 0xF3, 0x02, 0xAF,
3432 0x07, 0xE3, 0x0C, 0x41, 0x10, 0x1C, 0x10, 0x88, 0x0C, 0x4A, 0x07,
3433 0xAA, 0x02, 0x11, 0x00, 0x6C, 0xFF, 0xB6, 0xFF, 0xFA, 0xFF, 0xE6,
3434 0xFF, 0x8C, 0xFF, 0x84, 0xFF, 0xE7, 0x00, 0x73, 0x04, 0x96, 0x09,
3435 0x67, 0x0E, 0xA5, 0x10, 0x2D, 0x0F, 0xBF, 0x0A, 0x7B, 0x05, 0x7D,
3436 0x01, 0xA8, 0xFF, 0x7A, 0xFF, 0xD6, 0xFF, 0x00, 0x00, 0xFE, 0xFF,
3437 0xCA, 0xFF, 0x72, 0xFF, 0xC9, 0xFF, 0xE8, 0x01, 0x29, 0x06, 0x73,
3438 0x0B, 0x96, 0x0F, 0x8D, 0x10, 0xDB, 0x0D, 0xDB, 0x08, 0xD8, 0x03,
3439 0x98, 0x00, 0x76, 0xFF, 0x99, 0xFF, 0xEE, 0xFF, 0xF5, 0xFF, 0xA8,
3440 0xFF, 0x6E, 0xFF, 0x4A, 0x00, 0x31, 0x03, 0x03, 0x08, 0x2B, 0x0D,
3441 0x5B, 0x10, 0xFB, 0x0F, 0x3C, 0x0C, 0xF7, 0x06, 0x71, 0x02, 0xFA,
3442 0xFF, 0x6D, 0xFF, 0xBC, 0xFF, 0xFC, 0xFF, 0xE2, 0xFF, 0x87, 0xFF,
3443 0x8C, 0xFF, 0x0F, 0x01, 0xBB, 0x04, 0xEA, 0x09, 0xA2, 0x0E, 0xA9,
3444 0x10, 0xF9, 0x0E, 0x6C, 0x0A, 0x2F, 0x05, 0x50, 0x01, 0x9C, 0xFF,
3445 0x7F, 0xFF, 0xDB, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xC5, 0xFF, 0x70,
3446 0xFF, 0xDB, 0xFF, 0x1C, 0x02, 0x79, 0x06, 0xC3, 0x0B, 0xC0, 0x0F,
3447 0x7C, 0x10, 0x98, 0x0D, 0x86, 0x08, 0x95, 0x03, 0x78, 0x00, 0x72,
3448 0xFF, 0x9F, 0xFF, 0xF1, 0xFF, 0xF3, 0xFF, 0xA2, 0xFF, 0x70, 0xFF,
3449 0x67, 0x00, 0x71, 0x03, 0x57, 0x08, 0x71, 0x0D, 0x71, 0x10, 0xD6,
3450 0x0F, 0xEF, 0x0B, 0xA6, 0x06, 0x3A, 0x02, 0xE6, 0xFF, 0x6E, 0xFF,
3451 0xC1, 0xFF, 0xFD, 0xFF, 0x00, 0x00, 0xDD, 0xFF, 0x81, 0xFF, 0x96,
3452 0xFF, 0x38, 0x01, 0x05, 0x05, 0x3E, 0x0A, 0xDA, 0x0E, 0xAA, 0x10,
3453 0xC2, 0x0E, 0x19, 0x0A, 0xE4, 0x04, 0x25, 0x01, 0x91, 0xFF, 0x84,
3454 0xFF, 0xDF, 0xFF, 0xFC, 0xFF, 0xBF, 0xFF, 0x6E, 0xFF, 0xEF, 0xFF,
3455 0x52, 0x02, 0xCA, 0x06, 0x11, 0x0C, 0xE6, 0x0F, 0x68, 0x10, 0x52,
3456 0x0D, 0x32, 0x08, 0x54, 0x03, 0x5A, 0x00, 0x6F, 0xFF, 0xA5, 0xFF,
3457 0xF4, 0xFF, 0xF0, 0xFF, 0x9C, 0xFF, 0x74, 0xFF, 0x86, 0x00, 0xB3,
3458 0x03, 0xAC, 0x08, 0xB6, 0x0D, 0x84, 0x10, 0xAD, 0x0F, 0xA0, 0x0B,
3459 0x55, 0x06, 0x05, 0x02, 0xD3, 0xFF, 0x71, 0xFF, 0xC7, 0xFF, 0xFE,
3460 0xFF, 0x00, 0x00, 0xD9, 0xFF, 0x7D, 0xFF, 0xA1, 0xFF, 0x64, 0x01,
3461 0x50, 0x05, 0x91, 0x0A, 0x10, 0x0F, 0xA8, 0x10, 0x88, 0x0E, 0xC5,
3462 0x09, 0x9B, 0x04, 0xFD, 0x00, 0x88, 0xFF, 0x89, 0xFF, 0xE4, 0xFF,
3463 0xFB, 0xFF, 0xB9, 0xFF, 0x6C, 0xFF, 0x04, 0x00, 0x8A, 0x02, 0x1C,
3464 0x07, 0x5E, 0x0C, 0x0A, 0x10, 0x50, 0x10, 0x0B, 0x0D, 0xDE, 0x07,
3465 0x15, 0x03, 0x3E, 0x00, 0x6D, 0xFF, 0xAB, 0xFF, 0xF6, 0xFF, 0xEC,
3466 0xFF, 0x96, 0xFF, 0x78, 0xFF, 0xA7, 0x00, 0xF6, 0x03, 0x00, 0x09,
3467 0xF8, 0x0D, 0x93, 0x10, 0x82, 0x0F, 0x50, 0x0B, 0x06, 0x06, 0xD2,
3468 0x01, 0xC2, 0xFF, 0x74, 0xFF, 0xCD, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
3469 0xD4, 0xFF, 0x79, 0xFF, 0xAE, 0xFF, 0x91, 0x01, 0x9D, 0x05, 0xE3,
3470 0x0A, 0x43, 0x0F, 0xA1, 0x10, 0x4C, 0x0E, 0x71, 0x09, 0x53, 0x04,
3471 0xD7, 0x00, 0x80, 0xFF, 0x8E, 0xFF, 0xE8, 0xFF, 0xF9, 0xFF, 0xB3,
3472 0xFF, 0x6C, 0xFF, 0x1C, 0x00, 0xC4, 0x02, 0x6F, 0x07, 0xAA, 0x0C,
3473 0x2A, 0x10, 0x34, 0x10, 0xC2, 0x0C, 0x8A, 0x07, 0xD8, 0x02, 0x24,
3474 0x00, 0x6C, 0xFF, 0xB1, 0xFF, 0xF8, 0xFF, 0xE9, 0xFF, 0x90, 0xFF,
3475 0x7E, 0xFF, 0xCB, 0x00, 0x3B, 0x04, 0x55, 0x09, 0x37, 0x0E, 0x9E,
3476 0x10, 0x53, 0x0F, 0xFF, 0x0A, 0xB7, 0x05, 0xA1, 0x01, 0xB3, 0xFF,
3477 0x77, 0xFF, 0xD2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCE, 0xFF, 0x75,
3478 0xFF, 0xBD, 0xFF, 0xC1, 0x01, 0xEB, 0x05, 0x35, 0x0B, 0x73, 0x0F,
3479 0x97, 0x10, 0x0D, 0x0E, 0x1C, 0x09, 0x0D, 0x04, 0xB3, 0x00, 0x7A,
3480 0xFF, 0x94, 0xFF, 0xEB, 0xFF, 0xF7, 0xFF, 0xAD, 0xFF, 0x6D, 0xFF,
3481 0x35, 0x00, 0x01, 0x03, 0xC2, 0x07, 0xF3, 0x0C, 0x47, 0x10, 0x15,
3482 0x10, 0x78, 0x0C, 0x37, 0x07, 0x9D, 0x02, 0x0C, 0x00, 0x6C, 0xFF,
3483 0xB7, 0xFF, 0xFA, 0xFF, 0xE5, 0xFF, 0x8B, 0xFF, 0x85, 0xFF, 0xF0,
3484 0x00, 0x83, 0x04, 0xA9, 0x09, 0x74, 0x0E, 0xA6, 0x10, 0x21, 0x0F,
3485 0xAD, 0x0A, 0x6A, 0x05, 0x73, 0x01, 0xA5, 0xFF, 0x7B, 0xFF, 0xD7,
3486 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xC9, 0xFF, 0x72, 0xFF, 0xCD, 0xFF,
3487 0xF4, 0x01, 0x3B, 0x06, 0x85, 0x0B, 0x9F, 0x0F, 0x89, 0x10, 0xCC,
3488 0x0D, 0xC8, 0x08, 0xC9, 0x03, 0x91, 0x00, 0x75, 0xFF, 0x9A, 0xFF,
3489 0xEF, 0xFF, 0xF5, 0xFF, 0xA7, 0xFF, 0x6E, 0xFF, 0x50, 0x00, 0x3F,
3490 0x03, 0x16, 0x08, 0x3B, 0x0D, 0x60, 0x10, 0xF3, 0x0F, 0x2B, 0x0C,
3491 0xE5, 0x06, 0x65, 0x02, 0xF6, 0xFF, 0x6D, 0xFF, 0xBD, 0xFF, 0xFC,
3492 0xFF, 0xE1, 0xFF, 0x85, 0xFF, 0x8E, 0xFF, 0x18, 0x01, 0xCB, 0x04,
3493 0xFD, 0x09, 0xAF, 0x0E, 0xAA, 0x10, 0xED, 0x0E, 0x5A, 0x0A, 0x1E,
3494 0x05, 0x46, 0x01, 0x9A, 0xFF, 0x80, 0xFF, 0xDC, 0xFF, 0x00, 0x00,
3495 0xFD, 0xFF, 0xC3, 0xFF, 0x6F, 0xFF, 0xDF, 0xFF, 0x28, 0x02, 0x8B,
3496 0x06, 0xD5, 0x0B, 0xC9, 0x0F, 0x78, 0x10, 0x88, 0x0D, 0x73, 0x08,
3497 0x86, 0x03, 0x71, 0x00, 0x71, 0xFF, 0xA0, 0xFF, 0xF2, 0xFF, 0xF2,
3498 0xFF, 0xA1, 0xFF, 0x71, 0xFF, 0x6E, 0x00, 0x7F, 0x03, 0x6A, 0x08,
3499 0x81, 0x0D, 0x76, 0x10, 0xCD, 0x0F, 0xDD, 0x0B, 0x94, 0x06, 0x2E,
3500 0x02, 0xE1, 0xFF, 0x6F, 0xFF, 0xC3, 0xFF, 0xFD, 0xFF, 0x00, 0x00,
3501 0xDC, 0xFF, 0x80, 0xFF, 0x98, 0xFF, 0x42, 0x01, 0x16, 0x05, 0x50,
3502 0x0A, 0xE7, 0x0E, 0xAA, 0x10, 0xB5, 0x0E, 0x06, 0x0A, 0xD3, 0x04,
3503 0x1C, 0x01, 0x8F, 0xFF, 0x85, 0xFF, 0xE0, 0xFF, 0xFC, 0xFF, 0xBE,
3504 0xFF, 0x6D, 0xFF, 0xF3, 0xFF, 0x5E, 0x02, 0xDC, 0x06, 0x23, 0x0C,
3505 0xEF, 0x0F, 0x63, 0x10, 0x43, 0x0D, 0x1F, 0x08, 0x46, 0x03, 0x53,
3506 0x00, 0x6E, 0xFF, 0xA6, 0xFF, 0xF4, 0xFF, 0xEF, 0xFF, 0x9B, 0xFF,
3507 0x75, 0xFF, 0x8D, 0x00, 0xC1, 0x03, 0xBE, 0x08, 0xC4, 0x0D, 0x88,
3508 0x10, 0xA4, 0x0F, 0x8E, 0x0B, 0x43, 0x06, 0xF9, 0x01, 0xCF, 0xFF,
3509 0x71, 0xFF, 0xC8, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xD8, 0xFF, 0x7C,
3510 0xFF, 0xA4, 0xFF, 0x6E, 0x01, 0x61, 0x05, 0xA3, 0x0A, 0x1C, 0x0F,
3511 0xA7, 0x10, 0x7B, 0x0E, 0xB2, 0x09, 0x8B, 0x04, 0xF4, 0x00, 0x86,
3512 0xFF, 0x8A, 0xFF, 0xE4, 0xFF, 0xFA, 0xFF, 0xB8, 0xFF, 0x6C, 0xFF,
3513 0x09, 0x00, 0x97, 0x02, 0x2E, 0x07, 0x6F, 0x0C, 0x11, 0x10, 0x4A,
3514 0x10, 0xFB, 0x0C, 0xCB, 0x07, 0x07, 0x03, 0x38, 0x00, 0x6D, 0xFF,
3515 0xAC, 0xFF, 0xF7, 0xFF, 0xEC, 0xFF, 0x95, 0xFF, 0x79, 0xFF, 0xAF,
3516 0x00, 0x05, 0x04, 0x13, 0x09, 0x06, 0x0E, 0x96, 0x10, 0x78, 0x0F,
3517 0x3E, 0x0B, 0xF4, 0x05, 0xC7, 0x01, 0xBF, 0xFF, 0x74, 0xFF, 0xCE,
3518 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2, 0xFF, 0x78, 0xFF, 0xB1, 0xFF,
3519 0x9C, 0x01, 0xAE, 0x05, 0xF6, 0x0A, 0x4E, 0x0F, 0x9F, 0x10, 0x3E,
3520 0x0E, 0x5E, 0x09, 0x43, 0x04, 0xCF, 0x00, 0x7F, 0xFF, 0x90, 0xFF,
3521 0xE8, 0xFF, 0xF9, 0xFF, 0xB2, 0xFF, 0x6C, 0xFF, 0x21, 0x00, 0xD2,
3522 0x02, 0x81, 0x07, 0xBA, 0x0C, 0x31, 0x10, 0x2E, 0x10, 0xB2, 0x0C,
3523 0x78, 0x07, 0xCB, 0x02, 0x1E, 0x00, 0x6C, 0xFF, 0xB2, 0xFF, 0xF9,
3524 0xFF, 0xE8, 0xFF, 0x8F, 0xFF, 0x80, 0xFF, 0xD3, 0x00, 0x4B, 0x04,
3525 0x67, 0x09, 0x45, 0x0E, 0xA0, 0x10, 0x48, 0x0F, 0xEC, 0x0A, 0xA6,
3526 0x05, 0x97, 0x01, 0xB0, 0xFF, 0x78, 0xFF, 0xD3, 0xFF, 0x00, 0x00,
3527 0xFF, 0xFF, 0xCD, 0xFF, 0x74, 0xFF, 0xC0, 0xFF, 0xCC, 0x01, 0xFD,
3528 0x05, 0x47, 0x0B, 0x7D, 0x0F, 0x94, 0x10, 0xFF, 0x0D, 0x0A, 0x09,
3529 0xFE, 0x03, 0xAB, 0x00, 0x79, 0xFF, 0x95, 0xFF, 0xEC, 0xFF, 0xF7,
3530 0xFF, 0xAC, 0xFF, 0x6D, 0xFF, 0x3B, 0x00, 0x0E, 0x03, 0xD5, 0x07,
3531 0x03, 0x0D, 0x4D, 0x10, 0x0E, 0x10, 0x67, 0x0C, 0x25, 0x07, 0x91,
3532 0x02, 0x07, 0x00, 0x6C, 0xFF, 0xB8, 0xFF, 0xFB, 0xFF, 0xE4, 0xFF,
3533 0x89, 0xFF, 0x87, 0xFF, 0xF9, 0x00, 0x93, 0x04, 0xBC, 0x09, 0x82,
3534 0x0E, 0xA7, 0x10, 0x16, 0x0F, 0x9A, 0x0A, 0x59, 0x05, 0x69, 0x01,
3535 0xA3, 0xFF, 0x7C, 0xFF, 0xD8, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xC8,
3536 0xFF, 0x71, 0xFF, 0xD1, 0xFF, 0xFF, 0x01, 0x4C, 0x06, 0x97, 0x0B,
3537 0xA9, 0x0F, 0x86, 0x10, 0xBD, 0x0D, 0xB5, 0x08, 0xBA, 0x03, 0x8A,
3538 0x00, 0x74, 0xFF, 0x9B, 0xFF, 0xEF, 0xFF, 0xF4, 0xFF, 0xA5, 0xFF,
3539 0x6F, 0xFF, 0x57, 0x00, 0x4D, 0x03, 0x29, 0x08, 0x4B, 0x0D, 0x65,
3540 0x10, 0xEB, 0x0F, 0x1A, 0x0C, 0xD3, 0x06, 0x58, 0x02, 0xF1, 0xFF,
3541 0x6D, 0xFF, 0xBE, 0xFF, 0xFC, 0xFF, 0xE0, 0xFF, 0x84, 0xFF, 0x90,
3542 0xFF, 0x21, 0x01, 0xDC, 0x04, 0x10, 0x0A, 0xBB, 0x0E, 0xAA, 0x10,
3543 0xE1, 0x0E, 0x47, 0x0A, 0x0D, 0x05, 0x3D, 0x01, 0x97, 0xFF, 0x81,
3544 0xFF, 0xDD, 0xFF, 0x00, 0x00, 0xFD, 0xFF, 0xC2, 0xFF, 0x6F, 0xFF,
3545 0xE4, 0xFF, 0x34, 0x02, 0x9D, 0x06, 0xE6, 0x0B, 0xD1, 0x0F, 0x73,
3546 0x10, 0x79, 0x0D, 0x61, 0x08, 0x78, 0x03, 0x6A, 0x00, 0x70, 0xFF,
3547 0xA1, 0xFF, 0xF2, 0xFF, 0xF1, 0xFF, 0x9F, 0xFF, 0x72, 0xFF, 0x74,
3548 0x00, 0x8E, 0x03, 0x7D, 0x08, 0x90, 0x0D, 0x7A, 0x10, 0xC4, 0x0F,
3549 0xCC, 0x0B, 0x82, 0x06, 0x22, 0x02, 0xDD, 0xFF, 0x6F, 0xFF, 0xC4,
3550 0xFF, 0xFD, 0xFF, 0x00, 0x00, 0xDB, 0xFF, 0x7F, 0xFF, 0x9B, 0xFF,
3551 0x4B, 0x01, 0x26, 0x05, 0x63, 0x0A, 0xF3, 0x0E, 0xAA, 0x10, 0xA8,
3552 0x0E, 0xF4, 0x09, 0xC3, 0x04, 0x13, 0x01, 0x8D, 0xFF, 0x86, 0xFF,
3553 0xE1, 0xFF, 0xFC, 0xFF, 0xBC, 0xFF, 0x6D, 0xFF, 0xF8, 0xFF, 0x6B,
3554 0x02, 0xEE, 0x06, 0x34, 0x0C, 0xF7, 0x0F, 0x5D, 0x10, 0x33, 0x0D,
3555 0x0D, 0x08, 0x38, 0x03, 0x4D, 0x00, 0x6E, 0xFF, 0xA7, 0xFF, 0xF5,
3556 0xFF, 0xEE, 0xFF, 0x99, 0xFF, 0x76, 0xFF, 0x94, 0x00, 0xD0, 0x03,
3557 0xD1, 0x08, 0xD3, 0x0D, 0x8B, 0x10, 0x9A, 0x0F, 0x7C, 0x0B, 0x32,
3558 0x06, 0xEE, 0x01, 0xCB, 0xFF, 0x72, 0xFF, 0xCA, 0xFF, 0xFE, 0xFF,
3559 0x00, 0x00, 0xD6, 0xFF, 0x7B, 0xFF, 0xA7, 0xFF, 0x78, 0x01, 0x72,
3560 0x05, 0xB6, 0x0A, 0x27, 0x0F, 0xA5, 0x10, 0x6E, 0x0E, 0xA0, 0x09,
3561 0x7B, 0x04, 0xEC, 0x00, 0x85, 0xFF, 0x8B, 0xFF, 0xE5, 0xFF, 0xFA,
3562 0xFF, 0xB6, 0xFF, 0x6C, 0xFF, 0x0E, 0x00, 0xA4, 0x02, 0x41, 0x07,
3563 0x80, 0x0C, 0x19, 0x10, 0x44, 0x10, 0xEB, 0x0C, 0xB9, 0x07, 0xFA,
3564 0x02, 0x32, 0x00, 0x6D, 0xFF, 0xAE, 0xFF, 0xF7, 0xFF, 0xEB, 0xFF,
3565 0x93, 0xFF, 0x7B, 0xFF, 0xB7, 0x00, 0x15, 0x04, 0x26, 0x09, 0x14,
3566 0x0E, 0x98, 0x10, 0x6D, 0x0F, 0x2C, 0x0B, 0xE3, 0x05, 0xBC, 0x01,
3567 0xBB, 0xFF, 0x75, 0xFF, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD1,
3568 0xFF, 0x77, 0xFF, 0xB5, 0xFF, 0xA6, 0x01, 0xC0, 0x05, 0x08, 0x0B,
3569 0x58, 0x0F, 0x9D, 0x10, 0x30, 0x0E, 0x4B, 0x09, 0x34, 0x04, 0xC6,
3570 0x00, 0x7D, 0xFF, 0x91, 0xFF, 0xE9, 0xFF, 0xF8, 0xFF, 0xB0, 0xFF,
3571 0x6C, 0xFF, 0x27, 0x00, 0xDF, 0x02, 0x94, 0x07, 0xCA, 0x0C, 0x37,
3572 0x10, 0x27, 0x10, 0xA1, 0x0C, 0x65, 0x07, 0xBE, 0x02, 0x19, 0x00,
3573 0x6C, 0xFF, 0xB4, 0xFF, 0xF9, 0xFF, 0xE7, 0xFF, 0x8E, 0xFF, 0x81,
3574 0xFF, 0xDB, 0x00, 0x5B, 0x04, 0x7A, 0x09, 0x53, 0x0E, 0xA2, 0x10,
3575 0x3D, 0x0F, 0xDA, 0x0A, 0x95, 0x05, 0x8C, 0x01, 0xAD, 0xFF, 0x79,
3576 0xFF, 0xD4, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xCC, 0xFF, 0x73, 0xFF,
3577 0xC4, 0xFF, 0xD7, 0x01, 0x0E, 0x06, 0x59, 0x0B, 0x87, 0x0F, 0x91,
3578 0x10, 0xF0, 0x0D, 0xF7, 0x08, 0xEF, 0x03, 0xA3, 0x00, 0x78, 0xFF,
3579 0x97, 0xFF, 0xED, 0xFF, 0xF6, 0xFF, 0xAA, 0xFF, 0x6D, 0xFF, 0x41,
3580 0x00, 0x1C, 0x03, 0xE7, 0x07, 0x13, 0x0D, 0x52, 0x10, 0x06, 0x10,
3581 0x56, 0x0C, 0x13, 0x07, 0x84, 0x02, 0x02, 0x00, 0x6D, 0xFF, 0xBA,
3582 0xFF, 0xFB, 0xFF, 0xE3, 0xFF, 0x88, 0xFF, 0x89, 0xFF, 0x01, 0x01,
3583 0xA3, 0x04, 0xCE, 0x09, 0x8F, 0x0E, 0xA8, 0x10, 0x0A, 0x0F, 0x88,
3584 0x0A, 0x48, 0x05, 0x5F, 0x01, 0xA0, 0xFF, 0x7D, 0xFF, 0xD9, 0xFF,
3585 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0xFF, 0x70, 0xFF, 0xD5, 0xFF, 0x0B,
3586 0x02, 0x5E, 0x06, 0xA9, 0x0B, 0xB2, 0x0F, 0x82, 0x10, 0xAE, 0x0D,
3587 0xA2, 0x08, 0xAB, 0x03, 0x82, 0x00, 0x73, 0xFF, 0x9D, 0xFF, 0xF0,
3588 0xFF, 0xF3, 0xFF, 0xA4, 0xFF, 0x6F, 0xFF, 0x5D, 0x00, 0x5B, 0x03,
3589 0x3B, 0x08, 0x5A, 0x0D, 0x6A, 0x10, 0xE2, 0x0F, 0x09, 0x0C, 0xC1,
3590 0x06, 0x4C, 0x02, 0xEC, 0xFF, 0x6E, 0xFF, 0xC0, 0xFF, 0xFC, 0xFF,
3591 0xDF, 0xFF, 0x83, 0xFF, 0x93, 0xFF, 0x2A, 0x01, 0xEC, 0x04, 0x22,
3592 0x0A, 0xC8, 0x0E, 0xAB, 0x10, 0xD4, 0x0E, 0x35, 0x0A, 0xFD, 0x04,
3593 0x33, 0x01, 0x95, 0xFF, 0x82, 0xFF, 0xDE, 0xFF, 0x00, 0x00, 0xFD,
3594 0xFF, 0xC1, 0xFF, 0x6E, 0xFF, 0xE8, 0xFF, 0x40, 0x02, 0xAF, 0x06,
3595 0xF7, 0x0B, 0xDA, 0x0F, 0x6F, 0x10, 0x6A, 0x0D, 0x4E, 0x08, 0x6A,
3596 0x03, 0x64, 0x00, 0x70, 0xFF, 0xA3, 0xFF, 0xF3, 0xFF, 0xF1, 0xFF,
3597 0x9E, 0xFF, 0x72, 0xFF, 0x7B, 0x00, 0x9C, 0x03, 0x90, 0x08, 0x9F,
3598 0x0D, 0x7E, 0x10, 0xBB, 0x0F, 0xBA, 0x0B, 0x70, 0x06, 0x16, 0x02,
3599 0xD9, 0xFF, 0x70, 0xFF, 0xC5, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xDA,
3600 0xFF, 0x7E, 0xFF, 0x9D, 0xFF, 0x55, 0x01, 0x37, 0x05, 0x75, 0x0A,
3601 0xFF, 0x0E, 0xA9, 0x10, 0x9C, 0x0E, 0xE1, 0x09, 0xB3, 0x04, 0x0A,
3602 0x01, 0x8B, 0xFF, 0x87, 0xFF, 0xE2, 0xFF, 0xFB, 0xFF, 0xBB, 0xFF,
3603 0x6D, 0xFF, 0xFD, 0xFF, 0x77, 0x02, 0x01, 0x07, 0x45, 0x0C, 0xFF,
3604 0x0F, 0x58, 0x10, 0x23, 0x0D, 0xFA, 0x07, 0x2A, 0x03, 0x47, 0x00,
3605 0x6E, 0xFF, 0xA9, 0xFF, 0xF5, 0xFF, 0xED, 0xFF, 0x98, 0xFF, 0x77,
3606 0xFF, 0x9C, 0x00, 0xDF, 0x03, 0xE4, 0x08, 0xE2, 0x0D, 0x8E, 0x10,
3607 0x91, 0x0F, 0x6B, 0x0B, 0x20, 0x06, 0xE3, 0x01, 0xC8, 0xFF, 0x73,
3608 0xFF, 0xCB, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xD5, 0xFF, 0x7A, 0xFF,
3609 0xAA, 0xFF, 0x82, 0x01, 0x83, 0x05, 0xC8, 0x0A, 0x32, 0x0F, 0xA4,
3610 0x10, 0x60, 0x0E, 0x8D, 0x09, 0x6B, 0x04, 0xE3, 0x00, 0x83, 0xFF,
3611 0x8D, 0xFF, 0xE6, 0xFF, 0xFA, 0xFF, 0xB5, 0xFF, 0x6C, 0xFF, 0x14,
3612 0x00, 0xB1, 0x02, 0x53, 0x07, 0x91, 0x0C, 0x20, 0x10, 0x3E, 0x10,
3613 0xDB, 0x0C, 0xA6, 0x07, 0xEC, 0x02, 0x2C, 0x00, 0x6C, 0xFF, 0xAF,
3614 0xFF, 0xF8, 0xFF, 0xEA, 0xFF, 0x92, 0xFF, 0x7C, 0xFF, 0xBE, 0x00,
3615 0x24, 0x04, 0x38, 0x09, 0x22, 0x0E, 0x9B, 0x10, 0x63, 0x0F, 0x1A,
3616 0x0B, 0xD1, 0x05, 0xB1, 0x01, 0xB8, 0xFF, 0x76, 0xFF, 0xD0, 0xFF,
3617 0xFF, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0x76, 0xFF, 0xB8, 0xFF, 0xB1,
3618 0x01, 0xD1, 0x05, 0x1A, 0x0B, 0x63, 0x0F, 0x9B, 0x10, 0x22, 0x0E,
3619 0x38, 0x09, 0x24, 0x04, 0xBE, 0x00, 0x7C, 0xFF, 0x92, 0xFF, 0xEA,
3620 0xFF, 0xF8, 0xFF, 0xAF, 0xFF, 0x6C, 0xFF, 0x2C, 0x00, 0xEC, 0x02,
3621 0xA6, 0x07, 0xDB, 0x0C, 0x3E, 0x10, 0x20, 0x10, 0x91, 0x0C, 0x53,
3622 0x07, 0xB1, 0x02, 0x14, 0x00, 0x6C, 0xFF, 0xB5, 0xFF, 0xFA, 0xFF,
3623 0xE6, 0xFF, 0x8D, 0xFF, 0x83, 0xFF, 0xE3, 0x00, 0x6B, 0x04, 0x8D,
3624 0x09, 0x60, 0x0E, 0xA4, 0x10, 0x32, 0x0F, 0xC8, 0x0A, 0x83, 0x05,
3625 0x82, 0x01, 0xAA, 0xFF, 0x7A, 0xFF, 0xD5, 0xFF, 0x00, 0x00, 0xFF,
3626 0xFF, 0xCB, 0xFF, 0x73, 0xFF, 0xC8, 0xFF, 0xE3, 0x01, 0x20, 0x06,
3627 0x6B, 0x0B, 0x91, 0x0F, 0x8E, 0x10, 0xE2, 0x0D, 0xE4, 0x08, 0xDF,
3628 0x03, 0x9C, 0x00, 0x77, 0xFF, 0x98, 0xFF, 0xED, 0xFF, 0xF5, 0xFF,
3629 0xA9, 0xFF, 0x6E, 0xFF, 0x47, 0x00, 0x2A, 0x03, 0xFA, 0x07, 0x23,
3630 0x0D, 0x58, 0x10, 0xFF, 0x0F, 0x45, 0x0C, 0x01, 0x07, 0x77, 0x02,
3631 0xFD, 0xFF, 0x6D, 0xFF, 0xBB, 0xFF, 0xFB, 0xFF, 0xE2, 0xFF, 0x87,
3632 0xFF, 0x8B, 0xFF, 0x0A, 0x01, 0xB3, 0x04, 0xE1, 0x09, 0x9C, 0x0E,
3633 0xA9, 0x10, 0xFF, 0x0E, 0x75, 0x0A, 0x37, 0x05, 0x55, 0x01, 0x9D,
3634 0xFF, 0x7E, 0xFF, 0xDA, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xC5, 0xFF,
3635 0x70, 0xFF, 0xD9, 0xFF, 0x16, 0x02, 0x70, 0x06, 0xBA, 0x0B, 0xBB,
3636 0x0F, 0x7E, 0x10, 0x9F, 0x0D, 0x90, 0x08, 0x9C, 0x03, 0x7B, 0x00,
3637 0x72, 0xFF, 0x9E, 0xFF, 0xF1, 0xFF, 0xF3, 0xFF, 0xA3, 0xFF, 0x70,
3638 0xFF, 0x64, 0x00, 0x6A, 0x03, 0x4E, 0x08, 0x6A, 0x0D, 0x6F, 0x10,
3639 0xDA, 0x0F, 0xF7, 0x0B, 0xAF, 0x06, 0x40, 0x02, 0xE8, 0xFF, 0x6E,
3640 0xFF, 0xC1, 0xFF, 0xFD, 0xFF, 0x00, 0x00, 0xDE, 0xFF, 0x82, 0xFF,
3641 0x95, 0xFF, 0x33, 0x01, 0xFD, 0x04, 0x35, 0x0A, 0xD4, 0x0E, 0xAB,
3642 0x10, 0xC8, 0x0E, 0x22, 0x0A, 0xEC, 0x04, 0x2A, 0x01, 0x93, 0xFF,
3643 0x83, 0xFF, 0xDF, 0xFF, 0xFC, 0xFF, 0xC0, 0xFF, 0x6E, 0xFF, 0xEC,
3644 0xFF, 0x4C, 0x02, 0xC1, 0x06, 0x09, 0x0C, 0xE2, 0x0F, 0x6A, 0x10,
3645 0x5A, 0x0D, 0x3B, 0x08, 0x5B, 0x03, 0x5D, 0x00, 0x6F, 0xFF, 0xA4,
3646 0xFF, 0xF3, 0xFF, 0xF0, 0xFF, 0x9D, 0xFF, 0x73, 0xFF, 0x82, 0x00,
3647 0xAB, 0x03, 0xA2, 0x08, 0xAE, 0x0D, 0x82, 0x10, 0xB2, 0x0F, 0xA9,
3648 0x0B, 0x5E, 0x06, 0x0B, 0x02, 0xD5, 0xFF, 0x70, 0xFF, 0xC7, 0xFF,
3649 0xFE, 0xFF, 0x00, 0x00, 0xD9, 0xFF, 0x7D, 0xFF, 0xA0, 0xFF, 0x5F,
3650 0x01, 0x48, 0x05, 0x88, 0x0A, 0x0A, 0x0F, 0xA8, 0x10, 0x8F, 0x0E,
3651 0xCE, 0x09, 0xA3, 0x04, 0x01, 0x01, 0x89, 0xFF, 0x88, 0xFF, 0xE3,
3652 0xFF, 0xFB, 0xFF, 0xBA, 0xFF, 0x6D, 0xFF, 0x02, 0x00, 0x84, 0x02,
3653 0x13, 0x07, 0x56, 0x0C, 0x06, 0x10, 0x52, 0x10, 0x13, 0x0D, 0xE7,
3654 0x07, 0x1C, 0x03, 0x41, 0x00, 0x6D, 0xFF, 0xAA, 0xFF, 0xF6, 0xFF,
3655 0xED, 0xFF, 0x97, 0xFF, 0x78, 0xFF, 0xA3, 0x00, 0xEF, 0x03, 0xF7,
3656 0x08, 0xF0, 0x0D, 0x91, 0x10, 0x87, 0x0F, 0x59, 0x0B, 0x0E, 0x06,
3657 0xD7, 0x01, 0xC4, 0xFF, 0x73, 0xFF, 0xCC, 0xFF, 0xFF, 0xFF, 0x00,
3658 0x00, 0xD4, 0xFF, 0x79, 0xFF, 0xAD, 0xFF, 0x8C, 0x01, 0x95, 0x05,
3659 0xDA, 0x0A, 0x3D, 0x0F, 0xA2, 0x10, 0x53, 0x0E, 0x7A, 0x09, 0x5B,
3660 0x04, 0xDB, 0x00, 0x81, 0xFF, 0x8E, 0xFF, 0xE7, 0xFF, 0xF9, 0xFF,
3661 0xB4, 0xFF, 0x6C, 0xFF, 0x19, 0x00, 0xBE, 0x02, 0x65, 0x07, 0xA1,
3662 0x0C, 0x27, 0x10, 0x37, 0x10, 0xCA, 0x0C, 0x94, 0x07, 0xDF, 0x02,
3663 0x27, 0x00, 0x6C, 0xFF, 0xB0, 0xFF, 0xF8, 0xFF, 0xE9, 0xFF, 0x91,
3664 0xFF, 0x7D, 0xFF, 0xC6, 0x00, 0x34, 0x04, 0x4B, 0x09, 0x30, 0x0E,
3665 0x9D, 0x10, 0x58, 0x0F, 0x08, 0x0B, 0xC0, 0x05, 0xA6, 0x01, 0xB5,
3666 0xFF, 0x77, 0xFF, 0xD1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0xFF,
3667 0x75, 0xFF, 0xBB, 0xFF, 0xBC, 0x01, 0xE3, 0x05, 0x2C, 0x0B, 0x6D,
3668 0x0F, 0x98, 0x10, 0x14, 0x0E, 0x26, 0x09, 0x15, 0x04, 0xB7, 0x00,
3669 0x7B, 0xFF, 0x93, 0xFF, 0xEB, 0xFF, 0xF7, 0xFF, 0xAE, 0xFF, 0x6D,
3670 0xFF, 0x32, 0x00, 0xFA, 0x02, 0xB9, 0x07, 0xEB, 0x0C, 0x44, 0x10,
3671 0x19, 0x10, 0x80, 0x0C, 0x41, 0x07, 0xA4, 0x02, 0x0E, 0x00, 0x6C,
3672 0xFF, 0xB6, 0xFF, 0xFA, 0xFF, 0xE5, 0xFF, 0x8B, 0xFF, 0x85, 0xFF,
3673 0xEC, 0x00, 0x7B, 0x04, 0xA0, 0x09, 0x6E, 0x0E, 0xA5, 0x10, 0x27,
3674 0x0F, 0xB6, 0x0A, 0x72, 0x05, 0x78, 0x01, 0xA7, 0xFF, 0x7B, 0xFF,
3675 0xD6, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xCA, 0xFF, 0x72, 0xFF, 0xCB,
3676 0xFF, 0xEE, 0x01, 0x32, 0x06, 0x7C, 0x0B, 0x9A, 0x0F, 0x8B, 0x10,
3677 0xD3, 0x0D, 0xD1, 0x08, 0xD0, 0x03, 0x94, 0x00, 0x76, 0xFF, 0x99,
3678 0xFF, 0xEE, 0xFF, 0xF5, 0xFF, 0xA7, 0xFF, 0x6E, 0xFF, 0x4D, 0x00,
3679 0x38, 0x03, 0x0D, 0x08, 0x33, 0x0D, 0x5D, 0x10, 0xF7, 0x0F, 0x34,
3680 0x0C, 0xEE, 0x06, 0x6B, 0x02, 0xF8, 0xFF, 0x6D, 0xFF, 0xBC, 0xFF,
3681 0xFC, 0xFF, 0xE1, 0xFF, 0x86, 0xFF, 0x8D, 0xFF, 0x13, 0x01, 0xC3,
3682 0x04, 0xF4, 0x09, 0xA8, 0x0E, 0xAA, 0x10, 0xF3, 0x0E, 0x63, 0x0A,
3683 0x26, 0x05, 0x4B, 0x01, 0x9B, 0xFF, 0x7F, 0xFF, 0xDB, 0xFF, 0x00,
3684 0x00, 0xFD, 0xFF, 0xC4, 0xFF, 0x6F, 0xFF, 0xDD, 0xFF, 0x22, 0x02,
3685 0x82, 0x06, 0xCC, 0x0B, 0xC4, 0x0F, 0x7A, 0x10, 0x90, 0x0D, 0x7D,
3686 0x08, 0x8E, 0x03, 0x74, 0x00, 0x72, 0xFF, 0x9F, 0xFF, 0xF1, 0xFF,
3687 0xF2, 0xFF, 0xA1, 0xFF, 0x70, 0xFF, 0x6A, 0x00, 0x78, 0x03, 0x61,
3688 0x08, 0x79, 0x0D, 0x73, 0x10, 0xD1, 0x0F, 0xE6, 0x0B, 0x9D, 0x06,
3689 0x34, 0x02, 0xE4, 0xFF, 0x6F, 0xFF, 0xC2, 0xFF, 0xFD, 0xFF, 0x00,
3690 0x00, 0xDD, 0xFF, 0x81, 0xFF, 0x97, 0xFF, 0x3D, 0x01, 0x0D, 0x05,
3691 0x47, 0x0A, 0xE1, 0x0E, 0xAA, 0x10, 0xBB, 0x0E, 0x10, 0x0A, 0xDC,
3692 0x04, 0x21, 0x01, 0x90, 0xFF, 0x84, 0xFF, 0xE0, 0xFF, 0xFC, 0xFF,
3693 0xBE, 0xFF, 0x6D, 0xFF, 0xF1, 0xFF, 0x58, 0x02, 0xD3, 0x06, 0x1A,
3694 0x0C, 0xEB, 0x0F, 0x65, 0x10, 0x4B, 0x0D, 0x29, 0x08, 0x4D, 0x03,
3695 0x57, 0x00, 0x6F, 0xFF, 0xA5, 0xFF, 0xF4, 0xFF, 0xEF, 0xFF, 0x9B,
3696 0xFF, 0x74, 0xFF, 0x8A, 0x00, 0xBA, 0x03, 0xB5, 0x08, 0xBD, 0x0D,
3697 0x86, 0x10, 0xA9, 0x0F, 0x97, 0x0B, 0x4C, 0x06, 0xFF, 0x01, 0xD1,
3698 0xFF, 0x71, 0xFF, 0xC8, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xD8, 0xFF,
3699 0x7C, 0xFF, 0xA3, 0xFF, 0x69, 0x01, 0x59, 0x05, 0x9A, 0x0A, 0x16,
3700 0x0F, 0xA7, 0x10, 0x82, 0x0E, 0xBC, 0x09, 0x93, 0x04, 0xF9, 0x00,
3701 0x87, 0xFF, 0x89, 0xFF, 0xE4, 0xFF, 0xFB, 0xFF, 0xB8, 0xFF, 0x6C,
3702 0xFF, 0x07, 0x00, 0x91, 0x02, 0x25, 0x07, 0x67, 0x0C, 0x0E, 0x10,
3703 0x4D, 0x10, 0x03, 0x0D, 0xD5, 0x07, 0x0E, 0x03, 0x3B, 0x00, 0x6D,
3704 0xFF, 0xAC, 0xFF, 0xF7, 0xFF, 0xEC, 0xFF, 0x95, 0xFF, 0x79, 0xFF,
3705 0xAB, 0x00, 0xFE, 0x03, 0x0A, 0x09, 0xFF, 0x0D, 0x94, 0x10, 0x7D,
3706 0x0F, 0x47, 0x0B, 0xFD, 0x05, 0xCC, 0x01, 0xC0, 0xFF, 0x74, 0xFF,
3707 0xCD, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xD3, 0xFF, 0x78, 0xFF, 0xB0,
3708 0xFF, 0x97, 0x01, 0xA6, 0x05, 0xEC, 0x0A, 0x48, 0x0F, 0xA0, 0x10,
3709 0x45, 0x0E, 0x67, 0x09, 0x4B, 0x04, 0xD3, 0x00, 0x80, 0xFF, 0x8F,
3710 0xFF, 0xE8, 0xFF, 0xF9, 0xFF, 0xB2, 0xFF, 0x6C, 0xFF, 0x1E, 0x00,
3711 0xCB, 0x02, 0x78, 0x07, 0xB2, 0x0C, 0x2E, 0x10, 0x31, 0x10, 0xBA,
3712 0x0C, 0x81, 0x07, 0xD2, 0x02, 0x21, 0x00, 0x6C, 0xFF, 0xB2, 0xFF,
3713 0xF9, 0xFF, 0xE8, 0xFF, 0x90, 0xFF, 0x7F, 0xFF, 0xCF, 0x00, 0x43,
3714 0x04, 0x5E, 0x09, 0x3E, 0x0E, 0x9F, 0x10, 0x4E, 0x0F, 0xF6, 0x0A,
3715 0xAE, 0x05, 0x9C, 0x01, 0xB1, 0xFF, 0x78, 0xFF, 0xD2, 0xFF, 0xFF,
3716 0xFF, 0xFF, 0xFF, 0xCE, 0xFF, 0x74, 0xFF, 0xBF, 0xFF, 0xC7, 0x01,
3717 0xF4, 0x05, 0x3E, 0x0B, 0x78, 0x0F, 0x96, 0x10, 0x06, 0x0E, 0x13,
3718 0x09, 0x05, 0x04, 0xAF, 0x00, 0x79, 0xFF, 0x95, 0xFF, 0xEC, 0xFF,
3719 0xF7, 0xFF, 0xAC, 0xFF, 0x6D, 0xFF, 0x38, 0x00, 0x07, 0x03, 0xCB,
3720 0x07, 0xFB, 0x0C, 0x4A, 0x10, 0x11, 0x10, 0x6F, 0x0C, 0x2E, 0x07,
3721 0x97, 0x02, 0x09, 0x00, 0x6C, 0xFF, 0xB8, 0xFF, 0xFA, 0xFF, 0xE4,
3722 0xFF, 0x8A, 0xFF, 0x86, 0xFF, 0xF4, 0x00, 0x8B, 0x04, 0xB2, 0x09,
3723 0x7B, 0x0E, 0xA7, 0x10, 0x1C, 0x0F, 0xA3, 0x0A, 0x61, 0x05, 0x6E,
3724 0x01, 0xA4, 0xFF, 0x7C, 0xFF, 0xD8, 0xFF, 0x00, 0x00, 0xFE, 0xFF,
3725 0xC8, 0xFF, 0x71, 0xFF, 0xCF, 0xFF, 0xF9, 0x01, 0x43, 0x06, 0x8E,
3726 0x0B, 0xA4, 0x0F, 0x88, 0x10, 0xC4, 0x0D, 0xBE, 0x08, 0xC1, 0x03,
3727 0x8D, 0x00, 0x75, 0xFF, 0x9B, 0xFF, 0xEF, 0xFF, 0xF4, 0xFF, 0xA6,
3728 0xFF, 0x6E, 0xFF, 0x53, 0x00, 0x46, 0x03, 0x1F, 0x08, 0x43, 0x0D,
3729 0x63, 0x10, 0xEF, 0x0F, 0x23, 0x0C, 0xDC, 0x06, 0x5E, 0x02, 0xF3,
3730 0xFF, 0x6D, 0xFF, 0xBE, 0xFF, 0xFC, 0xFF, 0xE0, 0xFF, 0x85, 0xFF,
3731 0x8F, 0xFF, 0x1C, 0x01, 0xD3, 0x04, 0x06, 0x0A, 0xB5, 0x0E, 0xAA,
3732 0x10, 0xE7, 0x0E, 0x50, 0x0A, 0x16, 0x05, 0x42, 0x01, 0x98, 0xFF,
3733 0x80, 0xFF, 0xDC, 0xFF, 0x00, 0x00, 0xFD, 0xFF, 0xC3, 0xFF, 0x6F,
3734 0xFF, 0xE1, 0xFF, 0x2E, 0x02, 0x94, 0x06, 0xDD, 0x0B, 0xCD, 0x0F,
3735 0x76, 0x10, 0x81, 0x0D, 0x6A, 0x08, 0x7F, 0x03, 0x6E, 0x00, 0x71,
3736 0xFF, 0xA1, 0xFF, 0xF2, 0xFF, 0x00, 0x00, 0x15, 0x00, 0xD1, 0xFF,
3737 0x8B, 0xFE, 0xBC, 0xFD, 0xE1, 0x00, 0x84, 0x09, 0xB0, 0x13, 0x47,
3738 0x18, 0xB0, 0x13, 0x84, 0x09, 0xE1, 0x00, 0xBC, 0xFD, 0x8B, 0xFE,
3739 0xD1, 0xFF, 0x15, 0x00, 0xFD, 0xFF, 0x13, 0x00, 0xDA, 0x00, 0x30,
3740 0x00, 0x5D, 0xFC, 0xB3, 0xFC, 0x35, 0x0A, 0xC2, 0x1C, 0x24, 0x20,
3741 0x48, 0x10, 0x5D, 0xFF, 0x74, 0xFB, 0x3A, 0xFF, 0xFB, 0x00, 0x42,
3742 0x00, 0xF8, 0xFF, 0xFA, 0xFF, 0x2C, 0x00, 0xF3, 0x00, 0xAD, 0xFF,
3743 0xC5, 0xFB, 0x11, 0xFE, 0xAF, 0x0D, 0xEF, 0x1E, 0x68, 0x1E, 0xBC,
3744 0x0C, 0xA7, 0xFD, 0xEA, 0xFB, 0xD3, 0xFF, 0xEE, 0x00, 0x24, 0x00,
3745 0xFA, 0xFF, 0xF7, 0xFF, 0x4C, 0x00, 0xFB, 0x00, 0x0C, 0xFF, 0x5F,
3746 0xFB, 0xE8, 0xFF, 0x3D, 0x11, 0x7E, 0x20, 0x13, 0x1C, 0x4C, 0x09,
3747 0x6A, 0xFC, 0x8C, 0xFC, 0x4E, 0x00, 0xD1, 0x00, 0x0E, 0x00, 0xFD,
3748 0xFF, 0xF7, 0xFF, 0x72, 0x00, 0xEC, 0x00, 0x55, 0xFE, 0x3D, 0xFB,
3749 0x37, 0x02, 0xBE, 0x14, 0x5D, 0x21, 0x40, 0x19, 0x18, 0x06, 0xA2,
3750 0xFB, 0x47, 0xFD, 0xA7, 0x00, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00,
3751 0x00, 0x00, 0xFC, 0xFF, 0x9B, 0x00, 0xC0, 0x00, 0x92, 0xFD, 0x73,
3752 0xFB, 0xF2, 0x04, 0x0E, 0x18, 0x81, 0x21, 0x0C, 0x16, 0x37, 0x03,
3753 0x47, 0xFB, 0x0B, 0xFE, 0xDF, 0x00, 0x82, 0x00, 0xF9, 0xFF, 0xFE,
3754 0xFF, 0x08, 0x00, 0xC3, 0x00, 0x74, 0x00, 0xD2, 0xFC, 0x10, 0xFC,
3755 0x08, 0x08, 0x0A, 0x1B, 0xE9, 0x20, 0x9A, 0x12, 0xBE, 0x00, 0x49,
3756 0xFB, 0xC8, 0xFE, 0xF9, 0x00, 0x5A, 0x00, 0xF7, 0xFF, 0xFC, 0xFF,
3757 0x1B, 0x00, 0xE4, 0x00, 0x06, 0x00, 0x24, 0xFC, 0x1E, 0xFD, 0x65,
3758 0x0B, 0x94, 0x1D, 0x9D, 0x1F, 0x0D, 0x0F, 0xB8, 0xFE, 0x96, 0xFB,
3759 0x72, 0xFF, 0xF9, 0x00, 0x37, 0x00, 0xF8, 0xFF, 0xF9, 0xFF, 0x36,
3760 0x00, 0xF8, 0x00, 0x78, 0xFF, 0x9B, 0xFB, 0xA6, 0xFE, 0xE9, 0x0E,
3761 0x8D, 0x1F, 0xAA, 0x1D, 0x87, 0x0B, 0x2B, 0xFD, 0x1E, 0xFC, 0x02,
3762 0x00, 0xE5, 0x00, 0x1C, 0x00, 0xFB, 0xFF, 0xF7, 0xFF, 0x58, 0x00,
3763 0xF9, 0x00, 0xCF, 0xFE, 0x4A, 0xFB, 0xA7, 0x00, 0x77, 0x12, 0xE0,
3764 0x20, 0x26, 0x1B, 0x28, 0x08, 0x18, 0xFC, 0xCB, 0xFC, 0x71, 0x00,
3765 0xC5, 0x00, 0x08, 0x00, 0xFE, 0xFF, 0xF8, 0xFF, 0x80, 0x00, 0xE1,
3766 0x00, 0x13, 0xFE, 0x45, 0xFB, 0x1D, 0x03, 0xEB, 0x15, 0x7F, 0x21,
3767 0x2D, 0x18, 0x0E, 0x05, 0x77, 0xFB, 0x8B, 0xFD, 0xBE, 0x00, 0x9D,
3768 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xA9, 0x00,
3769 0xAA, 0x00, 0x4F, 0xFD, 0x9D, 0xFB, 0xFA, 0x05, 0x22, 0x19, 0x62,
3770 0x21, 0xE0, 0x14, 0x50, 0x02, 0x3E, 0xFB, 0x4E, 0xFE, 0xEB, 0x00,
3771 0x73, 0x00, 0xF7, 0xFF, 0xFE, 0xFF, 0x0D, 0x00, 0xD0, 0x00, 0x52,
3772 0x00, 0x93, 0xFC, 0x60, 0xFC, 0x2C, 0x09, 0xFA, 0x1B, 0x8A, 0x20,
3773 0x60, 0x11, 0xFD, 0xFF, 0x5C, 0xFB, 0x06, 0xFF, 0xFB, 0x00, 0x4D,
3774 0x00, 0xF7, 0xFF, 0xFA, 0xFF, 0x23, 0x00, 0xED, 0x00, 0xD9, 0xFF,
3775 0xEF, 0xFB, 0x98, 0xFD, 0x99, 0x0C, 0x54, 0x1E, 0x02, 0x1F, 0xD2,
3776 0x0D, 0x20, 0xFE, 0xC0, 0xFB, 0xA7, 0xFF, 0xF4, 0x00, 0x2D, 0x00,
3777 0xF9, 0xFF, 0xF8, 0xFF, 0x41, 0x00, 0xFB, 0x00, 0x41, 0xFF, 0x78,
3778 0xFB, 0x4A, 0xFF, 0x25, 0x10, 0x16, 0x20, 0xDA, 0x1C, 0x56, 0x0A,
3779 0xBE, 0xFC, 0x56, 0xFC, 0x2C, 0x00, 0xDB, 0x00, 0x14, 0x00, 0xFD,
3780 0xFF, 0xF7, 0xFF, 0x66, 0x00, 0xF4, 0x00, 0x8F, 0xFE, 0x3F, 0xFB,
3781 0x75, 0x01, 0xAE, 0x13, 0x2C, 0x21, 0x2A, 0x1A, 0x0D, 0x07, 0xD4,
3782 0xFB, 0x0C, 0xFD, 0x8F, 0x00, 0xB7, 0x00, 0x03, 0x00, 0xFF, 0xFF,
3783 0x00, 0x00, 0xFA, 0xFF, 0x8E, 0x00, 0xD1, 0x00, 0xCF, 0xFD, 0x58,
3784 0xFB, 0x10, 0x04, 0x10, 0x17, 0x8A, 0x21, 0x10, 0x17, 0x10, 0x04,
3785 0x58, 0xFB, 0xCF, 0xFD, 0xD1, 0x00, 0x8E, 0x00, 0xFA, 0xFF, 0xFF,
3786 0xFF, 0x03, 0x00, 0xB7, 0x00, 0x8F, 0x00, 0x0C, 0xFD, 0xD4, 0xFB,
3787 0x0D, 0x07, 0x2A, 0x1A, 0x2C, 0x21, 0xAE, 0x13, 0x75, 0x01, 0x3F,
3788 0xFB, 0x8F, 0xFE, 0xF4, 0x00, 0x66, 0x00, 0xF7, 0xFF, 0xFD, 0xFF,
3789 0x14, 0x00, 0xDB, 0x00, 0x2C, 0x00, 0x56, 0xFC, 0xBE, 0xFC, 0x56,
3790 0x0A, 0xDA, 0x1C, 0x16, 0x20, 0x25, 0x10, 0x4A, 0xFF, 0x78, 0xFB,
3791 0x41, 0xFF, 0xFB, 0x00, 0x41, 0x00, 0xF8, 0xFF, 0xF9, 0xFF, 0x2D,
3792 0x00, 0xF4, 0x00, 0xA7, 0xFF, 0xC0, 0xFB, 0x20, 0xFE, 0xD2, 0x0D,
3793 0x02, 0x1F, 0x54, 0x1E, 0x99, 0x0C, 0x98, 0xFD, 0xEF, 0xFB, 0xD9,
3794 0xFF, 0xED, 0x00, 0x23, 0x00, 0xFA, 0xFF, 0xF7, 0xFF, 0x4D, 0x00,
3795 0xFB, 0x00, 0x06, 0xFF, 0x5C, 0xFB, 0xFD, 0xFF, 0x60, 0x11, 0x8A,
3796 0x20, 0xFA, 0x1B, 0x2C, 0x09, 0x60, 0xFC, 0x93, 0xFC, 0x52, 0x00,
3797 0xD0, 0x00, 0x0D, 0x00, 0xFE, 0xFF, 0xF7, 0xFF, 0x73, 0x00, 0xEB,
3798 0x00, 0x4E, 0xFE, 0x3E, 0xFB, 0x50, 0x02, 0xE0, 0x14, 0x62, 0x21,
3799 0x22, 0x19, 0xFA, 0x05, 0x9D, 0xFB, 0x4F, 0xFD, 0xAA, 0x00, 0xA9,
3800 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0x9D, 0x00,
3801 0xBE, 0x00, 0x8B, 0xFD, 0x77, 0xFB, 0x0E, 0x05, 0x2D, 0x18, 0x7F,
3802 0x21, 0xEB, 0x15, 0x1D, 0x03, 0x45, 0xFB, 0x13, 0xFE, 0xE1, 0x00,
3803 0x80, 0x00, 0xF8, 0xFF, 0xFE, 0xFF, 0x08, 0x00, 0xC5, 0x00, 0x71,
3804 0x00, 0xCB, 0xFC, 0x18, 0xFC, 0x28, 0x08, 0x26, 0x1B, 0xE0, 0x20,
3805 0x77, 0x12, 0xA7, 0x00, 0x4A, 0xFB, 0xCF, 0xFE, 0xF9, 0x00, 0x58,
3806 0x00, 0xF7, 0xFF, 0xFB, 0xFF, 0x1C, 0x00, 0xE5, 0x00, 0x02, 0x00,
3807 0x1E, 0xFC, 0x2B, 0xFD, 0x87, 0x0B, 0xAA, 0x1D, 0x8D, 0x1F, 0xE9,
3808 0x0E, 0xA6, 0xFE, 0x9B, 0xFB, 0x78, 0xFF, 0xF8, 0x00, 0x36, 0x00,
3809 0xF9, 0xFF, 0xF8, 0xFF, 0x37, 0x00, 0xF9, 0x00, 0x72, 0xFF, 0x96,
3810 0xFB, 0xB8, 0xFE, 0x0D, 0x0F, 0x9D, 0x1F, 0x94, 0x1D, 0x65, 0x0B,
3811 0x1E, 0xFD, 0x24, 0xFC, 0x06, 0x00, 0xE4, 0x00, 0x1B, 0x00, 0xFC,
3812 0xFF, 0xF7, 0xFF, 0x5A, 0x00, 0xF9, 0x00, 0xC8, 0xFE, 0x49, 0xFB,
3813 0xBE, 0x00, 0x9A, 0x12, 0xE9, 0x20, 0x0A, 0x1B, 0x08, 0x08, 0x10,
3814 0xFC, 0xD2, 0xFC, 0x74, 0x00, 0xC3, 0x00, 0x08, 0x00, 0xFE, 0xFF,
3815 0xF9, 0xFF, 0x82, 0x00, 0xDF, 0x00, 0x0B, 0xFE, 0x47, 0xFB, 0x37,
3816 0x03, 0x0C, 0x16, 0x81, 0x21, 0x0E, 0x18, 0xF2, 0x04, 0x73, 0xFB,
3817 0x92, 0xFD, 0xC0, 0x00, 0x9B, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00,
3818 0x00, 0x00, 0x00, 0xAB, 0x00, 0xA7, 0x00, 0x47, 0xFD, 0xA2, 0xFB,
3819 0x18, 0x06, 0x40, 0x19, 0x5D, 0x21, 0xBE, 0x14, 0x37, 0x02, 0x3D,
3820 0xFB, 0x55, 0xFE, 0xEC, 0x00, 0x72, 0x00, 0xF7, 0xFF, 0xFD, 0xFF,
3821 0x0E, 0x00, 0xD1, 0x00, 0x4E, 0x00, 0x8C, 0xFC, 0x6A, 0xFC, 0x4C,
3822 0x09, 0x13, 0x1C, 0x7E, 0x20, 0x3D, 0x11, 0xE8, 0xFF, 0x5F, 0xFB,
3823 0x0C, 0xFF, 0xFB, 0x00, 0x4C, 0x00, 0xF7, 0xFF, 0xFA, 0xFF, 0x24,
3824 0x00, 0xEE, 0x00, 0xD3, 0xFF, 0xEA, 0xFB, 0xA7, 0xFD, 0xBC, 0x0C,
3825 0x68, 0x1E, 0xEF, 0x1E, 0xAF, 0x0D, 0x11, 0xFE, 0xC5, 0xFB, 0xAD,
3826 0xFF, 0xF3, 0x00, 0x2C, 0x00, 0xFA, 0xFF, 0xF8, 0xFF, 0x42, 0x00,
3827 0xFB, 0x00, 0x3A, 0xFF, 0x74, 0xFB, 0x5D, 0xFF, 0x48, 0x10, 0x24,
3828 0x20, 0xC2, 0x1C, 0x35, 0x0A, 0xB3, 0xFC, 0x5D, 0xFC, 0x30, 0x00,
3829 0xDA, 0x00, 0x13, 0x00, 0xFD, 0xFF, 0xF7, 0xFF, 0x67, 0x00, 0xF3,
3830 0x00, 0x88, 0xFE, 0x3E, 0xFB, 0x8C, 0x01, 0xD0, 0x13, 0x33, 0x21,
3831 0x0D, 0x1A, 0xEE, 0x06, 0xCD, 0xFB, 0x13, 0xFD, 0x92, 0x00, 0xB6,
3832 0x00, 0x03, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFA, 0xFF, 0x90, 0x00,
3833 0xCF, 0x00, 0xC7, 0xFD, 0x5B, 0xFB, 0x2B, 0x04, 0x31, 0x17, 0x8A,
3834 0x21, 0xF0, 0x16, 0xF4, 0x03, 0x56, 0xFB, 0xD6, 0xFD, 0xD3, 0x00,
3835 0x8D, 0x00, 0xFA, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0xB9, 0x00, 0x8C,
3836 0x00, 0x05, 0xFD, 0xDB, 0xFB, 0x2C, 0x07, 0x47, 0x1A, 0x25, 0x21,
3837 0x8B, 0x13, 0x5D, 0x01, 0x40, 0xFB, 0x97, 0xFE, 0xF5, 0x00, 0x64,
3838 0x00, 0xF7, 0xFF, 0xFC, 0xFF, 0x15, 0x00, 0xDC, 0x00, 0x27, 0x00,
3839 0x50, 0xFC, 0xCA, 0xFC, 0x78, 0x0A, 0xF2, 0x1C, 0x07, 0x20, 0x02,
3840 0x10, 0x37, 0xFF, 0x7B, 0xFB, 0x47, 0xFF, 0xFB, 0x00, 0x40, 0x00,
3841 0xF8, 0xFF, 0xF9, 0xFF, 0x2E, 0x00, 0xF5, 0x00, 0xA2, 0xFF, 0xBB,
3842 0xFB, 0x31, 0xFE, 0xF5, 0x0D, 0x14, 0x1F, 0x3F, 0x1E, 0x77, 0x0C,
3843 0x8A, 0xFD, 0xF5, 0xFB, 0xDE, 0xFF, 0xEC, 0x00, 0x22, 0x00, 0xFB,
3844 0xFF, 0xF7, 0xFF, 0x4E, 0x00, 0xFB, 0x00, 0xFF, 0xFE, 0x59, 0xFB,
3845 0x11, 0x00, 0x83, 0x11, 0x96, 0x20, 0xE0, 0x1B, 0x0B, 0x09, 0x56,
3846 0xFC, 0x99, 0xFC, 0x56, 0x00, 0xCE, 0x00, 0x0D, 0x00, 0xFE, 0xFF,
3847 0xF8, 0xFF, 0x75, 0x00, 0xEA, 0x00, 0x47, 0xFE, 0x3E, 0xFB, 0x69,
3848 0x02, 0x02, 0x15, 0x66, 0x21, 0x04, 0x19, 0xDC, 0x05, 0x98, 0xFB,
3849 0x56, 0xFD, 0xAD, 0x00, 0xA8, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
3850 0x00, 0xFD, 0xFF, 0x9E, 0x00, 0xBC, 0x00, 0x83, 0xFD, 0x7B, 0xFB,
3851 0x2B, 0x05, 0x4C, 0x18, 0x7C, 0x21, 0xCA, 0x15, 0x03, 0x03, 0x44,
3852 0xFB, 0x1A, 0xFE, 0xE2, 0x00, 0x7E, 0x00, 0xF8, 0xFF, 0xFE, 0xFF,
3853 0x09, 0x00, 0xC6, 0x00, 0x6D, 0x00, 0xC3, 0xFC, 0x20, 0xFC, 0x49,
3854 0x08, 0x41, 0x1B, 0xD6, 0x20, 0x54, 0x12, 0x92, 0x00, 0x4C, 0xFB,
3855 0xD6, 0xFE, 0xFA, 0x00, 0x57, 0x00, 0xF7, 0xFF, 0xFB, 0xFF, 0x1D,
3856 0x00, 0xE6, 0x00, 0xFD, 0xFF, 0x18, 0xFC, 0x38, 0xFD, 0xA9, 0x0B,
3857 0xC0, 0x1D, 0x7C, 0x1F, 0xC6, 0x0E, 0x95, 0xFE, 0x9F, 0xFB, 0x7E,
3858 0xFF, 0xF8, 0x00, 0x35, 0x00, 0xF9, 0xFF, 0xF8, 0xFF, 0x38, 0x00,
3859 0xF9, 0x00, 0x6C, 0xFF, 0x92, 0xFB, 0xC9, 0xFE, 0x2F, 0x0F, 0xAD,
3860 0x1F, 0x7D, 0x1D, 0x42, 0x0B, 0x12, 0xFD, 0x2A, 0xFC, 0x0B, 0x00,
3861 0xE3, 0x00, 0x1A, 0x00, 0xFC, 0xFF, 0xF7, 0xFF, 0x5B, 0x00, 0xF8,
3862 0x00, 0xC1, 0xFE, 0x47, 0xFB, 0xD4, 0x00, 0xBC, 0x12, 0xF3, 0x20,
3863 0xEF, 0x1A, 0xE9, 0x07, 0x08, 0xFC, 0xD9, 0xFC, 0x78, 0x00, 0xC2,
3864 0x00, 0x07, 0x00, 0xFF, 0xFF, 0xF9, 0xFF, 0x83, 0x00, 0xDD, 0x00,
3865 0x04, 0xFE, 0x49, 0xFB, 0x52, 0x03, 0x2D, 0x16, 0x83, 0x21, 0xEF,
3866 0x17, 0xD5, 0x04, 0x6F, 0xFB, 0x9A, 0xFD, 0xC3, 0x00, 0x9A, 0x00,
3867 0xFC, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xAD, 0x00, 0xA4,
3868 0x00, 0x40, 0xFD, 0xA8, 0xFB, 0x36, 0x06, 0x5E, 0x19, 0x58, 0x21,
3869 0x9C, 0x14, 0x1E, 0x02, 0x3D, 0xFB, 0x5D, 0xFE, 0xED, 0x00, 0x70,
3870 0x00, 0xF7, 0xFF, 0xFD, 0xFF, 0x0F, 0x00, 0xD2, 0x00, 0x4A, 0x00,
3871 0x85, 0xFC, 0x74, 0xFC, 0x6D, 0x09, 0x2D, 0x1C, 0x72, 0x20, 0x1A,
3872 0x11, 0xD4, 0xFF, 0x61, 0xFB, 0x13, 0xFF, 0xFC, 0x00, 0x4A, 0x00,
3873 0xF7, 0xFF, 0xFA, 0xFF, 0x25, 0x00, 0xEF, 0x00, 0xCE, 0xFF, 0xE4,
3874 0xFB, 0xB5, 0xFD, 0xDE, 0x0C, 0x7C, 0x1E, 0xDD, 0x1E, 0x8C, 0x0D,
3875 0x01, 0xFE, 0xCA, 0xFB, 0xB3, 0xFF, 0xF3, 0x00, 0x2B, 0x00, 0xFA,
3876 0xFF, 0xF8, 0xFF, 0x44, 0x00, 0xFB, 0x00, 0x34, 0xFF, 0x71, 0xFB,
3877 0x71, 0xFF, 0x6B, 0x10, 0x32, 0x20, 0xA9, 0x1C, 0x13, 0x0A, 0xA8,
3878 0xFC, 0x63, 0xFC, 0x35, 0x00, 0xD9, 0x00, 0x12, 0x00, 0xFD, 0xFF,
3879 0xF7, 0xFF, 0x69, 0x00, 0xF2, 0x00, 0x81, 0xFE, 0x3E, 0xFB, 0xA4,
3880 0x01, 0xF2, 0x13, 0x3A, 0x21, 0xF0, 0x19, 0xCF, 0x06, 0xC7, 0xFB,
3881 0x1B, 0xFD, 0x96, 0x00, 0xB4, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0x00,
3882 0x00, 0xFB, 0xFF, 0x92, 0x00, 0xCD, 0x00, 0xC0, 0xFD, 0x5E, 0xFB,
3883 0x47, 0x04, 0x51, 0x17, 0x8A, 0x21, 0xD0, 0x16, 0xD9, 0x03, 0x53,
3884 0xFB, 0xDE, 0xFD, 0xD5, 0x00, 0x8B, 0x00, 0xFA, 0xFF, 0xFF, 0xFF,
3885 0x04, 0x00, 0xBA, 0x00, 0x89, 0x00, 0xFD, 0xFC, 0xE2, 0xFB, 0x4B,
3886 0x07, 0x63, 0x1A, 0x1D, 0x21, 0x69, 0x13, 0x46, 0x01, 0x41, 0xFB,
3887 0x9E, 0xFE, 0xF5, 0x00, 0x63, 0x00, 0xF7, 0xFF, 0xFC, 0xFF, 0x16,
3888 0x00, 0xDD, 0x00, 0x23, 0x00, 0x49, 0xFC, 0xD5, 0xFC, 0x99, 0x0A,
3889 0x09, 0x1D, 0xF9, 0x1F, 0xDF, 0x0F, 0x24, 0xFF, 0x7F, 0xFB, 0x4D,
3890 0xFF, 0xFB, 0x00, 0x3F, 0x00, 0xF8, 0xFF, 0xF9, 0xFF, 0x2F, 0x00,
3891 0xF5, 0x00, 0x9C, 0xFF, 0xB6, 0xFB, 0x41, 0xFE, 0x17, 0x0E, 0x26,
3892 0x1F, 0x2B, 0x1E, 0x54, 0x0C, 0x7C, 0xFD, 0xFA, 0xFB, 0xE3, 0xFF,
3893 0xEB, 0x00, 0x21, 0x00, 0xFB, 0xFF, 0xF7, 0xFF, 0x50, 0x00, 0xFB,
3894 0x00, 0xF8, 0xFE, 0x57, 0xFB, 0x26, 0x00, 0xA6, 0x11, 0xA1, 0x20,
3895 0xC6, 0x1B, 0xEA, 0x08, 0x4D, 0xFC, 0xA0, 0xFC, 0x5A, 0x00, 0xCD,
3896 0x00, 0x0C, 0x00, 0xFE, 0xFF, 0xF8, 0xFF, 0x77, 0x00, 0xE9, 0x00,
3897 0x3F, 0xFE, 0x3F, 0xFB, 0x82, 0x02, 0x23, 0x15, 0x6B, 0x21, 0xE5,
3898 0x18, 0xBE, 0x05, 0x93, 0xFB, 0x5E, 0xFD, 0xAF, 0x00, 0xA6, 0x00,
3899 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xA0, 0x00, 0xB9,
3900 0x00, 0x7C, 0xFD, 0x80, 0xFB, 0x48, 0x05, 0x6B, 0x18, 0x79, 0x21,
3901 0xA9, 0x15, 0xE9, 0x02, 0x43, 0xFB, 0x21, 0xFE, 0xE3, 0x00, 0x7D,
3902 0x00, 0xF8, 0xFF, 0xFE, 0xFF, 0x09, 0x00, 0xC7, 0x00, 0x69, 0x00,
3903 0xBC, 0xFC, 0x29, 0xFC, 0x69, 0x08, 0x5C, 0x1B, 0xCC, 0x20, 0x32,
3904 0x12, 0x7C, 0x00, 0x4E, 0xFB, 0xDD, 0xFE, 0xFA, 0x00, 0x56, 0x00,
3905 0xF7, 0xFF, 0xFB, 0xFF, 0x1D, 0x00, 0xE7, 0x00, 0xF8, 0xFF, 0x12,
3906 0xFC, 0x45, 0xFD, 0xCB, 0x0B, 0xD6, 0x1D, 0x6C, 0x1F, 0xA3, 0x0E,
3907 0x84, 0xFE, 0xA4, 0xFB, 0x84, 0xFF, 0xF7, 0x00, 0x34, 0x00, 0xF9,
3908 0xFF, 0xF8, 0xFF, 0x3A, 0x00, 0xFA, 0x00, 0x66, 0xFF, 0x8E, 0xFB,
3909 0xDB, 0xFE, 0x53, 0x0F, 0xBD, 0x1F, 0x66, 0x1D, 0x21, 0x0B, 0x05,
3910 0xFD, 0x30, 0xFC, 0x10, 0x00, 0xE2, 0x00, 0x19, 0x00, 0xFC, 0xFF,
3911 0xF7, 0xFF, 0x5D, 0x00, 0xF8, 0x00, 0xBA, 0xFE, 0x46, 0xFB, 0xEA,
3912 0x00, 0xDF, 0x12, 0xFC, 0x20, 0xD3, 0x1A, 0xC9, 0x07, 0x00, 0xFC,
3913 0xE0, 0xFC, 0x7B, 0x00, 0xC0, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0xF9,
3914 0xFF, 0x85, 0x00, 0xDC, 0x00, 0xFC, 0xFD, 0x4A, 0xFB, 0x6C, 0x03,
3915 0x4E, 0x16, 0x85, 0x21, 0xCF, 0x17, 0xB8, 0x04, 0x6C, 0xFB, 0xA2,
3916 0xFD, 0xC5, 0x00, 0x98, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
3917 0x01, 0x00, 0xAE, 0x00, 0xA1, 0x00, 0x38, 0xFD, 0xAE, 0xFB, 0x54,
3918 0x06, 0x7C, 0x19, 0x53, 0x21, 0x7B, 0x14, 0x05, 0x02, 0x3D, 0xFB,
3919 0x64, 0xFE, 0xEE, 0x00, 0x6F, 0x00, 0xF7, 0xFF, 0xFD, 0xFF, 0x0F,
3920 0x00, 0xD4, 0x00, 0x46, 0x00, 0x7E, 0xFC, 0x7E, 0xFC, 0x8E, 0x09,
3921 0x46, 0x1C, 0x66, 0x20, 0xF7, 0x10, 0xC0, 0xFF, 0x64, 0xFB, 0x1A,
3922 0xFF, 0xFC, 0x00, 0x49, 0x00, 0xF7, 0xFF, 0xFA, 0xFF, 0x26, 0x00,
3923 0xF0, 0x00, 0xC9, 0xFF, 0xDF, 0xFB, 0xC4, 0xFD, 0x01, 0x0D, 0x90,
3924 0x1E, 0xCA, 0x1E, 0x69, 0x0D, 0xF1, 0xFD, 0xCF, 0xFB, 0xB8, 0xFF,
3925 0xF2, 0x00, 0x29, 0x00, 0xFA, 0xFF, 0xF7, 0xFF, 0x45, 0x00, 0xFC,
3926 0x00, 0x2D, 0xFF, 0x6D, 0xFB, 0x84, 0xFF, 0x8E, 0x10, 0x3F, 0x20,
3927 0x91, 0x1C, 0xF2, 0x09, 0x9D, 0xFC, 0x6A, 0xFC, 0x39, 0x00, 0xD7,
3928 0x00, 0x12, 0x00, 0xFD, 0xFF, 0xF7, 0xFF, 0x6A, 0x00, 0xF1, 0x00,
3929 0x7A, 0xFE, 0x3D, 0xFB, 0xBC, 0x01, 0x14, 0x14, 0x41, 0x21, 0xD4,
3930 0x19, 0xB0, 0x06, 0xC0, 0xFB, 0x22, 0xFD, 0x99, 0x00, 0xB3, 0x00,
3931 0x02, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFB, 0xFF, 0x93, 0x00, 0xCB,
3932 0x00, 0xB8, 0xFD, 0x61, 0xFB, 0x63, 0x04, 0x71, 0x17, 0x89, 0x21,
3933 0xB0, 0x16, 0xBD, 0x03, 0x51, 0xFB, 0xE6, 0xFD, 0xD7, 0x00, 0x8A,
3934 0x00, 0xFA, 0xFF, 0xFF, 0xFF, 0x05, 0x00, 0xBC, 0x00, 0x86, 0x00,
3935 0xF6, 0xFC, 0xE9, 0xFB, 0x6A, 0x07, 0x80, 0x1A, 0x15, 0x21, 0x47,
3936 0x13, 0x2F, 0x01, 0x42, 0xFB, 0xA5, 0xFE, 0xF6, 0x00, 0x61, 0x00,
3937 0xF7, 0xFF, 0xFC, 0xFF, 0x16, 0x00, 0xDF, 0x00, 0x1E, 0x00, 0x43,
3938 0xFC, 0xE1, 0xFC, 0xBB, 0x0A, 0x21, 0x1D, 0xEA, 0x1F, 0xBC, 0x0F,
3939 0x12, 0xFF, 0x82, 0xFB, 0x54, 0xFF, 0xFA, 0x00, 0x3D, 0x00, 0xF8,
3940 0xFF, 0xF9, 0xFF, 0x30, 0x00, 0xF6, 0x00, 0x96, 0xFF, 0xB1, 0xFB,
3941 0x51, 0xFE, 0x3A, 0x0E, 0x38, 0x1F, 0x16, 0x1E, 0x32, 0x0C, 0x6E,
3942 0xFD, 0x00, 0xFC, 0xE8, 0xFF, 0xEA, 0x00, 0x20, 0x00, 0xFB, 0xFF,
3943 0xF7, 0xFF, 0x51, 0x00, 0xFB, 0x00, 0xF1, 0xFE, 0x54, 0xFB, 0x3B,
3944 0x00, 0xC9, 0x11, 0xAD, 0x20, 0xAC, 0x1B, 0xCA, 0x08, 0x44, 0xFC,
3945 0xA7, 0xFC, 0x5E, 0x00, 0xCC, 0x00, 0x0B, 0x00, 0xFE, 0xFF, 0xF8,
3946 0xFF, 0x78, 0x00, 0xE7, 0x00, 0x38, 0xFE, 0x40, 0xFB, 0x9B, 0x02,
3947 0x45, 0x15, 0x6F, 0x21, 0xC7, 0x18, 0xA1, 0x05, 0x8E, 0xFB, 0x65,
3948 0xFD, 0xB2, 0x00, 0xA5, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x00,
3949 0xFE, 0xFF, 0xA2, 0x00, 0xB7, 0x00, 0x74, 0xFD, 0x84, 0xFB, 0x66,
3950 0x05, 0x8A, 0x18, 0x76, 0x21, 0x87, 0x15, 0xCF, 0x02, 0x41, 0xFB,
3951 0x29, 0xFE, 0xE5, 0x00, 0x7B, 0x00, 0xF8, 0xFF, 0xFE, 0xFF, 0x0A,
3952 0x00, 0xC9, 0x00, 0x66, 0x00, 0xB5, 0xFC, 0x32, 0xFC, 0x89, 0x08,
3953 0x77, 0x1B, 0xC2, 0x20, 0x0F, 0x12, 0x66, 0x00, 0x50, 0xFB, 0xE4,
3954 0xFE, 0xFA, 0x00, 0x54, 0x00, 0xF7, 0xFF, 0xFB, 0xFF, 0x1E, 0x00,
3955 0xE8, 0x00, 0xF3, 0xFF, 0x0C, 0xFC, 0x53, 0xFD, 0xED, 0x0B, 0xEB,
3956 0x1D, 0x5A, 0x1F, 0x80, 0x0E, 0x73, 0xFE, 0xA8, 0xFB, 0x8A, 0xFF,
3957 0xF7, 0x00, 0x32, 0x00, 0xF9, 0xFF, 0xF8, 0xFF, 0x3B, 0x00, 0xFA,
3958 0x00, 0x60, 0xFF, 0x8A, 0xFB, 0xED, 0xFE, 0x76, 0x0F, 0xCC, 0x1F,
3959 0x4F, 0x1D, 0xFF, 0x0A, 0xF9, 0xFC, 0x36, 0xFC, 0x15, 0x00, 0xE1,
3960 0x00, 0x18, 0x00, 0xFC, 0xFF, 0xF7, 0xFF, 0x5E, 0x00, 0xF7, 0x00,
3961 0xB3, 0xFE, 0x44, 0xFB, 0x01, 0x01, 0x02, 0x13, 0x04, 0x21, 0xB8,
3962 0x1A, 0xA9, 0x07, 0xF8, 0xFB, 0xE7, 0xFC, 0x7F, 0x00, 0xBF, 0x00,
3963 0x06, 0x00, 0xFF, 0xFF, 0xF9, 0xFF, 0x86, 0x00, 0xDA, 0x00, 0xF5,
3964 0xFD, 0x4C, 0xFB, 0x87, 0x03, 0x6E, 0x16, 0x86, 0x21, 0xB0, 0x17,
3965 0x9C, 0x04, 0x68, 0xFB, 0xA9, 0xFD, 0xC7, 0x00, 0x96, 0x00, 0xFB,
3966 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xB0, 0x00, 0x9F, 0x00,
3967 0x31, 0xFD, 0xB4, 0xFB, 0x73, 0x06, 0x99, 0x19, 0x4D, 0x21, 0x59,
3968 0x14, 0xED, 0x01, 0x3D, 0xFB, 0x6B, 0xFE, 0xEF, 0x00, 0x6D, 0x00,
3969 0xF7, 0xFF, 0xFD, 0xFF, 0x10, 0x00, 0xD5, 0x00, 0x42, 0x00, 0x77,
3970 0xFC, 0x88, 0xFC, 0xAF, 0x09, 0x5F, 0x1C, 0x59, 0x20, 0xD4, 0x10,
3971 0xAC, 0xFF, 0x67, 0xFB, 0x20, 0xFF, 0xFC, 0x00, 0x48, 0x00, 0xF7,
3972 0xFF, 0xFA, 0xFF, 0x27, 0x00, 0xF0, 0x00, 0xC3, 0xFF, 0xD9, 0xFB,
3973 0xD3, 0xFD, 0x24, 0x0D, 0xA3, 0x1E, 0xB7, 0x1E, 0x46, 0x0D, 0xE2,
3974 0xFD, 0xD4, 0xFB, 0xBE, 0xFF, 0xF1, 0x00, 0x28, 0x00, 0xFA, 0xFF,
3975 0xF7, 0xFF, 0x46, 0x00, 0xFC, 0x00, 0x27, 0xFF, 0x6A, 0xFB, 0x98,
3976 0xFF, 0xB1, 0x10, 0x4C, 0x20, 0x78, 0x1C, 0xD1, 0x09, 0x93, 0xFC,
3977 0x71, 0xFC, 0x3D, 0x00, 0xD6, 0x00, 0x11, 0x00, 0xFD, 0xFF, 0xF7,
3978 0xFF, 0x6C, 0x00, 0xF0, 0x00, 0x72, 0xFE, 0x3D, 0xFB, 0xD4, 0x01,
3979 0x36, 0x14, 0x47, 0x21, 0xB6, 0x19, 0x91, 0x06, 0xBA, 0xFB, 0x29,
3980 0xFD, 0x9C, 0x00, 0xB1, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0x00, 0x00,
3981 0xFB, 0xFF, 0x95, 0x00, 0xC9, 0x00, 0xB1, 0xFD, 0x65, 0xFB, 0x80,
3982 0x04, 0x90, 0x17, 0x88, 0x21, 0x8F, 0x16, 0xA2, 0x03, 0x4E, 0xFB,
3983 0xED, 0xFD, 0xD9, 0x00, 0x88, 0x00, 0xF9, 0xFF, 0xFF, 0xFF, 0x05,
3984 0x00, 0xBD, 0x00, 0x82, 0x00, 0xEF, 0xFC, 0xF0, 0xFB, 0x8A, 0x07,
3985 0x9C, 0x1A, 0x0D, 0x21, 0x24, 0x13, 0x18, 0x01, 0x43, 0xFB, 0xAC,
3986 0xFE, 0xF7, 0x00, 0x60, 0x00, 0xF7, 0xFF, 0xFC, 0xFF, 0x17, 0x00,
3987 0xE0, 0x00, 0x1A, 0x00, 0x3D, 0xFC, 0xED, 0xFC, 0xDD, 0x0A, 0x38,
3988 0x1D, 0xDB, 0x1F, 0x99, 0x0F, 0xFF, 0xFE, 0x86, 0xFB, 0x5A, 0xFF,
3989 0xFA, 0x00, 0x3C, 0x00, 0xF8, 0xFF, 0xF9, 0xFF, 0x31, 0x00, 0xF6,
3990 0x00, 0x90, 0xFF, 0xAD, 0xFB, 0x62, 0xFE, 0x5D, 0x0E, 0x49, 0x1F,
3991 0x01, 0x1E, 0x10, 0x0C, 0x60, 0xFD, 0x06, 0xFC, 0xEE, 0xFF, 0xE9,
3992 0x00, 0x1F, 0x00, 0xFB, 0xFF, 0xF7, 0xFF, 0x53, 0x00, 0xFB, 0x00,
3993 0xEB, 0xFE, 0x52, 0xFB, 0x51, 0x00, 0xEC, 0x11, 0xB7, 0x20, 0x91,
3994 0x1B, 0xA9, 0x08, 0x3B, 0xFC, 0xAE, 0xFC, 0x62, 0x00, 0xCA, 0x00,
3995 0x0B, 0x00, 0xFE, 0xFF, 0xF8, 0xFF, 0x7A, 0x00, 0xE6, 0x00, 0x30,
3996 0xFE, 0x40, 0xFB, 0xB5, 0x02, 0x66, 0x15, 0x73, 0x21, 0xA9, 0x18,
3997 0x83, 0x05, 0x89, 0xFB, 0x6D, 0xFD, 0xB4, 0x00, 0xA3, 0x00, 0xFE,
3998 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xA3, 0x00, 0xB4, 0x00,
3999 0x6D, 0xFD, 0x89, 0xFB, 0x83, 0x05, 0xA9, 0x18, 0x73, 0x21, 0x66,
4000 0x15, 0xB5, 0x02, 0x40, 0xFB, 0x30, 0xFE, 0xE6, 0x00, 0x7A, 0x00,
4001 0xF8, 0xFF, 0xFE, 0xFF, 0x0B, 0x00, 0xCA, 0x00, 0x62, 0x00, 0xAE,
4002 0xFC, 0x3B, 0xFC, 0xA9, 0x08, 0x91, 0x1B, 0xB7, 0x20, 0xEC, 0x11,
4003 0x51, 0x00, 0x52, 0xFB, 0xEB, 0xFE, 0xFB, 0x00, 0x53, 0x00, 0xF7,
4004 0xFF, 0xFB, 0xFF, 0x1F, 0x00, 0xE9, 0x00, 0xEE, 0xFF, 0x06, 0xFC,
4005 0x60, 0xFD, 0x10, 0x0C, 0x01, 0x1E, 0x49, 0x1F, 0x5D, 0x0E, 0x62,
4006 0xFE, 0xAD, 0xFB, 0x90, 0xFF, 0xF6, 0x00, 0x31, 0x00, 0xF9, 0xFF,
4007 0xF8, 0xFF, 0x3C, 0x00, 0xFA, 0x00, 0x5A, 0xFF, 0x86, 0xFB, 0xFF,
4008 0xFE, 0x99, 0x0F, 0xDB, 0x1F, 0x38, 0x1D, 0xDD, 0x0A, 0xED, 0xFC,
4009 0x3D, 0xFC, 0x1A, 0x00, 0xE0, 0x00, 0x17, 0x00, 0xFC, 0xFF, 0xF7,
4010 0xFF, 0x60, 0x00, 0xF7, 0x00, 0xAC, 0xFE, 0x43, 0xFB, 0x18, 0x01,
4011 0x24, 0x13, 0x0D, 0x21, 0x9C, 0x1A, 0x8A, 0x07, 0xF0, 0xFB, 0xEF,
4012 0xFC, 0x82, 0x00, 0xBD, 0x00, 0x05, 0x00, 0xFF, 0xFF, 0xF9, 0xFF,
4013 0x88, 0x00, 0xD9, 0x00, 0xED, 0xFD, 0x4E, 0xFB, 0xA2, 0x03, 0x8F,
4014 0x16, 0x88, 0x21, 0x90, 0x17, 0x80, 0x04, 0x65, 0xFB, 0xB1, 0xFD,
4015 0xC9, 0x00, 0x95, 0x00, 0xFB, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x02,
4016 0x00, 0xB1, 0x00, 0x9C, 0x00, 0x29, 0xFD, 0xBA, 0xFB, 0x91, 0x06,
4017 0xB6, 0x19, 0x47, 0x21, 0x36, 0x14, 0xD4, 0x01, 0x3D, 0xFB, 0x72,
4018 0xFE, 0xF0, 0x00, 0x6C, 0x00, 0xF7, 0xFF, 0xFD, 0xFF, 0x11, 0x00,
4019 0xD6, 0x00, 0x3D, 0x00, 0x71, 0xFC, 0x93, 0xFC, 0xD1, 0x09, 0x78,
4020 0x1C, 0x4C, 0x20, 0xB1, 0x10, 0x98, 0xFF, 0x6A, 0xFB, 0x27, 0xFF,
4021 0xFC, 0x00, 0x46, 0x00, 0xF7, 0xFF, 0xFA, 0xFF, 0x28, 0x00, 0xF1,
4022 0x00, 0xBE, 0xFF, 0xD4, 0xFB, 0xE2, 0xFD, 0x46, 0x0D, 0xB7, 0x1E,
4023 0xA3, 0x1E, 0x24, 0x0D, 0xD3, 0xFD, 0xD9, 0xFB, 0xC3, 0xFF, 0xF0,
4024 0x00, 0x27, 0x00, 0xFA, 0xFF, 0xF7, 0xFF, 0x48, 0x00, 0xFC, 0x00,
4025 0x20, 0xFF, 0x67, 0xFB, 0xAC, 0xFF, 0xD4, 0x10, 0x59, 0x20, 0x5F,
4026 0x1C, 0xAF, 0x09, 0x88, 0xFC, 0x77, 0xFC, 0x42, 0x00, 0xD5, 0x00,
4027 0x10, 0x00, 0xFD, 0xFF, 0xF7, 0xFF, 0x6D, 0x00, 0xEF, 0x00, 0x6B,
4028 0xFE, 0x3D, 0xFB, 0xED, 0x01, 0x59, 0x14, 0x4D, 0x21, 0x99, 0x19,
4029 0x73, 0x06, 0xB4, 0xFB, 0x31, 0xFD, 0x9F, 0x00, 0xB0, 0x00, 0x01,
4030 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFB, 0xFF, 0x96, 0x00, 0xC7, 0x00,
4031 0xA9, 0xFD, 0x68, 0xFB, 0x9C, 0x04, 0xB0, 0x17, 0x86, 0x21, 0x6E,
4032 0x16, 0x87, 0x03, 0x4C, 0xFB, 0xF5, 0xFD, 0xDA, 0x00, 0x86, 0x00,
4033 0xF9, 0xFF, 0xFF, 0xFF, 0x06, 0x00, 0xBF, 0x00, 0x7F, 0x00, 0xE7,
4034 0xFC, 0xF8, 0xFB, 0xA9, 0x07, 0xB8, 0x1A, 0x04, 0x21, 0x02, 0x13,
4035 0x01, 0x01, 0x44, 0xFB, 0xB3, 0xFE, 0xF7, 0x00, 0x5E, 0x00, 0xF7,
4036 0xFF, 0xFC, 0xFF, 0x18, 0x00, 0xE1, 0x00, 0x15, 0x00, 0x36, 0xFC,
4037 0xF9, 0xFC, 0xFF, 0x0A, 0x4F, 0x1D, 0xCC, 0x1F, 0x76, 0x0F, 0xED,
4038 0xFE, 0x8A, 0xFB, 0x60, 0xFF, 0xFA, 0x00, 0x3B, 0x00, 0xF8, 0xFF,
4039 0xF9, 0xFF, 0x32, 0x00, 0xF7, 0x00, 0x8A, 0xFF, 0xA8, 0xFB, 0x73,
4040 0xFE, 0x80, 0x0E, 0x5A, 0x1F, 0xEB, 0x1D, 0xED, 0x0B, 0x53, 0xFD,
4041 0x0C, 0xFC, 0xF3, 0xFF, 0xE8, 0x00, 0x1E, 0x00, 0xFB, 0xFF, 0xF7,
4042 0xFF, 0x54, 0x00, 0xFA, 0x00, 0xE4, 0xFE, 0x50, 0xFB, 0x66, 0x00,
4043 0x0F, 0x12, 0xC2, 0x20, 0x77, 0x1B, 0x89, 0x08, 0x32, 0xFC, 0xB5,
4044 0xFC, 0x66, 0x00, 0xC9, 0x00, 0x0A, 0x00, 0xFE, 0xFF, 0xF8, 0xFF,
4045 0x7B, 0x00, 0xE5, 0x00, 0x29, 0xFE, 0x41, 0xFB, 0xCF, 0x02, 0x87,
4046 0x15, 0x76, 0x21, 0x8A, 0x18, 0x66, 0x05, 0x84, 0xFB, 0x74, 0xFD,
4047 0xB7, 0x00, 0xA2, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFE,
4048 0xFF, 0xA5, 0x00, 0xB2, 0x00, 0x65, 0xFD, 0x8E, 0xFB, 0xA1, 0x05,
4049 0xC7, 0x18, 0x6F, 0x21, 0x45, 0x15, 0x9B, 0x02, 0x40, 0xFB, 0x38,
4050 0xFE, 0xE7, 0x00, 0x78, 0x00, 0xF8, 0xFF, 0xFE, 0xFF, 0x0B, 0x00,
4051 0xCC, 0x00, 0x5E, 0x00, 0xA7, 0xFC, 0x44, 0xFC, 0xCA, 0x08, 0xAC,
4052 0x1B, 0xAD, 0x20, 0xC9, 0x11, 0x3B, 0x00, 0x54, 0xFB, 0xF1, 0xFE,
4053 0xFB, 0x00, 0x51, 0x00, 0xF7, 0xFF, 0xFB, 0xFF, 0x20, 0x00, 0xEA,
4054 0x00, 0xE8, 0xFF, 0x00, 0xFC, 0x6E, 0xFD, 0x32, 0x0C, 0x16, 0x1E,
4055 0x38, 0x1F, 0x3A, 0x0E, 0x51, 0xFE, 0xB1, 0xFB, 0x96, 0xFF, 0xF6,
4056 0x00, 0x30, 0x00, 0xF9, 0xFF, 0xF8, 0xFF, 0x3D, 0x00, 0xFA, 0x00,
4057 0x54, 0xFF, 0x82, 0xFB, 0x12, 0xFF, 0xBC, 0x0F, 0xEA, 0x1F, 0x21,
4058 0x1D, 0xBB, 0x0A, 0xE1, 0xFC, 0x43, 0xFC, 0x1E, 0x00, 0xDF, 0x00,
4059 0x16, 0x00, 0xFC, 0xFF, 0xF7, 0xFF, 0x61, 0x00, 0xF6, 0x00, 0xA5,
4060 0xFE, 0x42, 0xFB, 0x2F, 0x01, 0x47, 0x13, 0x15, 0x21, 0x80, 0x1A,
4061 0x6A, 0x07, 0xE9, 0xFB, 0xF6, 0xFC, 0x86, 0x00, 0xBC, 0x00, 0x05,
4062 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0x8A, 0x00, 0xD7, 0x00, 0xE6, 0xFD,
4063 0x51, 0xFB, 0xBD, 0x03, 0xB0, 0x16, 0x89, 0x21, 0x71, 0x17, 0x63,
4064 0x04, 0x61, 0xFB, 0xB8, 0xFD, 0xCB, 0x00, 0x93, 0x00, 0xFB, 0xFF,
4065 0x00, 0x00, 0xFF, 0xFF, 0x02, 0x00, 0xB3, 0x00, 0x99, 0x00, 0x22,
4066 0xFD, 0xC0, 0xFB, 0xB0, 0x06, 0xD4, 0x19, 0x41, 0x21, 0x14, 0x14,
4067 0xBC, 0x01, 0x3D, 0xFB, 0x7A, 0xFE, 0xF1, 0x00, 0x6A, 0x00, 0xF7,
4068 0xFF, 0xFD, 0xFF, 0x12, 0x00, 0xD7, 0x00, 0x39, 0x00, 0x6A, 0xFC,
4069 0x9D, 0xFC, 0xF2, 0x09, 0x91, 0x1C, 0x3F, 0x20, 0x8E, 0x10, 0x84,
4070 0xFF, 0x6D, 0xFB, 0x2D, 0xFF, 0xFC, 0x00, 0x45, 0x00, 0xF7, 0xFF,
4071 0xFA, 0xFF, 0x29, 0x00, 0xF2, 0x00, 0xB8, 0xFF, 0xCF, 0xFB, 0xF1,
4072 0xFD, 0x69, 0x0D, 0xCA, 0x1E, 0x90, 0x1E, 0x01, 0x0D, 0xC4, 0xFD,
4073 0xDF, 0xFB, 0xC9, 0xFF, 0xF0, 0x00, 0x26, 0x00, 0xFA, 0xFF, 0xF7,
4074 0xFF, 0x49, 0x00, 0xFC, 0x00, 0x1A, 0xFF, 0x64, 0xFB, 0xC0, 0xFF,
4075 0xF7, 0x10, 0x66, 0x20, 0x46, 0x1C, 0x8E, 0x09, 0x7E, 0xFC, 0x7E,
4076 0xFC, 0x46, 0x00, 0xD4, 0x00, 0x0F, 0x00, 0xFD, 0xFF, 0xF7, 0xFF,
4077 0x6F, 0x00, 0xEE, 0x00, 0x64, 0xFE, 0x3D, 0xFB, 0x05, 0x02, 0x7B,
4078 0x14, 0x53, 0x21, 0x7C, 0x19, 0x54, 0x06, 0xAE, 0xFB, 0x38, 0xFD,
4079 0xA1, 0x00, 0xAE, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFC,
4080 0xFF, 0x98, 0x00, 0xC5, 0x00, 0xA2, 0xFD, 0x6C, 0xFB, 0xB8, 0x04,
4081 0xCF, 0x17, 0x85, 0x21, 0x4E, 0x16, 0x6C, 0x03, 0x4A, 0xFB, 0xFC,
4082 0xFD, 0xDC, 0x00, 0x85, 0x00, 0xF9, 0xFF, 0xFF, 0xFF, 0x07, 0x00,
4083 0xC0, 0x00, 0x7B, 0x00, 0xE0, 0xFC, 0x00, 0xFC, 0xC9, 0x07, 0xD3,
4084 0x1A, 0xFC, 0x20, 0xDF, 0x12, 0xEA, 0x00, 0x46, 0xFB, 0xBA, 0xFE,
4085 0xF8, 0x00, 0x5D, 0x00, 0xF7, 0xFF, 0xFC, 0xFF, 0x19, 0x00, 0xE2,
4086 0x00, 0x10, 0x00, 0x30, 0xFC, 0x05, 0xFD, 0x21, 0x0B, 0x66, 0x1D,
4087 0xBD, 0x1F, 0x53, 0x0F, 0xDB, 0xFE, 0x8E, 0xFB, 0x66, 0xFF, 0xFA,
4088 0x00, 0x3A, 0x00, 0xF8, 0xFF, 0xF9, 0xFF, 0x34, 0x00, 0xF7, 0x00,
4089 0x84, 0xFF, 0xA4, 0xFB, 0x84, 0xFE, 0xA3, 0x0E, 0x6C, 0x1F, 0xD6,
4090 0x1D, 0xCB, 0x0B, 0x45, 0xFD, 0x12, 0xFC, 0xF8, 0xFF, 0xE7, 0x00,
4091 0x1D, 0x00, 0xFB, 0xFF, 0xF7, 0xFF, 0x56, 0x00, 0xFA, 0x00, 0xDD,
4092 0xFE, 0x4E, 0xFB, 0x7C, 0x00, 0x32, 0x12, 0xCC, 0x20, 0x5C, 0x1B,
4093 0x69, 0x08, 0x29, 0xFC, 0xBC, 0xFC, 0x69, 0x00, 0xC7, 0x00, 0x09,
4094 0x00, 0xFE, 0xFF, 0xF8, 0xFF, 0x7D, 0x00, 0xE3, 0x00, 0x21, 0xFE,
4095 0x43, 0xFB, 0xE9, 0x02, 0xA9, 0x15, 0x79, 0x21, 0x6B, 0x18, 0x48,
4096 0x05, 0x80, 0xFB, 0x7C, 0xFD, 0xB9, 0x00, 0xA0, 0x00, 0xFD, 0xFF,
4097 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xA6, 0x00, 0xAF, 0x00, 0x5E,
4098 0xFD, 0x93, 0xFB, 0xBE, 0x05, 0xE5, 0x18, 0x6B, 0x21, 0x23, 0x15,
4099 0x82, 0x02, 0x3F, 0xFB, 0x3F, 0xFE, 0xE9, 0x00, 0x77, 0x00, 0xF8,
4100 0xFF, 0xFE, 0xFF, 0x0C, 0x00, 0xCD, 0x00, 0x5A, 0x00, 0xA0, 0xFC,
4101 0x4D, 0xFC, 0xEA, 0x08, 0xC6, 0x1B, 0xA1, 0x20, 0xA6, 0x11, 0x26,
4102 0x00, 0x57, 0xFB, 0xF8, 0xFE, 0xFB, 0x00, 0x50, 0x00, 0xF7, 0xFF,
4103 0xFB, 0xFF, 0x21, 0x00, 0xEB, 0x00, 0xE3, 0xFF, 0xFA, 0xFB, 0x7C,
4104 0xFD, 0x54, 0x0C, 0x2B, 0x1E, 0x26, 0x1F, 0x17, 0x0E, 0x41, 0xFE,
4105 0xB6, 0xFB, 0x9C, 0xFF, 0xF5, 0x00, 0x2F, 0x00, 0xF9, 0xFF, 0xF8,
4106 0xFF, 0x3F, 0x00, 0xFB, 0x00, 0x4D, 0xFF, 0x7F, 0xFB, 0x24, 0xFF,
4107 0xDF, 0x0F, 0xF9, 0x1F, 0x09, 0x1D, 0x99, 0x0A, 0xD5, 0xFC, 0x49,
4108 0xFC, 0x23, 0x00, 0xDD, 0x00, 0x16, 0x00, 0xFC, 0xFF, 0xF7, 0xFF,
4109 0x63, 0x00, 0xF5, 0x00, 0x9E, 0xFE, 0x41, 0xFB, 0x46, 0x01, 0x69,
4110 0x13, 0x1D, 0x21, 0x63, 0x1A, 0x4B, 0x07, 0xE2, 0xFB, 0xFD, 0xFC,
4111 0x89, 0x00, 0xBA, 0x00, 0x04, 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0x8B,
4112 0x00, 0xD5, 0x00, 0xDE, 0xFD, 0x53, 0xFB, 0xD9, 0x03, 0xD0, 0x16,
4113 0x8A, 0x21, 0x51, 0x17, 0x47, 0x04, 0x5E, 0xFB, 0xC0, 0xFD, 0xCD,
4114 0x00, 0x92, 0x00, 0xFB, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x02, 0x00,
4115 0xB4, 0x00, 0x96, 0x00, 0x1B, 0xFD, 0xC7, 0xFB, 0xCF, 0x06, 0xF0,
4116 0x19, 0x3A, 0x21, 0xF2, 0x13, 0xA4, 0x01, 0x3E, 0xFB, 0x81, 0xFE,
4117 0xF2, 0x00, 0x69, 0x00, 0xF7, 0xFF, 0xFD, 0xFF, 0x12, 0x00, 0xD9,
4118 0x00, 0x35, 0x00, 0x63, 0xFC, 0xA8, 0xFC, 0x13, 0x0A, 0xA9, 0x1C,
4119 0x32, 0x20, 0x6B, 0x10, 0x71, 0xFF, 0x71, 0xFB, 0x34, 0xFF, 0xFB,
4120 0x00, 0x44, 0x00, 0xF8, 0xFF, 0xFA, 0xFF, 0x2B, 0x00, 0xF3, 0x00,
4121 0xB3, 0xFF, 0xCA, 0xFB, 0x01, 0xFE, 0x8C, 0x0D, 0xDD, 0x1E, 0x7C,
4122 0x1E, 0xDE, 0x0C, 0xB5, 0xFD, 0xE4, 0xFB, 0xCE, 0xFF, 0xEF, 0x00,
4123 0x25, 0x00, 0xFA, 0xFF, 0xF7, 0xFF, 0x4A, 0x00, 0xFC, 0x00, 0x13,
4124 0xFF, 0x61, 0xFB, 0xD4, 0xFF, 0x1A, 0x11, 0x72, 0x20, 0x2D, 0x1C,
4125 0x6D, 0x09, 0x74, 0xFC, 0x85, 0xFC, 0x4A, 0x00, 0xD2, 0x00, 0x0F,
4126 0x00, 0xFD, 0xFF, 0xF7, 0xFF, 0x70, 0x00, 0xED, 0x00, 0x5D, 0xFE,
4127 0x3D, 0xFB, 0x1E, 0x02, 0x9C, 0x14, 0x58, 0x21, 0x5E, 0x19, 0x36,
4128 0x06, 0xA8, 0xFB, 0x40, 0xFD, 0xA4, 0x00, 0xAD, 0x00, 0x00, 0x00,
4129 0xFF, 0xFF, 0x00, 0x00, 0xFC, 0xFF, 0x9A, 0x00, 0xC3, 0x00, 0x9A,
4130 0xFD, 0x6F, 0xFB, 0xD5, 0x04, 0xEF, 0x17, 0x83, 0x21, 0x2D, 0x16,
4131 0x52, 0x03, 0x49, 0xFB, 0x04, 0xFE, 0xDD, 0x00, 0x83, 0x00, 0xF9,
4132 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0xC2, 0x00, 0x78, 0x00, 0xD9, 0xFC,
4133 0x08, 0xFC, 0xE9, 0x07, 0xEF, 0x1A, 0xF3, 0x20, 0xBC, 0x12, 0xD4,
4134 0x00, 0x47, 0xFB, 0xC1, 0xFE, 0xF8, 0x00, 0x5B, 0x00, 0xF7, 0xFF,
4135 0xFC, 0xFF, 0x1A, 0x00, 0xE3, 0x00, 0x0B, 0x00, 0x2A, 0xFC, 0x12,
4136 0xFD, 0x42, 0x0B, 0x7D, 0x1D, 0xAD, 0x1F, 0x2F, 0x0F, 0xC9, 0xFE,
4137 0x92, 0xFB, 0x6C, 0xFF, 0xF9, 0x00, 0x38, 0x00, 0xF8, 0xFF, 0xF9,
4138 0xFF, 0x35, 0x00, 0xF8, 0x00, 0x7E, 0xFF, 0x9F, 0xFB, 0x95, 0xFE,
4139 0xC6, 0x0E, 0x7C, 0x1F, 0xC0, 0x1D, 0xA9, 0x0B, 0x38, 0xFD, 0x18,
4140 0xFC, 0xFD, 0xFF, 0xE6, 0x00, 0x1D, 0x00, 0xFB, 0xFF, 0xF7, 0xFF,
4141 0x57, 0x00, 0xFA, 0x00, 0xD6, 0xFE, 0x4C, 0xFB, 0x92, 0x00, 0x54,
4142 0x12, 0xD6, 0x20, 0x41, 0x1B, 0x49, 0x08, 0x20, 0xFC, 0xC3, 0xFC,
4143 0x6D, 0x00, 0xC6, 0x00, 0x09, 0x00, 0xFE, 0xFF, 0xF8, 0xFF, 0x7E,
4144 0x00, 0xE2, 0x00, 0x1A, 0xFE, 0x44, 0xFB, 0x03, 0x03, 0xCA, 0x15,
4145 0x7C, 0x21, 0x4C, 0x18, 0x2B, 0x05, 0x7B, 0xFB, 0x83, 0xFD, 0xBC,
4146 0x00, 0x9E, 0x00, 0xFD, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
4147 0xA8, 0x00, 0xAD, 0x00, 0x56, 0xFD, 0x98, 0xFB, 0xDC, 0x05, 0x04,
4148 0x19, 0x66, 0x21, 0x02, 0x15, 0x69, 0x02, 0x3E, 0xFB, 0x47, 0xFE,
4149 0xEA, 0x00, 0x75, 0x00, 0xF8, 0xFF, 0xFE, 0xFF, 0x0D, 0x00, 0xCE,
4150 0x00, 0x56, 0x00, 0x99, 0xFC, 0x56, 0xFC, 0x0B, 0x09, 0xE0, 0x1B,
4151 0x96, 0x20, 0x83, 0x11, 0x11, 0x00, 0x59, 0xFB, 0xFF, 0xFE, 0xFB,
4152 0x00, 0x4E, 0x00, 0xF7, 0xFF, 0xFB, 0xFF, 0x22, 0x00, 0xEC, 0x00,
4153 0xDE, 0xFF, 0xF5, 0xFB, 0x8A, 0xFD, 0x77, 0x0C, 0x3F, 0x1E, 0x14,
4154 0x1F, 0xF5, 0x0D, 0x31, 0xFE, 0xBB, 0xFB, 0xA2, 0xFF, 0xF5, 0x00,
4155 0x2E, 0x00, 0xF9, 0xFF, 0xF8, 0xFF, 0x40, 0x00, 0xFB, 0x00, 0x47,
4156 0xFF, 0x7B, 0xFB, 0x37, 0xFF, 0x02, 0x10, 0x07, 0x20, 0xF2, 0x1C,
4157 0x78, 0x0A, 0xCA, 0xFC, 0x50, 0xFC, 0x27, 0x00, 0xDC, 0x00, 0x15,
4158 0x00, 0xFC, 0xFF, 0xF7, 0xFF, 0x64, 0x00, 0xF5, 0x00, 0x97, 0xFE,
4159 0x40, 0xFB, 0x5D, 0x01, 0x8B, 0x13, 0x25, 0x21, 0x47, 0x1A, 0x2C,
4160 0x07, 0xDB, 0xFB, 0x05, 0xFD, 0x8C, 0x00, 0xB9, 0x00, 0x04, 0x00,
4161 0xFF, 0xFF, 0xFA, 0xFF, 0x8D, 0x00, 0xD3, 0x00, 0xD6, 0xFD, 0x56,
4162 0xFB, 0xF4, 0x03, 0xF0, 0x16, 0x8A, 0x21, 0x31, 0x17, 0x2B, 0x04,
4163 0x5B, 0xFB, 0xC7, 0xFD, 0xCF, 0x00, 0x90, 0x00, 0xFA, 0xFF, 0x00,
4164 0x00, 0xFF, 0xFF, 0x03, 0x00, 0xB6, 0x00, 0x92, 0x00, 0x13, 0xFD,
4165 0xCD, 0xFB, 0xEE, 0x06, 0x0D, 0x1A, 0x33, 0x21, 0xD0, 0x13, 0x8C,
4166 0x01, 0x3E, 0xFB, 0x88, 0xFE, 0xF3, 0x00, 0x67, 0x00, 0xF7, 0xFF,
4167 0x06, 0x00, 0x1D, 0x00, 0x03, 0xFF, 0xFE, 0x00, 0xA1, 0x02, 0xA6,
4168 0xF8, 0x56, 0x02, 0xA5, 0x28, 0xA5, 0x28, 0x56, 0x02, 0xA6, 0xF8,
4169 0xA1, 0x02, 0xFE, 0x00, 0x03, 0xFF, 0x1D, 0x00, 0x06, 0x00, 0x00,
4170 0x00, 0x21, 0x00, 0xA6, 0xFF, 0x3F, 0xFF, 0x0B, 0x03, 0x42, 0xFE,
4171 0x3E, 0xF8, 0x7F, 0x15, 0xAC, 0x30, 0x7F, 0x15, 0x3E, 0xF8, 0x42,
4172 0xFE, 0x0B, 0x03, 0x3F, 0xFF, 0xA6, 0xFF, 0x21, 0x00, 0x00, 0x00,
4173 0xFA, 0xFF, 0xCE, 0xFF, 0x14, 0x01, 0x00, 0xFD, 0x35, 0x06, 0xD5,
4174 0xF4, 0xDA, 0x15, 0x92, 0x40, 0xAE, 0xFE, 0xF3, 0xFC, 0x68, 0x03,
4175 0x86, 0xFD, 0x51, 0x01, 0x8B, 0xFF, 0x11, 0x00, 0x01, 0x00, 0xEC,
4176 0xFF, 0xF9, 0xFF, 0xC6, 0x00, 0x55, 0xFD, 0x35, 0x06, 0x90, 0xF3,
4177 0xE5, 0x1C, 0x6B, 0x3D, 0x71, 0xFA, 0x34, 0xFF, 0x46, 0x02, 0xFF,
4178 0xFD, 0x2D, 0x01, 0x90, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xDB, 0xFF,
4179 0x2D, 0x00, 0x60, 0x00, 0xE1, 0xFD, 0xCE, 0x05, 0xED, 0xF2, 0xF3,
4180 0x23, 0x20, 0x39, 0x22, 0xF7, 0x44, 0x01, 0x1F, 0x01, 0x89, 0xFE,
4181 0xFB, 0x00, 0x9C, 0xFF, 0x0D, 0x00, 0x06, 0x00, 0xC9, 0xFF, 0x68,
4182 0x00, 0xE5, 0xFF, 0xA0, 0xFE, 0xFB, 0x04, 0x0C, 0xF3, 0xC5, 0x2A,
4183 0xD8, 0x33, 0xC9, 0xF4, 0x0B, 0x03, 0x05, 0x00, 0x1A, 0xFF, 0xC1,
4184 0x00, 0xAD, 0xFF, 0x0A, 0x00, 0x09, 0x00, 0xB5, 0xFF, 0xA5, 0x00,
4185 0x5C, 0xFF, 0x8C, 0xFF, 0xBF, 0x03, 0x06, 0xF4, 0x22, 0x31, 0xC8,
4186 0x2D, 0x63, 0xF3, 0x76, 0x04, 0x08, 0xFF, 0xA7, 0xFF, 0x84, 0x00,
4187 0xC0, 0xFF, 0x07, 0x00, 0x0C, 0x00, 0xA4, 0xFF, 0xE1, 0x00, 0xCB,
4188 0xFE, 0x9B, 0x00, 0x21, 0x02, 0xEE, 0xF5, 0xCD, 0x36, 0x24, 0x27,
4189 0xE1, 0xF2, 0x7A, 0x05, 0x33, 0xFE, 0x2A, 0x00, 0x47, 0x00, 0xD3,
4190 0xFF, 0x04, 0x00, 0x0F, 0x00, 0x95, 0xFF, 0x17, 0x01, 0x3D, 0xFE,
4191 0xBD, 0x01, 0x30, 0x00, 0xCC, 0xF8, 0x92, 0x3B, 0x2A, 0x20, 0x2E,
4192 0xF3, 0x12, 0x06, 0x8F, 0xFD, 0x9A, 0x00, 0x10, 0x00, 0xE5, 0xFF,
4193 0x02, 0x00, 0x10, 0x00, 0x8C, 0xFF, 0x42, 0x01, 0xBB, 0xFD, 0xE4,
4194 0x02, 0x01, 0xFE, 0x9C, 0xFC, 0x45, 0x3F, 0x16, 0x19, 0x2D, 0xF4,
4195 0x41, 0x06, 0x21, 0xFD, 0xF3, 0x00, 0xE0, 0xFF, 0xF4, 0xFF, 0x01,
4196 0x00, 0x10, 0x00, 0x8B, 0xFF, 0x5D, 0x01, 0x4F, 0xFD, 0xFB, 0x03,
4197 0xB2, 0xFB, 0x53, 0x01, 0xC2, 0x41, 0x24, 0x12, 0xBA, 0xF5, 0x0F,
4198 0x06, 0xE9, 0xFC, 0x33, 0x01, 0xBB, 0xFF, 0x00, 0x00, 0x00, 0x00,
4199 0x0D, 0x00, 0x93, 0xFF, 0x63, 0x01, 0x04, 0xFD, 0xEF, 0x04, 0x62,
4200 0xF9, 0xD7, 0x06, 0xF2, 0x42, 0x8D, 0x0B, 0xB0, 0xF7, 0x87, 0x05,
4201 0xE6, 0xFC, 0x58, 0x01, 0xA0, 0xFF, 0x09, 0x00, 0x00, 0x00, 0x00,
4202 0x00, 0x07, 0x00, 0xA5, 0xFF, 0x52, 0x01, 0xE2, 0xFC, 0xAD, 0x05,
4203 0x35, 0xF7, 0x08, 0x0D, 0xCB, 0x42, 0x81, 0x05, 0xE8, 0xF9, 0xBB,
4204 0x04, 0x12, 0xFD, 0x64, 0x01, 0x90, 0xFF, 0x0E, 0x00, 0x00, 0x00,
4205 0xFE, 0xFF, 0xC2, 0xFF, 0x27, 0x01, 0xF1, 0xFC, 0x22, 0x06, 0x54,
4206 0xF5, 0xB8, 0x13, 0x4A, 0x41, 0x29, 0x00, 0x3C, 0xFC, 0xBD, 0x03,
4207 0x66, 0xFD, 0x58, 0x01, 0x8A, 0xFF, 0x11, 0x00, 0x01, 0x00, 0xF1,
4208 0xFF, 0xEB, 0xFF, 0xE1, 0x00, 0x35, 0xFD, 0x40, 0x06, 0xE4, 0xF3,
4209 0xB7, 0x1A, 0x85, 0x3E, 0xA6, 0xFB, 0x86, 0xFE, 0xA0, 0x02, 0xD7,
4210 0xFD, 0x39, 0x01, 0x8E, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xE1, 0xFF,
4211 0x1C, 0x00, 0x82, 0x00, 0xB0, 0xFD, 0xF9, 0x05, 0x0C, 0xF3, 0xCB,
4212 0x21, 0x8F, 0x3A, 0x0D, 0xF8, 0xA9, 0x00, 0x79, 0x01, 0x5D, 0xFE,
4213 0x0B, 0x01, 0x98, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0xCE, 0xFF, 0x55,
4214 0x00, 0x0D, 0x00, 0x60, 0xFE, 0x48, 0x05, 0xEC, 0xF2, 0xB6, 0x28,
4215 0x91, 0x35, 0x68, 0xF5, 0x88, 0x02, 0x5A, 0x00, 0xED, 0xFE, 0xD4,
4216 0x00, 0xA8, 0xFF, 0x0B, 0x00, 0x08, 0x00, 0xBB, 0xFF, 0x92, 0x00,
4217 0x87, 0xFF, 0x3F, 0xFF, 0x2B, 0x04, 0xA1, 0xF3, 0x3D, 0x2F, 0xB8,
4218 0x2F, 0xB8, 0xF3, 0x11, 0x04, 0x52, 0xFF, 0x7C, 0xFF, 0x97, 0x00,
4219 0xBA, 0xFF, 0x08, 0x00, 0x0B, 0x00, 0xA9, 0xFF, 0xCF, 0x00, 0xF8,
4220 0xFE, 0x44, 0x00, 0xAA, 0x02, 0x3E, 0xF5, 0x24, 0x35, 0x3B, 0x29,
4221 0xF2, 0xF2, 0x35, 0x05, 0x70, 0xFE, 0x03, 0x00, 0x5A, 0x00, 0xCD,
4222 0xFF, 0x05, 0x00, 0x0E, 0x00, 0x99, 0xFF, 0x07, 0x01, 0x68, 0xFE,
4223 0x63, 0x01, 0xD0, 0x00, 0xD0, 0xF7, 0x35, 0x3A, 0x55, 0x22, 0x02,
4224 0xF3, 0xEF, 0x05, 0xBC, 0xFD, 0x7A, 0x00, 0x20, 0x00, 0xDF, 0xFF,
4225 0x03, 0x00, 0x10, 0x00, 0x8E, 0xFF, 0x36, 0x01, 0xE1, 0xFD, 0x8A,
4226 0x02, 0xB2, 0xFE, 0x56, 0xFB, 0x40, 0x3E, 0x42, 0x1B, 0xCE, 0xF3,
4227 0x3E, 0x06, 0x3D, 0xFD, 0xDB, 0x00, 0xEE, 0xFF, 0xF0, 0xFF, 0x01,
4228 0x00, 0x11, 0x00, 0x8A, 0xFF, 0x57, 0x01, 0x6D, 0xFD, 0xA8, 0x03,
4229 0x69, 0xFC, 0xC8, 0xFF, 0x20, 0x41, 0x40, 0x14, 0x33, 0xF5, 0x28,
4230 0x06, 0xF5, 0xFC, 0x22, 0x01, 0xC5, 0xFF, 0xFD, 0xFF, 0x00, 0x00,
4231 0x0F, 0x00, 0x8F, 0xFF, 0x64, 0x01, 0x17, 0xFD, 0xA9, 0x04, 0x16,
4232 0xFA, 0x10, 0x05, 0xB8, 0x42, 0x87, 0x0D, 0x0D, 0xF7, 0xB9, 0x05,
4233 0xE2, 0xFC, 0x50, 0x01, 0xA7, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00,
4234 0x00, 0x0A, 0x00, 0x9E, 0xFF, 0x5A, 0x01, 0xE8, 0xFC, 0x7A, 0x05,
4235 0xDA, 0xF7, 0x10, 0x0B, 0xFB, 0x42, 0x4B, 0x07, 0x35, 0xF9, 0x00,
4236 0x05, 0x00, 0xFD, 0x63, 0x01, 0x94, 0xFF, 0x0D, 0x00, 0x00, 0x00,
4237 0x01, 0x00, 0xB8, 0xFF, 0x37, 0x01, 0xE7, 0xFC, 0x07, 0x06, 0xDE,
4238 0xF5, 0x9F, 0x11, 0xE4, 0x41, 0xB8, 0x01, 0x84, 0xFB, 0x0F, 0x04,
4239 0x48, 0xFD, 0x5E, 0x01, 0x8B, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF5,
4240 0xFF, 0xDD, 0xFF, 0xF9, 0x00, 0x1B, 0xFD, 0x41, 0x06, 0x47, 0xF4,
4241 0x8B, 0x18, 0x81, 0x3F, 0xF1, 0xFC, 0xD5, 0xFD, 0xFA, 0x02, 0xB2,
4242 0xFD, 0x45, 0x01, 0x8C, 0xFF, 0x11, 0x00, 0x02, 0x00, 0xE6, 0xFF,
4243 0x0C, 0x00, 0xA2, 0x00, 0x85, 0xFD, 0x1A, 0x06, 0x3C, 0xF3, 0x9F,
4244 0x1F, 0xE6, 0x3B, 0x0E, 0xF9, 0x07, 0x00, 0xD4, 0x01, 0x33, 0xFE,
4245 0x1B, 0x01, 0x94, 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD4, 0xFF, 0x43,
4246 0x00, 0x33, 0x00, 0x25, 0xFE, 0x89, 0x05, 0xE0, 0xF2, 0x9C, 0x26,
4247 0x33, 0x37, 0x1E, 0xF6, 0xFD, 0x01, 0xB0, 0x00, 0xC0, 0xFE, 0xE6,
4248 0x00, 0xA2, 0xFF, 0x0C, 0x00, 0x07, 0x00, 0xC1, 0xFF, 0x7F, 0x00,
4249 0xB2, 0xFF, 0xF6, 0xFE, 0x8E, 0x04, 0x51, 0xF3, 0x49, 0x2D, 0x98,
4250 0x31, 0x23, 0xF4, 0xA2, 0x03, 0xA0, 0xFF, 0x51, 0xFF, 0xAA, 0x00,
4251 0xB4, 0xFF, 0x09, 0x00, 0x0A, 0x00, 0xAE, 0xFF, 0xBD, 0x00, 0x25,
4252 0xFF, 0xF1, 0xFF, 0x2B, 0x03, 0xA5, 0xF4, 0x68, 0x33, 0x48, 0x2B,
4253 0x17, 0xF3, 0xE7, 0x04, 0xB1, 0xFE, 0xDB, 0xFF, 0x6C, 0x00, 0xC7,
4254 0xFF, 0x06, 0x00, 0x0D, 0x00, 0x9E, 0xFF, 0xF7, 0x00, 0x94, 0xFE,
4255 0x09, 0x01, 0x6A, 0x01, 0xEB, 0xF6, 0xC1, 0x38, 0x7D, 0x24, 0xE8,
4256 0xF2, 0xC1, 0x05, 0xEE, 0xFD, 0x57, 0x00, 0x31, 0x00, 0xDA, 0xFF,
4257 0x03, 0x00, 0x10, 0x00, 0x91, 0xFF, 0x29, 0x01, 0x09, 0xFE, 0x2F,
4258 0x02, 0x5F, 0xFF, 0x27, 0xFA, 0x20, 0x3D, 0x70, 0x1D, 0x7D, 0xF3,
4259 0x31, 0x06, 0x5E, 0xFD, 0xBF, 0x00, 0xFD, 0xFF, 0xEB, 0xFF, 0x02,
4260 0x00, 0x11, 0x00, 0x8B, 0xFF, 0x4E, 0x01, 0x8E, 0xFD, 0x52, 0x03,
4261 0x20, 0xFD, 0x52, 0xFE, 0x60, 0x40, 0x63, 0x16, 0xB7, 0xF4, 0x39,
4262 0x06, 0x05, 0xFD, 0x0F, 0x01, 0xD1, 0xFF, 0xF9, 0xFF, 0x00, 0x00,
4263 0x10, 0x00, 0x8D, 0xFF, 0x62, 0x01, 0x2E, 0xFD, 0x5E, 0x04, 0xCC,
4264 0xFA, 0x5B, 0x03, 0x5E, 0x42, 0x8E, 0x0F, 0x71, 0xF6, 0xE4, 0x05,
4265 0xE2, 0xFC, 0x45, 0x01, 0xAF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x00,
4266 0x00, 0x0B, 0x00, 0x99, 0xFF, 0x60, 0x01, 0xF2, 0xFC, 0x40, 0x05,
4267 0x85, 0xF8, 0x26, 0x09, 0x0C, 0x43, 0x26, 0x09, 0x85, 0xF8, 0x40,
4268 0x05, 0xF2, 0xFC, 0x60, 0x01, 0x99, 0xFF, 0x0B, 0x00, 0x00, 0x00,
4269 0x04, 0x00, 0xAF, 0xFF, 0x45, 0x01, 0xE2, 0xFC, 0xE4, 0x05, 0x71,
4270 0xF6, 0x8E, 0x0F, 0x5E, 0x42, 0x5B, 0x03, 0xCC, 0xFA, 0x5E, 0x04,
4271 0x2E, 0xFD, 0x62, 0x01, 0x8D, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xF9,
4272 0xFF, 0xD1, 0xFF, 0x0F, 0x01, 0x05, 0xFD, 0x39, 0x06, 0xB7, 0xF4,
4273 0x63, 0x16, 0x60, 0x40, 0x52, 0xFE, 0x20, 0xFD, 0x52, 0x03, 0x8E,
4274 0xFD, 0x4E, 0x01, 0x8B, 0xFF, 0x11, 0x00, 0x02, 0x00, 0xEB, 0xFF,
4275 0xFD, 0xFF, 0xBF, 0x00, 0x5E, 0xFD, 0x31, 0x06, 0x7D, 0xF3, 0x70,
4276 0x1D, 0x20, 0x3D, 0x27, 0xFA, 0x5F, 0xFF, 0x2F, 0x02, 0x09, 0xFE,
4277 0x29, 0x01, 0x91, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xDA, 0xFF, 0x31,
4278 0x00, 0x57, 0x00, 0xEE, 0xFD, 0xC1, 0x05, 0xE8, 0xF2, 0x7D, 0x24,
4279 0xC1, 0x38, 0xEB, 0xF6, 0x6A, 0x01, 0x09, 0x01, 0x94, 0xFE, 0xF7,
4280 0x00, 0x9E, 0xFF, 0x0D, 0x00, 0x06, 0x00, 0xC7, 0xFF, 0x6C, 0x00,
4281 0xDB, 0xFF, 0xB1, 0xFE, 0xE7, 0x04, 0x17, 0xF3, 0x48, 0x2B, 0x68,
4282 0x33, 0xA5, 0xF4, 0x2B, 0x03, 0xF1, 0xFF, 0x25, 0xFF, 0xBD, 0x00,
4283 0xAE, 0xFF, 0x0A, 0x00, 0x09, 0x00, 0xB4, 0xFF, 0xAA, 0x00, 0x51,
4284 0xFF, 0xA0, 0xFF, 0xA2, 0x03, 0x23, 0xF4, 0x98, 0x31, 0x49, 0x2D,
4285 0x51, 0xF3, 0x8E, 0x04, 0xF6, 0xFE, 0xB2, 0xFF, 0x7F, 0x00, 0xC1,
4286 0xFF, 0x07, 0x00, 0x0C, 0x00, 0xA2, 0xFF, 0xE6, 0x00, 0xC0, 0xFE,
4287 0xB0, 0x00, 0xFD, 0x01, 0x1E, 0xF6, 0x33, 0x37, 0x9C, 0x26, 0xE0,
4288 0xF2, 0x89, 0x05, 0x25, 0xFE, 0x33, 0x00, 0x43, 0x00, 0xD4, 0xFF,
4289 0x04, 0x00, 0x0F, 0x00, 0x94, 0xFF, 0x1B, 0x01, 0x33, 0xFE, 0xD4,
4290 0x01, 0x07, 0x00, 0x0E, 0xF9, 0xE6, 0x3B, 0x9F, 0x1F, 0x3C, 0xF3,
4291 0x1A, 0x06, 0x85, 0xFD, 0xA2, 0x00, 0x0C, 0x00, 0xE6, 0xFF, 0x02,
4292 0x00, 0x11, 0x00, 0x8C, 0xFF, 0x45, 0x01, 0xB2, 0xFD, 0xFA, 0x02,
4293 0xD5, 0xFD, 0xF1, 0xFC, 0x81, 0x3F, 0x8B, 0x18, 0x47, 0xF4, 0x41,
4294 0x06, 0x1B, 0xFD, 0xF9, 0x00, 0xDD, 0xFF, 0xF5, 0xFF, 0x01, 0x00,
4295 0x10, 0x00, 0x8B, 0xFF, 0x5E, 0x01, 0x48, 0xFD, 0x0F, 0x04, 0x84,
4296 0xFB, 0xB8, 0x01, 0xE4, 0x41, 0x9F, 0x11, 0xDE, 0xF5, 0x07, 0x06,
4297 0xE7, 0xFC, 0x37, 0x01, 0xB8, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x0D,
4298 0x00, 0x94, 0xFF, 0x63, 0x01, 0x00, 0xFD, 0x00, 0x05, 0x35, 0xF9,
4299 0x4B, 0x07, 0xFB, 0x42, 0x10, 0x0B, 0xDA, 0xF7, 0x7A, 0x05, 0xE8,
4300 0xFC, 0x5A, 0x01, 0x9E, 0xFF, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
4301 0x07, 0x00, 0xA7, 0xFF, 0x50, 0x01, 0xE2, 0xFC, 0xB9, 0x05, 0x0D,
4302 0xF7, 0x87, 0x0D, 0xB8, 0x42, 0x10, 0x05, 0x16, 0xFA, 0xA9, 0x04,
4303 0x17, 0xFD, 0x64, 0x01, 0x8F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xFD,
4304 0xFF, 0xC5, 0xFF, 0x22, 0x01, 0xF5, 0xFC, 0x28, 0x06, 0x33, 0xF5,
4305 0x40, 0x14, 0x20, 0x41, 0xC8, 0xFF, 0x69, 0xFC, 0xA8, 0x03, 0x6D,
4306 0xFD, 0x57, 0x01, 0x8A, 0xFF, 0x11, 0x00, 0x01, 0x00, 0xF0, 0xFF,
4307 0xEE, 0xFF, 0xDB, 0x00, 0x3D, 0xFD, 0x3E, 0x06, 0xCE, 0xF3, 0x42,
4308 0x1B, 0x40, 0x3E, 0x56, 0xFB, 0xB2, 0xFE, 0x8A, 0x02, 0xE1, 0xFD,
4309 0x36, 0x01, 0x8E, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xDF, 0xFF, 0x20,
4310 0x00, 0x7A, 0x00, 0xBC, 0xFD, 0xEF, 0x05, 0x02, 0xF3, 0x55, 0x22,
4311 0x35, 0x3A, 0xD0, 0xF7, 0xD0, 0x00, 0x63, 0x01, 0x68, 0xFE, 0x07,
4312 0x01, 0x99, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0xCD, 0xFF, 0x5A, 0x00,
4313 0x03, 0x00, 0x70, 0xFE, 0x35, 0x05, 0xF2, 0xF2, 0x3B, 0x29, 0x24,
4314 0x35, 0x3E, 0xF5, 0xAA, 0x02, 0x44, 0x00, 0xF8, 0xFE, 0xCF, 0x00,
4315 0xA9, 0xFF, 0x0B, 0x00, 0x08, 0x00, 0xBA, 0xFF, 0x97, 0x00, 0x7C,
4316 0xFF, 0x52, 0xFF, 0x11, 0x04, 0xB8, 0xF3, 0xB8, 0x2F, 0x3D, 0x2F,
4317 0xA1, 0xF3, 0x2B, 0x04, 0x3F, 0xFF, 0x87, 0xFF, 0x92, 0x00, 0xBB,
4318 0xFF, 0x08, 0x00, 0x0B, 0x00, 0xA8, 0xFF, 0xD4, 0x00, 0xED, 0xFE,
4319 0x5A, 0x00, 0x88, 0x02, 0x68, 0xF5, 0x91, 0x35, 0xB6, 0x28, 0xEC,
4320 0xF2, 0x48, 0x05, 0x60, 0xFE, 0x0D, 0x00, 0x55, 0x00, 0xCE, 0xFF,
4321 0x05, 0x00, 0x0E, 0x00, 0x98, 0xFF, 0x0B, 0x01, 0x5D, 0xFE, 0x79,
4322 0x01, 0xA9, 0x00, 0x0D, 0xF8, 0x8F, 0x3A, 0xCB, 0x21, 0x0C, 0xF3,
4323 0xF9, 0x05, 0xB0, 0xFD, 0x82, 0x00, 0x1C, 0x00, 0xE1, 0xFF, 0x03,
4324 0x00, 0x10, 0x00, 0x8E, 0xFF, 0x39, 0x01, 0xD7, 0xFD, 0xA0, 0x02,
4325 0x86, 0xFE, 0xA6, 0xFB, 0x85, 0x3E, 0xB7, 0x1A, 0xE4, 0xF3, 0x40,
4326 0x06, 0x35, 0xFD, 0xE1, 0x00, 0xEB, 0xFF, 0xF1, 0xFF, 0x01, 0x00,
4327 0x11, 0x00, 0x8A, 0xFF, 0x58, 0x01, 0x66, 0xFD, 0xBD, 0x03, 0x3C,
4328 0xFC, 0x29, 0x00, 0x4A, 0x41, 0xB8, 0x13, 0x54, 0xF5, 0x22, 0x06,
4329 0xF1, 0xFC, 0x27, 0x01, 0xC2, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0x0E,
4330 0x00, 0x90, 0xFF, 0x64, 0x01, 0x12, 0xFD, 0xBB, 0x04, 0xE8, 0xF9,
4331 0x81, 0x05, 0xCB, 0x42, 0x08, 0x0D, 0x35, 0xF7, 0xAD, 0x05, 0xE2,
4332 0xFC, 0x52, 0x01, 0xA5, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
4333 0x09, 0x00, 0xA0, 0xFF, 0x58, 0x01, 0xE6, 0xFC, 0x87, 0x05, 0xB0,
4334 0xF7, 0x8D, 0x0B, 0xF2, 0x42, 0xD7, 0x06, 0x62, 0xF9, 0xEF, 0x04,
4335 0x04, 0xFD, 0x63, 0x01, 0x93, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x00,
4336 0x00, 0xBB, 0xFF, 0x33, 0x01, 0xE9, 0xFC, 0x0F, 0x06, 0xBA, 0xF5,
4337 0x24, 0x12, 0xC2, 0x41, 0x53, 0x01, 0xB2, 0xFB, 0xFB, 0x03, 0x4F,
4338 0xFD, 0x5D, 0x01, 0x8B, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF4, 0xFF,
4339 0xE0, 0xFF, 0xF3, 0x00, 0x21, 0xFD, 0x41, 0x06, 0x2D, 0xF4, 0x16,
4340 0x19, 0x45, 0x3F, 0x9C, 0xFC, 0x01, 0xFE, 0xE4, 0x02, 0xBB, 0xFD,
4341 0x42, 0x01, 0x8C, 0xFF, 0x10, 0x00, 0x02, 0x00, 0xE5, 0xFF, 0x10,
4342 0x00, 0x9A, 0x00, 0x8F, 0xFD, 0x12, 0x06, 0x2E, 0xF3, 0x2A, 0x20,
4343 0x92, 0x3B, 0xCC, 0xF8, 0x30, 0x00, 0xBD, 0x01, 0x3D, 0xFE, 0x17,
4344 0x01, 0x95, 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD3, 0xFF, 0x47, 0x00,
4345 0x2A, 0x00, 0x33, 0xFE, 0x7A, 0x05, 0xE1, 0xF2, 0x24, 0x27, 0xCD,
4346 0x36, 0xEE, 0xF5, 0x21, 0x02, 0x9B, 0x00, 0xCB, 0xFE, 0xE1, 0x00,
4347 0xA4, 0xFF, 0x0C, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0x84, 0x00, 0xA7,
4348 0xFF, 0x08, 0xFF, 0x76, 0x04, 0x63, 0xF3, 0xC8, 0x2D, 0x22, 0x31,
4349 0x06, 0xF4, 0xBF, 0x03, 0x8C, 0xFF, 0x5C, 0xFF, 0xA5, 0x00, 0xB5,
4350 0xFF, 0x09, 0x00, 0x0A, 0x00, 0xAD, 0xFF, 0xC1, 0x00, 0x1A, 0xFF,
4351 0x05, 0x00, 0x0B, 0x03, 0xC9, 0xF4, 0xD8, 0x33, 0xC5, 0x2A, 0x0C,
4352 0xF3, 0xFB, 0x04, 0xA0, 0xFE, 0xE5, 0xFF, 0x68, 0x00, 0xC9, 0xFF,
4353 0x06, 0x00, 0x0D, 0x00, 0x9C, 0xFF, 0xFB, 0x00, 0x89, 0xFE, 0x1F,
4354 0x01, 0x44, 0x01, 0x22, 0xF7, 0x20, 0x39, 0xF3, 0x23, 0xED, 0xF2,
4355 0xCE, 0x05, 0xE1, 0xFD, 0x60, 0x00, 0x2D, 0x00, 0xDB, 0xFF, 0x03,
4356 0x00, 0x10, 0x00, 0x90, 0xFF, 0x2D, 0x01, 0xFF, 0xFD, 0x46, 0x02,
4357 0x34, 0xFF, 0x71, 0xFA, 0x6B, 0x3D, 0xE5, 0x1C, 0x90, 0xF3, 0x35,
4358 0x06, 0x55, 0xFD, 0xC6, 0x00, 0xF9, 0xFF, 0xEC, 0xFF, 0x01, 0x00,
4359 0x11, 0x00, 0x8B, 0xFF, 0x51, 0x01, 0x86, 0xFD, 0x68, 0x03, 0xF3,
4360 0xFC, 0xAE, 0xFE, 0x92, 0x40, 0xDA, 0x15, 0xD5, 0xF4, 0x35, 0x06,
4361 0x00, 0xFD, 0x14, 0x01, 0xCE, 0xFF, 0xFA, 0xFF, 0x00, 0x00, 0x0F,
4362 0x00, 0x8D, 0xFF, 0x63, 0x01, 0x28, 0xFD, 0x71, 0x04, 0x9E, 0xFA,
4363 0xC7, 0x03, 0x79, 0x42, 0x0B, 0x0F, 0x97, 0xF6, 0xDA, 0x05, 0xE2,
4364 0xFC, 0x48, 0x01, 0xAD, 0xFF, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
4365 0x0B, 0x00, 0x9A, 0xFF, 0x5F, 0x01, 0xEF, 0xFC, 0x4F, 0x05, 0x5A,
4366 0xF8, 0x9F, 0x09, 0x0A, 0x43, 0xAE, 0x08, 0xB1, 0xF8, 0x30, 0x05,
4367 0xF5, 0xFC, 0x61, 0x01, 0x97, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x03,
4368 0x00, 0xB1, 0xFF, 0x41, 0x01, 0xE3, 0xFC, 0xED, 0x05, 0x4C, 0xF6,
4369 0x11, 0x10, 0x42, 0x42, 0xF1, 0x02, 0xFA, 0xFA, 0x4B, 0x04, 0x34,
4370 0xFD, 0x61, 0x01, 0x8C, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF8, 0xFF,
4371 0xD4, 0xFF, 0x0A, 0x01, 0x0A, 0xFD, 0x3C, 0x06, 0x9A, 0xF4, 0xED,
4372 0x16, 0x2A, 0x40, 0xF8, 0xFD, 0x4D, 0xFD, 0x3C, 0x03, 0x97, 0xFD,
4373 0x4C, 0x01, 0x8B, 0xFF, 0x11, 0x00, 0x02, 0x00, 0xEA, 0xFF, 0x00,
4374 0x00, 0xB8, 0x00, 0x67, 0xFD, 0x2C, 0x06, 0x6B, 0xF3, 0xFC, 0x1D,
4375 0xD3, 0x3C, 0xDF, 0xF9, 0x89, 0xFF, 0x18, 0x02, 0x13, 0xFE, 0x26,
4376 0x01, 0x92, 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD9, 0xFF, 0x36, 0x00,
4377 0x4E, 0x00, 0xFB, 0xFD, 0xB4, 0x05, 0xE4, 0xF2, 0x04, 0x25, 0x5F,
4378 0x38, 0xB6, 0xF6, 0x90, 0x01, 0xF3, 0x00, 0x9F, 0xFE, 0xF3, 0x00,
4379 0x9F, 0xFF, 0x0D, 0x00, 0x06, 0x00, 0xC6, 0xFF, 0x71, 0x00, 0xD1,
4380 0xFF, 0xC2, 0xFE, 0xD1, 0x04, 0x23, 0xF3, 0xC9, 0x2B, 0xF5, 0x32,
4381 0x83, 0xF4, 0x49, 0x03, 0xDC, 0xFF, 0x30, 0xFF, 0xB8, 0x00, 0xB0,
4382 0xFF, 0x0A, 0x00, 0x09, 0x00, 0xB3, 0xFF, 0xAE, 0x00, 0x46, 0xFF,
4383 0xB4, 0xFF, 0x85, 0x03, 0x42, 0xF4, 0x0E, 0x32, 0xCA, 0x2C, 0x41,
4384 0xF3, 0xA5, 0x04, 0xE4, 0xFE, 0xBC, 0xFF, 0x7A, 0x00, 0xC3, 0xFF,
4385 0x07, 0x00, 0x0D, 0x00, 0xA1, 0xFF, 0xEA, 0x00, 0xB5, 0xFE, 0xC6,
4386 0x00, 0xD9, 0x01, 0x4F, 0xF6, 0x99, 0x37, 0x16, 0x26, 0xE0, 0xF2,
4387 0x98, 0x05, 0x16, 0xFE, 0x3C, 0x00, 0x3F, 0x00, 0xD6, 0xFF, 0x04,
4388 0x00, 0x0F, 0x00, 0x93, 0xFF, 0x1F, 0x01, 0x28, 0xFE, 0xEB, 0x01,
4389 0xDD, 0xFF, 0x52, 0xF9, 0x36, 0x3C, 0x13, 0x1F, 0x4B, 0xF3, 0x20,
4390 0x06, 0x7B, 0xFD, 0xA9, 0x00, 0x08, 0x00, 0xE7, 0xFF, 0x02, 0x00,
4391 0x11, 0x00, 0x8C, 0xFF, 0x47, 0x01, 0xA9, 0xFD, 0x10, 0x03, 0xA8,
4392 0xFD, 0x47, 0xFD, 0xBB, 0x3F, 0x01, 0x18, 0x62, 0xF4, 0x40, 0x06,
4393 0x15, 0xFD, 0xFF, 0x00, 0xDA, 0xFF, 0xF6, 0xFF, 0x01, 0x00, 0x10,
4394 0x00, 0x8B, 0xFF, 0x5F, 0x01, 0x41, 0xFD, 0x23, 0x04, 0x56, 0xFB,
4395 0x1F, 0x02, 0x06, 0x42, 0x19, 0x11, 0x02, 0xF6, 0xFF, 0x05, 0xE5,
4396 0xFC, 0x3B, 0x01, 0xB6, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x0D, 0x00,
4397 0x95, 0xFF, 0x62, 0x01, 0xFC, 0xFC, 0x10, 0x05, 0x09, 0xF9, 0xC1,
4398 0x07, 0x03, 0x43, 0x94, 0x0A, 0x05, 0xF8, 0x6C, 0x05, 0xEA, 0xFC,
4399 0x5C, 0x01, 0x9D, 0xFF, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
4400 0x00, 0xA9, 0xFF, 0x4D, 0x01, 0xE1, 0xFC, 0xC4, 0x05, 0xE6, 0xF6,
4401 0x08, 0x0E, 0xA5, 0x42, 0xA1, 0x04, 0x43, 0xFA, 0x97, 0x04, 0x1D,
4402 0xFD, 0x64, 0x01, 0x8F, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xFC, 0xFF,
4403 0xC8, 0xFF, 0x1E, 0x01, 0xF8, 0xFC, 0x2D, 0x06, 0x13, 0xF5, 0xC8,
4404 0x14, 0xF2, 0x40, 0x69, 0xFF, 0x97, 0xFC, 0x92, 0x03, 0x75, 0xFD,
4405 0x55, 0x01, 0x8A, 0xFF, 0x11, 0x00, 0x01, 0x00, 0xEF, 0xFF, 0xF2,
4406 0xFF, 0xD4, 0x00, 0x45, 0xFD, 0x3B, 0x06, 0xB8, 0xF3, 0xCE, 0x1B,
4407 0xFB, 0x3D, 0x08, 0xFB, 0xDE, 0xFE, 0x73, 0x02, 0xEB, 0xFD, 0x33,
4408 0x01, 0x8F, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xDE, 0xFF, 0x25, 0x00,
4409 0x71, 0x00, 0xC8, 0xFD, 0xE5, 0x05, 0xFA, 0xF2, 0xDF, 0x22, 0xDB,
4410 0x39, 0x94, 0xF7, 0xF7, 0x00, 0x4C, 0x01, 0x73, 0xFE, 0x03, 0x01,
4411 0x9A, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0xCC, 0xFF, 0x5E, 0x00, 0xF9,
4412 0xFF, 0x80, 0xFE, 0x23, 0x05, 0xF9, 0xF2, 0xC0, 0x29, 0xB8, 0x34,
4413 0x16, 0xF5, 0xCB, 0x02, 0x2F, 0x00, 0x03, 0xFF, 0xCA, 0x00, 0xAA,
4414 0xFF, 0x0B, 0x00, 0x08, 0x00, 0xB8, 0xFF, 0x9B, 0x00, 0x72, 0xFF,
4415 0x65, 0xFF, 0xF6, 0x03, 0xD1, 0xF3, 0x31, 0x30, 0xC1, 0x2E, 0x8B,
4416 0xF3, 0x45, 0x04, 0x2D, 0xFF, 0x92, 0xFF, 0x8D, 0x00, 0xBD, 0xFF,
4417 0x08, 0x00, 0x0C, 0x00, 0xA6, 0xFF, 0xD8, 0x00, 0xE2, 0xFE, 0x6F,
4418 0x00, 0x66, 0x02, 0x93, 0xF5, 0xFB, 0x35, 0x31, 0x28, 0xE7, 0xF2,
4419 0x59, 0x05, 0x51, 0xFE, 0x17, 0x00, 0x50, 0x00, 0xD0, 0xFF, 0x05,
4420 0x00, 0x0E, 0x00, 0x97, 0xFF, 0x0F, 0x01, 0x53, 0xFE, 0x90, 0x01,
4421 0x81, 0x00, 0x4B, 0xF8, 0xE6, 0x3A, 0x3F, 0x21, 0x16, 0xF3, 0x02,
4422 0x06, 0xA5, 0xFD, 0x8A, 0x00, 0x18, 0x00, 0xE2, 0xFF, 0x02, 0x00,
4423 0x10, 0x00, 0x8D, 0xFF, 0x3C, 0x01, 0xCE, 0xFD, 0xB7, 0x02, 0x5A,
4424 0xFE, 0xF7, 0xFB, 0xC6, 0x3E, 0x2C, 0x1A, 0xFC, 0xF3, 0x41, 0x06,
4425 0x2E, 0xFD, 0xE7, 0x00, 0xE7, 0xFF, 0xF2, 0xFF, 0x01, 0x00, 0x10,
4426 0x00, 0x8B, 0xFF, 0x5A, 0x01, 0x5E, 0xFD, 0xD2, 0x03, 0x0E, 0xFC,
4427 0x8B, 0x00, 0x75, 0x41, 0x32, 0x13, 0x75, 0xF5, 0x1C, 0x06, 0xEE,
4428 0xFC, 0x2B, 0x01, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0E, 0x00,
4429 0x91, 0xFF, 0x64, 0x01, 0x0D, 0xFD, 0xCD, 0x04, 0xBB, 0xF9, 0xF2,
4430 0x05, 0xD9, 0x42, 0x88, 0x0C, 0x5E, 0xF7, 0xA1, 0x05, 0xE3, 0xFC,
4431 0x54, 0x01, 0xA3, 0xFF, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
4432 0x00, 0xA2, 0xFF, 0x56, 0x01, 0xE5, 0xFC, 0x94, 0x05, 0x87, 0xF7,
4433 0x0A, 0x0C, 0xE6, 0x42, 0x64, 0x06, 0x8E, 0xF9, 0xDE, 0x04, 0x09,
4434 0xFD, 0x64, 0x01, 0x92, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00,
4435 0xBD, 0xFF, 0x2F, 0x01, 0xEC, 0xFC, 0x16, 0x06, 0x98, 0xF5, 0xAB,
4436 0x12, 0x9C, 0x41, 0xEE, 0x00, 0xE0, 0xFB, 0xE6, 0x03, 0x57, 0xFD,
4437 0x5B, 0x01, 0x8B, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF3, 0xFF, 0xE4,
4438 0xFF, 0xED, 0x00, 0x27, 0xFD, 0x41, 0x06, 0x14, 0xF4, 0xA1, 0x19,
4439 0x06, 0x3F, 0x49, 0xFC, 0x2E, 0xFE, 0xCD, 0x02, 0xC4, 0xFD, 0x3F,
4440 0x01, 0x8D, 0xFF, 0x10, 0x00, 0x02, 0x00, 0xE3, 0xFF, 0x14, 0x00,
4441 0x92, 0x00, 0x9A, 0xFD, 0x0A, 0x06, 0x22, 0xF3, 0xB4, 0x20, 0x3C,
4442 0x3B, 0x8B, 0xF8, 0x58, 0x00, 0xA7, 0x01, 0x48, 0xFE, 0x13, 0x01,
4443 0x96, 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD1, 0xFF, 0x4C, 0x00, 0x20,
4444 0x00, 0x42, 0xFE, 0x6A, 0x05, 0xE3, 0xF2, 0xAB, 0x27, 0x66, 0x36,
4445 0xC0, 0xF5, 0x44, 0x02, 0x85, 0x00, 0xD7, 0xFE, 0xDD, 0x00, 0xA5,
4446 0xFF, 0x0C, 0x00, 0x07, 0x00, 0xBE, 0xFF, 0x89, 0x00, 0x9D, 0xFF,
4447 0x1A, 0xFF, 0x5E, 0x04, 0x76, 0xF3, 0x45, 0x2E, 0xAA, 0x30, 0xEB,
4448 0xF3, 0xDB, 0x03, 0x79, 0xFF, 0x67, 0xFF, 0xA0, 0x00, 0xB7, 0xFF,
4449 0x09, 0x00, 0x0B, 0x00, 0xAC, 0xFF, 0xC6, 0x00, 0x0E, 0xFF, 0x1A,
4450 0x00, 0xEB, 0x02, 0xEF, 0xF4, 0x49, 0x34, 0x43, 0x2A, 0x02, 0xF3,
4451 0x0F, 0x05, 0x90, 0xFE, 0xEF, 0xFF, 0x63, 0x00, 0xCA, 0xFF, 0x06,
4452 0x00, 0x0E, 0x00, 0x9B, 0xFF, 0xFF, 0x00, 0x7E, 0xFE, 0x36, 0x01,
4453 0x1E, 0x01, 0x5B, 0xF7, 0x7E, 0x39, 0x69, 0x23, 0xF3, 0xF2, 0xD9,
4454 0x05, 0xD4, 0xFD, 0x69, 0x00, 0x29, 0x00, 0xDD, 0xFF, 0x03, 0x00,
4455 0x10, 0x00, 0x90, 0xFF, 0x30, 0x01, 0xF5, 0xFD, 0x5C, 0x02, 0x09,
4456 0xFF, 0xBC, 0xFA, 0xB5, 0x3D, 0x5A, 0x1C, 0xA3, 0xF3, 0x38, 0x06,
4457 0x4D, 0xFD, 0xCD, 0x00, 0xF5, 0xFF, 0xED, 0xFF, 0x01, 0x00, 0x11,
4458 0x00, 0x8B, 0xFF, 0x53, 0x01, 0x7E, 0xFD, 0x7D, 0x03, 0xC5, 0xFC,
4459 0x0B, 0xFF, 0xC3, 0x40, 0x51, 0x15, 0xF4, 0xF4, 0x31, 0x06, 0xFC,
4460 0xFC, 0x19, 0x01, 0xCB, 0xFF, 0xFB, 0xFF, 0x00, 0x00, 0x0F, 0x00,
4461 0x8E, 0xFF, 0x63, 0x01, 0x22, 0xFD, 0x84, 0x04, 0x71, 0xFA, 0x34,
4462 0x04, 0x90, 0x42, 0x89, 0x0E, 0xBE, 0xF6, 0xCF, 0x05, 0xE1, 0xFC,
4463 0x4A, 0x01, 0xAB, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B,
4464 0x00, 0x9B, 0xFF, 0x5D, 0x01, 0xEC, 0xFC, 0x5D, 0x05, 0x2F, 0xF8,
4465 0x19, 0x0A, 0x07, 0x43, 0x37, 0x08, 0xDD, 0xF8, 0x21, 0x05, 0xF8,
4466 0xFC, 0x62, 0x01, 0x96, 0xFF, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00,
4467 0xB4, 0xFF, 0x3E, 0x01, 0xE4, 0xFC, 0xF6, 0x05, 0x26, 0xF6, 0x95,
4468 0x10, 0x26, 0x42, 0x87, 0x02, 0x28, 0xFB, 0x37, 0x04, 0x3B, 0xFD,
4469 0x60, 0x01, 0x8C, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF7, 0xFF, 0xD7,
4470 0xFF, 0x04, 0x01, 0x0F, 0xFD, 0x3E, 0x06, 0x7D, 0xF4, 0x76, 0x17,
4471 0xF4, 0x3F, 0x9F, 0xFD, 0x7B, 0xFD, 0x26, 0x03, 0xA0, 0xFD, 0x4A,
4472 0x01, 0x8B, 0xFF, 0x11, 0x00, 0x02, 0x00, 0xE9, 0xFF, 0x04, 0x00,
4473 0xB1, 0x00, 0x71, 0xFD, 0x26, 0x06, 0x5A, 0xF3, 0x88, 0x1E, 0x87,
4474 0x3C, 0x98, 0xF9, 0xB3, 0xFF, 0x02, 0x02, 0x1E, 0xFE, 0x22, 0x01,
4475 0x93, 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD7, 0xFF, 0x3A, 0x00, 0x45,
4476 0x00, 0x09, 0xFE, 0xA7, 0x05, 0xE1, 0xF2, 0x8D, 0x25, 0xFD, 0x37,
4477 0x82, 0xF6, 0xB5, 0x01, 0xDC, 0x00, 0xAA, 0xFE, 0xEE, 0x00, 0xA0,
4478 0xFF, 0x0D, 0x00, 0x06, 0x00, 0xC4, 0xFF, 0x76, 0x00, 0xC7, 0xFF,
4479 0xD3, 0xFE, 0xBC, 0x04, 0x31, 0xF3, 0x4A, 0x2C, 0x83, 0x32, 0x61,
4480 0xF4, 0x68, 0x03, 0xC8, 0xFF, 0x3B, 0xFF, 0xB3, 0x00, 0xB1, 0xFF,
4481 0x0A, 0x00, 0x0A, 0x00, 0xB1, 0xFF, 0xB3, 0x00, 0x3B, 0xFF, 0xC8,
4482 0xFF, 0x68, 0x03, 0x61, 0xF4, 0x83, 0x32, 0x4A, 0x2C, 0x31, 0xF3,
4483 0xBC, 0x04, 0xD3, 0xFE, 0xC7, 0xFF, 0x76, 0x00, 0xC4, 0xFF, 0x06,
4484 0x00, 0x0D, 0x00, 0xA0, 0xFF, 0xEE, 0x00, 0xAA, 0xFE, 0xDC, 0x00,
4485 0xB5, 0x01, 0x82, 0xF6, 0xFD, 0x37, 0x8D, 0x25, 0xE1, 0xF2, 0xA7,
4486 0x05, 0x09, 0xFE, 0x45, 0x00, 0x3A, 0x00, 0xD7, 0xFF, 0x04, 0x00,
4487 0x0F, 0x00, 0x93, 0xFF, 0x22, 0x01, 0x1E, 0xFE, 0x02, 0x02, 0xB3,
4488 0xFF, 0x98, 0xF9, 0x87, 0x3C, 0x88, 0x1E, 0x5A, 0xF3, 0x26, 0x06,
4489 0x71, 0xFD, 0xB1, 0x00, 0x04, 0x00, 0xE9, 0xFF, 0x02, 0x00, 0x11,
4490 0x00, 0x8B, 0xFF, 0x4A, 0x01, 0xA0, 0xFD, 0x26, 0x03, 0x7B, 0xFD,
4491 0x9F, 0xFD, 0xF4, 0x3F, 0x76, 0x17, 0x7D, 0xF4, 0x3E, 0x06, 0x0F,
4492 0xFD, 0x04, 0x01, 0xD7, 0xFF, 0xF7, 0xFF, 0x01, 0x00, 0x10, 0x00,
4493 0x8C, 0xFF, 0x60, 0x01, 0x3B, 0xFD, 0x37, 0x04, 0x28, 0xFB, 0x87,
4494 0x02, 0x26, 0x42, 0x95, 0x10, 0x26, 0xF6, 0xF6, 0x05, 0xE4, 0xFC,
4495 0x3E, 0x01, 0xB4, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x96,
4496 0xFF, 0x62, 0x01, 0xF8, 0xFC, 0x21, 0x05, 0xDD, 0xF8, 0x37, 0x08,
4497 0x07, 0x43, 0x19, 0x0A, 0x2F, 0xF8, 0x5D, 0x05, 0xEC, 0xFC, 0x5D,
4498 0x01, 0x9B, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
4499 0xAB, 0xFF, 0x4A, 0x01, 0xE1, 0xFC, 0xCF, 0x05, 0xBE, 0xF6, 0x89,
4500 0x0E, 0x90, 0x42, 0x34, 0x04, 0x71, 0xFA, 0x84, 0x04, 0x22, 0xFD,
4501 0x63, 0x01, 0x8E, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xCB,
4502 0xFF, 0x19, 0x01, 0xFC, 0xFC, 0x31, 0x06, 0xF4, 0xF4, 0x51, 0x15,
4503 0xC3, 0x40, 0x0B, 0xFF, 0xC5, 0xFC, 0x7D, 0x03, 0x7E, 0xFD, 0x53,
4504 0x01, 0x8B, 0xFF, 0x11, 0x00, 0x01, 0x00, 0xED, 0xFF, 0xF5, 0xFF,
4505 0xCD, 0x00, 0x4D, 0xFD, 0x38, 0x06, 0xA3, 0xF3, 0x5A, 0x1C, 0xB5,
4506 0x3D, 0xBC, 0xFA, 0x09, 0xFF, 0x5C, 0x02, 0xF5, 0xFD, 0x30, 0x01,
4507 0x90, 0xFF, 0x10, 0x00, 0x03, 0x00, 0xDD, 0xFF, 0x29, 0x00, 0x69,
4508 0x00, 0xD4, 0xFD, 0xD9, 0x05, 0xF3, 0xF2, 0x69, 0x23, 0x7E, 0x39,
4509 0x5B, 0xF7, 0x1E, 0x01, 0x36, 0x01, 0x7E, 0xFE, 0xFF, 0x00, 0x9B,
4510 0xFF, 0x0E, 0x00, 0x06, 0x00, 0xCA, 0xFF, 0x63, 0x00, 0xEF, 0xFF,
4511 0x90, 0xFE, 0x0F, 0x05, 0x02, 0xF3, 0x43, 0x2A, 0x49, 0x34, 0xEF,
4512 0xF4, 0xEB, 0x02, 0x1A, 0x00, 0x0E, 0xFF, 0xC6, 0x00, 0xAC, 0xFF,
4513 0x0B, 0x00, 0x09, 0x00, 0xB7, 0xFF, 0xA0, 0x00, 0x67, 0xFF, 0x79,
4514 0xFF, 0xDB, 0x03, 0xEB, 0xF3, 0xAA, 0x30, 0x45, 0x2E, 0x76, 0xF3,
4515 0x5E, 0x04, 0x1A, 0xFF, 0x9D, 0xFF, 0x89, 0x00, 0xBE, 0xFF, 0x07,
4516 0x00, 0x0C, 0x00, 0xA5, 0xFF, 0xDD, 0x00, 0xD7, 0xFE, 0x85, 0x00,
4517 0x44, 0x02, 0xC0, 0xF5, 0x66, 0x36, 0xAB, 0x27, 0xE3, 0xF2, 0x6A,
4518 0x05, 0x42, 0xFE, 0x20, 0x00, 0x4C, 0x00, 0xD1, 0xFF, 0x04, 0x00,
4519 0x0F, 0x00, 0x96, 0xFF, 0x13, 0x01, 0x48, 0xFE, 0xA7, 0x01, 0x58,
4520 0x00, 0x8B, 0xF8, 0x3C, 0x3B, 0xB4, 0x20, 0x22, 0xF3, 0x0A, 0x06,
4521 0x9A, 0xFD, 0x92, 0x00, 0x14, 0x00, 0xE3, 0xFF, 0x02, 0x00, 0x10,
4522 0x00, 0x8D, 0xFF, 0x3F, 0x01, 0xC4, 0xFD, 0xCD, 0x02, 0x2E, 0xFE,
4523 0x49, 0xFC, 0x06, 0x3F, 0xA1, 0x19, 0x14, 0xF4, 0x41, 0x06, 0x27,
4524 0xFD, 0xED, 0x00, 0xE4, 0xFF, 0xF3, 0xFF, 0x01, 0x00, 0x10, 0x00,
4525 0x8B, 0xFF, 0x5B, 0x01, 0x57, 0xFD, 0xE6, 0x03, 0xE0, 0xFB, 0xEE,
4526 0x00, 0x9C, 0x41, 0xAB, 0x12, 0x98, 0xF5, 0x16, 0x06, 0xEC, 0xFC,
4527 0x2F, 0x01, 0xBD, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x92,
4528 0xFF, 0x64, 0x01, 0x09, 0xFD, 0xDE, 0x04, 0x8E, 0xF9, 0x64, 0x06,
4529 0xE6, 0x42, 0x0A, 0x0C, 0x87, 0xF7, 0x94, 0x05, 0xE5, 0xFC, 0x56,
4530 0x01, 0xA2, 0xFF, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
4531 0xA3, 0xFF, 0x54, 0x01, 0xE3, 0xFC, 0xA1, 0x05, 0x5E, 0xF7, 0x88,
4532 0x0C, 0xD9, 0x42, 0xF2, 0x05, 0xBB, 0xF9, 0xCD, 0x04, 0x0D, 0xFD,
4533 0x64, 0x01, 0x91, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0,
4534 0xFF, 0x2B, 0x01, 0xEE, 0xFC, 0x1C, 0x06, 0x75, 0xF5, 0x32, 0x13,
4535 0x75, 0x41, 0x8B, 0x00, 0x0E, 0xFC, 0xD2, 0x03, 0x5E, 0xFD, 0x5A,
4536 0x01, 0x8B, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF2, 0xFF, 0xE7, 0xFF,
4537 0xE7, 0x00, 0x2E, 0xFD, 0x41, 0x06, 0xFC, 0xF3, 0x2C, 0x1A, 0xC6,
4538 0x3E, 0xF7, 0xFB, 0x5A, 0xFE, 0xB7, 0x02, 0xCE, 0xFD, 0x3C, 0x01,
4539 0x8D, 0xFF, 0x10, 0x00, 0x02, 0x00, 0xE2, 0xFF, 0x18, 0x00, 0x8A,
4540 0x00, 0xA5, 0xFD, 0x02, 0x06, 0x16, 0xF3, 0x3F, 0x21, 0xE6, 0x3A,
4541 0x4B, 0xF8, 0x81, 0x00, 0x90, 0x01, 0x53, 0xFE, 0x0F, 0x01, 0x97,
4542 0xFF, 0x0E, 0x00, 0x05, 0x00, 0xD0, 0xFF, 0x50, 0x00, 0x17, 0x00,
4543 0x51, 0xFE, 0x59, 0x05, 0xE7, 0xF2, 0x31, 0x28, 0xFB, 0x35, 0x93,
4544 0xF5, 0x66, 0x02, 0x6F, 0x00, 0xE2, 0xFE, 0xD8, 0x00, 0xA6, 0xFF,
4545 0x0C, 0x00, 0x08, 0x00, 0xBD, 0xFF, 0x8D, 0x00, 0x92, 0xFF, 0x2D,
4546 0xFF, 0x45, 0x04, 0x8B, 0xF3, 0xC1, 0x2E, 0x31, 0x30, 0xD1, 0xF3,
4547 0xF6, 0x03, 0x65, 0xFF, 0x72, 0xFF, 0x9B, 0x00, 0xB8, 0xFF, 0x08,
4548 0x00, 0x0B, 0x00, 0xAA, 0xFF, 0xCA, 0x00, 0x03, 0xFF, 0x2F, 0x00,
4549 0xCB, 0x02, 0x16, 0xF5, 0xB8, 0x34, 0xC0, 0x29, 0xF9, 0xF2, 0x23,
4550 0x05, 0x80, 0xFE, 0xF9, 0xFF, 0x5E, 0x00, 0xCC, 0xFF, 0x05, 0x00,
4551 0x0E, 0x00, 0x9A, 0xFF, 0x03, 0x01, 0x73, 0xFE, 0x4C, 0x01, 0xF7,
4552 0x00, 0x94, 0xF7, 0xDB, 0x39, 0xDF, 0x22, 0xFA, 0xF2, 0xE5, 0x05,
4553 0xC8, 0xFD, 0x71, 0x00, 0x25, 0x00, 0xDE, 0xFF, 0x03, 0x00, 0x10,
4554 0x00, 0x8F, 0xFF, 0x33, 0x01, 0xEB, 0xFD, 0x73, 0x02, 0xDE, 0xFE,
4555 0x08, 0xFB, 0xFB, 0x3D, 0xCE, 0x1B, 0xB8, 0xF3, 0x3B, 0x06, 0x45,
4556 0xFD, 0xD4, 0x00, 0xF2, 0xFF, 0xEF, 0xFF, 0x01, 0x00, 0x11, 0x00,
4557 0x8A, 0xFF, 0x55, 0x01, 0x75, 0xFD, 0x92, 0x03, 0x97, 0xFC, 0x69,
4558 0xFF, 0xF2, 0x40, 0xC8, 0x14, 0x13, 0xF5, 0x2D, 0x06, 0xF8, 0xFC,
4559 0x1E, 0x01, 0xC8, 0xFF, 0xFC, 0xFF, 0x00, 0x00, 0x0F, 0x00, 0x8F,
4560 0xFF, 0x64, 0x01, 0x1D, 0xFD, 0x97, 0x04, 0x43, 0xFA, 0xA1, 0x04,
4561 0xA5, 0x42, 0x08, 0x0E, 0xE6, 0xF6, 0xC4, 0x05, 0xE1, 0xFC, 0x4D,
4562 0x01, 0xA9, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
4563 0x9D, 0xFF, 0x5C, 0x01, 0xEA, 0xFC, 0x6C, 0x05, 0x05, 0xF8, 0x94,
4564 0x0A, 0x03, 0x43, 0xC1, 0x07, 0x09, 0xF9, 0x10, 0x05, 0xFC, 0xFC,
4565 0x62, 0x01, 0x95, 0xFF, 0x0D, 0x00, 0x00, 0x00, 0x02, 0x00, 0xB6,
4566 0xFF, 0x3B, 0x01, 0xE5, 0xFC, 0xFF, 0x05, 0x02, 0xF6, 0x19, 0x11,
4567 0x06, 0x42, 0x1F, 0x02, 0x56, 0xFB, 0x23, 0x04, 0x41, 0xFD, 0x5F,
4568 0x01, 0x8B, 0xFF, 0x10, 0x00, 0x01, 0x00, 0xF6, 0xFF, 0xDA, 0xFF,
4569 0xFF, 0x00, 0x15, 0xFD, 0x40, 0x06, 0x62, 0xF4, 0x01, 0x18, 0xBB,
4570 0x3F, 0x47, 0xFD, 0xA8, 0xFD, 0x10, 0x03, 0xA9, 0xFD, 0x47, 0x01,
4571 0x8C, 0xFF, 0x11, 0x00, 0x02, 0x00, 0xE7, 0xFF, 0x08, 0x00, 0xA9,
4572 0x00, 0x7B, 0xFD, 0x20, 0x06, 0x4B, 0xF3, 0x13, 0x1F, 0x36, 0x3C,
4573 0x52, 0xF9, 0xDD, 0xFF, 0xEB, 0x01, 0x28, 0xFE, 0x1F, 0x01, 0x93,
4574 0xFF, 0x0F, 0x00, 0x04, 0x00, 0xD6, 0xFF, 0x3F, 0x00, 0x3C, 0x00,
4575 0x16, 0xFE, 0x98, 0x05, 0xE0, 0xF2, 0x16, 0x26, 0x99, 0x37, 0x4F,
4576 0xF6, 0xD9, 0x01, 0xC6, 0x00, 0xB5, 0xFE, 0xEA, 0x00, 0xA1, 0xFF,
4577 0x0D, 0x00, 0x07, 0x00, 0xC3, 0xFF, 0x7A, 0x00, 0xBC, 0xFF, 0xE4,
4578 0xFE, 0xA5, 0x04, 0x41, 0xF3, 0xCA, 0x2C, 0x0E, 0x32, 0x42, 0xF4,
4579 0x85, 0x03, 0xB4, 0xFF, 0x46, 0xFF, 0xAE, 0x00, 0xB3, 0xFF, 0x09,
4580 0x00, 0x0A, 0x00, 0xB0, 0xFF, 0xB8, 0x00, 0x30, 0xFF, 0xDC, 0xFF,
4581 0x49, 0x03, 0x83, 0xF4, 0xF5, 0x32, 0xC9, 0x2B, 0x23, 0xF3, 0xD1,
4582 0x04, 0xC2, 0xFE, 0xD1, 0xFF, 0x71, 0x00, 0xC6, 0xFF, 0x06, 0x00,
4583 0x0D, 0x00, 0x9F, 0xFF, 0xF3, 0x00, 0x9F, 0xFE, 0xF3, 0x00, 0x90,
4584 0x01, 0xB6, 0xF6, 0x5F, 0x38, 0x04, 0x25, 0xE4, 0xF2, 0xB4, 0x05,
4585 0xFB, 0xFD, 0x4E, 0x00, 0x36, 0x00, 0xD9, 0xFF, 0x04, 0x00, 0x0F,
4586 0x00, 0x92, 0xFF, 0x26, 0x01, 0x13, 0xFE, 0x18, 0x02, 0x89, 0xFF,
4587 0xDF, 0xF9, 0xD3, 0x3C, 0xFC, 0x1D, 0x6B, 0xF3, 0x2C, 0x06, 0x67,
4588 0xFD, 0xB8, 0x00, 0x00, 0x00, 0xEA, 0xFF, 0x02, 0x00, 0x11, 0x00,
4589 0x8B, 0xFF, 0x4C, 0x01, 0x97, 0xFD, 0x3C, 0x03, 0x4D, 0xFD, 0xF8,
4590 0xFD, 0x2A, 0x40, 0xED, 0x16, 0x9A, 0xF4, 0x3C, 0x06, 0x0A, 0xFD,
4591 0x0A, 0x01, 0xD4, 0xFF, 0xF8, 0xFF, 0x01, 0x00, 0x10, 0x00, 0x8C,
4592 0xFF, 0x61, 0x01, 0x34, 0xFD, 0x4B, 0x04, 0xFA, 0xFA, 0xF1, 0x02,
4593 0x42, 0x42, 0x11, 0x10, 0x4C, 0xF6, 0xED, 0x05, 0xE3, 0xFC, 0x41,
4594 0x01, 0xB1, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x97, 0xFF,
4595 0x61, 0x01, 0xF5, 0xFC, 0x30, 0x05, 0xB1, 0xF8, 0xAE, 0x08, 0x0A,
4596 0x43, 0x9F, 0x09, 0x5A, 0xF8, 0x4F, 0x05, 0xEF, 0xFC, 0x5F, 0x01,
4597 0x9A, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xAD,
4598 0xFF, 0x48, 0x01, 0xE2, 0xFC, 0xDA, 0x05, 0x97, 0xF6, 0x0B, 0x0F,
4599 0x79, 0x42, 0xC7, 0x03, 0x9E, 0xFA, 0x71, 0x04, 0x28, 0xFD, 0x63,
4600 0x01, 0x8D, 0xFF, 0x0F, 0x00
4601};
4602
4603static u16
4604CoefficientSizes[] = {
4605 /* Playback */
4606 0x00C0, 0x5000, 0x0060, 0x2800, 0x0040, 0x0060, 0x1400, 0x0000,
4607 /* Record */
4608 0x0020, 0x1260, 0x0020, 0x1260, 0x0000, 0x0040, 0x1260, 0x0000,
4609};
4610
4611#ifndef JUST_DATA
4612
4613static u16
4614nm256_getStartOffset (u8 which)
4615{
4616 u16 offset = 0;
4617
4618 while (which-- > 0)
4619 offset += CoefficientSizes[which];
4620
4621 return offset;
4622}
4623
4624static void
4625nm256_loadOneCoefficient (struct nm256_info *card, int devnum, u32 port,
4626 u16 which)
4627{
4628 u32 coeffBuf = (which < 8) ? card->coeffBuf : card->allCoeffBuf;
4629 u16 offset = nm256_getStartOffset (which);
4630 u16 size = CoefficientSizes[which];
4631
4632 card->coeffsCurrent = 0;
4633
4634 if (nm256_debug)
4635 printk (KERN_INFO "NM256: Loading coefficient buffer 0x%x-0x%x with coefficient %d, size %d, port 0x%x\n",
4636 coeffBuf, coeffBuf + size - 1, which, size, port);
4637 nm256_writeBuffer8 (card, coefficients + offset, 1, coeffBuf, size);
4638 nm256_writePort32 (card, 2, port + 0, coeffBuf);
4639 /* ??? Record seems to behave differently than playback. */
4640 if (devnum == 0)
4641 size--;
4642 nm256_writePort32 (card, 2, port + 4, coeffBuf + size);
4643}
4644
4645static void
4646nm256_loadAllCoefficients (struct nm256_info *card)
4647{
4648 nm256_writeBuffer8 (card, coefficients, 1, card->allCoeffBuf,
4649 NM_TOTAL_COEFF_COUNT * 4);
4650 card->coeffsCurrent = 1;
4651}
4652
4653static void
4654nm256_loadCoefficient (struct nm256_info *card, int which, int number)
4655{
4656 static u16 addrs[3] = { 0x1c, 0x21c, 0x408 };
4657 /* The enable register for the specified engine. */
4658 u32 poffset = (which == 1 ? 0x200 : 1);
4659
4660 if (nm256_readPort8 (card, 2, poffset) & 1) {
4661 printk (KERN_ERR "NM256: Engine was enabled while loading coefficients!\n");
4662 return;
4663 }
4664
4665 /* The recording engine uses coefficient values 8-15. */
4666 if (which == 1)
4667 number += 8;
4668
4669 if (! nm256_cachedCoefficients (card))
4670 nm256_loadOneCoefficient (card, which, addrs[which], number);
4671 else {
4672 u32 base = card->allCoeffBuf;
4673 u32 offset = nm256_getStartOffset (number);
4674 u32 endOffset = offset + CoefficientSizes[number];
4675
4676 if (nm256_debug)
4677 printk (KERN_DEBUG "loading coefficient %d at port 0x%x, offset %d (0x%x-0x%x)\n",
4678 number, addrs[which], offset, base + offset,
4679 base + endOffset - 1);
4680
4681 if (! card->coeffsCurrent)
4682 nm256_loadAllCoefficients (card);
4683
4684 nm256_writePort32 (card, 2, addrs[which], base + offset);
4685 nm256_writePort32 (card, 2, addrs[which] + 4, base + endOffset - 1);
4686 }
4687}
4688
4689#endif /* JUST_DATA */
4690
4691#endif
4692
4693/*
4694 * Local variables:
4695 * c-basic-offset: 4
4696 * End:
4697 */
diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c
index fc273e55094..7781c13c147 100644
--- a/sound/oss/opl3.c
+++ b/sound/oss/opl3.c
@@ -34,7 +34,6 @@
34 34
35#include "sound_config.h" 35#include "sound_config.h"
36 36
37#include "opl3.h"
38#include "opl3_hw.h" 37#include "opl3_hw.h"
39 38
40#define MAX_VOICE 18 39#define MAX_VOICE 18
@@ -73,7 +72,6 @@ typedef struct opl_devinfo
73 unsigned char cmask; 72 unsigned char cmask;
74 73
75 int is_opl4; 74 int is_opl4;
76 int *osp;
77} opl_devinfo; 75} opl_devinfo;
78 76
79static struct opl_devinfo *devc = NULL; 77static struct opl_devinfo *devc = NULL;
@@ -144,7 +142,7 @@ static int opl3_ioctl(int dev, unsigned int cmd, void __user * arg)
144 } 142 }
145} 143}
146 144
147int opl3_detect(int ioaddr, int *osp) 145static int opl3_detect(int ioaddr)
148{ 146{
149 /* 147 /*
150 * This function returns 1 if the FM chip is present at the given I/O port 148 * This function returns 1 if the FM chip is present at the given I/O port
@@ -182,7 +180,6 @@ int opl3_detect(int ioaddr, int *osp)
182 goto cleanup_devc; 180 goto cleanup_devc;
183 } 181 }
184 182
185 devc->osp = osp;
186 devc->base = ioaddr; 183 devc->base = ioaddr;
187 184
188 /* Reset timers 1 and 2 */ 185 /* Reset timers 1 and 2 */
@@ -1105,7 +1102,7 @@ static struct synth_operations opl3_operations =
1105 .setup_voice = opl3_setup_voice 1102 .setup_voice = opl3_setup_voice
1106}; 1103};
1107 1104
1108int opl3_init(int ioaddr, int *osp, struct module *owner) 1105static int opl3_init(int ioaddr, struct module *owner)
1109{ 1106{
1110 int i; 1107 int i;
1111 int me; 1108 int me;
@@ -1194,9 +1191,6 @@ int opl3_init(int ioaddr, int *osp, struct module *owner)
1194 return me; 1191 return me;
1195} 1192}
1196 1193
1197EXPORT_SYMBOL(opl3_init);
1198EXPORT_SYMBOL(opl3_detect);
1199
1200static int me; 1194static int me;
1201 1195
1202static int io = -1; 1196static int io = -1;
@@ -1209,12 +1203,12 @@ static int __init init_opl3 (void)
1209 1203
1210 if (io != -1) /* User loading pure OPL3 module */ 1204 if (io != -1) /* User loading pure OPL3 module */
1211 { 1205 {
1212 if (!opl3_detect(io, NULL)) 1206 if (!opl3_detect(io))
1213 { 1207 {
1214 return -ENODEV; 1208 return -ENODEV;
1215 } 1209 }
1216 1210
1217 me = opl3_init(io, NULL, THIS_MODULE); 1211 me = opl3_init(io, THIS_MODULE);
1218 } 1212 }
1219 1213
1220 return 0; 1214 return 0;
diff --git a/sound/oss/opl3.h b/sound/oss/opl3.h
deleted file mode 100644
index 0bc9a4bcda1..00000000000
--- a/sound/oss/opl3.h
+++ /dev/null
@@ -1,5 +0,0 @@
1
2int opl3_detect (int ioaddr, int *osp);
3int opl3_init(int ioaddr, int *osp, struct module *owner);
4
5void enable_opl3_mode(int left, int right, int both);
diff --git a/sound/oss/opl3sa2.c b/sound/oss/opl3sa2.c
deleted file mode 100644
index e20051f1be4..00000000000
--- a/sound/oss/opl3sa2.c
+++ /dev/null
@@ -1,1020 +0,0 @@
1/*
2 * sound/oss/opl3sa2.c
3 *
4 * A low level driver for Yamaha OPL3-SA2 and SA3 cards.
5 * NOTE: All traces of the name OPL3-SAx have now (December 2000) been
6 * removed from the driver code, as an email exchange with Yamaha
7 * provided the information that the YMF-719 is indeed just a
8 * re-badged 715.
9 *
10 * Copyright 1998-2001 Scott Murray <scott@spiteful.org>
11 *
12 * Originally based on the CS4232 driver (in cs4232.c) by Hannu Savolainen
13 * and others. Now incorporates code/ideas from pss.c, also by Hannu
14 * Savolainen. Both of those files are distributed with the following
15 * license:
16 *
17 * "Copyright (C) by Hannu Savolainen 1993-1997
18 *
19 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
20 * Version 2 (June 1991). See the "COPYING" file distributed with this software
21 * for more info."
22 *
23 * As such, in accordance with the above license, this file, opl3sa2.c, is
24 * distributed under the GNU GENERAL PUBLIC LICENSE (GPL) Version 2 (June 1991).
25 * See the "COPYING" file distributed with this software for more information.
26 *
27 * Change History
28 * --------------
29 * Scott Murray Original driver (Jun 14, 1998)
30 * Paul J.Y. Lahaie Changed probing / attach code order
31 * Scott Murray Added mixer support (Dec 03, 1998)
32 * Scott Murray Changed detection code to be more forgiving,
33 * added force option as last resort,
34 * fixed ioctl return values. (Dec 30, 1998)
35 * Scott Murray Simpler detection code should work all the time now
36 * (with thanks to Ben Hutchings for the heuristic),
37 * removed now unnecessary force option. (Jan 5, 1999)
38 * Christoph Hellwig Adapted to module_init/module_exit (Mar 4, 2000)
39 * Scott Murray Reworked SA2 versus SA3 mixer code, updated chipset
40 * version detection code (again!). (Dec 5, 2000)
41 * Scott Murray Adjusted master volume mixer scaling. (Dec 6, 2000)
42 * Scott Murray Based on a patch by Joel Yliluoma (aka Bisqwit),
43 * integrated wide mixer and adjusted mic, bass, treble
44 * scaling. (Dec 6, 2000)
45 * Scott Murray Based on a patch by Peter Englmaier, integrated
46 * ymode and loopback options. (Dec 6, 2000)
47 * Scott Murray Inspired by a patch by Peter Englmaier, and based on
48 * what ALSA does, added initialization code for the
49 * default DMA and IRQ settings. (Dec 6, 2000)
50 * Scott Murray Added some more checks to the card detection code,
51 * based on what ALSA does. (Dec 12, 2000)
52 * Scott Murray Inspired by similar patches from John Fremlin,
53 * Jim Radford, Mike Rolig, and Ingmar Steen, added 2.4
54 * ISA PnP API support, mainly based on bits from
55 * sb_card.c and awe_wave.c. (Dec 12, 2000)
56 * Scott Murray Some small cleanups to the init code output.
57 * (Jan 7, 2001)
58 * Zwane Mwaikambo Added PM support. (Dec 4 2001)
59 *
60 * Adam Belay Converted driver to new PnP Layer (Oct 12, 2002)
61 * Zwane Mwaikambo Code, data structure cleanups. (Feb 15 2002)
62 * Zwane Mwaikambo Free resources during auxiliary device probe
63 * failures (Apr 29 2002)
64 *
65 */
66
67#include <linux/pnp.h>
68#include <linux/init.h>
69#include <linux/module.h>
70#include <linux/delay.h>
71#include "sound_config.h"
72
73#include "ad1848.h"
74#include "mpu401.h"
75
76#define OPL3SA2_MODULE_NAME "opl3sa2"
77#define PFX OPL3SA2_MODULE_NAME ": "
78
79/* Useful control port indexes: */
80#define OPL3SA2_PM 0x01
81#define OPL3SA2_SYS_CTRL 0x02
82#define OPL3SA2_IRQ_CONFIG 0x03
83#define OPL3SA2_DMA_CONFIG 0x06
84#define OPL3SA2_MASTER_LEFT 0x07
85#define OPL3SA2_MASTER_RIGHT 0x08
86#define OPL3SA2_MIC 0x09
87#define OPL3SA2_MISC 0x0A
88
89#define OPL3SA3_WIDE 0x14
90#define OPL3SA3_BASS 0x15
91#define OPL3SA3_TREBLE 0x16
92
93/* Useful constants: */
94#define DEFAULT_VOLUME 50
95#define DEFAULT_MIC 50
96#define DEFAULT_TIMBRE 0
97
98/* Power saving modes */
99#define OPL3SA2_PM_MODE0 0x00
100#define OPL3SA2_PM_MODE1 0x04 /* PSV */
101#define OPL3SA2_PM_MODE2 0x05 /* PSV | PDX */
102#define OPL3SA2_PM_MODE3 0x27 /* ADOWN | PSV | PDN | PDX */
103
104
105/* For checking against what the card returns: */
106#define VERSION_UNKNOWN 0
107#define VERSION_YMF711 1
108#define VERSION_YMF715 2
109#define VERSION_YMF715B 3
110#define VERSION_YMF715E 4
111/* also assuming that anything > 4 but <= 7 is a 715E */
112
113/* Chipset type constants for use below */
114#define CHIPSET_UNKNOWN -1
115#define CHIPSET_OPL3SA2 0
116#define CHIPSET_OPL3SA3 1
117static const char *CHIPSET_TABLE[] = {"OPL3-SA2", "OPL3-SA3"};
118
119#ifdef CONFIG_PNP
120#define OPL3SA2_CARDS_MAX 4
121#else
122#define OPL3SA2_CARDS_MAX 1
123#endif
124
125/* This should be pretty obvious */
126static int opl3sa2_cards_num;
127
128typedef struct {
129 /* device resources */
130 unsigned short cfg_port;
131 struct address_info cfg;
132 struct address_info cfg_mss;
133 struct address_info cfg_mpu;
134#ifdef CONFIG_PNP
135 /* PnP Stuff */
136 struct pnp_dev* pdev;
137 int activated; /* Whether said devices have been activated */
138#endif
139 unsigned int card;
140 int chipset; /* What's my version(s)? */
141 char *chipset_name;
142
143 /* mixer data */
144 int mixer;
145 unsigned int volume_l;
146 unsigned int volume_r;
147 unsigned int mic;
148 unsigned int bass_l;
149 unsigned int bass_r;
150 unsigned int treble_l;
151 unsigned int treble_r;
152 unsigned int wide_l;
153 unsigned int wide_r;
154} opl3sa2_state_t;
155static opl3sa2_state_t opl3sa2_state[OPL3SA2_CARDS_MAX];
156
157
158
159/* Our parameters */
160static int __initdata io = -1;
161static int __initdata mss_io = -1;
162static int __initdata mpu_io = -1;
163static int __initdata irq = -1;
164static int __initdata dma = -1;
165static int __initdata dma2 = -1;
166static int __initdata ymode = -1;
167static int __initdata loopback = -1;
168
169#ifdef CONFIG_PNP
170/* PnP specific parameters */
171static int __initdata isapnp = 1;
172static int __initdata multiple = 1;
173
174/* Whether said devices have been activated */
175static int opl3sa2_activated[OPL3SA2_CARDS_MAX];
176#else
177static int __initdata isapnp; /* = 0 */
178static int __initdata multiple; /* = 0 */
179#endif
180
181MODULE_DESCRIPTION("Module for OPL3-SA2 and SA3 sound cards (uses AD1848 MSS driver).");
182MODULE_AUTHOR("Scott Murray <scott@spiteful.org>");
183MODULE_LICENSE("GPL");
184
185
186module_param(io, int, 0);
187MODULE_PARM_DESC(io, "Set I/O base of OPL3-SA2 or SA3 card (usually 0x370. Address must be even and must be from 0x100 to 0xFFE)");
188
189module_param(mss_io, int, 0);
190MODULE_PARM_DESC(mss_io, "Set MSS (audio) I/O base (0x530, 0xE80, or other. Address must end in 0 or 4 and must be from 0x530 to 0xF48)");
191
192module_param(mpu_io, int, 0);
193MODULE_PARM_DESC(mpu_io, "Set MIDI I/O base (0x330 or other. Address must be even and must be from 0x300 to 0x334)");
194
195module_param(irq, int, 0);
196MODULE_PARM_DESC(irq, "Set MSS (audio) IRQ (5, 7, 9, 10, 11, 12)");
197
198module_param(dma, int, 0);
199MODULE_PARM_DESC(dma, "Set MSS (audio) first DMA channel (0, 1, 3)");
200
201module_param(dma2, int, 0);
202MODULE_PARM_DESC(dma2, "Set MSS (audio) second DMA channel (0, 1, 3)");
203
204module_param(ymode, int, 0);
205MODULE_PARM_DESC(ymode, "Set Yamaha 3D enhancement mode (0 = Desktop/Normal, 1 = Notebook PC (1), 2 = Notebook PC (2), 3 = Hi-Fi)");
206
207module_param(loopback, int, 0);
208MODULE_PARM_DESC(loopback, "Set A/D input source. Useful for echo cancellation (0 = Mic Rch (default), 1 = Mono output loopback)");
209
210#ifdef CONFIG_PNP
211module_param(isapnp, bool, 0);
212MODULE_PARM_DESC(isapnp, "When set to 0, ISA PnP support will be disabled");
213
214module_param(multiple, bool, 0);
215MODULE_PARM_DESC(multiple, "When set to 0, will not search for multiple cards");
216#endif
217
218
219/*
220 * Standard read and write functions
221*/
222
223static inline void opl3sa2_write(unsigned short port,
224 unsigned char index,
225 unsigned char data)
226{
227 outb_p(index, port);
228 outb(data, port + 1);
229}
230
231
232static inline void opl3sa2_read(unsigned short port,
233 unsigned char index,
234 unsigned char* data)
235{
236 outb_p(index, port);
237 *data = inb(port + 1);
238}
239
240
241/*
242 * All of the mixer functions...
243 */
244
245static void opl3sa2_set_volume(opl3sa2_state_t* devc, int left, int right)
246{
247 static unsigned char scale[101] = {
248 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x0e,
249 0x0e, 0x0e, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0c,
250 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b,
251 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x09, 0x09,
252 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08,
253 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06,
254 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
255 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03,
256 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
257 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
258 0x00
259 };
260 unsigned char vol;
261
262 vol = scale[left];
263
264 /* If level is zero, turn on mute */
265 if(!left)
266 vol |= 0x80;
267
268 opl3sa2_write(devc->cfg_port, OPL3SA2_MASTER_LEFT, vol);
269
270 vol = scale[right];
271
272 /* If level is zero, turn on mute */
273 if(!right)
274 vol |= 0x80;
275
276 opl3sa2_write(devc->cfg_port, OPL3SA2_MASTER_RIGHT, vol);
277}
278
279
280static void opl3sa2_set_mic(opl3sa2_state_t* devc, int level)
281{
282 unsigned char vol = 0x1F;
283
284 if((level >= 0) && (level <= 100))
285 vol = 0x1F - (unsigned char) (32 * level / 101);
286
287 /* If level is zero, turn on mute */
288 if(!level)
289 vol |= 0x80;
290
291 opl3sa2_write(devc->cfg_port, OPL3SA2_MIC, vol);
292}
293
294
295static void opl3sa3_set_bass(opl3sa2_state_t* devc, int left, int right)
296{
297 unsigned char bass;
298
299 bass = left ? ((unsigned char) (8 * left / 101)) : 0;
300 bass |= (right ? ((unsigned char) (8 * right / 101)) : 0) << 4;
301
302 opl3sa2_write(devc->cfg_port, OPL3SA3_BASS, bass);
303}
304
305
306static void opl3sa3_set_treble(opl3sa2_state_t* devc, int left, int right)
307{
308 unsigned char treble;
309
310 treble = left ? ((unsigned char) (8 * left / 101)) : 0;
311 treble |= (right ? ((unsigned char) (8 * right / 101)) : 0) << 4;
312
313 opl3sa2_write(devc->cfg_port, OPL3SA3_TREBLE, treble);
314}
315
316
317
318
319static void opl3sa2_mixer_reset(opl3sa2_state_t* devc)
320{
321 if (devc) {
322 opl3sa2_set_volume(devc, DEFAULT_VOLUME, DEFAULT_VOLUME);
323 devc->volume_l = devc->volume_r = DEFAULT_VOLUME;
324
325 opl3sa2_set_mic(devc, DEFAULT_MIC);
326 devc->mic = DEFAULT_MIC;
327
328 if (devc->chipset == CHIPSET_OPL3SA3) {
329 opl3sa3_set_bass(devc, DEFAULT_TIMBRE, DEFAULT_TIMBRE);
330 devc->bass_l = devc->bass_r = DEFAULT_TIMBRE;
331 opl3sa3_set_treble(devc, DEFAULT_TIMBRE, DEFAULT_TIMBRE);
332 devc->treble_l = devc->treble_r = DEFAULT_TIMBRE;
333 }
334 }
335}
336
337static inline void arg_to_vol_mono(unsigned int vol, int* value)
338{
339 int left;
340
341 left = vol & 0x00ff;
342 if (left > 100)
343 left = 100;
344 *value = left;
345}
346
347
348static inline void arg_to_vol_stereo(unsigned int vol, int* aleft, int* aright)
349{
350 arg_to_vol_mono(vol, aleft);
351 arg_to_vol_mono(vol >> 8, aright);
352}
353
354
355static inline int ret_vol_mono(int vol)
356{
357 return ((vol << 8) | vol);
358}
359
360
361static inline int ret_vol_stereo(int left, int right)
362{
363 return ((right << 8) | left);
364}
365
366
367static int opl3sa2_mixer_ioctl(int dev, unsigned int cmd, void __user *arg)
368{
369 int retval, value, cmdf = cmd & 0xff;
370 int __user *p = (int __user *)arg;
371
372 opl3sa2_state_t* devc = &opl3sa2_state[dev];
373
374 switch (cmdf) {
375 case SOUND_MIXER_VOLUME:
376 case SOUND_MIXER_MIC:
377 case SOUND_MIXER_DEVMASK:
378 case SOUND_MIXER_STEREODEVS:
379 case SOUND_MIXER_RECMASK:
380 case SOUND_MIXER_RECSRC:
381 case SOUND_MIXER_CAPS:
382 break;
383
384 default:
385 return -EINVAL;
386 }
387
388 if (((cmd >> 8) & 0xff) != 'M')
389 return -EINVAL;
390
391 retval = 0;
392 if (_SIOC_DIR (cmd) & _SIOC_WRITE) {
393 switch (cmdf) {
394 case SOUND_MIXER_VOLUME:
395 retval = get_user(value, (unsigned __user *) arg);
396 if (retval)
397 break;
398 arg_to_vol_stereo(value, &devc->volume_l, &devc->volume_r);
399 opl3sa2_set_volume(devc, devc->volume_l, devc->volume_r);
400 value = ret_vol_stereo(devc->volume_l, devc->volume_r);
401 retval = put_user(value, p);
402 break;
403
404 case SOUND_MIXER_MIC:
405 retval = get_user(value, (unsigned __user *) arg);
406 if (retval)
407 break;
408 arg_to_vol_mono(value, &devc->mic);
409 opl3sa2_set_mic(devc, devc->mic);
410 value = ret_vol_mono(devc->mic);
411 retval = put_user(value, p);
412 break;
413
414 default:
415 retval = -EINVAL;
416 }
417 }
418 else {
419 /*
420 * Return parameters
421 */
422 switch (cmdf) {
423 case SOUND_MIXER_DEVMASK:
424 retval = put_user(SOUND_MASK_VOLUME | SOUND_MASK_MIC, p);
425 break;
426
427 case SOUND_MIXER_STEREODEVS:
428 retval = put_user(SOUND_MASK_VOLUME, p);
429 break;
430
431 case SOUND_MIXER_RECMASK:
432 /* No recording devices */
433 retval = put_user(0, p);
434 break;
435
436 case SOUND_MIXER_CAPS:
437 retval = put_user(SOUND_CAP_EXCL_INPUT, p);
438 break;
439
440 case SOUND_MIXER_RECSRC:
441 /* No recording source */
442 retval = put_user(0, p);
443 break;
444
445 case SOUND_MIXER_VOLUME:
446 value = ret_vol_stereo(devc->volume_l, devc->volume_r);
447 retval = put_user(value, p);
448 break;
449
450 case SOUND_MIXER_MIC:
451 value = ret_vol_mono(devc->mic);
452 put_user(value, p);
453 break;
454
455 default:
456 retval = -EINVAL;
457 }
458 }
459 return retval;
460}
461/* opl3sa2_mixer_ioctl end */
462
463
464static int opl3sa3_mixer_ioctl(int dev, unsigned int cmd, void __user * arg)
465{
466 int value, retval, cmdf = cmd & 0xff;
467
468 opl3sa2_state_t* devc = &opl3sa2_state[dev];
469
470 switch (cmdf) {
471 case SOUND_MIXER_BASS:
472 value = ret_vol_stereo(devc->bass_l, devc->bass_r);
473 retval = put_user(value, (int __user *) arg);
474 break;
475
476 case SOUND_MIXER_TREBLE:
477 value = ret_vol_stereo(devc->treble_l, devc->treble_r);
478 retval = put_user(value, (int __user *) arg);
479 break;
480
481 case SOUND_MIXER_DIGITAL1:
482 value = ret_vol_stereo(devc->wide_l, devc->wide_r);
483 retval = put_user(value, (int __user *) arg);
484 break;
485
486 default:
487 retval = -EINVAL;
488 }
489 return retval;
490}
491/* opl3sa3_mixer_ioctl end */
492
493
494static struct mixer_operations opl3sa2_mixer_operations =
495{
496 .owner = THIS_MODULE,
497 .id = "OPL3-SA2",
498 .name = "Yamaha OPL3-SA2",
499 .ioctl = opl3sa2_mixer_ioctl
500};
501
502static struct mixer_operations opl3sa3_mixer_operations =
503{
504 .owner = THIS_MODULE,
505 .id = "OPL3-SA3",
506 .name = "Yamaha OPL3-SA3",
507 .ioctl = opl3sa3_mixer_ioctl
508};
509
510/* End of mixer-related stuff */
511
512
513/*
514 * Component probe, attach, unload functions
515 */
516
517static inline void __exit unload_opl3sa2_mpu(struct address_info *hw_config)
518{
519 unload_mpu401(hw_config);
520}
521
522
523static void __init attach_opl3sa2_mss(struct address_info* hw_config, struct resource *ports)
524{
525 int initial_mixers;
526
527 initial_mixers = num_mixers;
528 attach_ms_sound(hw_config, ports, THIS_MODULE); /* Slot 0 */
529 if (hw_config->slots[0] != -1) {
530 /* Did the MSS driver install? */
531 if(num_mixers == (initial_mixers + 1)) {
532 /* The MSS mixer is installed, reroute mixers appropriately */
533 AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_CD);
534 AD1848_REROUTE(SOUND_MIXER_LINE2, SOUND_MIXER_SYNTH);
535 AD1848_REROUTE(SOUND_MIXER_LINE3, SOUND_MIXER_LINE);
536 }
537 else {
538 printk(KERN_ERR PFX "MSS mixer not installed?\n");
539 }
540 }
541}
542
543
544static inline void __exit unload_opl3sa2_mss(struct address_info* hw_config)
545{
546 unload_ms_sound(hw_config);
547}
548
549
550static int __init probe_opl3sa2(struct address_info* hw_config, int card)
551{
552 unsigned char misc;
553 unsigned char tmp;
554 unsigned char version;
555
556 /*
557 * Try and allocate our I/O port range.
558 */
559 if (!request_region(hw_config->io_base, 2, OPL3SA2_MODULE_NAME)) {
560 printk(KERN_ERR PFX "Control I/O port %#x not free\n",
561 hw_config->io_base);
562 goto out_nodev;
563 }
564
565 /*
566 * Check if writing to the read-only version bits of the miscellaneous
567 * register succeeds or not (it should not).
568 */
569 opl3sa2_read(hw_config->io_base, OPL3SA2_MISC, &misc);
570 opl3sa2_write(hw_config->io_base, OPL3SA2_MISC, misc ^ 0x07);
571 opl3sa2_read(hw_config->io_base, OPL3SA2_MISC, &tmp);
572 if(tmp != misc) {
573 printk(KERN_ERR PFX "Control I/O port %#x is not a YMF7xx chipset!\n",
574 hw_config->io_base);
575 goto out_region;
576 }
577
578 /*
579 * Check if the MIC register is accessible.
580 */
581 opl3sa2_read(hw_config->io_base, OPL3SA2_MIC, &tmp);
582 opl3sa2_write(hw_config->io_base, OPL3SA2_MIC, 0x8a);
583 opl3sa2_read(hw_config->io_base, OPL3SA2_MIC, &tmp);
584 if((tmp & 0x9f) != 0x8a) {
585 printk(KERN_ERR
586 PFX "Control I/O port %#x is not a YMF7xx chipset!\n",
587 hw_config->io_base);
588 goto out_region;
589 }
590 opl3sa2_write(hw_config->io_base, OPL3SA2_MIC, tmp);
591
592 /*
593 * Determine chipset type (SA2 or SA3)
594 *
595 * This is done by looking at the chipset version in the lower 3 bits
596 * of the miscellaneous register.
597 */
598 version = misc & 0x07;
599 printk(KERN_DEBUG PFX "Chipset version = %#x\n", version);
600 switch (version) {
601 case 0:
602 opl3sa2_state[card].chipset = CHIPSET_UNKNOWN;
603 printk(KERN_ERR
604 PFX "Unknown Yamaha audio controller version\n");
605 break;
606
607 case VERSION_YMF711:
608 opl3sa2_state[card].chipset = CHIPSET_OPL3SA2;
609 printk(KERN_INFO PFX "Found OPL3-SA2 (YMF711)\n");
610 break;
611
612 case VERSION_YMF715:
613 opl3sa2_state[card].chipset = CHIPSET_OPL3SA3;
614 printk(KERN_INFO
615 PFX "Found OPL3-SA3 (YMF715 or YMF719)\n");
616 break;
617
618 case VERSION_YMF715B:
619 opl3sa2_state[card].chipset = CHIPSET_OPL3SA3;
620 printk(KERN_INFO
621 PFX "Found OPL3-SA3 (YMF715B or YMF719B)\n");
622 break;
623
624 case VERSION_YMF715E:
625 default:
626 opl3sa2_state[card].chipset = CHIPSET_OPL3SA3;
627 printk(KERN_INFO
628 PFX "Found OPL3-SA3 (YMF715E or YMF719E)\n");
629 break;
630 }
631
632 if (opl3sa2_state[card].chipset != CHIPSET_UNKNOWN) {
633 /* Generate a pretty name */
634 opl3sa2_state[card].chipset_name = (char *)CHIPSET_TABLE[opl3sa2_state[card].chipset];
635 return 0;
636 }
637
638out_region:
639 release_region(hw_config->io_base, 2);
640out_nodev:
641 return -ENODEV;
642}
643
644
645static void __init attach_opl3sa2(struct address_info* hw_config, int card)
646{
647 /* Initialize IRQ configuration to IRQ-B: -, IRQ-A: WSS+MPU+OPL3 */
648 opl3sa2_write(hw_config->io_base, OPL3SA2_IRQ_CONFIG, 0x0d);
649
650 /* Initialize DMA configuration */
651 if(hw_config->dma2 == hw_config->dma) {
652 /* Want DMA configuration DMA-B: -, DMA-A: WSS-P+WSS-R */
653 opl3sa2_write(hw_config->io_base, OPL3SA2_DMA_CONFIG, 0x03);
654 }
655 else {
656 /* Want DMA configuration DMA-B: WSS-R, DMA-A: WSS-P */
657 opl3sa2_write(hw_config->io_base, OPL3SA2_DMA_CONFIG, 0x21);
658 }
659}
660
661
662static void __init attach_opl3sa2_mixer(struct address_info *hw_config, int card)
663{
664 struct mixer_operations* mixer_operations;
665 opl3sa2_state_t* devc = &opl3sa2_state[card];
666
667 /* Install master mixer */
668 if (devc->chipset == CHIPSET_OPL3SA3) {
669 mixer_operations = &opl3sa3_mixer_operations;
670 }
671 else {
672 mixer_operations = &opl3sa2_mixer_operations;
673 }
674
675 devc->cfg_port = hw_config->io_base;
676 devc->mixer = sound_install_mixer(MIXER_DRIVER_VERSION,
677 mixer_operations->name,
678 mixer_operations,
679 sizeof(struct mixer_operations),
680 devc);
681 if(devc->mixer < 0) {
682 printk(KERN_ERR PFX "Could not install %s master mixer\n",
683 mixer_operations->name);
684 }
685 else {
686 opl3sa2_mixer_reset(devc);
687
688 }
689}
690
691
692static void opl3sa2_clear_slots(struct address_info* hw_config)
693{
694 int i;
695
696 for(i = 0; i < 6; i++) {
697 hw_config->slots[i] = -1;
698 }
699}
700
701
702static void __init opl3sa2_set_ymode(struct address_info* hw_config, int ymode)
703{
704 /*
705 * Set the Yamaha 3D enhancement mode (aka Ymersion) if asked to and
706 * it's supported.
707 *
708 * 0: Desktop (aka normal) 5-12 cm speakers
709 * 1: Notebook PC mode 1 3 cm speakers
710 * 2: Notebook PC mode 2 1.5 cm speakers
711 * 3: Hi-fi 16-38 cm speakers
712 */
713 if(ymode >= 0 && ymode <= 3) {
714 unsigned char sys_ctrl;
715
716 opl3sa2_read(hw_config->io_base, OPL3SA2_SYS_CTRL, &sys_ctrl);
717 sys_ctrl = (sys_ctrl & 0xcf) | ((ymode & 3) << 4);
718 opl3sa2_write(hw_config->io_base, OPL3SA2_SYS_CTRL, sys_ctrl);
719 }
720 else {
721 printk(KERN_ERR PFX "not setting ymode, it must be one of 0,1,2,3\n");
722 }
723}
724
725
726static void __init opl3sa2_set_loopback(struct address_info* hw_config, int loopback)
727{
728 if(loopback >= 0 && loopback <= 1) {
729 unsigned char misc;
730
731 opl3sa2_read(hw_config->io_base, OPL3SA2_MISC, &misc);
732 misc = (misc & 0xef) | ((loopback & 1) << 4);
733 opl3sa2_write(hw_config->io_base, OPL3SA2_MISC, misc);
734 }
735 else {
736 printk(KERN_ERR PFX "not setting loopback, it must be either 0 or 1\n");
737 }
738}
739
740
741static void __exit unload_opl3sa2(struct address_info* hw_config, int card)
742{
743 /* Release control ports */
744 release_region(hw_config->io_base, 2);
745
746 /* Unload mixer */
747 if(opl3sa2_state[card].mixer >= 0)
748 sound_unload_mixerdev(opl3sa2_state[card].mixer);
749
750}
751
752#ifdef CONFIG_PNP
753static struct pnp_device_id pnp_opl3sa2_list[] = {
754 {.id = "YMH0021", .driver_data = 0},
755 {.id = ""}
756};
757
758MODULE_DEVICE_TABLE(pnp, pnp_opl3sa2_list);
759
760static int opl3sa2_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
761{
762 int card = opl3sa2_cards_num;
763
764 /* we don't actually want to return an error as the user may have specified
765 * no multiple card search
766 */
767
768 if (opl3sa2_cards_num == OPL3SA2_CARDS_MAX)
769 return 0;
770 opl3sa2_activated[card] = 1;
771
772 /* Our own config: */
773 opl3sa2_state[card].cfg.io_base = pnp_port_start(dev, 4);
774 opl3sa2_state[card].cfg.irq = pnp_irq(dev, 0);
775 opl3sa2_state[card].cfg.dma = pnp_dma(dev, 0);
776 opl3sa2_state[card].cfg.dma2 = pnp_dma(dev, 1);
777
778 /* The MSS config: */
779 opl3sa2_state[card].cfg_mss.io_base = pnp_port_start(dev, 1);
780 opl3sa2_state[card].cfg_mss.irq = pnp_irq(dev, 0);
781 opl3sa2_state[card].cfg_mss.dma = pnp_dma(dev, 0);
782 opl3sa2_state[card].cfg_mss.dma2 = pnp_dma(dev, 1);
783 opl3sa2_state[card].cfg_mss.card_subtype = 1; /* No IRQ or DMA setup */
784
785 opl3sa2_state[card].cfg_mpu.io_base = pnp_port_start(dev, 3);
786 opl3sa2_state[card].cfg_mpu.irq = pnp_irq(dev, 0);
787 opl3sa2_state[card].cfg_mpu.dma = -1;
788 opl3sa2_state[card].cfg_mpu.dma2 = -1;
789 opl3sa2_state[card].cfg_mpu.always_detect = 1; /* It's there, so use shared IRQs */
790
791 /* Call me paranoid: */
792 opl3sa2_clear_slots(&opl3sa2_state[card].cfg);
793 opl3sa2_clear_slots(&opl3sa2_state[card].cfg_mss);
794 opl3sa2_clear_slots(&opl3sa2_state[card].cfg_mpu);
795
796 opl3sa2_state[card].pdev = dev;
797 opl3sa2_cards_num++;
798
799 return 0;
800}
801
802static struct pnp_driver opl3sa2_driver = {
803 .name = "opl3sa2",
804 .id_table = pnp_opl3sa2_list,
805 .probe = opl3sa2_pnp_probe,
806};
807
808#endif /* CONFIG_PNP */
809
810/* End of component functions */
811
812/*
813 * Install OPL3-SA2 based card(s).
814 *
815 * Need to have ad1848 and mpu401 loaded ready.
816 */
817static int __init init_opl3sa2(void)
818{
819 int card, max;
820
821 /* Sanitize isapnp and multiple settings */
822 isapnp = isapnp != 0 ? 1 : 0;
823 multiple = multiple != 0 ? 1 : 0;
824
825 max = (multiple && isapnp) ? OPL3SA2_CARDS_MAX : 1;
826
827#ifdef CONFIG_PNP
828 if (isapnp){
829 pnp_register_driver(&opl3sa2_driver);
830 if(!opl3sa2_cards_num){
831 printk(KERN_INFO PFX "No PnP cards found\n");
832 isapnp = 0;
833 }
834 max = opl3sa2_cards_num;
835 }
836#endif
837
838 for (card = 0; card < max; card++) {
839 /* If a user wants an I/O then assume they meant it */
840 struct resource *ports;
841 int base;
842
843 if (!isapnp) {
844 if (io == -1 || irq == -1 || dma == -1 ||
845 dma2 == -1 || mss_io == -1) {
846 printk(KERN_ERR
847 PFX "io, mss_io, irq, dma, and dma2 must be set\n");
848 return -EINVAL;
849 }
850 opl3sa2_cards_num++;
851
852 /*
853 * Our own config:
854 * (NOTE: IRQ and DMA aren't used, so they're set to
855 * give pretty output from conf_printf. :)
856 */
857 opl3sa2_state[card].cfg.io_base = io;
858 opl3sa2_state[card].cfg.irq = irq;
859 opl3sa2_state[card].cfg.dma = dma;
860 opl3sa2_state[card].cfg.dma2 = dma2;
861
862 /* The MSS config: */
863 opl3sa2_state[card].cfg_mss.io_base = mss_io;
864 opl3sa2_state[card].cfg_mss.irq = irq;
865 opl3sa2_state[card].cfg_mss.dma = dma;
866 opl3sa2_state[card].cfg_mss.dma2 = dma2;
867 opl3sa2_state[card].cfg_mss.card_subtype = 1; /* No IRQ or DMA setup */
868
869 opl3sa2_state[card].cfg_mpu.io_base = mpu_io;
870 opl3sa2_state[card].cfg_mpu.irq = irq;
871 opl3sa2_state[card].cfg_mpu.dma = -1;
872 opl3sa2_state[card].cfg_mpu.always_detect = 1; /* Use shared IRQs */
873
874 /* Call me paranoid: */
875 opl3sa2_clear_slots(&opl3sa2_state[card].cfg);
876 opl3sa2_clear_slots(&opl3sa2_state[card].cfg_mss);
877 opl3sa2_clear_slots(&opl3sa2_state[card].cfg_mpu);
878 }
879
880 /* FIXME: leak */
881 if (probe_opl3sa2(&opl3sa2_state[card].cfg, card))
882 return -ENODEV;
883
884 base = opl3sa2_state[card].cfg_mss.io_base;
885
886 if (!request_region(base, 4, "WSS config"))
887 goto failed;
888
889 ports = request_region(base + 4, 4, "ad1848");
890 if (!ports)
891 goto failed2;
892
893 if (!probe_ms_sound(&opl3sa2_state[card].cfg_mss, ports)) {
894 /*
895 * If one or more cards are already registered, don't
896 * return an error but print a warning. Note, this
897 * should never really happen unless the hardware or
898 * ISA PnP screwed up.
899 */
900 release_region(base + 4, 4);
901 failed2:
902 release_region(base, 4);
903 failed:
904 release_region(opl3sa2_state[card].cfg.io_base, 2);
905
906 if (opl3sa2_cards_num) {
907 printk(KERN_WARNING
908 PFX "There was a problem probing one "
909 " of the ISA PNP cards, continuing\n");
910 opl3sa2_cards_num--;
911 continue;
912 } else
913 return -ENODEV;
914 }
915
916 attach_opl3sa2(&opl3sa2_state[card].cfg, card);
917 conf_printf(opl3sa2_state[card].chipset_name, &opl3sa2_state[card].cfg);
918 attach_opl3sa2_mixer(&opl3sa2_state[card].cfg, card);
919 attach_opl3sa2_mss(&opl3sa2_state[card].cfg_mss, ports);
920
921 /* ewww =) */
922 opl3sa2_state[card].card = card;
923
924 /*
925 * Set the Yamaha 3D enhancement mode (aka Ymersion) if asked to and
926 * it's supported.
927 */
928 if (ymode != -1) {
929 if (opl3sa2_state[card].chipset == CHIPSET_OPL3SA2) {
930 printk(KERN_ERR
931 PFX "ymode not supported on OPL3-SA2\n");
932 }
933 else {
934 opl3sa2_set_ymode(&opl3sa2_state[card].cfg, ymode);
935 }
936 }
937
938
939 /* Set A/D input to Mono loopback if asked to. */
940 if (loopback != -1) {
941 opl3sa2_set_loopback(&opl3sa2_state[card].cfg, loopback);
942 }
943
944 /* Attach MPU if we've been asked to do so, failure isn't fatal */
945 if (opl3sa2_state[card].cfg_mpu.io_base != -1) {
946 int base = opl3sa2_state[card].cfg_mpu.io_base;
947 struct resource *ports;
948 ports = request_region(base, 2, "mpu401");
949 if (!ports)
950 goto out;
951 if (!probe_mpu401(&opl3sa2_state[card].cfg_mpu, ports)) {
952 release_region(base, 2);
953 goto out;
954 }
955 if (attach_mpu401(&opl3sa2_state[card].cfg_mpu, THIS_MODULE)) {
956 printk(KERN_ERR PFX "failed to attach MPU401\n");
957 opl3sa2_state[card].cfg_mpu.slots[1] = -1;
958 }
959 }
960 }
961
962out:
963 if (isapnp) {
964 printk(KERN_NOTICE PFX "%d PnP card(s) found.\n", opl3sa2_cards_num);
965 }
966
967 return 0;
968}
969
970
971/*
972 * Uninstall OPL3-SA2 based card(s).
973 */
974static void __exit cleanup_opl3sa2(void)
975{
976 int card;
977
978 for(card = 0; card < opl3sa2_cards_num; card++) {
979 if (opl3sa2_state[card].cfg_mpu.slots[1] != -1) {
980 unload_opl3sa2_mpu(&opl3sa2_state[card].cfg_mpu);
981 }
982 unload_opl3sa2_mss(&opl3sa2_state[card].cfg_mss);
983 unload_opl3sa2(&opl3sa2_state[card].cfg, card);
984#ifdef CONFIG_PNP
985 pnp_unregister_driver(&opl3sa2_driver);
986#endif
987 }
988}
989
990module_init(init_opl3sa2);
991module_exit(cleanup_opl3sa2);
992
993#ifndef MODULE
994static int __init setup_opl3sa2(char *str)
995{
996 /* io, irq, dma, dma2,... */
997#ifdef CONFIG_PNP
998 int ints[11];
999#else
1000 int ints[9];
1001#endif
1002 str = get_options(str, ARRAY_SIZE(ints), ints);
1003
1004 io = ints[1];
1005 irq = ints[2];
1006 dma = ints[3];
1007 dma2 = ints[4];
1008 mss_io = ints[5];
1009 mpu_io = ints[6];
1010 ymode = ints[7];
1011 loopback = ints[8];
1012#ifdef CONFIG_PNP
1013 isapnp = ints[9];
1014 multiple = ints[10];
1015#endif
1016 return 1;
1017}
1018
1019__setup("opl3sa2=", setup_opl3sa2);
1020#endif
diff --git a/sound/oss/pas2_pcm.c b/sound/oss/pas2_pcm.c
index 4af6aafa3d8..36c3ea62086 100644
--- a/sound/oss/pas2_pcm.c
+++ b/sound/oss/pas2_pcm.c
@@ -85,7 +85,7 @@ static int pcm_set_speed(int arg)
85 * come from the SDK found on ftp.uwp.edu:/pub/msdos/proaudio/. 85 * come from the SDK found on ftp.uwp.edu:/pub/msdos/proaudio/.
86 * 86 *
87 * I cleared bit 5 of these values, since that bit controls the master 87 * I cleared bit 5 of these values, since that bit controls the master
88 * mute flag. (Olav Wölfelschneider) 88 * mute flag. (Olav Wölfelschneider)
89 * 89 *
90 */ 90 */
91#if !defined NO_AUTO_FILTER_SET 91#if !defined NO_AUTO_FILTER_SET
diff --git a/sound/oss/sb_card.c b/sound/oss/sb_card.c
index 27acd6f29b9..7de18b58f2c 100644
--- a/sound/oss/sb_card.c
+++ b/sound/oss/sb_card.c
@@ -290,7 +290,7 @@ static struct pnp_card_driver sb_pnp_driver = {
290MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table); 290MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table);
291#endif /* CONFIG_PNP */ 291#endif /* CONFIG_PNP */
292 292
293static void __init_or_module sb_unregister_all(void) 293static void sb_unregister_all(void)
294{ 294{
295#ifdef CONFIG_PNP 295#ifdef CONFIG_PNP
296 if (pnp_registered) 296 if (pnp_registered)
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index d98d311542e..96adc47917a 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -11,14 +11,14 @@
11 * Built from: 11 * Built from:
12 * Low level code: <audio@tridentmicro.com> from ALSA 12 * Low level code: <audio@tridentmicro.com> from ALSA
13 * Framework: Thomas Sailer <sailer@ife.ee.ethz.ch> 13 * Framework: Thomas Sailer <sailer@ife.ee.ethz.ch>
14 * Extended by: Zach Brown <zab@redhat.com> 14 * Extended by: Zach Brown <zab@redhat.com>
15 * 15 *
16 * Hacked up by: 16 * Hacked up by:
17 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 17 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
18 * Ollie Lho <ollie@sis.com.tw> SiS 7018 Audio Core Support 18 * Ollie Lho <ollie@sis.com.tw> SiS 7018 Audio Core Support
19 * Ching-Ling Lee <cling-li@ali.com.tw> ALi 5451 Audio Core Support 19 * Ching-Ling Lee <cling-li@ali.com.tw> ALi 5451 Audio Core Support
20 * Matt Wu <mattwu@acersoftech.com.cn> ALi 5451 Audio Core Support 20 * Matt Wu <mattwu@acersoftech.com.cn> ALi 5451 Audio Core Support
21 * Peter Wächtler <pwaechtler@loewe-komp.de> CyberPro5050 support 21 * Peter Wächtler <pwaechtler@loewe-komp.de> CyberPro5050 support
22 * Muli Ben-Yehuda <mulix@mulix.org> 22 * Muli Ben-Yehuda <mulix@mulix.org>
23 * 23 *
24 * 24 *
@@ -54,33 +54,33 @@
54 * adapt to new pci joystick attachment interface 54 * adapt to new pci joystick attachment interface
55 * v0.14.10f 55 * v0.14.10f
56 * July 24 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 56 * July 24 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
57 * patch from Eric Lemar (via Ian Soboroff): in suspend and resume, 57 * patch from Eric Lemar (via Ian Soboroff): in suspend and resume,
58 * fix wrong cast from pci_dev* to struct trident_card*. 58 * fix wrong cast from pci_dev* to struct trident_card*.
59 * v0.14.10e 59 * v0.14.10e
60 * July 19 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 60 * July 19 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
61 * rewrite the DMA buffer allocation/deallcoation functions, to make it 61 * rewrite the DMA buffer allocation/deallcoation functions, to make it
62 * modular and fix a bug where we would call free_pages on memory 62 * modular and fix a bug where we would call free_pages on memory
63 * obtained with pci_alloc_consistent. Also remove unnecessary #ifdef 63 * obtained with pci_alloc_consistent. Also remove unnecessary #ifdef
64 * CONFIG_PROC_FS and various other cleanups. 64 * CONFIG_PROC_FS and various other cleanups.
65 * v0.14.10d 65 * v0.14.10d
66 * July 19 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 66 * July 19 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
67 * made several printk(KERN_NOTICE...) into TRDBG(...), to avoid spamming 67 * made several printk(KERN_NOTICE...) into TRDBG(...), to avoid spamming
68 * my syslog with hundreds of messages. 68 * my syslog with hundreds of messages.
69 * v0.14.10c 69 * v0.14.10c
70 * July 16 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 70 * July 16 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
71 * Cleaned up Lei Hu's 0.4.10 driver to conform to Documentation/CodingStyle 71 * Cleaned up Lei Hu's 0.4.10 driver to conform to Documentation/CodingStyle
72 * and the coding style used in the rest of the file. 72 * and the coding style used in the rest of the file.
73 * v0.14.10b 73 * v0.14.10b
74 * June 23 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 74 * June 23 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
75 * add a missing unlock_set_fmt, remove a superflous lock/unlock pair 75 * add a missing unlock_set_fmt, remove a superflous lock/unlock pair
76 * with nothing in between. 76 * with nothing in between.
77 * v0.14.10a 77 * v0.14.10a
78 * June 21 2002 Muli Ben-Yehuda <mulix@actcom.co.il> 78 * June 21 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
79 * use a debug macro instead of #ifdef CONFIG_DEBUG, trim to 80 columns 79 * use a debug macro instead of #ifdef CONFIG_DEBUG, trim to 80 columns
80 * per line, use 'do {} while (0)' in statement macros. 80 * per line, use 'do {} while (0)' in statement macros.
81 * v0.14.10 81 * v0.14.10
82 * June 6 2002 Lei Hu <Lei_hu@ali.com.tw> 82 * June 6 2002 Lei Hu <Lei_hu@ali.com.tw>
83 * rewrite the part to read/write registers of audio codec for Ali5451 83 * rewrite the part to read/write registers of audio codec for Ali5451
84 * v0.14.9e 84 * v0.14.9e
85 * January 2 2002 Vojtech Pavlik <vojtech@ucw.cz> added gameport 85 * January 2 2002 Vojtech Pavlik <vojtech@ucw.cz> added gameport
86 * support to avoid resource conflict with pcigame.c 86 * support to avoid resource conflict with pcigame.c
@@ -89,7 +89,7 @@
89 * use set_current_state, properly release resources on failure in 89 * use set_current_state, properly release resources on failure in
90 * trident_probe, get rid of check_region 90 * trident_probe, get rid of check_region
91 * v0.14.9c 91 * v0.14.9c
92 * August 10 2001 Peter Wächtler <pwaechtler@loewe-komp.de> 92 * August 10 2001 Peter Wächtler <pwaechtler@loewe-komp.de>
93 * added support for Tvia (formerly Integraphics/IGST) CyberPro5050 93 * added support for Tvia (formerly Integraphics/IGST) CyberPro5050
94 * this chip is often found in settop boxes (combined video+audio) 94 * this chip is often found in settop boxes (combined video+audio)
95 * v0.14.9b 95 * v0.14.9b
@@ -111,7 +111,7 @@
111 * Set EBUF1 and EBUF2 to still mode 111 * Set EBUF1 and EBUF2 to still mode
112 * Add dc97/ac97 reset function 112 * Add dc97/ac97 reset function
113 * Fix power management: ali_restore_regs 113 * Fix power management: ali_restore_regs
114 * unreleased 114 * unreleased
115 * Mar 09 2001 Matt Wu 115 * Mar 09 2001 Matt Wu
116 * Add cache for ac97 access 116 * Add cache for ac97 access
117 * v0.14.7 117 * v0.14.7
@@ -120,7 +120,7 @@
120 * Fix bug: an extra tail will be played when playing 120 * Fix bug: an extra tail will be played when playing
121 * Jan 05 2001 Matt Wu 121 * Jan 05 2001 Matt Wu
122 * Implement multi-channels and S/PDIF in support for ALi 1535+ 122 * Implement multi-channels and S/PDIF in support for ALi 1535+
123 * v0.14.6 123 * v0.14.6
124 * Nov 1 2000 Ching-Ling Lee 124 * Nov 1 2000 Ching-Ling Lee
125 * Fix the bug of memory leak when switching 5.1-channels to 2 channels. 125 * Fix the bug of memory leak when switching 5.1-channels to 2 channels.
126 * Add lock protection into dynamic changing format of data. 126 * Add lock protection into dynamic changing format of data.
@@ -138,7 +138,7 @@
138 * v0.14.3 May 10 2000 Ollie Lho 138 * v0.14.3 May 10 2000 Ollie Lho
139 * fixed a small bug in trident_update_ptr, xmms 1.0.1 no longer uses 100% CPU 139 * fixed a small bug in trident_update_ptr, xmms 1.0.1 no longer uses 100% CPU
140 * v0.14.2 Mar 29 2000 Ching-Ling Lee 140 * v0.14.2 Mar 29 2000 Ching-Ling Lee
141 * Add clear to silence advance in trident_update_ptr 141 * Add clear to silence advance in trident_update_ptr
142 * fix invalid data of the end of the sound 142 * fix invalid data of the end of the sound
143 * v0.14.1 Mar 24 2000 Ching-Ling Lee 143 * v0.14.1 Mar 24 2000 Ching-Ling Lee
144 * ALi 5451 support added, playback and recording O.K. 144 * ALi 5451 support added, playback and recording O.K.
@@ -178,7 +178,7 @@
178 * SiS 7018 support added, playback O.K. 178 * SiS 7018 support added, playback O.K.
179 * v0.01 Alan Cox et. al. 179 * v0.01 Alan Cox et. al.
180 * Initial Release in kernel 2.3.30, does not work 180 * Initial Release in kernel 2.3.30, does not work
181 * 181 *
182 * ToDo 182 * ToDo
183 * Clean up of low level channel register access code. (done) 183 * Clean up of low level channel register access code. (done)
184 * Fix the bug on dma buffer management in update_ptr, read/write, drain_dac (done) 184 * Fix the bug on dma buffer management in update_ptr, read/write, drain_dac (done)
@@ -326,7 +326,7 @@ struct trident_state {
326 326
327 unsigned error; /* number of over/underruns */ 327 unsigned error; /* number of over/underruns */
328 /* put process on wait queue when no more space in buffer */ 328 /* put process on wait queue when no more space in buffer */
329 wait_queue_head_t wait; 329 wait_queue_head_t wait;
330 330
331 /* redundant, but makes calculations easier */ 331 /* redundant, but makes calculations easier */
332 unsigned fragsize; 332 unsigned fragsize;
@@ -358,7 +358,7 @@ struct trident_state {
358struct trident_channel { 358struct trident_channel {
359 int num; /* channel number */ 359 int num; /* channel number */
360 u32 lba; /* Loop Begine Address, where dma buffer starts */ 360 u32 lba; /* Loop Begine Address, where dma buffer starts */
361 u32 eso; /* End Sample Offset, wehre dma buffer ends */ 361 u32 eso; /* End Sample Offset, wehre dma buffer ends */
362 /* (in the unit of samples) */ 362 /* (in the unit of samples) */
363 u32 delta; /* delta value, sample rate / 48k for playback, */ 363 u32 delta; /* delta value, sample rate / 48k for playback, */
364 /* 48k/sample rate for recording */ 364 /* 48k/sample rate for recording */
@@ -417,7 +417,7 @@ struct trident_card {
417 /* soundcore stuff */ 417 /* soundcore stuff */
418 int dev_audio; 418 int dev_audio;
419 419
420 /* structures for abstraction of hardware facilities, codecs, */ 420 /* structures for abstraction of hardware facilities, codecs, */
421 /* banks and channels */ 421 /* banks and channels */
422 struct ac97_codec *ac97_codec[NR_AC97]; 422 struct ac97_codec *ac97_codec[NR_AC97];
423 struct trident_pcm_bank banks[NR_BANKS]; 423 struct trident_pcm_bank banks[NR_BANKS];
@@ -479,7 +479,7 @@ static void trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val);
479static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg); 479static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg);
480 480
481static int trident_open_mixdev(struct inode *inode, struct file *file); 481static int trident_open_mixdev(struct inode *inode, struct file *file);
482static int trident_ioctl_mixdev(struct inode *inode, struct file *file, 482static int trident_ioctl_mixdev(struct inode *inode, struct file *file,
483 unsigned int cmd, unsigned long arg); 483 unsigned int cmd, unsigned long arg);
484 484
485static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val); 485static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val);
@@ -496,10 +496,10 @@ static void ali_disable_spdif_in(struct trident_card *card);
496static void ali_disable_special_channel(struct trident_card *card, int ch); 496static void ali_disable_special_channel(struct trident_card *card, int ch);
497static void ali_setup_spdif_out(struct trident_card *card, int flag); 497static void ali_setup_spdif_out(struct trident_card *card, int flag);
498static int ali_write_5_1(struct trident_state *state, 498static int ali_write_5_1(struct trident_state *state,
499 const char __user *buffer, 499 const char __user *buffer,
500 int cnt_for_multi_channel, unsigned int *copy_count, 500 int cnt_for_multi_channel, unsigned int *copy_count,
501 unsigned int *state_cnt); 501 unsigned int *state_cnt);
502static int ali_allocate_other_states_resources(struct trident_state *state, 502static int ali_allocate_other_states_resources(struct trident_state *state,
503 int chan_nums); 503 int chan_nums);
504static void ali_free_other_states_resources(struct trident_state *state); 504static void ali_free_other_states_resources(struct trident_state *state);
505 505
@@ -722,7 +722,7 @@ trident_free_pcm_channel(struct trident_card *card, unsigned int channel)
722 if (channel < 31 || channel > 63) 722 if (channel < 31 || channel > 63)
723 return; 723 return;
724 724
725 if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX || 725 if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX ||
726 card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) { 726 card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) {
727 b = inb(TRID_REG(card, T4D_REC_CH)); 727 b = inb(TRID_REG(card, T4D_REC_CH));
728 if ((b & ~0x80) == channel) 728 if ((b & ~0x80) == channel)
@@ -742,7 +742,7 @@ cyber_alloc_pcm_channel(struct trident_card *card)
742 int idx; 742 int idx;
743 743
744 /* The cyberpro 5050 has only 32 voices and one bank */ 744 /* The cyberpro 5050 has only 32 voices and one bank */
745 /* .. at least they are not documented (if you want to call that 745 /* .. at least they are not documented (if you want to call that
746 * crap documentation), perhaps broken ? */ 746 * crap documentation), perhaps broken ? */
747 747
748 bank = &card->banks[BANK_A]; 748 bank = &card->banks[BANK_A];
@@ -802,7 +802,7 @@ cyber_init_ritual(struct trident_card *card)
802 /* enable, if it was disabled */ 802 /* enable, if it was disabled */
803 if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) { 803 if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) {
804 printk(KERN_INFO "cyberpro5050: enabling audio controller\n"); 804 printk(KERN_INFO "cyberpro5050: enabling audio controller\n");
805 cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE, 805 cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE,
806 portDat | CYBER_BMSK_AUENZ_ENABLE); 806 portDat | CYBER_BMSK_AUENZ_ENABLE);
807 /* check again if hardware is enabled now */ 807 /* check again if hardware is enabled now */
808 portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE); 808 portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
@@ -811,7 +811,7 @@ cyber_init_ritual(struct trident_card *card)
811 printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n"); 811 printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n");
812 ret = -1; 812 ret = -1;
813 } else { 813 } else {
814 cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE, 814 cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE,
815 CYBER_BMSK_AUDIO_INT_ENABLE); 815 CYBER_BMSK_AUDIO_INT_ENABLE);
816 cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x01); 816 cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x01);
817 cyber_outidx(CYBER_PORT_AUDIO, 0xba, 0x20); 817 cyber_outidx(CYBER_PORT_AUDIO, 0xba, 0x20);
@@ -827,7 +827,7 @@ cyber_init_ritual(struct trident_card *card)
827/* called with spin lock held */ 827/* called with spin lock held */
828 828
829static int 829static int
830trident_load_channel_registers(struct trident_card *card, u32 * data, 830trident_load_channel_registers(struct trident_card *card, u32 * data,
831 unsigned int channel) 831 unsigned int channel)
832{ 832{
833 int i; 833 int i;
@@ -845,7 +845,7 @@ trident_load_channel_registers(struct trident_card *card, u32 * data,
845 continue; 845 continue;
846 outl(data[i], TRID_REG(card, CHANNEL_START + 4 * i)); 846 outl(data[i], TRID_REG(card, CHANNEL_START + 4 * i));
847 } 847 }
848 if (card->pci_id == PCI_DEVICE_ID_ALI_5451 || 848 if (card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
849 card->pci_id == PCI_DEVICE_ID_INTERG_5050) { 849 card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
850 outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF1)); 850 outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF1));
851 outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF2)); 851 outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF2));
@@ -884,7 +884,7 @@ trident_write_voice_regs(struct trident_state *state)
884 break; 884 break;
885 case PCI_DEVICE_ID_TRIDENT_4DWAVE_NX: 885 case PCI_DEVICE_ID_TRIDENT_4DWAVE_NX:
886 data[0] = (channel->delta << 24); 886 data[0] = (channel->delta << 24);
887 data[2] = ((channel->delta << 16) & 0xff000000) | 887 data[2] = ((channel->delta << 16) & 0xff000000) |
888 (channel->eso & 0x00ffffff); 888 (channel->eso & 0x00ffffff);
889 data[3] = channel->fm_vol & 0xffff; 889 data[3] = channel->fm_vol & 0xffff;
890 break; 890 break;
@@ -989,13 +989,13 @@ trident_play_setup(struct trident_state *state)
989 if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) { 989 if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) {
990 channel->attribute = 0; 990 channel->attribute = 0;
991 if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451) { 991 if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451) {
992 if ((channel->num == ALI_SPDIF_IN_CHANNEL) || 992 if ((channel->num == ALI_SPDIF_IN_CHANNEL) ||
993 (channel->num == ALI_PCM_IN_CHANNEL)) 993 (channel->num == ALI_PCM_IN_CHANNEL))
994 ali_disable_special_channel(state->card, channel->num); 994 ali_disable_special_channel(state->card, channel->num);
995 else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL)) 995 else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL))
996 & ALI_SPDIF_OUT_CH_ENABLE) 996 & ALI_SPDIF_OUT_CH_ENABLE)
997 && (channel->num == ALI_SPDIF_OUT_CHANNEL)) { 997 && (channel->num == ALI_SPDIF_OUT_CHANNEL)) {
998 ali_set_spdif_out_rate(state->card, 998 ali_set_spdif_out_rate(state->card,
999 state->dmabuf.rate); 999 state->dmabuf.rate);
1000 state->dmabuf.channel->delta = 0x1000; 1000 state->dmabuf.channel->delta = 0x1000;
1001 } 1001 }
@@ -1063,7 +1063,7 @@ trident_rec_setup(struct trident_state *state)
1063 1063
1064 channel->lba = dmabuf->dma_handle; 1064 channel->lba = dmabuf->dma_handle;
1065 channel->delta = compute_rate_rec(dmabuf->rate); 1065 channel->delta = compute_rate_rec(dmabuf->rate);
1066 if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && 1066 if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) &&
1067 (channel->num == ALI_SPDIF_IN_CHANNEL)) { 1067 (channel->num == ALI_SPDIF_IN_CHANNEL)) {
1068 rate = ali_get_spdif_in_rate(card); 1068 rate = ali_get_spdif_in_rate(card);
1069 if (rate == 0) { 1069 if (rate == 0) {
@@ -1180,8 +1180,8 @@ start_adc(struct trident_state *state)
1180 unsigned long flags; 1180 unsigned long flags;
1181 1181
1182 spin_lock_irqsave(&card->lock, flags); 1182 spin_lock_irqsave(&card->lock, flags);
1183 if ((dmabuf->mapped || 1183 if ((dmabuf->mapped ||
1184 dmabuf->count < (signed) dmabuf->dmasize) && 1184 dmabuf->count < (signed) dmabuf->dmasize) &&
1185 dmabuf->ready) { 1185 dmabuf->ready) {
1186 dmabuf->enable |= ADC_RUNNING; 1186 dmabuf->enable |= ADC_RUNNING;
1187 trident_enable_voice_irq(card, chan_num); 1187 trident_enable_voice_irq(card, chan_num);
@@ -1261,7 +1261,7 @@ alloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev, int order)
1261 void *rawbuf = NULL; 1261 void *rawbuf = NULL;
1262 struct page *page, *pend; 1262 struct page *page, *pend;
1263 1263
1264 if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order, 1264 if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order,
1265 &dmabuf->dma_handle))) 1265 &dmabuf->dma_handle)))
1266 return -ENOMEM; 1266 return -ENOMEM;
1267 1267
@@ -1272,7 +1272,7 @@ alloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev, int order)
1272 dmabuf->rawbuf = rawbuf; 1272 dmabuf->rawbuf = rawbuf;
1273 dmabuf->buforder = order; 1273 dmabuf->buforder = order;
1274 1274
1275 /* now mark the pages as reserved; otherwise */ 1275 /* now mark the pages as reserved; otherwise */
1276 /* remap_pfn_range doesn't do what we want */ 1276 /* remap_pfn_range doesn't do what we want */
1277 pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1); 1277 pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
1278 for (page = virt_to_page(rawbuf); page <= pend; page++) 1278 for (page = virt_to_page(rawbuf); page <= pend; page++)
@@ -1310,7 +1310,7 @@ dealloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev)
1310 pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1); 1310 pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1);
1311 for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++) 1311 for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++)
1312 ClearPageReserved(page); 1312 ClearPageReserved(page);
1313 pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder, 1313 pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder,
1314 dmabuf->rawbuf, dmabuf->dma_handle); 1314 dmabuf->rawbuf, dmabuf->dma_handle);
1315 dmabuf->rawbuf = NULL; 1315 dmabuf->rawbuf = NULL;
1316 } 1316 }
@@ -1368,7 +1368,7 @@ prog_dmabuf(struct trident_state *state, enum dmabuf_mode rec)
1368 dealloc_dmabuf(&state->dmabuf, state->card->pci_dev); 1368 dealloc_dmabuf(&state->dmabuf, state->card->pci_dev);
1369 /* release the auxiliary DMA buffers */ 1369 /* release the auxiliary DMA buffers */
1370 for (i -= 2; i >= 0; i--) 1370 for (i -= 2; i >= 0; i--)
1371 dealloc_dmabuf(&state->other_states[i]->dmabuf, 1371 dealloc_dmabuf(&state->other_states[i]->dmabuf,
1372 state->card->pci_dev); 1372 state->card->pci_dev);
1373 unlock_set_fmt(state); 1373 unlock_set_fmt(state);
1374 return ret; 1374 return ret;
@@ -1398,7 +1398,7 @@ prog_dmabuf(struct trident_state *state, enum dmabuf_mode rec)
1398 dmabuf->fragsamples = dmabuf->fragsize >> sample_shift[dmabuf->fmt]; 1398 dmabuf->fragsamples = dmabuf->fragsize >> sample_shift[dmabuf->fmt];
1399 dmabuf->dmasize = dmabuf->numfrag << dmabuf->fragshift; 1399 dmabuf->dmasize = dmabuf->numfrag << dmabuf->fragshift;
1400 1400
1401 memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80, 1401 memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80,
1402 dmabuf->dmasize); 1402 dmabuf->dmasize);
1403 1403
1404 spin_lock_irqsave(&s->card->lock, flags); 1404 spin_lock_irqsave(&s->card->lock, flags);
@@ -1453,7 +1453,7 @@ trident_clear_tail(struct trident_state *state)
1453 swptr = dmabuf->swptr; 1453 swptr = dmabuf->swptr;
1454 spin_unlock_irqrestore(&state->card->lock, flags); 1454 spin_unlock_irqrestore(&state->card->lock, flags);
1455 1455
1456 if (swptr == 0 || swptr == dmabuf->dmasize / 2 || 1456 if (swptr == 0 || swptr == dmabuf->dmasize / 2 ||
1457 swptr == dmabuf->dmasize) 1457 swptr == dmabuf->dmasize)
1458 return; 1458 return;
1459 1459
@@ -1511,7 +1511,7 @@ drain_dac(struct trident_state *state, int nonblock)
1511 1511
1512 /* No matter how much data is left in the buffer, we have to wait until 1512 /* No matter how much data is left in the buffer, we have to wait until
1513 CSO == ESO/2 or CSO == ESO when address engine interrupts */ 1513 CSO == ESO/2 or CSO == ESO when address engine interrupts */
1514 if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 || 1514 if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
1515 state->card->pci_id == PCI_DEVICE_ID_INTERG_5050) { 1515 state->card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
1516 diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize; 1516 diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize;
1517 diff = diff % (dmabuf->dmasize); 1517 diff = diff % (dmabuf->dmasize);
@@ -1532,7 +1532,7 @@ drain_dac(struct trident_state *state, int nonblock)
1532 return 0; 1532 return 0;
1533} 1533}
1534 1534
1535/* update buffer manangement pointers, especially, */ 1535/* update buffer manangement pointers, especially, */
1536/* dmabuf->count and dmabuf->hwptr */ 1536/* dmabuf->count and dmabuf->hwptr */
1537static void 1537static void
1538trident_update_ptr(struct trident_state *state) 1538trident_update_ptr(struct trident_state *state)
@@ -1559,11 +1559,11 @@ trident_update_ptr(struct trident_state *state)
1559 } else { 1559 } else {
1560 dmabuf->count += diff; 1560 dmabuf->count += diff;
1561 1561
1562 if (dmabuf->count < 0 || 1562 if (dmabuf->count < 0 ||
1563 dmabuf->count > dmabuf->dmasize) { 1563 dmabuf->count > dmabuf->dmasize) {
1564 /* buffer underrun or buffer overrun, */ 1564 /* buffer underrun or buffer overrun, */
1565 /* we have no way to recover it here, just */ 1565 /* we have no way to recover it here, just */
1566 /* stop the machine and let the process */ 1566 /* stop the machine and let the process */
1567 /* force hwptr and swptr to sync */ 1567 /* force hwptr and swptr to sync */
1568 __stop_adc(state); 1568 __stop_adc(state);
1569 dmabuf->error++; 1569 dmabuf->error++;
@@ -1582,7 +1582,7 @@ trident_update_ptr(struct trident_state *state)
1582 } else { 1582 } else {
1583 dmabuf->count -= diff; 1583 dmabuf->count -= diff;
1584 1584
1585 if (dmabuf->count < 0 || 1585 if (dmabuf->count < 0 ||
1586 dmabuf->count > dmabuf->dmasize) { 1586 dmabuf->count > dmabuf->dmasize) {
1587 /* buffer underrun or buffer overrun, we have no way to recover 1587 /* buffer underrun or buffer overrun, we have no way to recover
1588 it here, just stop the machine and let the process force hwptr 1588 it here, just stop the machine and let the process force hwptr
@@ -1608,13 +1608,13 @@ trident_update_ptr(struct trident_state *state)
1608 if (state->chans_num == 6) { 1608 if (state->chans_num == 6) {
1609 clear_cnt = clear_cnt / 2; 1609 clear_cnt = clear_cnt / 2;
1610 swptr = swptr / 2; 1610 swptr = swptr / 2;
1611 memset(state->other_states[0]->dmabuf.rawbuf + swptr, 1611 memset(state->other_states[0]->dmabuf.rawbuf + swptr,
1612 silence, clear_cnt); 1612 silence, clear_cnt);
1613 memset(state->other_states[1]->dmabuf.rawbuf + swptr, 1613 memset(state->other_states[1]->dmabuf.rawbuf + swptr,
1614 silence, clear_cnt); 1614 silence, clear_cnt);
1615 memset(state->other_states[2]->dmabuf.rawbuf + swptr, 1615 memset(state->other_states[2]->dmabuf.rawbuf + swptr,
1616 silence, clear_cnt); 1616 silence, clear_cnt);
1617 memset(state->other_states[3]->dmabuf.rawbuf + swptr, 1617 memset(state->other_states[3]->dmabuf.rawbuf + swptr,
1618 silence, clear_cnt); 1618 silence, clear_cnt);
1619 } 1619 }
1620 dmabuf->endcleared = 1; 1620 dmabuf->endcleared = 1;
@@ -1627,13 +1627,13 @@ trident_update_ptr(struct trident_state *state)
1627 if (state->chans_num == 6) { 1627 if (state->chans_num == 6) {
1628 clear_cnt = clear_cnt / 2; 1628 clear_cnt = clear_cnt / 2;
1629 swptr = swptr / 2; 1629 swptr = swptr / 2;
1630 memset(state->other_states[0]->dmabuf.rawbuf + swptr, 1630 memset(state->other_states[0]->dmabuf.rawbuf + swptr,
1631 silence, clear_cnt); 1631 silence, clear_cnt);
1632 memset(state->other_states[1]->dmabuf.rawbuf + swptr, 1632 memset(state->other_states[1]->dmabuf.rawbuf + swptr,
1633 silence, clear_cnt); 1633 silence, clear_cnt);
1634 memset(state->other_states[2]->dmabuf.rawbuf + swptr, 1634 memset(state->other_states[2]->dmabuf.rawbuf + swptr,
1635 silence, clear_cnt); 1635 silence, clear_cnt);
1636 memset(state->other_states[3]->dmabuf.rawbuf + swptr, 1636 memset(state->other_states[3]->dmabuf.rawbuf + swptr,
1637 silence, clear_cnt); 1637 silence, clear_cnt);
1638 } 1638 }
1639 dmabuf->endcleared = 1; 1639 dmabuf->endcleared = 1;
@@ -1665,7 +1665,7 @@ trident_address_interrupt(struct trident_card *card)
1665 if ((state = card->states[i]) != NULL) { 1665 if ((state = card->states[i]) != NULL) {
1666 trident_update_ptr(state); 1666 trident_update_ptr(state);
1667 } else { 1667 } else {
1668 printk(KERN_WARNING "trident: spurious channel " 1668 printk(KERN_WARNING "trident: spurious channel "
1669 "irq %d.\n", channel); 1669 "irq %d.\n", channel);
1670 trident_stop_voice(card, channel); 1670 trident_stop_voice(card, channel);
1671 trident_disable_voice_irq(card, channel); 1671 trident_disable_voice_irq(card, channel);
@@ -1694,7 +1694,7 @@ ali_hwvol_control(struct trident_card *card, int opt)
1694 1694
1695 if (opt == 1) { // MUTE 1695 if (opt == 1) { // MUTE
1696 dwTemp ^= 0x8000; 1696 dwTemp ^= 0x8000;
1697 ali_ac97_write(card->ac97_codec[0], 1697 ali_ac97_write(card->ac97_codec[0],
1698 0x02, dwTemp); 1698 0x02, dwTemp);
1699 } else if (opt == 2) { // Down 1699 } else if (opt == 2) { // Down
1700 if (mute) 1700 if (mute)
@@ -1706,7 +1706,7 @@ ali_hwvol_control(struct trident_card *card, int opt)
1706 dwTemp &= 0xe0e0; 1706 dwTemp &= 0xe0e0;
1707 dwTemp |= (volume[0]) | (volume[1] << 8); 1707 dwTemp |= (volume[0]) | (volume[1] << 8);
1708 ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp); 1708 ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
1709 card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 1709 card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) |
1710 (((32 - volume[1]) * 25 / 8) << 8); 1710 (((32 - volume[1]) * 25 / 8) << 8);
1711 } else if (opt == 4) { // Up 1711 } else if (opt == 4) { // Up
1712 if (mute) 1712 if (mute)
@@ -1718,7 +1718,7 @@ ali_hwvol_control(struct trident_card *card, int opt)
1718 dwTemp &= 0xe0e0; 1718 dwTemp &= 0xe0e0;
1719 dwTemp |= (volume[0]) | (volume[1] << 8); 1719 dwTemp |= (volume[0]) | (volume[1] << 8);
1720 ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp); 1720 ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
1721 card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 1721 card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) |
1722 (((32 - volume[1]) * 25 / 8) << 8); 1722 (((32 - volume[1]) * 25 / 8) << 8);
1723 } else { 1723 } else {
1724 /* Nothing needs doing */ 1724 /* Nothing needs doing */
@@ -1801,7 +1801,7 @@ cyber_address_interrupt(struct trident_card *card)
1801 if ((state = card->states[i]) != NULL) { 1801 if ((state = card->states[i]) != NULL) {
1802 trident_update_ptr(state); 1802 trident_update_ptr(state);
1803 } else { 1803 } else {
1804 printk(KERN_WARNING "cyber5050: spurious " 1804 printk(KERN_WARNING "cyber5050: spurious "
1805 "channel irq %d.\n", channel); 1805 "channel irq %d.\n", channel);
1806 trident_stop_voice(card, channel); 1806 trident_stop_voice(card, channel);
1807 trident_disable_voice_irq(card, channel); 1807 trident_disable_voice_irq(card, channel);
@@ -1836,21 +1836,21 @@ trident_interrupt(int irq, void *dev_id)
1836 ali_queue_task(card, gpio & 0x07); 1836 ali_queue_task(card, gpio & 0x07);
1837 } 1837 }
1838 event = inl(TRID_REG(card, T4D_MISCINT)); 1838 event = inl(TRID_REG(card, T4D_MISCINT));
1839 outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 1839 outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1840 TRID_REG(card, T4D_MISCINT)); 1840 TRID_REG(card, T4D_MISCINT));
1841 spin_unlock(&card->lock); 1841 spin_unlock(&card->lock);
1842 return IRQ_HANDLED; 1842 return IRQ_HANDLED;
1843 } 1843 }
1844 1844
1845 /* manually clear interrupt status, bad hardware design, blame T^2 */ 1845 /* manually clear interrupt status, bad hardware design, blame T^2 */
1846 outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 1846 outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1847 TRID_REG(card, T4D_MISCINT)); 1847 TRID_REG(card, T4D_MISCINT));
1848 spin_unlock(&card->lock); 1848 spin_unlock(&card->lock);
1849 return IRQ_HANDLED; 1849 return IRQ_HANDLED;
1850} 1850}
1851 1851
1852/* in this loop, dmabuf.count signifies the amount of data that is waiting */ 1852/* in this loop, dmabuf.count signifies the amount of data that is waiting */
1853/* to be copied to the user's buffer. it is filled by the dma machine and */ 1853/* to be copied to the user's buffer. it is filled by the dma machine and */
1854/* drained by this loop. */ 1854/* drained by this loop. */
1855static ssize_t 1855static ssize_t
1856trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos) 1856trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
@@ -1878,8 +1878,8 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1878 while (count > 0) { 1878 while (count > 0) {
1879 spin_lock_irqsave(&state->card->lock, flags); 1879 spin_lock_irqsave(&state->card->lock, flags);
1880 if (dmabuf->count > (signed) dmabuf->dmasize) { 1880 if (dmabuf->count > (signed) dmabuf->dmasize) {
1881 /* buffer overrun, we are recovering from */ 1881 /* buffer overrun, we are recovering from */
1882 /* sleep_on_timeout, resync hwptr and swptr, */ 1882 /* sleep_on_timeout, resync hwptr and swptr, */
1883 /* make process flush the buffer */ 1883 /* make process flush the buffer */
1884 dmabuf->count = dmabuf->dmasize; 1884 dmabuf->count = dmabuf->dmasize;
1885 dmabuf->swptr = dmabuf->hwptr; 1885 dmabuf->swptr = dmabuf->hwptr;
@@ -1894,7 +1894,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1894 cnt = count; 1894 cnt = count;
1895 if (cnt <= 0) { 1895 if (cnt <= 0) {
1896 unsigned long tmo; 1896 unsigned long tmo;
1897 /* buffer is empty, start the dma machine and */ 1897 /* buffer is empty, start the dma machine and */
1898 /* wait for data to be recorded */ 1898 /* wait for data to be recorded */
1899 start_adc(state); 1899 start_adc(state);
1900 if (file->f_flags & O_NONBLOCK) { 1900 if (file->f_flags & O_NONBLOCK) {
@@ -1904,8 +1904,8 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
1904 } 1904 }
1905 1905
1906 mutex_unlock(&state->sem); 1906 mutex_unlock(&state->sem);
1907 /* No matter how much space left in the buffer, */ 1907 /* No matter how much space left in the buffer, */
1908 /* we have to wait until CSO == ESO/2 or CSO == ESO */ 1908 /* we have to wait until CSO == ESO/2 or CSO == ESO */
1909 /* when address engine interrupts */ 1909 /* when address engine interrupts */
1910 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2); 1910 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
1911 tmo >>= sample_shift[dmabuf->fmt]; 1911 tmo >>= sample_shift[dmabuf->fmt];
@@ -2005,7 +2005,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2005 while (count > 0) { 2005 while (count > 0) {
2006 spin_lock_irqsave(&state->card->lock, flags); 2006 spin_lock_irqsave(&state->card->lock, flags);
2007 if (dmabuf->count < 0) { 2007 if (dmabuf->count < 0) {
2008 /* buffer underrun, we are recovering from */ 2008 /* buffer underrun, we are recovering from */
2009 /* sleep_on_timeout, resync hwptr and swptr */ 2009 /* sleep_on_timeout, resync hwptr and swptr */
2010 dmabuf->count = 0; 2010 dmabuf->count = 0;
2011 dmabuf->swptr = dmabuf->hwptr; 2011 dmabuf->swptr = dmabuf->hwptr;
@@ -2020,7 +2020,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2020 cnt = count; 2020 cnt = count;
2021 if (cnt <= 0) { 2021 if (cnt <= 0) {
2022 unsigned long tmo; 2022 unsigned long tmo;
2023 /* buffer is full, start the dma machine and */ 2023 /* buffer is full, start the dma machine and */
2024 /* wait for data to be played */ 2024 /* wait for data to be played */
2025 start_dac(state); 2025 start_dac(state);
2026 if (file->f_flags & O_NONBLOCK) { 2026 if (file->f_flags & O_NONBLOCK) {
@@ -2028,8 +2028,8 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2028 ret = -EAGAIN; 2028 ret = -EAGAIN;
2029 goto out; 2029 goto out;
2030 } 2030 }
2031 /* No matter how much data left in the buffer, */ 2031 /* No matter how much data left in the buffer, */
2032 /* we have to wait until CSO == ESO/2 or CSO == ESO */ 2032 /* we have to wait until CSO == ESO/2 or CSO == ESO */
2033 /* when address engine interrupts */ 2033 /* when address engine interrupts */
2034 lock_set_fmt(state); 2034 lock_set_fmt(state);
2035 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2); 2035 tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
@@ -2037,15 +2037,15 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2037 unlock_set_fmt(state); 2037 unlock_set_fmt(state);
2038 mutex_unlock(&state->sem); 2038 mutex_unlock(&state->sem);
2039 2039
2040 /* There are two situations when sleep_on_timeout */ 2040 /* There are two situations when sleep_on_timeout */
2041 /* returns, one is when the interrupt is serviced */ 2041 /* returns, one is when the interrupt is serviced */
2042 /* correctly and the process is waked up by ISR */ 2042 /* correctly and the process is waked up by ISR */
2043 /* ON TIME. Another is when timeout is expired, which */ 2043 /* ON TIME. Another is when timeout is expired, which */
2044 /* means that either interrupt is NOT serviced */ 2044 /* means that either interrupt is NOT serviced */
2045 /* correctly (pending interrupt) or it is TOO LATE */ 2045 /* correctly (pending interrupt) or it is TOO LATE */
2046 /* for the process to be scheduled to run */ 2046 /* for the process to be scheduled to run */
2047 /* (scheduler latency) which results in a (potential) */ 2047 /* (scheduler latency) which results in a (potential) */
2048 /* buffer underrun. And worse, there is NOTHING we */ 2048 /* buffer underrun. And worse, there is NOTHING we */
2049 /* can do to prevent it. */ 2049 /* can do to prevent it. */
2050 if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) { 2050 if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
2051 pr_debug(KERN_ERR "trident: playback schedule " 2051 pr_debug(KERN_ERR "trident: playback schedule "
@@ -2054,8 +2054,8 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2054 dmabuf->fragsize, dmabuf->count, 2054 dmabuf->fragsize, dmabuf->count,
2055 dmabuf->hwptr, dmabuf->swptr); 2055 dmabuf->hwptr, dmabuf->swptr);
2056 2056
2057 /* a buffer underrun, we delay the recovery */ 2057 /* a buffer underrun, we delay the recovery */
2058 /* until next time the while loop begin and */ 2058 /* until next time the while loop begin and */
2059 /* we REALLY have data to play */ 2059 /* we REALLY have data to play */
2060 } 2060 }
2061 if (signal_pending(current)) { 2061 if (signal_pending(current)) {
@@ -2079,7 +2079,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2079 if (state->chans_num == 6) { 2079 if (state->chans_num == 6) {
2080 copy_count = 0; 2080 copy_count = 0;
2081 state_cnt = 0; 2081 state_cnt = 0;
2082 if (ali_write_5_1(state, buffer, cnt, &copy_count, 2082 if (ali_write_5_1(state, buffer, cnt, &copy_count,
2083 &state_cnt) == -EFAULT) { 2083 &state_cnt) == -EFAULT) {
2084 if (state_cnt) { 2084 if (state_cnt) {
2085 swptr = (swptr + state_cnt) % dmabuf->dmasize; 2085 swptr = (swptr + state_cnt) % dmabuf->dmasize;
@@ -2096,7 +2096,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
2096 goto out; 2096 goto out;
2097 } 2097 }
2098 } else { 2098 } else {
2099 if (copy_from_user(dmabuf->rawbuf + swptr, 2099 if (copy_from_user(dmabuf->rawbuf + swptr,
2100 buffer, cnt)) { 2100 buffer, cnt)) {
2101 if (!ret) 2101 if (!ret)
2102 ret = -EFAULT; 2102 ret = -EFAULT;
@@ -2172,7 +2172,7 @@ trident_poll(struct file *file, struct poll_table_struct *wait)
2172 if (dmabuf->count >= (signed) dmabuf->fragsize) 2172 if (dmabuf->count >= (signed) dmabuf->fragsize)
2173 mask |= POLLOUT | POLLWRNORM; 2173 mask |= POLLOUT | POLLWRNORM;
2174 } else { 2174 } else {
2175 if ((signed) dmabuf->dmasize >= dmabuf->count + 2175 if ((signed) dmabuf->dmasize >= dmabuf->count +
2176 (signed) dmabuf->fragsize) 2176 (signed) dmabuf->fragsize)
2177 mask |= POLLOUT | POLLWRNORM; 2177 mask |= POLLOUT | POLLWRNORM;
2178 } 2178 }
@@ -2227,7 +2227,7 @@ out:
2227} 2227}
2228 2228
2229static int 2229static int
2230trident_ioctl(struct inode *inode, struct file *file, 2230trident_ioctl(struct inode *inode, struct file *file,
2231 unsigned int cmd, unsigned long arg) 2231 unsigned int cmd, unsigned long arg)
2232{ 2232{
2233 struct trident_state *state = (struct trident_state *)file->private_data; 2233 struct trident_state *state = (struct trident_state *)file->private_data;
@@ -2348,7 +2348,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2348 2348
2349 2349
2350 case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format */ 2350 case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format */
2351 ret = put_user(AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 | 2351 ret = put_user(AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 |
2352 AFMT_U8, p); 2352 AFMT_U8, p);
2353 break; 2353 break;
2354 2354
@@ -2379,7 +2379,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2379 } 2379 }
2380 } 2380 }
2381 unlock_set_fmt(state); 2381 unlock_set_fmt(state);
2382 ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 2382 ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE :
2383 AFMT_U8, p); 2383 AFMT_U8, p);
2384 break; 2384 break;
2385 2385
@@ -2438,7 +2438,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2438 stop_adc(state); 2438 stop_adc(state);
2439 dmabuf->ready = 0; 2439 dmabuf->ready = 0;
2440 if (val >= 2) { 2440 if (val >= 2) {
2441 if (!((file->f_mode & FMODE_WRITE) && 2441 if (!((file->f_mode & FMODE_WRITE) &&
2442 (val == 6))) 2442 (val == 6)))
2443 val = 2; 2443 val = 2;
2444 dmabuf->fmt |= TRIDENT_FMT_STEREO; 2444 dmabuf->fmt |= TRIDENT_FMT_STEREO;
@@ -2504,7 +2504,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2504 abinfo.fragstotal = dmabuf->numfrag; 2504 abinfo.fragstotal = dmabuf->numfrag;
2505 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift; 2505 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
2506 spin_unlock_irqrestore(&state->card->lock, flags); 2506 spin_unlock_irqrestore(&state->card->lock, flags);
2507 ret = copy_to_user(argp, &abinfo, sizeof (abinfo)) ? 2507 ret = copy_to_user(argp, &abinfo, sizeof (abinfo)) ?
2508 -EFAULT : 0; 2508 -EFAULT : 0;
2509 break; 2509 break;
2510 2510
@@ -2524,7 +2524,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2524 abinfo.fragstotal = dmabuf->numfrag; 2524 abinfo.fragstotal = dmabuf->numfrag;
2525 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift; 2525 abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
2526 spin_unlock_irqrestore(&state->card->lock, flags); 2526 spin_unlock_irqrestore(&state->card->lock, flags);
2527 ret = copy_to_user(argp, &abinfo, sizeof (abinfo)) ? 2527 ret = copy_to_user(argp, &abinfo, sizeof (abinfo)) ?
2528 -EFAULT : 0; 2528 -EFAULT : 0;
2529 break; 2529 break;
2530 2530
@@ -2533,7 +2533,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2533 break; 2533 break;
2534 2534
2535 case SNDCTL_DSP_GETCAPS: 2535 case SNDCTL_DSP_GETCAPS:
2536 ret = put_user(DSP_CAP_REALTIME | DSP_CAP_TRIGGER | 2536 ret = put_user(DSP_CAP_REALTIME | DSP_CAP_TRIGGER |
2537 DSP_CAP_MMAP | DSP_CAP_BIND, p); 2537 DSP_CAP_MMAP | DSP_CAP_BIND, p);
2538 break; 2538 break;
2539 2539
@@ -2553,7 +2553,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2553 } 2553 }
2554 if (file->f_mode & FMODE_READ) { 2554 if (file->f_mode & FMODE_READ) {
2555 if (val & PCM_ENABLE_INPUT) { 2555 if (val & PCM_ENABLE_INPUT) {
2556 if (!dmabuf->ready && 2556 if (!dmabuf->ready &&
2557 (ret = prog_dmabuf_record(state))) 2557 (ret = prog_dmabuf_record(state)))
2558 break; 2558 break;
2559 start_adc(state); 2559 start_adc(state);
@@ -2562,7 +2562,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2562 } 2562 }
2563 if (file->f_mode & FMODE_WRITE) { 2563 if (file->f_mode & FMODE_WRITE) {
2564 if (val & PCM_ENABLE_OUTPUT) { 2564 if (val & PCM_ENABLE_OUTPUT) {
2565 if (!dmabuf->ready && 2565 if (!dmabuf->ready &&
2566 (ret = prog_dmabuf_playback(state))) 2566 (ret = prog_dmabuf_playback(state)))
2567 break; 2567 break;
2568 start_dac(state); 2568 start_dac(state);
@@ -2589,7 +2589,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2589 if (dmabuf->mapped) 2589 if (dmabuf->mapped)
2590 dmabuf->count &= dmabuf->fragsize - 1; 2590 dmabuf->count &= dmabuf->fragsize - 1;
2591 spin_unlock_irqrestore(&state->card->lock, flags); 2591 spin_unlock_irqrestore(&state->card->lock, flags);
2592 ret = copy_to_user(argp, &cinfo, sizeof (cinfo)) ? 2592 ret = copy_to_user(argp, &cinfo, sizeof (cinfo)) ?
2593 -EFAULT : 0; 2593 -EFAULT : 0;
2594 break; 2594 break;
2595 2595
@@ -2612,7 +2612,7 @@ trident_ioctl(struct inode *inode, struct file *file,
2612 if (dmabuf->mapped) 2612 if (dmabuf->mapped)
2613 dmabuf->count &= dmabuf->fragsize - 1; 2613 dmabuf->count &= dmabuf->fragsize - 1;
2614 spin_unlock_irqrestore(&state->card->lock, flags); 2614 spin_unlock_irqrestore(&state->card->lock, flags);
2615 ret = copy_to_user(argp, &cinfo, sizeof (cinfo)) ? 2615 ret = copy_to_user(argp, &cinfo, sizeof (cinfo)) ?
2616 -EFAULT : 0; 2616 -EFAULT : 0;
2617 break; 2617 break;
2618 2618
@@ -2641,17 +2641,17 @@ trident_ioctl(struct inode *inode, struct file *file,
2641 break; 2641 break;
2642 2642
2643 case SOUND_PCM_READ_CHANNELS: 2643 case SOUND_PCM_READ_CHANNELS:
2644 ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1, 2644 ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1,
2645 p); 2645 p);
2646 break; 2646 break;
2647 2647
2648 case SOUND_PCM_READ_BITS: 2648 case SOUND_PCM_READ_BITS:
2649 ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 2649 ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE :
2650 AFMT_U8, p); 2650 AFMT_U8, p);
2651 break; 2651 break;
2652 2652
2653 case SNDCTL_DSP_GETCHANNELMASK: 2653 case SNDCTL_DSP_GETCHANNELMASK:
2654 ret = put_user(DSP_BIND_FRONT | DSP_BIND_SURR | 2654 ret = put_user(DSP_BIND_FRONT | DSP_BIND_SURR |
2655 DSP_BIND_CENTER_LFE, p); 2655 DSP_BIND_CENTER_LFE, p);
2656 break; 2656 break;
2657 2657
@@ -2671,10 +2671,10 @@ trident_ioctl(struct inode *inode, struct file *file,
2671 } else { 2671 } else {
2672 dmabuf->ready = 0; 2672 dmabuf->ready = 0;
2673 if (file->f_mode & FMODE_READ) 2673 if (file->f_mode & FMODE_READ)
2674 dmabuf->channel->attribute = (CHANNEL_REC | 2674 dmabuf->channel->attribute = (CHANNEL_REC |
2675 SRC_ENABLE); 2675 SRC_ENABLE);
2676 if (file->f_mode & FMODE_WRITE) 2676 if (file->f_mode & FMODE_WRITE)
2677 dmabuf->channel->attribute = (CHANNEL_SPC_PB | 2677 dmabuf->channel->attribute = (CHANNEL_SPC_PB |
2678 SRC_ENABLE); 2678 SRC_ENABLE);
2679 dmabuf->channel->attribute |= mask2attr[ffs(val)]; 2679 dmabuf->channel->attribute |= mask2attr[ffs(val)];
2680 } 2680 }
@@ -2702,6 +2702,7 @@ trident_open(struct inode *inode, struct file *file)
2702 struct trident_card *card = devs; 2702 struct trident_card *card = devs;
2703 struct trident_state *state = NULL; 2703 struct trident_state *state = NULL;
2704 struct dmabuf *dmabuf = NULL; 2704 struct dmabuf *dmabuf = NULL;
2705 unsigned long flags;
2705 2706
2706 /* Added by Matt Wu 01-05-2001 */ 2707 /* Added by Matt Wu 01-05-2001 */
2707 /* TODO: there's some redundacy here wrt the check below */ 2708 /* TODO: there's some redundacy here wrt the check below */
@@ -2765,8 +2766,8 @@ trident_open(struct inode *inode, struct file *file)
2765 init_waitqueue_head(&dmabuf->wait); 2766 init_waitqueue_head(&dmabuf->wait);
2766 file->private_data = state; 2767 file->private_data = state;
2767 2768
2768 /* set default sample format. According to OSS Programmer's */ 2769 /* set default sample format. According to OSS Programmer's */
2769 /* Guide /dev/dsp should be default to unsigned 8-bits, mono, */ 2770 /* Guide /dev/dsp should be default to unsigned 8-bits, mono, */
2770 /* with sample rate 8kHz and /dev/dspW will accept 16-bits sample */ 2771 /* with sample rate 8kHz and /dev/dspW will accept 16-bits sample */
2771 if (file->f_mode & FMODE_WRITE) { 2772 if (file->f_mode & FMODE_WRITE) {
2772 dmabuf->fmt &= ~TRIDENT_FMT_MASK; 2773 dmabuf->fmt &= ~TRIDENT_FMT_MASK;
@@ -2779,11 +2780,13 @@ trident_open(struct inode *inode, struct file *file)
2779 /* set default channel attribute to normal playback */ 2780 /* set default channel attribute to normal playback */
2780 dmabuf->channel->attribute = CHANNEL_PB; 2781 dmabuf->channel->attribute = CHANNEL_PB;
2781 } 2782 }
2783 spin_lock_irqsave(&card->lock, flags);
2782 trident_set_dac_rate(state, 8000); 2784 trident_set_dac_rate(state, 8000);
2785 spin_unlock_irqrestore(&card->lock, flags);
2783 } 2786 }
2784 2787
2785 if (file->f_mode & FMODE_READ) { 2788 if (file->f_mode & FMODE_READ) {
2786 /* FIXME: Trident 4d can only record in signed 16-bits stereo, */ 2789 /* FIXME: Trident 4d can only record in signed 16-bits stereo, */
2787 /* 48kHz sample, to be dealed with in trident_set_adc_rate() ?? */ 2790 /* 48kHz sample, to be dealed with in trident_set_adc_rate() ?? */
2788 dmabuf->fmt &= ~TRIDENT_FMT_MASK; 2791 dmabuf->fmt &= ~TRIDENT_FMT_MASK;
2789 if ((minor & 0x0f) == SND_DEV_DSP16) 2792 if ((minor & 0x0f) == SND_DEV_DSP16)
@@ -2794,10 +2797,12 @@ trident_open(struct inode *inode, struct file *file)
2794 if (card->pci_id == PCI_DEVICE_ID_SI_7018) { 2797 if (card->pci_id == PCI_DEVICE_ID_SI_7018) {
2795 /* set default channel attribute to 0x8a80, record from 2798 /* set default channel attribute to 0x8a80, record from
2796 PCM L/R FIFO and mono = (left + right + 1)/2 */ 2799 PCM L/R FIFO and mono = (left + right + 1)/2 */
2797 dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR | 2800 dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR |
2798 MONO_MIX); 2801 MONO_MIX);
2799 } 2802 }
2803 spin_lock_irqsave(&card->lock, flags);
2800 trident_set_adc_rate(state, 8000); 2804 trident_set_adc_rate(state, 8000);
2805 spin_unlock_irqrestore(&card->lock, flags);
2801 2806
2802 /* Added by Matt Wu 01-05-2001 */ 2807 /* Added by Matt Wu 01-05-2001 */
2803 if (card->pci_id == PCI_DEVICE_ID_ALI_5451) 2808 if (card->pci_id == PCI_DEVICE_ID_ALI_5451)
@@ -3020,7 +3025,7 @@ acquirecodecaccess(struct trident_card *card)
3020 break; 3025 break;
3021 if (wsemabits == 0) { 3026 if (wsemabits == 0) {
3022 unlock: 3027 unlock:
3023 outl(((u32) (wcontrol & 0x1eff) | 0x00004000), 3028 outl(((u32) (wcontrol & 0x1eff) | 0x00004000),
3024 TRID_REG(card, ALI_AC97_WRITE)); 3029 TRID_REG(card, ALI_AC97_WRITE));
3025 continue; 3030 continue;
3026 } 3031 }
@@ -3104,7 +3109,7 @@ ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
3104 ncount = 10; 3109 ncount = 10;
3105 3110
3106 while (1) { 3111 while (1) {
3107 if ((inw(TRID_REG(card, ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) 3112 if ((inw(TRID_REG(card, ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ)
3108 != 0) 3113 != 0)
3109 break; 3114 break;
3110 if (ncount <= 0) 3115 if (ncount <= 0)
@@ -3112,7 +3117,7 @@ ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
3112 if (ncount-- == 1) { 3117 if (ncount-- == 1) {
3113 pr_debug("ali_ac97_read :try clear busy flag\n"); 3118 pr_debug("ali_ac97_read :try clear busy flag\n");
3114 aud_reg = inl(TRID_REG(card, ALI_AC97_WRITE)); 3119 aud_reg = inl(TRID_REG(card, ALI_AC97_WRITE));
3115 outl((aud_reg & 0xffff7fff), 3120 outl((aud_reg & 0xffff7fff),
3116 TRID_REG(card, ALI_AC97_WRITE)); 3121 TRID_REG(card, ALI_AC97_WRITE));
3117 } 3122 }
3118 udelay(10); 3123 udelay(10);
@@ -3159,7 +3164,7 @@ ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
3159 3164
3160 wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); 3165 wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
3161 wcontrol &= 0xff00; 3166 wcontrol &= 0xff00;
3162 wcontrol |= (0x8100 | reg); /* bit 8=1: (ali1535 )reserved/ */ 3167 wcontrol |= (0x8100 | reg); /* bit 8=1: (ali1535 )reserved/ */
3163 /* ali1535+ write */ 3168 /* ali1535+ write */
3164 outl((data | wcontrol), TRID_REG(card, ALI_AC97_WRITE)); 3169 outl((data | wcontrol), TRID_REG(card, ALI_AC97_WRITE));
3165 3170
@@ -3177,7 +3182,7 @@ ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
3177 break; 3182 break;
3178 if (ncount-- == 1) { 3183 if (ncount-- == 1) {
3179 pr_debug("ali_ac97_set :try clear busy flag!!\n"); 3184 pr_debug("ali_ac97_set :try clear busy flag!!\n");
3180 outw(wcontrol & 0x7fff, 3185 outw(wcontrol & 0x7fff,
3181 TRID_REG(card, ALI_AC97_WRITE)); 3186 TRID_REG(card, ALI_AC97_WRITE));
3182 } 3187 }
3183 udelay(10); 3188 udelay(10);
@@ -3382,7 +3387,7 @@ ali_detect_spdif_rate(struct trident_card *card)
3382 bval |= 0x1F; 3387 bval |= 0x1F;
3383 outb(bval, TRID_REG(card, ALI_SPDIF_CTRL + 1)); 3388 outb(bval, TRID_REG(card, ALI_SPDIF_CTRL + 1));
3384 3389
3385 while (((R1 < 0x0B) || (R1 > 0x0E)) && (R1 != 0x12) && 3390 while (((R1 < 0x0B) || (R1 > 0x0E)) && (R1 != 0x12) &&
3386 count <= 50000) { 3391 count <= 50000) {
3387 count++; 3392 count++;
3388 3393
@@ -3669,14 +3674,14 @@ ali_save_regs(struct trident_card *card)
3669 spin_lock_irqsave(&card->lock, flags); 3674 spin_lock_irqsave(&card->lock, flags);
3670 3675
3671 ali_registers.global_regs[0x2c] = inl(TRID_REG(card, T4D_MISCINT)); 3676 ali_registers.global_regs[0x2c] = inl(TRID_REG(card, T4D_MISCINT));
3672 //ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A)); 3677 //ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A));
3673 ali_registers.global_regs[0x21] = inl(TRID_REG(card, T4D_STOP_A)); 3678 ali_registers.global_regs[0x21] = inl(TRID_REG(card, T4D_STOP_A));
3674 3679
3675 //disable all IRQ bits 3680 //disable all IRQ bits
3676 outl(ALI_DISABLE_ALL_IRQ, TRID_REG(card, T4D_MISCINT)); 3681 outl(ALI_DISABLE_ALL_IRQ, TRID_REG(card, T4D_MISCINT));
3677 3682
3678 for (i = 1; i < ALI_MIXER_REGS; i++) 3683 for (i = 1; i < ALI_MIXER_REGS; i++)
3679 ali_registers.mixer_regs[i] = ali_ac97_read(card->ac97_codec[0], 3684 ali_registers.mixer_regs[i] = ali_ac97_read(card->ac97_codec[0],
3680 i * 2); 3685 i * 2);
3681 3686
3682 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 3687 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
@@ -3688,7 +3693,7 @@ ali_save_regs(struct trident_card *card)
3688 for (i = 0; i < ALI_CHANNELS; i++) { 3693 for (i = 0; i < ALI_CHANNELS; i++) {
3689 outb(i, TRID_REG(card, T4D_LFO_GC_CIR)); 3694 outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
3690 for (j = 0; j < ALI_CHANNEL_REGS; j++) 3695 for (j = 0; j < ALI_CHANNEL_REGS; j++)
3691 ali_registers.channel_regs[i][j] = inl(TRID_REG(card, 3696 ali_registers.channel_regs[i][j] = inl(TRID_REG(card,
3692 j * 4 + 0xe0)); 3697 j * 4 + 0xe0));
3693 } 3698 }
3694 3699
@@ -3707,18 +3712,18 @@ ali_restore_regs(struct trident_card *card)
3707 spin_lock_irqsave(&card->lock, flags); 3712 spin_lock_irqsave(&card->lock, flags);
3708 3713
3709 for (i = 1; i < ALI_MIXER_REGS; i++) 3714 for (i = 1; i < ALI_MIXER_REGS; i++)
3710 ali_ac97_write(card->ac97_codec[0], i * 2, 3715 ali_ac97_write(card->ac97_codec[0], i * 2,
3711 ali_registers.mixer_regs[i]); 3716 ali_registers.mixer_regs[i]);
3712 3717
3713 for (i = 0; i < ALI_CHANNELS; i++) { 3718 for (i = 0; i < ALI_CHANNELS; i++) {
3714 outb(i, TRID_REG(card, T4D_LFO_GC_CIR)); 3719 outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
3715 for (j = 0; j < ALI_CHANNEL_REGS; j++) 3720 for (j = 0; j < ALI_CHANNEL_REGS; j++)
3716 outl(ali_registers.channel_regs[i][j], 3721 outl(ali_registers.channel_regs[i][j],
3717 TRID_REG(card, j * 4 + 0xe0)); 3722 TRID_REG(card, j * 4 + 0xe0));
3718 } 3723 }
3719 3724
3720 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 3725 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
3721 if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A) || 3726 if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A) ||
3722 (i * 4 == T4D_START_A)) 3727 (i * 4 == T4D_START_A))
3723 continue; 3728 continue;
3724 outl(ali_registers.global_regs[i], TRID_REG(card, i * 4)); 3729 outl(ali_registers.global_regs[i], TRID_REG(card, i * 4));
@@ -3763,7 +3768,7 @@ ali_alloc_pcm_channel(struct trident_card *card)
3763 3768
3764 bank = &card->banks[BANK_A]; 3769 bank = &card->banks[BANK_A];
3765 3770
3766 if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & 3771 if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) &
3767 (ALI_SPDIF_OUT_CH_ENABLE)) { 3772 (ALI_SPDIF_OUT_CH_ENABLE)) {
3768 idx = ALI_SPDIF_OUT_CHANNEL; 3773 idx = ALI_SPDIF_OUT_CHANNEL;
3769 if (!(bank->bitmap & (1 << idx))) { 3774 if (!(bank->bitmap & (1 << idx))) {
@@ -3774,7 +3779,7 @@ ali_alloc_pcm_channel(struct trident_card *card)
3774 } 3779 }
3775 } 3780 }
3776 3781
3777 for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST; 3782 for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST;
3778 idx++) { 3783 idx++) {
3779 if (!(bank->bitmap & (1 << idx))) { 3784 if (!(bank->bitmap & (1 << idx))) {
3780 struct trident_channel *channel = &bank->channels[idx]; 3785 struct trident_channel *channel = &bank->channels[idx];
@@ -3785,9 +3790,9 @@ ali_alloc_pcm_channel(struct trident_card *card)
3785 } 3790 }
3786 3791
3787 /* no more free channels avaliable */ 3792 /* no more free channels avaliable */
3788#if 0 3793#if 0
3789 printk(KERN_ERR "ali: no more channels available on Bank A.\n"); 3794 printk(KERN_ERR "ali: no more channels available on Bank A.\n");
3790#endif /* 0 */ 3795#endif /* 0 */
3791 return NULL; 3796 return NULL;
3792} 3797}
3793 3798
@@ -3812,9 +3817,9 @@ ali_alloc_rec_pcm_channel(struct trident_card *card)
3812 } 3817 }
3813 3818
3814 /* no free recordable channels avaliable */ 3819 /* no free recordable channels avaliable */
3815#if 0 3820#if 0
3816 printk(KERN_ERR "ali: no recordable channels available on Bank A.\n"); 3821 printk(KERN_ERR "ali: no recordable channels available on Bank A.\n");
3817#endif /* 0 */ 3822#endif /* 0 */
3818 return NULL; 3823 return NULL;
3819} 3824}
3820 3825
@@ -3837,14 +3842,14 @@ ali_set_spdif_out_rate(struct trident_card *card, unsigned int rate)
3837 break; 3842 break;
3838 } 3843 }
3839 3844
3840 /* select spdif_out */ 3845 /* select spdif_out */
3841 ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS; 3846 ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS;
3842 3847
3843 ch_st_sel |= 0x80; /* select right */ 3848 ch_st_sel |= 0x80; /* select right */
3844 outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL)); 3849 outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
3845 outb(status_rate | 0x20, TRID_REG(card, ALI_SPDIF_CS + 2)); 3850 outb(status_rate | 0x20, TRID_REG(card, ALI_SPDIF_CS + 2));
3846 3851
3847 ch_st_sel &= (~0x80); /* select left */ 3852 ch_st_sel &= (~0x80); /* select left */
3848 outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL)); 3853 outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
3849 outw(status_rate | 0x10, TRID_REG(card, ALI_SPDIF_CS + 2)); 3854 outw(status_rate | 0x10, TRID_REG(card, ALI_SPDIF_CS + 2));
3850} 3855}
@@ -3881,14 +3886,14 @@ ali_address_interrupt(struct trident_card *card)
3881 } 3886 }
3882} 3887}
3883 3888
3884/* Updating the values of counters of other_states' DMAs without lock 3889/* Updating the values of counters of other_states' DMAs without lock
3885protection is no harm because all DMAs of multi-channels and interrupt 3890protection is no harm because all DMAs of multi-channels and interrupt
3886depend on a master state's DMA, and changing the counters of the master 3891depend on a master state's DMA, and changing the counters of the master
3887state DMA is protected by a spinlock. 3892state DMA is protected by a spinlock.
3888*/ 3893*/
3889static int 3894static int
3890ali_write_5_1(struct trident_state *state, const char __user *buf, 3895ali_write_5_1(struct trident_state *state, const char __user *buf,
3891 int cnt_for_multi_channel, unsigned int *copy_count, 3896 int cnt_for_multi_channel, unsigned int *copy_count,
3892 unsigned int *state_cnt) 3897 unsigned int *state_cnt)
3893{ 3898{
3894 3899
@@ -3904,10 +3909,10 @@ ali_write_5_1(struct trident_state *state, const char __user *buf,
3904 3909
3905 if ((i = state->multi_channels_adjust_count) > 0) { 3910 if ((i = state->multi_channels_adjust_count) > 0) {
3906 if (i == 1) { 3911 if (i == 1) {
3907 if (copy_from_user(dmabuf->rawbuf + swptr, 3912 if (copy_from_user(dmabuf->rawbuf + swptr,
3908 buffer, sample_s)) 3913 buffer, sample_s))
3909 return -EFAULT; 3914 return -EFAULT;
3910 seek_offset(swptr, buffer, cnt_for_multi_channel, 3915 seek_offset(swptr, buffer, cnt_for_multi_channel,
3911 sample_s, *copy_count); 3916 sample_s, *copy_count);
3912 i--; 3917 i--;
3913 (*state_cnt) += sample_s; 3918 (*state_cnt) += sample_s;
@@ -3916,10 +3921,10 @@ ali_write_5_1(struct trident_state *state, const char __user *buf,
3916 i = i - (state->chans_num - other_dma_nums); 3921 i = i - (state->chans_num - other_dma_nums);
3917 for (; (i < other_dma_nums) && (cnt_for_multi_channel > 0); i++) { 3922 for (; (i < other_dma_nums) && (cnt_for_multi_channel > 0); i++) {
3918 dmabuf_temp = &state->other_states[i]->dmabuf; 3923 dmabuf_temp = &state->other_states[i]->dmabuf;
3919 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 3924 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr,
3920 buffer, sample_s)) 3925 buffer, sample_s))
3921 return -EFAULT; 3926 return -EFAULT;
3922 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 3927 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel,
3923 sample_s, *copy_count); 3928 sample_s, *copy_count);
3924 } 3929 }
3925 if (cnt_for_multi_channel == 0) 3930 if (cnt_for_multi_channel == 0)
@@ -3928,39 +3933,39 @@ ali_write_5_1(struct trident_state *state, const char __user *buf,
3928 if (cnt_for_multi_channel > 0) { 3933 if (cnt_for_multi_channel > 0) {
3929 loop = cnt_for_multi_channel / (state->chans_num * sample_s); 3934 loop = cnt_for_multi_channel / (state->chans_num * sample_s);
3930 for (i = 0; i < loop; i++) { 3935 for (i = 0; i < loop; i++) {
3931 if (copy_from_user(dmabuf->rawbuf + swptr, buffer, 3936 if (copy_from_user(dmabuf->rawbuf + swptr, buffer,
3932 sample_s * 2)) 3937 sample_s * 2))
3933 return -EFAULT; 3938 return -EFAULT;
3934 seek_offset(swptr, buffer, cnt_for_multi_channel, 3939 seek_offset(swptr, buffer, cnt_for_multi_channel,
3935 sample_s * 2, *copy_count); 3940 sample_s * 2, *copy_count);
3936 (*state_cnt) += (sample_s * 2); 3941 (*state_cnt) += (sample_s * 2);
3937 3942
3938 dmabuf_temp = &state->other_states[0]->dmabuf; 3943 dmabuf_temp = &state->other_states[0]->dmabuf;
3939 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 3944 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr,
3940 buffer, sample_s)) 3945 buffer, sample_s))
3941 return -EFAULT; 3946 return -EFAULT;
3942 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 3947 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel,
3943 sample_s, *copy_count); 3948 sample_s, *copy_count);
3944 3949
3945 dmabuf_temp = &state->other_states[1]->dmabuf; 3950 dmabuf_temp = &state->other_states[1]->dmabuf;
3946 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 3951 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr,
3947 buffer, sample_s)) 3952 buffer, sample_s))
3948 return -EFAULT; 3953 return -EFAULT;
3949 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 3954 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel,
3950 sample_s, *copy_count); 3955 sample_s, *copy_count);
3951 3956
3952 dmabuf_temp = &state->other_states[2]->dmabuf; 3957 dmabuf_temp = &state->other_states[2]->dmabuf;
3953 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 3958 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr,
3954 buffer, sample_s)) 3959 buffer, sample_s))
3955 return -EFAULT; 3960 return -EFAULT;
3956 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 3961 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel,
3957 sample_s, *copy_count); 3962 sample_s, *copy_count);
3958 3963
3959 dmabuf_temp = &state->other_states[3]->dmabuf; 3964 dmabuf_temp = &state->other_states[3]->dmabuf;
3960 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 3965 if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr,
3961 buffer, sample_s)) 3966 buffer, sample_s))
3962 return -EFAULT; 3967 return -EFAULT;
3963 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 3968 seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel,
3964 sample_s, *copy_count); 3969 sample_s, *copy_count);
3965 } 3970 }
3966 3971
@@ -3969,15 +3974,15 @@ ali_write_5_1(struct trident_state *state, const char __user *buf,
3969 3974
3970 if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s)) 3975 if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
3971 return -EFAULT; 3976 return -EFAULT;
3972 seek_offset(swptr, buffer, cnt_for_multi_channel, 3977 seek_offset(swptr, buffer, cnt_for_multi_channel,
3973 sample_s, *copy_count); 3978 sample_s, *copy_count);
3974 (*state_cnt) += sample_s; 3979 (*state_cnt) += sample_s;
3975 3980
3976 if (cnt_for_multi_channel > 0) { 3981 if (cnt_for_multi_channel > 0) {
3977 if (copy_from_user(dmabuf->rawbuf + swptr, 3982 if (copy_from_user(dmabuf->rawbuf + swptr,
3978 buffer, sample_s)) 3983 buffer, sample_s))
3979 return -EFAULT; 3984 return -EFAULT;
3980 seek_offset(swptr, buffer, cnt_for_multi_channel, 3985 seek_offset(swptr, buffer, cnt_for_multi_channel,
3981 sample_s, *copy_count); 3986 sample_s, *copy_count);
3982 (*state_cnt) += sample_s; 3987 (*state_cnt) += sample_s;
3983 3988
@@ -3986,12 +3991,12 @@ ali_write_5_1(struct trident_state *state, const char __user *buf,
3986 loop = state->multi_channels_adjust_count - diff; 3991 loop = state->multi_channels_adjust_count - diff;
3987 for (i = 0; i < loop; i++) { 3992 for (i = 0; i < loop; i++) {
3988 dmabuf_temp = &state->other_states[i]->dmabuf; 3993 dmabuf_temp = &state->other_states[i]->dmabuf;
3989 if (copy_from_user(dmabuf_temp->rawbuf + 3994 if (copy_from_user(dmabuf_temp->rawbuf +
3990 dmabuf_temp->swptr, 3995 dmabuf_temp->swptr,
3991 buffer, sample_s)) 3996 buffer, sample_s))
3992 return -EFAULT; 3997 return -EFAULT;
3993 seek_offset(dmabuf_temp->swptr, buffer, 3998 seek_offset(dmabuf_temp->swptr, buffer,
3994 cnt_for_multi_channel, 3999 cnt_for_multi_channel,
3995 sample_s, *copy_count); 4000 sample_s, *copy_count);
3996 } 4001 }
3997 } 4002 }
@@ -4048,11 +4053,11 @@ ali_write_proc(struct file *file, const char __user *buffer, unsigned long count
4048 ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL); 4053 ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
4049 break; 4054 break;
4050 case '1': 4055 case '1':
4051 ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 4056 ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT |
4052 ALI_SPDIF_OUT_PCM); 4057 ALI_SPDIF_OUT_PCM);
4053 break; 4058 break;
4054 case '2': 4059 case '2':
4055 ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 4060 ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT |
4056 ALI_SPDIF_OUT_NON_PCM); 4061 ALI_SPDIF_OUT_NON_PCM);
4057 break; 4062 break;
4058 case '3': 4063 case '3':
@@ -4077,7 +4082,7 @@ trident_open_mixdev(struct inode *inode, struct file *file)
4077 4082
4078 for (card = devs; card != NULL; card = card->next) 4083 for (card = devs; card != NULL; card = card->next)
4079 for (i = 0; i < NR_AC97; i++) 4084 for (i = 0; i < NR_AC97; i++)
4080 if (card->ac97_codec[i] != NULL && 4085 if (card->ac97_codec[i] != NULL &&
4081 card->ac97_codec[i]->dev_mixer == minor) 4086 card->ac97_codec[i]->dev_mixer == minor)
4082 goto match; 4087 goto match;
4083 4088
@@ -4091,7 +4096,7 @@ trident_open_mixdev(struct inode *inode, struct file *file)
4091} 4096}
4092 4097
4093static int 4098static int
4094trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd, 4099trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
4095 unsigned long arg) 4100 unsigned long arg)
4096{ 4101{
4097 struct ac97_codec *codec = (struct ac97_codec *) file->private_data; 4102 struct ac97_codec *codec = (struct ac97_codec *) file->private_data;
@@ -4185,9 +4190,9 @@ trident_ac97_init(struct trident_card *card)
4185 /* disable AC97 GPIO interrupt */ 4190 /* disable AC97 GPIO interrupt */
4186 outl(0x00, TRID_REG(card, SI_AC97_GPIO)); 4191 outl(0x00, TRID_REG(card, SI_AC97_GPIO));
4187 /* when power up the AC link is in cold reset mode so stop it */ 4192 /* when power up the AC link is in cold reset mode so stop it */
4188 outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT | SECONDARY_ID, 4193 outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT | SECONDARY_ID,
4189 TRID_REG(card, SI_SERIAL_INTF_CTRL)); 4194 TRID_REG(card, SI_SERIAL_INTF_CTRL));
4190 /* it take a long time to recover from a cold reset */ 4195 /* it take a long time to recover from a cold reset */
4191 /* (especially when you have more than one codec) */ 4196 /* (especially when you have more than one codec) */
4192 udelay(2000); 4197 udelay(2000);
4193 ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL)); 4198 ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
@@ -4207,9 +4212,9 @@ trident_ac97_init(struct trident_card *card)
4207 /* disable AC97 GPIO interrupt */ 4212 /* disable AC97 GPIO interrupt */
4208 outl(0x00, TRID_REG(card, SI_AC97_GPIO)); 4213 outl(0x00, TRID_REG(card, SI_AC97_GPIO));
4209 /* when power up, the AC link is in cold reset mode, so stop it */ 4214 /* when power up, the AC link is in cold reset mode, so stop it */
4210 outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT, 4215 outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT,
4211 TRID_REG(card, SI_SERIAL_INTF_CTRL)); 4216 TRID_REG(card, SI_SERIAL_INTF_CTRL));
4212 /* it take a long time to recover from a cold reset (especially */ 4217 /* it take a long time to recover from a cold reset (especially */
4213 /* when you have more than one codec) */ 4218 /* when you have more than one codec) */
4214 udelay(2000); 4219 udelay(2000);
4215 ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL)); 4220 ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
@@ -4221,7 +4226,7 @@ trident_ac97_init(struct trident_card *card)
4221 if ((codec = ac97_alloc_codec()) == NULL) 4226 if ((codec = ac97_alloc_codec()) == NULL)
4222 return -ENOMEM; 4227 return -ENOMEM;
4223 4228
4224 /* initialize some basic codec information, other fields */ 4229 /* initialize some basic codec information, other fields */
4225 /* will be filled in ac97_probe_codec */ 4230 /* will be filled in ac97_probe_codec */
4226 codec->private_data = card; 4231 codec->private_data = card;
4227 codec->id = num_ac97; 4232 codec->id = num_ac97;
@@ -4352,8 +4357,8 @@ static inline int trident_register_gameport(struct trident_card *card) { return
4352static inline void trident_unregister_gameport(struct trident_card *card) { } 4357static inline void trident_unregister_gameport(struct trident_card *card) { }
4353#endif /* SUPPORT_JOYSTICK */ 4358#endif /* SUPPORT_JOYSTICK */
4354 4359
4355/* install the driver, we do not allocate hardware channel nor DMA buffer */ 4360/* install the driver, we do not allocate hardware channel nor DMA buffer */
4356/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ 4361/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */
4357/* open/read/write/ioctl/mmap) */ 4362/* open/read/write/ioctl/mmap) */
4358static int __devinit 4363static int __devinit
4359trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) 4364trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
@@ -4376,9 +4381,9 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4376 else 4381 else
4377 dma_mask = TRIDENT_DMA_MASK; 4382 dma_mask = TRIDENT_DMA_MASK;
4378 if (pci_set_dma_mask(pci_dev, dma_mask)) { 4383 if (pci_set_dma_mask(pci_dev, dma_mask)) {
4379 printk(KERN_ERR "trident: architecture does not support" 4384 printk(KERN_ERR "trident: architecture does not support"
4380 " %s PCI busmaster DMA\n", 4385 " %s PCI busmaster DMA\n",
4381 pci_dev->device == PCI_DEVICE_ID_ALI_5451 ? 4386 pci_dev->device == PCI_DEVICE_ID_ALI_5451 ?
4382 "32-bit" : "30-bit"); 4387 "32-bit" : "30-bit");
4383 goto out; 4388 goto out;
4384 } 4389 }
@@ -4422,7 +4427,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4422 4427
4423 pci_set_master(pci_dev); 4428 pci_set_master(pci_dev);
4424 4429
4425 printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n", 4430 printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n",
4426 card_names[pci_id->driver_data], card->iobase, card->irq); 4431 card_names[pci_id->driver_data], card->iobase, card->irq);
4427 4432
4428 if (card->pci_id == PCI_DEVICE_ID_ALI_5451) { 4433 if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
@@ -4449,9 +4454,9 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4449 4454
4450 /* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */ 4455 /* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */
4451 card->hwvolctl = 0; 4456 card->hwvolctl = 0;
4452 pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL, 4457 pci_dev_m1533 = pci_get_device(PCI_VENDOR_ID_AL,
4453 PCI_DEVICE_ID_AL_M1533, 4458 PCI_DEVICE_ID_AL_M1533,
4454 pci_dev_m1533); 4459 pci_dev_m1533);
4455 rc = -ENODEV; 4460 rc = -ENODEV;
4456 if (pci_dev_m1533 == NULL) 4461 if (pci_dev_m1533 == NULL)
4457 goto out_proc_fs; 4462 goto out_proc_fs;
@@ -4465,6 +4470,8 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4465 bits &= 0xbf; /*clear bit 6 */ 4470 bits &= 0xbf; /*clear bit 6 */
4466 pci_write_config_byte(pci_dev_m1533, 0x7b, bits); 4471 pci_write_config_byte(pci_dev_m1533, 0x7b, bits);
4467 } 4472 }
4473 pci_dev_put(pci_dev_m1533);
4474
4468 } else if (card->pci_id == PCI_DEVICE_ID_INTERG_5050) { 4475 } else if (card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
4469 card->alloc_pcm_channel = cyber_alloc_pcm_channel; 4476 card->alloc_pcm_channel = cyber_alloc_pcm_channel;
4470 card->alloc_rec_pcm_channel = cyber_alloc_pcm_channel; 4477 card->alloc_rec_pcm_channel = cyber_alloc_pcm_channel;
@@ -4482,7 +4489,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4482 rc = -ENODEV; 4489 rc = -ENODEV;
4483 if (request_irq(card->irq, &trident_interrupt, IRQF_SHARED, 4490 if (request_irq(card->irq, &trident_interrupt, IRQF_SHARED,
4484 card_names[pci_id->driver_data], card)) { 4491 card_names[pci_id->driver_data], card)) {
4485 printk(KERN_ERR "trident: unable to allocate irq %d\n", 4492 printk(KERN_ERR "trident: unable to allocate irq %d\n",
4486 card->irq); 4493 card->irq);
4487 goto out_proc_fs; 4494 goto out_proc_fs;
4488 } 4495 }
@@ -4533,7 +4540,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
4533 printk(KERN_INFO "trident: Running on Alpha system " 4540 printk(KERN_INFO "trident: Running on Alpha system "
4534 "type Nautilus\n"); 4541 "type Nautilus\n");
4535 ac97_data = ali_ac97_get(card, 0, AC97_POWER_CONTROL); 4542 ac97_data = ali_ac97_get(card, 0, AC97_POWER_CONTROL);
4536 ali_ac97_set(card, 0, AC97_POWER_CONTROL, 4543 ali_ac97_set(card, 0, AC97_POWER_CONTROL,
4537 ac97_data | ALI_EAPD_POWER_DOWN); 4544 ac97_data | ALI_EAPD_POWER_DOWN);
4538 } 4545 }
4539 } 4546 }
@@ -4566,7 +4573,7 @@ out_proc_fs:
4566 devs = NULL; 4573 devs = NULL;
4567out_release_region: 4574out_release_region:
4568 release_region(iobase, 256); 4575 release_region(iobase, 256);
4569 return rc; 4576 return rc;
4570} 4577}
4571 4578
4572static void __devexit 4579static void __devexit
@@ -4634,8 +4641,8 @@ static struct pci_driver trident_pci_driver = {
4634static int __init 4641static int __init
4635trident_init_module(void) 4642trident_init_module(void)
4636{ 4643{
4637 printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro " 4644 printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro "
4638 "5050 PCI Audio, version " DRIVER_VERSION ", " __TIME__ " " 4645 "5050 PCI Audio, version " DRIVER_VERSION ", " __TIME__ " "
4639 __DATE__ "\n"); 4646 __DATE__ "\n");
4640 4647
4641 return pci_register_driver(&trident_pci_driver); 4648 return pci_register_driver(&trident_pci_driver);
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1bcfb3aac18..c6b44102aa5 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -33,6 +33,7 @@ config SND_ALS4000
33 select SND_OPL3_LIB 33 select SND_OPL3_LIB
34 select SND_MPU401_UART 34 select SND_MPU401_UART
35 select SND_PCM 35 select SND_PCM
36 select SND_SB_COMMON
36 help 37 help
37 Say Y here to include support for soundcards based on Avance Logic 38 Say Y here to include support for soundcards based on Avance Logic
38 ALS4000 chips. 39 ALS4000 chips.
@@ -215,6 +216,16 @@ config SND_CS46XX_NEW_DSP
215 216
216 This works better than the old code, so say Y. 217 This works better than the old code, so say Y.
217 218
219config SND_CS5530
220 tristate "CS5530 Audio"
221 depends on SND && ISA_DMA_API
222 select SND_SB16_DSP
223 help
224 Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips.
225
226 To compile this driver as a module, choose M here: the module
227 will be called snd-cs5530.
228
218config SND_CS5535AUDIO 229config SND_CS5535AUDIO
219 tristate "CS5535/CS5536 Audio" 230 tristate "CS5535/CS5536 Audio"
220 depends on SND && X86 && !X86_64 231 depends on SND && X86 && !X86_64
@@ -576,7 +587,7 @@ config SND_INTEL8X0M
576config SND_KORG1212 587config SND_KORG1212
577 tristate "Korg 1212 IO" 588 tristate "Korg 1212 IO"
578 depends on SND 589 depends on SND
579 select FW_LOADER 590 select FW_LOADER if !SND_KORG1212_FIRMWARE_IN_KERNEL
580 select SND_PCM 591 select SND_PCM
581 help 592 help
582 Say Y here to include support for Korg 1212IO soundcards. 593 Say Y here to include support for Korg 1212IO soundcards.
@@ -584,10 +595,19 @@ config SND_KORG1212
584 To compile this driver as a module, choose M here: the module 595 To compile this driver as a module, choose M here: the module
585 will be called snd-korg1212. 596 will be called snd-korg1212.
586 597
598config SND_KORG1212_FIRMWARE_IN_KERNEL
599 bool "In-kernel firmware for Korg1212 driver"
600 depends on SND_KORG1212
601 default y
602 help
603 Say Y here to include the static firmware built in the kernel
604 for the Korg1212 driver. If you choose N here, you need to
605 install the firmware files from the alsa-firmware package.
606
587config SND_MAESTRO3 607config SND_MAESTRO3
588 tristate "ESS Allegro/Maestro3" 608 tristate "ESS Allegro/Maestro3"
589 depends on SND 609 depends on SND
590 select FW_LOADER 610 select FW_LOADER if !SND_MAESTRO3_FIRMWARE_IN_KERNEL
591 select SND_AC97_CODEC 611 select SND_AC97_CODEC
592 help 612 help
593 Say Y here to include support for soundcards based on ESS Maestro 3 613 Say Y here to include support for soundcards based on ESS Maestro 3
@@ -596,6 +616,15 @@ config SND_MAESTRO3
596 To compile this driver as a module, choose M here: the module 616 To compile this driver as a module, choose M here: the module
597 will be called snd-maestro3. 617 will be called snd-maestro3.
598 618
619config SND_MAESTRO3_FIRMWARE_IN_KERNEL
620 bool "In-kernel firmware for Maestro3 driver"
621 depends on SND_MAESTRO3
622 default y
623 help
624 Say Y here to include the static firmware built in the kernel
625 for the Maestro3 driver. If you choose N here, you need to
626 install the firmware files from the alsa-firmware package.
627
599config SND_MIXART 628config SND_MIXART
600 tristate "Digigram miXart" 629 tristate "Digigram miXart"
601 depends on SND 630 depends on SND
@@ -737,7 +766,7 @@ config SND_VX222
737config SND_YMFPCI 766config SND_YMFPCI
738 tristate "Yamaha YMF724/740/744/754" 767 tristate "Yamaha YMF724/740/744/754"
739 depends on SND 768 depends on SND
740 select FW_LOADER 769 select FW_LOADER if !SND_YMFPCI_FIRMWARE_IN_KERNEL
741 select SND_OPL3_LIB 770 select SND_OPL3_LIB
742 select SND_MPU401_UART 771 select SND_MPU401_UART
743 select SND_AC97_CODEC 772 select SND_AC97_CODEC
@@ -748,6 +777,15 @@ config SND_YMFPCI
748 To compile this driver as a module, choose M here: the module 777 To compile this driver as a module, choose M here: the module
749 will be called snd-ymfpci. 778 will be called snd-ymfpci.
750 779
780config SND_YMFPCI_FIRMWARE_IN_KERNEL
781 bool "In-kernel firmware for YMFPCI driver"
782 depends on SND_YMFPCI
783 default y
784 help
785 Say Y here to include the static firmware built in the kernel
786 for the YMFPCI driver. If you choose N here, you need to
787 install the firmware files from the alsa-firmware package.
788
751config SND_AC97_POWER_SAVE 789config SND_AC97_POWER_SAVE
752 bool "AC97 Power-Saving Mode" 790 bool "AC97 Power-Saving Mode"
753 depends on SND_AC97_CODEC && EXPERIMENTAL 791 depends on SND_AC97_CODEC && EXPERIMENTAL
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index e06736da9ef..cd76e0293d0 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -12,6 +12,7 @@ snd-azt3328-objs := azt3328.o
12snd-bt87x-objs := bt87x.o 12snd-bt87x-objs := bt87x.o
13snd-cmipci-objs := cmipci.o 13snd-cmipci-objs := cmipci.o
14snd-cs4281-objs := cs4281.o 14snd-cs4281-objs := cs4281.o
15snd-cs5530-objs := cs5530.o
15snd-ens1370-objs := ens1370.o 16snd-ens1370-objs := ens1370.o
16snd-ens1371-objs := ens1371.o 17snd-ens1371-objs := ens1371.o
17snd-es1938-objs := es1938.o 18snd-es1938-objs := es1938.o
@@ -36,6 +37,7 @@ obj-$(CONFIG_SND_AZT3328) += snd-azt3328.o
36obj-$(CONFIG_SND_BT87X) += snd-bt87x.o 37obj-$(CONFIG_SND_BT87X) += snd-bt87x.o
37obj-$(CONFIG_SND_CMIPCI) += snd-cmipci.o 38obj-$(CONFIG_SND_CMIPCI) += snd-cmipci.o
38obj-$(CONFIG_SND_CS4281) += snd-cs4281.o 39obj-$(CONFIG_SND_CS4281) += snd-cs4281.o
40obj-$(CONFIG_SND_CS5530) += snd-cs5530.o
39obj-$(CONFIG_SND_ENS1370) += snd-ens1370.o 41obj-$(CONFIG_SND_ENS1370) += snd-ens1370.o
40obj-$(CONFIG_SND_ENS1371) += snd-ens1371.o 42obj-$(CONFIG_SND_ENS1371) += snd-ens1371.o
41obj-$(CONFIG_SND_ES1938) += snd-es1938.o 43obj-$(CONFIG_SND_ES1938) += snd-es1938.o
diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
index 3c3222122d8..f5d471896b9 100644
--- a/sound/pci/ac97/Makefile
+++ b/sound/pci/ac97/Makefile
@@ -3,7 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_patch.o 6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o
7 7
8ifneq ($(CONFIG_PROC_FS),) 8ifneq ($(CONFIG_PROC_FS),)
9snd-ac97-codec-objs += ac97_proc.o 9snd-ac97-codec-objs += ac97_proc.o
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index a9eec2a2357..bbed644bf9c 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -35,9 +35,9 @@
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include <sound/initval.h> 37#include <sound/initval.h>
38#include "ac97_local.h"
39#include "ac97_id.h" 38#include "ac97_id.h"
40#include "ac97_patch.h" 39
40#include "ac97_patch.c"
41 41
42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
43MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); 43MODULE_DESCRIPTION("Universal interface for Audio Codec '97");
@@ -432,7 +432,8 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
432 * Controls 432 * Controls
433 */ 433 */
434 434
435int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 435static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
436{ 437{
437 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 438 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
438 439
@@ -446,7 +447,8 @@ int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
446 return 0; 447 return 0;
447} 448}
448 449
449int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 450static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
450{ 452{
451 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 453 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
452 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 454 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -462,7 +464,8 @@ int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
462 return 0; 464 return 0;
463} 465}
464 466
465int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 467static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
466{ 469{
467 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 470 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
468 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 471 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -508,7 +511,8 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save)
508} 511}
509 512
510/* volume and switch controls */ 513/* volume and switch controls */
511int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 514static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
512{ 516{
513 int mask = (kcontrol->private_value >> 16) & 0xff; 517 int mask = (kcontrol->private_value >> 16) & 0xff;
514 int shift = (kcontrol->private_value >> 8) & 0x0f; 518 int shift = (kcontrol->private_value >> 8) & 0x0f;
@@ -521,7 +525,8 @@ int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
521 return 0; 525 return 0;
522} 526}
523 527
524int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 528static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
525{ 530{
526 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 531 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
527 int reg = kcontrol->private_value & 0xff; 532 int reg = kcontrol->private_value & 0xff;
@@ -544,7 +549,8 @@ int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
544 return 0; 549 return 0;
545} 550}
546 551
547int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 552static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
548{ 554{
549 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 555 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
550 int reg = kcontrol->private_value & 0xff; 556 int reg = kcontrol->private_value & 0xff;
@@ -646,7 +652,7 @@ AC97_ENUM("Mic Select", std_enum[3]),
646AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0) 652AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0)
647}; 653};
648 654
649const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { 655static const struct snd_kcontrol_new snd_ac97_controls_3d[2] = {
650AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0), 656AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0),
651AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0) 657AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0)
652}; 658};
@@ -817,7 +823,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
817 return change; 823 return change;
818} 824}
819 825
820const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { 826static const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = {
821 { 827 {
822 .access = SNDRV_CTL_ELEM_ACCESS_READ, 828 .access = SNDRV_CTL_ELEM_ACCESS_READ,
823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1083,7 +1089,7 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha
1083 unsigned short val; 1089 unsigned short val;
1084 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); 1090 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));
1085 /* Do the read twice due to buffers on some ac97 codecs. 1091 /* Do the read twice due to buffers on some ac97 codecs.
1086 * e.g. The STAC9704 returns exactly what you wrote the the register 1092 * e.g. The STAC9704 returns exactly what you wrote to the register
1087 * if you read it immediately. This causes the detect routine to fail. 1093 * if you read it immediately. This causes the detect routine to fail.
1088 */ 1094 */
1089 val = snd_ac97_read(ac97, reg); 1095 val = snd_ac97_read(ac97, reg);
@@ -1097,7 +1103,7 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha
1097 } 1103 }
1098} 1104}
1099 1105
1100int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) 1106static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit)
1101{ 1107{
1102 unsigned short mask, val, orig, res; 1108 unsigned short mask, val, orig, res;
1103 1109
@@ -1137,7 +1143,8 @@ static inline int printable(unsigned int x)
1137 return x; 1143 return x;
1138} 1144}
1139 1145
1140struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97) 1146static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
1147 struct snd_ac97 * ac97)
1141{ 1148{
1142 struct snd_kcontrol_new template; 1149 struct snd_kcontrol_new template;
1143 memcpy(&template, _template, sizeof(template)); 1150 memcpy(&template, _template, sizeof(template));
@@ -2544,7 +2551,8 @@ static void set_ctl_name(char *dst, const char *src, const char *suffix)
2544} 2551}
2545 2552
2546/* remove the control with the given name and optional suffix */ 2553/* remove the control with the given name and optional suffix */
2547int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix) 2554static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
2555 const char *suffix)
2548{ 2556{
2549 struct snd_ctl_elem_id id; 2557 struct snd_ctl_elem_id id;
2550 memset(&id, 0, sizeof(id)); 2558 memset(&id, 0, sizeof(id));
@@ -2563,7 +2571,8 @@ static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, co
2563} 2571}
2564 2572
2565/* rename the control with the given name and optional suffix */ 2573/* rename the control with the given name and optional suffix */
2566int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) 2574static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
2575 const char *dst, const char *suffix)
2567{ 2576{
2568 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); 2577 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix);
2569 if (kctl) { 2578 if (kctl) {
@@ -2574,14 +2583,16 @@ int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst,
2574} 2583}
2575 2584
2576/* rename both Volume and Switch controls - don't check the return value */ 2585/* rename both Volume and Switch controls - don't check the return value */
2577void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst) 2586static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
2587 const char *dst)
2578{ 2588{
2579 snd_ac97_rename_ctl(ac97, src, dst, "Switch"); 2589 snd_ac97_rename_ctl(ac97, src, dst, "Switch");
2580 snd_ac97_rename_ctl(ac97, src, dst, "Volume"); 2590 snd_ac97_rename_ctl(ac97, src, dst, "Volume");
2581} 2591}
2582 2592
2583/* swap controls */ 2593/* swap controls */
2584int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) 2594static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
2595 const char *s2, const char *suffix)
2585{ 2596{
2586 struct snd_kcontrol *kctl1, *kctl2; 2597 struct snd_kcontrol *kctl1, *kctl2;
2587 kctl1 = ctl_find(ac97, s1, suffix); 2598 kctl1 = ctl_find(ac97, s1, suffix);
diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h
index a6244c720a1..78745c5c6df 100644
--- a/sound/pci/ac97/ac97_local.h
+++ b/sound/pci/ac97/ac97_local.h
@@ -22,59 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) 25void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name,
26#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26)) 26 int modem);
27#define AC97_SINGLE(xname, reg, shift, mask, invert) \
28{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
29 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
30 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
31#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
32{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
35#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \
37 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
38 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
39
40/* enum control */
41struct ac97_enum {
42 unsigned char reg;
43 unsigned char shift_l;
44 unsigned char shift_r;
45 unsigned short mask;
46 const char **texts;
47};
48
49#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
50{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
51 .mask = xmask, .texts = xtexts }
52#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
53 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
54#define AC97_ENUM(xname, xenum) \
55{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_enum_double, \
56 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
57 .private_value = (unsigned long)&xenum }
58
59/* ac97_codec.c */
60extern const struct snd_kcontrol_new snd_ac97_controls_3d[];
61extern const struct snd_kcontrol_new snd_ac97_controls_spdif[];
62struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97);
63void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem);
64int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
65int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
66int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
67int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
68int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix);
69int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix);
70int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix);
71void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst);
72void snd_ac97_restore_status(struct snd_ac97 *ac97);
73void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
74int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
75int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
76int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
77
78int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, 27int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
79 unsigned short mask, unsigned short value); 28 unsigned short mask, unsigned short value);
80 29
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index b188a4df58c..581ebba4d1a 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -23,20 +23,8 @@
23 * 23 *
24 */ 24 */
25 25
26#include <sound/driver.h>
27#include <linux/delay.h>
28#include <linux/init.h>
29#include <linux/slab.h>
30#include <linux/mutex.h>
31
32#include <sound/core.h>
33#include <sound/pcm.h>
34#include <sound/control.h>
35#include <sound/tlv.h>
36#include <sound/ac97_codec.h>
37#include "ac97_patch.h"
38#include "ac97_id.h"
39#include "ac97_local.h" 26#include "ac97_local.h"
27#include "ac97_patch.h"
40 28
41/* 29/*
42 * Chip specific initialization 30 * Chip specific initialization
@@ -390,7 +378,7 @@ static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = {
390 .build_post_spdif = patch_yamaha_ymf753_post_spdif 378 .build_post_spdif = patch_yamaha_ymf753_post_spdif
391}; 379};
392 380
393int patch_yamaha_ymf753(struct snd_ac97 * ac97) 381static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
394{ 382{
395 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com. 383 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com.
396 This chip has nonstandard and extended behaviour with regard to its S/PDIF output. 384 This chip has nonstandard and extended behaviour with regard to its S/PDIF output.
@@ -436,7 +424,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9703_ops = {
436 .build_specific = patch_wolfson_wm9703_specific, 424 .build_specific = patch_wolfson_wm9703_specific,
437}; 425};
438 426
439int patch_wolfson03(struct snd_ac97 * ac97) 427static int patch_wolfson03(struct snd_ac97 * ac97)
440{ 428{
441 ac97->build_ops = &patch_wolfson_wm9703_ops; 429 ac97->build_ops = &patch_wolfson_wm9703_ops;
442 return 0; 430 return 0;
@@ -467,7 +455,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9704_ops = {
467 .build_specific = patch_wolfson_wm9704_specific, 455 .build_specific = patch_wolfson_wm9704_specific,
468}; 456};
469 457
470int patch_wolfson04(struct snd_ac97 * ac97) 458static int patch_wolfson04(struct snd_ac97 * ac97)
471{ 459{
472 /* WM9704M/9704Q */ 460 /* WM9704M/9704Q */
473 ac97->build_ops = &patch_wolfson_wm9704_ops; 461 ac97->build_ops = &patch_wolfson_wm9704_ops;
@@ -489,7 +477,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = {
489 .build_specific = patch_wolfson_wm9705_specific, 477 .build_specific = patch_wolfson_wm9705_specific,
490}; 478};
491 479
492int patch_wolfson05(struct snd_ac97 * ac97) 480static int patch_wolfson05(struct snd_ac97 * ac97)
493{ 481{
494 /* WM9705, WM9710 */ 482 /* WM9705, WM9710 */
495 ac97->build_ops = &patch_wolfson_wm9705_ops; 483 ac97->build_ops = &patch_wolfson_wm9705_ops;
@@ -625,7 +613,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9711_ops = {
625 .build_specific = patch_wolfson_wm9711_specific, 613 .build_specific = patch_wolfson_wm9711_specific,
626}; 614};
627 615
628int patch_wolfson11(struct snd_ac97 * ac97) 616static int patch_wolfson11(struct snd_ac97 * ac97)
629{ 617{
630 /* WM9711, WM9712 */ 618 /* WM9711, WM9712 */
631 ac97->build_ops = &patch_wolfson_wm9711_ops; 619 ac97->build_ops = &patch_wolfson_wm9711_ops;
@@ -824,7 +812,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9713_ops = {
824#endif 812#endif
825}; 813};
826 814
827int patch_wolfson13(struct snd_ac97 * ac97) 815static int patch_wolfson13(struct snd_ac97 * ac97)
828{ 816{
829 /* WM9713, WM9714 */ 817 /* WM9713, WM9714 */
830 ac97->build_ops = &patch_wolfson_wm9713_ops; 818 ac97->build_ops = &patch_wolfson_wm9713_ops;
@@ -844,7 +832,7 @@ int patch_wolfson13(struct snd_ac97 * ac97)
844/* 832/*
845 * Tritech codec 833 * Tritech codec
846 */ 834 */
847int patch_tritech_tr28028(struct snd_ac97 * ac97) 835static int patch_tritech_tr28028(struct snd_ac97 * ac97)
848{ 836{
849 snd_ac97_write_cache(ac97, 0x26, 0x0300); 837 snd_ac97_write_cache(ac97, 0x26, 0x0300);
850 snd_ac97_write_cache(ac97, 0x26, 0x0000); 838 snd_ac97_write_cache(ac97, 0x26, 0x0000);
@@ -922,7 +910,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = {
922 .build_specific = patch_sigmatel_stac97xx_specific 910 .build_specific = patch_sigmatel_stac97xx_specific
923}; 911};
924 912
925int patch_sigmatel_stac9700(struct snd_ac97 * ac97) 913static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
926{ 914{
927 ac97->build_ops = &patch_sigmatel_stac9700_ops; 915 ac97->build_ops = &patch_sigmatel_stac9700_ops;
928 return 0; 916 return 0;
@@ -969,7 +957,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = {
969 .build_specific = patch_sigmatel_stac9708_specific 957 .build_specific = patch_sigmatel_stac9708_specific
970}; 958};
971 959
972int patch_sigmatel_stac9708(struct snd_ac97 * ac97) 960static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
973{ 961{
974 unsigned int codec72, codec6c; 962 unsigned int codec72, codec6c;
975 963
@@ -995,7 +983,7 @@ int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
995 return 0; 983 return 0;
996} 984}
997 985
998int patch_sigmatel_stac9721(struct snd_ac97 * ac97) 986static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
999{ 987{
1000 ac97->build_ops = &patch_sigmatel_stac9700_ops; 988 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1001 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) { 989 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
@@ -1009,7 +997,7 @@ int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1009 return 0; 997 return 0;
1010} 998}
1011 999
1012int patch_sigmatel_stac9744(struct snd_ac97 * ac97) 1000static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1013{ 1001{
1014 // patch for SigmaTel 1002 // patch for SigmaTel
1015 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1003 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1021,7 +1009,7 @@ int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1021 return 0; 1009 return 0;
1022} 1010}
1023 1011
1024int patch_sigmatel_stac9756(struct snd_ac97 * ac97) 1012static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1025{ 1013{
1026 // patch for SigmaTel 1014 // patch for SigmaTel
1027 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1015 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1198,7 +1186,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = {
1198 .build_specific = patch_sigmatel_stac9758_specific 1186 .build_specific = patch_sigmatel_stac9758_specific
1199}; 1187};
1200 1188
1201int patch_sigmatel_stac9758(struct snd_ac97 * ac97) 1189static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1202{ 1190{
1203 static unsigned short regs[4] = { 1191 static unsigned short regs[4] = {
1204 AC97_SIGMATEL_OUTSEL, 1192 AC97_SIGMATEL_OUTSEL,
@@ -1272,7 +1260,7 @@ static struct snd_ac97_build_ops patch_cirrus_ops = {
1272 .build_spdif = patch_cirrus_build_spdif 1260 .build_spdif = patch_cirrus_build_spdif
1273}; 1261};
1274 1262
1275int patch_cirrus_spdif(struct snd_ac97 * ac97) 1263static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1276{ 1264{
1277 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers. 1265 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers.
1278 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh* 1266 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh*
@@ -1293,7 +1281,7 @@ int patch_cirrus_spdif(struct snd_ac97 * ac97)
1293 return 0; 1281 return 0;
1294} 1282}
1295 1283
1296int patch_cirrus_cs4299(struct snd_ac97 * ac97) 1284static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1297{ 1285{
1298 /* force the detection of PC Beep */ 1286 /* force the detection of PC Beep */
1299 ac97->flags |= AC97_HAS_PC_BEEP; 1287 ac97->flags |= AC97_HAS_PC_BEEP;
@@ -1329,7 +1317,7 @@ static struct snd_ac97_build_ops patch_conexant_ops = {
1329 .build_spdif = patch_conexant_build_spdif 1317 .build_spdif = patch_conexant_build_spdif
1330}; 1318};
1331 1319
1332int patch_conexant(struct snd_ac97 * ac97) 1320static int patch_conexant(struct snd_ac97 * ac97)
1333{ 1321{
1334 ac97->build_ops = &patch_conexant_ops; 1322 ac97->build_ops = &patch_conexant_ops;
1335 ac97->flags |= AC97_CX_SPDIF; 1323 ac97->flags |= AC97_CX_SPDIF;
@@ -1338,7 +1326,7 @@ int patch_conexant(struct snd_ac97 * ac97)
1338 return 0; 1326 return 0;
1339} 1327}
1340 1328
1341int patch_cx20551(struct snd_ac97 *ac97) 1329static int patch_cx20551(struct snd_ac97 *ac97)
1342{ 1330{
1343 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01); 1331 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1344 return 0; 1332 return 0;
@@ -1430,7 +1418,7 @@ static const struct snd_ac97_res_table ad1819_restbl[] = {
1430 { } /* terminator */ 1418 { } /* terminator */
1431}; 1419};
1432 1420
1433int patch_ad1819(struct snd_ac97 * ac97) 1421static int patch_ad1819(struct snd_ac97 * ac97)
1434{ 1422{
1435 unsigned short scfg; 1423 unsigned short scfg;
1436 1424
@@ -1507,7 +1495,7 @@ static struct snd_ac97_build_ops patch_ad1881_build_ops = {
1507#endif 1495#endif
1508}; 1496};
1509 1497
1510int patch_ad1881(struct snd_ac97 * ac97) 1498static int patch_ad1881(struct snd_ac97 * ac97)
1511{ 1499{
1512 static const char cfg_idxs[3][2] = { 1500 static const char cfg_idxs[3][2] = {
1513 {2, 1}, 1501 {2, 1},
@@ -1595,7 +1583,7 @@ static struct snd_ac97_build_ops patch_ad1885_build_ops = {
1595#endif 1583#endif
1596}; 1584};
1597 1585
1598int patch_ad1885(struct snd_ac97 * ac97) 1586static int patch_ad1885(struct snd_ac97 * ac97)
1599{ 1587{
1600 patch_ad1881(ac97); 1588 patch_ad1881(ac97);
1601 /* This is required to deal with the Intel D815EEAL2 */ 1589 /* This is required to deal with the Intel D815EEAL2 */
@@ -1622,7 +1610,7 @@ static struct snd_ac97_build_ops patch_ad1886_build_ops = {
1622#endif 1610#endif
1623}; 1611};
1624 1612
1625int patch_ad1886(struct snd_ac97 * ac97) 1613static int patch_ad1886(struct snd_ac97 * ac97)
1626{ 1614{
1627 patch_ad1881(ac97); 1615 patch_ad1881(ac97);
1628 /* Presario700 workaround */ 1616 /* Presario700 workaround */
@@ -1794,6 +1782,11 @@ static unsigned int ad1981_jacks_blacklist[] = {
1794 0x10140534, /* Thinkpad X31 */ 1782 0x10140534, /* Thinkpad X31 */
1795 0x10140537, /* Thinkpad T41p */ 1783 0x10140537, /* Thinkpad T41p */
1796 0x10140554, /* Thinkpad T42p/R50p */ 1784 0x10140554, /* Thinkpad T42p/R50p */
1785 0x10140567, /* Thinkpad T43p 2668-G7U */
1786 0x10140581, /* Thinkpad X41-2527 */
1787 0x104380b0, /* Asus A7V8X-MX */
1788 0x11790241, /* Toshiba Satellite A-15 S127 */
1789 0x144dc01a, /* Samsung NP-X20C004/SEG */
1797 0 /* end */ 1790 0 /* end */
1798}; 1791};
1799 1792
@@ -1844,7 +1837,7 @@ static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1844 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); 1837 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1845} 1838}
1846 1839
1847int patch_ad1981a(struct snd_ac97 *ac97) 1840static int patch_ad1981a(struct snd_ac97 *ac97)
1848{ 1841{
1849 patch_ad1881(ac97); 1842 patch_ad1881(ac97);
1850 ac97->build_ops = &patch_ad1981a_build_ops; 1843 ac97->build_ops = &patch_ad1981a_build_ops;
@@ -1877,7 +1870,7 @@ static struct snd_ac97_build_ops patch_ad1981b_build_ops = {
1877#endif 1870#endif
1878}; 1871};
1879 1872
1880int patch_ad1981b(struct snd_ac97 *ac97) 1873static int patch_ad1981b(struct snd_ac97 *ac97)
1881{ 1874{
1882 patch_ad1881(ac97); 1875 patch_ad1881(ac97);
1883 ac97->build_ops = &patch_ad1981b_build_ops; 1876 ac97->build_ops = &patch_ad1981b_build_ops;
@@ -2014,7 +2007,7 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = {
2014 .update_jacks = ad1888_update_jacks, 2007 .update_jacks = ad1888_update_jacks,
2015}; 2008};
2016 2009
2017int patch_ad1888(struct snd_ac97 * ac97) 2010static int patch_ad1888(struct snd_ac97 * ac97)
2018{ 2011{
2019 unsigned short misc; 2012 unsigned short misc;
2020 2013
@@ -2052,7 +2045,7 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = {
2052 .update_jacks = ad1888_update_jacks, 2045 .update_jacks = ad1888_update_jacks,
2053}; 2046};
2054 2047
2055int patch_ad1980(struct snd_ac97 * ac97) 2048static int patch_ad1980(struct snd_ac97 * ac97)
2056{ 2049{
2057 patch_ad1888(ac97); 2050 patch_ad1888(ac97);
2058 ac97->build_ops = &patch_ad1980_build_ops; 2051 ac97->build_ops = &patch_ad1980_build_ops;
@@ -2168,7 +2161,7 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = {
2168 .update_jacks = ad1985_update_jacks, 2161 .update_jacks = ad1985_update_jacks,
2169}; 2162};
2170 2163
2171int patch_ad1985(struct snd_ac97 * ac97) 2164static int patch_ad1985(struct snd_ac97 * ac97)
2172{ 2165{
2173 unsigned short misc; 2166 unsigned short misc;
2174 2167
@@ -2468,7 +2461,7 @@ static struct snd_ac97_build_ops patch_ad1986_build_ops = {
2468 .update_jacks = ad1986_update_jacks, 2461 .update_jacks = ad1986_update_jacks,
2469}; 2462};
2470 2463
2471int patch_ad1986(struct snd_ac97 * ac97) 2464static int patch_ad1986(struct snd_ac97 * ac97)
2472{ 2465{
2473 patch_ad1881(ac97); 2466 patch_ad1881(ac97);
2474 ac97->build_ops = &patch_ad1986_build_ops; 2467 ac97->build_ops = &patch_ad1986_build_ops;
@@ -2561,7 +2554,7 @@ static struct snd_ac97_build_ops patch_alc650_ops = {
2561 .update_jacks = alc650_update_jacks 2554 .update_jacks = alc650_update_jacks
2562}; 2555};
2563 2556
2564int patch_alc650(struct snd_ac97 * ac97) 2557static int patch_alc650(struct snd_ac97 * ac97)
2565{ 2558{
2566 unsigned short val; 2559 unsigned short val;
2567 2560
@@ -2713,7 +2706,7 @@ static struct snd_ac97_build_ops patch_alc655_ops = {
2713 .update_jacks = alc655_update_jacks 2706 .update_jacks = alc655_update_jacks
2714}; 2707};
2715 2708
2716int patch_alc655(struct snd_ac97 * ac97) 2709static int patch_alc655(struct snd_ac97 * ac97)
2717{ 2710{
2718 unsigned int val; 2711 unsigned int val;
2719 2712
@@ -2739,6 +2732,7 @@ int patch_alc655(struct snd_ac97 * ac97)
2739 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */ 2732 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2740 ac97->subsystem_device == 0x0161 || /* LG K1 Express */ 2733 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2741 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */ 2734 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2735 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2742 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */ 2736 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2743 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2737 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2744 else 2738 else
@@ -2815,7 +2809,7 @@ static struct snd_ac97_build_ops patch_alc850_ops = {
2815 .update_jacks = alc850_update_jacks 2809 .update_jacks = alc850_update_jacks
2816}; 2810};
2817 2811
2818int patch_alc850(struct snd_ac97 *ac97) 2812static int patch_alc850(struct snd_ac97 *ac97)
2819{ 2813{
2820 ac97->build_ops = &patch_alc850_ops; 2814 ac97->build_ops = &patch_alc850_ops;
2821 2815
@@ -2875,7 +2869,7 @@ static struct snd_ac97_build_ops patch_cm9738_ops = {
2875 .update_jacks = cm9738_update_jacks 2869 .update_jacks = cm9738_update_jacks
2876}; 2870};
2877 2871
2878int patch_cm9738(struct snd_ac97 * ac97) 2872static int patch_cm9738(struct snd_ac97 * ac97)
2879{ 2873{
2880 ac97->build_ops = &patch_cm9738_ops; 2874 ac97->build_ops = &patch_cm9738_ops;
2881 /* FIXME: can anyone confirm below? */ 2875 /* FIXME: can anyone confirm below? */
@@ -2967,7 +2961,7 @@ static struct snd_ac97_build_ops patch_cm9739_ops = {
2967 .update_jacks = cm9739_update_jacks 2961 .update_jacks = cm9739_update_jacks
2968}; 2962};
2969 2963
2970int patch_cm9739(struct snd_ac97 * ac97) 2964static int patch_cm9739(struct snd_ac97 * ac97)
2971{ 2965{
2972 unsigned short val; 2966 unsigned short val;
2973 2967
@@ -3141,7 +3135,7 @@ static struct snd_ac97_build_ops patch_cm9761_ops = {
3141 .update_jacks = cm9761_update_jacks 3135 .update_jacks = cm9761_update_jacks
3142}; 3136};
3143 3137
3144int patch_cm9761(struct snd_ac97 *ac97) 3138static int patch_cm9761(struct snd_ac97 *ac97)
3145{ 3139{
3146 unsigned short val; 3140 unsigned short val;
3147 3141
@@ -3236,7 +3230,7 @@ static struct snd_ac97_build_ops patch_cm9780_ops = {
3236 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ 3230 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
3237}; 3231};
3238 3232
3239int patch_cm9780(struct snd_ac97 *ac97) 3233static int patch_cm9780(struct snd_ac97 *ac97)
3240{ 3234{
3241 unsigned short val; 3235 unsigned short val;
3242 3236
@@ -3279,7 +3273,7 @@ static struct snd_ac97_build_ops patch_vt1616_ops = {
3279 .build_specific = patch_vt1616_specific 3273 .build_specific = patch_vt1616_specific
3280}; 3274};
3281 3275
3282int patch_vt1616(struct snd_ac97 * ac97) 3276static int patch_vt1616(struct snd_ac97 * ac97)
3283{ 3277{
3284 ac97->build_ops = &patch_vt1616_ops; 3278 ac97->build_ops = &patch_vt1616_ops;
3285 return 0; 3279 return 0;
@@ -3288,16 +3282,111 @@ int patch_vt1616(struct snd_ac97 * ac97)
3288/* 3282/*
3289 * VT1617A codec 3283 * VT1617A codec
3290 */ 3284 */
3285
3286/*
3287 * unfortunately, the vt1617a stashes the twiddlers required for
3288 * nooding the i/o jacks on 2 different regs. * thameans that we cant
3289 * use the easy way provided by AC97_ENUM_DOUBLE() we have to write
3290 * are own funcs.
3291 *
3292 * NB: this is absolutely and utterly different from the vt1618. dunno
3293 * about the 1616.
3294 */
3295
3296/* copied from ac97_surround_jack_mode_info() */
3297static int snd_ac97_vt1617a_smart51_info(struct snd_kcontrol *kcontrol,
3298 struct snd_ctl_elem_info *uinfo)
3299{
3300 /* ordering in this list reflects vt1617a docs for Reg 20 and
3301 * 7a and Table 6 that lays out the matrix NB WRT Table6: SM51
3302 * is SM51EN *AND* it's Bit14, not Bit15 so the table is very
3303 * counter-intuitive */
3304
3305 static const char* texts[] = { "LineIn Mic1", "LineIn Mic1 Mic3",
3306 "Surr LFE/C Mic3", "LineIn LFE/C Mic3",
3307 "LineIn Mic2", "LineIn Mic2 Mic1",
3308 "Surr LFE Mic1", "Surr LFE Mic1 Mic2"};
3309 return ac97_enum_text_info(kcontrol, uinfo, texts, 8);
3310}
3311
3312static int snd_ac97_vt1617a_smart51_get(struct snd_kcontrol *kcontrol,
3313 struct snd_ctl_elem_value *ucontrol)
3314{
3315 ushort usSM51, usMS;
3316
3317 struct snd_ac97 *pac97;
3318
3319 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3320
3321 /* grab our desirec bits, then mash them together in a manner
3322 * consistent with Table 6 on page 17 in the 1617a docs */
3323
3324 usSM51 = snd_ac97_read(pac97, 0x7a) >> 14;
3325 usMS = snd_ac97_read(pac97, 0x20) >> 8;
3326
3327 ucontrol->value.enumerated.item[0] = (usSM51 << 1) + usMS;
3328
3329 return 0;
3330}
3331
3332static int snd_ac97_vt1617a_smart51_put(struct snd_kcontrol *kcontrol,
3333 struct snd_ctl_elem_value *ucontrol)
3334{
3335 ushort usSM51, usMS, usReg;
3336
3337 struct snd_ac97 *pac97;
3338
3339 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3340
3341 usSM51 = ucontrol->value.enumerated.item[0] >> 1;
3342 usMS = ucontrol->value.enumerated.item[0] & 1;
3343
3344 /* push our values into the register - consider that things will be left
3345 * in a funky state if the write fails */
3346
3347 usReg = snd_ac97_read(pac97, 0x7a);
3348 snd_ac97_write_cache(pac97, 0x7a, (usReg & 0x3FFF) + (usSM51 << 14));
3349 usReg = snd_ac97_read(pac97, 0x20);
3350 snd_ac97_write_cache(pac97, 0x20, (usReg & 0xFEFF) + (usMS << 8));
3351
3352 return 0;
3353}
3354
3355static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3356
3357 AC97_SINGLE("Center/LFE Exchange", 0x5a, 8, 1, 0),
3358 /*
3359 * These are used to enable/disable surround sound on motherboards
3360 * that have 3 bidirectional analog jacks
3361 */
3362 {
3363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3364 .name = "Smart 5.1 Select",
3365 .info = snd_ac97_vt1617a_smart51_info,
3366 .get = snd_ac97_vt1617a_smart51_get,
3367 .put = snd_ac97_vt1617a_smart51_put,
3368 },
3369};
3370
3291int patch_vt1617a(struct snd_ac97 * ac97) 3371int patch_vt1617a(struct snd_ac97 * ac97)
3292{ 3372{
3293 /* bring analog power consumption to normal, like WinXP driver 3373 int err = 0;
3294 * for EPIA SP 3374
3375 /* we choose to not fail out at this point, but we tell the
3376 caller when we return */
3377
3378 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3379 ARRAY_SIZE(snd_ac97_controls_vt1617a));
3380
3381 /* bring analog power consumption to normal by turning off the
3382 * headphone amplifier, like WinXP driver for EPIA SP
3295 */ 3383 */
3296 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3384 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3297 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3385 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3298 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 3386 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3299 ac97->build_ops = &patch_vt1616_ops; 3387 ac97->build_ops = &patch_vt1616_ops;
3300 return 0; 3388
3389 return err;
3301} 3390}
3302 3391
3303/* 3392/*
@@ -3338,7 +3427,7 @@ static struct snd_ac97_build_ops patch_it2646_ops = {
3338 .update_jacks = it2646_update_jacks 3427 .update_jacks = it2646_update_jacks
3339}; 3428};
3340 3429
3341int patch_it2646(struct snd_ac97 * ac97) 3430static int patch_it2646(struct snd_ac97 * ac97)
3342{ 3431{
3343 ac97->build_ops = &patch_it2646_ops; 3432 ac97->build_ops = &patch_it2646_ops;
3344 /* full DAC volume */ 3433 /* full DAC volume */
@@ -3371,7 +3460,7 @@ static struct snd_ac97_build_ops patch_si3036_ops = {
3371 .build_specific = patch_si3036_specific, 3460 .build_specific = patch_si3036_specific,
3372}; 3461};
3373 3462
3374int mpatch_si3036(struct snd_ac97 * ac97) 3463static int mpatch_si3036(struct snd_ac97 * ac97)
3375{ 3464{
3376 ac97->build_ops = &patch_si3036_ops; 3465 ac97->build_ops = &patch_si3036_ops;
3377 snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); 3466 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
@@ -3403,7 +3492,7 @@ static struct snd_ac97_res_table lm4550_restbl[] = {
3403 { } /* terminator */ 3492 { } /* terminator */
3404}; 3493};
3405 3494
3406int patch_lm4550(struct snd_ac97 *ac97) 3495static int patch_lm4550(struct snd_ac97 *ac97)
3407{ 3496{
3408 ac97->res_table = lm4550_restbl; 3497 ac97->res_table = lm4550_restbl;
3409 return 0; 3498 return 0;
@@ -3438,7 +3527,7 @@ static struct snd_ac97_build_ops patch_ucb1400_ops = {
3438 .build_specific = patch_ucb1400_specific, 3527 .build_specific = patch_ucb1400_specific,
3439}; 3528};
3440 3529
3441int patch_ucb1400(struct snd_ac97 * ac97) 3530static int patch_ucb1400(struct snd_ac97 * ac97)
3442{ 3531{
3443 ac97->build_ops = &patch_ucb1400_ops; 3532 ac97->build_ops = &patch_ucb1400_ops;
3444 /* enable headphone driver and smart low power mode by default */ 3533 /* enable headphone driver and smart low power mode by default */
diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h
index 555d1c9a98f..fd341ce6376 100644
--- a/sound/pci/ac97/ac97_patch.h
+++ b/sound/pci/ac97/ac97_patch.h
@@ -22,44 +22,72 @@
22 * 22 *
23 */ 23 */
24 24
25int patch_yamaha_ymf753(struct snd_ac97 * ac97); 25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
26int patch_wolfson00(struct snd_ac97 * ac97); 26 ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
27int patch_wolfson03(struct snd_ac97 * ac97); 27 ((invert) << 24))
28int patch_wolfson04(struct snd_ac97 * ac97); 28#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
29int patch_wolfson05(struct snd_ac97 * ac97); 29 (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
30int patch_wolfson11(struct snd_ac97 * ac97); 30#define AC97_SINGLE(xname, reg, shift, mask, invert) \
31int patch_wolfson13(struct snd_ac97 * ac97); 31{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32int patch_tritech_tr28028(struct snd_ac97 * ac97); 32 .info = snd_ac97_info_volsw, \
33int patch_sigmatel_stac9700(struct snd_ac97 * ac97); 33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34int patch_sigmatel_stac9708(struct snd_ac97 * ac97); 34 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
35int patch_sigmatel_stac9721(struct snd_ac97 * ac97); 35#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
36int patch_sigmatel_stac9744(struct snd_ac97 * ac97); 36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
37int patch_sigmatel_stac9756(struct snd_ac97 * ac97); 37 .info = snd_ac97_info_volsw, \
38int patch_sigmatel_stac9758(struct snd_ac97 * ac97); 38 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
39int patch_cirrus_cs4299(struct snd_ac97 * ac97); 39 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
40int patch_cirrus_spdif(struct snd_ac97 * ac97); 40#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
41int patch_conexant(struct snd_ac97 * ac97); 41{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
42int patch_cx20551(struct snd_ac97 * ac97); 42 .info = snd_ac97_info_volsw, \
43int patch_ad1819(struct snd_ac97 * ac97); 43 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
44int patch_ad1881(struct snd_ac97 * ac97); 44 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
45int patch_ad1885(struct snd_ac97 * ac97); 45
46int patch_ad1886(struct snd_ac97 * ac97); 46/* enum control */
47int patch_ad1888(struct snd_ac97 * ac97); 47struct ac97_enum {
48int patch_ad1980(struct snd_ac97 * ac97); 48 unsigned char reg;
49int patch_ad1981a(struct snd_ac97 * ac97); 49 unsigned char shift_l;
50int patch_ad1981b(struct snd_ac97 * ac97); 50 unsigned char shift_r;
51int patch_ad1985(struct snd_ac97 * ac97); 51 unsigned short mask;
52int patch_ad1986(struct snd_ac97 * ac97); 52 const char **texts;
53int patch_alc650(struct snd_ac97 * ac97); 53};
54int patch_alc655(struct snd_ac97 * ac97); 54
55int patch_alc850(struct snd_ac97 * ac97); 55#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
56int patch_cm9738(struct snd_ac97 * ac97); 56{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
57int patch_cm9739(struct snd_ac97 * ac97); 57 .mask = xmask, .texts = xtexts }
58int patch_cm9761(struct snd_ac97 * ac97); 58#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
59int patch_cm9780(struct snd_ac97 * ac97); 59 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
60int patch_vt1616(struct snd_ac97 * ac97); 60#define AC97_ENUM(xname, xenum) \
61int patch_vt1617a(struct snd_ac97 * ac97); 61{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
62int patch_it2646(struct snd_ac97 * ac97); 62 .info = snd_ac97_info_enum_double, \
63int patch_ucb1400(struct snd_ac97 * ac97); 63 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
64int mpatch_si3036(struct snd_ac97 * ac97); 64 .private_value = (unsigned long)&xenum }
65int patch_lm4550(struct snd_ac97 * ac97); 65
66/* ac97_codec.c */
67static const struct snd_kcontrol_new snd_ac97_controls_3d[];
68static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
69static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
70 struct snd_ac97 * ac97);
71static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
72 struct snd_ctl_elem_info *uinfo);
73static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_elem_value *ucontrol);
75static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
76 struct snd_ctl_elem_value *ucontrol);
77static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
78static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
79 const char *suffix);
80static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
81 const char *dst, const char *suffix);
82static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
83 const char *s2, const char *suffix);
84static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
85 const char *dst);
86static void snd_ac97_restore_status(struct snd_ac97 *ac97);
87static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
88static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
89 struct snd_ctl_elem_info *uinfo);
90static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
91 struct snd_ctl_elem_value *ucontrol);
92static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
93 struct snd_ctl_elem_value *ucontrol);
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index 3758d07182f..4281e6d0c5b 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -34,7 +34,6 @@
34#include <sound/control.h> 34#include <sound/control.h>
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include "ac97_patch.h"
38#include "ac97_id.h" 37#include "ac97_id.h"
39#include "ac97_local.h" 38#include "ac97_local.h"
40 39
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index ba7fa22b285..05b4c869694 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -69,10 +69,10 @@ module_param(enable, bool, 0444);
69 * Debug part definitions 69 * Debug part definitions
70 */ 70 */
71 71
72//#define ALI_DEBUG 72/* #define ALI_DEBUG */
73 73
74#ifdef ALI_DEBUG 74#ifdef ALI_DEBUG
75#define snd_ali_printk(format, args...) printk(format, ##args); 75#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
76#else 76#else
77#define snd_ali_printk(format, args...) 77#define snd_ali_printk(format, args...)
78#endif 78#endif
@@ -105,10 +105,10 @@ module_param(enable, bool, 0444);
105 * Direct Registers 105 * Direct Registers
106 */ 106 */
107 107
108#define ALI_LEGACY_DMAR0 0x00 // ADR0 108#define ALI_LEGACY_DMAR0 0x00 /* ADR0 */
109#define ALI_LEGACY_DMAR4 0x04 // CNT0 109#define ALI_LEGACY_DMAR4 0x04 /* CNT0 */
110#define ALI_LEGACY_DMAR11 0x0b // MOD 110#define ALI_LEGACY_DMAR11 0x0b /* MOD */
111#define ALI_LEGACY_DMAR15 0x0f // MMR 111#define ALI_LEGACY_DMAR15 0x0f /* MMR */
112#define ALI_MPUR0 0x20 112#define ALI_MPUR0 0x20
113#define ALI_MPUR1 0x21 113#define ALI_MPUR1 0x21
114#define ALI_MPUR2 0x22 114#define ALI_MPUR2 0x22
@@ -175,7 +175,7 @@ struct snd_ali;
175struct snd_ali_voice; 175struct snd_ali_voice;
176 176
177struct snd_ali_channel_control { 177struct snd_ali_channel_control {
178 // register data 178 /* register data */
179 struct REGDATA { 179 struct REGDATA {
180 unsigned int start; 180 unsigned int start;
181 unsigned int stop; 181 unsigned int stop;
@@ -183,7 +183,7 @@ struct snd_ali_channel_control {
183 unsigned int ainten; 183 unsigned int ainten;
184 } data; 184 } data;
185 185
186 // register addresses 186 /* register addresses */
187 struct REGS { 187 struct REGS {
188 unsigned int start; 188 unsigned int start;
189 unsigned int stop; 189 unsigned int stop;
@@ -197,19 +197,18 @@ struct snd_ali_channel_control {
197 197
198struct snd_ali_voice { 198struct snd_ali_voice {
199 unsigned int number; 199 unsigned int number;
200 unsigned int use: 1, 200 unsigned int use :1,
201 pcm: 1, 201 pcm :1,
202 midi: 1, 202 midi :1,
203 mode: 1, 203 mode :1,
204 synth: 1; 204 synth :1,
205 running :1;
205 206
206 /* PCM data */ 207 /* PCM data */
207 struct snd_ali *codec; 208 struct snd_ali *codec;
208 struct snd_pcm_substream *substream; 209 struct snd_pcm_substream *substream;
209 struct snd_ali_voice *extra; 210 struct snd_ali_voice *extra;
210 211
211 unsigned int running: 1;
212
213 int eso; /* final ESO value for channel */ 212 int eso; /* final ESO value for channel */
214 int count; /* runtime->period_size */ 213 int count; /* runtime->period_size */
215 214
@@ -231,23 +230,21 @@ struct snd_alidev {
231}; 230};
232 231
233 232
234#ifdef CONFIG_PM
235#define ALI_GLOBAL_REGS 56 233#define ALI_GLOBAL_REGS 56
236#define ALI_CHANNEL_REGS 8 234#define ALI_CHANNEL_REGS 8
237struct snd_ali_image { 235struct snd_ali_image {
238 unsigned long regs[ALI_GLOBAL_REGS]; 236 u32 regs[ALI_GLOBAL_REGS];
239 unsigned long channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS]; 237 u32 channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS];
240}; 238};
241#endif
242 239
243 240
244struct snd_ali { 241struct snd_ali {
245 unsigned long irq; 242 int irq;
246 unsigned long port; 243 unsigned long port;
247 unsigned char revision; 244 unsigned char revision;
248 245
249 unsigned int hw_initialized: 1; 246 unsigned int hw_initialized :1;
250 unsigned int spdif_support: 1; 247 unsigned int spdif_support :1;
251 248
252 struct pci_dev *pci; 249 struct pci_dev *pci;
253 struct pci_dev *pci_m1533; 250 struct pci_dev *pci_m1533;
@@ -287,108 +284,28 @@ MODULE_DEVICE_TABLE(pci, snd_ali_ids);
287 284
288static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int); 285static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int);
289static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short); 286static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short);
290static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short, unsigned short); 287static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short,
291 288 unsigned short);
292/*
293 * Debug Part
294 */
295
296#ifdef ALI_DEBUG
297
298static void ali_read_regs(struct snd_ali *codec, int channel)
299{
300 int i,j;
301 unsigned int dwVal;
302
303 printk("channel %d registers map:\n", channel);
304 outb((unsigned char)(channel & 0x001f), ALI_REG(codec,ALI_GC_CIR));
305
306 printk(" ");
307 for(j=0;j<8;j++)
308 printk("%2.2x ", j*4);
309 printk("\n");
310
311 for (i=0; i<=0xf8/4;i++) {
312 if(i%8 == 0)
313 printk("%2.2x ", (i*4/0x10)*0x10);
314 dwVal = inl(ALI_REG(codec,i*4));
315 printk("%8.8x ", dwVal);
316 if ((i+1)%8 == 0)
317 printk("\n");
318 }
319 printk("\n");
320}
321static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
322{
323 unsigned int dwVal;
324 struct pci_dev *pci_dev;
325 int i,j;
326
327 pci_dev = pci_get_device(vendor, deviceid, NULL);
328 if (pci_dev == NULL)
329 return ;
330
331 printk("\nM%x PCI CFG\n", deviceid);
332 printk(" ");
333 for(j=0;j<8;j++)
334 printk("%d ",j);
335 printk("\n");
336
337 for(i=0;i<8;i++) {
338 printk("%d ",i);
339 for(j=0;j<8;j++)
340 {
341 pci_read_config_dword(pci_dev, i*0x20+j*4, &dwVal);
342 printk("%8.8x ", dwVal);
343 }
344 printk("\n");
345 }
346 pci_dev_put(pci_dev);
347 }
348static void ali_read_ac97regs(struct snd_ali *codec, int secondary)
349{
350 unsigned short i,j;
351 unsigned short wVal;
352
353 printk("\ncodec %d registers map:\n", secondary);
354
355 printk(" ");
356 for(j=0;j<8;j++)
357 printk("%2.2x ",j*2);
358 printk("\n");
359
360 for (i=0; i<64;i++) {
361 if(i%8 == 0)
362 printk("%2.2x ", (i/8)*0x10);
363 wVal = snd_ali_codec_peek(codec, secondary, i*2);
364 printk("%4.4x ", wVal);
365 if ((i+1)%8 == 0)
366 printk("\n");
367 }
368 printk("\n");
369}
370
371#endif
372 289
373/* 290/*
374 * AC97 ACCESS 291 * AC97 ACCESS
375 */ 292 */
376 293
377static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec, 294static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec,
378 unsigned int port ) 295 unsigned int port)
379{ 296{
380 return (unsigned int)inl(ALI_REG(codec, port)); 297 return (unsigned int)inl(ALI_REG(codec, port));
381} 298}
382 299
383static inline void snd_ali_5451_poke( struct snd_ali *codec, 300static inline void snd_ali_5451_poke(struct snd_ali *codec,
384 unsigned int port, 301 unsigned int port,
385 unsigned int val ) 302 unsigned int val)
386{ 303{
387 outl((unsigned int)val, ALI_REG(codec, port)); 304 outl((unsigned int)val, ALI_REG(codec, port));
388} 305}
389 306
390static int snd_ali_codec_ready( struct snd_ali *codec, 307static int snd_ali_codec_ready(struct snd_ali *codec,
391 unsigned int port ) 308 unsigned int port)
392{ 309{
393 unsigned long end_time; 310 unsigned long end_time;
394 unsigned int res; 311 unsigned int res;
@@ -396,7 +313,7 @@ static int snd_ali_codec_ready( struct snd_ali *codec,
396 end_time = jiffies + msecs_to_jiffies(250); 313 end_time = jiffies + msecs_to_jiffies(250);
397 do { 314 do {
398 res = snd_ali_5451_peek(codec,port); 315 res = snd_ali_5451_peek(codec,port);
399 if (! (res & 0x8000)) 316 if (!(res & 0x8000))
400 return 0; 317 return 0;
401 schedule_timeout_uninterruptible(1); 318 schedule_timeout_uninterruptible(1);
402 } while (time_after_eq(end_time, jiffies)); 319 } while (time_after_eq(end_time, jiffies));
@@ -425,11 +342,11 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
425} 342}
426 343
427static void snd_ali_codec_poke(struct snd_ali *codec,int secondary, 344static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
428 unsigned short reg, 345 unsigned short reg,
429 unsigned short val) 346 unsigned short val)
430{ 347{
431 unsigned int dwVal = 0; 348 unsigned int dwVal;
432 unsigned int port = 0; 349 unsigned int port;
433 350
434 if (reg >= 0x80) { 351 if (reg >= 0x80) {
435 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg); 352 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
@@ -445,20 +362,22 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
445 362
446 dwVal = (unsigned int) (reg & 0xff); 363 dwVal = (unsigned int) (reg & 0xff);
447 dwVal |= 0x8000 | (val << 16); 364 dwVal |= 0x8000 | (val << 16);
448 if (secondary) dwVal |= 0x0080; 365 if (secondary)
449 if (codec->revision == ALI_5451_V02) dwVal |= 0x0100; 366 dwVal |= 0x0080;
367 if (codec->revision == ALI_5451_V02)
368 dwVal |= 0x0100;
450 369
451 snd_ali_5451_poke(codec,port,dwVal); 370 snd_ali_5451_poke(codec, port, dwVal);
452 371
453 return ; 372 return ;
454} 373}
455 374
456static unsigned short snd_ali_codec_peek( struct snd_ali *codec, 375static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
457 int secondary, 376 int secondary,
458 unsigned short reg) 377 unsigned short reg)
459{ 378{
460 unsigned int dwVal = 0; 379 unsigned int dwVal;
461 unsigned int port = 0; 380 unsigned int port;
462 381
463 if (reg >= 0x80) { 382 if (reg >= 0x80) {
464 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg); 383 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
@@ -474,7 +393,8 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
474 393
475 dwVal = (unsigned int) (reg & 0xff); 394 dwVal = (unsigned int) (reg & 0xff);
476 dwVal |= 0x8000; /* bit 15*/ 395 dwVal |= 0x8000; /* bit 15*/
477 if (secondary) dwVal |= 0x0080; 396 if (secondary)
397 dwVal |= 0x0080;
478 398
479 snd_ali_5451_poke(codec, port, dwVal); 399 snd_ali_5451_poke(codec, port, dwVal);
480 400
@@ -483,7 +403,7 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
483 if (snd_ali_codec_ready(codec, port) < 0) 403 if (snd_ali_codec_ready(codec, port) < 0)
484 return ~0; 404 return ~0;
485 405
486 return (snd_ali_5451_peek(codec, port) & 0xffff0000)>>16; 406 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16;
487} 407}
488 408
489static void snd_ali_codec_write(struct snd_ac97 *ac97, 409static void snd_ali_codec_write(struct snd_ac97 *ac97,
@@ -493,9 +413,9 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
493 struct snd_ali *codec = ac97->private_data; 413 struct snd_ali *codec = ac97->private_data;
494 414
495 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); 415 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
496 if(reg == AC97_GPIO_STATUS) { 416 if (reg == AC97_GPIO_STATUS) {
497 outl((val << ALI_AC97_GPIO_DATA_SHIFT)|ALI_AC97_GPIO_ENABLE, 417 outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
498 ALI_REG(codec, ALI_AC97_GPIO)); 418 ALI_REG(codec, ALI_AC97_GPIO));
499 return; 419 return;
500 } 420 }
501 snd_ali_codec_poke(codec, ac97->num, reg, val); 421 snd_ali_codec_poke(codec, ac97->num, reg, val);
@@ -503,12 +423,13 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
503} 423}
504 424
505 425
506static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short reg) 426static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
427 unsigned short reg)
507{ 428{
508 struct snd_ali *codec = ac97->private_data; 429 struct snd_ali *codec = ac97->private_data;
509 430
510 snd_ali_printk("codec_read reg=%xh.\n", reg); 431 snd_ali_printk("codec_read reg=%xh.\n", reg);
511 return (snd_ali_codec_peek(codec, ac97->num, reg)); 432 return snd_ali_codec_peek(codec, ac97->num, reg);
512} 433}
513 434
514/* 435/*
@@ -517,11 +438,12 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short r
517 438
518static int snd_ali_reset_5451(struct snd_ali *codec) 439static int snd_ali_reset_5451(struct snd_ali *codec)
519{ 440{
520 struct pci_dev *pci_dev = NULL; 441 struct pci_dev *pci_dev;
521 unsigned short wCount, wReg; 442 unsigned short wCount, wReg;
522 unsigned int dwVal; 443 unsigned int dwVal;
523 444
524 if ((pci_dev = codec->pci_m1533) != NULL) { 445 pci_dev = codec->pci_m1533;
446 if (pci_dev) {
525 pci_read_config_dword(pci_dev, 0x7c, &dwVal); 447 pci_read_config_dword(pci_dev, 0x7c, &dwVal);
526 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000); 448 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000);
527 udelay(5000); 449 udelay(5000);
@@ -541,7 +463,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
541 wCount = 200; 463 wCount = 200;
542 while(wCount--) { 464 while(wCount--) {
543 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN); 465 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN);
544 if((wReg & 0x000f) == 0x000f) 466 if ((wReg & 0x000f) == 0x000f)
545 return 0; 467 return 0;
546 udelay(5000); 468 udelay(5000);
547 } 469 }
@@ -555,8 +477,8 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
555 477
556static int snd_ali_reset_codec(struct snd_ali *codec) 478static int snd_ali_reset_codec(struct snd_ali *codec)
557{ 479{
558 struct pci_dev *pci_dev = NULL; 480 struct pci_dev *pci_dev;
559 unsigned char bVal = 0; 481 unsigned char bVal;
560 unsigned int dwVal; 482 unsigned int dwVal;
561 unsigned short wCount, wReg; 483 unsigned short wCount, wReg;
562 484
@@ -579,9 +501,9 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
579 udelay(15000); 501 udelay(15000);
580 502
581 wCount = 200; 503 wCount = 200;
582 while(wCount--) { 504 while (wCount--) {
583 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN); 505 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN);
584 if((wReg & 0x000f) == 0x000f) 506 if ((wReg & 0x000f) == 0x000f)
585 return 0; 507 return 0;
586 udelay(5000); 508 udelay(5000);
587 } 509 }
@@ -594,25 +516,27 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
594 * ALI 5451 Controller 516 * ALI 5451 Controller
595 */ 517 */
596 518
597static void snd_ali_enable_special_channel(struct snd_ali *codec, unsigned int channel) 519static void snd_ali_enable_special_channel(struct snd_ali *codec,
520 unsigned int channel)
598{ 521{
599 unsigned long dwVal = 0; 522 unsigned long dwVal;
600 523
601 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 524 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
602 dwVal |= 1 << (channel & 0x0000001f); 525 dwVal |= 1 << (channel & 0x0000001f);
603 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 526 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
604} 527}
605 528
606static void snd_ali_disable_special_channel(struct snd_ali *codec, unsigned int channel) 529static void snd_ali_disable_special_channel(struct snd_ali *codec,
530 unsigned int channel)
607{ 531{
608 unsigned long dwVal = 0; 532 unsigned long dwVal;
609 533
610 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 534 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
611 dwVal &= ~(1 << (channel & 0x0000001f)); 535 dwVal &= ~(1 << (channel & 0x0000001f));
612 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 536 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
613} 537}
614 538
615static void snd_ali_enable_address_interrupt(struct snd_ali * codec) 539static void snd_ali_enable_address_interrupt(struct snd_ali *codec)
616{ 540{
617 unsigned int gc; 541 unsigned int gc;
618 542
@@ -622,7 +546,7 @@ static void snd_ali_enable_address_interrupt(struct snd_ali * codec)
622 outl( gc, ALI_REG(codec, ALI_GC_CIR)); 546 outl( gc, ALI_REG(codec, ALI_GC_CIR));
623} 547}
624 548
625static void snd_ali_disable_address_interrupt(struct snd_ali * codec) 549static void snd_ali_disable_address_interrupt(struct snd_ali *codec)
626{ 550{
627 unsigned int gc; 551 unsigned int gc;
628 552
@@ -632,8 +556,9 @@ static void snd_ali_disable_address_interrupt(struct snd_ali * codec)
632 outl(gc, ALI_REG(codec, ALI_GC_CIR)); 556 outl(gc, ALI_REG(codec, ALI_GC_CIR));
633} 557}
634 558
635#if 0 // not used 559#if 0 /* not used */
636static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel) 560static void snd_ali_enable_voice_irq(struct snd_ali *codec,
561 unsigned int channel)
637{ 562{
638 unsigned int mask; 563 unsigned int mask;
639 struct snd_ali_channel_control *pchregs = &(codec->chregs); 564 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -641,13 +566,14 @@ static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel
641 snd_ali_printk("enable_voice_irq channel=%d\n",channel); 566 snd_ali_printk("enable_voice_irq channel=%d\n",channel);
642 567
643 mask = 1 << (channel & 0x1f); 568 mask = 1 << (channel & 0x1f);
644 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 569 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
645 pchregs->data.ainten |= mask; 570 pchregs->data.ainten |= mask;
646 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 571 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
647} 572}
648#endif 573#endif
649 574
650static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channel) 575static void snd_ali_disable_voice_irq(struct snd_ali *codec,
576 unsigned int channel)
651{ 577{
652 unsigned int mask; 578 unsigned int mask;
653 struct snd_ali_channel_control *pchregs = &(codec->chregs); 579 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -655,9 +581,9 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channe
655 snd_ali_printk("disable_voice_irq channel=%d\n",channel); 581 snd_ali_printk("disable_voice_irq channel=%d\n",channel);
656 582
657 mask = 1 << (channel & 0x1f); 583 mask = 1 << (channel & 0x1f);
658 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 584 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
659 pchregs->data.ainten &= ~mask; 585 pchregs->data.ainten &= ~mask;
660 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 586 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
661} 587}
662 588
663static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel) 589static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
@@ -665,7 +591,8 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
665 unsigned int idx = channel & 0x1f; 591 unsigned int idx = channel & 0x1f;
666 592
667 if (codec->synth.chcnt >= ALI_CHANNELS){ 593 if (codec->synth.chcnt >= ALI_CHANNELS){
668 snd_printk(KERN_ERR "ali_alloc_pcm_channel: no free channels.\n"); 594 snd_printk(KERN_ERR
595 "ali_alloc_pcm_channel: no free channels.\n");
669 return -1; 596 return -1;
670 } 597 }
671 598
@@ -685,35 +612,41 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
685 612
686 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm"); 613 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm");
687 614
688 // recording 615 /* recording */
689 if (rec) { 616 if (rec) {
690 if (codec->spdif_support && 617 if (codec->spdif_support &&
691 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_IN_SUPPORT)) 618 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
619 ALI_SPDIF_IN_SUPPORT))
692 idx = ALI_SPDIF_IN_CHANNEL; 620 idx = ALI_SPDIF_IN_CHANNEL;
693 else 621 else
694 idx = ALI_PCM_IN_CHANNEL; 622 idx = ALI_PCM_IN_CHANNEL;
695 623
696 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 624 result = snd_ali_alloc_pcm_channel(codec, idx);
625 if (result >= 0)
697 return result; 626 return result;
698 } else { 627 else {
699 snd_printk(KERN_ERR "ali_find_free_channel: record channel is busy now.\n"); 628 snd_printk(KERN_ERR "ali_find_free_channel: "
629 "record channel is busy now.\n");
700 return -1; 630 return -1;
701 } 631 }
702 } 632 }
703 633
704 //playback... 634 /* playback... */
705 if (codec->spdif_support && 635 if (codec->spdif_support &&
706 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE)) { 636 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
637 ALI_SPDIF_OUT_CH_ENABLE)) {
707 idx = ALI_SPDIF_OUT_CHANNEL; 638 idx = ALI_SPDIF_OUT_CHANNEL;
708 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 639 result = snd_ali_alloc_pcm_channel(codec, idx);
640 if (result >= 0)
709 return result; 641 return result;
710 } else { 642 else
711 snd_printk(KERN_ERR "ali_find_free_channel: S/PDIF out channel is in busy now.\n"); 643 snd_printk(KERN_ERR "ali_find_free_channel: "
712 } 644 "S/PDIF out channel is in busy now.\n");
713 } 645 }
714 646
715 for (idx = 0; idx < ALI_CHANNELS; idx++) { 647 for (idx = 0; idx < ALI_CHANNELS; idx++) {
716 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) 648 result = snd_ali_alloc_pcm_channel(codec, idx);
649 if (result >= 0)
717 return result; 650 return result;
718 } 651 }
719 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n"); 652 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
@@ -730,7 +663,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
730 return; 663 return;
731 664
732 if (!(codec->synth.chmap & (1 << idx))) { 665 if (!(codec->synth.chmap & (1 << idx))) {
733 snd_printk(KERN_ERR "ali_free_channel_pcm: channel %d is not in use.\n",channel); 666 snd_printk(KERN_ERR "ali_free_channel_pcm: "
667 "channel %d is not in use.\n", channel);
734 return; 668 return;
735 } else { 669 } else {
736 codec->synth.chmap &= ~(1 << idx); 670 codec->synth.chmap &= ~(1 << idx);
@@ -738,8 +672,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
738 } 672 }
739} 673}
740 674
741#if 0 // not used 675#if 0 /* not used */
742static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel) 676static void snd_ali_start_voice(struct snd_ali *codec, unsigned int channel)
743{ 677{
744 unsigned int mask = 1 << (channel & 0x1f); 678 unsigned int mask = 1 << (channel & 0x1f);
745 679
@@ -748,7 +682,7 @@ static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel)
748} 682}
749#endif 683#endif
750 684
751static void snd_ali_stop_voice(struct snd_ali * codec, unsigned int channel) 685static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
752{ 686{
753 unsigned int mask = 1 << (channel & 0x1f); 687 unsigned int mask = 1 << (channel & 0x1f);
754 688
@@ -768,26 +702,27 @@ static void snd_ali_delay(struct snd_ali *codec,int interval)
768 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 702 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
769 703
770 while (currenttimer < begintimer + interval) { 704 while (currenttimer < begintimer + interval) {
771 if(snd_ali_stimer_ready(codec) < 0) 705 if (snd_ali_stimer_ready(codec) < 0)
772 break; 706 break;
773 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 707 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
708 cpu_relax();
774 } 709 }
775} 710}
776 711
777static void snd_ali_detect_spdif_rate(struct snd_ali *codec) 712static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
778{ 713{
779 u16 wval = 0; 714 u16 wval;
780 u16 count = 0; 715 u16 count = 0;
781 u8 bval = 0, R1 = 0, R2 = 0; 716 u8 bval, R1 = 0, R2;
782 717
783 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 718 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
784 bval |= 0x1F; 719 bval |= 0x1F;
785 outb(bval,ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 720 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1));
786 721
787 while (((R1 < 0x0B )||(R1 > 0x0E)) && (R1 != 0x12) && count <= 50000) { 722 while ((R1 < 0x0b || R1 > 0x0e) && R1 != 0x12 && count <= 50000) {
788 count ++; 723 count ++;
789 snd_ali_delay(codec, 6); 724 snd_ali_delay(codec, 6);
790 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 725 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
791 R1 = bval & 0x1F; 726 R1 = bval & 0x1F;
792 } 727 }
793 728
@@ -796,12 +731,14 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
796 return; 731 return;
797 } 732 }
798 733
799 count = 0; 734 for (count = 0; count <= 50000; count++) {
800 while (count++ <= 50000) {
801 snd_ali_delay(codec, 6); 735 snd_ali_delay(codec, 6);
802 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 736 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
803 R2 = bval & 0x1F; 737 R2 = bval & 0x1F;
804 if (R2 != R1) R1 = R2; else break; 738 if (R2 != R1)
739 R1 = R2;
740 else
741 break;
805 } 742 }
806 743
807 if (count > 50000) { 744 if (count > 50000) {
@@ -810,42 +747,45 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
810 } 747 }
811 748
812 if (R2 >= 0x0b && R2 <= 0x0e) { 749 if (R2 >= 0x0b && R2 <= 0x0e) {
813 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 750 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
814 wval &= 0xE0F0; 751 wval &= 0xe0f0;
815 wval |= (u16)0x09 << 8 | (u16)0x05; 752 wval |= (0x09 << 8) | 0x05;
816 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 753 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
817 754
818 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 755 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
819 outb(bval|0x02,ALI_REG(codec,ALI_SPDIF_CS + 3)); 756 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
820 } else if (R2 == 0x12) { 757 } else if (R2 == 0x12) {
821 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 758 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
822 wval &= 0xE0F0; 759 wval &= 0xe0f0;
823 wval |= (u16)0x0E << 8 | (u16)0x08; 760 wval |= (0x0e << 8) | 0x08;
824 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 761 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
825 762
826 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 763 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
827 outb(bval|0x03,ALI_REG(codec,ALI_SPDIF_CS + 3)); 764 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
828 } 765 }
829} 766}
830 767
831static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) 768static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
832{ 769{
833 u32 dwRate = 0; 770 u32 dwRate;
834 u8 bval = 0; 771 u8 bval;
835 772
836 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 773 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
837 bval &= 0x7F; 774 bval &= 0x7f;
838 bval |= 0x40; 775 bval |= 0x40;
839 outb(bval, ALI_REG(codec,ALI_SPDIF_CTRL)); 776 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
840 777
841 snd_ali_detect_spdif_rate(codec); 778 snd_ali_detect_spdif_rate(codec);
842 779
843 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)); 780 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
844 bval &= 0x0F; 781 bval &= 0x0f;
845 782
846 if (bval == 0) dwRate = 44100; 783 switch (bval) {
847 if (bval == 1) dwRate = 48000; 784 case 0: dwRate = 44100; break;
848 if (bval == 2) dwRate = 32000; 785 case 1: dwRate = 48000; break;
786 case 2: dwRate = 32000; break;
787 default: dwRate = 0; break;
788 }
849 789
850 return dwRate; 790 return dwRate;
851} 791}
@@ -880,20 +820,22 @@ static void snd_ali_disable_spdif_in(struct snd_ali *codec)
880static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate) 820static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
881{ 821{
882 unsigned char bVal; 822 unsigned char bVal;
883 unsigned int dwRate = 0; 823 unsigned int dwRate;
884 824
885 if (rate == 32000) dwRate = 0x300; 825 switch (rate) {
886 if (rate == 44100) dwRate = 0; 826 case 32000: dwRate = 0x300; break;
887 if (rate == 48000) dwRate = 0x200; 827 case 48000: dwRate = 0x200; break;
828 default: dwRate = 0; break;
829 }
888 830
889 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 831 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
890 bVal &= (unsigned char)(~(1<<6)); 832 bVal &= (unsigned char)(~(1<<6));
891 833
892 bVal |= 0x80; //select right 834 bVal |= 0x80; /* select right */
893 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 835 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
894 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2)); 836 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
895 837
896 bVal &= (~0x80); //select left 838 bVal &= ~0x80; /* select left */
897 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 839 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
898 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); 840 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
899} 841}
@@ -902,8 +844,7 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
902{ 844{
903 unsigned short wVal; 845 unsigned short wVal;
904 unsigned char bVal; 846 unsigned char bVal;
905 847 struct pci_dev *pci_dev;
906 struct pci_dev *pci_dev = NULL;
907 848
908 pci_dev = codec->pci_m1533; 849 pci_dev = codec->pci_m1533;
909 if (pci_dev == NULL) 850 if (pci_dev == NULL)
@@ -926,17 +867,15 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
926 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 867 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
927 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL)); 868 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
928 869
929 { 870 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
930 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 871 wVal |= ALI_SPDIF_OUT_SEL_PCM;
931 wVal |= ALI_SPDIF_OUT_SEL_PCM; 872 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
932 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 873 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
933 snd_ali_disable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL);
934 }
935} 874}
936 875
937static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) 876static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
938{ 877{
939 unsigned short wVal = 0; 878 unsigned short wVal;
940 879
941 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 880 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
942 wVal &= ~ALI_SPDIF_OUT_SEL_PCM; 881 wVal &= ~ALI_SPDIF_OUT_SEL_PCM;
@@ -949,12 +888,13 @@ static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
949 wVal &= (~0x0002); 888 wVal &= (~0x0002);
950 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS)); 889 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
951*/ 890*/
952 snd_ali_enable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL); 891 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
953} 892}
954 893
955static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) 894static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
956{ 895{
957 unsigned short wVal = 0; 896 unsigned short wVal;
897
958 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 898 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
959 wVal |= ALI_SPDIF_OUT_SEL_PCM; 899 wVal |= ALI_SPDIF_OUT_SEL_PCM;
960 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 900 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
@@ -972,11 +912,11 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec)
972 snd_ali_disable_spdif_chnout(codec); 912 snd_ali_disable_spdif_chnout(codec);
973} 913}
974 914
975static void snd_ali_update_ptr(struct snd_ali *codec,int channel) 915static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
976{ 916{
977 struct snd_ali_voice *pvoice = NULL; 917 struct snd_ali_voice *pvoice;
978 struct snd_pcm_runtime *runtime; 918 struct snd_pcm_runtime *runtime;
979 struct snd_ali_channel_control *pchregs = NULL; 919 struct snd_ali_channel_control *pchregs;
980 unsigned int old, mask; 920 unsigned int old, mask;
981#ifdef ALI_DEBUG 921#ifdef ALI_DEBUG
982 unsigned int temp, cspf; 922 unsigned int temp, cspf;
@@ -984,9 +924,9 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
984 924
985 pchregs = &(codec->chregs); 925 pchregs = &(codec->chregs);
986 926
987 // check if interrupt occurred for channel 927 /* check if interrupt occurred for channel */
988 old = pchregs->data.aint; 928 old = pchregs->data.aint;
989 mask = ((unsigned int) 1L) << (channel & 0x1f); 929 mask = 1U << (channel & 0x1f);
990 930
991 if (!(old & mask)) 931 if (!(old & mask))
992 return; 932 return;
@@ -1005,7 +945,8 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1005 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask; 945 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
1006#endif 946#endif
1007 if (pvoice->running) { 947 if (pvoice->running) {
1008 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",(u16)temp,cspf); 948 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
949 (u16)temp, cspf);
1009 spin_unlock(&codec->reg_lock); 950 spin_unlock(&codec->reg_lock);
1010 snd_pcm_period_elapsed(pvoice->substream); 951 snd_pcm_period_elapsed(pvoice->substream);
1011 spin_lock(&codec->reg_lock); 952 spin_lock(&codec->reg_lock);
@@ -1027,49 +968,47 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1027 pchregs->data.aint = old & (~mask); 968 pchregs->data.aint = old & (~mask);
1028} 969}
1029 970
1030static void snd_ali_interrupt(struct snd_ali * codec) 971static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1031{ 972{
973 struct snd_ali *codec = dev_id;
1032 int channel; 974 int channel;
1033 unsigned int audio_int; 975 unsigned int audio_int;
1034 struct snd_ali_channel_control *pchregs = NULL; 976 struct snd_ali_channel_control *pchregs;
1035 pchregs = &(codec->chregs); 977
978 if (codec == NULL || !codec->hw_initialized)
979 return IRQ_NONE;
1036 980
1037 audio_int = inl(ALI_REG(codec, ALI_MISCINT)); 981 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
982 if (!audio_int)
983 return IRQ_NONE;
984
985 pchregs = &(codec->chregs);
1038 if (audio_int & ADDRESS_IRQ) { 986 if (audio_int & ADDRESS_IRQ) {
1039 // get interrupt status for all channels 987 /* get interrupt status for all channels */
1040 pchregs->data.aint = inl(ALI_REG(codec,pchregs->regs.aint)); 988 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
1041 for (channel = 0; channel < ALI_CHANNELS; channel++) { 989 for (channel = 0; channel < ALI_CHANNELS; channel++)
1042 snd_ali_update_ptr(codec, channel); 990 snd_ali_update_ptr(codec, channel);
1043 }
1044 } 991 }
1045 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 992 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1046 ALI_REG(codec,ALI_MISCINT)); 993 ALI_REG(codec, ALI_MISCINT));
1047}
1048
1049
1050static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1051{
1052 struct snd_ali *codec = dev_id;
1053 994
1054 if (codec == NULL)
1055 return IRQ_NONE;
1056 snd_ali_interrupt(codec);
1057 return IRQ_HANDLED; 995 return IRQ_HANDLED;
1058} 996}
1059 997
1060 998
1061static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int type, int rec, int channel) 999static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
1000 int type, int rec, int channel)
1062{ 1001{
1063 struct snd_ali_voice *pvoice = NULL; 1002 struct snd_ali_voice *pvoice;
1064 int idx; 1003 int idx;
1065 1004
1066 snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); 1005 snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
1067 1006
1068 spin_lock_irq(&codec->voice_alloc); 1007 spin_lock_irq(&codec->voice_alloc);
1069 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 1008 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
1070 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 1009 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1071 snd_ali_find_free_channel(codec,rec); 1010 snd_ali_find_free_channel(codec,rec);
1072 if(idx < 0) { 1011 if (idx < 0) {
1073 snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); 1012 snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
1074 spin_unlock_irq(&codec->voice_alloc); 1013 spin_unlock_irq(&codec->voice_alloc);
1075 return NULL; 1014 return NULL;
@@ -1087,7 +1026,8 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int typ
1087} 1026}
1088 1027
1089 1028
1090static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvoice) 1029static void snd_ali_free_voice(struct snd_ali * codec,
1030 struct snd_ali_voice *pvoice)
1091{ 1031{
1092 void (*private_free)(void *); 1032 void (*private_free)(void *);
1093 void *private_data; 1033 void *private_data;
@@ -1101,9 +1041,8 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1101 private_data = pvoice->private_data; 1041 private_data = pvoice->private_data;
1102 pvoice->private_free = NULL; 1042 pvoice->private_free = NULL;
1103 pvoice->private_data = NULL; 1043 pvoice->private_data = NULL;
1104 if (pvoice->pcm) { 1044 if (pvoice->pcm)
1105 snd_ali_free_channel_pcm(codec, pvoice->number); 1045 snd_ali_free_channel_pcm(codec, pvoice->number);
1106 }
1107 pvoice->use = pvoice->pcm = pvoice->synth = 0; 1046 pvoice->use = pvoice->pcm = pvoice->synth = 0;
1108 pvoice->substream = NULL; 1047 pvoice->substream = NULL;
1109 spin_unlock_irq(&codec->voice_alloc); 1048 spin_unlock_irq(&codec->voice_alloc);
@@ -1112,9 +1051,9 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1112} 1051}
1113 1052
1114 1053
1115static void snd_ali_clear_voices(struct snd_ali * codec, 1054static void snd_ali_clear_voices(struct snd_ali *codec,
1116 unsigned int v_min, 1055 unsigned int v_min,
1117 unsigned int v_max) 1056 unsigned int v_max)
1118{ 1057{
1119 unsigned int i; 1058 unsigned int i;
1120 1059
@@ -1124,7 +1063,7 @@ static void snd_ali_clear_voices(struct snd_ali * codec,
1124 } 1063 }
1125} 1064}
1126 1065
1127static void snd_ali_write_voice_regs(struct snd_ali * codec, 1066static void snd_ali_write_voice_regs(struct snd_ali *codec,
1128 unsigned int Channel, 1067 unsigned int Channel,
1129 unsigned int LBA, 1068 unsigned int LBA,
1130 unsigned int CSO, 1069 unsigned int CSO,
@@ -1139,7 +1078,7 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1139{ 1078{
1140 unsigned int ctlcmds[4]; 1079 unsigned int ctlcmds[4];
1141 1080
1142 outb((unsigned char)(Channel & 0x001f),ALI_REG(codec,ALI_GC_CIR)); 1081 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1143 1082
1144 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff); 1083 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff);
1145 ctlcmds[1] = LBA; 1084 ctlcmds[1] = LBA;
@@ -1152,10 +1091,10 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1152 1091
1153 outb(Channel, ALI_REG(codec, ALI_GC_CIR)); 1092 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1154 1093
1155 outl(ctlcmds[0], ALI_REG(codec,ALI_CSO_ALPHA_FMS)); 1094 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1156 outl(ctlcmds[1], ALI_REG(codec,ALI_LBA)); 1095 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1157 outl(ctlcmds[2], ALI_REG(codec,ALI_ESO_DELTA)); 1096 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1158 outl(ctlcmds[3], ALI_REG(codec,ALI_GVSEL_PAN_VOC_CTRL_EC)); 1097 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1159 1098
1160 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */ 1099 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1161 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */ 1100 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
@@ -1165,8 +1104,10 @@ static unsigned int snd_ali_convert_rate(unsigned int rate, int rec)
1165{ 1104{
1166 unsigned int delta; 1105 unsigned int delta;
1167 1106
1168 if (rate < 4000) rate = 4000; 1107 if (rate < 4000)
1169 if (rate > 48000) rate = 48000; 1108 rate = 4000;
1109 if (rate > 48000)
1110 rate = 48000;
1170 1111
1171 if (rec) { 1112 if (rec) {
1172 if (rate == 44100) 1113 if (rate == 44100)
@@ -1201,11 +1142,11 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1201 */ 1142 */
1202 CTRL = 0x00000001; 1143 CTRL = 0x00000001;
1203 if (snd_pcm_format_width(runtime->format) == 16) 1144 if (snd_pcm_format_width(runtime->format) == 16)
1204 CTRL |= 0x00000008; // 16-bit data 1145 CTRL |= 0x00000008; /* 16-bit data */
1205 if (!snd_pcm_format_unsigned(runtime->format)) 1146 if (!snd_pcm_format_unsigned(runtime->format))
1206 CTRL |= 0x00000002; // signed data 1147 CTRL |= 0x00000002; /* signed data */
1207 if (runtime->channels > 1) 1148 if (runtime->channels > 1)
1208 CTRL |= 0x00000004; // stereo data 1149 CTRL |= 0x00000004; /* stereo data */
1209 return CTRL; 1150 return CTRL;
1210} 1151}
1211 1152
@@ -1213,45 +1154,39 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1213 * PCM part 1154 * PCM part
1214 */ 1155 */
1215 1156
1216static int snd_ali_ioctl(struct snd_pcm_substream *substream,
1217 unsigned int cmd, void *arg)
1218{
1219 return snd_pcm_lib_ioctl(substream, cmd, arg);
1220}
1221
1222static int snd_ali_trigger(struct snd_pcm_substream *substream, 1157static int snd_ali_trigger(struct snd_pcm_substream *substream,
1223 int cmd) 1158 int cmd)
1224 1159
1225{ 1160{
1226 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1161 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1227 struct list_head *pos;
1228 struct snd_pcm_substream *s; 1162 struct snd_pcm_substream *s;
1229 unsigned int what, whati, capture_flag; 1163 unsigned int what, whati, capture_flag;
1230 struct snd_ali_voice *pvoice = NULL, *evoice = NULL; 1164 struct snd_ali_voice *pvoice, *evoice;
1231 unsigned int val; 1165 unsigned int val;
1232 int do_start; 1166 int do_start;
1233 1167
1234 switch (cmd) { 1168 switch (cmd) {
1235 case SNDRV_PCM_TRIGGER_START: 1169 case SNDRV_PCM_TRIGGER_START:
1236 case SNDRV_PCM_TRIGGER_RESUME: 1170 case SNDRV_PCM_TRIGGER_RESUME:
1237 do_start = 1; break; 1171 do_start = 1;
1172 break;
1238 case SNDRV_PCM_TRIGGER_STOP: 1173 case SNDRV_PCM_TRIGGER_STOP:
1239 case SNDRV_PCM_TRIGGER_SUSPEND: 1174 case SNDRV_PCM_TRIGGER_SUSPEND:
1240 do_start = 0; break; 1175 do_start = 0;
1176 break;
1241 default: 1177 default:
1242 return -EINVAL; 1178 return -EINVAL;
1243 } 1179 }
1244 1180
1245 what = whati = capture_flag = 0; 1181 what = whati = capture_flag = 0;
1246 snd_pcm_group_for_each(pos, substream) { 1182 snd_pcm_group_for_each_entry(s, substream) {
1247 s = snd_pcm_group_substream_entry(pos);
1248 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { 1183 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1249 pvoice = s->runtime->private_data; 1184 pvoice = s->runtime->private_data;
1250 evoice = pvoice->extra; 1185 evoice = pvoice->extra;
1251 what |= 1 << (pvoice->number & 0x1f); 1186 what |= 1 << (pvoice->number & 0x1f);
1252 if (evoice == NULL) { 1187 if (evoice == NULL)
1253 whati |= 1 << (pvoice->number & 0x1f); 1188 whati |= 1 << (pvoice->number & 0x1f);
1254 } else { 1189 else {
1255 whati |= 1 << (evoice->number & 0x1f); 1190 whati |= 1 << (evoice->number & 0x1f);
1256 what |= 1 << (evoice->number & 0x1f); 1191 what |= 1 << (evoice->number & 0x1f);
1257 } 1192 }
@@ -1270,48 +1205,51 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
1270 } 1205 }
1271 } 1206 }
1272 spin_lock(&codec->reg_lock); 1207 spin_lock(&codec->reg_lock);
1273 if (! do_start) { 1208 if (!do_start)
1274 outl(what, ALI_REG(codec, ALI_STOP)); 1209 outl(what, ALI_REG(codec, ALI_STOP));
1275 }
1276 val = inl(ALI_REG(codec, ALI_AINTEN)); 1210 val = inl(ALI_REG(codec, ALI_AINTEN));
1277 if (do_start) { 1211 if (do_start)
1278 val |= whati; 1212 val |= whati;
1279 } else { 1213 else
1280 val &= ~whati; 1214 val &= ~whati;
1281 }
1282 outl(val, ALI_REG(codec, ALI_AINTEN)); 1215 outl(val, ALI_REG(codec, ALI_AINTEN));
1283 if (do_start) { 1216 if (do_start)
1284 outl(what, ALI_REG(codec, ALI_START)); 1217 outl(what, ALI_REG(codec, ALI_START));
1285 } 1218 snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati);
1286 snd_ali_printk("trigger: what=%xh whati=%xh\n",what,whati);
1287 spin_unlock(&codec->reg_lock); 1219 spin_unlock(&codec->reg_lock);
1288 1220
1289 return 0; 1221 return 0;
1290} 1222}
1291 1223
1292static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, 1224static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream,
1293 struct snd_pcm_hw_params *hw_params) 1225 struct snd_pcm_hw_params *hw_params)
1294{ 1226{
1295 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1227 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1296 struct snd_pcm_runtime *runtime = substream->runtime; 1228 struct snd_pcm_runtime *runtime = substream->runtime;
1297 struct snd_ali_voice *pvoice = runtime->private_data; 1229 struct snd_ali_voice *pvoice = runtime->private_data;
1298 struct snd_ali_voice *evoice = pvoice->extra; 1230 struct snd_ali_voice *evoice = pvoice->extra;
1299 int err; 1231 int err;
1300 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1232
1301 if (err < 0) return err; 1233 err = snd_pcm_lib_malloc_pages(substream,
1234 params_buffer_bytes(hw_params));
1235 if (err < 0)
1236 return err;
1302 1237
1303 /* voice management */ 1238 /* voice management */
1304 1239
1305 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { 1240 if (params_buffer_size(hw_params) / 2 !=
1306 if (evoice == NULL) { 1241 params_period_size(hw_params)) {
1307 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1); 1242 if (!evoice) {
1308 if (evoice == NULL) 1243 evoice = snd_ali_alloc_voice(codec,
1244 SNDRV_ALI_VOICE_TYPE_PCM,
1245 0, -1);
1246 if (!evoice)
1309 return -ENOMEM; 1247 return -ENOMEM;
1310 pvoice->extra = evoice; 1248 pvoice->extra = evoice;
1311 evoice->substream = substream; 1249 evoice->substream = substream;
1312 } 1250 }
1313 } else { 1251 } else {
1314 if (evoice != NULL) { 1252 if (evoice) {
1315 snd_ali_free_voice(codec, evoice); 1253 snd_ali_free_voice(codec, evoice);
1316 pvoice->extra = evoice = NULL; 1254 pvoice->extra = evoice = NULL;
1317 } 1255 }
@@ -1328,7 +1266,7 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1328 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; 1266 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
1329 1267
1330 snd_pcm_lib_free_pages(substream); 1268 snd_pcm_lib_free_pages(substream);
1331 if (evoice != NULL) { 1269 if (evoice) {
1332 snd_ali_free_voice(codec, evoice); 1270 snd_ali_free_voice(codec, evoice);
1333 pvoice->extra = NULL; 1271 pvoice->extra = NULL;
1334 } 1272 }
@@ -1336,9 +1274,10 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1336} 1274}
1337 1275
1338static int snd_ali_hw_params(struct snd_pcm_substream *substream, 1276static int snd_ali_hw_params(struct snd_pcm_substream *substream,
1339 struct snd_pcm_hw_params *hw_params) 1277 struct snd_pcm_hw_params *hw_params)
1340{ 1278{
1341 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1279 return snd_pcm_lib_malloc_pages(substream,
1280 params_buffer_bytes(hw_params));
1342} 1281}
1343 1282
1344static int snd_ali_hw_free(struct snd_pcm_substream *substream) 1283static int snd_ali_hw_free(struct snd_pcm_substream *substream)
@@ -1369,12 +1308,13 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1369 /* set Delta (rate) value */ 1308 /* set Delta (rate) value */
1370 Delta = snd_ali_convert_rate(runtime->rate, 0); 1309 Delta = snd_ali_convert_rate(runtime->rate, 0);
1371 1310
1372 if ((pvoice->number == ALI_SPDIF_IN_CHANNEL) || 1311 if (pvoice->number == ALI_SPDIF_IN_CHANNEL ||
1373 (pvoice->number == ALI_PCM_IN_CHANNEL)) 1312 pvoice->number == ALI_PCM_IN_CHANNEL)
1374 snd_ali_disable_special_channel(codec, pvoice->number); 1313 snd_ali_disable_special_channel(codec, pvoice->number);
1375 else if (codec->spdif_support && 1314 else if (codec->spdif_support &&
1376 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 1315 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1377 && (pvoice->number == ALI_SPDIF_OUT_CHANNEL)) { 1316 ALI_SPDIF_OUT_CH_ENABLE)
1317 && pvoice->number == ALI_SPDIF_OUT_CHANNEL) {
1378 snd_ali_set_spdif_out_rate(codec, runtime->rate); 1318 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1379 Delta = 0x1000; 1319 Delta = 0x1000;
1380 } 1320 }
@@ -1388,7 +1328,8 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1388 /* set target ESO for channel */ 1328 /* set target ESO for channel */
1389 pvoice->eso = runtime->buffer_size; 1329 pvoice->eso = runtime->buffer_size;
1390 1330
1391 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",pvoice->eso,pvoice->count); 1331 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
1332 pvoice->eso, pvoice->count);
1392 1333
1393 /* set ESO to capture first MIDLP interrupt */ 1334 /* set ESO to capture first MIDLP interrupt */
1394 ESO = pvoice->eso -1; 1335 ESO = pvoice->eso -1;
@@ -1399,35 +1340,37 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1399 PAN = 0; 1340 PAN = 0;
1400 VOL = 0; 1341 VOL = 0;
1401 EC = 0; 1342 EC = 0;
1402 snd_ali_printk("playback_prepare:\n ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL); 1343 snd_ali_printk("playback_prepare:\n");
1403 snd_ali_write_voice_regs( codec, 1344 snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
1404 pvoice->number, 1345 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
1405 LBA, 1346 snd_ali_write_voice_regs(codec,
1406 0, /* cso */ 1347 pvoice->number,
1407 ESO, 1348 LBA,
1408 Delta, 1349 0, /* cso */
1409 0, /* alpha */ 1350 ESO,
1410 GVSEL, 1351 Delta,
1411 PAN, 1352 0, /* alpha */
1412 VOL, 1353 GVSEL,
1413 CTRL, 1354 PAN,
1414 EC); 1355 VOL,
1415 if (evoice != NULL) { 1356 CTRL,
1357 EC);
1358 if (evoice) {
1416 evoice->count = pvoice->count; 1359 evoice->count = pvoice->count;
1417 evoice->eso = pvoice->count << 1; 1360 evoice->eso = pvoice->count << 1;
1418 ESO = evoice->eso - 1; 1361 ESO = evoice->eso - 1;
1419 snd_ali_write_voice_regs(codec, 1362 snd_ali_write_voice_regs(codec,
1420 evoice->number, 1363 evoice->number,
1421 LBA, 1364 LBA,
1422 0, /* cso */ 1365 0, /* cso */
1423 ESO, 1366 ESO,
1424 Delta, 1367 Delta,
1425 0, /* alpha */ 1368 0, /* alpha */
1426 GVSEL, 1369 GVSEL,
1427 (unsigned int)0x7f, 1370 0x7f,
1428 (unsigned int)0x3ff, 1371 0x3ff,
1429 CTRL, 1372 CTRL,
1430 EC); 1373 EC);
1431 } 1374 }
1432 spin_unlock_irq(&codec->reg_lock); 1375 spin_unlock_irq(&codec->reg_lock);
1433 return 0; 1376 return 0;
@@ -1459,7 +1402,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1459 pvoice->number == ALI_MODEM_OUT_CHANNEL) ? 1402 pvoice->number == ALI_MODEM_OUT_CHANNEL) ?
1460 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); 1403 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode);
1461 1404
1462 // Prepare capture intr channel 1405 /* Prepare capture intr channel */
1463 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { 1406 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) {
1464 1407
1465 unsigned int rate; 1408 unsigned int rate;
@@ -1470,7 +1413,8 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1470 1413
1471 rate = snd_ali_get_spdif_in_rate(codec); 1414 rate = snd_ali_get_spdif_in_rate(codec);
1472 if (rate == 0) { 1415 if (rate == 0) {
1473 snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n"); 1416 snd_printk(KERN_WARNING "ali_capture_preapre: "
1417 "spdif rate detect err!\n");
1474 rate = 48000; 1418 rate = 48000;
1475 } 1419 }
1476 spin_lock_irq(&codec->reg_lock); 1420 spin_lock_irq(&codec->reg_lock);
@@ -1481,19 +1425,19 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1481 } 1425 }
1482 1426
1483 if (rate != 48000) 1427 if (rate != 48000)
1484 Delta = ((rate << 12)/runtime->rate)&0x00ffff; 1428 Delta = ((rate << 12) / runtime->rate) & 0x00ffff;
1485 } 1429 }
1486 1430
1487 // set target ESO for channel 1431 /* set target ESO for channel */
1488 pvoice->eso = runtime->buffer_size; 1432 pvoice->eso = runtime->buffer_size;
1489 1433
1490 // set interrupt count size 1434 /* set interrupt count size */
1491 pvoice->count = runtime->period_size; 1435 pvoice->count = runtime->period_size;
1492 1436
1493 // set Loop Back Address 1437 /* set Loop Back Address */
1494 LBA = runtime->dma_addr; 1438 LBA = runtime->dma_addr;
1495 1439
1496 // set ESO to capture first MIDLP interrupt 1440 /* set ESO to capture first MIDLP interrupt */
1497 ESO = pvoice->eso - 1; 1441 ESO = pvoice->eso - 1;
1498 CTRL = snd_ali_control_mode(substream); 1442 CTRL = snd_ali_control_mode(substream);
1499 GVSEL = 0; 1443 GVSEL = 0;
@@ -1514,14 +1458,14 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1514 CTRL, 1458 CTRL,
1515 EC); 1459 EC);
1516 1460
1517
1518 spin_unlock_irq(&codec->reg_lock); 1461 spin_unlock_irq(&codec->reg_lock);
1519 1462
1520 return 0; 1463 return 0;
1521} 1464}
1522 1465
1523 1466
1524static snd_pcm_uframes_t snd_ali_playback_pointer(struct snd_pcm_substream *substream) 1467static snd_pcm_uframes_t
1468snd_ali_playback_pointer(struct snd_pcm_substream *substream)
1525{ 1469{
1526 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1470 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1527 struct snd_pcm_runtime *runtime = substream->runtime; 1471 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1563,14 +1507,14 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream)
1563 1507
1564static struct snd_pcm_hardware snd_ali_playback = 1508static struct snd_pcm_hardware snd_ali_playback =
1565{ 1509{
1566 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1510 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1567 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1511 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1568 SNDRV_PCM_INFO_MMAP_VALID | 1512 SNDRV_PCM_INFO_MMAP_VALID |
1569 SNDRV_PCM_INFO_RESUME | 1513 SNDRV_PCM_INFO_RESUME |
1570 SNDRV_PCM_INFO_SYNC_START), 1514 SNDRV_PCM_INFO_SYNC_START),
1571 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1515 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1572 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1516 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1573 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1517 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1574 .rate_min = 4000, 1518 .rate_min = 4000,
1575 .rate_max = 48000, 1519 .rate_max = 48000,
1576 .channels_min = 1, 1520 .channels_min = 1,
@@ -1589,14 +1533,14 @@ static struct snd_pcm_hardware snd_ali_playback =
1589 1533
1590static struct snd_pcm_hardware snd_ali_capture = 1534static struct snd_pcm_hardware snd_ali_capture =
1591{ 1535{
1592 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1536 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1593 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1537 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1594 SNDRV_PCM_INFO_MMAP_VALID | 1538 SNDRV_PCM_INFO_MMAP_VALID |
1595 SNDRV_PCM_INFO_RESUME | 1539 SNDRV_PCM_INFO_RESUME |
1596 SNDRV_PCM_INFO_SYNC_START), 1540 SNDRV_PCM_INFO_SYNC_START),
1597 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1541 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1598 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1542 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1599 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1543 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1600 .rate_min = 4000, 1544 .rate_min = 4000,
1601 .rate_max = 48000, 1545 .rate_max = 48000,
1602 .channels_min = 1, 1546 .channels_min = 1,
@@ -1620,15 +1564,16 @@ static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime)
1620 } 1564 }
1621} 1565}
1622 1566
1623static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channel, 1567static int snd_ali_open(struct snd_pcm_substream *substream, int rec,
1624 struct snd_pcm_hardware *phw) 1568 int channel, struct snd_pcm_hardware *phw)
1625{ 1569{
1626 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1570 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1627 struct snd_pcm_runtime *runtime = substream->runtime; 1571 struct snd_pcm_runtime *runtime = substream->runtime;
1628 struct snd_ali_voice *pvoice; 1572 struct snd_ali_voice *pvoice;
1629 1573
1630 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); 1574 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1631 if (pvoice == NULL) 1575 channel);
1576 if (!pvoice)
1632 return -EAGAIN; 1577 return -EAGAIN;
1633 1578
1634 pvoice->substream = substream; 1579 pvoice->substream = substream;
@@ -1637,7 +1582,8 @@ static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channe
1637 1582
1638 runtime->hw = *phw; 1583 runtime->hw = *phw;
1639 snd_pcm_set_sync(substream); 1584 snd_pcm_set_sync(substream);
1640 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); 1585 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
1586 0, 64*1024);
1641 return 0; 1587 return 0;
1642} 1588}
1643 1589
@@ -1669,7 +1615,7 @@ static int snd_ali_close(struct snd_pcm_substream *substream)
1669static struct snd_pcm_ops snd_ali_playback_ops = { 1615static struct snd_pcm_ops snd_ali_playback_ops = {
1670 .open = snd_ali_playback_open, 1616 .open = snd_ali_playback_open,
1671 .close = snd_ali_playback_close, 1617 .close = snd_ali_playback_close,
1672 .ioctl = snd_ali_ioctl, 1618 .ioctl = snd_pcm_lib_ioctl,
1673 .hw_params = snd_ali_playback_hw_params, 1619 .hw_params = snd_ali_playback_hw_params,
1674 .hw_free = snd_ali_playback_hw_free, 1620 .hw_free = snd_ali_playback_hw_free,
1675 .prepare = snd_ali_playback_prepare, 1621 .prepare = snd_ali_playback_prepare,
@@ -1680,7 +1626,7 @@ static struct snd_pcm_ops snd_ali_playback_ops = {
1680static struct snd_pcm_ops snd_ali_capture_ops = { 1626static struct snd_pcm_ops snd_ali_capture_ops = {
1681 .open = snd_ali_capture_open, 1627 .open = snd_ali_capture_open,
1682 .close = snd_ali_close, 1628 .close = snd_ali_close,
1683 .ioctl = snd_ali_ioctl, 1629 .ioctl = snd_pcm_lib_ioctl,
1684 .hw_params = snd_ali_hw_params, 1630 .hw_params = snd_ali_hw_params,
1685 .hw_free = snd_ali_hw_free, 1631 .hw_free = snd_ali_hw_free,
1686 .prepare = snd_ali_prepare, 1632 .prepare = snd_ali_prepare,
@@ -1697,20 +1643,22 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream,
1697{ 1643{
1698 struct snd_ali *chip = snd_pcm_substream_chip(substream); 1644 struct snd_ali *chip = snd_pcm_substream_chip(substream);
1699 unsigned int modem_num = chip->num_of_codecs - 1; 1645 unsigned int modem_num = chip->num_of_codecs - 1;
1700 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); 1646 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE,
1647 params_rate(hw_params));
1701 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); 1648 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1702 return snd_ali_hw_params(substream, hw_params); 1649 return snd_ali_hw_params(substream, hw_params);
1703} 1650}
1704 1651
1705static struct snd_pcm_hardware snd_ali_modem = 1652static struct snd_pcm_hardware snd_ali_modem =
1706{ 1653{
1707 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1654 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1708 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1655 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1709 SNDRV_PCM_INFO_MMAP_VALID | 1656 SNDRV_PCM_INFO_MMAP_VALID |
1710 SNDRV_PCM_INFO_RESUME | 1657 SNDRV_PCM_INFO_RESUME |
1711 SNDRV_PCM_INFO_SYNC_START), 1658 SNDRV_PCM_INFO_SYNC_START),
1712 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1659 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1713 .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000, 1660 .rates = (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000 |
1661 SNDRV_PCM_RATE_16000),
1714 .rate_min = 8000, 1662 .rate_min = 8000,
1715 .rate_max = 16000, 1663 .rate_max = 16000,
1716 .channels_min = 1, 1664 .channels_min = 1,
@@ -1723,15 +1671,17 @@ static struct snd_pcm_hardware snd_ali_modem =
1723 .fifo_size = 0, 1671 .fifo_size = 0,
1724}; 1672};
1725 1673
1726static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec, int channel) 1674static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec,
1675 int channel)
1727{ 1676{
1728 static unsigned int rates [] = {8000,9600,12000,16000}; 1677 static unsigned int rates[] = {8000, 9600, 12000, 16000};
1729 static struct snd_pcm_hw_constraint_list hw_constraint_rates = { 1678 static struct snd_pcm_hw_constraint_list hw_constraint_rates = {
1730 .count = ARRAY_SIZE(rates), 1679 .count = ARRAY_SIZE(rates),
1731 .list = rates, 1680 .list = rates,
1732 .mask = 0, 1681 .mask = 0,
1733 }; 1682 };
1734 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem); 1683 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem);
1684
1735 if (err) 1685 if (err)
1736 return err; 1686 return err;
1737 return snd_pcm_hw_constraint_list(substream->runtime, 0, 1687 return snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -1788,7 +1738,8 @@ static void snd_ali_pcm_free(struct snd_pcm *pcm)
1788} 1738}
1789 1739
1790 1740
1791static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_pcm_description *desc) 1741static int __devinit snd_ali_pcm(struct snd_ali * codec, int device,
1742 struct ali_pcm_description *desc)
1792{ 1743{
1793 struct snd_pcm *pcm; 1744 struct snd_pcm *pcm;
1794 int err; 1745 int err;
@@ -1802,12 +1753,15 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1802 pcm->private_data = codec; 1753 pcm->private_data = codec;
1803 pcm->private_free = snd_ali_pcm_free; 1754 pcm->private_free = snd_ali_pcm_free;
1804 if (desc->playback_ops) 1755 if (desc->playback_ops)
1805 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); 1756 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1757 desc->playback_ops);
1806 if (desc->capture_ops) 1758 if (desc->capture_ops)
1807 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); 1759 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1760 desc->capture_ops);
1808 1761
1809 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1762 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1810 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1763 snd_dma_pci_data(codec->pci),
1764 64*1024, 128*1024);
1811 1765
1812 pcm->info_flags = 0; 1766 pcm->info_flags = 0;
1813 pcm->dev_class = desc->class; 1767 pcm->dev_class = desc->class;
@@ -1818,16 +1772,29 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1818} 1772}
1819 1773
1820static struct ali_pcm_description ali_pcms[] = { 1774static struct ali_pcm_description ali_pcms[] = {
1821 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, 1775 { .name = "ALI 5451",
1822 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM } 1776 .playback_num = ALI_CHANNELS,
1777 .capture_num = 1,
1778 .playback_ops = &snd_ali_playback_ops,
1779 .capture_ops = &snd_ali_capture_ops
1780 },
1781 { .name = "ALI 5451 modem",
1782 .playback_num = 1,
1783 .capture_num = 1,
1784 .playback_ops = &snd_ali_modem_playback_ops,
1785 .capture_ops = &snd_ali_modem_capture_ops,
1786 .class = SNDRV_PCM_CLASS_MODEM
1787 }
1823}; 1788};
1824 1789
1825static int __devinit snd_ali_build_pcms(struct snd_ali *codec) 1790static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1826{ 1791{
1827 int i, err; 1792 int i, err;
1828 for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) 1793 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) {
1829 if((err = snd_ali_pcm(codec, i, &ali_pcms[i])) < 0) 1794 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1795 if (err < 0)
1830 return err; 1796 return err;
1797 }
1831 return 0; 1798 return 0;
1832} 1799}
1833 1800
@@ -1837,7 +1804,8 @@ static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1837.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ 1804.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
1838.put = snd_ali5451_spdif_put, .private_value = value} 1805.put = snd_ali5451_spdif_put, .private_value = value}
1839 1806
1840static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1807static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_info *uinfo)
1841{ 1809{
1842 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1810 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1843 uinfo->count = 1; 1811 uinfo->count = 1;
@@ -1846,7 +1814,8 @@ static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
1846 return 0; 1814 return 0;
1847} 1815}
1848 1816
1849static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1817static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1850{ 1819{
1851 struct snd_ali *codec = kcontrol->private_data; 1820 struct snd_ali *codec = kcontrol->private_data;
1852 unsigned int enable; 1821 unsigned int enable;
@@ -1854,12 +1823,13 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1854 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1823 enable = ucontrol->value.integer.value[0] ? 1 : 0;
1855 1824
1856 spin_lock_irq(&codec->reg_lock); 1825 spin_lock_irq(&codec->reg_lock);
1857 switch(kcontrol->private_value) { 1826 switch (kcontrol->private_value) {
1858 case 0: 1827 case 0:
1859 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1828 enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1860 break; 1829 break;
1861 case 1: 1830 case 1:
1862 enable = ((codec->spdif_mask & 0x02) && (codec->spdif_mask & 0x04)) ? 1 : 0; 1831 enable = ((codec->spdif_mask & 0x02) &&
1832 (codec->spdif_mask & 0x04)) ? 1 : 0;
1863 break; 1833 break;
1864 case 2: 1834 case 2:
1865 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1835 enable = (codec->spdif_mask & 0x01) ? 1 : 0;
@@ -1872,7 +1842,8 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1872 return 0; 1842 return 0;
1873} 1843}
1874 1844
1875static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1845static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1846 struct snd_ctl_elem_value *ucontrol)
1876{ 1847{
1877 struct snd_ali *codec = kcontrol->private_data; 1848 struct snd_ali *codec = kcontrol->private_data;
1878 unsigned int change = 0, enable = 0; 1849 unsigned int change = 0, enable = 0;
@@ -1939,18 +1910,6 @@ static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] __devinitdata = {
1939 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2) 1910 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2)
1940}; 1911};
1941 1912
1942static void snd_ali_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
1943{
1944 struct snd_ali *codec = bus->private_data;
1945 codec->ac97_bus = NULL;
1946}
1947
1948static void snd_ali_mixer_free_ac97(struct snd_ac97 *ac97)
1949{
1950 struct snd_ali *codec = ac97->private_data;
1951 codec->ac97[ac97->num] = NULL;
1952}
1953
1954static int __devinit snd_ali_mixer(struct snd_ali * codec) 1913static int __devinit snd_ali_mixer(struct snd_ali * codec)
1955{ 1914{
1956 struct snd_ac97_template ac97; 1915 struct snd_ac97_template ac97;
@@ -1961,19 +1920,20 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1961 .read = snd_ali_codec_read, 1920 .read = snd_ali_codec_read,
1962 }; 1921 };
1963 1922
1964 if ((err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus)) < 0) 1923 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1924 if (err < 0)
1965 return err; 1925 return err;
1966 codec->ac97_bus->private_free = snd_ali_mixer_free_ac97_bus;
1967 1926
1968 memset(&ac97, 0, sizeof(ac97)); 1927 memset(&ac97, 0, sizeof(ac97));
1969 ac97.private_data = codec; 1928 ac97.private_data = codec;
1970 ac97.private_free = snd_ali_mixer_free_ac97;
1971 1929
1972 for ( i = 0 ; i < codec->num_of_codecs ; i++) { 1930 for (i = 0; i < codec->num_of_codecs; i++) {
1973 ac97.num = i; 1931 ac97.num = i;
1974 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1932 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1975 snd_printk(KERN_ERR "ali mixer %d creating error.\n", i); 1933 if (err < 0) {
1976 if(i == 0) 1934 snd_printk(KERN_ERR
1935 "ali mixer %d creating error.\n", i);
1936 if (i == 0)
1977 return err; 1937 return err;
1978 codec->num_of_codecs = 1; 1938 codec->num_of_codecs = 1;
1979 break; 1939 break;
@@ -1981,9 +1941,11 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1981 } 1941 }
1982 1942
1983 if (codec->spdif_support) { 1943 if (codec->spdif_support) {
1984 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { 1944 for (idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) {
1985 err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); 1945 err = snd_ctl_add(codec->card,
1986 if (err < 0) return err; 1946 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1947 if (err < 0)
1948 return err;
1987 } 1949 }
1988 } 1950 }
1989 return 0; 1951 return 0;
@@ -1998,11 +1960,11 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
1998 int i, j; 1960 int i, j;
1999 1961
2000 im = chip->image; 1962 im = chip->image;
2001 if (! im) 1963 if (!im)
2002 return 0; 1964 return 0;
2003 1965
2004 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1966 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005 for(i = 0 ; i < chip->num_of_codecs ; i++) { 1967 for (i = 0; i < chip->num_of_codecs; i++) {
2006 snd_pcm_suspend_all(chip->pcm[i]); 1968 snd_pcm_suspend_all(chip->pcm[i]);
2007 snd_ac97_suspend(chip->ac97[i]); 1969 snd_ac97_suspend(chip->ac97[i]);
2008 } 1970 }
@@ -2010,10 +1972,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2010 spin_lock_irq(&chip->reg_lock); 1972 spin_lock_irq(&chip->reg_lock);
2011 1973
2012 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT)); 1974 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT));
2013 // im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); 1975 /* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */
2014 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP)); 1976 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP));
2015 1977
2016 // disable all IRQ bits 1978 /* disable all IRQ bits */
2017 outl(0, ALI_REG(chip, ALI_MISCINT)); 1979 outl(0, ALI_REG(chip, ALI_MISCINT));
2018 1980
2019 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 1981 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
@@ -2028,7 +1990,7 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2028 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0)); 1990 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0));
2029 } 1991 }
2030 1992
2031 // stop all HW channel 1993 /* stop all HW channel */
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 1994 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 1995
2034 spin_unlock_irq(&chip->reg_lock); 1996 spin_unlock_irq(&chip->reg_lock);
@@ -2047,7 +2009,7 @@ static int ali_resume(struct pci_dev *pci)
2047 int i, j; 2009 int i, j;
2048 2010
2049 im = chip->image; 2011 im = chip->image;
2050 if (! im) 2012 if (!im)
2051 return 0; 2013 return 0;
2052 2014
2053 pci_set_power_state(pci, PCI_D0); 2015 pci_set_power_state(pci, PCI_D0);
@@ -2069,19 +2031,20 @@ static int ali_resume(struct pci_dev *pci)
2069 } 2031 }
2070 2032
2071 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 2033 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
2072 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) || (i*4 == ALI_START)) 2034 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
2035 (i*4 == ALI_START))
2073 continue; 2036 continue;
2074 outl(im->regs[i], ALI_REG(chip, i*4)); 2037 outl(im->regs[i], ALI_REG(chip, i*4));
2075 } 2038 }
2076 2039
2077 // start HW channel 2040 /* start HW channel */
2078 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START)); 2041 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
2079 // restore IRQ enable bits 2042 /* restore IRQ enable bits */
2080 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT)); 2043 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
2081 2044
2082 spin_unlock_irq(&chip->reg_lock); 2045 spin_unlock_irq(&chip->reg_lock);
2083 2046
2084 for(i = 0 ; i < chip->num_of_codecs ; i++) 2047 for (i = 0 ; i < chip->num_of_codecs; i++)
2085 snd_ac97_resume(chip->ac97[i]); 2048 snd_ac97_resume(chip->ac97[i]);
2086 2049
2087 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2050 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -2113,7 +2076,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2113{ 2076{
2114 unsigned int legacy; 2077 unsigned int legacy;
2115 unsigned char temp; 2078 unsigned char temp;
2116 struct pci_dev *pci_dev = NULL; 2079 struct pci_dev *pci_dev;
2117 2080
2118 snd_ali_printk("chip initializing ... \n"); 2081 snd_ali_printk("chip initializing ... \n");
2119 2082
@@ -2146,7 +2109,8 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2146 outb(0x10, ALI_REG(codec, ALI_MPUR2)); 2109 outb(0x10, ALI_REG(codec, ALI_MPUR2));
2147 2110
2148 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID); 2111 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID);
2149 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_STATUS); 2112 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
2113 AC97_EXTENDED_STATUS);
2150 if (codec->spdif_support) { 2114 if (codec->spdif_support) {
2151 snd_ali_enable_spdif_out(codec); 2115 snd_ali_enable_spdif_out(codec);
2152 codec->spdif_mask = 0x00000002; 2116 codec->spdif_mask = 0x00000002;
@@ -2158,8 +2122,9 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2158 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { 2122 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
2159 codec->num_of_codecs++; 2123 codec->num_of_codecs++;
2160 outl(inl(ALI_REG(codec, ALI_SCTRL)) | 2124 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
2161 (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN), 2125 (ALI_SCTRL_LINE_IN2 | ALI_SCTRL_GPIO_IN2 |
2162 ALI_REG(codec, ALI_SCTRL)); 2126 ALI_SCTRL_LINE_OUT_EN),
2127 ALI_REG(codec, ALI_SCTRL));
2163 } 2128 }
2164 2129
2165 snd_ali_printk("chip initialize succeed.\n"); 2130 snd_ali_printk("chip initialize succeed.\n");
@@ -2168,18 +2133,19 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2168} 2133}
2169 2134
2170/* proc for register dump */ 2135/* proc for register dump */
2171static void snd_ali_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 2136static void snd_ali_proc_read(struct snd_info_entry *entry,
2137 struct snd_info_buffer *buf)
2172{ 2138{
2173 struct snd_ali *codec = entry->private_data; 2139 struct snd_ali *codec = entry->private_data;
2174 int i; 2140 int i;
2175 for(i = 0 ; i < 256 ; i+= 4) 2141 for (i = 0; i < 256 ; i+= 4)
2176 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); 2142 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2177} 2143}
2178 2144
2179static void __devinit snd_ali_proc_init(struct snd_ali *codec) 2145static void __devinit snd_ali_proc_init(struct snd_ali *codec)
2180{ 2146{
2181 struct snd_info_entry *entry; 2147 struct snd_info_entry *entry;
2182 if(!snd_card_proc_new(codec->card, "ali5451", &entry)) 2148 if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2183 snd_info_set_text_ops(entry, codec, snd_ali_proc_read); 2149 snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2184} 2150}
2185 2151
@@ -2188,7 +2154,8 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2188 int err; 2154 int err;
2189 2155
2190 snd_ali_printk("resouces allocation ...\n"); 2156 snd_ali_printk("resouces allocation ...\n");
2191 if ((err = pci_request_regions(codec->pci, "ALI 5451")) < 0) 2157 err = pci_request_regions(codec->pci, "ALI 5451");
2158 if (err < 0)
2192 return err; 2159 return err;
2193 codec->port = pci_resource_start(codec->pci, 0); 2160 codec->port = pci_resource_start(codec->pci, 0);
2194 2161
@@ -2201,9 +2168,9 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2201 snd_ali_printk("resouces allocated.\n"); 2168 snd_ali_printk("resouces allocated.\n");
2202 return 0; 2169 return 0;
2203} 2170}
2204static int snd_ali_dev_free(struct snd_device *device) 2171static int snd_ali_dev_free(struct snd_device *device)
2205{ 2172{
2206 struct snd_ali *codec=device->device_data; 2173 struct snd_ali *codec = device->device_data;
2207 snd_ali_free(codec); 2174 snd_ali_free(codec);
2208 return 0; 2175 return 0;
2209} 2176}
@@ -2226,17 +2193,20 @@ static int __devinit snd_ali_create(struct snd_card *card,
2226 snd_ali_printk("creating ...\n"); 2193 snd_ali_printk("creating ...\n");
2227 2194
2228 /* enable PCI device */ 2195 /* enable PCI device */
2229 if ((err = pci_enable_device(pci)) < 0) 2196 err = pci_enable_device(pci);
2197 if (err < 0)
2230 return err; 2198 return err;
2231 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2199 /* check, if we can restrict PCI DMA transfers to 31 bits */
2232 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 || 2200 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 ||
2233 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) { 2201 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) {
2234 snd_printk(KERN_ERR "architecture does not support 31bit PCI busmaster DMA\n"); 2202 snd_printk(KERN_ERR "architecture does not support "
2203 "31bit PCI busmaster DMA\n");
2235 pci_disable_device(pci); 2204 pci_disable_device(pci);
2236 return -ENXIO; 2205 return -ENXIO;
2237 } 2206 }
2238 2207
2239 if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) { 2208 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
2209 if (!codec) {
2240 pci_disable_device(pci); 2210 pci_disable_device(pci);
2241 return -ENOMEM; 2211 return -ENOMEM;
2242 } 2212 }
@@ -2247,7 +2217,7 @@ static int __devinit snd_ali_create(struct snd_card *card,
2247 codec->card = card; 2217 codec->card = card;
2248 codec->pci = pci; 2218 codec->pci = pci;
2249 codec->irq = -1; 2219 codec->irq = -1;
2250 pci_read_config_byte(pci, PCI_REVISION_ID, &codec->revision); 2220 codec->revision = pci->revision;
2251 codec->spdif_support = spdif_support; 2221 codec->spdif_support = spdif_support;
2252 2222
2253 if (pcm_streams < 1) 2223 if (pcm_streams < 1)
@@ -2293,21 +2263,22 @@ static int __devinit snd_ali_create(struct snd_card *card,
2293 2263
2294 /* M1533: southbridge */ 2264 /* M1533: southbridge */
2295 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); 2265 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2296 if (! codec->pci_m1533) { 2266 if (!codec->pci_m1533) {
2297 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2267 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
2298 snd_ali_free(codec); 2268 snd_ali_free(codec);
2299 return -ENODEV; 2269 return -ENODEV;
2300 } 2270 }
2301 /* M7101: power management */ 2271 /* M7101: power management */
2302 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); 2272 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2303 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2273 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2304 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2274 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
2305 snd_ali_free(codec); 2275 snd_ali_free(codec);
2306 return -ENODEV; 2276 return -ENODEV;
2307 } 2277 }
2308 2278
2309 snd_ali_printk("snd_device_new is called.\n"); 2279 snd_ali_printk("snd_device_new is called.\n");
2310 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops)) < 0) { 2280 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2281 if (err < 0) {
2311 snd_ali_free(codec); 2282 snd_ali_free(codec);
2312 return err; 2283 return err;
2313 } 2284 }
@@ -2315,18 +2286,18 @@ static int __devinit snd_ali_create(struct snd_card *card,
2315 snd_card_set_dev(card, &pci->dev); 2286 snd_card_set_dev(card, &pci->dev);
2316 2287
2317 /* initialise synth voices*/ 2288 /* initialise synth voices*/
2318 for (i = 0; i < ALI_CHANNELS; i++ ) { 2289 for (i = 0; i < ALI_CHANNELS; i++)
2319 codec->synth.voices[i].number = i; 2290 codec->synth.voices[i].number = i;
2320 }
2321 2291
2322 if ((err = snd_ali_chip_init(codec)) < 0) { 2292 err = snd_ali_chip_init(codec);
2293 if (err < 0) {
2323 snd_printk(KERN_ERR "ali create: chip init error.\n"); 2294 snd_printk(KERN_ERR "ali create: chip init error.\n");
2324 return err; 2295 return err;
2325 } 2296 }
2326 2297
2327#ifdef CONFIG_PM 2298#ifdef CONFIG_PM
2328 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2299 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2329 if (! codec->image) 2300 if (!codec->image)
2330 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2301 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
2331#endif 2302#endif
2332 2303
@@ -2348,42 +2319,43 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2348 snd_ali_printk("probe ...\n"); 2319 snd_ali_printk("probe ...\n");
2349 2320
2350 card = snd_card_new(index, id, THIS_MODULE, 0); 2321 card = snd_card_new(index, id, THIS_MODULE, 0);
2351 if (card == NULL) 2322 if (!card)
2352 return -ENOMEM; 2323 return -ENOMEM;
2353 2324
2354 if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) { 2325 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
2355 snd_card_free(card); 2326 if (err < 0)
2356 return err; 2327 goto error;
2357 }
2358 card->private_data = codec; 2328 card->private_data = codec;
2359 2329
2360 snd_ali_printk("mixer building ...\n"); 2330 snd_ali_printk("mixer building ...\n");
2361 if ((err = snd_ali_mixer(codec)) < 0) { 2331 err = snd_ali_mixer(codec);
2362 snd_card_free(card); 2332 if (err < 0)
2363 return err; 2333 goto error;
2364 }
2365 2334
2366 snd_ali_printk("pcm building ...\n"); 2335 snd_ali_printk("pcm building ...\n");
2367 if ((err = snd_ali_build_pcms(codec)) < 0) { 2336 err = snd_ali_build_pcms(codec);
2368 snd_card_free(card); 2337 if (err < 0)
2369 return err; 2338 goto error;
2370 }
2371 2339
2372 snd_ali_proc_init(codec); 2340 snd_ali_proc_init(codec);
2373 2341
2374 strcpy(card->driver, "ALI5451"); 2342 strcpy(card->driver, "ALI5451");
2375 strcpy(card->shortname, "ALI 5451"); 2343 strcpy(card->shortname, "ALI 5451");
2376 2344
2377 sprintf(card->longname, "%s at 0x%lx, irq %li", 2345 sprintf(card->longname, "%s at 0x%lx, irq %i",
2378 card->shortname, codec->port, codec->irq); 2346 card->shortname, codec->port, codec->irq);
2379 2347
2380 snd_ali_printk("register card.\n"); 2348 snd_ali_printk("register card.\n");
2381 if ((err = snd_card_register(card)) < 0) { 2349 err = snd_card_register(card);
2382 snd_card_free(card); 2350 if (err < 0)
2383 return err; 2351 goto error;
2384 } 2352
2385 pci_set_drvdata(pci, card); 2353 pci_set_drvdata(pci, card);
2386 return 0; 2354 return 0;
2355
2356 error:
2357 snd_card_free(card);
2358 return err;
2387} 2359}
2388 2360
2389static void __devexit snd_ali_remove(struct pci_dev *pci) 2361static void __devexit snd_ali_remove(struct pci_dev *pci)
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 8afcb98ca7b..48cc39b771d 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -88,8 +88,8 @@
88#define PLAYBACK_BLOCK_COUNTER 0x9A 88#define PLAYBACK_BLOCK_COUNTER 0x9A
89#define RECORD_BLOCK_COUNTER 0x9B 89#define RECORD_BLOCK_COUNTER 0x9B
90 90
91#define DEBUG_CALLS 1 91#define DEBUG_CALLS 0
92#define DEBUG_PLAY_REC 1 92#define DEBUG_PLAY_REC 0
93 93
94#if DEBUG_CALLS 94#if DEBUG_CALLS
95#define snd_als300_dbgcalls(format, args...) printk(format, ##args) 95#define snd_als300_dbgcalls(format, args...) printk(format, ##args)
@@ -733,7 +733,8 @@ static int __devinit snd_als300_create(struct snd_card *card,
733 733
734 snd_als300_init(chip); 734 snd_als300_init(chip);
735 735
736 if (snd_als300_ac97(chip) < 0) { 736 err = snd_als300_ac97(chip);
737 if (err < 0) {
737 snd_printk(KERN_WARNING "Could not create ac97\n"); 738 snd_printk(KERN_WARNING "Could not create ac97\n");
738 snd_als300_free(chip); 739 snd_als300_free(chip);
739 return err; 740 return err;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 7d8053b5e8d..89184a42414 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1639,15 +1639,12 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1639{ 1639{
1640 struct snd_card *card; 1640 struct snd_card *card;
1641 struct atiixp *chip; 1641 struct atiixp *chip;
1642 unsigned char revision;
1643 int err; 1642 int err;
1644 1643
1645 card = snd_card_new(index, id, THIS_MODULE, 0); 1644 card = snd_card_new(index, id, THIS_MODULE, 0);
1646 if (card == NULL) 1645 if (card == NULL)
1647 return -ENOMEM; 1646 return -ENOMEM;
1648 1647
1649 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1650
1651 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); 1648 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
1652 strcpy(card->shortname, "ATI IXP"); 1649 strcpy(card->shortname, "ATI IXP");
1653 if ((err = snd_atiixp_create(card, pci, &chip)) < 0) 1650 if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
@@ -1670,7 +1667,8 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1670 snd_atiixp_chip_start(chip); 1667 snd_atiixp_chip_start(chip);
1671 1668
1672 snprintf(card->longname, sizeof(card->longname), 1669 snprintf(card->longname, sizeof(card->longname),
1673 "%s rev %x with %s at %#lx, irq %i", card->shortname, revision, 1670 "%s rev %x with %s at %#lx, irq %i", card->shortname,
1671 pci->revision,
1674 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?", 1672 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
1675 chip->addr, chip->irq); 1673 chip->addr, chip->irq);
1676 1674
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 904023fe4f2..ce752f84457 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1283,15 +1283,12 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1283{ 1283{
1284 struct snd_card *card; 1284 struct snd_card *card;
1285 struct atiixp_modem *chip; 1285 struct atiixp_modem *chip;
1286 unsigned char revision;
1287 int err; 1286 int err;
1288 1287
1289 card = snd_card_new(index, id, THIS_MODULE, 0); 1288 card = snd_card_new(index, id, THIS_MODULE, 0);
1290 if (card == NULL) 1289 if (card == NULL)
1291 return -ENOMEM; 1290 return -ENOMEM;
1292 1291
1293 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1294
1295 strcpy(card->driver, "ATIIXP-MODEM"); 1292 strcpy(card->driver, "ATIIXP-MODEM");
1296 strcpy(card->shortname, "ATI IXP Modem"); 1293 strcpy(card->shortname, "ATI IXP Modem");
1297 if ((err = snd_atiixp_create(card, pci, &chip)) < 0) 1294 if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
@@ -1312,7 +1309,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
1312 snd_atiixp_chip_start(chip); 1309 snd_atiixp_chip_start(chip);
1313 1310
1314 sprintf(card->longname, "%s rev %x at 0x%lx, irq %i", 1311 sprintf(card->longname, "%s rev %x at 0x%lx, irq %i",
1315 card->shortname, revision, chip->addr, chip->irq); 1312 card->shortname, pci->revision, chip->addr, chip->irq);
1316 1313
1317 if ((err = snd_card_register(card)) < 0) 1314 if ((err = snd_card_register(card)) < 0)
1318 goto __error; 1315 goto __error;
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 238154bb7a2..5ec1b6fcd54 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -341,11 +341,7 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
341 snd_card_free(card); 341 snd_card_free(card);
342 return err; 342 return err;
343 } 343 }
344 if ((err = pci_read_config_byte(pci, PCI_REVISION_ID, 344 chip->rev = pci->revision;
345 &(chip->rev))) < 0) {
346 snd_card_free(card);
347 return err;
348 }
349#ifdef CHIP_AU8830 345#ifdef CHIP_AU8830
350 if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) { 346 if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) {
351 printk(KERN_ALERT 347 printk(KERN_ALERT
diff --git a/sound/pci/au88x0/au88x0_sb.h b/sound/pci/au88x0/au88x0_sb.h
deleted file mode 100644
index 5a4d8fc2bbf..00000000000
--- a/sound/pci/au88x0/au88x0_sb.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * au88x0_sb.h
3 *
4 * Wed Oct 29 22:10:42 2003
5 *
6 ****************************************************************************/
7
8#ifdef CHIP_AU8820
9/* AU8820 starting @ 64KiB offset */
10#define SBEMU_BASE 0x10000
11#else
12/* AU8810? and AU8830 starting @ 164KiB offset */
13#define SBEMU_BASE 0x29000
14#endif
15
16#define FM_A_STATUS (SBEMU_BASE + 0x00) /* read */
17#define FM_A_ADDRESS (SBEMU_BASE + 0x00) /* write */
18#define FM_A_DATA (SBEMU_BASE + 0x04)
19#define FM_B_STATUS (SBEMU_BASE + 0x08)
20#define FM_B_ADDRESS (SBEMU_BASE + 0x08)
21#define FM_B_DATA (SBEMU_BASE + 0x0C)
22#define SB_MIXER_ADDR (SBEMU_BASE + 0x10)
23#define SB_MIXER_DATA (SBEMU_BASE + 0x14)
24#define SB_RESET (SBEMU_BASE + 0x18)
25#define SB_RESET_ALIAS (SBEMU_BASE + 0x1C)
26#define FM_STATUS2 (SBEMU_BASE + 0x20)
27#define FM_ADDR2 (SBEMU_BASE + 0x20)
28#define FM_DATA2 (SBEMU_BASE + 0x24)
29#define SB_DSP_READ (SBEMU_BASE + 0x28)
30#define SB_DSP_WRITE (SBEMU_BASE + 0x30)
31#define SB_DSP_WRITE_STATUS (SBEMU_BASE + 0x30) /* bit 7 */
32#define SB_DSP_READ_STATUS (SBEMU_BASE + 0x38) /* bit 7 */
33#define SB_LACR (SBEMU_BASE + 0x40) /* ? */
34#define SB_LADCR (SBEMU_BASE + 0x44) /* ? */
35#define SB_LAMR (SBEMU_BASE + 0x48) /* ? */
36#define SB_LARR (SBEMU_BASE + 0x4C) /* ? */
37#define SB_VERSION (SBEMU_BASE + 0x50)
38#define SB_CTRLSTAT (SBEMU_BASE + 0x54)
39#define SB_TIMERSTAT (SBEMU_BASE + 0x58)
40#define FM_RAM (SBEMU_BASE + 0x100) /* 0x40 ULONG */
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 43edd2839b5..36d3666a5b7 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). 2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168).
3 * Copyright (C) 2002, 2005 by Andreas Mohr <andi AT lisas.de> 3 * Copyright (C) 2002, 2005, 2006, 2007 by Andreas Mohr <andi AT lisas.de>
4 * 4 *
5 * Framework borrowed from Bart Hartgers's als4000.c. 5 * Framework borrowed from Bart Hartgers's als4000.c.
6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), 6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801),
@@ -52,6 +52,9 @@
52 * - full duplex 16bit playback/record at independent sampling rate 52 * - full duplex 16bit playback/record at independent sampling rate
53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr?? 53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr??
54 * - game port (legacy address support) 54 * - game port (legacy address support)
55 * - builtin 3D enhancement (said to be YAMAHA Ymersion)
56 * - builtin DirectInput support, helps reduce CPU overhead (interrupt-driven
57 * features supported)
55 * - built-in General DirectX timer having a 20 bits counter 58 * - built-in General DirectX timer having a 20 bits counter
56 * with 1us resolution (see below!) 59 * with 1us resolution (see below!)
57 * - I2S serial port for external DAC 60 * - I2S serial port for external DAC
@@ -94,6 +97,10 @@
94 * 97 *
95 * BUGS 98 * BUGS
96 * - full-duplex might *still* be problematic, not fully tested recently 99 * - full-duplex might *still* be problematic, not fully tested recently
100 * - (non-bug) "Bass/Treble or 3D settings don't work" - they do get evaluated
101 * if you set PCM output switch to "pre 3D" instead of "post 3D".
102 * If this can't be set, then get a mixer application that Isn't Stupid (tm)
103 * (e.g. kmix, gamix) - unfortunately several are!!
97 * 104 *
98 * TODO 105 * TODO
99 * - test MPU401 MIDI playback etc. 106 * - test MPU401 MIDI playback etc.
@@ -622,7 +629,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol,
622 return (nreg != oreg); 629 return (nreg != oreg);
623} 630}
624 631
625static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = { 632static struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = {
626 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1), 633 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1),
627 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1), 634 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1),
628 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1), 635 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1),
@@ -652,7 +659,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
652 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1), 659 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1),
653 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8), 660 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8),
654 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9), 661 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9),
655 AZF3328_MIXER_ENUM("PCM", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */ 662 AZF3328_MIXER_ENUM("PCM Output Route", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */
656 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0), 663 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0),
657 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0), 664 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0),
658 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0), 665 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0),
@@ -678,7 +685,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
678#endif 685#endif
679}; 686};
680 687
681static const u16 __devinitdata snd_azf3328_init_values[][2] = { 688static u16 __devinitdata snd_azf3328_init_values[][2] = {
682 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f }, 689 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f },
683 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f }, 690 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f },
684 { IDX_MIXER_BASSTREBLE, 0x0000 }, 691 { IDX_MIXER_BASSTREBLE, 0x0000 },
@@ -1369,7 +1376,6 @@ snd_azf3328_playback_close(struct snd_pcm_substream *substream)
1369 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); 1376 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream);
1370 1377
1371 snd_azf3328_dbgcallenter(); 1378 snd_azf3328_dbgcallenter();
1372
1373 chip->playback_substream = NULL; 1379 chip->playback_substream = NULL;
1374 snd_azf3328_dbgcallleave(); 1380 snd_azf3328_dbgcallleave();
1375 return 0; 1381 return 0;
@@ -1660,10 +1666,10 @@ snd_azf3328_test_bit(unsigned int reg, int bit)
1660} 1666}
1661#endif 1667#endif
1662 1668
1669#if DEBUG_MISC
1663static void 1670static void
1664snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) 1671snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1665{ 1672{
1666#if DEBUG_MISC
1667 u16 tmp; 1673 u16 tmp;
1668 1674
1669 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq); 1675 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq);
@@ -1673,10 +1679,16 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1673 for (tmp=0; tmp <= 0x01; tmp += 1) 1679 for (tmp=0; tmp <= 0x01; tmp += 1)
1674 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp)); 1680 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp));
1675 1681
1676 for (tmp = 0; tmp <= 0x6E; tmp += 2) 1682 for (tmp = 0; tmp < AZF_IO_SIZE_CODEC; tmp += 2)
1677 snd_azf3328_dbgmisc("0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inb(chip, tmp)); 1683 snd_azf3328_dbgmisc("codec 0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inw(chip, tmp));
1678#endif 1684
1685 for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2)
1686 snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n", tmp, snd_azf3328_mixer_inw(chip, tmp));
1679} 1687}
1688#else
1689static inline void
1690snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) {}
1691#endif
1680 1692
1681static int __devinit 1693static int __devinit
1682snd_azf3328_create(struct snd_card *card, 1694snd_azf3328_create(struct snd_card *card,
@@ -1842,8 +1854,8 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1842 1854
1843#ifdef MODULE 1855#ifdef MODULE
1844 printk( 1856 printk(
1845"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168\n" 1857"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n"
1846"azt3328: (hardware was completely undocumented - ZERO support from Aztech).\n" 1858"azt3328: Hardware was completely undocumented, unfortunately.\n"
1847"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" 1859"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n"
1848"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", 1860"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
1849 1024000 / seqtimer_scaling, seqtimer_scaling); 1861 1024000 / seqtimer_scaling, seqtimer_scaling);
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h
index b4f3e3cd006..679fa992e2b 100644
--- a/sound/pci/azt3328.h
+++ b/sound/pci/azt3328.h
@@ -106,8 +106,8 @@
106 #define IRQ_RECORDING 0x0002 106 #define IRQ_RECORDING 0x0002
107 #define IRQ_MPU401 0x0010 107 #define IRQ_MPU401 0x0010
108 #define IRQ_TIMER 0x0020 /* DirectX timer */ 108 #define IRQ_TIMER 0x0020 /* DirectX timer */
109 #define IRQ_UNKNOWN1 0x0040 /* probably unused */ 109 #define IRQ_UNKNOWN1 0x0040 /* probably unused, or possibly I2S port? or gameport IRQ? */
110 #define IRQ_UNKNOWN2 0x0080 /* probably unused */ 110 #define IRQ_UNKNOWN2 0x0080 /* probably unused, or possibly I2S port? or gameport IRQ? */
111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ 111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */
112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */ 112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */
113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */ 113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index e9b029e1cd6..6523ba07db9 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_ids[] = {
781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), 781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
782 /* Viewcast Osprey 200 */ 782 /* Viewcast Osprey 200 */
783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), 783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
784 /* ATI TV-Wonder */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000),
784 /* Leadtek Winfast tv 2000xp delux */ 786 /* Leadtek Winfast tv 2000xp delux */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000), 787 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000),
786 /* Voodoo TV 200 */ 788 /* Voodoo TV 200 */
@@ -833,7 +835,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
833 pci->device, pci->subsystem_vendor, pci->subsystem_device); 835 pci->device, pci->subsystem_vendor, pci->subsystem_device);
834 snd_printk(KERN_DEBUG "please mail id, board name, and, " 836 snd_printk(KERN_DEBUG "please mail id, board name, and, "
835 "if it works, the correct digital_rate option to " 837 "if it works, the correct digital_rate option to "
836 "<alsa-devel@lists.sf.net>\n"); 838 "<alsa-devel@alsa-project.org>\n");
837 return 32000; /* default rate */ 839 return 32000; /* default rate */
838} 840}
839 841
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index aaac6e5b476..a0420bc63f0 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -590,7 +590,6 @@ struct snd_ca0106 {
590 struct resource *res_port; 590 struct resource *res_port;
591 int irq; 591 int irq;
592 592
593 unsigned char revision; /* chip revision */
594 unsigned int serial; /* serial number */ 593 unsigned int serial; /* serial number */
595 unsigned short model; /* subsystem id */ 594 unsigned short model; /* subsystem id */
596 595
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index ea6712b63c9..fcab8fb97e3 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -168,6 +168,25 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
168#include "ca0106.h" 168#include "ca0106.h"
169 169
170static struct snd_ca0106_details ca0106_chip_details[] = { 170static struct snd_ca0106_details ca0106_chip_details[] = {
171 /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */
172 /* It is really just a normal SB Live 24bit. */
173 /*
174 * CTRL:CA0111-WTLF
175 * ADC: WM8775SEDS
176 * DAC: CS4382-KQZ
177 */
178 /* Tested:
179 * Playback on front, rear, center/lfe speakers
180 * Capture from Mic in.
181 * Not-Tested:
182 * Capture from Line in.
183 * Playback to digital out.
184 */
185 { .serial = 0x10121102,
186 .name = "X-Fi Extreme Audio [SB0790]",
187 .gpio_type = 1,
188 .i2c_adc = 1 } ,
189 /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */
171 /* AudigyLS[SB0310] */ 190 /* AudigyLS[SB0310] */
172 { .serial = 0x10021102, 191 { .serial = 0x10021102,
173 .name = "AudigyLS [SB0310]", 192 .name = "AudigyLS [SB0310]",
@@ -775,7 +794,6 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
775 struct snd_ca0106_pcm *epcm; 794 struct snd_ca0106_pcm *epcm;
776 int channel; 795 int channel;
777 int result = 0; 796 int result = 0;
778 struct list_head *pos;
779 struct snd_pcm_substream *s; 797 struct snd_pcm_substream *s;
780 u32 basic = 0; 798 u32 basic = 0;
781 u32 extended = 0; 799 u32 extended = 0;
@@ -790,8 +808,7 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
790 running=0; 808 running=0;
791 break; 809 break;
792 } 810 }
793 snd_pcm_group_for_each(pos, substream) { 811 snd_pcm_group_for_each_entry(s, substream) {
794 s = snd_pcm_group_substream_entry(pos);
795 runtime = s->runtime; 812 runtime = s->runtime;
796 epcm = runtime->private_data; 813 epcm = runtime->private_data;
797 channel = epcm->channel_id; 814 channel = epcm->channel_id;
@@ -1295,13 +1312,12 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1295 } 1312 }
1296 1313
1297 pci_set_master(pci); 1314 pci_set_master(pci);
1298 /* read revision & serial */ 1315 /* read serial */
1299 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->revision);
1300 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 1316 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
1301 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 1317 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
1302#if 1 1318#if 1
1303 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model, 1319 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model,
1304 chip->revision, chip->serial); 1320 pci->revision, chip->serial);
1305#endif 1321#endif
1306 strcpy(card->driver, "CA0106"); 1322 strcpy(card->driver, "CA0106");
1307 strcpy(card->shortname, "CA0106"); 1323 strcpy(card->shortname, "CA0106");
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 2ae539b195f..71d7aab9d86 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2897,6 +2897,10 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2897 } 2897 }
2898#endif 2898#endif
2899 2899
2900#ifdef CONFIG_PM
2901 kfree(chip->saved_regs);
2902#endif
2903
2900 pci_disable_device(chip->pci); 2904 pci_disable_device(chip->pci);
2901 kfree(chip); 2905 kfree(chip);
2902 return 0; 2906 return 0;
@@ -3107,7 +3111,7 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3107 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); 3111 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n");
3108 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n"); 3112 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n");
3109 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n"); 3113 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n");
3110 snd_printk(KERN_ERR " this message please report to alsa-devel@lists.sourceforge.net\n"); 3114 snd_printk(KERN_ERR " this message please report to alsa-devel@alsa-project.org\n");
3111 3115
3112 return -EIO; 3116 return -EIO;
3113#endif 3117#endif
@@ -3140,6 +3144,23 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3140/* 3144/*
3141 * start and load DSP 3145 * start and load DSP
3142 */ 3146 */
3147
3148static void cs46xx_enable_stream_irqs(struct snd_cs46xx *chip)
3149{
3150 unsigned int tmp;
3151
3152 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_IEV | HICR_CHGM);
3153
3154 tmp = snd_cs46xx_peek(chip, BA1_PFIE);
3155 tmp &= ~0x0000f03f;
3156 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt enable */
3157
3158 tmp = snd_cs46xx_peek(chip, BA1_CIE);
3159 tmp &= ~0x0000003f;
3160 tmp |= 0x00000001;
3161 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt enable */
3162}
3163
3143int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip) 3164int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3144{ 3165{
3145 unsigned int tmp; 3166 unsigned int tmp;
@@ -3214,19 +3235,7 @@ int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3214 3235
3215 snd_cs46xx_proc_start(chip); 3236 snd_cs46xx_proc_start(chip);
3216 3237
3217 /* 3238 cs46xx_enable_stream_irqs(chip);
3218 * Enable interrupts on the part.
3219 */
3220 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_IEV | HICR_CHGM);
3221
3222 tmp = snd_cs46xx_peek(chip, BA1_PFIE);
3223 tmp &= ~0x0000f03f;
3224 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt enable */
3225
3226 tmp = snd_cs46xx_peek(chip, BA1_CIE);
3227 tmp &= ~0x0000003f;
3228 tmp |= 0x00000001;
3229 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt enable */
3230 3239
3231#ifndef CONFIG_SND_CS46XX_NEW_DSP 3240#ifndef CONFIG_SND_CS46XX_NEW_DSP
3232 /* set the attenuation to 0dB */ 3241 /* set the attenuation to 0dB */
@@ -3665,11 +3674,19 @@ static struct cs_card_type __devinitdata cards[] = {
3665 * APM support 3674 * APM support
3666 */ 3675 */
3667#ifdef CONFIG_PM 3676#ifdef CONFIG_PM
3677static unsigned int saved_regs[] = {
3678 BA0_ACOSV,
3679 BA0_ASER_FADDR,
3680 BA0_ASER_MASTER,
3681 BA1_PVOL,
3682 BA1_CVOL,
3683};
3684
3668int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state) 3685int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3669{ 3686{
3670 struct snd_card *card = pci_get_drvdata(pci); 3687 struct snd_card *card = pci_get_drvdata(pci);
3671 struct snd_cs46xx *chip = card->private_data; 3688 struct snd_cs46xx *chip = card->private_data;
3672 int amp_saved; 3689 int i, amp_saved;
3673 3690
3674 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3691 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
3675 chip->in_suspend = 1; 3692 chip->in_suspend = 1;
@@ -3680,6 +3697,10 @@ int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3680 snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); 3697 snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
3681 snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); 3698 snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
3682 3699
3700 /* save some registers */
3701 for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
3702 chip->saved_regs[i] = snd_cs46xx_peekBA0(chip, saved_regs[i]);
3703
3683 amp_saved = chip->amplifier; 3704 amp_saved = chip->amplifier;
3684 /* turn off amp */ 3705 /* turn off amp */
3685 chip->amplifier_ctrl(chip, -chip->amplifier); 3706 chip->amplifier_ctrl(chip, -chip->amplifier);
@@ -3698,7 +3719,7 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3698{ 3719{
3699 struct snd_card *card = pci_get_drvdata(pci); 3720 struct snd_card *card = pci_get_drvdata(pci);
3700 struct snd_cs46xx *chip = card->private_data; 3721 struct snd_cs46xx *chip = card->private_data;
3701 int amp_saved; 3722 int i, amp_saved;
3702 3723
3703 pci_set_power_state(pci, PCI_D0); 3724 pci_set_power_state(pci, PCI_D0);
3704 pci_restore_state(pci); 3725 pci_restore_state(pci);
@@ -3716,6 +3737,16 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3716 3737
3717 snd_cs46xx_chip_init(chip); 3738 snd_cs46xx_chip_init(chip);
3718 3739
3740 snd_cs46xx_reset(chip);
3741#ifdef CONFIG_SND_CS46XX_NEW_DSP
3742 cs46xx_dsp_resume(chip);
3743 /* restore some registers */
3744 for (i = 0; i < ARRAY_SIZE(saved_regs); i++)
3745 snd_cs46xx_pokeBA0(chip, saved_regs[i], chip->saved_regs[i]);
3746#else
3747 snd_cs46xx_download_image(chip);
3748#endif
3749
3719#if 0 3750#if 0
3720 snd_cs46xx_codec_write(chip, BA0_AC97_GENERAL_PURPOSE, 3751 snd_cs46xx_codec_write(chip, BA0_AC97_GENERAL_PURPOSE,
3721 chip->ac97_general_purpose); 3752 chip->ac97_general_purpose);
@@ -3730,6 +3761,13 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3730 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); 3761 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
3731 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); 3762 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
3732 3763
3764 /* reset playback/capture */
3765 snd_cs46xx_set_play_sample_rate(chip, 8000);
3766 snd_cs46xx_set_capture_sample_rate(chip, 8000);
3767 snd_cs46xx_proc_start(chip);
3768
3769 cs46xx_enable_stream_irqs(chip);
3770
3733 if (amp_saved) 3771 if (amp_saved)
3734 chip->amplifier_ctrl(chip, 1); /* turn amp on */ 3772 chip->amplifier_ctrl(chip, 1); /* turn amp on */
3735 else 3773 else
@@ -3896,6 +3934,15 @@ int __devinit snd_cs46xx_create(struct snd_card *card,
3896 3934
3897 snd_cs46xx_proc_init(card, chip); 3935 snd_cs46xx_proc_init(card, chip);
3898 3936
3937#ifdef CONFIG_PM
3938 chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
3939 ARRAY_SIZE(saved_regs), GFP_KERNEL);
3940 if (!chip->saved_regs) {
3941 snd_cs46xx_free(chip);
3942 return -ENOMEM;
3943 }
3944#endif
3945
3899 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 3946 chip->active_ctrl(chip, -1); /* disable CLKRUN */
3900 3947
3901 snd_card_set_dev(card, &pci->dev); 3948 snd_card_set_dev(card, &pci->dev);
diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h
index f75750c2bd2..20dcd72f06c 100644
--- a/sound/pci/cs46xx/cs46xx_lib.h
+++ b/sound/pci/cs46xx/cs46xx_lib.h
@@ -86,6 +86,9 @@ static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned
86struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip); 86struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
87void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip); 87void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
88int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module); 88int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
89#ifdef CONFIG_PM
90int cs46xx_dsp_resume(struct snd_cs46xx * chip);
91#endif
89struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, 92struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
90 int symbol_type); 93 int symbol_type);
91#ifdef CONFIG_PROC_FS 94#ifdef CONFIG_PROC_FS
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 336e77e2600..590b35d91df 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -306,13 +306,59 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)
306 mutex_unlock(&chip->spos_mutex); 306 mutex_unlock(&chip->spos_mutex);
307} 307}
308 308
309static int dsp_load_parameter(struct snd_cs46xx *chip,
310 struct dsp_segment_desc *parameter)
311{
312 u32 doffset, dsize;
313
314 if (!parameter) {
315 snd_printdd("dsp_spos: module got no parameter segment\n");
316 return 0;
317 }
318
319 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
320 dsize = parameter->size * 4;
321
322 snd_printdd("dsp_spos: "
323 "downloading parameter data to chip (%08x-%08x)\n",
324 doffset,doffset + dsize);
325 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
326 snd_printk(KERN_ERR "dsp_spos: "
327 "failed to download parameter data to DSP\n");
328 return -EINVAL;
329 }
330 return 0;
331}
332
333static int dsp_load_sample(struct snd_cs46xx *chip,
334 struct dsp_segment_desc *sample)
335{
336 u32 doffset, dsize;
337
338 if (!sample) {
339 snd_printdd("dsp_spos: module got no sample segment\n");
340 return 0;
341 }
342
343 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET);
344 dsize = sample->size * 4;
345
346 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
347 doffset,doffset + dsize);
348
349 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
350 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
351 return -EINVAL;
352 }
353 return 0;
354}
355
309int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) 356int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module)
310{ 357{
311 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 358 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
312 struct dsp_segment_desc * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM); 359 struct dsp_segment_desc * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM);
313 struct dsp_segment_desc * parameter = get_segment_desc (module,SEGTYPE_SP_PARAMETER);
314 struct dsp_segment_desc * sample = get_segment_desc (module,SEGTYPE_SP_SAMPLE);
315 u32 doffset, dsize; 360 u32 doffset, dsize;
361 int err;
316 362
317 if (ins->nmodules == DSP_MAX_MODULES - 1) { 363 if (ins->nmodules == DSP_MAX_MODULES - 1) {
318 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n"); 364 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n");
@@ -326,49 +372,20 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
326 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE); 372 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE);
327 } 373 }
328 374
329 if (parameter == NULL) { 375 err = dsp_load_parameter(chip, get_segment_desc(module,
330 snd_printdd("dsp_spos: module got no parameter segment\n"); 376 SEGTYPE_SP_PARAMETER));
331 } else { 377 if (err < 0)
332 if (ins->nmodules > 0) { 378 return err;
333 snd_printk(KERN_WARNING "dsp_spos: WARNING current parameter data may be overwriten!\n");
334 }
335
336 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
337 dsize = parameter->size * 4;
338
339 snd_printdd("dsp_spos: downloading parameter data to chip (%08x-%08x)\n",
340 doffset,doffset + dsize);
341
342 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
343 snd_printk(KERN_ERR "dsp_spos: failed to download parameter data to DSP\n");
344 return -EINVAL;
345 }
346 }
347 379
348 if (ins->nmodules == 0) { 380 if (ins->nmodules == 0) {
349 snd_printdd("dsp_spos: clearing sample area\n"); 381 snd_printdd("dsp_spos: clearing sample area\n");
350 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE); 382 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE);
351 } 383 }
352 384
353 if (sample == NULL) { 385 err = dsp_load_sample(chip, get_segment_desc(module,
354 snd_printdd("dsp_spos: module got no sample segment\n"); 386 SEGTYPE_SP_SAMPLE));
355 } else { 387 if (err < 0)
356 if (ins->nmodules > 0) { 388 return err;
357 snd_printk(KERN_WARNING "dsp_spos: WARNING current sample data may be overwriten\n");
358 }
359
360 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET);
361 dsize = sample->size * 4;
362
363 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n",
364 doffset,doffset + dsize);
365
366 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
367 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n");
368 return -EINVAL;
369 }
370 }
371
372 389
373 if (ins->nmodules == 0) { 390 if (ins->nmodules == 0) {
374 snd_printdd("dsp_spos: clearing code area\n"); 391 snd_printdd("dsp_spos: clearing code area\n");
@@ -986,7 +1003,10 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
986 return NULL; 1003 return NULL;
987 } 1004 }
988 1005
989 strcpy(ins->tasks[ins->ntask].task_name,name); 1006 if (name)
1007 strcpy(ins->tasks[ins->ntask].task_name, name);
1008 else
1009 strcpy(ins->tasks[ins->ntask].task_name, "(NULL)");
990 ins->tasks[ins->ntask].address = dest; 1010 ins->tasks[ins->ntask].address = dest;
991 ins->tasks[ins->ntask].size = size; 1011 ins->tasks[ins->ntask].size = size;
992 1012
@@ -995,7 +1015,8 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
995 desc = (ins->tasks + ins->ntask); 1015 desc = (ins->tasks + ins->ntask);
996 ins->ntask++; 1016 ins->ntask++;
997 1017
998 add_symbol (chip,name,dest,SYMBOL_PARAMETER); 1018 if (name)
1019 add_symbol (chip,name,dest,SYMBOL_PARAMETER);
999 return desc; 1020 return desc;
1000} 1021}
1001 1022
@@ -1006,6 +1027,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32
1006 1027
1007 desc = _map_scb (chip,name,dest); 1028 desc = _map_scb (chip,name,dest);
1008 if (desc) { 1029 if (desc) {
1030 desc->data = scb_data;
1009 _dsp_create_scb(chip,scb_data,dest); 1031 _dsp_create_scb(chip,scb_data,dest);
1010 } else { 1032 } else {
1011 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); 1033 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n");
@@ -1023,6 +1045,7 @@ cs46xx_dsp_create_task_tree (struct snd_cs46xx *chip, char * name, u32 * task_da
1023 1045
1024 desc = _map_task_tree (chip,name,dest,size); 1046 desc = _map_task_tree (chip,name,dest,size);
1025 if (desc) { 1047 if (desc) {
1048 desc->data = task_data;
1026 _dsp_create_task_tree(chip,task_data,dest,size); 1049 _dsp_create_task_tree(chip,task_data,dest,size);
1027 } else { 1050 } else {
1028 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n"); 1051 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n");
@@ -1320,8 +1343,10 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1320 0x0000ffff 1343 0x0000ffff
1321 }; 1344 };
1322 1345
1323 /* dirty hack ... */ 1346 if (!cs46xx_dsp_create_task_tree(chip, NULL,
1324 _dsp_create_task_tree (chip,(u32 *)&mix2_ostream_spb,WRITE_BACK_SPB,2); 1347 (u32 *)&mix2_ostream_spb,
1348 WRITE_BACK_SPB, 2))
1349 goto _fail_end;
1325 } 1350 }
1326 1351
1327 /* input sample converter */ 1352 /* input sample converter */
@@ -1622,7 +1647,6 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
1622 return 0; 1647 return 0;
1623} 1648}
1624 1649
1625
1626static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx *chip) 1650static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx *chip)
1627{ 1651{
1628 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1652 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -1894,3 +1918,61 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right)
1894 1918
1895 return 0; 1919 return 0;
1896} 1920}
1921
1922#ifdef CONFIG_PM
1923int cs46xx_dsp_resume(struct snd_cs46xx * chip)
1924{
1925 struct dsp_spos_instance * ins = chip->dsp_spos_instance;
1926 int i, err;
1927
1928 /* clear parameter, sample and code areas */
1929 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET,
1930 DSP_PARAMETER_BYTE_SIZE);
1931 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET,
1932 DSP_SAMPLE_BYTE_SIZE);
1933 snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE);
1934
1935 for (i = 0; i < ins->nmodules; i++) {
1936 struct dsp_module_desc *module = &ins->modules[i];
1937 struct dsp_segment_desc *seg;
1938 u32 doffset, dsize;
1939
1940 seg = get_segment_desc(module, SEGTYPE_SP_PARAMETER);
1941 err = dsp_load_parameter(chip, seg);
1942 if (err < 0)
1943 return err;
1944
1945 seg = get_segment_desc(module, SEGTYPE_SP_SAMPLE);
1946 err = dsp_load_sample(chip, seg);
1947 if (err < 0)
1948 return err;
1949
1950 seg = get_segment_desc(module, SEGTYPE_SP_PROGRAM);
1951 if (!seg)
1952 continue;
1953
1954 doffset = seg->offset * 4 + module->load_address * 4
1955 + DSP_CODE_BYTE_OFFSET;
1956 dsize = seg->size * 4;
1957 err = snd_cs46xx_download(chip,
1958 ins->code.data + module->load_address,
1959 doffset, dsize);
1960 if (err < 0)
1961 return err;
1962 }
1963
1964 for (i = 0; i < ins->ntask; i++) {
1965 struct dsp_task_descriptor *t = &ins->tasks[i];
1966 _dsp_create_task_tree(chip, t->data, t->address, t->size);
1967 }
1968
1969 for (i = 0; i < ins->nscb; i++) {
1970 struct dsp_scb_descriptor *s = &ins->scbs[i];
1971 if (s->deleted)
1972 continue;
1973 _dsp_create_scb(chip, s->data, s->address);
1974 }
1975
1976 return 0;
1977}
1978#endif
diff --git a/sound/pci/cs46xx/imgs/cwcemb80.h b/sound/pci/cs46xx/imgs/cwcemb80.h
deleted file mode 100644
index a64c6ff9983..00000000000
--- a/sound/pci/cs46xx/imgs/cwcemb80.h
+++ /dev/null
@@ -1,1607 +0,0 @@
1/* generated from cwcemb80.osp DO NOT MODIFY */
2
3#ifndef __HEADER_cwcemb80_H__
4#define __HEADER_cwcemb80_H__
5
6static struct dsp_symbol_entry cwcemb80_symbols[] = {
7 { 0x0000, "BEGINADDRESS",0x00 },
8 { 0x8000, "EXECCHILD",0x03 },
9 { 0x8001, "EXECCHILD_98",0x03 },
10 { 0x8003, "EXECCHILD_PUSH1IND",0x03 },
11 { 0x8008, "EXECSIBLING",0x03 },
12 { 0x800a, "EXECSIBLING_298",0x03 },
13 { 0x800b, "EXECSIBLING_2IND1",0x03 },
14 { 0x8010, "TIMINGMASTER",0x03 },
15 { 0x804f, "S16_CODECINPUTTASK",0x03 },
16 { 0x805e, "PCMSERIALINPUTTASK",0x03 },
17 { 0x806d, "S16_MIX_TO_OSTREAM",0x03 },
18 { 0x809a, "S16_MIX",0x03 },
19 { 0x80bb, "S16_UPSRC",0x03 },
20 { 0x813b, "MIX3_EXP",0x03 },
21 { 0x8164, "DECIMATEBYPOW2",0x03 },
22 { 0x8197, "VARIDECIMATE",0x03 },
23 { 0x81f2, "_3DINPUTTASK",0x03 },
24 { 0x820a, "_3DPRLGCINPTASK",0x03 },
25 { 0x8227, "_3DSTEREOINPUTTASK",0x03 },
26 { 0x8242, "_3DOUTPUTTASK",0x03 },
27 { 0x82c4, "HRTF_MORPH_TASK",0x03 },
28 { 0x82c6, "WAIT4DATA",0x03 },
29 { 0x82fa, "PROLOGIC",0x03 },
30 { 0x8496, "DECORRELATOR",0x03 },
31 { 0x84a4, "STEREO2MONO",0x03 },
32 { 0x0070, "SPOSCB",0x02 },
33 { 0x0105, "TASKTREETHREAD",0x03 },
34 { 0x0136, "TASKTREEHEADERCODE",0x03 },
35 { 0x013f, "FGTASKTREEHEADERCODE",0x03 },
36 { 0x0163, "NULLALGORITHM",0x03 },
37 { 0x0167, "HFGEXECCHILD",0x03 },
38 { 0x0168, "HFGEXECCHILD_98",0x03 },
39 { 0x016a, "HFGEXECCHILD_PUSH1IND",0x03 },
40 { 0x016d, "HFGEXECSIBLING",0x03 },
41 { 0x016f, "HFGEXECSIBLING_298",0x03 },
42 { 0x0170, "HFGEXECSIBLING_2IND1",0x03 },
43 { 0x0173, "S16_CODECOUTPUTTASK",0x03 },
44 { 0x018e, "#CODE_END",0x00 },
45}; /* cwcemb80 symbols */
46
47static u32 cwcemb80_code[] = {
48/* BEGINADDRESS */
49/* 0000 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
50/* 0002 */ 0x00001705,0x00001400,0x000a411e,0x00001003,
51/* 0004 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
52/* 0006 */ 0x00009705,0x00001400,0x000a411e,0x00001003,
53/* 0008 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
54/* 000A */ 0x00011705,0x00001400,0x000a411e,0x00001003,
55/* 000C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
56/* 000E */ 0x00019705,0x00001400,0x000a411e,0x00001003,
57/* 0010 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
58/* 0012 */ 0x00021705,0x00001400,0x000a411e,0x00001003,
59/* 0014 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
60/* 0016 */ 0x00029705,0x00001400,0x000a411e,0x00001003,
61/* 0018 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
62/* 001A */ 0x00031705,0x00001400,0x000a411e,0x00001003,
63/* 001C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
64/* 001E */ 0x00039705,0x00001400,0x000a411e,0x00001003,
65/* 0020 */ 0x000fe19e,0x00001003,0x0009c730,0x00001003,
66/* 0022 */ 0x0008e19c,0x00001003,0x000083c1,0x00093040,
67/* 0024 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
68/* 0026 */ 0x00009705,0x00001400,0x000a211e,0x00001003,
69/* 0028 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
70/* 002A */ 0x00011705,0x00001400,0x000a211e,0x00001003,
71/* 002C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
72/* 002E */ 0x00019705,0x00001400,0x000a211e,0x00001003,
73/* 0030 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
74/* 0032 */ 0x00021705,0x00001400,0x000a211e,0x00001003,
75/* 0034 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
76/* 0036 */ 0x00029705,0x00001400,0x000a211e,0x00001003,
77/* 0038 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
78/* 003A */ 0x00031705,0x00001400,0x000a211e,0x00001003,
79/* 003C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
80/* 003E */ 0x00039705,0x00001400,0x000a211e,0x00001003,
81/* 0040 */ 0x0000a730,0x00001008,0x000e2730,0x00001002,
82/* 0042 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
83/* 0044 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
84/* 0046 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
85/* 0048 */ 0x00000000,0x00000000,0x000f619c,0x00001003,
86/* 004A */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
87/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
88/* 004E */ 0x00000000,0x00000000,0x00000000,0x00000000,
89/* 0050 */ 0x00000000,0x000c0000,0x00000000,0x00000000,
90/* 0052 */ 0x0000373c,0x00001000,0x00000000,0x00000000,
91/* 0054 */ 0x000ee19c,0x00001003,0x0007f801,0x000c0000,
92/* 0056 */ 0x00000037,0x00001000,0x00000000,0x00000000,
93/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
94/* 005A */ 0x00000000,0x00000000,0x0000273c,0x00001000,
95/* 005C */ 0x00000033,0x00001000,0x000e679e,0x00001003,
96/* 005E */ 0x00007705,0x00001400,0x000ac71e,0x00001003,
97/* 0060 */ 0x00087fc1,0x000c3be0,0x0007f801,0x000c0000,
98/* 0062 */ 0x00000037,0x00001000,0x00000000,0x00000000,
99/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
100/* 0066 */ 0x00000000,0x00000000,0x0000a730,0x00001003,
101/* 0068 */ 0x00000033,0x00001000,0x0007f801,0x000c0000,
102/* 006A */ 0x00000037,0x00001000,0x00000000,0x00000000,
103/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
104/* 006E */ 0x00000000,0x00000000,0x00000000,0x000c0000,
105/* 0070 */ 0x00000032,0x00001000,0x0000273d,0x00001000,
106/* 0072 */ 0x0004a730,0x00001003,0x00000f41,0x00097140,
107/* 0074 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
108/* 0076 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
109/* 0078 */ 0x00000000,0x00000000,0x0001bf05,0x0003fc40,
110/* 007A */ 0x00002725,0x000aa400,0x00013705,0x00093a00,
111/* 007C */ 0x0000002e,0x0009d6c0,0x00038630,0x00001004,
112/* 007E */ 0x0004ef0a,0x000eb785,0x0003fc8a,0x00000000,
113/* 0080 */ 0x00000000,0x000c70e0,0x0007d182,0x0002c640,
114/* 0082 */ 0x00000630,0x00001004,0x000799b8,0x0002c6c0,
115/* 0084 */ 0x00031705,0x00092240,0x00039f05,0x000932c0,
116/* 0086 */ 0x0003520a,0x00000000,0x00040731,0x0000100b,
117/* 0088 */ 0x00010705,0x000b20c0,0x00000000,0x000eba44,
118/* 008A */ 0x00032108,0x000c60c4,0x00065208,0x000c2917,
119/* 008C */ 0x000406b0,0x00001007,0x00012f05,0x00036880,
120/* 008E */ 0x0002818e,0x000c0000,0x0004410a,0x00000000,
121/* 0090 */ 0x00040630,0x00001007,0x00029705,0x000c0000,
122/* 0092 */ 0x00000000,0x00000000,0x00003fc1,0x0003fc40,
123/* 0094 */ 0x000037c1,0x00091b40,0x00003fc1,0x000911c0,
124/* 0096 */ 0x000037c1,0x000957c0,0x00003fc1,0x000951c0,
125/* 0098 */ 0x000037c1,0x00000000,0x00003fc1,0x000991c0,
126/* 009A */ 0x000037c1,0x00000000,0x00003fc1,0x0009d1c0,
127/* 009C */ 0x000037c1,0x00000000,0x0001ccc1,0x000915c0,
128/* 009E */ 0x0001c441,0x0009d800,0x0009cdc1,0x00091240,
129/* 00A0 */ 0x0001c541,0x00091d00,0x0009cfc1,0x00095240,
130/* 00A2 */ 0x0001c741,0x00095c80,0x000e8ca9,0x00099240,
131/* 00A4 */ 0x000e85ad,0x00095640,0x00069ca9,0x00099d80,
132/* 00A6 */ 0x000e952d,0x00099640,0x000eaca9,0x0009d6c0,
133/* 00A8 */ 0x000ea5ad,0x00091a40,0x0006bca9,0x0009de80,
134/* 00AA */ 0x000eb52d,0x00095a40,0x000ecca9,0x00099ac0,
135/* 00AC */ 0x000ec5ad,0x0009da40,0x000edca9,0x0009d300,
136/* 00AE */ 0x000a6e0a,0x00001000,0x000ed52d,0x00091e40,
137/* 00B0 */ 0x000eeca9,0x00095ec0,0x000ee5ad,0x00099e40,
138/* 00B2 */ 0x0006fca9,0x00002500,0x000fb208,0x000c59a0,
139/* 00B4 */ 0x000ef52d,0x0009de40,0x00068ca9,0x000912c1,
140/* 00B6 */ 0x000683ad,0x00095241,0x00020f05,0x000991c1,
141/* 00B8 */ 0x00000000,0x00000000,0x00086f88,0x00001000,
142/* 00BA */ 0x0009cf81,0x000b5340,0x0009c701,0x000b92c0,
143/* 00BC */ 0x0009de81,0x000bd300,0x0009d601,0x000b1700,
144/* 00BE */ 0x0001fd81,0x000b9d80,0x0009f501,0x000b57c0,
145/* 00C0 */ 0x000a0f81,0x000bd740,0x00020701,0x000b5c80,
146/* 00C2 */ 0x000a1681,0x000b97c0,0x00021601,0x00002500,
147/* 00C4 */ 0x000a0701,0x000b9b40,0x000a0f81,0x000b1bc0,
148/* 00C6 */ 0x00021681,0x00002d00,0x00020f81,0x000bd800,
149/* 00C8 */ 0x000a0701,0x000b5bc0,0x00021601,0x00003500,
150/* 00CA */ 0x000a0f81,0x000b5f40,0x000a0701,0x000bdbc0,
151/* 00CC */ 0x00021681,0x00003d00,0x00020f81,0x000b1d00,
152/* 00CE */ 0x000a0701,0x000b1fc0,0x00021601,0x00020500,
153/* 00D0 */ 0x00020f81,0x000b1341,0x000a0701,0x000b9fc0,
154/* 00D2 */ 0x00021681,0x00020d00,0x00020f81,0x000bde80,
155/* 00D4 */ 0x000a0701,0x000bdfc0,0x00021601,0x00021500,
156/* 00D6 */ 0x00020f81,0x000b9341,0x00020701,0x000b53c1,
157/* 00D8 */ 0x00021681,0x00021d00,0x000a0f81,0x000d0380,
158/* 00DA */ 0x0000b601,0x000b15c0,0x00007b01,0x00000000,
159/* 00DC */ 0x00007b81,0x000bd1c0,0x00007b01,0x00000000,
160/* 00DE */ 0x00007b81,0x000b91c0,0x00007b01,0x000b57c0,
161/* 00E0 */ 0x00007b81,0x000b51c0,0x00007b01,0x000b1b40,
162/* 00E2 */ 0x00007b81,0x000b11c0,0x00087b01,0x000c3dc0,
163/* 00E4 */ 0x0007e488,0x000d7e45,0x00000000,0x000d7a44,
164/* 00E6 */ 0x0007e48a,0x00000000,0x00011f05,0x00084080,
165/* 00E8 */ 0x00000000,0x00000000,0x00001705,0x000b3540,
166/* 00EA */ 0x00008a01,0x000bf040,0x00007081,0x000bb5c0,
167/* 00EC */ 0x00055488,0x00000000,0x0000d482,0x0003fc40,
168/* 00EE */ 0x0003fc88,0x00000000,0x0001e401,0x000b3a00,
169/* 00F0 */ 0x0001ec81,0x000bd6c0,0x0004ef08,0x000eb784,
170/* 00F2 */ 0x000c86b0,0x00001007,0x00008281,0x000bb240,
171/* 00F4 */ 0x0000b801,0x000b7140,0x00007888,0x00000000,
172/* 00F6 */ 0x0000073c,0x00001000,0x0007f188,0x000c0000,
173/* 00F8 */ 0x00000000,0x00000000,0x00055288,0x000c555c,
174/* 00FA */ 0x0005528a,0x000c0000,0x0009fa88,0x000c5d00,
175/* 00FC */ 0x0000fa88,0x00000000,0x00000032,0x00001000,
176/* 00FE */ 0x0000073d,0x00001000,0x0007f188,0x000c0000,
177/* 0100 */ 0x00000000,0x00000000,0x0008c01c,0x00001003,
178/* 0102 */ 0x00002705,0x00001008,0x0008b201,0x000c1392,
179/* 0104 */ 0x0000ba01,0x00000000,
180/* TASKTREETHREAD */
181/* 0105 */ 0x00008731,0x00001400,0x0004c108,0x000fe0c4,
182/* 0107 */ 0x00057488,0x00000000,0x000a6388,0x00001001,
183/* 0109 */ 0x0008b334,0x000bc141,0x0003020e,0x00000000,
184/* 010B */ 0x000886b0,0x00001008,0x00003625,0x000c5dfa,
185/* 010D */ 0x000a638a,0x00001001,0x0008020e,0x00001002,
186/* 010F */ 0x0008a6b0,0x00001008,0x0007f301,0x00000000,
187/* 0111 */ 0x00000000,0x00000000,0x00002725,0x000a8c40,
188/* 0113 */ 0x000000ae,0x00000000,0x000d8630,0x00001008,
189/* 0115 */ 0x00000000,0x000c74e0,0x0007d182,0x0002d640,
190/* 0117 */ 0x000a8630,0x00001008,0x000799b8,0x0002d6c0,
191/* 0119 */ 0x0000748a,0x000c3ec5,0x0007420a,0x000c0000,
192/* 011B */ 0x00062208,0x000c4117,0x00070630,0x00001009,
193/* 011D */ 0x00000000,0x000c0000,0x0001022e,0x00000000,
194/* 011F */ 0x0003a630,0x00001009,0x00000000,0x000c0000,
195/* 0121 */ 0x00000036,0x00001000,0x00000000,0x00000000,
196/* 0123 */ 0x00000000,0x00000000,0x00000000,0x00000000,
197/* 0125 */ 0x00000000,0x00000000,0x0002a730,0x00001008,
198/* 0127 */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
199/* 0129 */ 0x00000000,0x00000000,0x00000000,0x00000000,
200/* 012B */ 0x00000000,0x00000000,0x00000000,0x00000000,
201/* 012D */ 0x0002a730,0x00001008,0x00000033,0x00001000,
202/* 012F */ 0x0002a705,0x00001008,0x00007a01,0x000c0000,
203/* 0131 */ 0x000e6288,0x000d550a,0x0006428a,0x00000000,
204/* 0133 */ 0x00060730,0x0000100a,0x00000000,0x000c0000,
205/* 0135 */ 0x00000000,0x00000000,
206/* TASKTREEHEADERCODE */
207/* 0136 */ 0x0007aab0,0x00034880,0x00078fb0,0x0000100b,
208/* 0138 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
209/* 013A */ 0x000183ae,0x00000000,0x000786b0,0x0000100b,
210/* 013C */ 0x00022f05,0x000c3545,0x0000eb8a,0x00000000,
211/* 013E */ 0x00042731,0x00001003,
212/* FGTASKTREEHEADERCODE */
213/* 013F */ 0x0007aab0,0x00034880,0x00048fb0,0x0000100a,
214/* 0141 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
215/* 0143 */ 0x000183ae,0x00000000,0x000806b0,0x0000100b,
216/* 0145 */ 0x00022f05,0x00000000,0x00007401,0x00091140,
217/* 0147 */ 0x00048f05,0x000951c0,0x00042731,0x00001003,
218/* 0149 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
219/* 014B */ 0x00080000,0x000bffc7,0x000fe19e,0x00001003,
220/* 014D */ 0x00000000,0x00000000,0x0008e19c,0x00001003,
221/* 014F */ 0x000083c1,0x00093040,0x00000f41,0x00097140,
222/* 0151 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
223/* 0153 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
224/* 0155 */ 0x00000000,0x000fdc44,0x00055208,0x00000000,
225/* 0157 */ 0x00010705,0x000a2880,0x0000a23a,0x00093a00,
226/* 0159 */ 0x0003fc8a,0x000df6c5,0x0004ef0a,0x000c0000,
227/* 015B */ 0x00012f05,0x00036880,0x00065308,0x000c2997,
228/* 015D */ 0x000d86b0,0x0000100a,0x0004410a,0x000d40c7,
229/* 015F */ 0x00000000,0x00000000,0x00080730,0x00001004,
230/* 0161 */ 0x00056f0a,0x000ea105,0x00000000,0x00000000,
231/* NULLALGORITHM */
232/* 0163 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
233/* 0165 */ 0x00080000,0x000bffc7,0x0000273d,0x00001000,
234/* HFGEXECCHILD */
235/* 0167 */ 0x00000000,0x000eba44,
236/* HFGEXECCHILD_98 */
237/* 0168 */ 0x00048f05,0x0000f440,0x00007401,0x0000f7c0,
238/* HFGEXECCHILD_PUSH1IND */
239/* 016A */ 0x00000734,0x00001000,0x00010705,0x000a6880,
240/* 016C */ 0x00006a88,0x000c75c4,
241/* HFGEXECSIBLING */
242/* 016D */ 0x00000000,0x000e5084,0x00000000,0x000eba44,
243/* HFGEXECSIBLING_298 */
244/* 016F */ 0x00087401,0x000e4782,
245/* HFGEXECSIBLING_2IND1 */
246/* 0170 */ 0x00000734,0x00001000,0x00010705,0x000a6880,
247/* 0172 */ 0x00006a88,0x000c75c4,
248/* S16_CODECOUTPUTTASK */
249/* 0173 */ 0x0007c108,0x000c0000,0x0007e721,0x000bed40,
250/* 0175 */ 0x00005f25,0x000badc0,0x0003ba97,0x000beb80,
251/* 0177 */ 0x00065590,0x000b2e00,0x00033217,0x00003ec0,
252/* 0179 */ 0x00065590,0x000b8e40,0x0003ed80,0x000491c0,
253/* 017B */ 0x00073fb0,0x00074c80,0x000283a0,0x0000100c,
254/* 017D */ 0x000ee388,0x00042970,0x00008301,0x00021ef2,
255/* 017F */ 0x000b8f14,0x0000000f,0x000c4d8d,0x0000001b,
256/* 0181 */ 0x000d6dc2,0x000e06c6,0x000032ac,0x000c3916,
257/* 0183 */ 0x0004edc2,0x00074c80,0x00078898,0x00001000,
258/* 0185 */ 0x00038894,0x00000032,0x000c4d8d,0x00092e1b,
259/* 0187 */ 0x000d6dc2,0x000e06c6,0x0004edc2,0x000c1956,
260/* 0189 */ 0x0000722c,0x00034a00,0x00041705,0x0009ed40,
261/* 018B */ 0x00058730,0x00001400,0x000d7488,0x000c3a00,
262/* 018D */ 0x00048f05,0x00000000
263};
264/* #CODE_END */
265
266static u32 cwcemb80_parameter[] = {
267/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
268/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
269/* 0008 */ 0x00000000,0x00000000,0x00000163,0x00000000,
270/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
271/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
272/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
273/* 0018 */ 0x00000000,0x00200040,0x00008010,0x00000000,
274/* 001C */ 0x00000000,0x80000001,0x00000001,0x00060000,
275/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
276/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
277/* 0028 */ 0x00000000,0x00900080,0x00000173,0x00000000,
278/* 002C */ 0x00000000,0x00000010,0x00800000,0x00900000,
279/* 0030 */ 0xf2c0000f,0x00000200,0x00000000,0x00010600,
280/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
281/* 0038 */ 0x00000000,0x00000000,0x00000163,0x330300c2,
282/* 003C */ 0x06000000,0x00000000,0x80008000,0x80008000,
283/* 0040 */ 0x3fc0000f,0x00000301,0x00010400,0x00000000,
284/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
285/* 0048 */ 0x00000000,0x00b00000,0x00d0806d,0x330480c3,
286/* 004C */ 0x04800000,0x00000001,0x00800001,0x0000ffff,
287/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
288/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
289/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
290/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
291/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
292/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
293/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
294/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
295/* 0070 */ 0x066a0600,0x06350070,0x0000929d,0x929d929d,
296/* 0074 */ 0x00000000,0x0000735a,0x00000600,0x00000000,
297/* 0078 */ 0x929d735a,0x00000000,0x00010000,0x735a735a,
298/* 007C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
299/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
300/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
301/* 0088 */ 0x00000000,0x00000000,0x0000804f,0x000000c3,
302/* 008C */ 0x05000000,0x00a00010,0x00000000,0x80008000,
303/* 0090 */ 0x00000000,0x00000000,0x00000700,0x00000000,
304/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
305/* 0098 */ 0x00000080,0x00a00000,0x0000809a,0x000000c2,
306/* 009C */ 0x07400000,0x00000000,0x80008000,0xffffffff,
307/* 00A0 */ 0x00c80028,0x00005555,0x00000000,0x000107a0,
308/* 00A4 */ 0x00c80028,0x000000c2,0x06800000,0x00000000,
309/* 00A8 */ 0x06e00080,0x00300000,0x000080bb,0x000000c9,
310/* 00AC */ 0x07a00000,0x04000000,0x80008000,0xffffffff,
311/* 00B0 */ 0x00c80028,0x00005555,0x00000000,0x00000780,
312/* 00B4 */ 0x00c80028,0x000000c5,0xff800000,0x00000000,
313/* 00B8 */ 0x00640080,0x00c00000,0x00008197,0x000000c9,
314/* 00BC */ 0x07800000,0x04000000,0x80008000,0xffffffff,
315/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
316/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
317/* 00C8 */ 0x00000000,0x00000000,0x0000805e,0x000000c1,
318/* 00CC */ 0x00000000,0x00800000,0x80008000,0x80008000,
319/* 00D0 */ 0x00020000,0x0000ffff,0x00000000,0x00000000,
320/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
321/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
322/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
323/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
324/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
325/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
326/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
327/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
328/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
329/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
330/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
331/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
332/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
333/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
334/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
335/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
336/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
337/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
338/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
339/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
340/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
341/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
342/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
343/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
344/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
345/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
346/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
347/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
348/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
349/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
350/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
351/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
352/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
353/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
354/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
355/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
356/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
357/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
358/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
359/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
360/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
361/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
362/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
363/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
364/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
365/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
366/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
367/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
368/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
369/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
370/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
371/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
372/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
373/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
374/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
375/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
376/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
377/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
378/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
379/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
380/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
381/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
382/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
383/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
384/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
385/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
386/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
387/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
388/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
389/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
390/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
391/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
392/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
393/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
394/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
395/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
396/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
397/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
398/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
399/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
400/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
401/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
402/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
403/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
404/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
405/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
406/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
407/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
408/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
409/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
410/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
411/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
412/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
413/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
414/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
415/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
416/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
417/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
418/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
419/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
420/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
421/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
422/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
423/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
424/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
425/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
426/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
427/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
428/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
429/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
430/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
431/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
432/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
433/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
434/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
435/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
436/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
437/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
438/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
439/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
440/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
441/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
442/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
443/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
444/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
445/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
446/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
447/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
448/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
449/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
450/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
451/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
452/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
453/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
454/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
455/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
456/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
457/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
458/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
459/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
460/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
461/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
462/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
463/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
464/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
465/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
466/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
467/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
468/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
469/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
470/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
471/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
472/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
473/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
474/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
475/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
476/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
477/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
478/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
479/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
480/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
481/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
482/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
483/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
484/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
485/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
486/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
487/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
488/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
489/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
490/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
491/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
492/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
493/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
494/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
495/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
496/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
497/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
498/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
499/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
500/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
501/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
502/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
503/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
504/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
505/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
506/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
507/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
508/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
509/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
510/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
511/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
512/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
513/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
514/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
515/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
516/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
517/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
518/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
519/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
520/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
521/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
522/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
523/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
524/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
525/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
526/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
527/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
528/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
529/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
530/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
531/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
532/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
533/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
534/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
535/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
536/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
537/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
538/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
539/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
540/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
541/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
542/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
543/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
544/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
545/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
546/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
547/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
548/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
549/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
550/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
551/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
552/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
553/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
554/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
555/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
556/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
557/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
558/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
559/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
560/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
561/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
562/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
563/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
564/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
565/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
566/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
567/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
568/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
569/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
570/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
571/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
572/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
573/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
574/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
575/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
576/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
577/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
578/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
579/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
580/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
581/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
582/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
583/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
584/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
585/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
586/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
587/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
588/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
589/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
590/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
591/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
592/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
593/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
594/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
595/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
596/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
597/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
598/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
599/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
600/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
601/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
602/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
603/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
604/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
605/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
606/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
607/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
608/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
609/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
610/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
611/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
612/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
613/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
614/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
615/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
616/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
617/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
618/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
619/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
620/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
621/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
622/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
623/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
624/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
625/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
626/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
627/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
628/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
629/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
630/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
631/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
632/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
633/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
634/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
635/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
636/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
637/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
638/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
639/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
640/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
641/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
642/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
643/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
644/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
645/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
646/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
647/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
648/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
649/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
650/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
651/* 0600 */ 0x929d0600,0x929d929d,0x929d929d,0x929d0000,
652/* 0604 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
653/* 0608 */ 0x929d929d,0x00100635,0x060b013f,0x00000004,
654/* 060C */ 0x00000001,0x007a0002,0x00000000,0x066e0610,
655/* 0610 */ 0x0105929d,0x929d929d,0x929d929d,0x929d929d,
656/* 0614 */ 0x929d929d,0xa431ac75,0x0001735a,0xa431ac75,
657/* 0618 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
658/* 061C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
659/* 0620 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
660/* 0624 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
661/* 0628 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
662/* 062C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
663/* 0630 */ 0xa431ac75,0xa431ac75,0xa431ac75,0x735a0051,
664/* 0634 */ 0x00000000,0x929d929d,0x929d929d,0x929d929d,
665/* 0638 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
666/* 063C */ 0x929d929d,0x929d929d,0x00000000,0x06400136,
667/* 0640 */ 0x0000270f,0x00010000,0x007a0000,0x00000000,
668/* 0644 */ 0x068e0645,0x0105929d,0x929d929d,0x929d929d,
669/* 0648 */ 0x929d929d,0x929d929d,0xa431ac75,0x0001735a,
670/* 064C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
671/* 0650 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
672/* 0654 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
673/* 0658 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
674/* 065C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
675/* 0660 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
676/* 0664 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
677/* 0668 */ 0x735a0100,0x00000000,0x00000000,0x00000000,
678/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
679/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
680/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
681/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
682/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
683/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
684/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
685/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
686/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
687/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
688/* 0694 */ 0x00000000,0x00000000,0x00000000
689}; /* #PARAMETER_END */
690
691static u32 cwcemb80_sample[] = {
692/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
693/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
694/* 0008 */ 0x00000000,0x00000000,0x00000000,0x00000000,
695/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
696/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
697/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
698/* 0018 */ 0x00000000,0x00000000,0x00000000,0x00000000,
699/* 001C */ 0x00000000,0x00000000,0x00000000,0x00000000,
700/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
701/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
702/* 0028 */ 0x00000000,0x00000000,0x00000000,0x00000000,
703/* 002C */ 0x00000000,0x00000000,0x00000000,0x00000000,
704/* 0030 */ 0x00000000,0x00000000,0x00000000,0x00000000,
705/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
706/* 0038 */ 0x00000000,0x00000000,0x00000000,0x00000000,
707/* 003C */ 0x00000000,0x00000000,0x00000000,0x00000000,
708/* 0040 */ 0x00000000,0x00000000,0x00000000,0x00000000,
709/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
710/* 0048 */ 0x00000000,0x00000000,0x00000000,0x00000000,
711/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
712/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
713/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
714/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
715/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
716/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
717/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
718/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
719/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
720/* 0070 */ 0x00000000,0x00000000,0x00000000,0x00000000,
721/* 0074 */ 0x00000000,0x00000000,0x00000000,0x00000000,
722/* 0078 */ 0x00000000,0x00000000,0x00000000,0x00000000,
723/* 007C */ 0x00000000,0x00000000,0x00000000,0x00000000,
724/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
725/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
726/* 0088 */ 0x00000000,0x00000000,0x00000000,0x00000000,
727/* 008C */ 0x00000000,0x00000000,0x00000000,0x00000000,
728/* 0090 */ 0x00000000,0x00000000,0x00000000,0x00000000,
729/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
730/* 0098 */ 0x00000000,0x00000000,0x00000000,0x00000000,
731/* 009C */ 0x00000000,0x00000000,0x00000000,0x00000000,
732/* 00A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
733/* 00A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
734/* 00A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
735/* 00AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
736/* 00B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
737/* 00B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
738/* 00B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
739/* 00BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
740/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
741/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
742/* 00C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
743/* 00CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
744/* 00D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
745/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
746/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
747/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
748/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
749/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
750/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
751/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
752/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
753/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
754/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
755/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
756/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
757/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
758/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
759/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
760/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
761/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
762/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
763/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
764/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
765/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
766/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
767/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
768/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
769/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
770/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
771/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
772/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
773/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
774/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
775/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
776/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
777/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
778/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
779/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
780/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
781/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
782/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
783/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
784/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
785/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
786/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
787/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
788/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
789/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
790/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
791/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
792/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
793/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
794/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
795/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
796/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
797/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
798/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
799/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
800/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
801/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
802/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
803/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
804/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
805/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
806/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
807/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
808/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
809/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
810/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
811/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
812/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
813/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
814/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
815/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
816/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
817/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
818/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
819/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
820/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
821/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
822/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
823/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
824/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
825/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
826/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
827/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
828/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
829/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
830/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
831/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
832/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
833/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
834/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
835/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
836/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
837/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
838/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
839/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
840/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
841/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
842/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
843/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
844/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
845/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
846/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
847/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
848/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
849/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
850/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
851/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
852/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
853/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
854/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
855/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
856/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
857/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
858/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
859/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
860/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
861/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
862/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
863/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
864/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
865/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
866/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
867/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
868/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
869/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
870/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
871/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
872/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
873/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
874/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
875/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
876/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
877/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
878/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
879/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
880/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
881/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
882/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
883/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
884/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
885/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
886/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
887/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
888/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
889/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
890/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
891/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
892/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
893/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
894/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
895/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
896/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
897/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
898/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
899/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
900/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
901/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
902/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
903/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
904/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
905/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
906/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
907/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
908/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
909/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
910/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
911/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
912/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
913/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
914/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
915/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
916/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
917/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
918/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
919/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
920/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
921/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
922/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
923/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
924/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
925/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
926/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
927/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
928/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
929/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
930/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
931/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
932/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
933/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
934/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
935/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
936/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
937/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
938/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
939/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
940/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
941/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
942/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
943/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
944/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
945/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
946/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
947/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
948/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
949/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
950/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
951/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
952/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
953/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
954/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
955/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
956/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
957/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
958/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
959/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
960/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
961/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
962/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
963/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
964/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
965/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
966/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
967/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
968/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
969/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
970/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
971/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
972/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
973/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
974/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
975/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
976/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
977/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
978/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
979/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
980/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
981/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
982/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
983/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
984/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
985/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
986/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
987/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
988/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
989/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
990/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
991/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
992/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
993/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
994/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
995/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
996/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
997/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
998/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
999/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1000/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1001/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1002/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1003/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1004/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1005/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1006/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1007/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1008/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1009/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1010/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1011/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1012/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1013/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1014/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1015/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1016/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1017/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1018/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1019/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1020/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1021/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1022/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1023/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1024/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1025/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1026/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1027/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1028/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1029/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1030/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1031/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1032/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1033/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1034/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1035/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1036/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1037/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1038/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1039/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1040/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1041/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1042/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1043/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1044/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1045/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1046/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1047/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1048/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1049/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1050/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1051/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1052/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1053/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1054/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1055/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1056/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1057/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1058/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1059/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1060/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1061/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1062/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1063/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1064/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1065/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1066/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1067/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1068/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1069/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1070/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1071/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1072/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1073/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1074/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1075/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1076/* 0600 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1077/* 0604 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1078/* 0608 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1079/* 060C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1080/* 0610 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1081/* 0614 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1082/* 0618 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1083/* 061C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1084/* 0620 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1085/* 0624 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1086/* 0628 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1087/* 062C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1088/* 0630 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1089/* 0634 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1090/* 0638 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1091/* 063C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1092/* 0640 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1093/* 0644 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1094/* 0648 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1095/* 064C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1096/* 0650 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1097/* 0654 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1098/* 0658 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1099/* 065C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1100/* 0660 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1101/* 0664 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1102/* 0668 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1103/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1104/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1105/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1106/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1107/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1108/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1109/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1110/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1111/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1112/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1113/* 0694 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1114/* 0698 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1115/* 069C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1116/* 06A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1117/* 06A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1118/* 06A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1119/* 06AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1120/* 06B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1121/* 06B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1122/* 06B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1123/* 06BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1124/* 06C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1125/* 06C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1126/* 06C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1127/* 06CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1128/* 06D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1129/* 06D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1130/* 06D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1131/* 06DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1132/* 06E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1133/* 06E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1134/* 06E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1135/* 06EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1136/* 06F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1137/* 06F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1138/* 06F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1139/* 06FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1140/* 0700 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1141/* 0704 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1142/* 0708 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1143/* 070C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1144/* 0710 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1145/* 0714 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1146/* 0718 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1147/* 071C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1148/* 0720 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1149/* 0724 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1150/* 0728 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1151/* 072C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1152/* 0730 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1153/* 0734 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1154/* 0738 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1155/* 073C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1156/* 0740 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1157/* 0744 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1158/* 0748 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1159/* 074C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1160/* 0750 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1161/* 0754 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1162/* 0758 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1163/* 075C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1164/* 0760 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1165/* 0764 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1166/* 0768 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1167/* 076C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1168/* 0770 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1169/* 0774 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1170/* 0778 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1171/* 077C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1172/* 0780 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1173/* 0784 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1174/* 0788 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1175/* 078C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1176/* 0790 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1177/* 0794 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1178/* 0798 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1179/* 079C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1180/* 07A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1181/* 07A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1182/* 07A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1183/* 07AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1184/* 07B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1185/* 07B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1186/* 07B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1187/* 07BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1188/* 07C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1189/* 07C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1190/* 07C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1191/* 07CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1192/* 07D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1193/* 07D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1194/* 07D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1195/* 07DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1196/* 07E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1197/* 07E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1198/* 07E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1199/* 07EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1200/* 07F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1201/* 07F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1202/* 07F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1203/* 07FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1204/* 0800 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1205/* 0804 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1206/* 0808 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1207/* 080C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1208/* 0810 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1209/* 0814 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1210/* 0818 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1211/* 081C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1212/* 0820 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1213/* 0824 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1214/* 0828 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1215/* 082C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1216/* 0830 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1217/* 0834 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1218/* 0838 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1219/* 083C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1220/* 0840 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1221/* 0844 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1222/* 0848 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1223/* 084C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1224/* 0850 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1225/* 0854 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1226/* 0858 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1227/* 085C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1228/* 0860 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1229/* 0864 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1230/* 0868 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1231/* 086C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1232/* 0870 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1233/* 0874 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1234/* 0878 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1235/* 087C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1236/* 0880 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1237/* 0884 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1238/* 0888 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1239/* 088C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1240/* 0890 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1241/* 0894 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1242/* 0898 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1243/* 089C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1244/* 08A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1245/* 08A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1246/* 08A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1247/* 08AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1248/* 08B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1249/* 08B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1250/* 08B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1251/* 08BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1252/* 08C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1253/* 08C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1254/* 08C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1255/* 08CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1256/* 08D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1257/* 08D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1258/* 08D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1259/* 08DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1260/* 08E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1261/* 08E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1262/* 08E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1263/* 08EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1264/* 08F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1265/* 08F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1266/* 08F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1267/* 08FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1268/* 0900 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1269/* 0904 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1270/* 0908 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1271/* 090C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1272/* 0910 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1273/* 0914 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1274/* 0918 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1275/* 091C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1276/* 0920 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1277/* 0924 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1278/* 0928 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1279/* 092C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1280/* 0930 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1281/* 0934 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1282/* 0938 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1283/* 093C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1284/* 0940 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1285/* 0944 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1286/* 0948 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1287/* 094C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1288/* 0950 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1289/* 0954 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1290/* 0958 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1291/* 095C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1292/* 0960 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1293/* 0964 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1294/* 0968 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1295/* 096C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1296/* 0970 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1297/* 0974 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1298/* 0978 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1299/* 097C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1300/* 0980 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1301/* 0984 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1302/* 0988 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1303/* 098C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1304/* 0990 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1305/* 0994 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1306/* 0998 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1307/* 099C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1308/* 09A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1309/* 09A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1310/* 09A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1311/* 09AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1312/* 09B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1313/* 09B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1314/* 09B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1315/* 09BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1316/* 09C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1317/* 09C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1318/* 09C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1319/* 09CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1320/* 09D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1321/* 09D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1322/* 09D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1323/* 09DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1324/* 09E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1325/* 09E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1326/* 09E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1327/* 09EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1328/* 09F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1329/* 09F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1330/* 09F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1331/* 09FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1332/* 0A00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1333/* 0A04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1334/* 0A08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1335/* 0A0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1336/* 0A10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1337/* 0A14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1338/* 0A18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1339/* 0A1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1340/* 0A20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1341/* 0A24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1342/* 0A28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1343/* 0A2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1344/* 0A30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1345/* 0A34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1346/* 0A38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1347/* 0A3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1348/* 0A40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1349/* 0A44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1350/* 0A48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1351/* 0A4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1352/* 0A50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1353/* 0A54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1354/* 0A58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1355/* 0A5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1356/* 0A60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1357/* 0A64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1358/* 0A68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1359/* 0A6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1360/* 0A70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1361/* 0A74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1362/* 0A78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1363/* 0A7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1364/* 0A80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1365/* 0A84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1366/* 0A88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1367/* 0A8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1368/* 0A90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1369/* 0A94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1370/* 0A98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1371/* 0A9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1372/* 0AA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1373/* 0AA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1374/* 0AA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1375/* 0AAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1376/* 0AB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1377/* 0AB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1378/* 0AB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1379/* 0ABC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1380/* 0AC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1381/* 0AC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1382/* 0AC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1383/* 0ACC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1384/* 0AD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1385/* 0AD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1386/* 0AD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1387/* 0ADC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1388/* 0AE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1389/* 0AE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1390/* 0AE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1391/* 0AEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1392/* 0AF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1393/* 0AF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1394/* 0AF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1395/* 0AFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1396/* 0B00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1397/* 0B04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1398/* 0B08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1399/* 0B0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1400/* 0B10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1401/* 0B14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1402/* 0B18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1403/* 0B1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1404/* 0B20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1405/* 0B24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1406/* 0B28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1407/* 0B2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1408/* 0B30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1409/* 0B34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1410/* 0B38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1411/* 0B3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1412/* 0B40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1413/* 0B44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1414/* 0B48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1415/* 0B4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1416/* 0B50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1417/* 0B54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1418/* 0B58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1419/* 0B5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1420/* 0B60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1421/* 0B64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1422/* 0B68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1423/* 0B6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1424/* 0B70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1425/* 0B74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1426/* 0B78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1427/* 0B7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1428/* 0B80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1429/* 0B84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1430/* 0B88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1431/* 0B8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1432/* 0B90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1433/* 0B94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1434/* 0B98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1435/* 0B9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1436/* 0BA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1437/* 0BA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1438/* 0BA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1439/* 0BAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1440/* 0BB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1441/* 0BB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1442/* 0BB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1443/* 0BBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1444/* 0BC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1445/* 0BC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1446/* 0BC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1447/* 0BCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1448/* 0BD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1449/* 0BD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1450/* 0BD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1451/* 0BDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1452/* 0BE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1453/* 0BE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1454/* 0BE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1455/* 0BEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1456/* 0BF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1457/* 0BF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1458/* 0BF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1459/* 0BFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1460/* 0C00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1461/* 0C04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1462/* 0C08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1463/* 0C0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1464/* 0C10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1465/* 0C14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1466/* 0C18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1467/* 0C1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1468/* 0C20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1469/* 0C24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1470/* 0C28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1471/* 0C2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1472/* 0C30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1473/* 0C34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1474/* 0C38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1475/* 0C3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1476/* 0C40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1477/* 0C44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1478/* 0C48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1479/* 0C4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1480/* 0C50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1481/* 0C54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1482/* 0C58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1483/* 0C5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1484/* 0C60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1485/* 0C64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1486/* 0C68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1487/* 0C6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1488/* 0C70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1489/* 0C74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1490/* 0C78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1491/* 0C7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1492/* 0C80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1493/* 0C84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1494/* 0C88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1495/* 0C8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1496/* 0C90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1497/* 0C94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1498/* 0C98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1499/* 0C9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1500/* 0CA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1501/* 0CA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1502/* 0CA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1503/* 0CAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1504/* 0CB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1505/* 0CB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1506/* 0CB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1507/* 0CBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1508/* 0CC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1509/* 0CC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1510/* 0CC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1511/* 0CCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1512/* 0CD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1513/* 0CD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1514/* 0CD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1515/* 0CDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1516/* 0CE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1517/* 0CE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1518/* 0CE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1519/* 0CEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1520/* 0CF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1521/* 0CF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1522/* 0CF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1523/* 0CFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1524/* 0D00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1525/* 0D04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1526/* 0D08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1527/* 0D0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1528/* 0D10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1529/* 0D14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1530/* 0D18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1531/* 0D1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1532/* 0D20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1533/* 0D24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1534/* 0D28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1535/* 0D2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1536/* 0D30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1537/* 0D34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1538/* 0D38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1539/* 0D3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1540/* 0D40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1541/* 0D44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1542/* 0D48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1543/* 0D4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1544/* 0D50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1545/* 0D54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1546/* 0D58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1547/* 0D5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1548/* 0D60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1549/* 0D64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1550/* 0D68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1551/* 0D6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1552/* 0D70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1553/* 0D74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1554/* 0D78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1555/* 0D7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1556/* 0D80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1557/* 0D84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1558/* 0D88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1559/* 0D8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1560/* 0D90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1561/* 0D94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1562/* 0D98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1563/* 0D9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1564/* 0DA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1565/* 0DA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1566/* 0DA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1567/* 0DAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1568/* 0DB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1569/* 0DB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1570/* 0DB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1571/* 0DBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1572/* 0DC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1573/* 0DC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1574/* 0DC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1575/* 0DCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1576/* 0DD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1577/* 0DD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1578/* 0DD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1579/* 0DDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1580/* 0DE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1581/* 0DE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1582/* 0DE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1583/* 0DEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1584/* 0DF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1585/* 0DF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1586/* 0DF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1587/* 0DFC */ 0x00000000,0x00000000,0x00000000,0x00010004
1588}; /* #SAMPLE_END */
1589
1590
1591static struct dsp_segment_desc cwcemb80_segments[] = {
1592 { SEGTYPE_SP_PROGRAM, 0x00000000, 0x0000031c, cwcemb80_code },
1593 { SEGTYPE_SP_PARAMETER, 0x00000000, 0x00000697, cwcemb80_parameter },
1594 { SEGTYPE_SP_SAMPLE, 0x00000000, 0x00000e00, cwcemb80_sample },
1595};
1596
1597static struct dsp_module_desc cwcemb80_module = {
1598 "cwcemb80",
1599 {
1600 38,
1601 cwcemb80_symbols
1602 },
1603 3,
1604 cwcemb80_segments,
1605};
1606
1607#endif /* __HEADER_cwcemb80_H__ */
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
new file mode 100644
index 00000000000..240a0a46220
--- /dev/null
+++ b/sound/pci/cs5530.c
@@ -0,0 +1,306 @@
1/*
2 * cs5530.c - Initialisation code for Cyrix/NatSemi VSA1 softaudio
3 *
4 * (C) Copyright 2007 Ash Willis <ashwillis@programmer.net>
5 * (C) Copyright 2003 Red Hat Inc <alan@redhat.com>
6 *
7 * This driver was ported (shamelessly ripped ;) from oss/kahlua.c but I did
8 * mess with it a bit. The chip seems to have to have trouble with full duplex
9 * mode. If we're recording in 8bit 8000kHz, say, and we then attempt to
10 * simultaneously play back audio at 16bit 44100kHz, the device actually plays
11 * back in the same format in which it is capturing. By forcing the chip to
12 * always play/capture in 16/44100, we can let alsa-lib convert the samples and
13 * that way we can hack up some full duplex audio.
14 *
15 * XpressAudio(tm) is used on the Cyrix MediaGX (now NatSemi Geode) systems.
16 * The older version (VSA1) provides fairly good soundblaster emulation
17 * although there are a couple of bugs: large DMA buffers break record,
18 * and the MPU event handling seems suspect. VSA2 allows the native driver
19 * to control the AC97 audio engine directly and requires a different driver.
20 *
21 * Thanks to National Semiconductor for providing the needed information
22 * on the XpressAudio(tm) internals.
23 *
24 * This program is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
27 * later version.
28 *
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
33 *
34 * TO DO:
35 * Investigate whether we can portably support Cognac (5520) in the
36 * same manner.
37 */
38
39#include <sound/driver.h>
40#include <linux/delay.h>
41#include <linux/moduleparam.h>
42#include <linux/pci.h>
43#include <sound/core.h>
44#include <sound/sb.h>
45#include <sound/initval.h>
46
47MODULE_AUTHOR("Ash Willis");
48MODULE_DESCRIPTION("CS5530 Audio");
49MODULE_LICENSE("GPL");
50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54
55struct snd_cs5530 {
56 struct snd_card *card;
57 struct pci_dev *pci;
58 struct snd_sb *sb;
59 unsigned long pci_base;
60};
61
62static struct pci_device_id snd_cs5530_ids[] = {
63 {PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID,
64 PCI_ANY_ID, 0, 0},
65 {0,}
66};
67
68MODULE_DEVICE_TABLE(pci, snd_cs5530_ids);
69
70static int snd_cs5530_free(struct snd_cs5530 *chip)
71{
72 pci_release_regions(chip->pci);
73 pci_disable_device(chip->pci);
74 kfree(chip);
75 return 0;
76}
77
78static int snd_cs5530_dev_free(struct snd_device *device)
79{
80 struct snd_cs5530 *chip = device->device_data;
81 return snd_cs5530_free(chip);
82}
83
84static void __devexit snd_cs5530_remove(struct pci_dev *pci)
85{
86 snd_card_free(pci_get_drvdata(pci));
87 pci_set_drvdata(pci, NULL);
88}
89
90static u8 __devinit snd_cs5530_mixer_read(unsigned long io, u8 reg)
91{
92 outb(reg, io + 4);
93 udelay(20);
94 reg = inb(io + 5);
95 udelay(20);
96 return reg;
97}
98
99static int __devinit snd_cs5530_create(struct snd_card *card,
100 struct pci_dev *pci,
101 struct snd_cs5530 **rchip)
102{
103 struct snd_cs5530 *chip;
104 unsigned long sb_base;
105 u8 irq, dma8, dma16 = 0;
106 u16 map;
107 void __iomem *mem;
108 int err;
109
110 static struct snd_device_ops ops = {
111 .dev_free = snd_cs5530_dev_free,
112 };
113 *rchip = NULL;
114
115 err = pci_enable_device(pci);
116 if (err < 0)
117 return err;
118
119 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
120 if (chip == NULL) {
121 pci_disable_device(pci);
122 return -ENOMEM;
123 }
124
125 chip->card = card;
126 chip->pci = pci;
127
128 err = pci_request_regions(pci, "CS5530");
129 if (err < 0) {
130 kfree(chip);
131 pci_disable_device(pci);
132 return err;
133 }
134 chip->pci_base = pci_resource_start(pci, 0);
135
136 mem = ioremap_nocache(chip->pci_base, pci_resource_len(pci, 0));
137 if (mem == NULL) {
138 kfree(chip);
139 pci_disable_device(pci);
140 return -EBUSY;
141 }
142
143 map = readw(mem + 0x18);
144 iounmap(mem);
145
146 /* Map bits
147 0:1 * 0x20 + 0x200 = sb base
148 2 sb enable
149 3 adlib enable
150 5 MPU enable 0x330
151 6 MPU enable 0x300
152
153 The other bits may be used internally so must be masked */
154
155 sb_base = 0x220 + 0x20 * (map & 3);
156
157 if (map & (1<<2))
158 printk(KERN_INFO "CS5530: XpressAudio at 0x%lx\n", sb_base);
159 else {
160 printk(KERN_ERR "Could not find XpressAudio!\n");
161 snd_cs5530_free(chip);
162 return -ENODEV;
163 }
164
165 if (map & (1<<5))
166 printk(KERN_INFO "CS5530: MPU at 0x300\n");
167 else if (map & (1<<6))
168 printk(KERN_INFO "CS5530: MPU at 0x330\n");
169
170 irq = snd_cs5530_mixer_read(sb_base, 0x80) & 0x0F;
171 dma8 = snd_cs5530_mixer_read(sb_base, 0x81);
172
173 if (dma8 & 0x20)
174 dma16 = 5;
175 else if (dma8 & 0x40)
176 dma16 = 6;
177 else if (dma8 & 0x80)
178 dma16 = 7;
179 else {
180 printk(KERN_ERR "CS5530: No 16bit DMA enabled\n");
181 snd_cs5530_free(chip);
182 return -ENODEV;
183 }
184
185 if (dma8 & 0x01)
186 dma8 = 0;
187 else if (dma8 & 02)
188 dma8 = 1;
189 else if (dma8 & 0x08)
190 dma8 = 3;
191 else {
192 printk(KERN_ERR "CS5530: No 8bit DMA enabled\n");
193 snd_cs5530_free(chip);
194 return -ENODEV;
195 }
196
197 if (irq & 1)
198 irq = 9;
199 else if (irq & 2)
200 irq = 5;
201 else if (irq & 4)
202 irq = 7;
203 else if (irq & 8)
204 irq = 10;
205 else {
206 printk(KERN_ERR "CS5530: SoundBlaster IRQ not set\n");
207 snd_cs5530_free(chip);
208 return -ENODEV;
209 }
210
211 printk(KERN_INFO "CS5530: IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8,
212 dma16);
213
214 err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8,
215 dma16, SB_HW_CS5530, &chip->sb);
216 if (err < 0) {
217 printk(KERN_ERR "CS5530: Could not create SoundBlaster\n");
218 snd_cs5530_free(chip);
219 return err;
220 }
221
222 err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm);
223 if (err < 0) {
224 printk(KERN_ERR "CS5530: Could not create PCM\n");
225 snd_cs5530_free(chip);
226 return err;
227 }
228
229 err = snd_sbmixer_new(chip->sb);
230 if (err < 0) {
231 printk(KERN_ERR "CS5530: Could not create Mixer\n");
232 snd_cs5530_free(chip);
233 return err;
234 }
235
236 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
237 if (err < 0) {
238 snd_cs5530_free(chip);
239 return err;
240 }
241
242 snd_card_set_dev(card, &pci->dev);
243 *rchip = chip;
244 return 0;
245}
246
247static int __devinit snd_cs5530_probe(struct pci_dev *pci,
248 const struct pci_device_id *pci_id)
249{
250 static int dev;
251 struct snd_card *card;
252 struct snd_cs5530 *chip = NULL;
253 int err;
254
255 if (dev >= SNDRV_CARDS)
256 return -ENODEV;
257 if (!enable[dev]) {
258 dev++;
259 return -ENOENT;
260 }
261
262 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
263
264 if (card == NULL)
265 return -ENOMEM;
266
267 err = snd_cs5530_create(card, pci, &chip);
268 if (err < 0) {
269 snd_card_free(card);
270 return err;
271 }
272
273 strcpy(card->driver, "CS5530");
274 strcpy(card->shortname, "CS5530 Audio");
275 sprintf(card->longname, "%s at 0x%lx", card->shortname, chip->pci_base);
276
277 err = snd_card_register(card);
278 if (err < 0) {
279 snd_card_free(card);
280 return err;
281 }
282 pci_set_drvdata(pci, card);
283 dev++;
284 return 0;
285}
286
287static struct pci_driver driver = {
288 .name = "CS5530_Audio",
289 .id_table = snd_cs5530_ids,
290 .probe = snd_cs5530_probe,
291 .remove = __devexit_p(snd_cs5530_remove),
292};
293
294static int __init alsa_card_cs5530_init(void)
295{
296 return pci_register_driver(&driver);
297}
298
299static void __exit alsa_card_cs5530_exit(void)
300{
301 pci_unregister_driver(&driver);
302}
303
304module_init(alsa_card_cs5530_init)
305module_exit(alsa_card_cs5530_exit)
306
diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c
index 8e7fe033270..87078d3a685 100644
--- a/sound/pci/echoaudio/darla20.c
+++ b/sound/pci/echoaudio/darla20.c
@@ -56,6 +56,8 @@
56#include <asm/atomic.h> 56#include <asm/atomic.h>
57#include "echoaudio.h" 57#include "echoaudio.h"
58 58
59MODULE_FIRMWARE("ea/darla20_dsp.fw");
60
59#define FW_DARLA20_DSP 0 61#define FW_DARLA20_DSP 0
60 62
61static const struct firmware card_fw[] = { 63static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c
index a13c623eb99..42b48f9d212 100644
--- a/sound/pci/echoaudio/darla24.c
+++ b/sound/pci/echoaudio/darla24.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/darla24_dsp.fw");
64
63#define FW_DARLA24_DSP 0 65#define FW_DARLA24_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c
index 8fb15823aca..8dbb7ac865c 100644
--- a/sound/pci/echoaudio/echo3g.c
+++ b/sound/pci/echoaudio/echo3g.c
@@ -68,6 +68,10 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/echo3g_dsp.fw");
73MODULE_FIRMWARE("ea/3g_asic.fw");
74
71#define FW_361_LOADER 0 75#define FW_361_LOADER 0
72#define FW_ECHO3G_DSP 1 76#define FW_ECHO3G_DSP 1
73#define FW_3G_ASIC 2 77#define FW_3G_ASIC 2
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index e413da00759..f27b6a733b9 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -705,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
705 struct audiopipe *pipe = runtime->private_data; 705 struct audiopipe *pipe = runtime->private_data;
706 int i, err; 706 int i, err;
707 u32 channelmask = 0; 707 u32 channelmask = 0;
708 struct list_head *pos;
709 struct snd_pcm_substream *s; 708 struct snd_pcm_substream *s;
710 709
711 snd_pcm_group_for_each(pos, substream) { 710 snd_pcm_group_for_each_entry(s, substream) {
712 s = snd_pcm_group_substream_entry(pos);
713 for (i = 0; i < DSP_MAXPIPES; i++) { 711 for (i = 0; i < DSP_MAXPIPES; i++) {
714 if (s == chip->substream[i]) { 712 if (s == chip->substream[i]) {
715 channelmask |= 1 << i; 713 channelmask |= 1 << i;
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
index 9f439ea459f..52a93318957 100644
--- a/sound/pci/echoaudio/echoaudio_3g.c
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -233,8 +233,8 @@ static int load_asic(struct echoaudio *chip)
233 233
234 chip->asic_code = &card_fw[FW_3G_ASIC]; 234 chip->asic_code = &card_fw[FW_3G_ASIC];
235 235
236 /* Now give the new ASIC a little time to set up */ 236 /* Now give the new ASIC some time to set up */
237 mdelay(2); 237 msleep(1000);
238 /* See if it worked */ 238 /* See if it worked */
239 box_type = check_asic_status(chip); 239 box_type = check_asic_status(chip);
240 240
diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c
index af4d32026e4..fee2d483173 100644
--- a/sound/pci/echoaudio/gina20.c
+++ b/sound/pci/echoaudio/gina20.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/gina20_dsp.fw");
64
63#define FW_GINA20_DSP 0 65#define FW_GINA20_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c
index 9ff454a947e..d5eae470fe9 100644
--- a/sound/pci/echoaudio/gina24.c
+++ b/sound/pci/echoaudio/gina24.c
@@ -66,6 +66,12 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/gina24_301_dsp.fw");
71MODULE_FIRMWARE("ea/gina24_361_dsp.fw");
72MODULE_FIRMWARE("ea/gina24_301_asic.fw");
73MODULE_FIRMWARE("ea/gina24_361_asic.fw");
74
69#define FW_361_LOADER 0 75#define FW_361_LOADER 0
70#define FW_GINA24_301_DSP 1 76#define FW_GINA24_301_DSP 1
71#define FW_GINA24_361_DSP 2 77#define FW_GINA24_361_DSP 2
diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c
index 37eb726fd03..40f601cd016 100644
--- a/sound/pci/echoaudio/indigo.c
+++ b/sound/pci/echoaudio/indigo.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DSP 1 65#define FW_INDIGO_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c
index dc8b9182418..771c5383210 100644
--- a/sound/pci/echoaudio/indigodj.c
+++ b/sound/pci/echoaudio/indigodj.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dj_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DJ_DSP 1 65#define FW_INDIGO_DJ_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c
index eadf3263453..49c550defcf 100644
--- a/sound/pci/echoaudio/indigoio.c
+++ b/sound/pci/echoaudio/indigoio.c
@@ -59,6 +59,9 @@
59#include <asm/atomic.h> 59#include <asm/atomic.h>
60#include "echoaudio.h" 60#include "echoaudio.h"
61 61
62MODULE_FIRMWARE("ea/loader_dsp.fw");
63MODULE_FIRMWARE("ea/indigo_io_dsp.fw");
64
62#define FW_361_LOADER 0 65#define FW_361_LOADER 0
63#define FW_INDIGO_IO_DSP 1 66#define FW_INDIGO_IO_DSP 1
64 67
diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c
index 6cede497579..8f5483a405a 100644
--- a/sound/pci/echoaudio/layla20.c
+++ b/sound/pci/echoaudio/layla20.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/layla20_dsp.fw");
70MODULE_FIRMWARE("ea/layla20_asic.fw");
71
69#define FW_LAYLA20_DSP 0 72#define FW_LAYLA20_DSP 0
70#define FW_LAYLA20_ASIC 1 73#define FW_LAYLA20_ASIC 1
71 74
diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c
index 44f735426aa..0524667c02f 100644
--- a/sound/pci/echoaudio/layla24.c
+++ b/sound/pci/echoaudio/layla24.c
@@ -68,6 +68,12 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/layla24_dsp.fw");
73MODULE_FIRMWARE("ea/layla24_1_asic.fw");
74MODULE_FIRMWARE("ea/layla24_2A_asic.fw");
75MODULE_FIRMWARE("ea/layla24_2S_asic.fw");
76
71#define FW_361_LOADER 0 77#define FW_361_LOADER 0
72#define FW_LAYLA24_DSP 1 78#define FW_LAYLA24_DSP 1
73#define FW_LAYLA24_1_ASIC 2 79#define FW_LAYLA24_1_ASIC 2
diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c
index dc172d03ac3..893c7c20dd7 100644
--- a/sound/pci/echoaudio/mia.c
+++ b/sound/pci/echoaudio/mia.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/mia_dsp.fw");
71
69#define FW_361_LOADER 0 72#define FW_361_LOADER 0
70#define FW_MIA_DSP 1 73#define FW_MIA_DSP 1
71 74
diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c
index c856ed50dd9..3a5d5b0020d 100644
--- a/sound/pci/echoaudio/mona.c
+++ b/sound/pci/echoaudio/mona.c
@@ -64,6 +64,15 @@
64#include <asm/atomic.h> 64#include <asm/atomic.h>
65#include "echoaudio.h" 65#include "echoaudio.h"
66 66
67MODULE_FIRMWARE("ea/loader_dsp.fw");
68MODULE_FIRMWARE("ea/mona_301_dsp.fw");
69MODULE_FIRMWARE("ea/mona_361_dsp.fw");
70MODULE_FIRMWARE("ea/mona_301_1_asic_48.fw");
71MODULE_FIRMWARE("ea/mona_301_1_asic_96.fw");
72MODULE_FIRMWARE("ea/mona_361_1_asic_48.fw");
73MODULE_FIRMWARE("ea/mona_361_1_asic_96.fw");
74MODULE_FIRMWARE("ea/mona_2_asic.fw");
75
67#define FW_361_LOADER 0 76#define FW_361_LOADER 0
68#define FW_MONA_301_DSP 1 77#define FW_MONA_301_DSP 1
69#define FW_MONA_361_DSP 2 78#define FW_MONA_361_DSP 2
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 80aa585eade..404ae1be0a4 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -49,6 +49,19 @@
49#include "p17v.h" 49#include "p17v.h"
50 50
51 51
52#define HANA_FILENAME "emu/hana.fw"
53#define DOCK_FILENAME "emu/audio_dock.fw"
54#define EMU1010B_FILENAME "emu/emu1010b.fw"
55#define MICRO_DOCK_FILENAME "emu/micro_dock.fw"
56#define EMU1010_NOTEBOOK_FILENAME "emu/emu1010_notebook.fw"
57
58MODULE_FIRMWARE(HANA_FILENAME);
59MODULE_FIRMWARE(DOCK_FILENAME);
60MODULE_FIRMWARE(EMU1010B_FILENAME);
61MODULE_FIRMWARE(MICRO_DOCK_FILENAME);
62MODULE_FIRMWARE(EMU1010_NOTEBOOK_FILENAME);
63
64
52/************************************************************************* 65/*************************************************************************
53 * EMU10K1 init / done 66 * EMU10K1 init / done
54 *************************************************************************/ 67 *************************************************************************/
@@ -653,10 +666,12 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
653 return err; 666 return err;
654 } 667 }
655 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); 668 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size);
669#if 0
656 if (fw_entry->size != 0x133a4) { 670 if (fw_entry->size != 0x133a4) {
657 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename); 671 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename);
658 return -EINVAL; 672 return -EINVAL;
659 } 673 }
674#endif
660 675
661 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ 676 /* The FPGA is a Xilinx Spartan IIE XC2S50E */
662 /* GPIO7 -> FPGA PGMN 677 /* GPIO7 -> FPGA PGMN
@@ -687,14 +702,43 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
687 return 0; 702 return 0;
688} 703}
689 704
705/*
706 * EMU-1010 - details found out from this driver, official MS Win drivers,
707 * testing the card:
708 *
709 * Audigy2 (aka Alice2):
710 * ---------------------
711 * * communication over PCI
712 * * conversion of 32-bit data coming over EMU32 links from HANA FPGA
713 * to 2 x 16-bit, using internal DSP instructions
714 * * slave mode, clock supplied by HANA
715 * * linked to HANA using:
716 * 32 x 32-bit serial EMU32 output channels
717 * 16 x EMU32 input channels
718 * (?) x I2S I/O channels (?)
719 *
720 * FPGA (aka HANA):
721 * ---------------
722 * * provides all (?) physical inputs and outputs of the card
723 * (ADC, DAC, SPDIF I/O, ADAT I/O, etc.)
724 * * provides clock signal for the card and Alice2
725 * * two crystals - for 44.1kHz and 48kHz multiples
726 * * provides internal routing of signal sources to signal destinations
727 * * inputs/outputs to Alice2 - see above
728 *
729 * Current status of the driver:
730 * ----------------------------
731 * * only 44.1/48kHz supported (the MS Win driver supports up to 192 kHz)
732 * * PCM device nb. 2:
733 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops
734 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops
735 */
690static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) 736static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
691{ 737{
692 unsigned int i; 738 unsigned int i;
693 int tmp,tmp2; 739 int tmp,tmp2;
694 int reg; 740 int reg;
695 int err; 741 int err;
696 const char *hana_filename = "emu/hana.fw";
697 const char *dock_filename = "emu/audio_dock.fw";
698 742
699 snd_printk(KERN_INFO "emu1010: Special config.\n"); 743 snd_printk(KERN_INFO "emu1010: Special config.\n");
700 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 744 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
@@ -722,7 +766,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
722 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 766 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
723 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 767 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
724 snd_printdd("reg1=0x%x\n",reg); 768 snd_printdd("reg1=0x%x\n",reg);
725 if (reg == 0x55) { 769 if ((reg & 0x3f) == 0x15) {
726 /* FPGA netlist already present so clear it */ 770 /* FPGA netlist already present so clear it */
727 /* Return to programming mode */ 771 /* Return to programming mode */
728 772
@@ -730,19 +774,32 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
730 } 774 }
731 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 775 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
732 snd_printdd("reg2=0x%x\n",reg); 776 snd_printdd("reg2=0x%x\n",reg);
733 if (reg == 0x55) { 777 if ((reg & 0x3f) == 0x15) {
734 /* FPGA failed to return to programming mode */ 778 /* FPGA failed to return to programming mode */
779 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n");
735 return -ENODEV; 780 return -ENODEV;
736 } 781 }
737 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 782 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
738 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { 783 if (emu->card_capabilities->emu1010 == 1) {
739 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); 784 if ((err = snd_emu1010_load_firmware(emu, HANA_FILENAME)) != 0) {
740 return err; 785 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", HANA_FILENAME);
786 return err;
787 }
788 } else if (emu->card_capabilities->emu1010 == 2) {
789 if ((err = snd_emu1010_load_firmware(emu, EMU1010B_FILENAME)) != 0) {
790 snd_printk(KERN_INFO "emu1010: Loading Firmware file %s failed\n", EMU1010B_FILENAME);
791 return err;
792 }
793 } else if (emu->card_capabilities->emu1010 == 3) {
794 if ((err = snd_emu1010_load_firmware(emu, EMU1010_NOTEBOOK_FILENAME)) != 0) {
795 snd_printk(KERN_INFO "emu1010: Loading Firmware file %s failed\n", EMU1010_NOTEBOOK_FILENAME);
796 return err;
797 }
741 } 798 }
742 799
743 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 800 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
744 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 801 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
745 if (reg != 0x55) { 802 if ((reg & 0x3f) != 0x15) {
746 /* FPGA failed to be programmed */ 803 /* FPGA failed to be programmed */
747 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); 804 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg);
748 return -ENODEV; 805 return -ENODEV;
@@ -845,6 +902,27 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
845 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1); 902 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1);
846 snd_emu1010_fpga_link_dst_src_write(emu, 903 snd_emu1010_fpga_link_dst_src_write(emu,
847 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1); 904 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1);
905 /* Pavel Hofman - setting defaults for 8 more capture channels
906 * Defaults only, users will set their own values anyways, let's
907 * just copy/paste.
908 */
909
910 snd_emu1010_fpga_link_dst_src_write(emu,
911 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1);
912 snd_emu1010_fpga_link_dst_src_write(emu,
913 EMU_DST_ALICE2_EMU32_9, EMU_SRC_DOCK_MIC_B1);
914 snd_emu1010_fpga_link_dst_src_write(emu,
915 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HAMOA_ADC_LEFT2);
916 snd_emu1010_fpga_link_dst_src_write(emu,
917 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HAMOA_ADC_LEFT2);
918 snd_emu1010_fpga_link_dst_src_write(emu,
919 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_ADC1_LEFT1);
920 snd_emu1010_fpga_link_dst_src_write(emu,
921 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_ADC1_RIGHT1);
922 snd_emu1010_fpga_link_dst_src_write(emu,
923 EMU_DST_ALICE2_EMU32_E, EMU_SRC_DOCK_ADC2_LEFT1);
924 snd_emu1010_fpga_link_dst_src_write(emu,
925 EMU_DST_ALICE2_EMU32_F, EMU_SRC_DOCK_ADC2_RIGHT1);
848#endif 926#endif
849#if 0 927#if 0
850 /* Original */ 928 /* Original */
@@ -938,16 +1016,27 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
938 /* Return to Audio Dock programming mode */ 1016 /* Return to Audio Dock programming mode */
939 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 1017 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
940 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 1018 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK );
941 if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) { 1019 if (emu->card_capabilities->emu1010 == 1) {
942 return err; 1020 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) {
1021 return err;
1022 }
1023 } else if (emu->card_capabilities->emu1010 == 2) {
1024 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) {
1025 return err;
1026 }
1027 } else if (emu->card_capabilities->emu1010 == 3) {
1028 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) {
1029 return err;
1030 }
943 } 1031 }
1032
944 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 1033 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 );
945 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg ); 1034 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg );
946 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); 1035 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg);
947 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 1036 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
948 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 1037 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
949 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); 1038 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg);
950 if (reg != 0x55) { 1039 if ((reg & 0x3f) != 0x15) {
951 /* FPGA failed to be programmed */ 1040 /* FPGA failed to be programmed */
952 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); 1041 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg);
953 return 0; 1042 return 0;
@@ -1216,6 +1305,21 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1216 .spi_dac = 1, 1305 .spi_dac = 1,
1217 .i2c_adc = 1, 1306 .i2c_adc = 1,
1218 .spk71 = 1} , 1307 .spk71 = 1} ,
1308 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1309 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1310 .id = "EMU1010",
1311 .emu10k2_chip = 1,
1312 .ca0108_chip = 1,
1313 .ca_cardbus_chip = 1,
1314 .spk71 = 1 ,
1315 .emu1010 = 3} ,
1316 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
1317 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM????]",
1318 .id = "EMU1010",
1319 .emu10k2_chip = 1,
1320 .ca0108_chip = 1,
1321 .spk71 = 1 ,
1322 .emu1010 = 2} ,
1219 {.vendor = 0x1102, .device = 0x0008, 1323 {.vendor = 0x1102, .device = 0x0008,
1220 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1324 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]",
1221 .id = "Audigy2", 1325 .id = "Audigy2",
@@ -1497,7 +1601,6 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1497 struct snd_emu10k1 *emu; 1601 struct snd_emu10k1 *emu;
1498 int idx, err; 1602 int idx, err;
1499 int is_audigy; 1603 int is_audigy;
1500 unsigned char revision;
1501 unsigned int silent_page; 1604 unsigned int silent_page;
1502 const struct snd_emu_chip_details *c; 1605 const struct snd_emu_chip_details *c;
1503 static struct snd_device_ops ops = { 1606 static struct snd_device_ops ops = {
@@ -1529,8 +1632,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1529 emu->synth = NULL; 1632 emu->synth = NULL;
1530 emu->get_synth_voice = NULL; 1633 emu->get_synth_voice = NULL;
1531 /* read revision & serial */ 1634 /* read revision & serial */
1532 pci_read_config_byte(pci, PCI_REVISION_ID, &revision); 1635 emu->revision = pci->revision;
1533 emu->revision = revision;
1534 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1636 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1535 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1637 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1536 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); 1638 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model);
@@ -1651,12 +1753,13 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1651 emu->fx8010.extout_mask = extout_mask; 1753 emu->fx8010.extout_mask = extout_mask;
1652 emu->enable_ir = enable_ir; 1754 emu->enable_ir = enable_ir;
1653 1755
1756 if (emu->card_capabilities->ca_cardbus_chip) {
1757 if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
1758 goto error;
1759 }
1654 if (emu->card_capabilities->ecard) { 1760 if (emu->card_capabilities->ecard) {
1655 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1761 if ((err = snd_emu10k1_ecard_init(emu)) < 0)
1656 goto error; 1762 goto error;
1657 } else if (emu->card_capabilities->ca_cardbus_chip) {
1658 if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
1659 goto error;
1660 } else if (emu->card_capabilities->emu1010) { 1763 } else if (emu->card_capabilities->emu1010) {
1661 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1764 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) {
1662 snd_emu10k1_free(emu); 1765 snd_emu10k1_free(emu);
@@ -1802,10 +1905,10 @@ void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu)
1802 1905
1803void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) 1906void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
1804{ 1907{
1908 if (emu->card_capabilities->ca_cardbus_chip)
1909 snd_emu10k1_cardbus_init(emu);
1805 if (emu->card_capabilities->ecard) 1910 if (emu->card_capabilities->ecard)
1806 snd_emu10k1_ecard_init(emu); 1911 snd_emu10k1_ecard_init(emu);
1807 else if (emu->card_capabilities->ca_cardbus_chip)
1808 snd_emu10k1_cardbus_init(emu);
1809 else if (emu->card_capabilities->emu1010) 1912 else if (emu->card_capabilities->emu1010)
1810 snd_emu10k1_emu1010_init(emu); 1913 snd_emu10k1_emu1010_init(emu);
1811 else 1914 else
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index bb0fec7f7e1..e4af7a9b808 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -942,7 +942,7 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card,
942 942
943 pci_set_master(pci); 943 pci_set_master(pci);
944 /* read revision & serial */ 944 /* read revision & serial */
945 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->revision); 945 chip->revision = pci->revision;
946 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 946 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
947 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 947 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
948 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, 948 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model,
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index c02012cccd8..7206c0fa06f 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1123,6 +1123,11 @@ snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl
1123 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; 1123 ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF;
1124} 1124}
1125 1125
1126/*
1127 * Used for emu1010 - conversion from 32-bit capture inputs from HANA
1128 * to 2 x 16-bit registers in audigy - their values are read via DMA.
1129 * Conversion is performed by Audigy DSP instructions of FX8010.
1130 */
1126static int snd_emu10k1_audigy_dsp_convert_32_to_2x16( 1131static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
1127 struct snd_emu10k1_fx8010_code *icode, 1132 struct snd_emu10k1_fx8010_code *icode,
1128 u32 *ptr, int tmp, int bit_shifter16, 1133 u32 *ptr, int tmp, int bit_shifter16,
@@ -1193,7 +1198,11 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
1193 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); 1198 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP);
1194 1199
1195#if 1 1200#if 1
1196 /* PCM front Playback Volume (independent from stereo mix) */ 1201 /* PCM front Playback Volume (independent from stereo mix)
1202 * playback = 0 + ( gpr * FXBUS_PCM_LEFT_FRONT >> 31)
1203 * where gpr contains attenuation from corresponding mixer control
1204 * (snd_emu10k1_init_stereo_control)
1205 */
1197 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); 1206 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));
1198 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT)); 1207 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT));
1199 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100); 1208 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100);
@@ -1549,7 +1558,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1549 1558
1550 if (emu->card_capabilities->emu1010) { 1559 if (emu->card_capabilities->emu1010) {
1551 snd_printk("EMU inputs on\n"); 1560 snd_printk("EMU inputs on\n");
1552 /* Capture 8 channels of S32_LE sound */ 1561 /* Capture 16 (originally 8) channels of S32_LE sound */
1553 1562
1554 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */ 1563 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */
1555 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ 1564 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
@@ -1560,6 +1569,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1560 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) ); 1569 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) );
1561 /* Right ADC in 1 of 2 */ 1570 /* Right ADC in 1 of 2 */
1562 gpr_map[gpr++] = 0x00000000; 1571 gpr_map[gpr++] = 0x00000000;
1572 /* Delaying by one sample: instead of copying the input
1573 * value A_P16VIN to output A_FXBUS2 as in the first channel,
1574 * we use an auxiliary register, delaying the value by one
1575 * sample
1576 */
1563 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) ); 1577 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) );
1564 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000); 1578 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
1565 gpr_map[gpr++] = 0x00000000; 1579 gpr_map[gpr++] = 0x00000000;
@@ -1583,6 +1597,66 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1583 gpr_map[gpr++] = 0x00000000; 1597 gpr_map[gpr++] = 0x00000000;
1584 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) ); 1598 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) );
1585 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000); 1599 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000);
1600 /* Pavel Hofman - we still have voices, A_FXBUS2s, and
1601 * A_P16VINs available -
1602 * let's add 8 more capture channels - total of 16
1603 */
1604 gpr_map[gpr++] = 0x00000000;
1605 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1606 bit_shifter16,
1607 A_GPR(gpr - 1),
1608 A_FXBUS2(0x10));
1609 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x8),
1610 A_C_00000000, A_C_00000000);
1611 gpr_map[gpr++] = 0x00000000;
1612 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1613 bit_shifter16,
1614 A_GPR(gpr - 1),
1615 A_FXBUS2(0x12));
1616 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x9),
1617 A_C_00000000, A_C_00000000);
1618 gpr_map[gpr++] = 0x00000000;
1619 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1620 bit_shifter16,
1621 A_GPR(gpr - 1),
1622 A_FXBUS2(0x14));
1623 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xa),
1624 A_C_00000000, A_C_00000000);
1625 gpr_map[gpr++] = 0x00000000;
1626 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1627 bit_shifter16,
1628 A_GPR(gpr - 1),
1629 A_FXBUS2(0x16));
1630 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xb),
1631 A_C_00000000, A_C_00000000);
1632 gpr_map[gpr++] = 0x00000000;
1633 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1634 bit_shifter16,
1635 A_GPR(gpr - 1),
1636 A_FXBUS2(0x18));
1637 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xc),
1638 A_C_00000000, A_C_00000000);
1639 gpr_map[gpr++] = 0x00000000;
1640 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1641 bit_shifter16,
1642 A_GPR(gpr - 1),
1643 A_FXBUS2(0x1a));
1644 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xd),
1645 A_C_00000000, A_C_00000000);
1646 gpr_map[gpr++] = 0x00000000;
1647 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1648 bit_shifter16,
1649 A_GPR(gpr - 1),
1650 A_FXBUS2(0x1c));
1651 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xe),
1652 A_C_00000000, A_C_00000000);
1653 gpr_map[gpr++] = 0x00000000;
1654 snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1655 bit_shifter16,
1656 A_GPR(gpr - 1),
1657 A_FXBUS2(0x1e));
1658 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xf),
1659 A_C_00000000, A_C_00000000);
1586 1660
1587#if 0 1661#if 0
1588 for (z = 4; z < 8; z++) { 1662 for (z = 4; z < 8; z++) {
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 4db6e1ca166..7b2c1dcc533 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -77,6 +77,10 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,
77 return 0; 77 return 0;
78} 78}
79 79
80/*
81 * Items labels in enum mixer controls assigning source data to
82 * each destination
83 */
80static char *emu1010_src_texts[] = { 84static char *emu1010_src_texts[] = {
81 "Silence", 85 "Silence",
82 "Dock Mic A", 86 "Dock Mic A",
@@ -133,6 +137,9 @@ static char *emu1010_src_texts[] = {
133 "DSP 31", 137 "DSP 31",
134}; 138};
135 139
140/*
141 * List of data sources available for each destination
142 */
136static unsigned int emu1010_src_regs[] = { 143static unsigned int emu1010_src_regs[] = {
137 EMU_SRC_SILENCE,/* 0 */ 144 EMU_SRC_SILENCE,/* 0 */
138 EMU_SRC_DOCK_MIC_A1, /* 1 */ 145 EMU_SRC_DOCK_MIC_A1, /* 1 */
@@ -189,6 +196,10 @@ static unsigned int emu1010_src_regs[] = {
189 EMU_SRC_ALICE_EMU32B+0xf, /* 52 */ 196 EMU_SRC_ALICE_EMU32B+0xf, /* 52 */
190}; 197};
191 198
199/*
200 * Data destinations - physical EMU outputs.
201 * Each destination has an enum mixer control to choose a data source
202 */
192static unsigned int emu1010_output_dst[] = { 203static unsigned int emu1010_output_dst[] = {
193 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ 204 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */
194 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ 205 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */
@@ -216,6 +227,11 @@ static unsigned int emu1010_output_dst[] = {
216 EMU_DST_HANA_ADAT+7, /* 23 */ 227 EMU_DST_HANA_ADAT+7, /* 23 */
217}; 228};
218 229
230/*
231 * Data destinations - HANA outputs going to Alice2 (audigy) for
232 * capture (EMU32 + I2S links)
233 * Each destination has an enum mixer control to choose a data source
234 */
219static unsigned int emu1010_input_dst[] = { 235static unsigned int emu1010_input_dst[] = {
220 EMU_DST_ALICE2_EMU32_0, 236 EMU_DST_ALICE2_EMU32_0,
221 EMU_DST_ALICE2_EMU32_1, 237 EMU_DST_ALICE2_EMU32_1,
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index ab4f5df5241..eda5cb373de 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1233,24 +1233,26 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1233 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1233 runtime->hw.rate_min = runtime->hw.rate_max = 48000;
1234 spin_lock_irq(&emu->reg_lock); 1234 spin_lock_irq(&emu->reg_lock);
1235 if (emu->card_capabilities->emu1010) { 1235 if (emu->card_capabilities->emu1010) {
1236 /* TODO 1236 /* Nb. of channels has been increased to 16 */
1237 /* TODO
1237 * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE 1238 * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE
1238 * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 1239 * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
1239 * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 1240 * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
1240 * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 1241 * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000
1241 * rate_min = 44100, 1242 * rate_min = 44100,
1242 * rate_max = 192000, 1243 * rate_max = 192000,
1243 * channels_min = 8, 1244 * channels_min = 16,
1244 * channels_max = 8, 1245 * channels_max = 16,
1245 * Need to add mixer control to fix sample rate 1246 * Need to add mixer control to fix sample rate
1246 * 1247 *
1247 * There are 16 mono channels of 16bits each. 1248 * There are 32 mono channels of 16bits each.
1248 * 24bit Audio uses 2x channels over 16bit 1249 * 24bit Audio uses 2x channels over 16bit
1249 * 96kHz uses 2x channels over 48kHz 1250 * 96kHz uses 2x channels over 48kHz
1250 * 192kHz uses 4x channels over 48kHz 1251 * 192kHz uses 4x channels over 48kHz
1251 * So, for 48kHz 24bit, one has 8 channels 1252 * So, for 48kHz 24bit, one has 16 channels
1252 * for 96kHz 24bit, one has 4 channels 1253 * for 96kHz 24bit, one has 8 channels
1253 * for 192kHz 24bit, one has 2 channels 1254 * for 192kHz 24bit, one has 4 channels
1255 *
1254 */ 1256 */
1255#if 1 1257#if 1
1256 switch (emu->emu1010.internal_clock) { 1258 switch (emu->emu1010.internal_clock) {
@@ -1258,13 +1260,15 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1258 /* For 44.1kHz */ 1260 /* For 44.1kHz */
1259 runtime->hw.rates = SNDRV_PCM_RATE_44100; 1261 runtime->hw.rates = SNDRV_PCM_RATE_44100;
1260 runtime->hw.rate_min = runtime->hw.rate_max = 44100; 1262 runtime->hw.rate_min = runtime->hw.rate_max = 44100;
1261 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1263 runtime->hw.channels_min =
1264 runtime->hw.channels_max = 16;
1262 break; 1265 break;
1263 case 1: 1266 case 1:
1264 /* For 48kHz */ 1267 /* For 48kHz */
1265 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1268 runtime->hw.rates = SNDRV_PCM_RATE_48000;
1266 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1269 runtime->hw.rate_min = runtime->hw.rate_max = 48000;
1267 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1270 runtime->hw.channels_min =
1271 runtime->hw.channels_max = 16;
1268 break; 1272 break;
1269 }; 1273 };
1270#endif 1274#endif
@@ -1282,7 +1286,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
1282#endif 1286#endif
1283 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; 1287 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
1284 /* efx_voices_mask[0] is expected to be zero 1288 /* efx_voices_mask[0] is expected to be zero
1285 * efx_voices_mask[1] is expected to have 16bits set 1289 * efx_voices_mask[1] is expected to have 32bits set
1286 */ 1290 */
1287 } else { 1291 } else {
1288 runtime->hw.channels_min = runtime->hw.channels_max = 0; 1292 runtime->hw.channels_min = runtime->hw.channels_max = 0;
@@ -1787,11 +1791,24 @@ int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct s
1787 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ 1791 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */
1788 if (emu->audigy) { 1792 if (emu->audigy) {
1789 emu->efx_voices_mask[0] = 0; 1793 emu->efx_voices_mask[0] = 0;
1790 emu->efx_voices_mask[1] = 0xffff; 1794 if (emu->card_capabilities->emu1010)
1795 /* Pavel Hofman - 32 voices will be used for
1796 * capture (write mode) -
1797 * each bit = corresponding voice
1798 */
1799 emu->efx_voices_mask[1] = 0xffffffff;
1800 else
1801 emu->efx_voices_mask[1] = 0xffff;
1791 } else { 1802 } else {
1792 emu->efx_voices_mask[0] = 0xffff0000; 1803 emu->efx_voices_mask[0] = 0xffff0000;
1793 emu->efx_voices_mask[1] = 0; 1804 emu->efx_voices_mask[1] = 0;
1794 } 1805 }
1806 /* For emu1010, the control has to set 32 upper bits (voices)
1807 * out of the 64 bits (voices) to true for the 16-channels capture
1808 * to work correctly. Correct A_FXWC2 initial value (0xffffffff)
1809 * is already defined but the snd_emu10k1_pcm_efx_voices_mask
1810 * control can override this register's value.
1811 */
1795 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu); 1812 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu);
1796 if (!kctl) 1813 if (!kctl)
1797 return -ENOMEM; 1814 return -ENOMEM;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 465f8d50532..7ee19c63c2c 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -433,7 +433,6 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
433 struct snd_emu10k1_pcm *epcm; 433 struct snd_emu10k1_pcm *epcm;
434 int channel; 434 int channel;
435 int result = 0; 435 int result = 0;
436 struct list_head *pos;
437 struct snd_pcm_substream *s; 436 struct snd_pcm_substream *s;
438 u32 basic = 0; 437 u32 basic = 0;
439 u32 inte = 0; 438 u32 inte = 0;
@@ -448,8 +447,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
448 running = 0; 447 running = 0;
449 break; 448 break;
450 } 449 }
451 snd_pcm_group_for_each(pos, substream) { 450 snd_pcm_group_for_each_entry(s, substream) {
452 s = snd_pcm_group_substream_entry(pos);
453 runtime = s->runtime; 451 runtime = s->runtime;
454 epcm = runtime->private_data; 452 epcm = runtime->private_data;
455 channel = substream->pcm->device-emu->p16v_device_offset; 453 channel = substream->pcm->device-emu->p16v_device_offset;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 425b167522d..21cb4268a59 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -798,10 +798,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
799 { 799 {
800 unsigned int what = 0; 800 unsigned int what = 0;
801 struct list_head *pos;
802 struct snd_pcm_substream *s; 801 struct snd_pcm_substream *s;
803 snd_pcm_group_for_each(pos, substream) { 802 snd_pcm_group_for_each_entry(s, substream) {
804 s = snd_pcm_group_substream_entry(pos);
805 if (s == ensoniq->playback1_substream) { 803 if (s == ensoniq->playback1_substream) {
806 what |= ES_P1_PAUSE; 804 what |= ES_P1_PAUSE;
807 snd_pcm_trigger_done(s, substream); 805 snd_pcm_trigger_done(s, substream);
@@ -824,10 +822,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
824 case SNDRV_PCM_TRIGGER_STOP: 822 case SNDRV_PCM_TRIGGER_STOP:
825 { 823 {
826 unsigned int what = 0; 824 unsigned int what = 0;
827 struct list_head *pos;
828 struct snd_pcm_substream *s; 825 struct snd_pcm_substream *s;
829 snd_pcm_group_for_each(pos, substream) { 826 snd_pcm_group_for_each_entry(s, substream) {
830 s = snd_pcm_group_substream_entry(pos);
831 if (s == ensoniq->playback1_substream) { 827 if (s == ensoniq->playback1_substream) {
832 what |= ES_DAC1_EN; 828 what |= ES_DAC1_EN;
833 snd_pcm_trigger_done(s, substream); 829 snd_pcm_trigger_done(s, substream);
@@ -1611,8 +1607,8 @@ struct es1371_quirk {
1611 unsigned char rev; /* revision */ 1607 unsigned char rev; /* revision */
1612}; 1608};
1613 1609
1614static int __devinit es1371_quirk_lookup(struct ensoniq *ensoniq, 1610static int es1371_quirk_lookup(struct ensoniq *ensoniq,
1615 struct es1371_quirk *list) 1611 struct es1371_quirk *list)
1616{ 1612{
1617 while (list->vid != (unsigned short)PCI_ANY_ID) { 1613 while (list->vid != (unsigned short)PCI_ANY_ID) {
1618 if (ensoniq->pci->vendor == list->vid && 1614 if (ensoniq->pci->vendor == list->vid &&
@@ -2114,7 +2110,6 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
2114 struct ensoniq ** rensoniq) 2110 struct ensoniq ** rensoniq)
2115{ 2111{
2116 struct ensoniq *ensoniq; 2112 struct ensoniq *ensoniq;
2117 unsigned char cmdb;
2118 int err; 2113 int err;
2119 static struct snd_device_ops ops = { 2114 static struct snd_device_ops ops = {
2120 .dev_free = snd_ensoniq_dev_free, 2115 .dev_free = snd_ensoniq_dev_free,
@@ -2155,8 +2150,7 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
2155 } 2150 }
2156#endif 2151#endif
2157 pci_set_master(pci); 2152 pci_set_master(pci);
2158 pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb); 2153 ensoniq->rev = pci->revision;
2159 ensoniq->rev = cmdb;
2160#ifdef CHIP1370 2154#ifdef CHIP1370
2161#if 0 2155#if 0
2162 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | 2156 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE |
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index dc84c189b05..2faf009076b 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1554,10 +1554,7 @@ static int snd_es1968_playback_open(struct snd_pcm_substream *substream)
1554 runtime->hw = snd_es1968_playback; 1554 runtime->hw = snd_es1968_playback;
1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1556 calc_available_memory_size(chip); 1556 calc_available_memory_size(chip);
1557#if 0 1557
1558 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1559 1024);
1560#endif
1561 spin_lock_irq(&chip->substream_lock); 1558 spin_lock_irq(&chip->substream_lock);
1562 list_add(&es->list, &chip->substream_list); 1559 list_add(&es->list, &chip->substream_list);
1563 spin_unlock_irq(&chip->substream_lock); 1560 spin_unlock_irq(&chip->substream_lock);
@@ -1613,10 +1610,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
1613 runtime->hw = snd_es1968_capture; 1610 runtime->hw = snd_es1968_capture;
1614 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1611 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1615 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */ 1612 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */
1616#if 0 1613 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
1617 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1614
1618 1024);
1619#endif
1620 spin_lock_irq(&chip->substream_lock); 1615 spin_lock_irq(&chip->substream_lock);
1621 list_add(&es->list, &chip->substream_list); 1616 list_add(&es->list, &chip->substream_list);
1622 spin_unlock_irq(&chip->substream_lock); 1617 spin_unlock_irq(&chip->substream_lock);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 6dc578bbeec..11015178e20 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1369,7 +1369,6 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1369 struct fm801 ** rchip) 1369 struct fm801 ** rchip)
1370{ 1370{
1371 struct fm801 *chip; 1371 struct fm801 *chip;
1372 unsigned char rev;
1373 int err; 1372 int err;
1374 static struct snd_device_ops ops = { 1373 static struct snd_device_ops ops = {
1375 .dev_free = snd_fm801_dev_free, 1374 .dev_free = snd_fm801_dev_free,
@@ -1405,8 +1404,7 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1405 pci_set_master(pci); 1404 pci_set_master(pci);
1406 } 1405 }
1407 1406
1408 pci_read_config_byte(pci, PCI_REVISION_ID, &rev); 1407 if (pci->revision >= 0xb1) /* FM801-AU */
1409 if (rev >= 0xb1) /* FM801-AU */
1410 chip->multichannel = 1; 1408 chip->multichannel = 1;
1411 1409
1412 snd_fm801_chip_init(chip, 0); 1410 snd_fm801_chip_init(chip, 0);
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 60d7b05a204..b2484bbdcc1 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,5 +1,8 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2snd-hda-codec-objs := hda_codec.o \ 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally
4# designed to be individual modules
5snd-hda-intel-objs += hda_codec.o \
3 hda_generic.o \ 6 hda_generic.o \
4 patch_realtek.o \ 7 patch_realtek.o \
5 patch_cmedia.o \ 8 patch_cmedia.o \
@@ -10,7 +13,7 @@ snd-hda-codec-objs := hda_codec.o \
10 patch_conexant.o \ 13 patch_conexant.o \
11 patch_via.o 14 patch_via.o
12ifdef CONFIG_PROC_FS 15ifdef CONFIG_PROC_FS
13snd-hda-codec-objs += hda_proc.o 16snd-hda-intel-objs += hda_proc.o
14endif 17endif
15 18
16obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o snd-hda-codec.o 19obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8f34fb44798..f87f8f08895 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -24,7 +24,6 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/moduleparam.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
29#include <sound/core.h> 28#include <sound/core.h>
30#include "hda_codec.h" 29#include "hda_codec.h"
@@ -34,11 +33,6 @@
34#include "hda_local.h" 33#include "hda_local.h"
35 34
36 35
37MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
38MODULE_DESCRIPTION("Universal interface for High Definition Audio Codec");
39MODULE_LICENSE("GPL");
40
41
42/* 36/*
43 * vendor / preset table 37 * vendor / preset table
44 */ 38 */
@@ -77,12 +71,13 @@ static struct hda_vendor_id hda_vendor_ids[] = {
77 * 71 *
78 * Returns the obtained response value, or -1 for an error. 72 * Returns the obtained response value, or -1 for an error.
79 */ 73 */
80unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, 74unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
75 int direct,
81 unsigned int verb, unsigned int parm) 76 unsigned int verb, unsigned int parm)
82{ 77{
83 unsigned int res; 78 unsigned int res;
84 mutex_lock(&codec->bus->cmd_mutex); 79 mutex_lock(&codec->bus->cmd_mutex);
85 if (! codec->bus->ops.command(codec, nid, direct, verb, parm)) 80 if (!codec->bus->ops.command(codec, nid, direct, verb, parm))
86 res = codec->bus->ops.get_response(codec); 81 res = codec->bus->ops.get_response(codec);
87 else 82 else
88 res = (unsigned int)-1; 83 res = (unsigned int)-1;
@@ -90,8 +85,6 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int dire
90 return res; 85 return res;
91} 86}
92 87
93EXPORT_SYMBOL(snd_hda_codec_read);
94
95/** 88/**
96 * snd_hda_codec_write - send a single command without waiting for response 89 * snd_hda_codec_write - send a single command without waiting for response
97 * @codec: the HDA codec 90 * @codec: the HDA codec
@@ -114,8 +107,6 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
114 return err; 107 return err;
115} 108}
116 109
117EXPORT_SYMBOL(snd_hda_codec_write);
118
119/** 110/**
120 * snd_hda_sequence_write - sequence writes 111 * snd_hda_sequence_write - sequence writes
121 * @codec: the HDA codec 112 * @codec: the HDA codec
@@ -130,8 +121,6 @@ void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
130 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); 121 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
131} 122}
132 123
133EXPORT_SYMBOL(snd_hda_sequence_write);
134
135/** 124/**
136 * snd_hda_get_sub_nodes - get the range of sub nodes 125 * snd_hda_get_sub_nodes - get the range of sub nodes
137 * @codec: the HDA codec 126 * @codec: the HDA codec
@@ -141,7 +130,8 @@ EXPORT_SYMBOL(snd_hda_sequence_write);
141 * Parse the NID and store the start NID of its sub-nodes. 130 * Parse the NID and store the start NID of its sub-nodes.
142 * Returns the number of sub-nodes. 131 * Returns the number of sub-nodes.
143 */ 132 */
144int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id) 133int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
134 hda_nid_t *start_id)
145{ 135{
146 unsigned int parm; 136 unsigned int parm;
147 137
@@ -150,8 +140,6 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *sta
150 return (int)(parm & 0x7fff); 140 return (int)(parm & 0x7fff);
151} 141}
152 142
153EXPORT_SYMBOL(snd_hda_get_sub_nodes);
154
155/** 143/**
156 * snd_hda_get_connections - get connection list 144 * snd_hda_get_connections - get connection list
157 * @codec: the HDA codec 145 * @codec: the HDA codec
@@ -187,12 +175,13 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
187 conn_len = parm & AC_CLIST_LENGTH; 175 conn_len = parm & AC_CLIST_LENGTH;
188 mask = (1 << (shift-1)) - 1; 176 mask = (1 << (shift-1)) - 1;
189 177
190 if (! conn_len) 178 if (!conn_len)
191 return 0; /* no connection */ 179 return 0; /* no connection */
192 180
193 if (conn_len == 1) { 181 if (conn_len == 1) {
194 /* single connection */ 182 /* single connection */
195 parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, 0); 183 parm = snd_hda_codec_read(codec, nid, 0,
184 AC_VERB_GET_CONNECT_LIST, 0);
196 conn_list[0] = parm & mask; 185 conn_list[0] = parm & mask;
197 return 1; 186 return 1;
198 } 187 }
@@ -207,18 +196,21 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
207 if (i % num_elems == 0) 196 if (i % num_elems == 0)
208 parm = snd_hda_codec_read(codec, nid, 0, 197 parm = snd_hda_codec_read(codec, nid, 0,
209 AC_VERB_GET_CONNECT_LIST, i); 198 AC_VERB_GET_CONNECT_LIST, i);
210 range_val = !! (parm & (1 << (shift-1))); /* ranges */ 199 range_val = !!(parm & (1 << (shift-1))); /* ranges */
211 val = parm & mask; 200 val = parm & mask;
212 parm >>= shift; 201 parm >>= shift;
213 if (range_val) { 202 if (range_val) {
214 /* ranges between the previous and this one */ 203 /* ranges between the previous and this one */
215 if (! prev_nid || prev_nid >= val) { 204 if (!prev_nid || prev_nid >= val) {
216 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val); 205 snd_printk(KERN_WARNING "hda_codec: "
206 "invalid dep_range_val %x:%x\n",
207 prev_nid, val);
217 continue; 208 continue;
218 } 209 }
219 for (n = prev_nid + 1; n <= val; n++) { 210 for (n = prev_nid + 1; n <= val; n++) {
220 if (conns >= max_conns) { 211 if (conns >= max_conns) {
221 snd_printk(KERN_ERR "Too many connections\n"); 212 snd_printk(KERN_ERR
213 "Too many connections\n");
222 return -EINVAL; 214 return -EINVAL;
223 } 215 }
224 conn_list[conns++] = n; 216 conn_list[conns++] = n;
@@ -253,7 +245,8 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
253 struct hda_bus_unsolicited *unsol; 245 struct hda_bus_unsolicited *unsol;
254 unsigned int wp; 246 unsigned int wp;
255 247
256 if ((unsol = bus->unsol) == NULL) 248 unsol = bus->unsol;
249 if (!unsol)
257 return 0; 250 return 0;
258 251
259 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE; 252 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
@@ -268,8 +261,6 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
268 return 0; 261 return 0;
269} 262}
270 263
271EXPORT_SYMBOL(snd_hda_queue_unsol_event);
272
273/* 264/*
274 * process queueud unsolicited events 265 * process queueud unsolicited events
275 */ 266 */
@@ -287,7 +278,7 @@ static void process_unsol_events(struct work_struct *work)
287 rp <<= 1; 278 rp <<= 1;
288 res = unsol->queue[rp]; 279 res = unsol->queue[rp];
289 caddr = unsol->queue[rp + 1]; 280 caddr = unsol->queue[rp + 1];
290 if (! (caddr & (1 << 4))) /* no unsolicited event? */ 281 if (!(caddr & (1 << 4))) /* no unsolicited event? */
291 continue; 282 continue;
292 codec = bus->caddr_tbl[caddr & 0x0f]; 283 codec = bus->caddr_tbl[caddr & 0x0f];
293 if (codec && codec->patch_ops.unsol_event) 284 if (codec && codec->patch_ops.unsol_event)
@@ -298,7 +289,7 @@ static void process_unsol_events(struct work_struct *work)
298/* 289/*
299 * initialize unsolicited queue 290 * initialize unsolicited queue
300 */ 291 */
301static int init_unsol_queue(struct hda_bus *bus) 292static int __devinit init_unsol_queue(struct hda_bus *bus)
302{ 293{
303 struct hda_bus_unsolicited *unsol; 294 struct hda_bus_unsolicited *unsol;
304 295
@@ -306,8 +297,9 @@ static int init_unsol_queue(struct hda_bus *bus)
306 return 0; 297 return 0;
307 298
308 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); 299 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
309 if (! unsol) { 300 if (!unsol) {
310 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); 301 snd_printk(KERN_ERR "hda_codec: "
302 "can't allocate unsolicited queue\n");
311 return -ENOMEM; 303 return -ENOMEM;
312 } 304 }
313 INIT_WORK(&unsol->work, process_unsol_events); 305 INIT_WORK(&unsol->work, process_unsol_events);
@@ -323,16 +315,15 @@ static void snd_hda_codec_free(struct hda_codec *codec);
323 315
324static int snd_hda_bus_free(struct hda_bus *bus) 316static int snd_hda_bus_free(struct hda_bus *bus)
325{ 317{
326 struct list_head *p, *n; 318 struct hda_codec *codec, *n;
327 319
328 if (! bus) 320 if (!bus)
329 return 0; 321 return 0;
330 if (bus->unsol) { 322 if (bus->unsol) {
331 flush_scheduled_work(); 323 flush_scheduled_work();
332 kfree(bus->unsol); 324 kfree(bus->unsol);
333 } 325 }
334 list_for_each_safe(p, n, &bus->codec_list) { 326 list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
335 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
336 snd_hda_codec_free(codec); 327 snd_hda_codec_free(codec);
337 } 328 }
338 if (bus->ops.private_free) 329 if (bus->ops.private_free)
@@ -355,8 +346,9 @@ static int snd_hda_bus_dev_free(struct snd_device *device)
355 * 346 *
356 * Returns 0 if successful, or a negative error code. 347 * Returns 0 if successful, or a negative error code.
357 */ 348 */
358int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 349int __devinit snd_hda_bus_new(struct snd_card *card,
359 struct hda_bus **busp) 350 const struct hda_bus_template *temp,
351 struct hda_bus **busp)
360{ 352{
361 struct hda_bus *bus; 353 struct hda_bus *bus;
362 int err; 354 int err;
@@ -385,7 +377,8 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
385 mutex_init(&bus->cmd_mutex); 377 mutex_init(&bus->cmd_mutex);
386 INIT_LIST_HEAD(&bus->codec_list); 378 INIT_LIST_HEAD(&bus->codec_list);
387 379
388 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { 380 err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
381 if (err < 0) {
389 snd_hda_bus_free(bus); 382 snd_hda_bus_free(bus);
390 return err; 383 return err;
391 } 384 }
@@ -394,22 +387,24 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
394 return 0; 387 return 0;
395} 388}
396 389
397EXPORT_SYMBOL(snd_hda_bus_new);
398
399/* 390/*
400 * find a matching codec preset 391 * find a matching codec preset
401 */ 392 */
402static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec) 393static const struct hda_codec_preset __devinit *
394find_codec_preset(struct hda_codec *codec)
403{ 395{
404 const struct hda_codec_preset **tbl, *preset; 396 const struct hda_codec_preset **tbl, *preset;
405 397
398 if (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
399 return NULL; /* use the generic parser */
400
406 for (tbl = hda_preset_tables; *tbl; tbl++) { 401 for (tbl = hda_preset_tables; *tbl; tbl++) {
407 for (preset = *tbl; preset->id; preset++) { 402 for (preset = *tbl; preset->id; preset++) {
408 u32 mask = preset->mask; 403 u32 mask = preset->mask;
409 if (! mask) 404 if (!mask)
410 mask = ~0; 405 mask = ~0;
411 if (preset->id == (codec->vendor_id & mask) && 406 if (preset->id == (codec->vendor_id & mask) &&
412 (! preset->rev || 407 (!preset->rev ||
413 preset->rev == codec->revision_id)) 408 preset->rev == codec->revision_id))
414 return preset; 409 return preset;
415 } 410 }
@@ -434,27 +429,30 @@ void snd_hda_get_codec_name(struct hda_codec *codec,
434 break; 429 break;
435 } 430 }
436 } 431 }
437 if (! vendor) { 432 if (!vendor) {
438 sprintf(tmp, "Generic %04x", vendor_id); 433 sprintf(tmp, "Generic %04x", vendor_id);
439 vendor = tmp; 434 vendor = tmp;
440 } 435 }
441 if (codec->preset && codec->preset->name) 436 if (codec->preset && codec->preset->name)
442 snprintf(name, namelen, "%s %s", vendor, codec->preset->name); 437 snprintf(name, namelen, "%s %s", vendor, codec->preset->name);
443 else 438 else
444 snprintf(name, namelen, "%s ID %x", vendor, codec->vendor_id & 0xffff); 439 snprintf(name, namelen, "%s ID %x", vendor,
440 codec->vendor_id & 0xffff);
445} 441}
446 442
447/* 443/*
448 * look for an AFG and MFG nodes 444 * look for an AFG and MFG nodes
449 */ 445 */
450static void setup_fg_nodes(struct hda_codec *codec) 446static void __devinit setup_fg_nodes(struct hda_codec *codec)
451{ 447{
452 int i, total_nodes; 448 int i, total_nodes;
453 hda_nid_t nid; 449 hda_nid_t nid;
454 450
455 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 451 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
456 for (i = 0; i < total_nodes; i++, nid++) { 452 for (i = 0; i < total_nodes; i++, nid++) {
457 switch((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff)) { 453 unsigned int func;
454 func = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE);
455 switch (func & 0xff) {
458 case AC_GRP_AUDIO_FUNCTION: 456 case AC_GRP_AUDIO_FUNCTION:
459 codec->afg = nid; 457 codec->afg = nid;
460 break; 458 break;
@@ -478,7 +476,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
478 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, 476 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node,
479 &codec->start_nid); 477 &codec->start_nid);
480 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL); 478 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
481 if (! codec->wcaps) 479 if (!codec->wcaps)
482 return -ENOMEM; 480 return -ENOMEM;
483 nid = codec->start_nid; 481 nid = codec->start_nid;
484 for (i = 0; i < codec->num_nodes; i++, nid++) 482 for (i = 0; i < codec->num_nodes; i++, nid++)
@@ -493,7 +491,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
493 */ 491 */
494static void snd_hda_codec_free(struct hda_codec *codec) 492static void snd_hda_codec_free(struct hda_codec *codec)
495{ 493{
496 if (! codec) 494 if (!codec)
497 return; 495 return;
498 list_del(&codec->list); 496 list_del(&codec->list);
499 codec->bus->caddr_tbl[codec->addr] = NULL; 497 codec->bus->caddr_tbl[codec->addr] = NULL;
@@ -514,8 +512,8 @@ static void init_amp_hash(struct hda_codec *codec);
514 * 512 *
515 * Returns 0 if successful, or a negative error code. 513 * Returns 0 if successful, or a negative error code.
516 */ 514 */
517int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 515int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
518 struct hda_codec **codecp) 516 struct hda_codec **codecp)
519{ 517{
520 struct hda_codec *codec; 518 struct hda_codec *codec;
521 char component[13]; 519 char component[13];
@@ -525,7 +523,8 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
525 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL); 523 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL);
526 524
527 if (bus->caddr_tbl[codec_addr]) { 525 if (bus->caddr_tbl[codec_addr]) {
528 snd_printk(KERN_ERR "hda_codec: address 0x%x is already occupied\n", codec_addr); 526 snd_printk(KERN_ERR "hda_codec: "
527 "address 0x%x is already occupied\n", codec_addr);
529 return -EBUSY; 528 return -EBUSY;
530 } 529 }
531 530
@@ -543,18 +542,21 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
543 list_add_tail(&codec->list, &bus->codec_list); 542 list_add_tail(&codec->list, &bus->codec_list);
544 bus->caddr_tbl[codec_addr] = codec; 543 bus->caddr_tbl[codec_addr] = codec;
545 544
546 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); 545 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
546 AC_PAR_VENDOR_ID);
547 if (codec->vendor_id == -1) 547 if (codec->vendor_id == -1)
548 /* read again, hopefully the access method was corrected 548 /* read again, hopefully the access method was corrected
549 * in the last read... 549 * in the last read...
550 */ 550 */
551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, 551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
552 AC_PAR_VENDOR_ID); 552 AC_PAR_VENDOR_ID);
553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_SUBSYSTEM_ID); 553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT,
554 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID); 554 AC_PAR_SUBSYSTEM_ID);
555 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT,
556 AC_PAR_REV_ID);
555 557
556 setup_fg_nodes(codec); 558 setup_fg_nodes(codec);
557 if (! codec->afg && ! codec->mfg) { 559 if (!codec->afg && !codec->mfg) {
558 snd_printdd("hda_codec: no AFG or MFG node found\n"); 560 snd_printdd("hda_codec: no AFG or MFG node found\n");
559 snd_hda_codec_free(codec); 561 snd_hda_codec_free(codec);
560 return -ENODEV; 562 return -ENODEV;
@@ -566,15 +568,16 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
566 return -ENOMEM; 568 return -ENOMEM;
567 } 569 }
568 570
569 if (! codec->subsystem_id) { 571 if (!codec->subsystem_id) {
570 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 572 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
571 codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, 573 codec->subsystem_id =
572 AC_VERB_GET_SUBSYSTEM_ID, 574 snd_hda_codec_read(codec, nid, 0,
573 0); 575 AC_VERB_GET_SUBSYSTEM_ID, 0);
574 } 576 }
575 577
576 codec->preset = find_codec_preset(codec); 578 codec->preset = find_codec_preset(codec);
577 if (! *bus->card->mixername) 579 /* audio codec should override the mixer name */
580 if (codec->afg || !*bus->card->mixername)
578 snd_hda_get_codec_name(codec, bus->card->mixername, 581 snd_hda_get_codec_name(codec, bus->card->mixername,
579 sizeof(bus->card->mixername)); 582 sizeof(bus->card->mixername));
580 583
@@ -600,8 +603,6 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
600 return 0; 603 return 0;
601} 604}
602 605
603EXPORT_SYMBOL(snd_hda_codec_new);
604
605/** 606/**
606 * snd_hda_codec_setup_stream - set up the codec for streaming 607 * snd_hda_codec_setup_stream - set up the codec for streaming
607 * @codec: the CODEC to set up 608 * @codec: the CODEC to set up
@@ -610,13 +611,15 @@ EXPORT_SYMBOL(snd_hda_codec_new);
610 * @channel_id: channel id to pass, zero based. 611 * @channel_id: channel id to pass, zero based.
611 * @format: stream format. 612 * @format: stream format.
612 */ 613 */
613void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 614void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
615 u32 stream_tag,
614 int channel_id, int format) 616 int channel_id, int format)
615{ 617{
616 if (! nid) 618 if (!nid)
617 return; 619 return;
618 620
619 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 621 snd_printdd("hda_codec_setup_stream: "
622 "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
620 nid, stream_tag, channel_id, format); 623 nid, stream_tag, channel_id, format);
621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
622 (stream_tag << 4) | channel_id); 625 (stream_tag << 4) | channel_id);
@@ -624,8 +627,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stre
624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
625} 628}
626 629
627EXPORT_SYMBOL(snd_hda_codec_setup_stream);
628
629/* 630/*
630 * amp access functions 631 * amp access functions
631 */ 632 */
@@ -636,7 +637,7 @@ EXPORT_SYMBOL(snd_hda_codec_setup_stream);
636#define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 637#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
637 638
638/* initialize the hash table */ 639/* initialize the hash table */
639static void init_amp_hash(struct hda_codec *codec) 640static void __devinit init_amp_hash(struct hda_codec *codec)
640{ 641{
641 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); 642 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash));
642 codec->num_amp_entries = 0; 643 codec->num_amp_entries = 0;
@@ -662,15 +663,18 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
662 if (codec->num_amp_entries >= codec->amp_info_size) { 663 if (codec->num_amp_entries >= codec->amp_info_size) {
663 /* reallocate the array */ 664 /* reallocate the array */
664 int new_size = codec->amp_info_size + 64; 665 int new_size = codec->amp_info_size + 64;
665 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), 666 struct hda_amp_info *new_info;
666 GFP_KERNEL); 667 new_info = kcalloc(new_size, sizeof(struct hda_amp_info),
667 if (! new_info) { 668 GFP_KERNEL);
668 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); 669 if (!new_info) {
670 snd_printk(KERN_ERR "hda_codec: "
671 "can't malloc amp_info\n");
669 return NULL; 672 return NULL;
670 } 673 }
671 if (codec->amp_info) { 674 if (codec->amp_info) {
672 memcpy(new_info, codec->amp_info, 675 memcpy(new_info, codec->amp_info,
673 codec->amp_info_size * sizeof(struct hda_amp_info)); 676 codec->amp_info_size *
677 sizeof(struct hda_amp_info));
674 kfree(codec->amp_info); 678 kfree(codec->amp_info);
675 } 679 }
676 codec->amp_info_size = new_size; 680 codec->amp_info_size = new_size;
@@ -691,26 +695,44 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
691 */ 695 */
692static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) 696static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
693{ 697{
694 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0)); 698 struct hda_amp_info *info;
695 699
696 if (! info) 700 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0));
701 if (!info)
697 return 0; 702 return 0;
698 if (! (info->status & INFO_AMP_CAPS)) { 703 if (!(info->status & INFO_AMP_CAPS)) {
699 if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) 704 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
700 nid = codec->afg; 705 nid = codec->afg;
701 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ? 706 info->amp_caps = snd_hda_param_read(codec, nid,
702 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); 707 direction == HDA_OUTPUT ?
703 info->status |= INFO_AMP_CAPS; 708 AC_PAR_AMP_OUT_CAP :
709 AC_PAR_AMP_IN_CAP);
710 if (info->amp_caps)
711 info->status |= INFO_AMP_CAPS;
704 } 712 }
705 return info->amp_caps; 713 return info->amp_caps;
706} 714}
707 715
716int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
717 unsigned int caps)
718{
719 struct hda_amp_info *info;
720
721 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, dir, 0));
722 if (!info)
723 return -EINVAL;
724 info->amp_caps = caps;
725 info->status |= INFO_AMP_CAPS;
726 return 0;
727}
728
708/* 729/*
709 * read the current volume to info 730 * read the current volume to info
710 * if the cache exists, read the cache value. 731 * if the cache exists, read the cache value.
711 */ 732 */
712static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 733static unsigned int get_vol_mute(struct hda_codec *codec,
713 hda_nid_t nid, int ch, int direction, int index) 734 struct hda_amp_info *info, hda_nid_t nid,
735 int ch, int direction, int index)
714{ 736{
715 u32 val, parm; 737 u32 val, parm;
716 738
@@ -720,7 +742,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
720 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; 742 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
721 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 743 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
722 parm |= index; 744 parm |= index;
723 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 745 val = snd_hda_codec_read(codec, nid, 0,
746 AC_VERB_GET_AMP_GAIN_MUTE, parm);
724 info->vol[ch] = val & 0xff; 747 info->vol[ch] = val & 0xff;
725 info->status |= INFO_AMP_VOL(ch); 748 info->status |= INFO_AMP_VOL(ch);
726 return info->vol[ch]; 749 return info->vol[ch];
@@ -730,7 +753,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
730 * write the current volume in info to the h/w and update the cache 753 * write the current volume in info to the h/w and update the cache
731 */ 754 */
732static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 755static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
733 hda_nid_t nid, int ch, int direction, int index, int val) 756 hda_nid_t nid, int ch, int direction, int index,
757 int val)
734{ 758{
735 u32 parm; 759 u32 parm;
736 760
@@ -748,8 +772,9 @@ static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
748int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 772int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
749 int direction, int index) 773 int direction, int index)
750{ 774{
751 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 775 struct hda_amp_info *info;
752 if (! info) 776 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
777 if (!info)
753 return 0; 778 return 0;
754 return get_vol_mute(codec, info, nid, ch, direction, index); 779 return get_vol_mute(codec, info, nid, ch, direction, index);
755} 780}
@@ -760,13 +785,14 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
760int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, 785int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
761 int direction, int idx, int mask, int val) 786 int direction, int idx, int mask, int val)
762{ 787{
763 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 788 struct hda_amp_info *info;
764 789
765 if (! info) 790 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
791 if (!info)
766 return 0; 792 return 0;
767 val &= mask; 793 val &= mask;
768 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 794 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
769 if (info->vol[ch] == val && ! codec->in_resume) 795 if (info->vol[ch] == val && !codec->in_resume)
770 return 0; 796 return 0;
771 put_vol_mute(codec, info, nid, ch, direction, idx, val); 797 put_vol_mute(codec, info, nid, ch, direction, idx, val);
772 return 1; 798 return 1;
@@ -783,7 +809,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
783#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 809#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
784 810
785/* volume */ 811/* volume */
786int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 812int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_info *uinfo)
787{ 814{
788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 815 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
789 u16 nid = get_amp_nid(kcontrol); 816 u16 nid = get_amp_nid(kcontrol);
@@ -792,9 +819,11 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
792 u32 caps; 819 u32 caps;
793 820
794 caps = query_amp_caps(codec, nid, dir); 821 caps = query_amp_caps(codec, nid, dir);
795 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; /* num steps */ 822 /* num steps */
796 if (! caps) { 823 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
797 printk(KERN_WARNING "hda_codec: num_steps = 0 for NID=0x%x\n", nid); 824 if (!caps) {
825 printk(KERN_WARNING "hda_codec: "
826 "num_steps = 0 for NID=0x%x\n", nid);
798 return -EINVAL; 827 return -EINVAL;
799 } 828 }
800 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 829 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -804,7 +833,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
804 return 0; 833 return 0;
805} 834}
806 835
807int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 836int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
837 struct snd_ctl_elem_value *ucontrol)
808{ 838{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 839 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 hda_nid_t nid = get_amp_nid(kcontrol); 840 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -820,7 +850,8 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 return 0; 850 return 0;
821} 851}
822 852
823int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 853int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
854 struct snd_ctl_elem_value *ucontrol)
824{ 855{
825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
826 hda_nid_t nid = get_amp_nid(kcontrol); 857 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -852,7 +883,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
852 if (size < 4 * sizeof(unsigned int)) 883 if (size < 4 * sizeof(unsigned int))
853 return -ENOMEM; 884 return -ENOMEM;
854 caps = query_amp_caps(codec, nid, dir); 885 caps = query_amp_caps(codec, nid, dir);
855 val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25; 886 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
887 val2 = (val2 + 1) * 25;
856 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 888 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
857 val1 = ((int)val1) * ((int)val2); 889 val1 = ((int)val1) * ((int)val2);
858 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 890 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
@@ -867,7 +899,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
867} 899}
868 900
869/* switch */ 901/* switch */
870int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 902int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
903 struct snd_ctl_elem_info *uinfo)
871{ 904{
872 int chs = get_amp_channels(kcontrol); 905 int chs = get_amp_channels(kcontrol);
873 906
@@ -878,7 +911,8 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
878 return 0; 911 return 0;
879} 912}
880 913
881int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 914int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
915 struct snd_ctl_elem_value *ucontrol)
882{ 916{
883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 917 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
884 hda_nid_t nid = get_amp_nid(kcontrol); 918 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -888,13 +922,16 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
888 long *valp = ucontrol->value.integer.value; 922 long *valp = ucontrol->value.integer.value;
889 923
890 if (chs & 1) 924 if (chs & 1)
891 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80) ? 0 : 1; 925 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
926 0x80) ? 0 : 1;
892 if (chs & 2) 927 if (chs & 2)
893 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80) ? 0 : 1; 928 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
929 0x80) ? 0 : 1;
894 return 0; 930 return 0;
895} 931}
896 932
897int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 933int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
934 struct snd_ctl_elem_value *ucontrol)
898{ 935{
899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 936 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
900 hda_nid_t nid = get_amp_nid(kcontrol); 937 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -925,7 +962,8 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
925#define AMP_VAL_IDX_SHIFT 19 962#define AMP_VAL_IDX_SHIFT 19
926#define AMP_VAL_IDX_MASK (0x0f<<19) 963#define AMP_VAL_IDX_MASK (0x0f<<19)
927 964
928int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 965int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
966 struct snd_ctl_elem_value *ucontrol)
929{ 967{
930 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 968 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
931 unsigned long pval; 969 unsigned long pval;
@@ -940,7 +978,8 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
940 return err; 978 return err;
941} 979}
942 980
943int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 981int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
982 struct snd_ctl_elem_value *ucontrol)
944{ 983{
945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
946 unsigned long pval; 985 unsigned long pval;
@@ -950,7 +989,8 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
950 pval = kcontrol->private_value; 989 pval = kcontrol->private_value;
951 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 990 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
952 for (i = 0; i < indices; i++) { 991 for (i = 0; i < indices; i++) {
953 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 992 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) |
993 (i << AMP_VAL_IDX_SHIFT);
954 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 994 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
955 if (err < 0) 995 if (err < 0)
956 break; 996 break;
@@ -965,14 +1005,16 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
965 * SPDIF out controls 1005 * SPDIF out controls
966 */ 1006 */
967 1007
968static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1008static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol,
1009 struct snd_ctl_elem_info *uinfo)
969{ 1010{
970 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 1011 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
971 uinfo->count = 1; 1012 uinfo->count = 1;
972 return 0; 1013 return 0;
973} 1014}
974 1015
975static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1016static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol,
1017 struct snd_ctl_elem_value *ucontrol)
976{ 1018{
977 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1019 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
978 IEC958_AES0_NONAUDIO | 1020 IEC958_AES0_NONAUDIO |
@@ -983,7 +1025,8 @@ static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
983 return 0; 1025 return 0;
984} 1026}
985 1027
986static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1028static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol,
1029 struct snd_ctl_elem_value *ucontrol)
987{ 1030{
988 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1031 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
989 IEC958_AES0_NONAUDIO | 1032 IEC958_AES0_NONAUDIO |
@@ -991,7 +1034,8 @@ static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
991 return 0; 1034 return 0;
992} 1035}
993 1036
994static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1037static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol,
1038 struct snd_ctl_elem_value *ucontrol)
995{ 1039{
996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
997 1041
@@ -1011,19 +1055,21 @@ static unsigned short convert_from_spdif_status(unsigned int sbits)
1011 unsigned short val = 0; 1055 unsigned short val = 0;
1012 1056
1013 if (sbits & IEC958_AES0_PROFESSIONAL) 1057 if (sbits & IEC958_AES0_PROFESSIONAL)
1014 val |= 1 << 6; 1058 val |= AC_DIG1_PROFESSIONAL;
1015 if (sbits & IEC958_AES0_NONAUDIO) 1059 if (sbits & IEC958_AES0_NONAUDIO)
1016 val |= 1 << 5; 1060 val |= AC_DIG1_NONAUDIO;
1017 if (sbits & IEC958_AES0_PROFESSIONAL) { 1061 if (sbits & IEC958_AES0_PROFESSIONAL) {
1018 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) 1062 if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
1019 val |= 1 << 3; 1063 IEC958_AES0_PRO_EMPHASIS_5015)
1064 val |= AC_DIG1_EMPHASIS;
1020 } else { 1065 } else {
1021 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015) 1066 if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
1022 val |= 1 << 3; 1067 IEC958_AES0_CON_EMPHASIS_5015)
1023 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT)) 1068 val |= AC_DIG1_EMPHASIS;
1024 val |= 1 << 4; 1069 if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
1070 val |= AC_DIG1_COPYRIGHT;
1025 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8)) 1071 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
1026 val |= 1 << 7; 1072 val |= AC_DIG1_LEVEL;
1027 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8); 1073 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
1028 } 1074 }
1029 return val; 1075 return val;
@@ -1035,26 +1081,27 @@ static unsigned int convert_to_spdif_status(unsigned short val)
1035{ 1081{
1036 unsigned int sbits = 0; 1082 unsigned int sbits = 0;
1037 1083
1038 if (val & (1 << 5)) 1084 if (val & AC_DIG1_NONAUDIO)
1039 sbits |= IEC958_AES0_NONAUDIO; 1085 sbits |= IEC958_AES0_NONAUDIO;
1040 if (val & (1 << 6)) 1086 if (val & AC_DIG1_PROFESSIONAL)
1041 sbits |= IEC958_AES0_PROFESSIONAL; 1087 sbits |= IEC958_AES0_PROFESSIONAL;
1042 if (sbits & IEC958_AES0_PROFESSIONAL) { 1088 if (sbits & IEC958_AES0_PROFESSIONAL) {
1043 if (sbits & (1 << 3)) 1089 if (sbits & AC_DIG1_EMPHASIS)
1044 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 1090 sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
1045 } else { 1091 } else {
1046 if (val & (1 << 3)) 1092 if (val & AC_DIG1_EMPHASIS)
1047 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 1093 sbits |= IEC958_AES0_CON_EMPHASIS_5015;
1048 if (! (val & (1 << 4))) 1094 if (!(val & AC_DIG1_COPYRIGHT))
1049 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 1095 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
1050 if (val & (1 << 7)) 1096 if (val & AC_DIG1_LEVEL)
1051 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 1097 sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
1052 sbits |= val & (0x7f << 8); 1098 sbits |= val & (0x7f << 8);
1053 } 1099 }
1054 return sbits; 1100 return sbits;
1055} 1101}
1056 1102
1057static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1103static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
1104 struct snd_ctl_elem_value *ucontrol)
1058{ 1105{
1059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1060 hda_nid_t nid = kcontrol->private_value; 1107 hda_nid_t nid = kcontrol->private_value;
@@ -1072,15 +1119,18 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1072 codec->spdif_ctls = val; 1119 codec->spdif_ctls = val;
1073 1120
1074 if (change || codec->in_resume) { 1121 if (change || codec->in_resume) {
1075 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1122 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 1123 val & 0xff);
1124 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2,
1125 val >> 8);
1077 } 1126 }
1078 1127
1079 mutex_unlock(&codec->spdif_mutex); 1128 mutex_unlock(&codec->spdif_mutex);
1080 return change; 1129 return change;
1081} 1130}
1082 1131
1083static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1132static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol,
1133 struct snd_ctl_elem_info *uinfo)
1084{ 1134{
1085 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1135 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1086 uinfo->count = 1; 1136 uinfo->count = 1;
@@ -1089,15 +1139,17 @@ static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct s
1089 return 0; 1139 return 0;
1090} 1140}
1091 1141
1092static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1142static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,
1143 struct snd_ctl_elem_value *ucontrol)
1093{ 1144{
1094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1145 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1095 1146
1096 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 1147 ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
1097 return 0; 1148 return 0;
1098} 1149}
1099 1150
1100static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1151static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
1152 struct snd_ctl_elem_value *ucontrol)
1101{ 1153{
1102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1154 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1103 hda_nid_t nid = kcontrol->private_value; 1155 hda_nid_t nid = kcontrol->private_value;
@@ -1105,16 +1157,21 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1105 int change; 1157 int change;
1106 1158
1107 mutex_lock(&codec->spdif_mutex); 1159 mutex_lock(&codec->spdif_mutex);
1108 val = codec->spdif_ctls & ~1; 1160 val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
1109 if (ucontrol->value.integer.value[0]) 1161 if (ucontrol->value.integer.value[0])
1110 val |= 1; 1162 val |= AC_DIG1_ENABLE;
1111 change = codec->spdif_ctls != val; 1163 change = codec->spdif_ctls != val;
1112 if (change || codec->in_resume) { 1164 if (change || codec->in_resume) {
1113 codec->spdif_ctls = val; 1165 codec->spdif_ctls = val;
1114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1115 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1167 val & 0xff);
1116 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1168 /* unmute amp switch (if any) */
1117 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1169 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
1170 (val & AC_DIG1_ENABLE))
1171 snd_hda_codec_write(codec, nid, 0,
1172 AC_VERB_SET_AMP_GAIN_MUTE,
1173 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1174 AC_AMP_SET_OUTPUT);
1118 } 1175 }
1119 mutex_unlock(&codec->spdif_mutex); 1176 mutex_unlock(&codec->spdif_mutex);
1120 return change; 1177 return change;
@@ -1162,7 +1219,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1162 * 1219 *
1163 * Returns 0 if successful, or a negative error code. 1220 * Returns 0 if successful, or a negative error code.
1164 */ 1221 */
1165int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) 1222int __devinit snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
1223 hda_nid_t nid)
1166{ 1224{
1167 int err; 1225 int err;
1168 struct snd_kcontrol *kctl; 1226 struct snd_kcontrol *kctl;
@@ -1171,10 +1229,12 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1171 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1229 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1172 kctl = snd_ctl_new1(dig_mix, codec); 1230 kctl = snd_ctl_new1(dig_mix, codec);
1173 kctl->private_value = nid; 1231 kctl->private_value = nid;
1174 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1232 err = snd_ctl_add(codec->bus->card, kctl);
1233 if (err < 0)
1175 return err; 1234 return err;
1176 } 1235 }
1177 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1236 codec->spdif_ctls =
1237 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1178 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1238 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1179 return 0; 1239 return 0;
1180} 1240}
@@ -1185,7 +1245,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1185 1245
1186#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info 1246#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info
1187 1247
1188static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1248static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol,
1249 struct snd_ctl_elem_value *ucontrol)
1189{ 1250{
1190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1191 1252
@@ -1193,7 +1254,8 @@ static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd
1193 return 0; 1254 return 0;
1194} 1255}
1195 1256
1196static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1257static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol,
1258 struct snd_ctl_elem_value *ucontrol)
1197{ 1259{
1198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1199 hda_nid_t nid = kcontrol->private_value; 1261 hda_nid_t nid = kcontrol->private_value;
@@ -1204,13 +1266,15 @@ static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd
1204 change = codec->spdif_in_enable != val; 1266 change = codec->spdif_in_enable != val;
1205 if (change || codec->in_resume) { 1267 if (change || codec->in_resume) {
1206 codec->spdif_in_enable = val; 1268 codec->spdif_in_enable = val;
1207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1269 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1270 val);
1208 } 1271 }
1209 mutex_unlock(&codec->spdif_mutex); 1272 mutex_unlock(&codec->spdif_mutex);
1210 return change; 1273 return change;
1211} 1274}
1212 1275
1213static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1276static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
1277 struct snd_ctl_elem_value *ucontrol)
1214{ 1278{
1215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1279 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1216 hda_nid_t nid = kcontrol->private_value; 1280 hda_nid_t nid = kcontrol->private_value;
@@ -1254,7 +1318,8 @@ static struct snd_kcontrol_new dig_in_ctls[] = {
1254 * 1318 *
1255 * Returns 0 if successful, or a negative error code. 1319 * Returns 0 if successful, or a negative error code.
1256 */ 1320 */
1257int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) 1321int __devinit snd_hda_create_spdif_in_ctls(struct hda_codec *codec,
1322 hda_nid_t nid)
1258{ 1323{
1259 int err; 1324 int err;
1260 struct snd_kcontrol *kctl; 1325 struct snd_kcontrol *kctl;
@@ -1263,10 +1328,13 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1263 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1328 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1264 kctl = snd_ctl_new1(dig_mix, codec); 1329 kctl = snd_ctl_new1(dig_mix, codec);
1265 kctl->private_value = nid; 1330 kctl->private_value = nid;
1266 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1331 err = snd_ctl_add(codec->bus->card, kctl);
1332 if (err < 0)
1267 return err; 1333 return err;
1268 } 1334 }
1269 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1335 codec->spdif_in_enable =
1336 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) &
1337 AC_DIG1_ENABLE;
1270 return 0; 1338 return 0;
1271} 1339}
1272 1340
@@ -1304,15 +1372,14 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1304 * 1372 *
1305 * Returns 0 if successful, otherwise a negative error code. 1373 * Returns 0 if successful, otherwise a negative error code.
1306 */ 1374 */
1307int snd_hda_build_controls(struct hda_bus *bus) 1375int __devinit snd_hda_build_controls(struct hda_bus *bus)
1308{ 1376{
1309 struct list_head *p; 1377 struct hda_codec *codec;
1310 1378
1311 /* build controls */ 1379 /* build controls */
1312 list_for_each(p, &bus->codec_list) { 1380 list_for_each_entry(codec, &bus->codec_list, list) {
1313 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1314 int err; 1381 int err;
1315 if (! codec->patch_ops.build_controls) 1382 if (!codec->patch_ops.build_controls)
1316 continue; 1383 continue;
1317 err = codec->patch_ops.build_controls(codec); 1384 err = codec->patch_ops.build_controls(codec);
1318 if (err < 0) 1385 if (err < 0)
@@ -1320,13 +1387,12 @@ int snd_hda_build_controls(struct hda_bus *bus)
1320 } 1387 }
1321 1388
1322 /* initialize */ 1389 /* initialize */
1323 list_for_each(p, &bus->codec_list) { 1390 list_for_each_entry(codec, &bus->codec_list, list) {
1324 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1325 int err; 1391 int err;
1326 hda_set_power_state(codec, 1392 hda_set_power_state(codec,
1327 codec->afg ? codec->afg : codec->mfg, 1393 codec->afg ? codec->afg : codec->mfg,
1328 AC_PWRST_D0); 1394 AC_PWRST_D0);
1329 if (! codec->patch_ops.init) 1395 if (!codec->patch_ops.init)
1330 continue; 1396 continue;
1331 err = codec->patch_ops.init(codec); 1397 err = codec->patch_ops.init(codec);
1332 if (err < 0) 1398 if (err < 0)
@@ -1335,8 +1401,6 @@ int snd_hda_build_controls(struct hda_bus *bus)
1335 return 0; 1401 return 0;
1336} 1402}
1337 1403
1338EXPORT_SYMBOL(snd_hda_build_controls);
1339
1340/* 1404/*
1341 * stream formats 1405 * stream formats
1342 */ 1406 */
@@ -1361,6 +1425,11 @@ static struct hda_rate_tbl rate_bits[] = {
1361 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ 1425 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
1362 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 1426 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
1363 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 1427 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
1428#define AC_PAR_PCM_RATE_BITS 11
1429 /* up to bits 10, 384kHZ isn't supported properly */
1430
1431 /* not autodetected value */
1432 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1364 1433
1365 { 0 } /* terminator */ 1434 { 0 } /* terminator */
1366}; 1435};
@@ -1389,7 +1458,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1389 val = rate_bits[i].hda_fmt; 1458 val = rate_bits[i].hda_fmt;
1390 break; 1459 break;
1391 } 1460 }
1392 if (! rate_bits[i].hz) { 1461 if (!rate_bits[i].hz) {
1393 snd_printdd("invalid rate %d\n", rate); 1462 snd_printdd("invalid rate %d\n", rate);
1394 return 0; 1463 return 0;
1395 } 1464 }
@@ -1414,15 +1483,14 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1414 val |= 0x20; 1483 val |= 0x20;
1415 break; 1484 break;
1416 default: 1485 default:
1417 snd_printdd("invalid format width %d\n", snd_pcm_format_width(format)); 1486 snd_printdd("invalid format width %d\n",
1487 snd_pcm_format_width(format));
1418 return 0; 1488 return 0;
1419 } 1489 }
1420 1490
1421 return val; 1491 return val;
1422} 1492}
1423 1493
1424EXPORT_SYMBOL(snd_hda_calc_stream_format);
1425
1426/** 1494/**
1427 * snd_hda_query_supported_pcm - query the supported PCM rates and formats 1495 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
1428 * @codec: the HDA codec 1496 * @codec: the HDA codec
@@ -1449,12 +1517,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1449 if (val == -1) 1517 if (val == -1)
1450 return -EIO; 1518 return -EIO;
1451 } 1519 }
1452 if (! val) 1520 if (!val)
1453 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1521 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1454 1522
1455 if (ratesp) { 1523 if (ratesp) {
1456 u32 rates = 0; 1524 u32 rates = 0;
1457 for (i = 0; rate_bits[i].hz; i++) { 1525 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) {
1458 if (val & (1 << i)) 1526 if (val & (1 << i))
1459 rates |= rate_bits[i].alsa_bits; 1527 rates |= rate_bits[i].alsa_bits;
1460 } 1528 }
@@ -1470,8 +1538,9 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1470 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1538 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1471 if (streams == -1) 1539 if (streams == -1)
1472 return -EIO; 1540 return -EIO;
1473 if (! streams) { 1541 if (!streams) {
1474 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1542 streams = snd_hda_param_read(codec, codec->afg,
1543 AC_PAR_STREAM);
1475 if (streams == -1) 1544 if (streams == -1)
1476 return -EIO; 1545 return -EIO;
1477 } 1546 }
@@ -1495,7 +1564,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1495 bps = 24; 1564 bps = 24;
1496 else if (val & AC_SUPPCM_BITS_20) 1565 else if (val & AC_SUPPCM_BITS_20)
1497 bps = 20; 1566 bps = 20;
1498 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|AC_SUPPCM_BITS_32)) { 1567 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|
1568 AC_SUPPCM_BITS_32)) {
1499 formats |= SNDRV_PCM_FMTBIT_S32_LE; 1569 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1500 if (val & AC_SUPPCM_BITS_32) 1570 if (val & AC_SUPPCM_BITS_32)
1501 bps = 32; 1571 bps = 32;
@@ -1505,10 +1575,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1505 bps = 20; 1575 bps = 20;
1506 } 1576 }
1507 } 1577 }
1508 else if (streams == AC_SUPFMT_FLOAT32) { /* should be exclusive */ 1578 else if (streams == AC_SUPFMT_FLOAT32) {
1579 /* should be exclusive */
1509 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; 1580 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
1510 bps = 32; 1581 bps = 32;
1511 } else if (streams == AC_SUPFMT_AC3) { /* should be exclusive */ 1582 } else if (streams == AC_SUPFMT_AC3) {
1583 /* should be exclusive */
1512 /* temporary hack: we have still no proper support 1584 /* temporary hack: we have still no proper support
1513 * for the direct AC3 stream... 1585 * for the direct AC3 stream...
1514 */ 1586 */
@@ -1525,7 +1597,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1525} 1597}
1526 1598
1527/** 1599/**
1528 * snd_hda_is_supported_format - check whether the given node supports the format val 1600 * snd_hda_is_supported_format - check whether the given node supports
1601 * the format val
1529 * 1602 *
1530 * Returns 1 if supported, 0 if not. 1603 * Returns 1 if supported, 0 if not.
1531 */ 1604 */
@@ -1541,50 +1614,50 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1541 if (val == -1) 1614 if (val == -1)
1542 return 0; 1615 return 0;
1543 } 1616 }
1544 if (! val) { 1617 if (!val) {
1545 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1618 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1546 if (val == -1) 1619 if (val == -1)
1547 return 0; 1620 return 0;
1548 } 1621 }
1549 1622
1550 rate = format & 0xff00; 1623 rate = format & 0xff00;
1551 for (i = 0; rate_bits[i].hz; i++) 1624 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++)
1552 if (rate_bits[i].hda_fmt == rate) { 1625 if (rate_bits[i].hda_fmt == rate) {
1553 if (val & (1 << i)) 1626 if (val & (1 << i))
1554 break; 1627 break;
1555 return 0; 1628 return 0;
1556 } 1629 }
1557 if (! rate_bits[i].hz) 1630 if (i >= AC_PAR_PCM_RATE_BITS)
1558 return 0; 1631 return 0;
1559 1632
1560 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1633 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1561 if (stream == -1) 1634 if (stream == -1)
1562 return 0; 1635 return 0;
1563 if (! stream && nid != codec->afg) 1636 if (!stream && nid != codec->afg)
1564 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1637 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1565 if (! stream || stream == -1) 1638 if (!stream || stream == -1)
1566 return 0; 1639 return 0;
1567 1640
1568 if (stream & AC_SUPFMT_PCM) { 1641 if (stream & AC_SUPFMT_PCM) {
1569 switch (format & 0xf0) { 1642 switch (format & 0xf0) {
1570 case 0x00: 1643 case 0x00:
1571 if (! (val & AC_SUPPCM_BITS_8)) 1644 if (!(val & AC_SUPPCM_BITS_8))
1572 return 0; 1645 return 0;
1573 break; 1646 break;
1574 case 0x10: 1647 case 0x10:
1575 if (! (val & AC_SUPPCM_BITS_16)) 1648 if (!(val & AC_SUPPCM_BITS_16))
1576 return 0; 1649 return 0;
1577 break; 1650 break;
1578 case 0x20: 1651 case 0x20:
1579 if (! (val & AC_SUPPCM_BITS_20)) 1652 if (!(val & AC_SUPPCM_BITS_20))
1580 return 0; 1653 return 0;
1581 break; 1654 break;
1582 case 0x30: 1655 case 0x30:
1583 if (! (val & AC_SUPPCM_BITS_24)) 1656 if (!(val & AC_SUPPCM_BITS_24))
1584 return 0; 1657 return 0;
1585 break; 1658 break;
1586 case 0x40: 1659 case 0x40:
1587 if (! (val & AC_SUPPCM_BITS_32)) 1660 if (!(val & AC_SUPPCM_BITS_32))
1588 return 0; 1661 return 0;
1589 break; 1662 break;
1590 default: 1663 default:
@@ -1625,15 +1698,15 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
1625 return 0; 1698 return 0;
1626} 1699}
1627 1700
1628static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream *info) 1701static int __devinit set_pcm_default_values(struct hda_codec *codec,
1702 struct hda_pcm_stream *info)
1629{ 1703{
1630 if (info->nid) { 1704 /* query support PCM information from the given NID */
1631 /* query support PCM information from the given NID */ 1705 if (info->nid && (!info->rates || !info->formats)) {
1632 if (! info->rates || ! info->formats) 1706 snd_hda_query_supported_pcm(codec, info->nid,
1633 snd_hda_query_supported_pcm(codec, info->nid, 1707 info->rates ? NULL : &info->rates,
1634 info->rates ? NULL : &info->rates, 1708 info->formats ? NULL : &info->formats,
1635 info->formats ? NULL : &info->formats, 1709 info->maxbps ? NULL : &info->maxbps);
1636 info->maxbps ? NULL : &info->maxbps);
1637 } 1710 }
1638 if (info->ops.open == NULL) 1711 if (info->ops.open == NULL)
1639 info->ops.open = hda_pcm_default_open_close; 1712 info->ops.open = hda_pcm_default_open_close;
@@ -1676,15 +1749,14 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream
1676 * 1749 *
1677 * This function returns 0 if successfull, or a negative error code. 1750 * This function returns 0 if successfull, or a negative error code.
1678 */ 1751 */
1679int snd_hda_build_pcms(struct hda_bus *bus) 1752int __devinit snd_hda_build_pcms(struct hda_bus *bus)
1680{ 1753{
1681 struct list_head *p; 1754 struct hda_codec *codec;
1682 1755
1683 list_for_each(p, &bus->codec_list) { 1756 list_for_each_entry(codec, &bus->codec_list, list) {
1684 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1685 unsigned int pcm, s; 1757 unsigned int pcm, s;
1686 int err; 1758 int err;
1687 if (! codec->patch_ops.build_pcms) 1759 if (!codec->patch_ops.build_pcms)
1688 continue; 1760 continue;
1689 err = codec->patch_ops.build_pcms(codec); 1761 err = codec->patch_ops.build_pcms(codec);
1690 if (err < 0) 1762 if (err < 0)
@@ -1693,7 +1765,7 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1693 for (s = 0; s < 2; s++) { 1765 for (s = 0; s < 2; s++) {
1694 struct hda_pcm_stream *info; 1766 struct hda_pcm_stream *info;
1695 info = &codec->pcm_info[pcm].stream[s]; 1767 info = &codec->pcm_info[pcm].stream[s];
1696 if (! info->substreams) 1768 if (!info->substreams)
1697 continue; 1769 continue;
1698 err = set_pcm_default_values(codec, info); 1770 err = set_pcm_default_values(codec, info);
1699 if (err < 0) 1771 if (err < 0)
@@ -1704,8 +1776,6 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1704 return 0; 1776 return 0;
1705} 1777}
1706 1778
1707EXPORT_SYMBOL(snd_hda_build_pcms);
1708
1709/** 1779/**
1710 * snd_hda_check_board_config - compare the current codec with the config table 1780 * snd_hda_check_board_config - compare the current codec with the config table
1711 * @codec: the HDA codec 1781 * @codec: the HDA codec
@@ -1719,9 +1789,9 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1719 * 1789 *
1720 * If no entries are matching, the function returns a negative value. 1790 * If no entries are matching, the function returns a negative value.
1721 */ 1791 */
1722int snd_hda_check_board_config(struct hda_codec *codec, 1792int __devinit snd_hda_check_board_config(struct hda_codec *codec,
1723 int num_configs, const char **models, 1793 int num_configs, const char **models,
1724 const struct snd_pci_quirk *tbl) 1794 const struct snd_pci_quirk *tbl)
1725{ 1795{
1726 if (codec->bus->modelname && models) { 1796 if (codec->bus->modelname && models) {
1727 int i; 1797 int i;
@@ -1771,24 +1841,26 @@ int snd_hda_check_board_config(struct hda_codec *codec,
1771 * 1841 *
1772 * Returns 0 if successful, or a negative error code. 1842 * Returns 0 if successful, or a negative error code.
1773 */ 1843 */
1774int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 1844int __devinit snd_hda_add_new_ctls(struct hda_codec *codec,
1845 struct snd_kcontrol_new *knew)
1775{ 1846{
1776 int err; 1847 int err;
1777 1848
1778 for (; knew->name; knew++) { 1849 for (; knew->name; knew++) {
1779 struct snd_kcontrol *kctl; 1850 struct snd_kcontrol *kctl;
1780 kctl = snd_ctl_new1(knew, codec); 1851 kctl = snd_ctl_new1(knew, codec);
1781 if (! kctl) 1852 if (!kctl)
1782 return -ENOMEM; 1853 return -ENOMEM;
1783 err = snd_ctl_add(codec->bus->card, kctl); 1854 err = snd_ctl_add(codec->bus->card, kctl);
1784 if (err < 0) { 1855 if (err < 0) {
1785 if (! codec->addr) 1856 if (!codec->addr)
1786 return err; 1857 return err;
1787 kctl = snd_ctl_new1(knew, codec); 1858 kctl = snd_ctl_new1(knew, codec);
1788 if (! kctl) 1859 if (!kctl)
1789 return -ENOMEM; 1860 return -ENOMEM;
1790 kctl->id.device = codec->addr; 1861 kctl->id.device = codec->addr;
1791 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1862 err = snd_ctl_add(codec->bus->card, kctl);
1863 if (err < 0)
1792 return err; 1864 return err;
1793 } 1865 }
1794 } 1866 }
@@ -1799,8 +1871,10 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
1799/* 1871/*
1800 * Channel mode helper 1872 * Channel mode helper
1801 */ 1873 */
1802int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 1874int snd_hda_ch_mode_info(struct hda_codec *codec,
1803 const struct hda_channel_mode *chmode, int num_chmodes) 1875 struct snd_ctl_elem_info *uinfo,
1876 const struct hda_channel_mode *chmode,
1877 int num_chmodes)
1804{ 1878{
1805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1879 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1806 uinfo->count = 1; 1880 uinfo->count = 1;
@@ -1812,8 +1886,10 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinf
1812 return 0; 1886 return 0;
1813} 1887}
1814 1888
1815int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1889int snd_hda_ch_mode_get(struct hda_codec *codec,
1816 const struct hda_channel_mode *chmode, int num_chmodes, 1890 struct snd_ctl_elem_value *ucontrol,
1891 const struct hda_channel_mode *chmode,
1892 int num_chmodes,
1817 int max_channels) 1893 int max_channels)
1818{ 1894{
1819 int i; 1895 int i;
@@ -1827,15 +1903,17 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1827 return 0; 1903 return 0;
1828} 1904}
1829 1905
1830int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1906int snd_hda_ch_mode_put(struct hda_codec *codec,
1831 const struct hda_channel_mode *chmode, int num_chmodes, 1907 struct snd_ctl_elem_value *ucontrol,
1908 const struct hda_channel_mode *chmode,
1909 int num_chmodes,
1832 int *max_channelsp) 1910 int *max_channelsp)
1833{ 1911{
1834 unsigned int mode; 1912 unsigned int mode;
1835 1913
1836 mode = ucontrol->value.enumerated.item[0]; 1914 mode = ucontrol->value.enumerated.item[0];
1837 snd_assert(mode < num_chmodes, return -EINVAL); 1915 snd_assert(mode < num_chmodes, return -EINVAL);
1838 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) 1916 if (*max_channelsp == chmode[mode].channels && !codec->in_resume)
1839 return 0; 1917 return 0;
1840 /* change the current channel setting */ 1918 /* change the current channel setting */
1841 *max_channelsp = chmode[mode].channels; 1919 *max_channelsp = chmode[mode].channels;
@@ -1847,7 +1925,8 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1847/* 1925/*
1848 * input MUX helper 1926 * input MUX helper
1849 */ 1927 */
1850int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) 1928int snd_hda_input_mux_info(const struct hda_input_mux *imux,
1929 struct snd_ctl_elem_info *uinfo)
1851{ 1930{
1852 unsigned int index; 1931 unsigned int index;
1853 1932
@@ -1861,8 +1940,10 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem
1861 return 0; 1940 return 0;
1862} 1941}
1863 1942
1864int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 1943int snd_hda_input_mux_put(struct hda_codec *codec,
1865 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1944 const struct hda_input_mux *imux,
1945 struct snd_ctl_elem_value *ucontrol,
1946 hda_nid_t nid,
1866 unsigned int *cur_val) 1947 unsigned int *cur_val)
1867{ 1948{
1868 unsigned int idx; 1949 unsigned int idx;
@@ -1870,7 +1951,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1870 idx = ucontrol->value.enumerated.item[0]; 1951 idx = ucontrol->value.enumerated.item[0];
1871 if (idx >= imux->num_items) 1952 if (idx >= imux->num_items)
1872 idx = imux->num_items - 1; 1953 idx = imux->num_items - 1;
1873 if (*cur_val == idx && ! codec->in_resume) 1954 if (*cur_val == idx && !codec->in_resume)
1874 return 0; 1955 return 0;
1875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, 1956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
1876 imux->items[idx].index); 1957 imux->items[idx].index);
@@ -1883,25 +1964,53 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1883 * Multi-channel / digital-out PCM helper functions 1964 * Multi-channel / digital-out PCM helper functions
1884 */ 1965 */
1885 1966
1967/* setup SPDIF output stream */
1968static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
1969 unsigned int stream_tag, unsigned int format)
1970{
1971 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
1972 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1973 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1974 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
1975 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
1976 /* turn on again (if needed) */
1977 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1978 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1979 codec->spdif_ctls & 0xff);
1980}
1981
1886/* 1982/*
1887 * open the digital out in the exclusive mode 1983 * open the digital out in the exclusive mode
1888 */ 1984 */
1889int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout) 1985int snd_hda_multi_out_dig_open(struct hda_codec *codec,
1986 struct hda_multi_out *mout)
1890{ 1987{
1891 mutex_lock(&codec->spdif_mutex); 1988 mutex_lock(&codec->spdif_mutex);
1892 if (mout->dig_out_used) { 1989 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
1893 mutex_unlock(&codec->spdif_mutex); 1990 /* already opened as analog dup; reset it once */
1894 return -EBUSY; /* already being used */ 1991 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1895 }
1896 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 1992 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1897 mutex_unlock(&codec->spdif_mutex); 1993 mutex_unlock(&codec->spdif_mutex);
1898 return 0; 1994 return 0;
1899} 1995}
1900 1996
1997int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
1998 struct hda_multi_out *mout,
1999 unsigned int stream_tag,
2000 unsigned int format,
2001 struct snd_pcm_substream *substream)
2002{
2003 mutex_lock(&codec->spdif_mutex);
2004 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format);
2005 mutex_unlock(&codec->spdif_mutex);
2006 return 0;
2007}
2008
1901/* 2009/*
1902 * release the digital out 2010 * release the digital out
1903 */ 2011 */
1904int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout) 2012int snd_hda_multi_out_dig_close(struct hda_codec *codec,
2013 struct hda_multi_out *mout)
1905{ 2014{
1906 mutex_lock(&codec->spdif_mutex); 2015 mutex_lock(&codec->spdif_mutex);
1907 mout->dig_out_used = 0; 2016 mout->dig_out_used = 0;
@@ -1912,7 +2021,8 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *m
1912/* 2021/*
1913 * set up more restrictions for analog out 2022 * set up more restrictions for analog out
1914 */ 2023 */
1915int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 2024int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2025 struct hda_multi_out *mout,
1916 struct snd_pcm_substream *substream) 2026 struct snd_pcm_substream *substream)
1917{ 2027{
1918 substream->runtime->hw.channels_max = mout->max_channels; 2028 substream->runtime->hw.channels_max = mout->max_channels;
@@ -1924,7 +2034,8 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out
1924 * set up the i/o for analog out 2034 * set up the i/o for analog out
1925 * when the digital out is available, copy the front out to digital out, too. 2035 * when the digital out is available, copy the front out to digital out, too.
1926 */ 2036 */
1927int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 2037int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2038 struct hda_multi_out *mout,
1928 unsigned int stream_tag, 2039 unsigned int stream_tag,
1929 unsigned int format, 2040 unsigned int format,
1930 struct snd_pcm_substream *substream) 2041 struct snd_pcm_substream *substream)
@@ -1936,24 +2047,27 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1936 mutex_lock(&codec->spdif_mutex); 2047 mutex_lock(&codec->spdif_mutex);
1937 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2048 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1938 if (chs == 2 && 2049 if (chs == 2 &&
1939 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 2050 snd_hda_is_supported_format(codec, mout->dig_out_nid,
1940 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 2051 format) &&
2052 !(codec->spdif_status & IEC958_AES0_NONAUDIO)) {
1941 mout->dig_out_used = HDA_DIG_ANALOG_DUP; 2053 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
1942 /* setup digital receiver */ 2054 setup_dig_out_stream(codec, mout->dig_out_nid,
1943 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2055 stream_tag, format);
1944 stream_tag, 0, format);
1945 } else { 2056 } else {
1946 mout->dig_out_used = 0; 2057 mout->dig_out_used = 0;
1947 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2058 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
2059 0, 0, 0);
1948 } 2060 }
1949 } 2061 }
1950 mutex_unlock(&codec->spdif_mutex); 2062 mutex_unlock(&codec->spdif_mutex);
1951 2063
1952 /* front */ 2064 /* front */
1953 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); 2065 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
2066 0, format);
1954 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) 2067 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
1955 /* headphone out will just decode front left/right (stereo) */ 2068 /* headphone out will just decode front left/right (stereo) */
1956 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 2069 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
2070 0, format);
1957 /* extra outputs copied from front */ 2071 /* extra outputs copied from front */
1958 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2072 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1959 if (mout->extra_out_nid[i]) 2073 if (mout->extra_out_nid[i])
@@ -1964,11 +2078,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1964 /* surrounds */ 2078 /* surrounds */
1965 for (i = 1; i < mout->num_dacs; i++) { 2079 for (i = 1; i < mout->num_dacs; i++) {
1966 if (chs >= (i + 1) * 2) /* independent out */ 2080 if (chs >= (i + 1) * 2) /* independent out */
1967 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 2081 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1968 format); 2082 i * 2, format);
1969 else /* copy front */ 2083 else /* copy front */
1970 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, 2084 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1971 format); 2085 0, format);
1972 } 2086 }
1973 return 0; 2087 return 0;
1974} 2088}
@@ -1976,7 +2090,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1976/* 2090/*
1977 * clean up the setting for analog out 2091 * clean up the setting for analog out
1978 */ 2092 */
1979int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout) 2093int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2094 struct hda_multi_out *mout)
1980{ 2095{
1981 hda_nid_t *nids = mout->dac_nids; 2096 hda_nid_t *nids = mout->dac_nids;
1982 int i; 2097 int i;
@@ -2003,7 +2118,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
2003 * Helper for automatic ping configuration 2118 * Helper for automatic ping configuration
2004 */ 2119 */
2005 2120
2006static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) 2121static int __devinit is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2007{ 2122{
2008 for (; *list; list++) 2123 for (; *list; list++)
2009 if (*list == nid) 2124 if (*list == nid)
@@ -2011,6 +2126,32 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2011 return 0; 2126 return 0;
2012} 2127}
2013 2128
2129
2130/*
2131 * Sort an associated group of pins according to their sequence numbers.
2132 */
2133static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
2134 int num_pins)
2135{
2136 int i, j;
2137 short seq;
2138 hda_nid_t nid;
2139
2140 for (i = 0; i < num_pins; i++) {
2141 for (j = i + 1; j < num_pins; j++) {
2142 if (sequences[i] > sequences[j]) {
2143 seq = sequences[i];
2144 sequences[i] = sequences[j];
2145 sequences[j] = seq;
2146 nid = pins[i];
2147 pins[i] = pins[j];
2148 pins[j] = nid;
2149 }
2150 }
2151 }
2152}
2153
2154
2014/* 2155/*
2015 * Parse all pin widgets and store the useful pin nids to cfg 2156 * Parse all pin widgets and store the useful pin nids to cfg
2016 * 2157 *
@@ -2028,22 +2169,27 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2028 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 2169 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
2029 * respectively. 2170 * respectively.
2030 */ 2171 */
2031int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 2172int __devinit snd_hda_parse_pin_def_config(struct hda_codec *codec,
2032 hda_nid_t *ignore_nids) 2173 struct auto_pin_cfg *cfg,
2174 hda_nid_t *ignore_nids)
2033{ 2175{
2034 hda_nid_t nid, nid_start; 2176 hda_nid_t nid, nid_start;
2035 int i, j, nodes; 2177 int nodes;
2036 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)]; 2178 short seq, assoc_line_out, assoc_speaker;
2179 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
2180 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
2037 2181
2038 memset(cfg, 0, sizeof(*cfg)); 2182 memset(cfg, 0, sizeof(*cfg));
2039 2183
2040 memset(sequences, 0, sizeof(sequences)); 2184 memset(sequences_line_out, 0, sizeof(sequences_line_out));
2041 assoc_line_out = 0; 2185 memset(sequences_speaker, 0, sizeof(sequences_speaker));
2186 assoc_line_out = assoc_speaker = 0;
2042 2187
2043 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 2188 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
2044 for (nid = nid_start; nid < nodes + nid_start; nid++) { 2189 for (nid = nid_start; nid < nodes + nid_start; nid++) {
2045 unsigned int wid_caps = get_wcaps(codec, nid); 2190 unsigned int wid_caps = get_wcaps(codec, nid);
2046 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2191 unsigned int wid_type =
2192 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2047 unsigned int def_conf; 2193 unsigned int def_conf;
2048 short assoc, loc; 2194 short assoc, loc;
2049 2195
@@ -2054,7 +2200,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2054 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 2200 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
2055 continue; 2201 continue;
2056 2202
2057 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 2203 def_conf = snd_hda_codec_read(codec, nid, 0,
2204 AC_VERB_GET_CONFIG_DEFAULT, 0);
2058 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 2205 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2059 continue; 2206 continue;
2060 loc = get_defcfg_location(def_conf); 2207 loc = get_defcfg_location(def_conf);
@@ -2062,22 +2209,31 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2062 case AC_JACK_LINE_OUT: 2209 case AC_JACK_LINE_OUT:
2063 seq = get_defcfg_sequence(def_conf); 2210 seq = get_defcfg_sequence(def_conf);
2064 assoc = get_defcfg_association(def_conf); 2211 assoc = get_defcfg_association(def_conf);
2065 if (! assoc) 2212 if (!assoc)
2066 continue; 2213 continue;
2067 if (! assoc_line_out) 2214 if (!assoc_line_out)
2068 assoc_line_out = assoc; 2215 assoc_line_out = assoc;
2069 else if (assoc_line_out != assoc) 2216 else if (assoc_line_out != assoc)
2070 continue; 2217 continue;
2071 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 2218 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
2072 continue; 2219 continue;
2073 cfg->line_out_pins[cfg->line_outs] = nid; 2220 cfg->line_out_pins[cfg->line_outs] = nid;
2074 sequences[cfg->line_outs] = seq; 2221 sequences_line_out[cfg->line_outs] = seq;
2075 cfg->line_outs++; 2222 cfg->line_outs++;
2076 break; 2223 break;
2077 case AC_JACK_SPEAKER: 2224 case AC_JACK_SPEAKER:
2225 seq = get_defcfg_sequence(def_conf);
2226 assoc = get_defcfg_association(def_conf);
2227 if (! assoc)
2228 continue;
2229 if (! assoc_speaker)
2230 assoc_speaker = assoc;
2231 else if (assoc_speaker != assoc)
2232 continue;
2078 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 2233 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
2079 continue; 2234 continue;
2080 cfg->speaker_pins[cfg->speaker_outs] = nid; 2235 cfg->speaker_pins[cfg->speaker_outs] = nid;
2236 sequences_speaker[cfg->speaker_outs] = seq;
2081 cfg->speaker_outs++; 2237 cfg->speaker_outs++;
2082 break; 2238 break;
2083 case AC_JACK_HP_OUT: 2239 case AC_JACK_HP_OUT:
@@ -2123,34 +2279,45 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2123 } 2279 }
2124 2280
2125 /* sort by sequence */ 2281 /* sort by sequence */
2126 for (i = 0; i < cfg->line_outs; i++) 2282 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2127 for (j = i + 1; j < cfg->line_outs; j++) 2283 cfg->line_outs);
2128 if (sequences[i] > sequences[j]) { 2284 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker,
2129 seq = sequences[i]; 2285 cfg->speaker_outs);
2130 sequences[i] = sequences[j]; 2286
2131 sequences[j] = seq; 2287 /*
2132 nid = cfg->line_out_pins[i]; 2288 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2133 cfg->line_out_pins[i] = cfg->line_out_pins[j]; 2289 * as a primary output
2134 cfg->line_out_pins[j] = nid; 2290 */
2135 } 2291 if (!cfg->line_outs) {
2292 if (cfg->speaker_outs) {
2293 cfg->line_outs = cfg->speaker_outs;
2294 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2295 sizeof(cfg->speaker_pins));
2296 cfg->speaker_outs = 0;
2297 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2298 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
2299 } else if (cfg->hp_outs) {
2300 cfg->line_outs = cfg->hp_outs;
2301 memcpy(cfg->line_out_pins, cfg->hp_pins,
2302 sizeof(cfg->hp_pins));
2303 cfg->hp_outs = 0;
2304 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2305 cfg->line_out_type = AUTO_PIN_HP_OUT;
2306 }
2307 }
2136 2308
2137 /* Reorder the surround channels 2309 /* Reorder the surround channels
2138 * ALSA sequence is front/surr/clfe/side 2310 * ALSA sequence is front/surr/clfe/side
2139 * HDA sequence is: 2311 * HDA sequence is:
2140 * 4-ch: front/surr => OK as it is 2312 * 4-ch: front/surr => OK as it is
2141 * 6-ch: front/clfe/surr 2313 * 6-ch: front/clfe/surr
2142 * 8-ch: front/clfe/side/surr 2314 * 8-ch: front/clfe/rear/side|fc
2143 */ 2315 */
2144 switch (cfg->line_outs) { 2316 switch (cfg->line_outs) {
2145 case 3: 2317 case 3:
2146 nid = cfg->line_out_pins[1];
2147 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2148 cfg->line_out_pins[2] = nid;
2149 break;
2150 case 4: 2318 case 4:
2151 nid = cfg->line_out_pins[1]; 2319 nid = cfg->line_out_pins[1];
2152 cfg->line_out_pins[1] = cfg->line_out_pins[3]; 2320 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2153 cfg->line_out_pins[3] = cfg->line_out_pins[2];
2154 cfg->line_out_pins[2] = nid; 2321 cfg->line_out_pins[2] = nid;
2155 break; 2322 break;
2156 } 2323 }
@@ -2179,26 +2346,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2179 cfg->input_pins[AUTO_PIN_CD], 2346 cfg->input_pins[AUTO_PIN_CD],
2180 cfg->input_pins[AUTO_PIN_AUX]); 2347 cfg->input_pins[AUTO_PIN_AUX]);
2181 2348
2182 /*
2183 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2184 * as a primary output
2185 */
2186 if (! cfg->line_outs) {
2187 if (cfg->speaker_outs) {
2188 cfg->line_outs = cfg->speaker_outs;
2189 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2190 sizeof(cfg->speaker_pins));
2191 cfg->speaker_outs = 0;
2192 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2193 } else if (cfg->hp_outs) {
2194 cfg->line_outs = cfg->hp_outs;
2195 memcpy(cfg->line_out_pins, cfg->hp_pins,
2196 sizeof(cfg->hp_pins));
2197 cfg->hp_outs = 0;
2198 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2199 }
2200 }
2201
2202 return 0; 2349 return 0;
2203} 2350}
2204 2351
@@ -2222,11 +2369,10 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2222 */ 2369 */
2223int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) 2370int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2224{ 2371{
2225 struct list_head *p; 2372 struct hda_codec *codec;
2226 2373
2227 /* FIXME: should handle power widget capabilities */ 2374 /* FIXME: should handle power widget capabilities */
2228 list_for_each(p, &bus->codec_list) { 2375 list_for_each_entry(codec, &bus->codec_list, list) {
2229 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2230 if (codec->patch_ops.suspend) 2376 if (codec->patch_ops.suspend)
2231 codec->patch_ops.suspend(codec, state); 2377 codec->patch_ops.suspend(codec, state);
2232 hda_set_power_state(codec, 2378 hda_set_power_state(codec,
@@ -2236,8 +2382,6 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2236 return 0; 2382 return 0;
2237} 2383}
2238 2384
2239EXPORT_SYMBOL(snd_hda_suspend);
2240
2241/** 2385/**
2242 * snd_hda_resume - resume the codecs 2386 * snd_hda_resume - resume the codecs
2243 * @bus: the HDA bus 2387 * @bus: the HDA bus
@@ -2247,10 +2391,9 @@ EXPORT_SYMBOL(snd_hda_suspend);
2247 */ 2391 */
2248int snd_hda_resume(struct hda_bus *bus) 2392int snd_hda_resume(struct hda_bus *bus)
2249{ 2393{
2250 struct list_head *p; 2394 struct hda_codec *codec;
2251 2395
2252 list_for_each(p, &bus->codec_list) { 2396 list_for_each_entry(codec, &bus->codec_list, list) {
2253 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2254 hda_set_power_state(codec, 2397 hda_set_power_state(codec,
2255 codec->afg ? codec->afg : codec->mfg, 2398 codec->afg ? codec->afg : codec->mfg,
2256 AC_PWRST_D0); 2399 AC_PWRST_D0);
@@ -2260,8 +2403,6 @@ int snd_hda_resume(struct hda_bus *bus)
2260 return 0; 2403 return 0;
2261} 2404}
2262 2405
2263EXPORT_SYMBOL(snd_hda_resume);
2264
2265/** 2406/**
2266 * snd_hda_resume_ctls - resume controls in the new control list 2407 * snd_hda_resume_ctls - resume controls in the new control list
2267 * @codec: the HDA codec 2408 * @codec: the HDA codec
@@ -2276,7 +2417,7 @@ int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2276 struct snd_ctl_elem_value *val; 2417 struct snd_ctl_elem_value *val;
2277 2418
2278 val = kmalloc(sizeof(*val), GFP_KERNEL); 2419 val = kmalloc(sizeof(*val), GFP_KERNEL);
2279 if (! val) 2420 if (!val)
2280 return -ENOMEM; 2421 return -ENOMEM;
2281 codec->in_resume = 1; 2422 codec->in_resume = 1;
2282 for (; knew->name; knew++) { 2423 for (; knew->name; knew++) {
@@ -2320,19 +2461,3 @@ int snd_hda_resume_spdif_in(struct hda_codec *codec)
2320 return snd_hda_resume_ctls(codec, dig_in_ctls); 2461 return snd_hda_resume_ctls(codec, dig_in_ctls);
2321} 2462}
2322#endif 2463#endif
2323
2324/*
2325 * INIT part
2326 */
2327
2328static int __init alsa_hda_init(void)
2329{
2330 return 0;
2331}
2332
2333static void __exit alsa_hda_exit(void)
2334{
2335}
2336
2337module_init(alsa_hda_init)
2338module_exit(alsa_hda_exit)
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index c12bc4e8840..56c26e7ccdf 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -233,7 +233,7 @@ enum {
233 */ 233 */
234 234
235/* Amp gain/mute */ 235/* Amp gain/mute */
236#define AC_AMP_MUTE (1<<8) 236#define AC_AMP_MUTE (1<<7)
237#define AC_AMP_GAIN (0x7f) 237#define AC_AMP_GAIN (0x7f)
238#define AC_AMP_GET_INDEX (0xf<<0) 238#define AC_AMP_GET_INDEX (0xf<<0)
239 239
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1e5ff0cd370..000287f7da4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -133,7 +133,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
133 return -ENOMEM; 133 return -ENOMEM;
134 } 134 }
135 } 135 }
136 memcpy(node->conn_list, conn_list, nconns); 136 memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t));
137 node->nconns = nconns; 137 node->nconns = nconns;
138 node->wid_caps = get_wcaps(codec, nid); 138 node->wid_caps = get_wcaps(codec, nid);
139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1672cace1ae..92bc8b3fa2a 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -88,6 +88,8 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
88 "{ATI, SB600}," 88 "{ATI, SB600},"
89 "{ATI, RS600}," 89 "{ATI, RS600},"
90 "{ATI, RS690}," 90 "{ATI, RS690},"
91 "{ATI, RS780},"
92 "{ATI, R600},"
91 "{VIA, VT8251}," 93 "{VIA, VT8251},"
92 "{VIA, VT8237A}," 94 "{VIA, VT8237A},"
93 "{SiS, SIS966}," 95 "{SiS, SIS966},"
@@ -198,6 +200,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
198#define RIRB_INT_MASK 0x05 200#define RIRB_INT_MASK 0x05
199 201
200/* STATESTS int mask: SD2,SD1,SD0 */ 202/* STATESTS int mask: SD2,SD1,SD0 */
203#define AZX_MAX_CODECS 3
201#define STATESTS_INT_MASK 0x07 204#define STATESTS_INT_MASK 0x07
202 205
203/* SD_CTL bits */ 206/* SD_CTL bits */
@@ -338,6 +341,9 @@ struct azx {
338 unsigned int single_cmd :1; 341 unsigned int single_cmd :1;
339 unsigned int polling_mode :1; 342 unsigned int polling_mode :1;
340 unsigned int msi :1; 343 unsigned int msi :1;
344
345 /* for debugging */
346 unsigned int last_cmd; /* last issued command (to sync) */
341}; 347};
342 348
343/* driver types */ 349/* driver types */
@@ -463,18 +469,10 @@ static void azx_free_cmd_io(struct azx *chip)
463} 469}
464 470
465/* send a command */ 471/* send a command */
466static int azx_corb_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, 472static int azx_corb_send_cmd(struct hda_codec *codec, u32 val)
467 unsigned int verb, unsigned int para)
468{ 473{
469 struct azx *chip = codec->bus->private_data; 474 struct azx *chip = codec->bus->private_data;
470 unsigned int wp; 475 unsigned int wp;
471 u32 val;
472
473 val = (u32)(codec->addr & 0x0f) << 28;
474 val |= (u32)direct << 27;
475 val |= (u32)nid << 20;
476 val |= verb << 8;
477 val |= para;
478 476
479 /* add command to corb */ 477 /* add command to corb */
480 wp = azx_readb(chip, CORBWP); 478 wp = azx_readb(chip, CORBWP);
@@ -535,12 +533,12 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
535 } 533 }
536 if (! chip->rirb.cmds) 534 if (! chip->rirb.cmds)
537 return chip->rirb.res; /* the last value */ 535 return chip->rirb.res; /* the last value */
538 schedule_timeout_interruptible(1); 536 schedule_timeout(1);
539 } while (time_after_eq(timeout, jiffies)); 537 } while (time_after_eq(timeout, jiffies));
540 538
541 if (chip->msi) { 539 if (chip->msi) {
542 snd_printk(KERN_WARNING "hda_intel: No response from codec, " 540 snd_printk(KERN_WARNING "hda_intel: No response from codec, "
543 "disabling MSI...\n"); 541 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd);
544 free_irq(chip->irq, chip); 542 free_irq(chip->irq, chip);
545 chip->irq = -1; 543 chip->irq = -1;
546 pci_disable_msi(chip->pci); 544 pci_disable_msi(chip->pci);
@@ -552,13 +550,15 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
552 550
553 if (!chip->polling_mode) { 551 if (!chip->polling_mode) {
554 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " 552 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
555 "switching to polling mode...\n"); 553 "switching to polling mode: last cmd=0x%08x\n",
554 chip->last_cmd);
556 chip->polling_mode = 1; 555 chip->polling_mode = 1;
557 goto again; 556 goto again;
558 } 557 }
559 558
560 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 559 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
561 "switching to single_cmd mode...\n"); 560 "switching to single_cmd mode: last cmd=0x%08x\n",
561 chip->last_cmd);
562 chip->rirb.rp = azx_readb(chip, RIRBWP); 562 chip->rirb.rp = azx_readb(chip, RIRBWP);
563 chip->rirb.cmds = 0; 563 chip->rirb.cmds = 0;
564 /* switch to single_cmd mode */ 564 /* switch to single_cmd mode */
@@ -578,20 +578,11 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
578 */ 578 */
579 579
580/* send a command */ 580/* send a command */
581static int azx_single_send_cmd(struct hda_codec *codec, hda_nid_t nid, 581static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
582 int direct, unsigned int verb,
583 unsigned int para)
584{ 582{
585 struct azx *chip = codec->bus->private_data; 583 struct azx *chip = codec->bus->private_data;
586 u32 val;
587 int timeout = 50; 584 int timeout = 50;
588 585
589 val = (u32)(codec->addr & 0x0f) << 28;
590 val |= (u32)direct << 27;
591 val |= (u32)nid << 20;
592 val |= verb << 8;
593 val |= para;
594
595 while (timeout--) { 586 while (timeout--) {
596 /* check ICB busy bit */ 587 /* check ICB busy bit */
597 if (! (azx_readw(chip, IRS) & ICH6_IRS_BUSY)) { 588 if (! (azx_readw(chip, IRS) & ICH6_IRS_BUSY)) {
@@ -636,10 +627,19 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid,
636 unsigned int para) 627 unsigned int para)
637{ 628{
638 struct azx *chip = codec->bus->private_data; 629 struct azx *chip = codec->bus->private_data;
630 u32 val;
631
632 val = (u32)(codec->addr & 0x0f) << 28;
633 val |= (u32)direct << 27;
634 val |= (u32)nid << 20;
635 val |= verb << 8;
636 val |= para;
637 chip->last_cmd = val;
638
639 if (chip->single_cmd) 639 if (chip->single_cmd)
640 return azx_single_send_cmd(codec, nid, direct, verb, para); 640 return azx_single_send_cmd(codec, val);
641 else 641 else
642 return azx_corb_send_cmd(codec, nid, direct, verb, para); 642 return azx_corb_send_cmd(codec, val);
643} 643}
644 644
645/* get a response */ 645/* get a response */
@@ -978,7 +978,7 @@ static unsigned int azx_max_codecs[] __devinitdata = {
978static int __devinit azx_codec_create(struct azx *chip, const char *model) 978static int __devinit azx_codec_create(struct azx *chip, const char *model)
979{ 979{
980 struct hda_bus_template bus_temp; 980 struct hda_bus_template bus_temp;
981 int c, codecs, err; 981 int c, codecs, audio_codecs, err;
982 982
983 memset(&bus_temp, 0, sizeof(bus_temp)); 983 memset(&bus_temp, 0, sizeof(bus_temp));
984 bus_temp.private_data = chip; 984 bus_temp.private_data = chip;
@@ -990,16 +990,30 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) 990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
991 return err; 991 return err;
992 992
993 codecs = 0; 993 codecs = audio_codecs = 0;
994 for (c = 0; c < azx_max_codecs[chip->driver_type]; c++) { 994 for (c = 0; c < AZX_MAX_CODECS; c++) {
995 if ((chip->codec_mask & (1 << c)) & probe_mask) { 995 if ((chip->codec_mask & (1 << c)) & probe_mask) {
996 err = snd_hda_codec_new(chip->bus, c, NULL); 996 struct hda_codec *codec;
997 err = snd_hda_codec_new(chip->bus, c, &codec);
997 if (err < 0) 998 if (err < 0)
998 continue; 999 continue;
999 codecs++; 1000 codecs++;
1001 if (codec->afg)
1002 audio_codecs++;
1003 }
1004 }
1005 if (!audio_codecs) {
1006 /* probe additional slots if no codec is found */
1007 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1008 if ((chip->codec_mask & (1 << c)) & probe_mask) {
1009 err = snd_hda_codec_new(chip->bus, c, NULL);
1010 if (err < 0)
1011 continue;
1012 codecs++;
1013 }
1000 } 1014 }
1001 } 1015 }
1002 if (! codecs) { 1016 if (!codecs) {
1003 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1017 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1004 return -ENXIO; 1018 return -ENXIO;
1005 } 1019 }
@@ -1518,7 +1532,7 @@ static int azx_dev_free(struct snd_device *device)
1518/* 1532/*
1519 * white/black-listing for position_fix 1533 * white/black-listing for position_fix
1520 */ 1534 */
1521static const struct snd_pci_quirk position_fix_list[] __devinitdata = { 1535static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1522 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1536 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1523 {} 1537 {}
1524}; 1538};
@@ -1758,6 +1772,8 @@ static struct pci_device_id azx_ids[] = {
1758 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1772 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
1759 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 1773 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
1760 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 1774 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1775 { 0x1002, 0x960c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
1776 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */
1761 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1777 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1762 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1778 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1763 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1779 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
@@ -1769,6 +1785,12 @@ static struct pci_device_id azx_ids[] = {
1769 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 1785 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */
1770 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 1786 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
1771 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 1787 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */
1788 { 0x10de, 0x07fc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
1789 { 0x10de, 0x07fd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */
1790 { 0x10de, 0x0774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1791 { 0x10de, 0x0775, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1792 { 0x10de, 0x0776, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1793 { 0x10de, 0x0777, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */
1772 { 0, } 1794 { 0, }
1773}; 1795};
1774MODULE_DEVICE_TABLE(pci, azx_ids); 1796MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 39718d6cdad..f91ea5ec9f6 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -148,6 +148,11 @@ struct hda_multi_out {
148 148
149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout); 149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout);
150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); 150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout);
151int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
152 struct hda_multi_out *mout,
153 unsigned int stream_tag,
154 unsigned int format,
155 struct snd_pcm_substream *substream);
151int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 156int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout,
152 struct snd_pcm_substream *substream); 157 struct snd_pcm_substream *substream);
153int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 158int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout,
@@ -217,6 +222,12 @@ enum {
217 AUTO_PIN_LAST 222 AUTO_PIN_LAST
218}; 223};
219 224
225enum {
226 AUTO_PIN_LINE_OUT,
227 AUTO_PIN_SPEAKER_OUT,
228 AUTO_PIN_HP_OUT
229};
230
220extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 231extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
221 232
222struct auto_pin_cfg { 233struct auto_pin_cfg {
@@ -225,6 +236,7 @@ struct auto_pin_cfg {
225 int speaker_outs; 236 int speaker_outs;
226 hda_nid_t speaker_pins[5]; 237 hda_nid_t speaker_pins[5];
227 int hp_outs; 238 int hp_outs;
239 int line_out_type; /* AUTO_PIN_XXX_OUT */
228 hda_nid_t hp_pins[5]; 240 hda_nid_t hp_pins[5];
229 hda_nid_t input_pins[AUTO_PIN_LAST]; 241 hda_nid_t input_pins[AUTO_PIN_LAST];
230 hda_nid_t dig_out_pin; 242 hda_nid_t dig_out_pin;
@@ -265,5 +277,7 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
265 return codec->wcaps[nid - codec->start_nid]; 277 return codec->wcaps[nid - codec->start_nid];
266} 278}
267 279
280int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
281 unsigned int caps);
268 282
269#endif /* __SOUND_HDA_LOCAL_H */ 283#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index e313e685f16..ac15066fd30 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -250,6 +250,12 @@ static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffe
250 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); 250 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
251 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 251 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
252 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 252 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
253
254 if (codec->mfg)
255 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
256 else
257 snd_iprintf(buffer, "No Modem Function Group found\n");
258
253 if (! codec->afg) 259 if (! codec->afg)
254 return; 260 return;
255 snd_iprintf(buffer, "Default PCM:\n"); 261 snd_iprintf(buffer, "Default PCM:\n");
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index f94f1f22889..4d7f8d11ad7 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988 2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
3 * AD1986A, AD1988
3 * 4 *
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> 5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
5 * 6 *
6 * This driver is free software; you can redistribute it and/or modify 7 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -61,7 +62,7 @@ struct ad198x_spec {
61 int num_channel_mode; 62 int num_channel_mode;
62 63
63 /* PCM information */ 64 /* PCM information */
64 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ 65 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
65 66
66 struct mutex amp_mutex; /* PCM volume/mute control mutex */ 67 struct mutex amp_mutex; /* PCM volume/mute control mutex */
67 unsigned int spdif_route; 68 unsigned int spdif_route;
@@ -192,6 +193,17 @@ static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 193 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
193} 194}
194 195
196static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
197 struct hda_codec *codec,
198 unsigned int stream_tag,
199 unsigned int format,
200 struct snd_pcm_substream *substream)
201{
202 struct ad198x_spec *spec = codec->spec;
203 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
204 format, substream);
205}
206
195/* 207/*
196 * Analog capture 208 * Analog capture
197 */ 209 */
@@ -250,7 +262,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
250 .nid = 0, /* fill later */ 262 .nid = 0, /* fill later */
251 .ops = { 263 .ops = {
252 .open = ad198x_dig_playback_pcm_open, 264 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close 265 .close = ad198x_dig_playback_pcm_close,
266 .prepare = ad198x_dig_playback_pcm_prepare
254 }, 267 },
255}; 268};
256 269
@@ -739,41 +752,35 @@ static struct hda_verb ad1986a_init_verbs[] = {
739 { } /* end */ 752 { } /* end */
740}; 753};
741 754
742/* additional verbs for 3-stack model */
743static struct hda_verb ad1986a_3st_init_verbs[] = {
744 /* Mic and line-in selectors */
745 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
746 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
747 { } /* end */
748};
749
750static struct hda_verb ad1986a_ch2_init[] = { 755static struct hda_verb ad1986a_ch2_init[] = {
751 /* Surround out -> Line In */ 756 /* Surround out -> Line In */
752 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 757 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
753 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 758 /* Line-in selectors */
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
754 /* CLFE -> Mic in */ 760 /* CLFE -> Mic in */
755 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 761 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
756 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 762 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
757 { } /* end */ 764 { } /* end */
758}; 765};
759 766
760static struct hda_verb ad1986a_ch4_init[] = { 767static struct hda_verb ad1986a_ch4_init[] = {
761 /* Surround out -> Surround */ 768 /* Surround out -> Surround */
762 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 769 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
763 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 770 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
764 /* CLFE -> Mic in */ 771 /* CLFE -> Mic in */
765 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 772 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
766 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 773 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
767 { } /* end */ 774 { } /* end */
768}; 775};
769 776
770static struct hda_verb ad1986a_ch6_init[] = { 777static struct hda_verb ad1986a_ch6_init[] = {
771 /* Surround out -> Surround out */ 778 /* Surround out -> Surround out */
772 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 779 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
773 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 780 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
774 /* CLFE -> CLFE */ 781 /* CLFE -> CLFE */
775 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 782 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
776 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
777 { } /* end */ 784 { } /* end */
778}; 785};
779 786
@@ -828,6 +835,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
828 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), 835 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
829 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), 836 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), 837 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
838 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
831 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), 839 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
832 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), 840 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
833 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), 841 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
@@ -882,9 +890,8 @@ static int patch_ad1986a(struct hda_codec *codec)
882 case AD1986A_3STACK: 890 case AD1986A_3STACK:
883 spec->num_mixers = 2; 891 spec->num_mixers = 2;
884 spec->mixers[1] = ad1986a_3st_mixers; 892 spec->mixers[1] = ad1986a_3st_mixers;
885 spec->num_init_verbs = 3; 893 spec->num_init_verbs = 2;
886 spec->init_verbs[1] = ad1986a_3st_init_verbs; 894 spec->init_verbs[1] = ad1986a_ch2_init;
887 spec->init_verbs[2] = ad1986a_ch2_init;
888 spec->channel_mode = ad1986a_modes; 895 spec->channel_mode = ad1986a_modes;
889 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); 896 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
890 spec->need_dac_fix = 1; 897 spec->need_dac_fix = 1;
@@ -1892,8 +1899,9 @@ static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1892 1899
1893 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1900 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1894 if (sel > 0) { 1901 if (sel > 0) {
1895 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); 1902 sel = snd_hda_codec_read(codec, 0x0b, 0,
1896 if (sel <= 3) 1903 AC_VERB_GET_CONNECT_SEL, 0);
1904 if (sel < 3)
1897 sel++; 1905 sel++;
1898 else 1906 else
1899 sel = 0; 1907 sel = 0;
@@ -1906,23 +1914,27 @@ static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1906 struct snd_ctl_elem_value *ucontrol) 1914 struct snd_ctl_elem_value *ucontrol)
1907{ 1915{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1916 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 unsigned int sel; 1917 unsigned int val, sel;
1910 int change; 1918 int change;
1911 1919
1920 val = ucontrol->value.enumerated.item[0];
1912 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1921 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 if (! ucontrol->value.enumerated.item[0]) { 1922 if (!val) {
1914 change = sel != 0; 1923 change = sel != 0;
1915 if (change) 1924 if (change || codec->in_resume)
1916 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); 1925 snd_hda_codec_write(codec, 0x02, 0,
1926 AC_VERB_SET_CONNECT_SEL, 0);
1917 } else { 1927 } else {
1918 change = sel == 0; 1928 change = sel == 0;
1919 if (change) 1929 if (change || codec->in_resume)
1920 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); 1930 snd_hda_codec_write(codec, 0x02, 0,
1921 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; 1931 AC_VERB_SET_CONNECT_SEL, 1);
1922 change |= sel == ucontrol->value.enumerated.item[0]; 1932 sel = snd_hda_codec_read(codec, 0x0b, 0,
1923 if (change) 1933 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1924 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1934 change |= sel != val;
1925 ucontrol->value.enumerated.item[0] - 1); 1935 if (change || codec->in_resume)
1936 snd_hda_codec_write(codec, 0x0b, 0,
1937 AC_VERB_SET_CONNECT_SEL, val - 1);
1926 } 1938 }
1927 return change; 1939 return change;
1928} 1940}
@@ -2764,11 +2776,634 @@ static int patch_ad1988(struct hda_codec *codec)
2764 2776
2765 2777
2766/* 2778/*
2779 * AD1884 / AD1984
2780 *
2781 * port-B - front line/mic-in
2782 * port-E - aux in/out
2783 * port-F - aux in/out
2784 * port-C - rear line/mic-in
2785 * port-D - rear line/hp-out
2786 * port-A - front line/hp-out
2787 *
2788 * AD1984 = AD1884 + two digital mic-ins
2789 *
2790 * FIXME:
2791 * For simplicity, we share the single DAC for both HP and line-outs
2792 * right now. The inidividual playbacks could be easily implemented,
2793 * but no build-up framework is given, so far.
2794 */
2795
2796static hda_nid_t ad1884_dac_nids[1] = {
2797 0x04,
2798};
2799
2800static hda_nid_t ad1884_adc_nids[2] = {
2801 0x08, 0x09,
2802};
2803
2804static hda_nid_t ad1884_capsrc_nids[2] = {
2805 0x0c, 0x0d,
2806};
2807
2808#define AD1884_SPDIF_OUT 0x02
2809
2810static struct hda_input_mux ad1884_capture_source = {
2811 .num_items = 4,
2812 .items = {
2813 { "Front Mic", 0x0 },
2814 { "Mic", 0x1 },
2815 { "CD", 0x2 },
2816 { "Mix", 0x3 },
2817 },
2818};
2819
2820static struct snd_kcontrol_new ad1884_base_mixers[] = {
2821 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2822 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2824 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2825 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
2826 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
2827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2830 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2831 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
2832 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
2833 /*
2834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2836 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2837 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2838 */
2839 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2842 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2845 {
2846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2847 /* The multiple "Capture Source" controls confuse alsamixer
2848 * So call somewhat different..
2849 * FIXME: the controls appear in the "playback" view!
2850 */
2851 /* .name = "Capture Source", */
2852 .name = "Input Source",
2853 .count = 2,
2854 .info = ad198x_mux_enum_info,
2855 .get = ad198x_mux_enum_get,
2856 .put = ad198x_mux_enum_put,
2857 },
2858 /* SPDIF controls */
2859 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2860 {
2861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2862 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2863 /* identical with ad1983 */
2864 .info = ad1983_spdif_route_info,
2865 .get = ad1983_spdif_route_get,
2866 .put = ad1983_spdif_route_put,
2867 },
2868 { } /* end */
2869};
2870
2871static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
2872 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
2873 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
2874 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
2875 HDA_INPUT),
2876 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
2877 HDA_INPUT),
2878 { } /* end */
2879};
2880
2881/*
2882 * initialization verbs
2883 */
2884static struct hda_verb ad1884_init_verbs[] = {
2885 /* DACs; mute as default */
2886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2888 /* Port-A (HP) mixer */
2889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2891 /* Port-A pin */
2892 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2894 /* HP selector - select DAC2 */
2895 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
2896 /* Port-D (Line-out) mixer */
2897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2899 /* Port-D pin */
2900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2901 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 /* Mono-out mixer */
2903 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2904 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2905 /* Mono-out pin */
2906 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2907 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2908 /* Mono selector */
2909 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2910 /* Port-B (front mic) pin */
2911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 /* Port-C (rear mic) pin */
2914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2916 /* Analog mixer; mute as default */
2917 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2918 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2919 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2920 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2921 /* Analog Mix output amp */
2922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2923 /* SPDIF output selector */
2924 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2926 { } /* end */
2927};
2928
2929static int patch_ad1884(struct hda_codec *codec)
2930{
2931 struct ad198x_spec *spec;
2932
2933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2934 if (spec == NULL)
2935 return -ENOMEM;
2936
2937 mutex_init(&spec->amp_mutex);
2938 codec->spec = spec;
2939
2940 spec->multiout.max_channels = 2;
2941 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
2942 spec->multiout.dac_nids = ad1884_dac_nids;
2943 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
2944 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
2945 spec->adc_nids = ad1884_adc_nids;
2946 spec->capsrc_nids = ad1884_capsrc_nids;
2947 spec->input_mux = &ad1884_capture_source;
2948 spec->num_mixers = 1;
2949 spec->mixers[0] = ad1884_base_mixers;
2950 spec->num_init_verbs = 1;
2951 spec->init_verbs[0] = ad1884_init_verbs;
2952 spec->spdif_route = 0;
2953
2954 codec->patch_ops = ad198x_patch_ops;
2955
2956 return 0;
2957}
2958
2959/*
2960 * Lenovo Thinkpad T61/X61
2961 */
2962static struct hda_input_mux ad1984_thinkpad_capture_source = {
2963 .num_items = 3,
2964 .items = {
2965 { "Mic", 0x0 },
2966 { "Internal Mic", 0x1 },
2967 { "Mix", 0x3 },
2968 },
2969};
2970
2971static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
2972 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2973 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2975 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2977 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2980 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
2981 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
2982 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
2983 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
2984 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
2985 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
2986 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
2987 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2988 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2991 {
2992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2993 /* The multiple "Capture Source" controls confuse alsamixer
2994 * So call somewhat different..
2995 * FIXME: the controls appear in the "playback" view!
2996 */
2997 /* .name = "Capture Source", */
2998 .name = "Input Source",
2999 .count = 2,
3000 .info = ad198x_mux_enum_info,
3001 .get = ad198x_mux_enum_get,
3002 .put = ad198x_mux_enum_put,
3003 },
3004 { } /* end */
3005};
3006
3007/* additional verbs */
3008static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3009 /* Port-E (docking station mic) pin */
3010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3011 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 /* docking mic boost */
3013 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3014 /* Analog mixer - docking mic; mute as default */
3015 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3016 /* enable EAPD bit */
3017 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3018 { } /* end */
3019};
3020
3021/* Digial MIC ADC NID 0x05 + 0x06 */
3022static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3023 struct hda_codec *codec,
3024 unsigned int stream_tag,
3025 unsigned int format,
3026 struct snd_pcm_substream *substream)
3027{
3028 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3029 stream_tag, 0, format);
3030 return 0;
3031}
3032
3033static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3034 struct hda_codec *codec,
3035 struct snd_pcm_substream *substream)
3036{
3037 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3038 0, 0, 0);
3039 return 0;
3040}
3041
3042static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3043 .substreams = 2,
3044 .channels_min = 2,
3045 .channels_max = 2,
3046 .nid = 0x05,
3047 .ops = {
3048 .prepare = ad1984_pcm_dmic_prepare,
3049 .cleanup = ad1984_pcm_dmic_cleanup
3050 },
3051};
3052
3053static int ad1984_build_pcms(struct hda_codec *codec)
3054{
3055 struct ad198x_spec *spec = codec->spec;
3056 struct hda_pcm *info;
3057 int err;
3058
3059 err = ad198x_build_pcms(codec);
3060 if (err < 0)
3061 return err;
3062
3063 info = spec->pcm_rec + codec->num_pcms;
3064 codec->num_pcms++;
3065 info->name = "AD1984 Digital Mic";
3066 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3067 return 0;
3068}
3069
3070/* models */
3071enum {
3072 AD1984_BASIC,
3073 AD1984_THINKPAD,
3074 AD1984_MODELS
3075};
3076
3077static const char *ad1984_models[AD1984_MODELS] = {
3078 [AD1984_BASIC] = "basic",
3079 [AD1984_THINKPAD] = "thinkpad",
3080};
3081
3082static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3083 /* Lenovo Thinkpad T61/X61 */
3084 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3085 {}
3086};
3087
3088static int patch_ad1984(struct hda_codec *codec)
3089{
3090 struct ad198x_spec *spec;
3091 int board_config, err;
3092
3093 err = patch_ad1884(codec);
3094 if (err < 0)
3095 return err;
3096 spec = codec->spec;
3097 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3098 ad1984_models, ad1984_cfg_tbl);
3099 switch (board_config) {
3100 case AD1984_BASIC:
3101 /* additional digital mics */
3102 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3103 codec->patch_ops.build_pcms = ad1984_build_pcms;
3104 break;
3105 case AD1984_THINKPAD:
3106 spec->multiout.dig_out_nid = 0;
3107 spec->input_mux = &ad1984_thinkpad_capture_source;
3108 spec->mixers[0] = ad1984_thinkpad_mixers;
3109 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3110 break;
3111 }
3112 return 0;
3113}
3114
3115
3116/*
3117 * AD1882
3118 *
3119 * port-A - front hp-out
3120 * port-B - front mic-in
3121 * port-C - rear line-in, shared surr-out (3stack)
3122 * port-D - rear line-out
3123 * port-E - rear mic-in, shared clfe-out (3stack)
3124 * port-F - rear surr-out (6stack)
3125 * port-G - rear clfe-out (6stack)
3126 */
3127
3128static hda_nid_t ad1882_dac_nids[3] = {
3129 0x04, 0x03, 0x05
3130};
3131
3132static hda_nid_t ad1882_adc_nids[2] = {
3133 0x08, 0x09,
3134};
3135
3136static hda_nid_t ad1882_capsrc_nids[2] = {
3137 0x0c, 0x0d,
3138};
3139
3140#define AD1882_SPDIF_OUT 0x02
3141
3142/* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3143static struct hda_input_mux ad1882_capture_source = {
3144 .num_items = 5,
3145 .items = {
3146 { "Front Mic", 0x1 },
3147 { "Mic", 0x4 },
3148 { "Line", 0x2 },
3149 { "CD", 0x3 },
3150 { "Mix", 0x7 },
3151 },
3152};
3153
3154static struct snd_kcontrol_new ad1882_base_mixers[] = {
3155 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
3157 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
3158 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
3159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3160 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3161 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3162 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3163 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3166 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
3168 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
3169 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
3170 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
3171 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
3172 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
3173 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
3174 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
3175 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
3176 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3177 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3178 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3179 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3180 {
3181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3182 /* The multiple "Capture Source" controls confuse alsamixer
3183 * So call somewhat different..
3184 * FIXME: the controls appear in the "playback" view!
3185 */
3186 /* .name = "Capture Source", */
3187 .name = "Input Source",
3188 .count = 2,
3189 .info = ad198x_mux_enum_info,
3190 .get = ad198x_mux_enum_get,
3191 .put = ad198x_mux_enum_put,
3192 },
3193 /* SPDIF controls */
3194 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3195 {
3196 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3197 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3198 /* identical with ad1983 */
3199 .info = ad1983_spdif_route_info,
3200 .get = ad1983_spdif_route_get,
3201 .put = ad1983_spdif_route_put,
3202 },
3203 { } /* end */
3204};
3205
3206static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
3207 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3208 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
3209 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
3210 {
3211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3212 .name = "Channel Mode",
3213 .info = ad198x_ch_mode_info,
3214 .get = ad198x_ch_mode_get,
3215 .put = ad198x_ch_mode_put,
3216 },
3217 { } /* end */
3218};
3219
3220static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
3221 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
3222 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
3223 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
3224 { } /* end */
3225};
3226
3227static struct hda_verb ad1882_ch2_init[] = {
3228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3229 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3230 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3232 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3233 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3234 { } /* end */
3235};
3236
3237static struct hda_verb ad1882_ch4_init[] = {
3238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3239 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3240 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3241 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3242 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3243 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3244 { } /* end */
3245};
3246
3247static struct hda_verb ad1882_ch6_init[] = {
3248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3249 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3250 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3251 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3252 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3253 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3254 { } /* end */
3255};
3256
3257static struct hda_channel_mode ad1882_modes[3] = {
3258 { 2, ad1882_ch2_init },
3259 { 4, ad1882_ch4_init },
3260 { 6, ad1882_ch6_init },
3261};
3262
3263/*
3264 * initialization verbs
3265 */
3266static struct hda_verb ad1882_init_verbs[] = {
3267 /* DACs; mute as default */
3268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3269 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3270 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3271 /* Port-A (HP) mixer */
3272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3274 /* Port-A pin */
3275 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3276 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3277 /* HP selector - select DAC2 */
3278 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
3279 /* Port-D (Line-out) mixer */
3280 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3281 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3282 /* Port-D pin */
3283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3284 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3285 /* Mono-out mixer */
3286 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3287 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3288 /* Mono-out pin */
3289 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3291 /* Port-B (front mic) pin */
3292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3294 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3295 /* Port-C (line-in) pin */
3296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3298 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3299 /* Port-C mixer - mute as input */
3300 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3301 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3302 /* Port-E (mic-in) pin */
3303 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3306 /* Port-E mixer - mute as input */
3307 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3308 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3309 /* Port-F (surround) */
3310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3312 /* Port-G (CLFE) */
3313 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3315 /* Analog mixer; mute as default */
3316 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
3317 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3318 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3319 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3320 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3321 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3322 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3323 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3324 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3325 /* Analog Mix output amp */
3326 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3327 /* SPDIF output selector */
3328 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3329 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3331 { } /* end */
3332};
3333
3334/* models */
3335enum {
3336 AD1882_3STACK,
3337 AD1882_6STACK,
3338 AD1882_MODELS
3339};
3340
3341static const char *ad1882_models[AD1986A_MODELS] = {
3342 [AD1882_3STACK] = "3stack",
3343 [AD1882_6STACK] = "6stack",
3344};
3345
3346
3347static int patch_ad1882(struct hda_codec *codec)
3348{
3349 struct ad198x_spec *spec;
3350 int board_config;
3351
3352 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3353 if (spec == NULL)
3354 return -ENOMEM;
3355
3356 mutex_init(&spec->amp_mutex);
3357 codec->spec = spec;
3358
3359 spec->multiout.max_channels = 6;
3360 spec->multiout.num_dacs = 3;
3361 spec->multiout.dac_nids = ad1882_dac_nids;
3362 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
3363 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
3364 spec->adc_nids = ad1882_adc_nids;
3365 spec->capsrc_nids = ad1882_capsrc_nids;
3366 spec->input_mux = &ad1882_capture_source;
3367 spec->num_mixers = 1;
3368 spec->mixers[0] = ad1882_base_mixers;
3369 spec->num_init_verbs = 1;
3370 spec->init_verbs[0] = ad1882_init_verbs;
3371 spec->spdif_route = 0;
3372
3373 codec->patch_ops = ad198x_patch_ops;
3374
3375 /* override some parameters */
3376 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
3377 ad1882_models, NULL);
3378 switch (board_config) {
3379 default:
3380 case AD1882_3STACK:
3381 spec->num_mixers = 2;
3382 spec->mixers[1] = ad1882_3stack_mixers;
3383 spec->channel_mode = ad1882_modes;
3384 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
3385 spec->need_dac_fix = 1;
3386 spec->multiout.max_channels = 2;
3387 spec->multiout.num_dacs = 1;
3388 break;
3389 case AD1882_6STACK:
3390 spec->num_mixers = 2;
3391 spec->mixers[1] = ad1882_6stack_mixers;
3392 break;
3393 }
3394 return 0;
3395}
3396
3397
3398/*
2767 * patch entries 3399 * patch entries
2768 */ 3400 */
2769struct hda_codec_preset snd_hda_preset_analog[] = { 3401struct hda_codec_preset snd_hda_preset_analog[] = {
3402 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
3403 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
2770 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 3404 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2771 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 3405 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3406 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
2772 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 3407 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
2773 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, 3408 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
2774 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, 3409 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 831469d3a92..72d3ab9751a 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -94,6 +94,17 @@ static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
94 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 94 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
95} 95}
96 96
97static int atihdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
98 struct hda_codec *codec,
99 unsigned int stream_tag,
100 unsigned int format,
101 struct snd_pcm_substream *substream)
102{
103 struct atihdmi_spec *spec = codec->spec;
104 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
105 format, substream);
106}
107
97static struct hda_pcm_stream atihdmi_pcm_digital_playback = { 108static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
98 .substreams = 1, 109 .substreams = 1,
99 .channels_min = 2, 110 .channels_min = 2,
@@ -101,7 +112,8 @@ static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
101 .nid = 0x2, /* NID to query formats and rates and setup streams */ 112 .nid = 0x2, /* NID to query formats and rates and setup streams */
102 .ops = { 113 .ops = {
103 .open = atihdmi_dig_playback_pcm_open, 114 .open = atihdmi_dig_playback_pcm_open,
104 .close = atihdmi_dig_playback_pcm_close 115 .close = atihdmi_dig_playback_pcm_close,
116 .prepare = atihdmi_dig_playback_pcm_prepare
105 }, 117 },
106}; 118};
107 119
@@ -160,6 +172,8 @@ static int patch_atihdmi(struct hda_codec *codec)
160 */ 172 */
161struct hda_codec_preset snd_hda_preset_atihdmi[] = { 173struct hda_codec_preset snd_hda_preset_atihdmi[] = {
162 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 174 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
163 { .id = 0x1002791a, .name = "ATI RS690 HDMI", .patch = patch_atihdmi }, 175 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
176 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
177 { .id = 0x1002aa01, .name = "ATI R600 HDMI", .patch = patch_atihdmi },
164 {} /* terminator */ 178 {} /* terminator */
165}; 179};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 5b9d3a31a1a..3c722e667bc 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -497,6 +497,17 @@ static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
497 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 497 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
498} 498}
499 499
500static int cmi9880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
501 struct hda_codec *codec,
502 unsigned int stream_tag,
503 unsigned int format,
504 struct snd_pcm_substream *substream)
505{
506 struct cmi_spec *spec = codec->spec;
507 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
508 format, substream);
509}
510
500/* 511/*
501 * Analog capture 512 * Analog capture
502 */ 513 */
@@ -556,7 +567,8 @@ static struct hda_pcm_stream cmi9880_pcm_digital_playback = {
556 /* NID is set in cmi9880_build_pcms */ 567 /* NID is set in cmi9880_build_pcms */
557 .ops = { 568 .ops = {
558 .open = cmi9880_dig_playback_pcm_open, 569 .open = cmi9880_dig_playback_pcm_open,
559 .close = cmi9880_dig_playback_pcm_close 570 .close = cmi9880_dig_playback_pcm_close,
571 .prepare = cmi9880_dig_playback_pcm_prepare
560 }, 572 },
561}; 573};
562 574
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 46e93c6b9a4..4d8e8af5c81 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -136,6 +136,18 @@ static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
136 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 136 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
137} 137}
138 138
139static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
140 struct hda_codec *codec,
141 unsigned int stream_tag,
142 unsigned int format,
143 struct snd_pcm_substream *substream)
144{
145 struct conexant_spec *spec = codec->spec;
146 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
147 stream_tag,
148 format, substream);
149}
150
139/* 151/*
140 * Analog capture 152 * Analog capture
141 */ 153 */
@@ -194,7 +206,8 @@ static struct hda_pcm_stream conexant_pcm_digital_playback = {
194 .nid = 0, /* fill later */ 206 .nid = 0, /* fill later */
195 .ops = { 207 .ops = {
196 .open = conexant_dig_playback_pcm_open, 208 .open = conexant_dig_playback_pcm_open,
197 .close = conexant_dig_playback_pcm_close 209 .close = conexant_dig_playback_pcm_close,
210 .prepare = conexant_dig_playback_pcm_prepare
198 }, 211 },
199}; 212};
200 213
@@ -452,115 +465,6 @@ static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
452 .put = conexant_ch_mode_put, \ 465 .put = conexant_ch_mode_put, \
453 .private_value = nid | (dir<<16) } 466 .private_value = nid | (dir<<16) }
454 467
455static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_info *uinfo)
457{
458 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
459 uinfo->count = 1;
460 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1;
462 return 0;
463}
464
465static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
467{
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
471 long *valp = ucontrol->value.integer.value;
472 unsigned int val = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_GPIO_DATA, 0x00);
474
475 *valp = (val & mask) != 0;
476 return 0;
477}
478
479static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
481{
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 hda_nid_t nid = kcontrol->private_value & 0xffff;
484 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
485 long val = *ucontrol->value.integer.value;
486 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_GPIO_DATA,
488 0x00);
489 unsigned int old_data = gpio_data;
490
491 /* Set/unset the masked GPIO bit(s) as needed */
492 if (val == 0)
493 gpio_data &= ~mask;
494 else
495 gpio_data |= mask;
496 if (gpio_data == old_data && !codec->in_resume)
497 return 0;
498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
499 return 1;
500}
501
502#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \
503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
504 .info = cxt_gpio_data_info, \
505 .get = cxt_gpio_data_get, \
506 .put = cxt_gpio_data_put, \
507 .private_value = nid | (mask<<16) }
508#if 0
509static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_info *uinfo)
511{
512 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
513 uinfo->count = 1;
514 uinfo->value.integer.min = 0;
515 uinfo->value.integer.max = 1;
516 return 0;
517}
518
519static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_value *ucontrol)
521{
522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
523 hda_nid_t nid = kcontrol->private_value & 0xffff;
524 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
525 long *valp = ucontrol->value.integer.value;
526 unsigned int val = snd_hda_codec_read(codec, nid, 0,
527 AC_VERB_GET_DIGI_CONVERT, 0x00);
528
529 *valp = (val & mask) != 0;
530 return 0;
531}
532
533static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 hda_nid_t nid = kcontrol->private_value & 0xffff;
538 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
539 long val = *ucontrol->value.integer.value;
540 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
541 AC_VERB_GET_DIGI_CONVERT,
542 0x00);
543 unsigned int old_data = ctrl_data;
544
545 /* Set/unset the masked control bit(s) as needed */
546 if (val == 0)
547 ctrl_data &= ~mask;
548 else
549 ctrl_data |= mask;
550 if (ctrl_data == old_data && !codec->in_resume)
551 return 0;
552 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
553 ctrl_data);
554 return 1;
555}
556
557#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \
558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
559 .info = cxt_spdif_ctrl_info, \
560 .get = cxt_spdif_ctrl_get, \
561 .put = cxt_spdif_ctrl_put, \
562 .private_value = nid | (mask<<16) }
563#endif
564#endif /* CONFIG_SND_DEBUG */ 468#endif /* CONFIG_SND_DEBUG */
565 469
566/* Conexant 5045 specific */ 470/* Conexant 5045 specific */
@@ -599,6 +503,7 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
599 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80; 503 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
600 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 504 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
601 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 505 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
506
602 bits = spec->cur_eapd ? 0 : 0x80; 507 bits = spec->cur_eapd ? 0 : 0x80;
603 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits); 508 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
604 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits); 509 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
@@ -624,6 +529,29 @@ static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
624 return change; 529 return change;
625} 530}
626 531
532/* toggle input of built-in and mic jack appropriately */
533static void cxt5045_hp_automic(struct hda_codec *codec)
534{
535 static struct hda_verb mic_jack_on[] = {
536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
537 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
538 {}
539 };
540 static struct hda_verb mic_jack_off[] = {
541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
543 {}
544 };
545 unsigned int present;
546
547 present = snd_hda_codec_read(codec, 0x12, 0,
548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
549 if (present)
550 snd_hda_sequence_write(codec, mic_jack_on);
551 else
552 snd_hda_sequence_write(codec, mic_jack_off);
553}
554
627 555
628/* mute internal speaker if HP is plugged */ 556/* mute internal speaker if HP is plugged */
629static void cxt5045_hp_automute(struct hda_codec *codec) 557static void cxt5045_hp_automute(struct hda_codec *codec)
@@ -634,7 +562,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec)
634 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, 562 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
635 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
636 564
637 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; 565 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
638 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 566 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
639 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 567 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
640} 568}
@@ -648,6 +576,10 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
648 case CONEXANT_HP_EVENT: 576 case CONEXANT_HP_EVENT:
649 cxt5045_hp_automute(codec); 577 cxt5045_hp_automute(codec);
650 break; 578 break;
579 case CONEXANT_MIC_EVENT:
580 cxt5045_hp_automic(codec);
581 break;
582
651 } 583 }
652} 584}
653 585
@@ -659,12 +591,10 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
659 .get = conexant_mux_enum_get, 591 .get = conexant_mux_enum_get,
660 .put = conexant_mux_enum_put 592 .put = conexant_mux_enum_put
661 }, 593 },
662 HDA_CODEC_VOLUME("Int Mic Volume", 0x17, 0x01, HDA_INPUT), 594 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
663 HDA_CODEC_MUTE("Int Mic Switch", 0x17, 0x01, HDA_INPUT), 595 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
664 HDA_CODEC_VOLUME("Ext Mic Volume", 0x17, 0x02, HDA_INPUT), 596 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
665 HDA_CODEC_MUTE("Ext Mic Switch", 0x17, 0x02, HDA_INPUT), 597 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
667 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
668 { 598 {
669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
670 .name = "Master Playback Volume", 600 .name = "Master Playback Volume",
@@ -688,7 +618,7 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
688static struct hda_verb cxt5045_init_verbs[] = { 618static struct hda_verb cxt5045_init_verbs[] = {
689 /* Line in, Mic */ 619 /* Line in, Mic */
690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
692 /* HP, Amp */ 622 /* HP, Amp */
693 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 623 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
694 {0x17, AC_VERB_SET_CONNECT_SEL,0x01}, 624 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
@@ -701,18 +631,29 @@ static struct hda_verb cxt5045_init_verbs[] = {
701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
702 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04}, 632 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
703 /* Record selector: Int mic */ 633 /* Record selector: Int mic */
704 {0x1a, AC_VERB_SET_CONNECT_SEL,0x0}, 634 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
706 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 636 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
707 /* SPDIF route: PCM */ 637 /* SPDIF route: PCM */
708 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 638 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
709 /* pin sensing on HP and Mic jacks */
710 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
711 /* EAPD */ 639 /* EAPD */
712 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 640 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
713 { } /* end */ 641 { } /* end */
714}; 642};
715 643
644
645static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
646 /* pin sensing on HP jack */
647 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
648 { } /* end */
649};
650
651static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
652 /* pin sensing on HP jack */
653 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
654 { } /* end */
655};
656
716#ifdef CONFIG_SND_DEBUG 657#ifdef CONFIG_SND_DEBUG
717/* Test configuration for debugging, modelled after the ALC260 test 658/* Test configuration for debugging, modelled after the ALC260 test
718 * configuration. 659 * configuration.
@@ -733,6 +674,10 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
733 /* Output controls */ 674 /* Output controls */
734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
679 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
736 681
737 /* Modes for retasking pin widgets */ 682 /* Modes for retasking pin widgets */
738 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 683 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
@@ -742,25 +687,17 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
742 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 687 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
743 688
744 /* Loopback mixer controls */ 689 /* Loopback mixer controls */
745 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT), 690
746 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT), 691 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
747 HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT), 692 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
748 HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT), 693 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
749 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT), 694 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
750 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT), 695 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
751 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT), 696 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
752 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT), 697 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
753 698 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
754 HDA_CODEC_VOLUME("Capture-1 Volume", 0x17, 0x0, HDA_INPUT), 699 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
755 HDA_CODEC_MUTE("Capture-1 Switch", 0x17, 0x0, HDA_INPUT), 700 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
756 HDA_CODEC_VOLUME("Capture-2 Volume", 0x17, 0x1, HDA_INPUT),
757 HDA_CODEC_MUTE("Capture-2 Switch", 0x17, 0x1, HDA_INPUT),
758 HDA_CODEC_VOLUME("Capture-3 Volume", 0x17, 0x2, HDA_INPUT),
759 HDA_CODEC_MUTE("Capture-3 Switch", 0x17, 0x2, HDA_INPUT),
760 HDA_CODEC_VOLUME("Capture-4 Volume", 0x17, 0x3, HDA_INPUT),
761 HDA_CODEC_MUTE("Capture-4 Switch", 0x17, 0x3, HDA_INPUT),
762 HDA_CODEC_VOLUME("Capture-5 Volume", 0x17, 0x4, HDA_INPUT),
763 HDA_CODEC_MUTE("Capture-5 Switch", 0x17, 0x4, HDA_INPUT),
764 { 701 {
765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
766 .name = "Input Source", 703 .name = "Input Source",
@@ -768,14 +705,28 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
768 .get = conexant_mux_enum_get, 705 .get = conexant_mux_enum_get,
769 .put = conexant_mux_enum_put, 706 .put = conexant_mux_enum_put,
770 }, 707 },
771 708 /* Audio input controls */
709 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
710 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
711 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
712 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
713 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
714 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
715 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
716 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
717 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
718 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
772 { } /* end */ 719 { } /* end */
773}; 720};
774 721
775static struct hda_verb cxt5045_test_init_verbs[] = { 722static struct hda_verb cxt5045_test_init_verbs[] = {
723 /* Set connections */
724 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
725 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
726 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
776 /* Enable retasking pins as output, initially without power amp */ 727 /* Enable retasking pins as output, initially without power amp */
777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 728 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 729 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 730
780 /* Disable digital (SPDIF) pins initially, but users can enable 731 /* Disable digital (SPDIF) pins initially, but users can enable
781 * them via a mixer switch. In the case of SPDIF-out, this initverb 732 * them via a mixer switch. In the case of SPDIF-out, this initverb
@@ -804,6 +755,7 @@ static struct hda_verb cxt5045_test_init_verbs[] = {
804 * pin) 755 * pin)
805 */ 756 */
806 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 757 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
758 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
807 759
808 /* Mute all inputs to mixer widget (even unconnected ones) */ 760 /* Mute all inputs to mixer widget (even unconnected ones) */
809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ 761 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
@@ -827,7 +779,8 @@ static int cxt5045_init(struct hda_codec *codec)
827 779
828 780
829enum { 781enum {
830 CXT5045_LAPTOP, /* Laptops w/ EAPD support */ 782 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
783 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
831#ifdef CONFIG_SND_DEBUG 784#ifdef CONFIG_SND_DEBUG
832 CXT5045_TEST, 785 CXT5045_TEST,
833#endif 786#endif
@@ -836,6 +789,7 @@ enum {
836 789
837static const char *cxt5045_models[CXT5045_MODELS] = { 790static const char *cxt5045_models[CXT5045_MODELS] = {
838 [CXT5045_LAPTOP] = "laptop", 791 [CXT5045_LAPTOP] = "laptop",
792 [CXT5045_FUJITSU] = "fujitsu",
839#ifdef CONFIG_SND_DEBUG 793#ifdef CONFIG_SND_DEBUG
840 [CXT5045_TEST] = "test", 794 [CXT5045_TEST] = "test",
841#endif 795#endif
@@ -844,7 +798,13 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 798static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
845 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), 799 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
846 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP), 800 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
847 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP), 801 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
802 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
803 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
804 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),
805 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
806 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),
807 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
848 {} 808 {}
849}; 809};
850 810
@@ -877,16 +837,23 @@ static int patch_cxt5045(struct hda_codec *codec)
877 837
878 838
879 codec->patch_ops = conexant_patch_ops; 839 codec->patch_ops = conexant_patch_ops;
880 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
881 840
882 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 841 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
883 cxt5045_models, 842 cxt5045_models,
884 cxt5045_cfg_tbl); 843 cxt5045_cfg_tbl);
885 switch (board_config) { 844 switch (board_config) {
886 case CXT5045_LAPTOP: 845 case CXT5045_LAPTOP:
846 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
847 spec->input_mux = &cxt5045_capture_source;
848 spec->num_init_verbs = 2;
849 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
850 spec->mixers[0] = cxt5045_mixers;
851 codec->patch_ops.init = cxt5045_init;
852 break;
853 case CXT5045_FUJITSU:
887 spec->input_mux = &cxt5045_capture_source; 854 spec->input_mux = &cxt5045_capture_source;
888 spec->num_init_verbs = 2; 855 spec->num_init_verbs = 2;
889 spec->init_verbs[1] = cxt5045_init_verbs; 856 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
890 spec->mixers[0] = cxt5045_mixers; 857 spec->mixers[0] = cxt5045_mixers;
891 codec->patch_ops.init = cxt5045_init; 858 codec->patch_ops.init = cxt5045_init;
892 break; 859 break;
@@ -913,10 +880,9 @@ static struct hda_channel_mode cxt5047_modes[1] = {
913}; 880};
914 881
915static struct hda_input_mux cxt5047_capture_source = { 882static struct hda_input_mux cxt5047_capture_source = {
916 .num_items = 2, 883 .num_items = 1,
917 .items = { 884 .items = {
918 { "ExtMic", 0x0 }, 885 { "Mic", 0x2 },
919 { "IntMic", 0x1 },
920 } 886 }
921}; 887};
922 888
@@ -994,6 +960,23 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
994 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); 960 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
995} 961}
996 962
963/* mute internal speaker if HP is plugged */
964static void cxt5047_hp2_automute(struct hda_codec *codec)
965{
966 struct conexant_spec *spec = codec->spec;
967 unsigned int bits;
968
969 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
971
972 bits = spec->hp_present ? 0x80 : 0;
973 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
974 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
975 /* Mute/Unmute PCM 2 for good measure - some systems need this */
976 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
977 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
978}
979
997/* toggle input of built-in and mic jack appropriately */ 980/* toggle input of built-in and mic jack appropriately */
998static void cxt5047_hp_automic(struct hda_codec *codec) 981static void cxt5047_hp_automic(struct hda_codec *codec)
999{ 982{
@@ -1009,7 +992,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
1009 }; 992 };
1010 unsigned int present; 993 unsigned int present;
1011 994
1012 present = snd_hda_codec_read(codec, 0x08, 0, 995 present = snd_hda_codec_read(codec, 0x15, 0,
1013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1014 if (present) 997 if (present)
1015 snd_hda_sequence_write(codec, mic_jack_on); 998 snd_hda_sequence_write(codec, mic_jack_on);
@@ -1032,38 +1015,36 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1032 } 1015 }
1033} 1016}
1034 1017
1018/* unsolicited event for HP jack sensing - non-EAPD systems */
1019static void cxt5047_hp2_unsol_event(struct hda_codec *codec,
1020 unsigned int res)
1021{
1022 res >>= 26;
1023 switch (res) {
1024 case CONEXANT_HP_EVENT:
1025 cxt5047_hp2_automute(codec);
1026 break;
1027 case CONEXANT_MIC_EVENT:
1028 cxt5047_hp_automic(codec);
1029 break;
1030 }
1031}
1032
1035static struct snd_kcontrol_new cxt5047_mixers[] = { 1033static struct snd_kcontrol_new cxt5047_mixers[] = {
1036 {
1037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1038 .name = "Capture Source",
1039 .info = conexant_mux_enum_info,
1040 .get = conexant_mux_enum_get,
1041 .put = conexant_mux_enum_put
1042 },
1043 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), 1034 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), 1035 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1036 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1038 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1046 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1039 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1047 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1040 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 1041 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT), 1042 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT), 1043 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1051 { 1044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1045 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1053 .name = "Master Playback Volume", 1046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1054 .info = snd_hda_mixer_amp_volume_info, 1047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1055 .get = snd_hda_mixer_amp_volume_get,
1056 .put = cxt5047_hp_master_vol_put,
1057 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1058 },
1059 {
1060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1061 .name = "Master Playback Switch",
1062 .info = cxt_eapd_info,
1063 .get = cxt_eapd_get,
1064 .put = cxt5047_hp_master_sw_put,
1065 .private_value = 0x13,
1066 },
1067 1048
1068 {} 1049 {}
1069}; 1050};
@@ -1133,18 +1114,19 @@ static struct hda_verb cxt5047_init_verbs[] = {
1133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1116 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1136 /* HP, Amp, Speaker */ 1117 /* HP, Speaker */
1137 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1118 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1138 {0x1A, AC_VERB_SET_CONNECT_SEL,0x00}, 1119 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1139 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1140 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1141 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1142 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1143 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0}, 1120 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1144 /* Record selector: Front mic */ 1121 /* Record selector: Mic */
1145 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1122 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1147 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1124 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1125 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1126 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1127 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1128 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1129 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1148 /* SPDIF route: PCM */ 1130 /* SPDIF route: PCM */
1149 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 1131 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1150 /* Enable unsolicited events */ 1132 /* Enable unsolicited events */
@@ -1161,8 +1143,6 @@ static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1162 /* Speaker routing */ 1144 /* Speaker routing */
1163 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1}, 1145 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1164 /* Change default to ExtMic for recording */
1165 {0x1a, AC_VERB_SET_CONNECT_SEL,0x2},
1166 {} 1146 {}
1167}; 1147};
1168 1148
@@ -1172,7 +1152,6 @@ static struct hda_verb cxt5047_hp_init_verbs[] = {
1172 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 1152 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1173 /* Record selector: Ext Mic */ 1153 /* Record selector: Ext Mic */
1174 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1154 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1175 {0x1a, AC_VERB_SET_CONNECT_SEL,0x02},
1176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1177 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1156 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1178 /* Speaker routing */ 1157 /* Speaker routing */
@@ -1242,14 +1221,6 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1242 .get = conexant_mux_enum_get, 1221 .get = conexant_mux_enum_get,
1243 .put = conexant_mux_enum_put, 1222 .put = conexant_mux_enum_put,
1244 }, 1223 },
1245 /* Controls for GPIO pins, assuming they exist and are configured
1246 * as outputs
1247 */
1248 CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
1249 CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
1250 CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
1251 CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
1252
1253 { } /* end */ 1224 { } /* end */
1254}; 1225};
1255 1226
@@ -1374,19 +1345,20 @@ static int patch_cxt5047(struct hda_codec *codec)
1374 spec->channel_mode = cxt5047_modes, 1345 spec->channel_mode = cxt5047_modes,
1375 1346
1376 codec->patch_ops = conexant_patch_ops; 1347 codec->patch_ops = conexant_patch_ops;
1377 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1378 1348
1379 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1349 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1380 cxt5047_models, 1350 cxt5047_models,
1381 cxt5047_cfg_tbl); 1351 cxt5047_cfg_tbl);
1382 switch (board_config) { 1352 switch (board_config) {
1383 case CXT5047_LAPTOP: 1353 case CXT5047_LAPTOP:
1354 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event;
1384 break; 1355 break;
1385 case CXT5047_LAPTOP_HP: 1356 case CXT5047_LAPTOP_HP:
1386 spec->input_mux = &cxt5047_hp_capture_source; 1357 spec->input_mux = &cxt5047_hp_capture_source;
1387 spec->num_init_verbs = 2; 1358 spec->num_init_verbs = 2;
1388 spec->init_verbs[1] = cxt5047_hp_init_verbs; 1359 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1389 spec->mixers[0] = cxt5047_hp_mixers; 1360 spec->mixers[0] = cxt5047_hp_mixers;
1361 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1390 codec->patch_ops.init = cxt5047_hp_init; 1362 codec->patch_ops.init = cxt5047_hp_init;
1391 break; 1363 break;
1392 case CXT5047_LAPTOP_EAPD: 1364 case CXT5047_LAPTOP_EAPD:
@@ -1394,12 +1366,14 @@ static int patch_cxt5047(struct hda_codec *codec)
1394 spec->num_init_verbs = 2; 1366 spec->num_init_verbs = 2;
1395 spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1367 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1396 spec->mixers[0] = cxt5047_toshiba_mixers; 1368 spec->mixers[0] = cxt5047_toshiba_mixers;
1369 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1397 break; 1370 break;
1398#ifdef CONFIG_SND_DEBUG 1371#ifdef CONFIG_SND_DEBUG
1399 case CXT5047_TEST: 1372 case CXT5047_TEST:
1400 spec->input_mux = &cxt5047_test_capture_source; 1373 spec->input_mux = &cxt5047_test_capture_source;
1401 spec->mixers[0] = cxt5047_test_mixer; 1374 spec->mixers[0] = cxt5047_test_mixer;
1402 spec->init_verbs[0] = cxt5047_test_init_verbs; 1375 spec->init_verbs[0] = cxt5047_test_init_verbs;
1376 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1403#endif 1377#endif
1404 } 1378 }
1405 return 0; 1379 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fba3cb11bc2..9a47eec5a27 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -74,6 +74,8 @@ enum {
74 ALC260_HP_3013, 74 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X, 75 ALC260_FUJITSU_S702X,
76 ALC260_ACER, 76 ALC260_ACER,
77 ALC260_WILL,
78 ALC260_REPLACER_672V,
77#ifdef CONFIG_SND_DEBUG 79#ifdef CONFIG_SND_DEBUG
78 ALC260_TEST, 80 ALC260_TEST,
79#endif 81#endif
@@ -91,10 +93,19 @@ enum {
91 ALC262_HP_BPC_D7000_WL, 93 ALC262_HP_BPC_D7000_WL,
92 ALC262_HP_BPC_D7000_WF, 94 ALC262_HP_BPC_D7000_WF,
93 ALC262_BENQ_ED8, 95 ALC262_BENQ_ED8,
96 ALC262_SONY_ASSAMD,
97 ALC262_BENQ_T31,
94 ALC262_AUTO, 98 ALC262_AUTO,
95 ALC262_MODEL_LAST /* last tag */ 99 ALC262_MODEL_LAST /* last tag */
96}; 100};
97 101
102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
98/* ALC861 models */ 109/* ALC861 models */
99enum { 110enum {
100 ALC861_3ST, 111 ALC861_3ST,
@@ -112,20 +123,38 @@ enum {
112/* ALC861-VD models */ 123/* ALC861-VD models */
113enum { 124enum {
114 ALC660VD_3ST, 125 ALC660VD_3ST,
126 ALC660VD_3ST_DIG,
115 ALC861VD_3ST, 127 ALC861VD_3ST,
116 ALC861VD_3ST_DIG, 128 ALC861VD_3ST_DIG,
117 ALC861VD_6ST_DIG, 129 ALC861VD_6ST_DIG,
130 ALC861VD_LENOVO,
131 ALC861VD_DALLAS,
118 ALC861VD_AUTO, 132 ALC861VD_AUTO,
119 ALC861VD_MODEL_LAST, 133 ALC861VD_MODEL_LAST,
120}; 134};
121 135
136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
122/* ALC882 models */ 147/* ALC882 models */
123enum { 148enum {
124 ALC882_3ST_DIG, 149 ALC882_3ST_DIG,
125 ALC882_6ST_DIG, 150 ALC882_6ST_DIG,
126 ALC882_ARIMA, 151 ALC882_ARIMA,
127 ALC882_AUTO, 152 ALC882_W2JC,
153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
128 ALC885_MACPRO, 155 ALC885_MACPRO,
156 ALC885_IMAC24,
157 ALC882_AUTO,
129 ALC882_MODEL_LAST, 158 ALC882_MODEL_LAST,
130}; 159};
131 160
@@ -137,10 +166,15 @@ enum {
137 ALC883_6ST_DIG, 166 ALC883_6ST_DIG,
138 ALC883_TARGA_DIG, 167 ALC883_TARGA_DIG,
139 ALC883_TARGA_2ch_DIG, 168 ALC883_TARGA_2ch_DIG,
140 ALC888_DEMO_BOARD,
141 ALC883_ACER, 169 ALC883_ACER,
142 ALC883_MEDION, 170 ALC883_MEDION,
171 ALC883_MEDION_MD2,
143 ALC883_LAPTOP_EAPD, 172 ALC883_LAPTOP_EAPD,
173 ALC883_LENOVO_101E_2ch,
174 ALC883_LENOVO_NB0763,
175 ALC888_LENOVO_MS7195_DIG,
176 ALC888_6ST_HP,
177 ALC888_3ST_HP,
144 ALC883_AUTO, 178 ALC883_AUTO,
145 ALC883_MODEL_LAST, 179 ALC883_MODEL_LAST,
146}; 180};
@@ -163,7 +197,7 @@ struct alc_spec {
163 struct hda_pcm_stream *stream_analog_playback; 197 struct hda_pcm_stream *stream_analog_playback;
164 struct hda_pcm_stream *stream_analog_capture; 198 struct hda_pcm_stream *stream_analog_capture;
165 199
166 char *stream_name_digital; /* digital PCM stream */ 200 char *stream_name_digital; /* digital PCM stream */
167 struct hda_pcm_stream *stream_digital_playback; 201 struct hda_pcm_stream *stream_digital_playback;
168 struct hda_pcm_stream *stream_digital_capture; 202 struct hda_pcm_stream *stream_digital_capture;
169 203
@@ -401,7 +435,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
401 AC_VERB_GET_PIN_WIDGET_CONTROL, 435 AC_VERB_GET_PIN_WIDGET_CONTROL,
402 0x00); 436 0x00);
403 437
404 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 438 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
405 val = alc_pin_mode_min(dir); 439 val = alc_pin_mode_min(dir);
406 440
407 change = pinctl != alc_pin_mode_values[val]; 441 change = pinctl != alc_pin_mode_values[val];
@@ -460,7 +494,8 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
460 uinfo->value.integer.min = 0; 494 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1; 495 uinfo->value.integer.max = 1;
462 return 0; 496 return 0;
463} 497}
498
464static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 499static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol) 500 struct snd_ctl_elem_value *ucontrol)
466{ 501{
@@ -520,7 +555,8 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
520 uinfo->value.integer.min = 0; 555 uinfo->value.integer.min = 0;
521 uinfo->value.integer.max = 1; 556 uinfo->value.integer.max = 1;
522 return 0; 557 return 0;
523} 558}
559
524static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 560static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol) 561 struct snd_ctl_elem_value *ucontrol)
526{ 562{
@@ -592,7 +628,7 @@ static void setup_preset(struct alc_spec *spec,
592 spec->multiout.hp_nid = preset->hp_nid; 628 spec->multiout.hp_nid = preset->hp_nid;
593 629
594 spec->num_mux_defs = preset->num_mux_defs; 630 spec->num_mux_defs = preset->num_mux_defs;
595 if (! spec->num_mux_defs) 631 if (!spec->num_mux_defs)
596 spec->num_mux_defs = 1; 632 spec->num_mux_defs = 1;
597 spec->input_mux = preset->input_mux; 633 spec->input_mux = preset->input_mux;
598 634
@@ -604,6 +640,122 @@ static void setup_preset(struct alc_spec *spec,
604 spec->init_hook = preset->init_hook; 640 spec->init_hook = preset->init_hook;
605} 641}
606 642
643/* Enable GPIO mask and set output */
644static struct hda_verb alc_gpio1_init_verbs[] = {
645 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
647 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
648 { }
649};
650
651static struct hda_verb alc_gpio2_init_verbs[] = {
652 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
654 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
655 { }
656};
657
658static struct hda_verb alc_gpio3_init_verbs[] = {
659 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
661 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
662 { }
663};
664
665/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
666 * 31 ~ 16 : Manufacture ID
667 * 15 ~ 8 : SKU ID
668 * 7 ~ 0 : Assembly ID
669 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
670 */
671static void alc_subsystem_id(struct hda_codec *codec,
672 unsigned int porta, unsigned int porte,
673 unsigned int portd)
674{
675 unsigned int ass, tmp;
676
677 ass = codec->subsystem_id;
678 if (!(ass & 1))
679 return;
680
681 /* Override */
682 tmp = (ass & 0x38) >> 3; /* external Amp control */
683 switch (tmp) {
684 case 1:
685 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
686 break;
687 case 3:
688 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
689 break;
690 case 7:
691 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
692 break;
693 case 5:
694 switch (codec->vendor_id) {
695 case 0x10ec0862:
696 case 0x10ec0660:
697 case 0x10ec0662:
698 case 0x10ec0267:
699 case 0x10ec0268:
700 snd_hda_codec_write(codec, 0x14, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 snd_hda_codec_write(codec, 0x15, 0,
703 AC_VERB_SET_EAPD_BTLENABLE, 2);
704 return;
705 }
706 case 6:
707 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
708 hda_nid_t port = 0;
709 tmp = (ass & 0x1800) >> 11;
710 switch (tmp) {
711 case 0: port = porta; break;
712 case 1: port = porte; break;
713 case 2: port = portd; break;
714 }
715 if (port)
716 snd_hda_codec_write(codec, port, 0,
717 AC_VERB_SET_EAPD_BTLENABLE,
718 2);
719 }
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
721 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
722 (tmp == 5 ? 0x3040 : 0x3050));
723 break;
724 }
725}
726
727/*
728 * Fix-up pin default configurations
729 */
730
731struct alc_pincfg {
732 hda_nid_t nid;
733 u32 val;
734};
735
736static void alc_fix_pincfg(struct hda_codec *codec,
737 const struct snd_pci_quirk *quirk,
738 const struct alc_pincfg **pinfix)
739{
740 const struct alc_pincfg *cfg;
741
742 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
743 if (!quirk)
744 return;
745
746 cfg = pinfix[quirk->value];
747 for (; cfg->nid; cfg++) {
748 int i;
749 u32 val = cfg->val;
750 for (i = 0; i < 4; i++) {
751 snd_hda_codec_write(codec, cfg->nid, 0,
752 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
753 val & 0xff);
754 val >>= 8;
755 }
756 }
757}
758
607/* 759/*
608 * ALC880 3-stack model 760 * ALC880 3-stack model
609 * 761 *
@@ -801,7 +953,7 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
801static hda_nid_t alc880_6st_dac_nids[4] = { 953static hda_nid_t alc880_6st_dac_nids[4] = {
802 /* front, rear, clfe, rear_surr */ 954 /* front, rear, clfe, rear_surr */
803 0x02, 0x03, 0x04, 0x05 955 0x02, 0x03, 0x04, 0x05
804}; 956};
805 957
806static struct hda_input_mux alc880_6stack_capture_source = { 958static struct hda_input_mux alc880_6stack_capture_source = {
807 .num_items = 4, 959 .num_items = 4,
@@ -1409,25 +1561,43 @@ static struct hda_verb alc880_beep_init_verbs[] = {
1409}; 1561};
1410 1562
1411/* toggle speaker-output according to the hp-jack state */ 1563/* toggle speaker-output according to the hp-jack state */
1412static void alc880_uniwill_automute(struct hda_codec *codec) 1564static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1413{ 1565{
1414 unsigned int present; 1566 unsigned int present;
1567 unsigned char bits;
1415 1568
1416 present = snd_hda_codec_read(codec, 0x14, 0, 1569 present = snd_hda_codec_read(codec, 0x14, 0,
1417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1571 bits = present ? 0x80 : 0;
1418 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 1572 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1419 0x80, present ? 0x80 : 0); 1573 0x80, bits);
1420 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 1574 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1421 0x80, present ? 0x80 : 0); 1575 0x80, bits);
1422 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, 1576 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1423 0x80, present ? 0x80 : 0); 1577 0x80, bits);
1424 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, 1578 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1425 0x80, present ? 0x80 : 0); 1579 0x80, bits);
1580}
1581
1582/* auto-toggle front mic */
1583static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1584{
1585 unsigned int present;
1586 unsigned char bits;
1426 1587
1427 present = snd_hda_codec_read(codec, 0x18, 0, 1588 present = snd_hda_codec_read(codec, 0x18, 0,
1428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1429 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1590 bits = present ? 0x80 : 0;
1430 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 1591 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1592 0x80, bits);
1593 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1594 0x80, bits);
1595}
1596
1597static void alc880_uniwill_automute(struct hda_codec *codec)
1598{
1599 alc880_uniwill_hp_automute(codec);
1600 alc880_uniwill_mic_automute(codec);
1431} 1601}
1432 1602
1433static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1603static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -1436,22 +1606,28 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1436 /* Looks like the unsol event is incompatible with the standard 1606 /* Looks like the unsol event is incompatible with the standard
1437 * definition. 4bit tag is placed at 28 bit! 1607 * definition. 4bit tag is placed at 28 bit!
1438 */ 1608 */
1439 if ((res >> 28) == ALC880_HP_EVENT || 1609 switch (res >> 28) {
1440 (res >> 28) == ALC880_MIC_EVENT) 1610 case ALC880_HP_EVENT:
1441 alc880_uniwill_automute(codec); 1611 alc880_uniwill_hp_automute(codec);
1612 break;
1613 case ALC880_MIC_EVENT:
1614 alc880_uniwill_mic_automute(codec);
1615 break;
1616 }
1442} 1617}
1443 1618
1444static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1619static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1445{ 1620{
1446 unsigned int present; 1621 unsigned int present;
1622 unsigned char bits;
1447 1623
1448 present = snd_hda_codec_read(codec, 0x14, 0, 1624 present = snd_hda_codec_read(codec, 0x14, 0,
1449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1450 1626 bits = present ? 0x80 : 0;
1451 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, 1627 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1452 0x80, present ? 0x80 : 0); 1628 0x80, bits);
1453 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, 1629 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1454 0x80, present ? 0x80 : 0); 1630 0x80, bits);
1455} 1631}
1456 1632
1457static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1633static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1480,7 +1656,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1480 */ 1656 */
1481 if ((res >> 28) == ALC880_HP_EVENT) 1657 if ((res >> 28) == ALC880_HP_EVENT)
1482 alc880_uniwill_p53_hp_automute(codec); 1658 alc880_uniwill_p53_hp_automute(codec);
1483 if ((res >> 28) == ALC880_DCVOL_EVENT) 1659 if ((res >> 28) == ALC880_DCVOL_EVENT)
1484 alc880_uniwill_p53_dcvol_automute(codec); 1660 alc880_uniwill_p53_dcvol_automute(codec);
1485} 1661}
1486 1662
@@ -1547,22 +1723,8 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = {
1547}; 1723};
1548 1724
1549/* Enable GPIO mask and set output */ 1725/* Enable GPIO mask and set output */
1550static struct hda_verb alc880_gpio1_init_verbs[] = { 1726#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1551 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 1727#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1552 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1553 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1554
1555 { }
1556};
1557
1558/* Enable GPIO mask and set output */
1559static struct hda_verb alc880_gpio2_init_verbs[] = {
1560 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1561 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1562 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1563
1564 { }
1565};
1566 1728
1567/* Clevo m520g init */ 1729/* Clevo m520g init */
1568static struct hda_verb alc880_pin_clevo_init_verbs[] = { 1730static struct hda_verb alc880_pin_clevo_init_verbs[] = {
@@ -1734,13 +1896,15 @@ static struct hda_verb alc880_lg_init_verbs[] = {
1734static void alc880_lg_automute(struct hda_codec *codec) 1896static void alc880_lg_automute(struct hda_codec *codec)
1735{ 1897{
1736 unsigned int present; 1898 unsigned int present;
1899 unsigned char bits;
1737 1900
1738 present = snd_hda_codec_read(codec, 0x1b, 0, 1901 present = snd_hda_codec_read(codec, 0x1b, 0,
1739 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1903 bits = present ? 0x80 : 0;
1740 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1904 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1741 0x80, present ? 0x80 : 0); 1905 0x80, bits);
1742 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1906 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1743 0x80, present ? 0x80 : 0); 1907 0x80, bits);
1744} 1908}
1745 1909
1746static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1910static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1758,31 +1922,53 @@ static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1758 * Pin assignment: 1922 * Pin assignment:
1759 * Speaker-out: 0x14 1923 * Speaker-out: 0x14
1760 * Mic-In: 0x18 1924 * Mic-In: 0x18
1761 * Built-in Mic-In: 0x19 (?) 1925 * Built-in Mic-In: 0x19
1762 * HP-Out: 0x1b 1926 * Line-In: 0x1b
1927 * HP-Out: 0x1a
1763 * SPDIF-Out: 0x1e 1928 * SPDIF-Out: 0x1e
1764 */ 1929 */
1765 1930
1766/* seems analog CD is not working */
1767static struct hda_input_mux alc880_lg_lw_capture_source = { 1931static struct hda_input_mux alc880_lg_lw_capture_source = {
1768 .num_items = 2, 1932 .num_items = 3,
1769 .items = { 1933 .items = {
1770 { "Mic", 0x0 }, 1934 { "Mic", 0x0 },
1771 { "Internal Mic", 0x1 }, 1935 { "Internal Mic", 0x1 },
1936 { "Line In", 0x2 },
1772 }, 1937 },
1773}; 1938};
1774 1939
1940#define alc880_lg_lw_modes alc880_threestack_modes
1941
1775static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { 1942static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1776 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1777 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 1944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1780 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 1955 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1781 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 1956 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1957 {
1958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1959 .name = "Channel Mode",
1960 .info = alc_ch_mode_info,
1961 .get = alc_ch_mode_get,
1962 .put = alc_ch_mode_put,
1963 },
1782 { } /* end */ 1964 { } /* end */
1783}; 1965};
1784 1966
1785static struct hda_verb alc880_lg_lw_init_verbs[] = { 1967static struct hda_verb alc880_lg_lw_init_verbs[] = {
1968 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1969 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1970 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1971
1786 /* set capture source to mic-in */ 1972 /* set capture source to mic-in */
1787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -1792,7 +1978,6 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1794 /* HP-out */ 1980 /* HP-out */
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1798 /* mic-in to input */ 1983 /* mic-in to input */
@@ -1810,13 +1995,15 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1810static void alc880_lg_lw_automute(struct hda_codec *codec) 1995static void alc880_lg_lw_automute(struct hda_codec *codec)
1811{ 1996{
1812 unsigned int present; 1997 unsigned int present;
1998 unsigned char bits;
1813 1999
1814 present = snd_hda_codec_read(codec, 0x1b, 0, 2000 present = snd_hda_codec_read(codec, 0x1b, 0,
1815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2002 bits = present ? 0x80 : 0;
1816 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 2003 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1817 0x80, present ? 0x80 : 0); 2004 0x80, bits);
1818 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 2005 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1819 0x80, present ? 0x80 : 0); 2006 0x80, bits);
1820} 2007}
1821 2008
1822static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 2009static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1916,6 +2103,17 @@ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1916 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2103 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1917} 2104}
1918 2105
2106static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec,
2108 unsigned int stream_tag,
2109 unsigned int format,
2110 struct snd_pcm_substream *substream)
2111{
2112 struct alc_spec *spec = codec->spec;
2113 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2114 stream_tag, format, substream);
2115}
2116
1919static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2117static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1920 struct hda_codec *codec, 2118 struct hda_codec *codec,
1921 struct snd_pcm_substream *substream) 2119 struct snd_pcm_substream *substream)
@@ -1984,7 +2182,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
1984 /* NID is set in alc_build_pcms */ 2182 /* NID is set in alc_build_pcms */
1985 .ops = { 2183 .ops = {
1986 .open = alc880_dig_playback_pcm_open, 2184 .open = alc880_dig_playback_pcm_open,
1987 .close = alc880_dig_playback_pcm_close 2185 .close = alc880_dig_playback_pcm_close,
2186 .prepare = alc880_dig_playback_pcm_prepare
1988 }, 2187 },
1989}; 2188};
1990 2189
@@ -2075,7 +2274,7 @@ static void alc_free(struct hda_codec *codec)
2075 struct alc_spec *spec = codec->spec; 2274 struct alc_spec *spec = codec->spec;
2076 unsigned int i; 2275 unsigned int i;
2077 2276
2078 if (! spec) 2277 if (!spec)
2079 return; 2278 return;
2080 2279
2081 if (spec->kctl_alloc) { 2280 if (spec->kctl_alloc) {
@@ -2477,7 +2676,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2477static struct alc_config_preset alc880_presets[] = { 2676static struct alc_config_preset alc880_presets[] = {
2478 [ALC880_3ST] = { 2677 [ALC880_3ST] = {
2479 .mixers = { alc880_three_stack_mixer }, 2678 .mixers = { alc880_three_stack_mixer },
2480 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2679 .init_verbs = { alc880_volume_init_verbs,
2680 alc880_pin_3stack_init_verbs },
2481 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2482 .dac_nids = alc880_dac_nids, 2682 .dac_nids = alc880_dac_nids,
2483 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 2683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
@@ -2487,7 +2687,8 @@ static struct alc_config_preset alc880_presets[] = {
2487 }, 2687 },
2488 [ALC880_3ST_DIG] = { 2688 [ALC880_3ST_DIG] = {
2489 .mixers = { alc880_three_stack_mixer }, 2689 .mixers = { alc880_three_stack_mixer },
2490 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_3stack_init_verbs },
2491 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2692 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2492 .dac_nids = alc880_dac_nids, 2693 .dac_nids = alc880_dac_nids,
2493 .dig_out_nid = ALC880_DIGOUT_NID, 2694 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2509,8 +2710,10 @@ static struct alc_config_preset alc880_presets[] = {
2509 .input_mux = &alc880_capture_source, 2710 .input_mux = &alc880_capture_source,
2510 }, 2711 },
2511 [ALC880_5ST] = { 2712 [ALC880_5ST] = {
2512 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 2713 .mixers = { alc880_three_stack_mixer,
2513 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2714 alc880_five_stack_mixer},
2715 .init_verbs = { alc880_volume_init_verbs,
2716 alc880_pin_5stack_init_verbs },
2514 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2717 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2515 .dac_nids = alc880_dac_nids, 2718 .dac_nids = alc880_dac_nids,
2516 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 2719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
@@ -2518,8 +2721,10 @@ static struct alc_config_preset alc880_presets[] = {
2518 .input_mux = &alc880_capture_source, 2721 .input_mux = &alc880_capture_source,
2519 }, 2722 },
2520 [ALC880_5ST_DIG] = { 2723 [ALC880_5ST_DIG] = {
2521 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 2724 .mixers = { alc880_three_stack_mixer,
2522 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2725 alc880_five_stack_mixer },
2726 .init_verbs = { alc880_volume_init_verbs,
2727 alc880_pin_5stack_init_verbs },
2523 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2524 .dac_nids = alc880_dac_nids, 2729 .dac_nids = alc880_dac_nids,
2525 .dig_out_nid = ALC880_DIGOUT_NID, 2730 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2529,7 +2734,8 @@ static struct alc_config_preset alc880_presets[] = {
2529 }, 2734 },
2530 [ALC880_6ST] = { 2735 [ALC880_6ST] = {
2531 .mixers = { alc880_six_stack_mixer }, 2736 .mixers = { alc880_six_stack_mixer },
2532 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
2533 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2534 .dac_nids = alc880_6st_dac_nids, 2740 .dac_nids = alc880_6st_dac_nids,
2535 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 2741 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
@@ -2538,7 +2744,8 @@ static struct alc_config_preset alc880_presets[] = {
2538 }, 2744 },
2539 [ALC880_6ST_DIG] = { 2745 [ALC880_6ST_DIG] = {
2540 .mixers = { alc880_six_stack_mixer }, 2746 .mixers = { alc880_six_stack_mixer },
2541 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_6stack_init_verbs },
2542 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2749 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2543 .dac_nids = alc880_6st_dac_nids, 2750 .dac_nids = alc880_6st_dac_nids,
2544 .dig_out_nid = ALC880_DIGOUT_NID, 2751 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2548,7 +2755,8 @@ static struct alc_config_preset alc880_presets[] = {
2548 }, 2755 },
2549 [ALC880_W810] = { 2756 [ALC880_W810] = {
2550 .mixers = { alc880_w810_base_mixer }, 2757 .mixers = { alc880_w810_base_mixer },
2551 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 2758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_w810_init_verbs,
2552 alc880_gpio2_init_verbs }, 2760 alc880_gpio2_init_verbs },
2553 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 2761 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2554 .dac_nids = alc880_w810_dac_nids, 2762 .dac_nids = alc880_w810_dac_nids,
@@ -2559,7 +2767,8 @@ static struct alc_config_preset alc880_presets[] = {
2559 }, 2767 },
2560 [ALC880_Z71V] = { 2768 [ALC880_Z71V] = {
2561 .mixers = { alc880_z71v_mixer }, 2769 .mixers = { alc880_z71v_mixer },
2562 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 2770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_z71v_init_verbs },
2563 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 2772 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2564 .dac_nids = alc880_z71v_dac_nids, 2773 .dac_nids = alc880_z71v_dac_nids,
2565 .dig_out_nid = ALC880_DIGOUT_NID, 2774 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2570,7 +2779,8 @@ static struct alc_config_preset alc880_presets[] = {
2570 }, 2779 },
2571 [ALC880_F1734] = { 2780 [ALC880_F1734] = {
2572 .mixers = { alc880_f1734_mixer }, 2781 .mixers = { alc880_f1734_mixer },
2573 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 2782 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_pin_f1734_init_verbs },
2574 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 2784 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2575 .dac_nids = alc880_f1734_dac_nids, 2785 .dac_nids = alc880_f1734_dac_nids,
2576 .hp_nid = 0x02, 2786 .hp_nid = 0x02,
@@ -2580,7 +2790,8 @@ static struct alc_config_preset alc880_presets[] = {
2580 }, 2790 },
2581 [ALC880_ASUS] = { 2791 [ALC880_ASUS] = {
2582 .mixers = { alc880_asus_mixer }, 2792 .mixers = { alc880_asus_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
2584 alc880_gpio1_init_verbs }, 2795 alc880_gpio1_init_verbs },
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids, 2797 .dac_nids = alc880_asus_dac_nids,
@@ -2591,7 +2802,8 @@ static struct alc_config_preset alc880_presets[] = {
2591 }, 2802 },
2592 [ALC880_ASUS_DIG] = { 2803 [ALC880_ASUS_DIG] = {
2593 .mixers = { alc880_asus_mixer }, 2804 .mixers = { alc880_asus_mixer },
2594 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2805 .init_verbs = { alc880_volume_init_verbs,
2806 alc880_pin_asus_init_verbs,
2595 alc880_gpio1_init_verbs }, 2807 alc880_gpio1_init_verbs },
2596 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2808 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2597 .dac_nids = alc880_asus_dac_nids, 2809 .dac_nids = alc880_asus_dac_nids,
@@ -2603,7 +2815,8 @@ static struct alc_config_preset alc880_presets[] = {
2603 }, 2815 },
2604 [ALC880_ASUS_DIG2] = { 2816 [ALC880_ASUS_DIG2] = {
2605 .mixers = { alc880_asus_mixer }, 2817 .mixers = { alc880_asus_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2818 .init_verbs = { alc880_volume_init_verbs,
2819 alc880_pin_asus_init_verbs,
2607 alc880_gpio2_init_verbs }, /* use GPIO2 */ 2820 alc880_gpio2_init_verbs }, /* use GPIO2 */
2608 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2609 .dac_nids = alc880_asus_dac_nids, 2822 .dac_nids = alc880_asus_dac_nids,
@@ -2615,7 +2828,8 @@ static struct alc_config_preset alc880_presets[] = {
2615 }, 2828 },
2616 [ALC880_ASUS_W1V] = { 2829 [ALC880_ASUS_W1V] = {
2617 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 2830 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2618 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2831 .init_verbs = { alc880_volume_init_verbs,
2832 alc880_pin_asus_init_verbs,
2619 alc880_gpio1_init_verbs }, 2833 alc880_gpio1_init_verbs },
2620 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2621 .dac_nids = alc880_asus_dac_nids, 2835 .dac_nids = alc880_asus_dac_nids,
@@ -2664,7 +2878,7 @@ static struct alc_config_preset alc880_presets[] = {
2664 .init_hook = alc880_uniwill_p53_hp_automute, 2878 .init_hook = alc880_uniwill_p53_hp_automute,
2665 }, 2879 },
2666 [ALC880_FUJITSU] = { 2880 [ALC880_FUJITSU] = {
2667 .mixers = { alc880_fujitsu_mixer, 2881 .mixers = { alc880_fujitsu_mixer,
2668 alc880_pcbeep_mixer, }, 2882 alc880_pcbeep_mixer, },
2669 .init_verbs = { alc880_volume_init_verbs, 2883 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_uniwill_p53_init_verbs, 2884 alc880_uniwill_p53_init_verbs,
@@ -2707,11 +2921,11 @@ static struct alc_config_preset alc880_presets[] = {
2707 .mixers = { alc880_lg_lw_mixer }, 2921 .mixers = { alc880_lg_lw_mixer },
2708 .init_verbs = { alc880_volume_init_verbs, 2922 .init_verbs = { alc880_volume_init_verbs,
2709 alc880_lg_lw_init_verbs }, 2923 alc880_lg_lw_init_verbs },
2710 .num_dacs = 1, 2924 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2711 .dac_nids = alc880_dac_nids, 2925 .dac_nids = alc880_dac_nids,
2712 .dig_out_nid = ALC880_DIGOUT_NID, 2926 .dig_out_nid = ALC880_DIGOUT_NID,
2713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2927 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2714 .channel_mode = alc880_2_jack_modes, 2928 .channel_mode = alc880_lg_lw_modes,
2715 .input_mux = &alc880_lg_lw_capture_source, 2929 .input_mux = &alc880_lg_lw_capture_source,
2716 .unsol_event = alc880_lg_lw_unsol_event, 2930 .unsol_event = alc880_lg_lw_unsol_event,
2717 .init_hook = alc880_lg_lw_automute, 2931 .init_hook = alc880_lg_lw_automute,
@@ -2749,18 +2963,21 @@ static struct snd_kcontrol_new alc880_control_templates[] = {
2749}; 2963};
2750 2964
2751/* add dynamic controls */ 2965/* add dynamic controls */
2752static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 2966static int add_control(struct alc_spec *spec, int type, const char *name,
2967 unsigned long val)
2753{ 2968{
2754 struct snd_kcontrol_new *knew; 2969 struct snd_kcontrol_new *knew;
2755 2970
2756 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2971 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2757 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2972 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2758 2973
2759 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2974 /* array + terminator */
2760 if (! knew) 2975 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2976 if (!knew)
2761 return -ENOMEM; 2977 return -ENOMEM;
2762 if (spec->kctl_alloc) { 2978 if (spec->kctl_alloc) {
2763 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 2979 memcpy(knew, spec->kctl_alloc,
2980 sizeof(*knew) * spec->num_kctl_alloc);
2764 kfree(spec->kctl_alloc); 2981 kfree(spec->kctl_alloc);
2765 } 2982 }
2766 spec->kctl_alloc = knew; 2983 spec->kctl_alloc = knew;
@@ -2770,7 +2987,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2770 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2987 knew = &spec->kctl_alloc[spec->num_kctl_used];
2771 *knew = alc880_control_templates[type]; 2988 *knew = alc880_control_templates[type];
2772 knew->name = kstrdup(name, GFP_KERNEL); 2989 knew->name = kstrdup(name, GFP_KERNEL);
2773 if (! knew->name) 2990 if (!knew->name)
2774 return -ENOMEM; 2991 return -ENOMEM;
2775 knew->private_value = val; 2992 knew->private_value = val;
2776 spec->num_kctl_used++; 2993 spec->num_kctl_used++;
@@ -2790,7 +3007,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2790#define ALC880_PIN_CD_NID 0x1c 3007#define ALC880_PIN_CD_NID 0x1c
2791 3008
2792/* fill in the dac_nids table from the parsed pin configuration */ 3009/* fill in the dac_nids table from the parsed pin configuration */
2793static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 3010static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3011 const struct auto_pin_cfg *cfg)
2794{ 3012{
2795 hda_nid_t nid; 3013 hda_nid_t nid;
2796 int assigned[4]; 3014 int assigned[4];
@@ -2815,8 +3033,9 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
2815 continue; 3033 continue;
2816 /* search for an empty channel */ 3034 /* search for an empty channel */
2817 for (j = 0; j < cfg->line_outs; j++) { 3035 for (j = 0; j < cfg->line_outs; j++) {
2818 if (! assigned[j]) { 3036 if (!assigned[j]) {
2819 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 3037 spec->multiout.dac_nids[i] =
3038 alc880_idx_to_dac(j);
2820 assigned[j] = 1; 3039 assigned[j] = 1;
2821 break; 3040 break;
2822 } 3041 }
@@ -2831,36 +3050,54 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2831 const struct auto_pin_cfg *cfg) 3050 const struct auto_pin_cfg *cfg)
2832{ 3051{
2833 char name[32]; 3052 char name[32];
2834 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 3053 static const char *chname[4] = {
3054 "Front", "Surround", NULL /*CLFE*/, "Side"
3055 };
2835 hda_nid_t nid; 3056 hda_nid_t nid;
2836 int i, err; 3057 int i, err;
2837 3058
2838 for (i = 0; i < cfg->line_outs; i++) { 3059 for (i = 0; i < cfg->line_outs; i++) {
2839 if (! spec->multiout.dac_nids[i]) 3060 if (!spec->multiout.dac_nids[i])
2840 continue; 3061 continue;
2841 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 3062 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2842 if (i == 2) { 3063 if (i == 2) {
2843 /* Center/LFE */ 3064 /* Center/LFE */
2844 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 3065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2845 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 3066 "Center Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3068 HDA_OUTPUT));
3069 if (err < 0)
2846 return err; 3070 return err;
2847 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 3071 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2848 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3072 "LFE Playback Volume",
3073 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3074 HDA_OUTPUT));
3075 if (err < 0)
2849 return err; 3076 return err;
2850 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 3077 err = add_control(spec, ALC_CTL_BIND_MUTE,
2851 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 3078 "Center Playback Switch",
3079 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3080 HDA_INPUT));
3081 if (err < 0)
2852 return err; 3082 return err;
2853 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 3083 err = add_control(spec, ALC_CTL_BIND_MUTE,
2854 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 3084 "LFE Playback Switch",
3085 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3086 HDA_INPUT));
3087 if (err < 0)
2855 return err; 3088 return err;
2856 } else { 3089 } else {
2857 sprintf(name, "%s Playback Volume", chname[i]); 3090 sprintf(name, "%s Playback Volume", chname[i]);
2858 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3093 HDA_OUTPUT));
3094 if (err < 0)
2860 return err; 3095 return err;
2861 sprintf(name, "%s Playback Switch", chname[i]); 3096 sprintf(name, "%s Playback Switch", chname[i]);
2862 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3097 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2863 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3098 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3099 HDA_INPUT));
3100 if (err < 0)
2864 return err; 3101 return err;
2865 } 3102 }
2866 } 3103 }
@@ -2875,51 +3112,57 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2875 int err; 3112 int err;
2876 char name[32]; 3113 char name[32];
2877 3114
2878 if (! pin) 3115 if (!pin)
2879 return 0; 3116 return 0;
2880 3117
2881 if (alc880_is_fixed_pin(pin)) { 3118 if (alc880_is_fixed_pin(pin)) {
2882 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3119 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2883 /* specify the DAC as the extra output */ 3120 /* specify the DAC as the extra output */
2884 if (! spec->multiout.hp_nid) 3121 if (!spec->multiout.hp_nid)
2885 spec->multiout.hp_nid = nid; 3122 spec->multiout.hp_nid = nid;
2886 else 3123 else
2887 spec->multiout.extra_out_nid[0] = nid; 3124 spec->multiout.extra_out_nid[0] = nid;
2888 /* control HP volume/switch on the output mixer amp */ 3125 /* control HP volume/switch on the output mixer amp */
2889 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3126 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2890 sprintf(name, "%s Playback Volume", pfx); 3127 sprintf(name, "%s Playback Volume", pfx);
2891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3128 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3129 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3130 if (err < 0)
2893 return err; 3131 return err;
2894 sprintf(name, "%s Playback Switch", pfx); 3132 sprintf(name, "%s Playback Switch", pfx);
2895 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3133 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3134 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3135 if (err < 0)
2897 return err; 3136 return err;
2898 } else if (alc880_is_multi_pin(pin)) { 3137 } else if (alc880_is_multi_pin(pin)) {
2899 /* set manual connection */ 3138 /* set manual connection */
2900 /* we have only a switch on HP-out PIN */ 3139 /* we have only a switch on HP-out PIN */
2901 sprintf(name, "%s Playback Switch", pfx); 3140 sprintf(name, "%s Playback Switch", pfx);
2902 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3141 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 3142 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3143 if (err < 0)
2904 return err; 3144 return err;
2905 } 3145 }
2906 return 0; 3146 return 0;
2907} 3147}
2908 3148
2909/* create input playback/capture controls for the given pin */ 3149/* create input playback/capture controls for the given pin */
2910static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, 3150static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3151 const char *ctlname,
2911 int idx, hda_nid_t mix_nid) 3152 int idx, hda_nid_t mix_nid)
2912{ 3153{
2913 char name[32]; 3154 char name[32];
2914 int err; 3155 int err;
2915 3156
2916 sprintf(name, "%s Playback Volume", ctlname); 3157 sprintf(name, "%s Playback Volume", ctlname);
2917 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3158 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2918 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3160 if (err < 0)
2919 return err; 3161 return err;
2920 sprintf(name, "%s Playback Switch", ctlname); 3162 sprintf(name, "%s Playback Switch", ctlname);
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3163 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3164 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3165 if (err < 0)
2923 return err; 3166 return err;
2924 return 0; 3167 return 0;
2925} 3168}
@@ -2939,8 +3182,10 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2939 idx, 0x0b); 3182 idx, 0x0b);
2940 if (err < 0) 3183 if (err < 0)
2941 return err; 3184 return err;
2942 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3185 imux->items[imux->num_items].label =
2943 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 3186 auto_pin_cfg_labels[i];
3187 imux->items[imux->num_items].index =
3188 alc880_input_pin_idx(cfg->input_pins[i]);
2944 imux->num_items++; 3189 imux->num_items++;
2945 } 3190 }
2946 } 3191 }
@@ -2952,8 +3197,10 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2952 int dac_idx) 3197 int dac_idx)
2953{ 3198{
2954 /* set as output */ 3199 /* set as output */
2955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3201 pin_type);
3202 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3203 AMP_OUT_UNMUTE);
2957 /* need the manual connection? */ 3204 /* need the manual connection? */
2958 if (alc880_is_multi_pin(nid)) { 3205 if (alc880_is_multi_pin(nid)) {
2959 struct alc_spec *spec = codec->spec; 3206 struct alc_spec *spec = codec->spec;
@@ -2964,14 +3211,24 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2964 } 3211 }
2965} 3212}
2966 3213
3214static int get_pin_type(int line_out_type)
3215{
3216 if (line_out_type == AUTO_PIN_HP_OUT)
3217 return PIN_HP;
3218 else
3219 return PIN_OUT;
3220}
3221
2967static void alc880_auto_init_multi_out(struct hda_codec *codec) 3222static void alc880_auto_init_multi_out(struct hda_codec *codec)
2968{ 3223{
2969 struct alc_spec *spec = codec->spec; 3224 struct alc_spec *spec = codec->spec;
2970 int i; 3225 int i;
2971 3226
3227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
2972 for (i = 0; i < spec->autocfg.line_outs; i++) { 3228 for (i = 0; i < spec->autocfg.line_outs; i++) {
2973 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2974 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 3230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3231 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
2975 } 3232 }
2976} 3233}
2977 3234
@@ -2996,37 +3253,52 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
2996 for (i = 0; i < AUTO_PIN_LAST; i++) { 3253 for (i = 0; i < AUTO_PIN_LAST; i++) {
2997 hda_nid_t nid = spec->autocfg.input_pins[i]; 3254 hda_nid_t nid = spec->autocfg.input_pins[i];
2998 if (alc880_is_input_pin(nid)) { 3255 if (alc880_is_input_pin(nid)) {
2999 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3256 snd_hda_codec_write(codec, nid, 0,
3000 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3257 AC_VERB_SET_PIN_WIDGET_CONTROL,
3258 i <= AUTO_PIN_FRONT_MIC ?
3259 PIN_VREF80 : PIN_IN);
3001 if (nid != ALC880_PIN_CD_NID) 3260 if (nid != ALC880_PIN_CD_NID)
3002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3261 snd_hda_codec_write(codec, nid, 0,
3262 AC_VERB_SET_AMP_GAIN_MUTE,
3003 AMP_OUT_MUTE); 3263 AMP_OUT_MUTE);
3004 } 3264 }
3005 } 3265 }
3006} 3266}
3007 3267
3008/* parse the BIOS configuration and set up the alc_spec */ 3268/* parse the BIOS configuration and set up the alc_spec */
3009/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 3269/* return 1 if successful, 0 if the proper config is not found,
3270 * or a negative error code
3271 */
3010static int alc880_parse_auto_config(struct hda_codec *codec) 3272static int alc880_parse_auto_config(struct hda_codec *codec)
3011{ 3273{
3012 struct alc_spec *spec = codec->spec; 3274 struct alc_spec *spec = codec->spec;
3013 int err; 3275 int err;
3014 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3276 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3015 3277
3016 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3278 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3017 alc880_ignore)) < 0) 3279 alc880_ignore);
3280 if (err < 0)
3018 return err; 3281 return err;
3019 if (! spec->autocfg.line_outs) 3282 if (!spec->autocfg.line_outs)
3020 return 0; /* can't find valid BIOS pin config */ 3283 return 0; /* can't find valid BIOS pin config */
3021 3284
3022 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 3285 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3023 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3286 if (err < 0)
3024 (err = alc880_auto_create_extra_out(spec, 3287 return err;
3025 spec->autocfg.speaker_pins[0], 3288 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3026 "Speaker")) < 0 || 3289 if (err < 0)
3027 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3290 return err;
3028 "Headphone")) < 0 || 3291 err = alc880_auto_create_extra_out(spec,
3029 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3292 spec->autocfg.speaker_pins[0],
3293 "Speaker");
3294 if (err < 0)
3295 return err;
3296 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3297 "Headphone");
3298 if (err < 0)
3299 return err;
3300 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3301 if (err < 0)
3030 return err; 3302 return err;
3031 3303
3032 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3304 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -3086,7 +3358,7 @@ static int patch_alc880(struct hda_codec *codec)
3086 if (err < 0) { 3358 if (err < 0) {
3087 alc_free(codec); 3359 alc_free(codec);
3088 return err; 3360 return err;
3089 } else if (! err) { 3361 } else if (!err) {
3090 printk(KERN_INFO 3362 printk(KERN_INFO
3091 "hda_codec: Cannot set up configuration " 3363 "hda_codec: Cannot set up configuration "
3092 "from BIOS. Using 3-stack mode...\n"); 3364 "from BIOS. Using 3-stack mode...\n");
@@ -3105,14 +3377,16 @@ static int patch_alc880(struct hda_codec *codec)
3105 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3377 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3106 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3378 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3107 3379
3108 if (! spec->adc_nids && spec->input_mux) { 3380 if (!spec->adc_nids && spec->input_mux) {
3109 /* check whether NID 0x07 is valid */ 3381 /* check whether NID 0x07 is valid */
3110 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3382 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3383 /* get type */
3384 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3112 if (wcap != AC_WID_AUD_IN) { 3385 if (wcap != AC_WID_AUD_IN) {
3113 spec->adc_nids = alc880_adc_nids_alt; 3386 spec->adc_nids = alc880_adc_nids_alt;
3114 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3387 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3115 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 3388 spec->mixers[spec->num_mixers] =
3389 alc880_capture_alt_mixer;
3116 spec->num_mixers++; 3390 spec->num_mixers++;
3117 } else { 3391 } else {
3118 spec->adc_nids = alc880_adc_nids; 3392 spec->adc_nids = alc880_adc_nids;
@@ -3254,7 +3528,7 @@ static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3528 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3255 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3529 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3256 { } /* end */ 3530 { } /* end */
3257}; 3531};
3258 3532
3259static struct snd_kcontrol_new alc260_input_mixer[] = { 3533static struct snd_kcontrol_new alc260_input_mixer[] = {
3260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3534 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
@@ -3349,6 +3623,42 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
3349 { } /* end */ 3623 { } /* end */
3350}; 3624};
3351 3625
3626/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3627 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3628 */
3629static struct snd_kcontrol_new alc260_will_mixer[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3631 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3634 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3635 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3636 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3637 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3638 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3640 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3641 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3642 { } /* end */
3643};
3644
3645/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3646 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3647 */
3648static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3649 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3650 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3653 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3654 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3656 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3657 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3658 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3659 { } /* end */
3660};
3661
3352/* capture mixer elements */ 3662/* capture mixer elements */
3353static struct snd_kcontrol_new alc260_capture_mixer[] = { 3663static struct snd_kcontrol_new alc260_capture_mixer[] = {
3354 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 3664 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
@@ -3434,7 +3744,9 @@ static struct hda_verb alc260_init_verbs[] = {
3434 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3744 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* unmute LINE-2 out pin */ 3745 /* unmute LINE-2 out pin */
3436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3747 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3748 * Line In 2 = 0x03
3749 */
3438 /* mute CD */ 3750 /* mute CD */
3439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3440 /* mute Line In */ 3752 /* mute Line In */
@@ -3482,7 +3794,9 @@ static struct hda_verb alc260_hp_init_verbs[] = {
3482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3483 /* mute pin widget amp left and right (no gain on this amp) */ 3795 /* mute pin widget amp left and right (no gain on this amp) */
3484 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3796 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3485 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3797 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3798 * Line In 2 = 0x03
3799 */
3486 /* unmute CD */ 3800 /* unmute CD */
3487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3488 /* unmute Line In */ 3802 /* unmute Line In */
@@ -3530,7 +3844,9 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
3530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3531 /* mute pin widget amp left and right (no gain on this amp) */ 3845 /* mute pin widget amp left and right (no gain on this amp) */
3532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3533 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3847 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3848 * Line In 2 = 0x03
3849 */
3534 /* unmute CD */ 3850 /* unmute CD */
3535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3536 /* unmute Line In */ 3852 /* unmute Line In */
@@ -3680,7 +3996,9 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 3998
3683 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3999 /* Unmute Line-out pin widget amp left and right
4000 * (no equiv mixer ctrl)
4001 */
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3685 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 4003 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3686 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4004 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -3719,6 +4037,55 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3719 { } 4037 { }
3720}; 4038};
3721 4039
4040static struct hda_verb alc260_will_verbs[] = {
4041 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4042 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4044 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4045 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4046 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4047 {}
4048};
4049
4050static struct hda_verb alc260_replacer_672v_verbs[] = {
4051 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4052 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4053 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4054
4055 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4057 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4058
4059 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4060 {}
4061};
4062
4063/* toggle speaker-output according to the hp-jack state */
4064static void alc260_replacer_672v_automute(struct hda_codec *codec)
4065{
4066 unsigned int present;
4067
4068 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4069 present = snd_hda_codec_read(codec, 0x0f, 0,
4070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4071 if (present) {
4072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4075 } else {
4076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4077 snd_hda_codec_write(codec, 0x0f, 0,
4078 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4079 }
4080}
4081
4082static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4083 unsigned int res)
4084{
4085 if ((res >> 26) == ALC880_HP_EVENT)
4086 alc260_replacer_672v_automute(codec);
4087}
4088
3722/* Test configuration for debugging, modelled after the ALC880 test 4089/* Test configuration for debugging, modelled after the ALC880 test
3723 * configuration. 4090 * configuration.
3724 */ 4091 */
@@ -3946,10 +4313,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3946 return 0; /* N/A */ 4313 return 0; /* N/A */
3947 4314
3948 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4315 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3949 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 4316 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4317 if (err < 0)
3950 return err; 4318 return err;
3951 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4319 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3952 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 4320 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4321 if (err < 0)
3953 return err; 4322 return err;
3954 return 1; 4323 return 1;
3955} 4324}
@@ -3985,7 +4354,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3985 if (err < 0) 4354 if (err < 0)
3986 return err; 4355 return err;
3987 } 4356 }
3988 return 0; 4357 return 0;
3989} 4358}
3990 4359
3991/* create playback/capture controls for input pins */ 4360/* create playback/capture controls for input pins */
@@ -3999,20 +4368,24 @@ static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3999 if (cfg->input_pins[i] >= 0x12) { 4368 if (cfg->input_pins[i] >= 0x12) {
4000 idx = cfg->input_pins[i] - 0x12; 4369 idx = cfg->input_pins[i] - 0x12;
4001 err = new_analog_input(spec, cfg->input_pins[i], 4370 err = new_analog_input(spec, cfg->input_pins[i],
4002 auto_pin_cfg_labels[i], idx, 0x07); 4371 auto_pin_cfg_labels[i], idx,
4372 0x07);
4003 if (err < 0) 4373 if (err < 0)
4004 return err; 4374 return err;
4005 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4375 imux->items[imux->num_items].label =
4376 auto_pin_cfg_labels[i];
4006 imux->items[imux->num_items].index = idx; 4377 imux->items[imux->num_items].index = idx;
4007 imux->num_items++; 4378 imux->num_items++;
4008 } 4379 }
4009 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 4380 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4010 idx = cfg->input_pins[i] - 0x09; 4381 idx = cfg->input_pins[i] - 0x09;
4011 err = new_analog_input(spec, cfg->input_pins[i], 4382 err = new_analog_input(spec, cfg->input_pins[i],
4012 auto_pin_cfg_labels[i], idx, 0x07); 4383 auto_pin_cfg_labels[i], idx,
4384 0x07);
4013 if (err < 0) 4385 if (err < 0)
4014 return err; 4386 return err;
4015 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4387 imux->items[imux->num_items].label =
4388 auto_pin_cfg_labels[i];
4016 imux->items[imux->num_items].index = idx; 4389 imux->items[imux->num_items].index = idx;
4017 imux->num_items++; 4390 imux->num_items++;
4018 } 4391 }
@@ -4025,14 +4398,15 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4025 int sel_idx) 4398 int sel_idx)
4026{ 4399{
4027 /* set as output */ 4400 /* set as output */
4028 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 4402 pin_type);
4403 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4404 AMP_OUT_UNMUTE);
4030 /* need the manual connection? */ 4405 /* need the manual connection? */
4031 if (nid >= 0x12) { 4406 if (nid >= 0x12) {
4032 int idx = nid - 0x12; 4407 int idx = nid - 0x12;
4033 snd_hda_codec_write(codec, idx + 0x0b, 0, 4408 snd_hda_codec_write(codec, idx + 0x0b, 0,
4034 AC_VERB_SET_CONNECT_SEL, sel_idx); 4409 AC_VERB_SET_CONNECT_SEL, sel_idx);
4035
4036 } 4410 }
4037} 4411}
4038 4412
@@ -4041,9 +4415,12 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4041 struct alc_spec *spec = codec->spec; 4415 struct alc_spec *spec = codec->spec;
4042 hda_nid_t nid; 4416 hda_nid_t nid;
4043 4417
4044 nid = spec->autocfg.line_out_pins[0]; 4418 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4045 if (nid) 4419 nid = spec->autocfg.line_out_pins[0];
4046 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4420 if (nid) {
4421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4422 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4423 }
4047 4424
4048 nid = spec->autocfg.speaker_pins[0]; 4425 nid = spec->autocfg.speaker_pins[0];
4049 if (nid) 4426 if (nid)
@@ -4051,8 +4428,8 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4051 4428
4052 nid = spec->autocfg.hp_pins[0]; 4429 nid = spec->autocfg.hp_pins[0];
4053 if (nid) 4430 if (nid)
4054 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4431 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4055} 4432}
4056 4433
4057#define ALC260_PIN_CD_NID 0x16 4434#define ALC260_PIN_CD_NID 0x16
4058static void alc260_auto_init_analog_input(struct hda_codec *codec) 4435static void alc260_auto_init_analog_input(struct hda_codec *codec)
@@ -4063,10 +4440,13 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
4063 for (i = 0; i < AUTO_PIN_LAST; i++) { 4440 for (i = 0; i < AUTO_PIN_LAST; i++) {
4064 hda_nid_t nid = spec->autocfg.input_pins[i]; 4441 hda_nid_t nid = spec->autocfg.input_pins[i];
4065 if (nid >= 0x12) { 4442 if (nid >= 0x12) {
4066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4443 snd_hda_codec_write(codec, nid, 0,
4067 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4444 AC_VERB_SET_PIN_WIDGET_CONTROL,
4445 i <= AUTO_PIN_FRONT_MIC ?
4446 PIN_VREF80 : PIN_IN);
4068 if (nid != ALC260_PIN_CD_NID) 4447 if (nid != ALC260_PIN_CD_NID)
4069 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4448 snd_hda_codec_write(codec, nid, 0,
4449 AC_VERB_SET_AMP_GAIN_MUTE,
4070 AMP_OUT_MUTE); 4450 AMP_OUT_MUTE);
4071 } 4451 }
4072 } 4452 }
@@ -4086,8 +4466,8 @@ static struct hda_verb alc260_volume_init_verbs[] = {
4086 4466
4087 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4467 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4088 * mixer widget 4468 * mixer widget
4089 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4469 * Note: PASD motherboards uses the Line In 2 as the input for
4090 * mic (mic 2) 4470 * front panel mic (mic 2)
4091 */ 4471 */
4092 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4472 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4122,14 +4502,17 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4122 int err; 4502 int err;
4123 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4124 4504
4125 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4126 alc260_ignore)) < 0) 4506 alc260_ignore);
4507 if (err < 0)
4127 return err; 4508 return err;
4128 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 4509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4510 if (err < 0)
4129 return err; 4511 return err;
4130 if (! spec->kctl_alloc) 4512 if (!spec->kctl_alloc)
4131 return 0; /* can't find valid BIOS pin config */ 4513 return 0; /* can't find valid BIOS pin config */
4132 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4515 if (err < 0)
4133 return err; 4516 return err;
4134 4517
4135 spec->multiout.max_channels = 2; 4518 spec->multiout.max_channels = 2;
@@ -4177,6 +4560,8 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
4177 [ALC260_HP_3013] = "hp-3013", 4560 [ALC260_HP_3013] = "hp-3013",
4178 [ALC260_FUJITSU_S702X] = "fujitsu", 4561 [ALC260_FUJITSU_S702X] = "fujitsu",
4179 [ALC260_ACER] = "acer", 4562 [ALC260_ACER] = "acer",
4563 [ALC260_WILL] = "will",
4564 [ALC260_REPLACER_672V] = "replacer",
4180#ifdef CONFIG_SND_DEBUG 4565#ifdef CONFIG_SND_DEBUG
4181 [ALC260_TEST] = "test", 4566 [ALC260_TEST] = "test",
4182#endif 4567#endif
@@ -4200,6 +4585,8 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
4200 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 4585 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4201 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 4586 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4202 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 4587 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4588 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4589 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4203 {} 4590 {}
4204}; 4591};
4205 4592
@@ -4270,6 +4657,34 @@ static struct alc_config_preset alc260_presets[] = {
4270 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 4657 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4271 .input_mux = alc260_acer_capture_sources, 4658 .input_mux = alc260_acer_capture_sources,
4272 }, 4659 },
4660 [ALC260_WILL] = {
4661 .mixers = { alc260_will_mixer,
4662 alc260_capture_mixer },
4663 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4664 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4665 .dac_nids = alc260_dac_nids,
4666 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4667 .adc_nids = alc260_adc_nids,
4668 .dig_out_nid = ALC260_DIGOUT_NID,
4669 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4670 .channel_mode = alc260_modes,
4671 .input_mux = &alc260_capture_source,
4672 },
4673 [ALC260_REPLACER_672V] = {
4674 .mixers = { alc260_replacer_672v_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4678 .dac_nids = alc260_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4680 .adc_nids = alc260_adc_nids,
4681 .dig_out_nid = ALC260_DIGOUT_NID,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
4684 .input_mux = &alc260_capture_source,
4685 .unsol_event = alc260_replacer_672v_unsol_event,
4686 .init_hook = alc260_replacer_672v_automute,
4687 },
4273#ifdef CONFIG_SND_DEBUG 4688#ifdef CONFIG_SND_DEBUG
4274 [ALC260_TEST] = { 4689 [ALC260_TEST] = {
4275 .mixers = { alc260_test_mixer, 4690 .mixers = { alc260_test_mixer,
@@ -4313,7 +4728,7 @@ static int patch_alc260(struct hda_codec *codec)
4313 if (err < 0) { 4728 if (err < 0) {
4314 alc_free(codec); 4729 alc_free(codec);
4315 return err; 4730 return err;
4316 } else if (! err) { 4731 } else if (!err) {
4317 printk(KERN_INFO 4732 printk(KERN_INFO
4318 "hda_codec: Cannot set up configuration " 4733 "hda_codec: Cannot set up configuration "
4319 "from BIOS. Using base mode...\n"); 4734 "from BIOS. Using base mode...\n");
@@ -4382,7 +4797,8 @@ static struct hda_input_mux alc882_capture_source = {
4382#define alc882_mux_enum_info alc_mux_enum_info 4797#define alc882_mux_enum_info alc_mux_enum_info
4383#define alc882_mux_enum_get alc_mux_enum_get 4798#define alc882_mux_enum_get alc_mux_enum_get
4384 4799
4385static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 4800static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
4386{ 4802{
4387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4388 struct alc_spec *spec = codec->spec; 4804 struct alc_spec *spec = codec->spec;
@@ -4396,7 +4812,7 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4396 idx = ucontrol->value.enumerated.item[0]; 4812 idx = ucontrol->value.enumerated.item[0];
4397 if (idx >= imux->num_items) 4813 if (idx >= imux->num_items)
4398 idx = imux->num_items - 1; 4814 idx = imux->num_items - 1;
4399 if (*cur_val == idx && ! codec->in_resume) 4815 if (*cur_val == idx && !codec->in_resume)
4400 return 0; 4816 return 0;
4401 for (i = 0; i < imux->num_items; i++) { 4817 for (i = 0; i < imux->num_items; i++) {
4402 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 4818 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -4408,6 +4824,35 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4408} 4824}
4409 4825
4410/* 4826/*
4827 * 2ch mode
4828 */
4829static struct hda_verb alc882_3ST_ch2_init[] = {
4830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4834 { } /* end */
4835};
4836
4837/*
4838 * 6ch mode
4839 */
4840static struct hda_verb alc882_3ST_ch6_init[] = {
4841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4843 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4844 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4845 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4846 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4847 { } /* end */
4848};
4849
4850static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4851 { 2, alc882_3ST_ch2_init },
4852 { 6, alc882_3ST_ch6_init },
4853};
4854
4855/*
4411 * 6ch mode 4856 * 6ch mode
4412 */ 4857 */
4413static struct hda_verb alc882_sixstack_ch6_init[] = { 4858static struct hda_verb alc882_sixstack_ch6_init[] = {
@@ -4464,6 +4909,55 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
4464 { } /* end */ 4909 { } /* end */
4465}; 4910};
4466 4911
4912static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4923 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4924 { } /* end */
4925};
4926
4927static struct snd_kcontrol_new alc882_targa_mixer[] = {
4928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4939 { } /* end */
4940};
4941
4942/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4943 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4944 */
4945static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4958 { } /* end */
4959};
4960
4467static struct snd_kcontrol_new alc882_chmode_mixer[] = { 4961static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4468 { 4962 {
4469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -4559,7 +5053,7 @@ static struct hda_verb alc882_eapd_verbs[] = {
4559 /* change to EAPD mode */ 5053 /* change to EAPD mode */
4560 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 5054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4561 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 5055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4562 { } 5056 { }
4563}; 5057};
4564 5058
4565/* Mac Pro test */ 5059/* Mac Pro test */
@@ -4624,6 +5118,121 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
4624 5118
4625 { } 5119 { }
4626}; 5120};
5121
5122/* iMac 24 mixer. */
5123static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5125 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5126 { } /* end */
5127};
5128
5129/* iMac 24 init verbs. */
5130static struct hda_verb alc885_imac24_init_verbs[] = {
5131 /* Internal speakers: output 0 (0x0c) */
5132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5135 /* Internal speakers: output 0 (0x0c) */
5136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5139 /* Headphone: output 0 (0x0c) */
5140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5142 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5144 /* Front Mic: input vref at 80% */
5145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5147 { }
5148};
5149
5150/* Toggle speaker-output according to the hp-jack state */
5151static void alc885_imac24_automute(struct hda_codec *codec)
5152{
5153 unsigned int present;
5154
5155 present = snd_hda_codec_read(codec, 0x14, 0,
5156 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5157 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5158 0x80, present ? 0x80 : 0);
5159 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5160 0x80, present ? 0x80 : 0);
5161 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5162 0x80, present ? 0x80 : 0);
5163 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5164 0x80, present ? 0x80 : 0);
5165}
5166
5167/* Processes unsolicited events. */
5168static void alc885_imac24_unsol_event(struct hda_codec *codec,
5169 unsigned int res)
5170{
5171 /* Headphone insertion or removal. */
5172 if ((res >> 26) == ALC880_HP_EVENT)
5173 alc885_imac24_automute(codec);
5174}
5175
5176static struct hda_verb alc882_targa_verbs[] = {
5177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5179
5180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5182
5183 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5186
5187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5190 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5191 { } /* end */
5192};
5193
5194/* toggle speaker-output according to the hp-jack state */
5195static void alc882_targa_automute(struct hda_codec *codec)
5196{
5197 unsigned int present;
5198
5199 present = snd_hda_codec_read(codec, 0x14, 0,
5200 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5201 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5202 0x80, present ? 0x80 : 0);
5203 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5204 0x80, present ? 0x80 : 0);
5205 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5206}
5207
5208static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5209{
5210 /* Looks like the unsol event is incompatible with the standard
5211 * definition. 4bit tag is placed at 26 bit!
5212 */
5213 if (((res >> 26) == ALC880_HP_EVENT)) {
5214 alc882_targa_automute(codec);
5215 }
5216}
5217
5218static struct hda_verb alc882_asus_a7j_verbs[] = {
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221
5222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5225
5226 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5228 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5229
5230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5233 { } /* end */
5234};
5235
4627static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 5236static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4628{ 5237{
4629 unsigned int gpiostate, gpiomask, gpiodir; 5238 unsigned int gpiostate, gpiomask, gpiodir;
@@ -4672,8 +5281,8 @@ static struct hda_verb alc882_auto_init_verbs[] = {
4672 5281
4673 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4674 * mixer widget 5283 * mixer widget
4675 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5284 * Note: PASD motherboards uses the Line In 2 as the input for
4676 * mic (mic 2) 5285 * front panel mic (mic 2)
4677 */ 5286 */
4678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4782,7 +5391,9 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
4782 [ALC882_3ST_DIG] = "3stack-dig", 5391 [ALC882_3ST_DIG] = "3stack-dig",
4783 [ALC882_6ST_DIG] = "6stack-dig", 5392 [ALC882_6ST_DIG] = "6stack-dig",
4784 [ALC882_ARIMA] = "arima", 5393 [ALC882_ARIMA] = "arima",
5394 [ALC882_W2JC] = "w2jc",
4785 [ALC885_MACPRO] = "macpro", 5395 [ALC885_MACPRO] = "macpro",
5396 [ALC885_IMAC24] = "imac24",
4786 [ALC882_AUTO] = "auto", 5397 [ALC882_AUTO] = "auto",
4787}; 5398};
4788 5399
@@ -4790,8 +5401,12 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
4790 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), 5401 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4791 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), 5402 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4792 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 5403 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5404 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
4793 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 5405 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5407 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
4794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 5408 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
4795 {} 5410 {}
4796}; 5411};
4797 5412
@@ -4828,6 +5443,18 @@ static struct alc_config_preset alc882_presets[] = {
4828 .channel_mode = alc882_sixstack_modes, 5443 .channel_mode = alc882_sixstack_modes,
4829 .input_mux = &alc882_capture_source, 5444 .input_mux = &alc882_capture_source,
4830 }, 5445 },
5446 [ALC882_W2JC] = {
5447 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5448 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5449 alc880_gpio1_init_verbs },
5450 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5451 .dac_nids = alc882_dac_nids,
5452 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5453 .channel_mode = alc880_threestack_modes,
5454 .need_dac_fix = 1,
5455 .input_mux = &alc882_capture_source,
5456 .dig_out_nid = ALC882_DIGOUT_NID,
5457 },
4831 [ALC885_MACPRO] = { 5458 [ALC885_MACPRO] = {
4832 .mixers = { alc882_macpro_mixer }, 5459 .mixers = { alc882_macpro_mixer },
4833 .init_verbs = { alc882_macpro_init_verbs }, 5460 .init_verbs = { alc882_macpro_init_verbs },
@@ -4839,10 +5466,76 @@ static struct alc_config_preset alc882_presets[] = {
4839 .channel_mode = alc882_ch_modes, 5466 .channel_mode = alc882_ch_modes,
4840 .input_mux = &alc882_capture_source, 5467 .input_mux = &alc882_capture_source,
4841 }, 5468 },
5469 [ALC885_IMAC24] = {
5470 .mixers = { alc885_imac24_mixer },
5471 .init_verbs = { alc885_imac24_init_verbs },
5472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5473 .dac_nids = alc882_dac_nids,
5474 .dig_out_nid = ALC882_DIGOUT_NID,
5475 .dig_in_nid = ALC882_DIGIN_NID,
5476 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5477 .channel_mode = alc882_ch_modes,
5478 .input_mux = &alc882_capture_source,
5479 .unsol_event = alc885_imac24_unsol_event,
5480 .init_hook = alc885_imac24_automute,
5481 },
5482 [ALC882_TARGA] = {
5483 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5484 alc882_capture_mixer },
5485 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5486 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5487 .dac_nids = alc882_dac_nids,
5488 .dig_out_nid = ALC882_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5490 .adc_nids = alc882_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5492 .channel_mode = alc882_3ST_6ch_modes,
5493 .need_dac_fix = 1,
5494 .input_mux = &alc882_capture_source,
5495 .unsol_event = alc882_targa_unsol_event,
5496 .init_hook = alc882_targa_automute,
5497 },
5498 [ALC882_ASUS_A7J] = {
5499 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5500 alc882_capture_mixer },
5501 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5506 .adc_nids = alc882_adc_nids,
5507 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5508 .channel_mode = alc882_3ST_6ch_modes,
5509 .need_dac_fix = 1,
5510 .input_mux = &alc882_capture_source,
5511 },
4842}; 5512};
4843 5513
4844 5514
4845/* 5515/*
5516 * Pin config fixes
5517 */
5518enum {
5519 PINFIX_ABIT_AW9D_MAX
5520};
5521
5522static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5523 { 0x15, 0x01080104 }, /* side */
5524 { 0x16, 0x01011012 }, /* rear */
5525 { 0x17, 0x01016011 }, /* clfe */
5526 { }
5527};
5528
5529static const struct alc_pincfg *alc882_pin_fixes[] = {
5530 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5531};
5532
5533static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5534 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5535 {}
5536};
5537
5538/*
4846 * BIOS auto configuration 5539 * BIOS auto configuration
4847 */ 5540 */
4848static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 5541static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
@@ -4851,15 +5544,17 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4851{ 5544{
4852 /* set as output */ 5545 /* set as output */
4853 struct alc_spec *spec = codec->spec; 5546 struct alc_spec *spec = codec->spec;
4854 int idx; 5547 int idx;
4855 5548
4856 if (spec->multiout.dac_nids[dac_idx] == 0x25) 5549 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4857 idx = 4; 5550 idx = 4;
4858 else 5551 else
4859 idx = spec->multiout.dac_nids[dac_idx] - 2; 5552 idx = spec->multiout.dac_nids[dac_idx] - 2;
4860 5553
4861 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 5554 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4862 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 5555 pin_type);
5556 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5557 AMP_OUT_UNMUTE);
4863 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 5558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4864 5559
4865} 5560}
@@ -4869,10 +5564,13 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
4869 struct alc_spec *spec = codec->spec; 5564 struct alc_spec *spec = codec->spec;
4870 int i; 5565 int i;
4871 5566
5567 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4872 for (i = 0; i <= HDA_SIDE; i++) { 5568 for (i = 0; i <= HDA_SIDE; i++) {
4873 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 5569 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4874 if (nid) 5571 if (nid)
4875 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 5572 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5573 i);
4876 } 5574 }
4877} 5575}
4878 5576
@@ -4883,7 +5581,8 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
4883 5581
4884 pin = spec->autocfg.hp_pins[0]; 5582 pin = spec->autocfg.hp_pins[0];
4885 if (pin) /* connect to front */ 5583 if (pin) /* connect to front */
4886 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 5584 /* use dac 0 */
5585 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4887} 5586}
4888 5587
4889#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 5588#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -4897,10 +5596,13 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
4897 for (i = 0; i < AUTO_PIN_LAST; i++) { 5596 for (i = 0; i < AUTO_PIN_LAST; i++) {
4898 hda_nid_t nid = spec->autocfg.input_pins[i]; 5597 hda_nid_t nid = spec->autocfg.input_pins[i];
4899 if (alc882_is_input_pin(nid)) { 5598 if (alc882_is_input_pin(nid)) {
4900 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 5599 snd_hda_codec_write(codec, nid, 0,
4901 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 5600 AC_VERB_SET_PIN_WIDGET_CONTROL,
5601 i <= AUTO_PIN_FRONT_MIC ?
5602 PIN_VREF80 : PIN_IN);
4902 if (nid != ALC882_PIN_CD_NID) 5603 if (nid != ALC882_PIN_CD_NID)
4903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 5604 snd_hda_codec_write(codec, nid, 0,
5605 AC_VERB_SET_AMP_GAIN_MUTE,
4904 AMP_OUT_MUTE); 5606 AMP_OUT_MUTE);
4905 } 5607 }
4906 } 5608 }
@@ -4949,6 +5651,9 @@ static int patch_alc882(struct hda_codec *codec)
4949 case 0x106b0c00: /* Mac Pro */ 5651 case 0x106b0c00: /* Mac Pro */
4950 board_config = ALC885_MACPRO; 5652 board_config = ALC885_MACPRO;
4951 break; 5653 break;
5654 case 0x106b1000: /* iMac 24 */
5655 board_config = ALC885_IMAC24;
5656 break;
4952 default: 5657 default:
4953 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 5658 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4954 "trying auto-probe from BIOS...\n"); 5659 "trying auto-probe from BIOS...\n");
@@ -4956,13 +5661,15 @@ static int patch_alc882(struct hda_codec *codec)
4956 } 5661 }
4957 } 5662 }
4958 5663
5664 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5665
4959 if (board_config == ALC882_AUTO) { 5666 if (board_config == ALC882_AUTO) {
4960 /* automatic parse from the BIOS config */ 5667 /* automatic parse from the BIOS config */
4961 err = alc882_parse_auto_config(codec); 5668 err = alc882_parse_auto_config(codec);
4962 if (err < 0) { 5669 if (err < 0) {
4963 alc_free(codec); 5670 alc_free(codec);
4964 return err; 5671 return err;
4965 } else if (! err) { 5672 } else if (!err) {
4966 printk(KERN_INFO 5673 printk(KERN_INFO
4967 "hda_codec: Cannot set up configuration " 5674 "hda_codec: Cannot set up configuration "
4968 "from BIOS. Using base mode...\n"); 5675 "from BIOS. Using base mode...\n");
@@ -4973,7 +5680,7 @@ static int patch_alc882(struct hda_codec *codec)
4973 if (board_config != ALC882_AUTO) 5680 if (board_config != ALC882_AUTO)
4974 setup_preset(spec, &alc882_presets[board_config]); 5681 setup_preset(spec, &alc882_presets[board_config]);
4975 5682
4976 if (board_config == ALC885_MACPRO) { 5683 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
4977 alc882_gpio_mute(codec, 0, 0); 5684 alc882_gpio_mute(codec, 0, 0);
4978 alc882_gpio_mute(codec, 1, 0); 5685 alc882_gpio_mute(codec, 1, 0);
4979 } 5686 }
@@ -4986,14 +5693,16 @@ static int patch_alc882(struct hda_codec *codec)
4986 spec->stream_digital_playback = &alc882_pcm_digital_playback; 5693 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4987 spec->stream_digital_capture = &alc882_pcm_digital_capture; 5694 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4988 5695
4989 if (! spec->adc_nids && spec->input_mux) { 5696 if (!spec->adc_nids && spec->input_mux) {
4990 /* check whether NID 0x07 is valid */ 5697 /* check whether NID 0x07 is valid */
4991 unsigned int wcap = get_wcaps(codec, 0x07); 5698 unsigned int wcap = get_wcaps(codec, 0x07);
4992 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5699 /* get type */
5700 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4993 if (wcap != AC_WID_AUD_IN) { 5701 if (wcap != AC_WID_AUD_IN) {
4994 spec->adc_nids = alc882_adc_nids_alt; 5702 spec->adc_nids = alc882_adc_nids_alt;
4995 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 5703 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4996 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 5704 spec->mixers[spec->num_mixers] =
5705 alc882_capture_alt_mixer;
4997 spec->num_mixers++; 5706 spec->num_mixers++;
4998 } else { 5707 } else {
4999 spec->adc_nids = alc882_adc_nids; 5708 spec->adc_nids = alc882_adc_nids;
@@ -5033,6 +5742,7 @@ static hda_nid_t alc883_adc_nids[2] = {
5033 /* ADC1-2 */ 5742 /* ADC1-2 */
5034 0x08, 0x09, 5743 0x08, 0x09,
5035}; 5744};
5745
5036/* input MUX */ 5746/* input MUX */
5037/* FIXME: should be a matrix-type input source selection */ 5747/* FIXME: should be a matrix-type input source selection */
5038 5748
@@ -5045,6 +5755,25 @@ static struct hda_input_mux alc883_capture_source = {
5045 { "CD", 0x4 }, 5755 { "CD", 0x4 },
5046 }, 5756 },
5047}; 5757};
5758
5759static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5760 .num_items = 2,
5761 .items = {
5762 { "Mic", 0x1 },
5763 { "Line", 0x2 },
5764 },
5765};
5766
5767static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5768 .num_items = 4,
5769 .items = {
5770 { "Mic", 0x0 },
5771 { "iMic", 0x1 },
5772 { "Line", 0x2 },
5773 { "CD", 0x4 },
5774 },
5775};
5776
5048#define alc883_mux_enum_info alc_mux_enum_info 5777#define alc883_mux_enum_info alc_mux_enum_info
5049#define alc883_mux_enum_get alc_mux_enum_get 5778#define alc883_mux_enum_get alc_mux_enum_get
5050 5779
@@ -5063,7 +5792,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5063 idx = ucontrol->value.enumerated.item[0]; 5792 idx = ucontrol->value.enumerated.item[0];
5064 if (idx >= imux->num_items) 5793 if (idx >= imux->num_items)
5065 idx = imux->num_items - 1; 5794 idx = imux->num_items - 1;
5066 if (*cur_val == idx && ! codec->in_resume) 5795 if (*cur_val == idx && !codec->in_resume)
5067 return 0; 5796 return 0;
5068 for (i = 0; i < imux->num_items; i++) { 5797 for (i = 0; i < imux->num_items; i++) {
5069 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 5798 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -5073,6 +5802,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5073 *cur_val = idx; 5802 *cur_val = idx;
5074 return 1; 5803 return 1;
5075} 5804}
5805
5076/* 5806/*
5077 * 2ch mode 5807 * 2ch mode
5078 */ 5808 */
@@ -5325,7 +6055,7 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5325 .put = alc883_mux_enum_put, 6055 .put = alc883_mux_enum_put,
5326 }, 6056 },
5327 { } /* end */ 6057 { } /* end */
5328}; 6058};
5329 6059
5330static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 6060static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5350,8 +6080,161 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5350 .put = alc883_mux_enum_put, 6080 .put = alc883_mux_enum_put,
5351 }, 6081 },
5352 { } /* end */ 6082 { } /* end */
6083};
6084
6085static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6087 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6088 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6089 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6095 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6096 {
6097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6098 /* .name = "Capture Source", */
6099 .name = "Input Source",
6100 .count = 1,
6101 .info = alc883_mux_enum_info,
6102 .get = alc883_mux_enum_get,
6103 .put = alc883_mux_enum_put,
6104 },
6105 { } /* end */
6106};
6107
6108static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6116 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6117 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6122 {
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* .name = "Capture Source", */
6125 .name = "Input Source",
6126 .count = 2,
6127 .info = alc883_mux_enum_info,
6128 .get = alc883_mux_enum_get,
6129 .put = alc883_mux_enum_put,
6130 },
6131 { } /* end */
6132};
6133
6134static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6137 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6148 {
6149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6150 /* .name = "Capture Source", */
6151 .name = "Input Source",
6152 .count = 2,
6153 .info = alc883_mux_enum_info,
6154 .get = alc883_mux_enum_get,
6155 .put = alc883_mux_enum_put,
6156 },
6157 { } /* end */
5353}; 6158};
5354 6159
6160static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6164 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6170 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6182 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6183 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6188 {
6189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6190 /* .name = "Capture Source", */
6191 .name = "Input Source",
6192 .count = 2,
6193 .info = alc883_mux_enum_info,
6194 .get = alc883_mux_enum_get,
6195 .put = alc883_mux_enum_put,
6196 },
6197 { } /* end */
6198};
6199
6200static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6224 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6225 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6226 {
6227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6228 /* .name = "Capture Source", */
6229 .name = "Input Source",
6230 .count = 2,
6231 .info = alc883_mux_enum_info,
6232 .get = alc883_mux_enum_get,
6233 .put = alc883_mux_enum_put,
6234 },
6235 { } /* end */
6236};
6237
5355static struct snd_kcontrol_new alc883_chmode_mixer[] = { 6238static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5356 { 6239 {
5357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 6240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -5452,25 +6335,158 @@ static struct hda_verb alc883_tagra_verbs[] = {
5452 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6335 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5453 6336
5454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6337 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5455 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 6338 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5456 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 6339 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5457 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 6340 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5458 6341
5459 { } /* end */ 6342 { } /* end */
5460}; 6343};
5461 6344
6345static struct hda_verb alc883_lenovo_101e_verbs[] = {
6346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6349 { } /* end */
6350};
6351
6352static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6357 { } /* end */
6358};
6359
6360static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6366 { } /* end */
6367};
6368
6369static struct hda_verb alc888_6st_hp_verbs[] = {
6370 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6374 { }
6375};
6376
6377static struct hda_verb alc888_3st_hp_verbs[] = {
6378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6379 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6380 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6381 { }
6382};
6383
6384static struct hda_verb alc888_3st_hp_2ch_init[] = {
6385 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6386 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6387 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6388 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6389 { }
6390};
6391
6392static struct hda_verb alc888_3st_hp_6ch_init[] = {
6393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6397 { }
6398};
6399
6400static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6401 { 2, alc888_3st_hp_2ch_init },
6402 { 6, alc888_3st_hp_6ch_init },
6403};
6404
6405/* toggle front-jack and RCA according to the hp-jack state */
6406static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6407{
6408 unsigned int present;
6409
6410 present = snd_hda_codec_read(codec, 0x1b, 0,
6411 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6412 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6413 0x80, present ? 0x80 : 0);
6414 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6415 0x80, present ? 0x80 : 0);
6416 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6417 0x80, present ? 0x80 : 0);
6418 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6419 0x80, present ? 0x80 : 0);
6420
6421}
6422
6423/* toggle RCA according to the front-jack state */
6424static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6425{
6426 unsigned int present;
6427
6428 present = snd_hda_codec_read(codec, 0x14, 0,
6429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6430 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6433 0x80, present ? 0x80 : 0);
6434
6435}
6436static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6437 unsigned int res)
6438{
6439 if ((res >> 26) == ALC880_HP_EVENT)
6440 alc888_lenovo_ms7195_front_automute(codec);
6441 if ((res >> 26) == ALC880_FRONT_EVENT)
6442 alc888_lenovo_ms7195_rca_automute(codec);
6443}
6444
6445static struct hda_verb alc883_medion_md2_verbs[] = {
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6448
6449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6450
6451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6452 { } /* end */
6453};
6454
6455/* toggle speaker-output according to the hp-jack state */
6456static void alc883_medion_md2_automute(struct hda_codec *codec)
6457{
6458 unsigned int present;
6459
6460 present = snd_hda_codec_read(codec, 0x14, 0,
6461 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6462 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6463 0x80, present ? 0x80 : 0);
6464 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6465 0x80, present ? 0x80 : 0);
6466}
6467
6468static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6469 unsigned int res)
6470{
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc883_medion_md2_automute(codec);
6473}
6474
5462/* toggle speaker-output according to the hp-jack state */ 6475/* toggle speaker-output according to the hp-jack state */
5463static void alc883_tagra_automute(struct hda_codec *codec) 6476static void alc883_tagra_automute(struct hda_codec *codec)
5464{ 6477{
5465 unsigned int present; 6478 unsigned int present;
6479 unsigned char bits;
5466 6480
5467 present = snd_hda_codec_read(codec, 0x14, 0, 6481 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 6482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6483 bits = present ? 0x80 : 0;
5469 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 6484 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5470 0x80, present ? 0x80 : 0); 6485 0x80, bits);
5471 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 6486 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5472 0x80, present ? 0x80 : 0); 6487 0x80, bits);
5473 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); 6488 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6489 present ? 1 : 3);
5474} 6490}
5475 6491
5476static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 6492static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -5479,6 +6495,47 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5479 alc883_tagra_automute(codec); 6495 alc883_tagra_automute(codec);
5480} 6496}
5481 6497
6498static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6499{
6500 unsigned int present;
6501 unsigned char bits;
6502
6503 present = snd_hda_codec_read(codec, 0x14, 0,
6504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6505 bits = present ? 0x80 : 0;
6506 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6507 0x80, bits);
6508 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6509 0x80, bits);
6510}
6511
6512static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6513{
6514 unsigned int present;
6515 unsigned char bits;
6516
6517 present = snd_hda_codec_read(codec, 0x1b, 0,
6518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6519 bits = present ? 0x80 : 0;
6520 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6521 0x80, bits);
6522 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6523 0x80, bits);
6524 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6525 0x80, bits);
6526 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6527 0x80, bits);
6528}
6529
6530static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6531 unsigned int res)
6532{
6533 if ((res >> 26) == ALC880_HP_EVENT)
6534 alc883_lenovo_101e_all_automute(codec);
6535 if ((res >> 26) == ALC880_FRONT_EVENT)
6536 alc883_lenovo_101e_ispeaker_automute(codec);
6537}
6538
5482/* 6539/*
5483 * generic initialization of ADC, input mixers and output mixers 6540 * generic initialization of ADC, input mixers and output mixers
5484 */ 6541 */
@@ -5493,8 +6550,8 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5493 6550
5494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6551 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5495 * mixer widget 6552 * mixer widget
5496 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6553 * Note: PASD motherboards uses the Line In 2 as the input for
5497 * mic (mic 2) 6554 * front panel mic (mic 2)
5498 */ 6555 */
5499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5530,13 +6587,13 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5533 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6590 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5535 /* Input mixer2 */ 6592 /* Input mixer2 */
5536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5539 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5541 6598
5542 { } 6599 { }
@@ -5580,22 +6637,33 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
5580 [ALC883_6ST_DIG] = "6stack-dig", 6637 [ALC883_6ST_DIG] = "6stack-dig",
5581 [ALC883_TARGA_DIG] = "targa-dig", 6638 [ALC883_TARGA_DIG] = "targa-dig",
5582 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 6639 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5583 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5584 [ALC883_ACER] = "acer", 6640 [ALC883_ACER] = "acer",
5585 [ALC883_MEDION] = "medion", 6641 [ALC883_MEDION] = "medion",
6642 [ALC883_MEDION_MD2] = "medion-md2",
5586 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 6643 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6644 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6645 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6646 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6647 [ALC888_6ST_HP] = "6stack-hp",
6648 [ALC888_3ST_HP] = "3stack-hp",
5587 [ALC883_AUTO] = "auto", 6649 [ALC883_AUTO] = "auto",
5588}; 6650};
5589 6651
5590static struct snd_pci_quirk alc883_cfg_tbl[] = { 6652static struct snd_pci_quirk alc883_cfg_tbl[] = {
5591 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 6653 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6654 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
5592 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 6655 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5593 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 6656 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5594 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 6657 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6658 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
5595 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 6659 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5596 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 6660 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6661 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
5597 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 6662 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6663 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6664 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
5598 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 6665 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6666 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
5599 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 6667 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5600 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 6668 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5601 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), 6669 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
@@ -5606,9 +6674,17 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5606 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), 6674 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5607 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 6675 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5608 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), 6676 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6677 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
5609 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 6678 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5610 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 6679 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5611 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 6680 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6681 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6682 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6683 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6684 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6685 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6686 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6687 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
5612 {} 6688 {}
5613}; 6689};
5614 6690
@@ -5639,7 +6715,7 @@ static struct alc_config_preset alc883_presets[] = {
5639 .channel_mode = alc883_3ST_6ch_modes, 6715 .channel_mode = alc883_3ST_6ch_modes,
5640 .need_dac_fix = 1, 6716 .need_dac_fix = 1,
5641 .input_mux = &alc883_capture_source, 6717 .input_mux = &alc883_capture_source,
5642 }, 6718 },
5643 [ALC883_3ST_6ch] = { 6719 [ALC883_3ST_6ch] = {
5644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 6720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5645 .init_verbs = { alc883_init_verbs }, 6721 .init_verbs = { alc883_init_verbs },
@@ -5651,7 +6727,7 @@ static struct alc_config_preset alc883_presets[] = {
5651 .channel_mode = alc883_3ST_6ch_modes, 6727 .channel_mode = alc883_3ST_6ch_modes,
5652 .need_dac_fix = 1, 6728 .need_dac_fix = 1,
5653 .input_mux = &alc883_capture_source, 6729 .input_mux = &alc883_capture_source,
5654 }, 6730 },
5655 [ALC883_6ST_DIG] = { 6731 [ALC883_6ST_DIG] = {
5656 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 6732 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5657 .init_verbs = { alc883_init_verbs }, 6733 .init_verbs = { alc883_init_verbs },
@@ -5694,19 +6770,6 @@ static struct alc_config_preset alc883_presets[] = {
5694 .unsol_event = alc883_tagra_unsol_event, 6770 .unsol_event = alc883_tagra_unsol_event,
5695 .init_hook = alc883_tagra_automute, 6771 .init_hook = alc883_tagra_automute,
5696 }, 6772 },
5697 [ALC888_DEMO_BOARD] = {
5698 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5699 .init_verbs = { alc883_init_verbs },
5700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5701 .dac_nids = alc883_dac_nids,
5702 .dig_out_nid = ALC883_DIGOUT_NID,
5703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5704 .adc_nids = alc883_adc_nids,
5705 .dig_in_nid = ALC883_DIGIN_NID,
5706 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5707 .channel_mode = alc883_sixstack_modes,
5708 .input_mux = &alc883_capture_source,
5709 },
5710 [ALC883_ACER] = { 6773 [ALC883_ACER] = {
5711 .mixers = { alc883_base_mixer, 6774 .mixers = { alc883_base_mixer,
5712 alc883_chmode_mixer }, 6775 alc883_chmode_mixer },
@@ -5737,6 +6800,20 @@ static struct alc_config_preset alc883_presets[] = {
5737 .channel_mode = alc883_sixstack_modes, 6800 .channel_mode = alc883_sixstack_modes,
5738 .input_mux = &alc883_capture_source, 6801 .input_mux = &alc883_capture_source,
5739 }, 6802 },
6803 [ALC883_MEDION_MD2] = {
6804 .mixers = { alc883_medion_md2_mixer},
6805 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6807 .dac_nids = alc883_dac_nids,
6808 .dig_out_nid = ALC883_DIGOUT_NID,
6809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6810 .adc_nids = alc883_adc_nids,
6811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6812 .channel_mode = alc883_3ST_2ch_modes,
6813 .input_mux = &alc883_capture_source,
6814 .unsol_event = alc883_medion_md2_unsol_event,
6815 .init_hook = alc883_medion_md2_automute,
6816 },
5740 [ALC883_LAPTOP_EAPD] = { 6817 [ALC883_LAPTOP_EAPD] = {
5741 .mixers = { alc883_base_mixer, 6818 .mixers = { alc883_base_mixer,
5742 alc883_chmode_mixer }, 6819 alc883_chmode_mixer },
@@ -5749,6 +6826,73 @@ static struct alc_config_preset alc883_presets[] = {
5749 .channel_mode = alc883_3ST_2ch_modes, 6826 .channel_mode = alc883_3ST_2ch_modes,
5750 .input_mux = &alc883_capture_source, 6827 .input_mux = &alc883_capture_source,
5751 }, 6828 },
6829 [ALC883_LENOVO_101E_2ch] = {
6830 .mixers = { alc883_lenovo_101e_2ch_mixer},
6831 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6833 .dac_nids = alc883_dac_nids,
6834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6835 .adc_nids = alc883_adc_nids,
6836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6837 .channel_mode = alc883_3ST_2ch_modes,
6838 .input_mux = &alc883_lenovo_101e_capture_source,
6839 .unsol_event = alc883_lenovo_101e_unsol_event,
6840 .init_hook = alc883_lenovo_101e_all_automute,
6841 },
6842 [ALC883_LENOVO_NB0763] = {
6843 .mixers = { alc883_lenovo_nb0763_mixer },
6844 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6846 .dac_nids = alc883_dac_nids,
6847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6848 .adc_nids = alc883_adc_nids,
6849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6850 .channel_mode = alc883_3ST_2ch_modes,
6851 .need_dac_fix = 1,
6852 .input_mux = &alc883_lenovo_nb0763_capture_source,
6853 .unsol_event = alc883_medion_md2_unsol_event,
6854 .init_hook = alc883_medion_md2_automute,
6855 },
6856 [ALC888_LENOVO_MS7195_DIG] = {
6857 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6858 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6860 .dac_nids = alc883_dac_nids,
6861 .dig_out_nid = ALC883_DIGOUT_NID,
6862 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6863 .adc_nids = alc883_adc_nids,
6864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6865 .channel_mode = alc883_3ST_6ch_modes,
6866 .need_dac_fix = 1,
6867 .input_mux = &alc883_capture_source,
6868 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6869 .init_hook = alc888_lenovo_ms7195_front_automute,
6870 },
6871 [ALC888_6ST_HP] = {
6872 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6873 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
6874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6875 .dac_nids = alc883_dac_nids,
6876 .dig_out_nid = ALC883_DIGOUT_NID,
6877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6878 .adc_nids = alc883_adc_nids,
6879 .dig_in_nid = ALC883_DIGIN_NID,
6880 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6881 .channel_mode = alc883_sixstack_modes,
6882 .input_mux = &alc883_capture_source,
6883 },
6884 [ALC888_3ST_HP] = {
6885 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6886 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
6887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6888 .dac_nids = alc883_dac_nids,
6889 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6890 .adc_nids = alc883_adc_nids,
6891 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6892 .channel_mode = alc888_3st_hp_modes,
6893 .need_dac_fix = 1,
6894 .input_mux = &alc883_capture_source,
6895 },
5752}; 6896};
5753 6897
5754 6898
@@ -5761,8 +6905,8 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5761{ 6905{
5762 /* set as output */ 6906 /* set as output */
5763 struct alc_spec *spec = codec->spec; 6907 struct alc_spec *spec = codec->spec;
5764 int idx; 6908 int idx;
5765 6909
5766 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6910 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5767 idx = 4; 6911 idx = 4;
5768 else 6912 else
@@ -5781,10 +6925,13 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
5781 struct alc_spec *spec = codec->spec; 6925 struct alc_spec *spec = codec->spec;
5782 int i; 6926 int i;
5783 6927
6928 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5784 for (i = 0; i <= HDA_SIDE; i++) { 6929 for (i = 0; i <= HDA_SIDE; i++) {
5785 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6930 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6931 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5786 if (nid) 6932 if (nid)
5787 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 6933 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6934 i);
5788 } 6935 }
5789} 6936}
5790 6937
@@ -5833,8 +6980,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
5833 else if (err > 0) 6980 else if (err > 0)
5834 /* hack - override the init verbs */ 6981 /* hack - override the init verbs */
5835 spec->init_verbs[0] = alc883_auto_init_verbs; 6982 spec->init_verbs[0] = alc883_auto_init_verbs;
5836 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 6983 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5837 spec->num_mixers++; 6984 spec->num_mixers++;
5838 return err; 6985 return err;
5839} 6986}
5840 6987
@@ -5872,7 +7019,7 @@ static int patch_alc883(struct hda_codec *codec)
5872 if (err < 0) { 7019 if (err < 0) {
5873 alc_free(codec); 7020 alc_free(codec);
5874 return err; 7021 return err;
5875 } else if (! err) { 7022 } else if (!err) {
5876 printk(KERN_INFO 7023 printk(KERN_INFO
5877 "hda_codec: Cannot set up configuration " 7024 "hda_codec: Cannot set up configuration "
5878 "from BIOS. Using base mode...\n"); 7025 "from BIOS. Using base mode...\n");
@@ -5891,7 +7038,7 @@ static int patch_alc883(struct hda_codec *codec)
5891 spec->stream_digital_playback = &alc883_pcm_digital_playback; 7038 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5892 spec->stream_digital_capture = &alc883_pcm_digital_capture; 7039 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5893 7040
5894 if (! spec->adc_nids && spec->input_mux) { 7041 if (!spec->adc_nids && spec->input_mux) {
5895 spec->adc_nids = alc883_adc_nids; 7042 spec->adc_nids = alc883_adc_nids;
5896 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 7043 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5897 } 7044 }
@@ -6009,6 +7156,27 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6009 { } /* end */ 7156 { } /* end */
6010}; 7157};
6011 7158
7159static struct snd_kcontrol_new alc262_sony_mixer[] = {
7160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7165 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7166 { } /* end */
7167};
7168
7169static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7176 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7177 { } /* end */
7178};
7179
6012#define alc262_capture_mixer alc882_capture_mixer 7180#define alc262_capture_mixer alc882_capture_mixer
6013#define alc262_capture_alt_mixer alc882_capture_alt_mixer 7181#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6014 7182
@@ -6028,8 +7196,8 @@ static struct hda_verb alc262_init_verbs[] = {
6028 7196
6029 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7197 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6030 * mixer widget 7198 * mixer widget
6031 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7199 * Note: PASD motherboards uses the Line In 2 as the input for
6032 * mic (mic 2) 7200 * front panel mic (mic 2)
6033 */ 7201 */
6034 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6086,7 +7254,7 @@ static struct hda_verb alc262_init_verbs[] = {
6086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 7254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 7255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 7256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 7257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6090 7258
6091 { } 7259 { }
6092}; 7260};
@@ -6107,13 +7275,22 @@ static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6107 {} 7275 {}
6108}; 7276};
6109 7277
7278static struct hda_verb alc262_sony_unsol_verbs[] = {
7279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7280 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7282
7283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7285};
7286
6110/* mute/unmute internal speaker according to the hp jack and mute state */ 7287/* mute/unmute internal speaker according to the hp jack and mute state */
6111static void alc262_hippo_automute(struct hda_codec *codec, int force) 7288static void alc262_hippo_automute(struct hda_codec *codec, int force)
6112{ 7289{
6113 struct alc_spec *spec = codec->spec; 7290 struct alc_spec *spec = codec->spec;
6114 unsigned int mute; 7291 unsigned int mute;
6115 7292
6116 if (force || ! spec->sense_updated) { 7293 if (force || !spec->sense_updated) {
6117 unsigned int present; 7294 unsigned int present;
6118 /* need to execute and sync at first */ 7295 /* need to execute and sync at first */
6119 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 7296 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6153,7 +7330,7 @@ static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6153 struct alc_spec *spec = codec->spec; 7330 struct alc_spec *spec = codec->spec;
6154 unsigned int mute; 7331 unsigned int mute;
6155 7332
6156 if (force || ! spec->sense_updated) { 7333 if (force || !spec->sense_updated) {
6157 unsigned int present; 7334 unsigned int present;
6158 /* need to execute and sync at first */ 7335 /* need to execute and sync at first */
6159 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 7336 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6226,7 +7403,7 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6226 struct alc_spec *spec = codec->spec; 7403 struct alc_spec *spec = codec->spec;
6227 unsigned int mute; 7404 unsigned int mute;
6228 7405
6229 if (force || ! spec->sense_updated) { 7406 if (force || !spec->sense_updated) {
6230 unsigned int present; 7407 unsigned int present;
6231 /* need to execute and sync at first */ 7408 /* need to execute and sync at first */
6232 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 7409 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6330,8 +7507,18 @@ static struct hda_verb alc262_EAPD_verbs[] = {
6330 {} 7507 {}
6331}; 7508};
6332 7509
7510static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7513
7514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7515 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7516 {}
7517};
7518
6333/* add playback controls from the parsed DAC table */ 7519/* add playback controls from the parsed DAC table */
6334static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 7520static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7521 const struct auto_pin_cfg *cfg)
6335{ 7522{
6336 hda_nid_t nid; 7523 hda_nid_t nid;
6337 int err; 7524 int err;
@@ -6342,26 +7529,39 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6342 7529
6343 nid = cfg->line_out_pins[0]; 7530 nid = cfg->line_out_pins[0];
6344 if (nid) { 7531 if (nid) {
6345 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 7532 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6346 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 7533 "Front Playback Volume",
7534 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7535 if (err < 0)
6347 return err; 7536 return err;
6348 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 7537 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6349 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7538 "Front Playback Switch",
7539 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7540 if (err < 0)
6350 return err; 7541 return err;
6351 } 7542 }
6352 7543
6353 nid = cfg->speaker_pins[0]; 7544 nid = cfg->speaker_pins[0];
6354 if (nid) { 7545 if (nid) {
6355 if (nid == 0x16) { 7546 if (nid == 0x16) {
6356 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 7547 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6357 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 7548 "Speaker Playback Volume",
7549 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7550 HDA_OUTPUT));
7551 if (err < 0)
6358 return err; 7552 return err;
6359 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 7553 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6360 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 7554 "Speaker Playback Switch",
7555 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7556 HDA_OUTPUT));
7557 if (err < 0)
6361 return err; 7558 return err;
6362 } else { 7559 } else {
6363 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 7560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6364 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7561 "Speaker Playback Switch",
7562 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7563 HDA_OUTPUT));
7564 if (err < 0)
6365 return err; 7565 return err;
6366 } 7566 }
6367 } 7567 }
@@ -6369,23 +7569,33 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6369 if (nid) { 7569 if (nid) {
6370 /* spec->multiout.hp_nid = 2; */ 7570 /* spec->multiout.hp_nid = 2; */
6371 if (nid == 0x16) { 7571 if (nid == 0x16) {
6372 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 7572 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6373 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 7573 "Headphone Playback Volume",
7574 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7575 HDA_OUTPUT));
7576 if (err < 0)
6374 return err; 7577 return err;
6375 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 7578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6376 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 7579 "Headphone Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7581 HDA_OUTPUT));
7582 if (err < 0)
6377 return err; 7583 return err;
6378 } else { 7584 } else {
6379 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 7585 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6380 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 7586 "Headphone Playback Switch",
7587 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7588 HDA_OUTPUT));
7589 if (err < 0)
6381 return err; 7590 return err;
6382 } 7591 }
6383 } 7592 }
6384 return 0; 7593 return 0;
6385} 7594}
6386 7595
6387/* identical with ALC880 */ 7596/* identical with ALC880 */
6388#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 7597#define alc262_auto_create_analog_input_ctls \
7598 alc880_auto_create_analog_input_ctls
6389 7599
6390/* 7600/*
6391 * generic initialization of ADC, input mixers and output mixers 7601 * generic initialization of ADC, input mixers and output mixers
@@ -6403,8 +7613,8 @@ static struct hda_verb alc262_volume_init_verbs[] = {
6403 7613
6404 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7614 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6405 * mixer widget 7615 * mixer widget
6406 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7616 * Note: PASD motherboards uses the Line In 2 as the input for
6407 * mic (mic 2) 7617 * front panel mic (mic 2)
6408 */ 7618 */
6409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7619 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6464,8 +7674,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6464 7674
6465 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 7675 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6466 * mixer widget 7676 * mixer widget
6467 * Note: PASD motherboards uses the Line In 2 as the input for front panel 7677 * Note: PASD motherboards uses the Line In 2 as the input for
6468 * mic (mic 2) 7678 * front panel mic (mic 2)
6469 */ 7679 */
6470 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 7680 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6647,13 +7857,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
6647 int err; 7857 int err;
6648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 7858 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6649 7859
6650 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 7860 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6651 alc262_ignore)) < 0) 7861 alc262_ignore);
7862 if (err < 0)
6652 return err; 7863 return err;
6653 if (! spec->autocfg.line_outs) 7864 if (!spec->autocfg.line_outs)
6654 return 0; /* can't find valid BIOS pin config */ 7865 return 0; /* can't find valid BIOS pin config */
6655 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 7866 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
6656 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 7867 if (err < 0)
7868 return err;
7869 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7870 if (err < 0)
6657 return err; 7871 return err;
6658 7872
6659 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 7873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -6697,6 +7911,8 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
6697 [ALC262_HP_BPC] = "hp-bpc", 7911 [ALC262_HP_BPC] = "hp-bpc",
6698 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", 7912 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
6699 [ALC262_BENQ_ED8] = "benq", 7913 [ALC262_BENQ_ED8] = "benq",
7914 [ALC262_BENQ_T31] = "benq-t31",
7915 [ALC262_SONY_ASSAMD] = "sony-assamd",
6700 [ALC262_AUTO] = "auto", 7916 [ALC262_AUTO] = "auto",
6701}; 7917};
6702 7918
@@ -6704,8 +7920,12 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
6704 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 7920 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6705 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 7921 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6706 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), 7922 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7923 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7924 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
6707 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), 7925 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7926 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
6708 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), 7927 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7928 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
6709 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 7929 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
6710 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 7930 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
6711 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), 7931 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
@@ -6718,6 +7938,10 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
6718 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 7938 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
6719 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 7939 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
6720 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 7940 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7941 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
7942 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7943 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7944 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
6721 {} 7945 {}
6722}; 7946};
6723 7947
@@ -6777,7 +8001,7 @@ static struct alc_config_preset alc262_presets[] = {
6777 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6778 .channel_mode = alc262_modes, 8002 .channel_mode = alc262_modes,
6779 .input_mux = &alc262_HP_capture_source, 8003 .input_mux = &alc262_HP_capture_source,
6780 }, 8004 },
6781 [ALC262_HP_BPC_D7000_WF] = { 8005 [ALC262_HP_BPC_D7000_WF] = {
6782 .mixers = { alc262_HP_BPC_WildWest_mixer }, 8006 .mixers = { alc262_HP_BPC_WildWest_mixer },
6783 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 8007 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
@@ -6787,7 +8011,7 @@ static struct alc_config_preset alc262_presets[] = {
6787 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6788 .channel_mode = alc262_modes, 8012 .channel_mode = alc262_modes,
6789 .input_mux = &alc262_HP_capture_source, 8013 .input_mux = &alc262_HP_capture_source,
6790 }, 8014 },
6791 [ALC262_HP_BPC_D7000_WL] = { 8015 [ALC262_HP_BPC_D7000_WL] = {
6792 .mixers = { alc262_HP_BPC_WildWest_mixer, 8016 .mixers = { alc262_HP_BPC_WildWest_mixer,
6793 alc262_HP_BPC_WildWest_option_mixer }, 8017 alc262_HP_BPC_WildWest_option_mixer },
@@ -6798,7 +8022,7 @@ static struct alc_config_preset alc262_presets[] = {
6798 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6799 .channel_mode = alc262_modes, 8023 .channel_mode = alc262_modes,
6800 .input_mux = &alc262_HP_capture_source, 8024 .input_mux = &alc262_HP_capture_source,
6801 }, 8025 },
6802 [ALC262_BENQ_ED8] = { 8026 [ALC262_BENQ_ED8] = {
6803 .mixers = { alc262_base_mixer }, 8027 .mixers = { alc262_base_mixer },
6804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 8028 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -6808,7 +8032,29 @@ static struct alc_config_preset alc262_presets[] = {
6808 .num_channel_mode = ARRAY_SIZE(alc262_modes), 8032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6809 .channel_mode = alc262_modes, 8033 .channel_mode = alc262_modes,
6810 .input_mux = &alc262_capture_source, 8034 .input_mux = &alc262_capture_source,
6811 }, 8035 },
8036 [ALC262_SONY_ASSAMD] = {
8037 .mixers = { alc262_sony_mixer },
8038 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8039 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8040 .dac_nids = alc262_dac_nids,
8041 .hp_nid = 0x02,
8042 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8043 .channel_mode = alc262_modes,
8044 .input_mux = &alc262_capture_source,
8045 .unsol_event = alc262_hippo_unsol_event,
8046 },
8047 [ALC262_BENQ_T31] = {
8048 .mixers = { alc262_benq_t31_mixer },
8049 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8051 .dac_nids = alc262_dac_nids,
8052 .hp_nid = 0x03,
8053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8054 .channel_mode = alc262_modes,
8055 .input_mux = &alc262_capture_source,
8056 .unsol_event = alc262_hippo_unsol_event,
8057 },
6812}; 8058};
6813 8059
6814static int patch_alc262(struct hda_codec *codec) 8060static int patch_alc262(struct hda_codec *codec)
@@ -6823,7 +8069,9 @@ static int patch_alc262(struct hda_codec *codec)
6823 8069
6824 codec->spec = spec; 8070 codec->spec = spec;
6825#if 0 8071#if 0
6826 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 8072 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8073 * under-run
8074 */
6827 { 8075 {
6828 int tmp; 8076 int tmp;
6829 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 8077 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
@@ -6849,7 +8097,7 @@ static int patch_alc262(struct hda_codec *codec)
6849 if (err < 0) { 8097 if (err < 0) {
6850 alc_free(codec); 8098 alc_free(codec);
6851 return err; 8099 return err;
6852 } else if (! err) { 8100 } else if (!err) {
6853 printk(KERN_INFO 8101 printk(KERN_INFO
6854 "hda_codec: Cannot set up configuration " 8102 "hda_codec: Cannot set up configuration "
6855 "from BIOS. Using base mode...\n"); 8103 "from BIOS. Using base mode...\n");
@@ -6868,15 +8116,17 @@ static int patch_alc262(struct hda_codec *codec)
6868 spec->stream_digital_playback = &alc262_pcm_digital_playback; 8116 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6869 spec->stream_digital_capture = &alc262_pcm_digital_capture; 8117 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6870 8118
6871 if (! spec->adc_nids && spec->input_mux) { 8119 if (!spec->adc_nids && spec->input_mux) {
6872 /* check whether NID 0x07 is valid */ 8120 /* check whether NID 0x07 is valid */
6873 unsigned int wcap = get_wcaps(codec, 0x07); 8121 unsigned int wcap = get_wcaps(codec, 0x07);
6874 8122
6875 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 8123 /* get type */
8124 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6876 if (wcap != AC_WID_AUD_IN) { 8125 if (wcap != AC_WID_AUD_IN) {
6877 spec->adc_nids = alc262_adc_nids_alt; 8126 spec->adc_nids = alc262_adc_nids_alt;
6878 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 8127 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6879 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 8128 spec->mixers[spec->num_mixers] =
8129 alc262_capture_alt_mixer;
6880 spec->num_mixers++; 8130 spec->num_mixers++;
6881 } else { 8131 } else {
6882 spec->adc_nids = alc262_adc_nids; 8132 spec->adc_nids = alc262_adc_nids;
@@ -6894,6 +8144,515 @@ static int patch_alc262(struct hda_codec *codec)
6894} 8144}
6895 8145
6896/* 8146/*
8147 * ALC268 channel source setting (2 channel)
8148 */
8149#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8150#define alc268_modes alc260_modes
8151
8152static hda_nid_t alc268_dac_nids[2] = {
8153 /* front, hp */
8154 0x02, 0x03
8155};
8156
8157static hda_nid_t alc268_adc_nids[2] = {
8158 /* ADC0-1 */
8159 0x08, 0x07
8160};
8161
8162static hda_nid_t alc268_adc_nids_alt[1] = {
8163 /* ADC0 */
8164 0x08
8165};
8166
8167static struct snd_kcontrol_new alc268_base_mixer[] = {
8168 /* output mixer control */
8169 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8173 { }
8174};
8175
8176/*
8177 * generic initialization of ADC, input mixers and output mixers
8178 */
8179static struct hda_verb alc268_base_init_verbs[] = {
8180 /* Unmute DAC0-1 and set vol = 0 */
8181 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187
8188 /*
8189 * Set up output mixers (0x0c - 0x0e)
8190 */
8191 /* set vol=0 to output mixers */
8192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8196
8197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8199
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8208
8209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8217
8218 /* FIXME: use matrix-type input source selection */
8219 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8220 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8221 /* Input mixer2 */
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8226
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8231 { }
8232};
8233
8234/*
8235 * generic initialization of ADC, input mixers and output mixers
8236 */
8237static struct hda_verb alc268_volume_init_verbs[] = {
8238 /* set output DAC */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8243
8244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8249
8250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
8256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260
8261 /* set PCBEEP vol = 0 */
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8263
8264 { }
8265};
8266
8267#define alc268_mux_enum_info alc_mux_enum_info
8268#define alc268_mux_enum_get alc_mux_enum_get
8269
8270static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8271 struct snd_ctl_elem_value *ucontrol)
8272{
8273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8274 struct alc_spec *spec = codec->spec;
8275 const struct hda_input_mux *imux = spec->input_mux;
8276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8277 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8278 hda_nid_t nid = capture_mixers[adc_idx];
8279 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8280 unsigned int i, idx;
8281
8282 idx = ucontrol->value.enumerated.item[0];
8283 if (idx >= imux->num_items)
8284 idx = imux->num_items - 1;
8285 if (*cur_val == idx && !codec->in_resume)
8286 return 0;
8287 for (i = 0; i < imux->num_items; i++) {
8288 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8290 v | (imux->items[i].index << 8));
8291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8292 idx );
8293 }
8294 *cur_val = idx;
8295 return 1;
8296}
8297
8298static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8299 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8301 {
8302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8303 /* The multiple "Capture Source" controls confuse alsamixer
8304 * So call somewhat different..
8305 * FIXME: the controls appear in the "playback" view!
8306 */
8307 /* .name = "Capture Source", */
8308 .name = "Input Source",
8309 .count = 1,
8310 .info = alc268_mux_enum_info,
8311 .get = alc268_mux_enum_get,
8312 .put = alc268_mux_enum_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc268_capture_mixer[] = {
8318 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8320 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8321 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8322 {
8323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8324 /* The multiple "Capture Source" controls confuse alsamixer
8325 * So call somewhat different..
8326 * FIXME: the controls appear in the "playback" view!
8327 */
8328 /* .name = "Capture Source", */
8329 .name = "Input Source",
8330 .count = 2,
8331 .info = alc268_mux_enum_info,
8332 .get = alc268_mux_enum_get,
8333 .put = alc268_mux_enum_put,
8334 },
8335 { } /* end */
8336};
8337
8338static struct hda_input_mux alc268_capture_source = {
8339 .num_items = 4,
8340 .items = {
8341 { "Mic", 0x0 },
8342 { "Front Mic", 0x1 },
8343 { "Line", 0x2 },
8344 { "CD", 0x3 },
8345 },
8346};
8347
8348/* create input playback/capture controls for the given pin */
8349static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8350 const char *ctlname, int idx)
8351{
8352 char name[32];
8353 int err;
8354
8355 sprintf(name, "%s Playback Volume", ctlname);
8356 if (nid == 0x14) {
8357 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8358 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8359 HDA_OUTPUT));
8360 if (err < 0)
8361 return err;
8362 } else if (nid == 0x15) {
8363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8364 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8365 HDA_OUTPUT));
8366 if (err < 0)
8367 return err;
8368 } else
8369 return -1;
8370 sprintf(name, "%s Playback Switch", ctlname);
8371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8372 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8373 if (err < 0)
8374 return err;
8375 return 0;
8376}
8377
8378/* add playback controls from the parsed DAC table */
8379static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8380 const struct auto_pin_cfg *cfg)
8381{
8382 hda_nid_t nid;
8383 int err;
8384
8385 spec->multiout.num_dacs = 2; /* only use one dac */
8386 spec->multiout.dac_nids = spec->private_dac_nids;
8387 spec->multiout.dac_nids[0] = 2;
8388 spec->multiout.dac_nids[1] = 3;
8389
8390 nid = cfg->line_out_pins[0];
8391 if (nid)
8392 alc268_new_analog_output(spec, nid, "Front", 0);
8393
8394 nid = cfg->speaker_pins[0];
8395 if (nid == 0x1d) {
8396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8397 "Speaker Playback Volume",
8398 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8399 if (err < 0)
8400 return err;
8401 }
8402 nid = cfg->hp_pins[0];
8403 if (nid)
8404 alc268_new_analog_output(spec, nid, "Headphone", 0);
8405
8406 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8407 if (nid == 0x16) {
8408 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8409 "Mono Playback Switch",
8410 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8411 if (err < 0)
8412 return err;
8413 }
8414 return 0;
8415}
8416
8417/* create playback/capture controls for input pins */
8418static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8419 const struct auto_pin_cfg *cfg)
8420{
8421 struct hda_input_mux *imux = &spec->private_imux;
8422 int i, idx1;
8423
8424 for (i = 0; i < AUTO_PIN_LAST; i++) {
8425 switch(cfg->input_pins[i]) {
8426 case 0x18:
8427 idx1 = 0; /* Mic 1 */
8428 break;
8429 case 0x19:
8430 idx1 = 1; /* Mic 2 */
8431 break;
8432 case 0x1a:
8433 idx1 = 2; /* Line In */
8434 break;
8435 case 0x1c:
8436 idx1 = 3; /* CD */
8437 break;
8438 default:
8439 continue;
8440 }
8441 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8442 imux->items[imux->num_items].index = idx1;
8443 imux->num_items++;
8444 }
8445 return 0;
8446}
8447
8448static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8449{
8450 struct alc_spec *spec = codec->spec;
8451 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8452 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8453 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8454 unsigned int dac_vol1, dac_vol2;
8455
8456 if (speaker_nid) {
8457 snd_hda_codec_write(codec, speaker_nid, 0,
8458 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8459 snd_hda_codec_write(codec, 0x0f, 0,
8460 AC_VERB_SET_AMP_GAIN_MUTE,
8461 AMP_IN_UNMUTE(1));
8462 snd_hda_codec_write(codec, 0x10, 0,
8463 AC_VERB_SET_AMP_GAIN_MUTE,
8464 AMP_IN_UNMUTE(1));
8465 } else {
8466 snd_hda_codec_write(codec, 0x0f, 0,
8467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8468 snd_hda_codec_write(codec, 0x10, 0,
8469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8470 }
8471
8472 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8473 if (line_nid == 0x14)
8474 dac_vol2 = AMP_OUT_ZERO;
8475 else if (line_nid == 0x15)
8476 dac_vol1 = AMP_OUT_ZERO;
8477 if (hp_nid == 0x14)
8478 dac_vol2 = AMP_OUT_ZERO;
8479 else if (hp_nid == 0x15)
8480 dac_vol1 = AMP_OUT_ZERO;
8481 if (line_nid != 0x16 || hp_nid != 0x16 ||
8482 spec->autocfg.line_out_pins[1] != 0x16 ||
8483 spec->autocfg.line_out_pins[2] != 0x16)
8484 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8485
8486 snd_hda_codec_write(codec, 0x02, 0,
8487 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8488 snd_hda_codec_write(codec, 0x03, 0,
8489 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8490}
8491
8492/* pcm configuration: identiacal with ALC880 */
8493#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8494#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8495#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8496
8497/*
8498 * BIOS auto configuration
8499 */
8500static int alc268_parse_auto_config(struct hda_codec *codec)
8501{
8502 struct alc_spec *spec = codec->spec;
8503 int err;
8504 static hda_nid_t alc268_ignore[] = { 0 };
8505
8506 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8507 alc268_ignore);
8508 if (err < 0)
8509 return err;
8510 if (!spec->autocfg.line_outs)
8511 return 0; /* can't find valid BIOS pin config */
8512
8513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8514 if (err < 0)
8515 return err;
8516 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8517 if (err < 0)
8518 return err;
8519
8520 spec->multiout.max_channels = 2;
8521
8522 /* digital only support output */
8523 if (spec->autocfg.dig_out_pin)
8524 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8525
8526 if (spec->kctl_alloc)
8527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8528
8529 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8530 spec->num_mux_defs = 1;
8531 spec->input_mux = &spec->private_imux;
8532
8533 return 1;
8534}
8535
8536#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8537#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8538#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8539
8540/* init callback for auto-configuration model -- overriding the default init */
8541static void alc268_auto_init(struct hda_codec *codec)
8542{
8543 alc268_auto_init_multi_out(codec);
8544 alc268_auto_init_hp_out(codec);
8545 alc268_auto_init_mono_speaker_out(codec);
8546 alc268_auto_init_analog_input(codec);
8547}
8548
8549/*
8550 * configuration and preset
8551 */
8552static const char *alc268_models[ALC268_MODEL_LAST] = {
8553 [ALC268_3ST] = "3stack",
8554 [ALC268_AUTO] = "auto",
8555};
8556
8557static struct snd_pci_quirk alc268_cfg_tbl[] = {
8558 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8559 {}
8560};
8561
8562static struct alc_config_preset alc268_presets[] = {
8563 [ALC268_3ST] = {
8564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8565 .init_verbs = { alc268_base_init_verbs },
8566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8567 .dac_nids = alc268_dac_nids,
8568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8569 .adc_nids = alc268_adc_nids_alt,
8570 .hp_nid = 0x03,
8571 .dig_out_nid = ALC268_DIGOUT_NID,
8572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8573 .channel_mode = alc268_modes,
8574 .input_mux = &alc268_capture_source,
8575 },
8576};
8577
8578static int patch_alc268(struct hda_codec *codec)
8579{
8580 struct alc_spec *spec;
8581 int board_config;
8582 int err;
8583
8584 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8585 if (spec == NULL)
8586 return -ENOMEM;
8587
8588 codec->spec = spec;
8589
8590 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8591 alc268_models,
8592 alc268_cfg_tbl);
8593
8594 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8595 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8596 "trying auto-probe from BIOS...\n");
8597 board_config = ALC268_AUTO;
8598 }
8599
8600 if (board_config == ALC268_AUTO) {
8601 /* automatic parse from the BIOS config */
8602 err = alc268_parse_auto_config(codec);
8603 if (err < 0) {
8604 alc_free(codec);
8605 return err;
8606 } else if (!err) {
8607 printk(KERN_INFO
8608 "hda_codec: Cannot set up configuration "
8609 "from BIOS. Using base mode...\n");
8610 board_config = ALC268_3ST;
8611 }
8612 }
8613
8614 if (board_config != ALC268_AUTO)
8615 setup_preset(spec, &alc268_presets[board_config]);
8616
8617 spec->stream_name_analog = "ALC268 Analog";
8618 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8619 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8620
8621 spec->stream_name_digital = "ALC268 Digital";
8622 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8623
8624 if (board_config == ALC268_AUTO) {
8625 if (!spec->adc_nids && spec->input_mux) {
8626 /* check whether NID 0x07 is valid */
8627 unsigned int wcap = get_wcaps(codec, 0x07);
8628
8629 /* get type */
8630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8631 if (wcap != AC_WID_AUD_IN) {
8632 spec->adc_nids = alc268_adc_nids_alt;
8633 spec->num_adc_nids =
8634 ARRAY_SIZE(alc268_adc_nids_alt);
8635 spec->mixers[spec->num_mixers] =
8636 alc268_capture_alt_mixer;
8637 spec->num_mixers++;
8638 } else {
8639 spec->adc_nids = alc268_adc_nids;
8640 spec->num_adc_nids =
8641 ARRAY_SIZE(alc268_adc_nids);
8642 spec->mixers[spec->num_mixers] =
8643 alc268_capture_mixer;
8644 spec->num_mixers++;
8645 }
8646 }
8647 }
8648 codec->patch_ops = alc_patch_ops;
8649 if (board_config == ALC268_AUTO)
8650 spec->init_hook = alc268_auto_init;
8651
8652 return 0;
8653}
8654
8655/*
6897 * ALC861 channel source setting (2/6 channel selection for 3-stack) 8656 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6898 */ 8657 */
6899 8658
@@ -6904,7 +8663,9 @@ static int patch_alc262(struct hda_codec *codec)
6904static struct hda_verb alc861_threestack_ch2_init[] = { 8663static struct hda_verb alc861_threestack_ch2_init[] = {
6905 /* set pin widget 1Ah (line in) for input */ 8664 /* set pin widget 1Ah (line in) for input */
6906 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6907 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 8666 /* set pin widget 18h (mic1/2) for input, for mic also enable
8667 * the vref
8668 */
6908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 8669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6909 8670
6910 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 8671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -6961,7 +8722,9 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6961static struct hda_verb alc861_asus_ch2_init[] = { 8722static struct hda_verb alc861_asus_ch2_init[] = {
6962 /* set pin widget 1Ah (line in) for input */ 8723 /* set pin widget 1Ah (line in) for input */
6963 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 8724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6964 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 8725 /* set pin widget 18h (mic1/2) for input, for mic also enable
8726 * the vref
8727 */
6965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 8728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6966 8729
6967 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 8730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7016,7 +8779,7 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
7016 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7019 8782
7020 /* Capture mixer control */ 8783 /* Capture mixer control */
7021 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8784 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8785 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7050,7 +8813,7 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7050 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8813 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7053 8816
7054 /* Capture mixer control */ 8817 /* Capture mixer control */
7055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7092,7 +8855,7 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7092 }, 8855 },
7093 8856
7094 { } /* end */ 8857 { } /* end */
7095}; 8858};
7096 8859
7097static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 8860static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7098 /* output mixer control */ 8861 /* output mixer control */
@@ -7113,7 +8876,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7116 8879
7117 /* Capture mixer control */ 8880 /* Capture mixer control */
7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7134,7 +8897,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7134 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 8897 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7135 }, 8898 },
7136 { } /* end */ 8899 { } /* end */
7137}; 8900};
7138 8901
7139static struct snd_kcontrol_new alc861_asus_mixer[] = { 8902static struct snd_kcontrol_new alc861_asus_mixer[] = {
7140 /* output mixer control */ 8903 /* output mixer control */
@@ -7154,8 +8917,8 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 8917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7155 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 8918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 8919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */ 8920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
7158 8921
7159 /* Capture mixer control */ 8922 /* Capture mixer control */
7160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 8923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 8924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7239,7 +9002,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
7239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7243 9006
7244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9008 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7249,7 +9012,8 @@ static struct hda_verb alc861_base_init_verbs[] = {
7249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9015 /* hp used DAC 3 (Front) */
9016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7254 9018
7255 { } 9019 { }
@@ -7300,7 +9064,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7304 9068
7305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7310,7 +9074,8 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9077 /* hp used DAC 3 (Front) */
9078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 { } 9080 { }
7316}; 9081};
@@ -7329,7 +9094,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7329 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 9094 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7330 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9095 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7331 /* port-E for HP out (front panel) */ 9096 /* port-E for HP out (front panel) */
7332 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 9097 /* this has to be set to VREF80 */
9098 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7333 /* route front PCM to HP */ 9099 /* route front PCM to HP */
7334 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9100 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7335 /* port-F for mic-in (front panel) with vref */ 9101 /* port-F for mic-in (front panel) with vref */
@@ -7360,7 +9126,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 9129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7364 9130
7365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7370,7 +9136,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 9139 /* hp used DAC 3 (Front) */
9140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7375 { } 9142 { }
7376}; 9143};
@@ -7379,7 +9146,9 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7379 /* 9146 /*
7380 * Unmute ADC0 and set the default input to mic-in 9147 * Unmute ADC0 and set the default input to mic-in
7381 */ 9148 */
7382 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ 9149 /* port-A for surround (rear panel)
9150 * according to codec#0 this is the HP jack
9151 */
7383 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 9152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7384 /* route front PCM to HP */ 9153 /* route front PCM to HP */
7385 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 9154 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -7391,7 +9160,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 9160 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9161 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7393 /* port-E for HP out (front panel) */ 9162 /* port-E for HP out (front panel) */
7394 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ 9163 /* this has to be set to VREF80 */
9164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7395 /* route front PCM to HP */ 9165 /* route front PCM to HP */
7396 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 9166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7397 /* port-F for mic-in (front panel) with vref */ 9167 /* port-F for mic-in (front panel) with vref */
@@ -7421,7 +9191,7 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ 9194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7425 9195
7426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7431,7 +9201,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 9203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */ 9204 /* hp used DAC 3 (Front) */
9205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7436 { } 9207 { }
7437}; 9208};
@@ -7450,7 +9221,7 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7450 /* 9221 /*
7451 * Unmute ADC0 and set the default input to mic-in 9222 * Unmute ADC0 and set the default input to mic-in
7452 */ 9223 */
7453// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 9224 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
7454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 9225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7455 9226
7456 /* Unmute DAC0~3 & spdif out*/ 9227 /* Unmute DAC0~3 & spdif out*/
@@ -7483,21 +9254,21 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7483 9254
7484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 9259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 9260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 9261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 9262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7492 9263
7493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 9264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
7494 9265
7495 { } 9266 { }
7496}; 9267};
7497 9268
7498static struct hda_verb alc861_toshiba_init_verbs[] = { 9269static struct hda_verb alc861_toshiba_init_verbs[] = {
7499 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 9270 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7500 9271
7501 { } 9272 { }
7502}; 9273};
7503 9274
@@ -7521,9 +9292,6 @@ static void alc861_toshiba_automute(struct hda_codec *codec)
7521static void alc861_toshiba_unsol_event(struct hda_codec *codec, 9292static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7522 unsigned int res) 9293 unsigned int res)
7523{ 9294{
7524 /* Looks like the unsol event is incompatible with the standard
7525 * definition. 6bit tag is placed at 26 bit!
7526 */
7527 if ((res >> 26) == ALC880_HP_EVENT) 9295 if ((res >> 26) == ALC880_HP_EVENT)
7528 alc861_toshiba_automute(codec); 9296 alc861_toshiba_automute(codec);
7529} 9297}
@@ -7568,7 +9336,8 @@ static struct hda_input_mux alc861_capture_source = {
7568}; 9336};
7569 9337
7570/* fill in the dac_nids table from the parsed pin configuration */ 9338/* fill in the dac_nids table from the parsed pin configuration */
7571static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 9339static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9340 const struct auto_pin_cfg *cfg)
7572{ 9341{
7573 int i; 9342 int i;
7574 hda_nid_t nid; 9343 hda_nid_t nid;
@@ -7591,29 +9360,40 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7591 const struct auto_pin_cfg *cfg) 9360 const struct auto_pin_cfg *cfg)
7592{ 9361{
7593 char name[32]; 9362 char name[32];
7594 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 9363 static const char *chname[4] = {
9364 "Front", "Surround", NULL /*CLFE*/, "Side"
9365 };
7595 hda_nid_t nid; 9366 hda_nid_t nid;
7596 int i, idx, err; 9367 int i, idx, err;
7597 9368
7598 for (i = 0; i < cfg->line_outs; i++) { 9369 for (i = 0; i < cfg->line_outs; i++) {
7599 nid = spec->multiout.dac_nids[i]; 9370 nid = spec->multiout.dac_nids[i];
7600 if (! nid) 9371 if (!nid)
7601 continue; 9372 continue;
7602 if (nid == 0x05) { 9373 if (nid == 0x05) {
7603 /* Center/LFE */ 9374 /* Center/LFE */
7604 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 9375 err = add_control(spec, ALC_CTL_BIND_MUTE,
7605 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 9376 "Center Playback Switch",
9377 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9378 HDA_OUTPUT));
9379 if (err < 0)
7606 return err; 9380 return err;
7607 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 9381 err = add_control(spec, ALC_CTL_BIND_MUTE,
7608 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 9382 "LFE Playback Switch",
9383 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9384 HDA_OUTPUT));
9385 if (err < 0)
7609 return err; 9386 return err;
7610 } else { 9387 } else {
7611 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 9388 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9389 idx++)
7612 if (nid == alc861_dac_nids[idx]) 9390 if (nid == alc861_dac_nids[idx])
7613 break; 9391 break;
7614 sprintf(name, "%s Playback Switch", chname[idx]); 9392 sprintf(name, "%s Playback Switch", chname[idx]);
7615 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 9394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9395 HDA_OUTPUT));
9396 if (err < 0)
7617 return err; 9397 return err;
7618 } 9398 }
7619 } 9399 }
@@ -7625,13 +9405,15 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7625 int err; 9405 int err;
7626 hda_nid_t nid; 9406 hda_nid_t nid;
7627 9407
7628 if (! pin) 9408 if (!pin)
7629 return 0; 9409 return 0;
7630 9410
7631 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 9411 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7632 nid = 0x03; 9412 nid = 0x03;
7633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 9413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7634 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9416 if (err < 0)
7635 return err; 9417 return err;
7636 spec->multiout.hp_nid = nid; 9418 spec->multiout.hp_nid = nid;
7637 } 9419 }
@@ -7639,32 +9421,33 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7639} 9421}
7640 9422
7641/* create playback/capture controls for input pins */ 9423/* create playback/capture controls for input pins */
7642static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 9424static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9425 const struct auto_pin_cfg *cfg)
7643{ 9426{
7644 struct hda_input_mux *imux = &spec->private_imux; 9427 struct hda_input_mux *imux = &spec->private_imux;
7645 int i, err, idx, idx1; 9428 int i, err, idx, idx1;
7646 9429
7647 for (i = 0; i < AUTO_PIN_LAST; i++) { 9430 for (i = 0; i < AUTO_PIN_LAST; i++) {
7648 switch(cfg->input_pins[i]) { 9431 switch (cfg->input_pins[i]) {
7649 case 0x0c: 9432 case 0x0c:
7650 idx1 = 1; 9433 idx1 = 1;
7651 idx = 2; // Line In 9434 idx = 2; /* Line In */
7652 break; 9435 break;
7653 case 0x0f: 9436 case 0x0f:
7654 idx1 = 2; 9437 idx1 = 2;
7655 idx = 2; // Line In 9438 idx = 2; /* Line In */
7656 break; 9439 break;
7657 case 0x0d: 9440 case 0x0d:
7658 idx1 = 0; 9441 idx1 = 0;
7659 idx = 1; // Mic In 9442 idx = 1; /* Mic In */
7660 break; 9443 break;
7661 case 0x10: 9444 case 0x10:
7662 idx1 = 3; 9445 idx1 = 3;
7663 idx = 1; // Mic In 9446 idx = 1; /* Mic In */
7664 break; 9447 break;
7665 case 0x11: 9448 case 0x11:
7666 idx1 = 4; 9449 idx1 = 4;
7667 idx = 0; // CD 9450 idx = 0; /* CD */
7668 break; 9451 break;
7669 default: 9452 default:
7670 continue; 9453 continue;
@@ -7677,7 +9460,7 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
7677 9460
7678 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 9461 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7679 imux->items[imux->num_items].index = idx1; 9462 imux->items[imux->num_items].index = idx1;
7680 imux->num_items++; 9463 imux->num_items++;
7681 } 9464 }
7682 return 0; 9465 return 0;
7683} 9466}
@@ -7702,13 +9485,16 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
7702 { } /* end */ 9485 { } /* end */
7703}; 9486};
7704 9487
7705static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 9488static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9489 hda_nid_t nid,
7706 int pin_type, int dac_idx) 9490 int pin_type, int dac_idx)
7707{ 9491{
7708 /* set as output */ 9492 /* set as output */
7709 9493
7710 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 9494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7711 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 9495 pin_type);
9496 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9497 AMP_OUT_UNMUTE);
7712 9498
7713} 9499}
7714 9500
@@ -7717,10 +9503,13 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
7717 struct alc_spec *spec = codec->spec; 9503 struct alc_spec *spec = codec->spec;
7718 int i; 9504 int i;
7719 9505
9506 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
7720 for (i = 0; i < spec->autocfg.line_outs; i++) { 9507 for (i = 0; i < spec->autocfg.line_outs; i++) {
7721 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7722 if (nid) 9510 if (nid)
7723 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 9511 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9512 spec->multiout.dac_nids[i]);
7724 } 9513 }
7725} 9514}
7726 9515
@@ -7731,7 +9520,8 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
7731 9520
7732 pin = spec->autocfg.hp_pins[0]; 9521 pin = spec->autocfg.hp_pins[0];
7733 if (pin) /* connect to front */ 9522 if (pin) /* connect to front */
7734 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 9523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9524 spec->multiout.dac_nids[0]);
7735} 9525}
7736 9526
7737static void alc861_auto_init_analog_input(struct hda_codec *codec) 9527static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -7741,31 +9531,43 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
7741 9531
7742 for (i = 0; i < AUTO_PIN_LAST; i++) { 9532 for (i = 0; i < AUTO_PIN_LAST; i++) {
7743 hda_nid_t nid = spec->autocfg.input_pins[i]; 9533 hda_nid_t nid = spec->autocfg.input_pins[i];
7744 if ((nid>=0x0c) && (nid <=0x11)) { 9534 if (nid >= 0x0c && nid <= 0x11) {
7745 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 9535 snd_hda_codec_write(codec, nid, 0,
7746 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 9536 AC_VERB_SET_PIN_WIDGET_CONTROL,
9537 i <= AUTO_PIN_FRONT_MIC ?
9538 PIN_VREF80 : PIN_IN);
7747 } 9539 }
7748 } 9540 }
7749} 9541}
7750 9542
7751/* parse the BIOS configuration and set up the alc_spec */ 9543/* parse the BIOS configuration and set up the alc_spec */
7752/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 9544/* return 1 if successful, 0 if the proper config is not found,
9545 * or a negative error code
9546 */
7753static int alc861_parse_auto_config(struct hda_codec *codec) 9547static int alc861_parse_auto_config(struct hda_codec *codec)
7754{ 9548{
7755 struct alc_spec *spec = codec->spec; 9549 struct alc_spec *spec = codec->spec;
7756 int err; 9550 int err;
7757 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 9551 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7758 9552
7759 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7760 alc861_ignore)) < 0) 9554 alc861_ignore);
9555 if (err < 0)
7761 return err; 9556 return err;
7762 if (! spec->autocfg.line_outs) 9557 if (!spec->autocfg.line_outs)
7763 return 0; /* can't find valid BIOS pin config */ 9558 return 0; /* can't find valid BIOS pin config */
7764 9559
7765 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9560 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
7766 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 9561 if (err < 0)
7767 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || 9562 return err;
7768 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 9563 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9564 if (err < 0)
9565 return err;
9566 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9567 if (err < 0)
9568 return err;
9569 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9570 if (err < 0)
7769 return err; 9571 return err;
7770 9572
7771 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9573 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -7817,13 +9619,22 @@ static struct snd_pci_quirk alc861_cfg_tbl[] = {
7817 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 9619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
7818 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 9620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7819 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 9621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9622 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9623 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
7820 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 9624 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7821 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), 9625 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
7822 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 9626 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
7823 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), 9627 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9628 * Any other models that need this preset?
9629 */
9630 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
7824 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 9631 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9632 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
7825 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 9633 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9634 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
7826 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 9635 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9636 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9637 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
7827 {} 9638 {}
7828}; 9639};
7829 9640
@@ -7892,7 +9703,8 @@ static struct alc_config_preset alc861_presets[] = {
7892 }, 9703 },
7893 [ALC861_TOSHIBA] = { 9704 [ALC861_TOSHIBA] = {
7894 .mixers = { alc861_toshiba_mixer }, 9705 .mixers = { alc861_toshiba_mixer },
7895 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, 9706 .init_verbs = { alc861_base_init_verbs,
9707 alc861_toshiba_init_verbs },
7896 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 9708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7897 .dac_nids = alc861_dac_nids, 9709 .dac_nids = alc861_dac_nids,
7898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
@@ -7944,7 +9756,7 @@ static int patch_alc861(struct hda_codec *codec)
7944 if (spec == NULL) 9756 if (spec == NULL)
7945 return -ENOMEM; 9757 return -ENOMEM;
7946 9758
7947 codec->spec = spec; 9759 codec->spec = spec;
7948 9760
7949 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 9761 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7950 alc861_models, 9762 alc861_models,
@@ -7962,7 +9774,7 @@ static int patch_alc861(struct hda_codec *codec)
7962 if (err < 0) { 9774 if (err < 0) {
7963 alc_free(codec); 9775 alc_free(codec);
7964 return err; 9776 return err;
7965 } else if (! err) { 9777 } else if (!err) {
7966 printk(KERN_INFO 9778 printk(KERN_INFO
7967 "hda_codec: Cannot set up configuration " 9779 "hda_codec: Cannot set up configuration "
7968 "from BIOS. Using base mode...\n"); 9780 "from BIOS. Using base mode...\n");
@@ -8031,6 +9843,15 @@ static struct hda_input_mux alc861vd_capture_source = {
8031 }, 9843 },
8032}; 9844};
8033 9845
9846static struct hda_input_mux alc861vd_dallas_capture_source = {
9847 .num_items = 3,
9848 .items = {
9849 { "Front Mic", 0x0 },
9850 { "ATAPI Mic", 0x1 },
9851 { "Line In", 0x5 },
9852 },
9853};
9854
8034#define alc861vd_mux_enum_info alc_mux_enum_info 9855#define alc861vd_mux_enum_info alc_mux_enum_info
8035#define alc861vd_mux_enum_get alc_mux_enum_get 9856#define alc861vd_mux_enum_get alc_mux_enum_get
8036 9857
@@ -8049,7 +9870,7 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8049 idx = ucontrol->value.enumerated.item[0]; 9870 idx = ucontrol->value.enumerated.item[0];
8050 if (idx >= imux->num_items) 9871 if (idx >= imux->num_items)
8051 idx = imux->num_items - 1; 9872 idx = imux->num_items - 1;
8052 if (*cur_val == idx && ! codec->in_resume) 9873 if (*cur_val == idx && !codec->in_resume)
8053 return 0; 9874 return 0;
8054 for (i = 0; i < imux->num_items; i++) { 9875 for (i = 0; i < imux->num_items; i++) {
8055 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 9876 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -8193,6 +10014,55 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8193 { } /* end */ 10014 { } /* end */
8194}; 10015};
8195 10016
10017static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10018 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10019 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10020 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10021
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10023
10024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10027
10028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10031
10032 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10033 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10034
10035 { } /* end */
10036};
10037
10038/* Pin assignment: Front=0x14, HP = 0x15,
10039 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10040 */
10041static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10054 {
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10058 .count = 1,
10059 .info = alc882_mux_enum_info,
10060 .get = alc882_mux_enum_get,
10061 .put = alc882_mux_enum_put,
10062 },
10063 { } /* end */
10064};
10065
8196/* 10066/*
8197 * generic initialization of ADC, input mixers and output mixers 10067 * generic initialization of ADC, input mixers and output mixers
8198 */ 10068 */
@@ -8214,10 +10084,10 @@ static struct hda_verb alc861vd_volume_init_verbs[] = {
8214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 10084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8215 10085
8216 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 10086 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
8219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
8220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
8221 10091
8222 /* 10092 /*
8223 * Set up output mixers (0x02 - 0x05) 10093 * Set up output mixers (0x02 - 0x05)
@@ -8318,6 +10188,132 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8318 { } 10188 { }
8319}; 10189};
8320 10190
10191static struct hda_verb alc861vd_eapd_verbs[] = {
10192 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10193 { }
10194};
10195
10196static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10202 {}
10203};
10204
10205/* toggle speaker-output according to the hp-jack state */
10206static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10207{
10208 unsigned int present;
10209 unsigned char bits;
10210
10211 present = snd_hda_codec_read(codec, 0x1b, 0,
10212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10213 bits = present ? 0x80 : 0;
10214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10215 0x80, bits);
10216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10217 0x80, bits);
10218}
10219
10220static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10221{
10222 unsigned int present;
10223 unsigned char bits;
10224
10225 present = snd_hda_codec_read(codec, 0x18, 0,
10226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10227 bits = present ? 0x80 : 0;
10228 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10229 0x80, bits);
10230 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10231 0x80, bits);
10232}
10233
10234static void alc861vd_lenovo_automute(struct hda_codec *codec)
10235{
10236 alc861vd_lenovo_hp_automute(codec);
10237 alc861vd_lenovo_mic_automute(codec);
10238}
10239
10240static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10241 unsigned int res)
10242{
10243 switch (res >> 26) {
10244 case ALC880_HP_EVENT:
10245 alc861vd_lenovo_hp_automute(codec);
10246 break;
10247 case ALC880_MIC_EVENT:
10248 alc861vd_lenovo_mic_automute(codec);
10249 break;
10250 }
10251}
10252
10253static struct hda_verb alc861vd_dallas_verbs[] = {
10254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10258
10259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267
10268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10276
10277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10285
10286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10290
10291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10294
10295 { } /* end */
10296};
10297
10298/* toggle speaker-output according to the hp-jack state */
10299static void alc861vd_dallas_automute(struct hda_codec *codec)
10300{
10301 unsigned int present;
10302
10303 present = snd_hda_codec_read(codec, 0x15, 0,
10304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10305 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10306 0x80, present ? 0x80 : 0);
10307 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10308 0x80, present ? 0x80 : 0);
10309}
10310
10311static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10312{
10313 if ((res >> 26) == ALC880_HP_EVENT)
10314 alc861vd_dallas_automute(codec);
10315}
10316
8321/* pcm configuration: identiacal with ALC880 */ 10317/* pcm configuration: identiacal with ALC880 */
8322#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 10318#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8323#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 10319#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
@@ -8329,18 +10325,27 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8329 */ 10325 */
8330static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { 10326static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8331 [ALC660VD_3ST] = "3stack-660", 10327 [ALC660VD_3ST] = "3stack-660",
10328 [ALC660VD_3ST_DIG]= "3stack-660-digout",
8332 [ALC861VD_3ST] = "3stack", 10329 [ALC861VD_3ST] = "3stack",
8333 [ALC861VD_3ST_DIG] = "3stack-digout", 10330 [ALC861VD_3ST_DIG] = "3stack-digout",
8334 [ALC861VD_6ST_DIG] = "6stack-digout", 10331 [ALC861VD_6ST_DIG] = "6stack-digout",
10332 [ALC861VD_LENOVO] = "lenovo",
10333 [ALC861VD_DALLAS] = "dallas",
8335 [ALC861VD_AUTO] = "auto", 10334 [ALC861VD_AUTO] = "auto",
8336}; 10335};
8337 10336
8338static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 10337static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10338 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
8339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 10339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10340 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
8340 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 10341 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8341 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 10342 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8342 10343
8343 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST), 10344 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10345 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10346 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10347 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10348 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
8344 {} 10349 {}
8345}; 10350};
8346 10351
@@ -8357,6 +10362,19 @@ static struct alc_config_preset alc861vd_presets[] = {
8357 .channel_mode = alc861vd_3stack_2ch_modes, 10362 .channel_mode = alc861vd_3stack_2ch_modes,
8358 .input_mux = &alc861vd_capture_source, 10363 .input_mux = &alc861vd_capture_source,
8359 }, 10364 },
10365 [ALC660VD_3ST_DIG] = {
10366 .mixers = { alc861vd_3st_mixer },
10367 .init_verbs = { alc861vd_volume_init_verbs,
10368 alc861vd_3stack_init_verbs },
10369 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10370 .dac_nids = alc660vd_dac_nids,
10371 .dig_out_nid = ALC861VD_DIGOUT_NID,
10372 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10373 .adc_nids = alc861vd_adc_nids,
10374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10375 .channel_mode = alc861vd_3stack_2ch_modes,
10376 .input_mux = &alc861vd_capture_source,
10377 },
8360 [ALC861VD_3ST] = { 10378 [ALC861VD_3ST] = {
8361 .mixers = { alc861vd_3st_mixer }, 10379 .mixers = { alc861vd_3st_mixer },
8362 .init_verbs = { alc861vd_volume_init_verbs, 10380 .init_verbs = { alc861vd_volume_init_verbs,
@@ -8389,6 +10407,35 @@ static struct alc_config_preset alc861vd_presets[] = {
8389 .channel_mode = alc861vd_6stack_modes, 10407 .channel_mode = alc861vd_6stack_modes,
8390 .input_mux = &alc861vd_capture_source, 10408 .input_mux = &alc861vd_capture_source,
8391 }, 10409 },
10410 [ALC861VD_LENOVO] = {
10411 .mixers = { alc861vd_lenovo_mixer },
10412 .init_verbs = { alc861vd_volume_init_verbs,
10413 alc861vd_3stack_init_verbs,
10414 alc861vd_eapd_verbs,
10415 alc861vd_lenovo_unsol_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10419 .adc_nids = alc861vd_adc_nids,
10420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10421 .channel_mode = alc861vd_3stack_2ch_modes,
10422 .input_mux = &alc861vd_capture_source,
10423 .unsol_event = alc861vd_lenovo_unsol_event,
10424 .init_hook = alc861vd_lenovo_automute,
10425 },
10426 [ALC861VD_DALLAS] = {
10427 .mixers = { alc861vd_dallas_mixer },
10428 .init_verbs = { alc861vd_dallas_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10432 .adc_nids = alc861vd_adc_nids,
10433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10434 .channel_mode = alc861vd_3stack_2ch_modes,
10435 .input_mux = &alc861vd_dallas_capture_source,
10436 .unsol_event = alc861vd_dallas_unsol_event,
10437 .init_hook = alc861vd_dallas_automute,
10438 },
8392}; 10439};
8393 10440
8394/* 10441/*
@@ -8409,11 +10456,13 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8409 struct alc_spec *spec = codec->spec; 10456 struct alc_spec *spec = codec->spec;
8410 int i; 10457 int i;
8411 10458
10459 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8412 for (i = 0; i <= HDA_SIDE; i++) { 10460 for (i = 0; i <= HDA_SIDE; i++) {
8413 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 10461 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10462 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8414 if (nid) 10463 if (nid)
8415 alc861vd_auto_set_output_and_unmute(codec, nid, 10464 alc861vd_auto_set_output_and_unmute(codec, nid,
8416 PIN_OUT, i); 10465 pin_type, i);
8417 } 10466 }
8418} 10467}
8419 10468
@@ -8466,7 +10515,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8466 int i, err; 10515 int i, err;
8467 10516
8468 for (i = 0; i < cfg->line_outs; i++) { 10517 for (i = 0; i < cfg->line_outs; i++) {
8469 if (! spec->multiout.dac_nids[i]) 10518 if (!spec->multiout.dac_nids[i])
8470 continue; 10519 continue;
8471 nid_v = alc861vd_idx_to_mixer_vol( 10520 nid_v = alc861vd_idx_to_mixer_vol(
8472 alc880_dac_to_idx( 10521 alc880_dac_to_idx(
@@ -8477,36 +10526,42 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8477 10526
8478 if (i == 2) { 10527 if (i == 2) {
8479 /* Center/LFE */ 10528 /* Center/LFE */
8480 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 10529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8481 "Center Playback Volume", 10530 "Center Playback Volume",
8482 HDA_COMPOSE_AMP_VAL(nid_v, 1, 10531 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
8483 0, HDA_OUTPUT))) < 0) 10532 HDA_OUTPUT));
10533 if (err < 0)
8484 return err; 10534 return err;
8485 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 10535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8486 "LFE Playback Volume", 10536 "LFE Playback Volume",
8487 HDA_COMPOSE_AMP_VAL(nid_v, 2, 10537 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
8488 0, HDA_OUTPUT))) < 0) 10538 HDA_OUTPUT));
10539 if (err < 0)
8489 return err; 10540 return err;
8490 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 10541 err = add_control(spec, ALC_CTL_BIND_MUTE,
8491 "Center Playback Switch", 10542 "Center Playback Switch",
8492 HDA_COMPOSE_AMP_VAL(nid_s, 1, 10543 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
8493 2, HDA_INPUT))) < 0) 10544 HDA_INPUT));
10545 if (err < 0)
8494 return err; 10546 return err;
8495 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 10547 err = add_control(spec, ALC_CTL_BIND_MUTE,
8496 "LFE Playback Switch", 10548 "LFE Playback Switch",
8497 HDA_COMPOSE_AMP_VAL(nid_s, 2, 10549 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
8498 2, HDA_INPUT))) < 0) 10550 HDA_INPUT));
10551 if (err < 0)
8499 return err; 10552 return err;
8500 } else { 10553 } else {
8501 sprintf(name, "%s Playback Volume", chname[i]); 10554 sprintf(name, "%s Playback Volume", chname[i]);
8502 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8503 HDA_COMPOSE_AMP_VAL(nid_v, 3, 10556 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8504 0, HDA_OUTPUT))) < 0) 10557 HDA_OUTPUT));
10558 if (err < 0)
8505 return err; 10559 return err;
8506 sprintf(name, "%s Playback Switch", chname[i]); 10560 sprintf(name, "%s Playback Switch", chname[i]);
8507 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 10561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8508 HDA_COMPOSE_AMP_VAL(nid_v, 3, 10562 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8509 2, HDA_INPUT))) < 0) 10563 HDA_INPUT));
10564 if (err < 0)
8510 return err; 10565 return err;
8511 } 10566 }
8512 } 10567 }
@@ -8523,13 +10578,13 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8523 int err; 10578 int err;
8524 char name[32]; 10579 char name[32];
8525 10580
8526 if (! pin) 10581 if (!pin)
8527 return 0; 10582 return 0;
8528 10583
8529 if (alc880_is_fixed_pin(pin)) { 10584 if (alc880_is_fixed_pin(pin)) {
8530 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 10585 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8531 /* specify the DAC as the extra output */ 10586 /* specify the DAC as the extra output */
8532 if (! spec->multiout.hp_nid) 10587 if (!spec->multiout.hp_nid)
8533 spec->multiout.hp_nid = nid_v; 10588 spec->multiout.hp_nid = nid_v;
8534 else 10589 else
8535 spec->multiout.extra_out_nid[0] = nid_v; 10590 spec->multiout.extra_out_nid[0] = nid_v;
@@ -8540,22 +10595,22 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8540 alc880_fixed_pin_idx(pin)); 10595 alc880_fixed_pin_idx(pin));
8541 10596
8542 sprintf(name, "%s Playback Volume", pfx); 10597 sprintf(name, "%s Playback Volume", pfx);
8543 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 10598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8544 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 10599 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
8545 HDA_OUTPUT))) < 0) 10600 if (err < 0)
8546 return err; 10601 return err;
8547 sprintf(name, "%s Playback Switch", pfx); 10602 sprintf(name, "%s Playback Switch", pfx);
8548 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 10603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8549 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 10604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
8550 HDA_INPUT))) < 0) 10605 if (err < 0)
8551 return err; 10606 return err;
8552 } else if (alc880_is_multi_pin(pin)) { 10607 } else if (alc880_is_multi_pin(pin)) {
8553 /* set manual connection */ 10608 /* set manual connection */
8554 /* we have only a switch on HP-out PIN */ 10609 /* we have only a switch on HP-out PIN */
8555 sprintf(name, "%s Playback Switch", pfx); 10610 sprintf(name, "%s Playback Switch", pfx);
8556 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 10611 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8557 HDA_COMPOSE_AMP_VAL(pin, 3, 0, 10612 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
8558 HDA_OUTPUT))) < 0) 10613 if (err < 0)
8559 return err; 10614 return err;
8560 } 10615 }
8561 return 0; 10616 return 0;
@@ -8572,21 +10627,31 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
8572 int err; 10627 int err;
8573 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 10628 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8574 10629
8575 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 10630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8576 alc861vd_ignore)) < 0) 10631 alc861vd_ignore);
10632 if (err < 0)
8577 return err; 10633 return err;
8578 if (! spec->autocfg.line_outs) 10634 if (!spec->autocfg.line_outs)
8579 return 0; /* can't find valid BIOS pin config */ 10635 return 0; /* can't find valid BIOS pin config */
8580 10636
8581 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 10637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
8582 (err = alc861vd_auto_create_multi_out_ctls(spec, 10638 if (err < 0)
8583 &spec->autocfg)) < 0 || 10639 return err;
8584 (err = alc861vd_auto_create_extra_out(spec, 10640 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
8585 spec->autocfg.speaker_pins[0], "Speaker")) < 0 || 10641 if (err < 0)
8586 (err = alc861vd_auto_create_extra_out(spec, 10642 return err;
8587 spec->autocfg.hp_pins[0], "Headphone")) < 0 || 10643 err = alc861vd_auto_create_extra_out(spec,
8588 (err = alc880_auto_create_analog_input_ctls(spec, 10644 spec->autocfg.speaker_pins[0],
8589 &spec->autocfg)) < 0) 10645 "Speaker");
10646 if (err < 0)
10647 return err;
10648 err = alc861vd_auto_create_extra_out(spec,
10649 spec->autocfg.hp_pins[0],
10650 "Headphone");
10651 if (err < 0)
10652 return err;
10653 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10654 if (err < 0)
8590 return err; 10655 return err;
8591 10656
8592 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 10657 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8641,7 +10706,7 @@ static int patch_alc861vd(struct hda_codec *codec)
8641 if (err < 0) { 10706 if (err < 0) {
8642 alc_free(codec); 10707 alc_free(codec);
8643 return err; 10708 return err;
8644 } else if (! err) { 10709 } else if (!err) {
8645 printk(KERN_INFO 10710 printk(KERN_INFO
8646 "hda_codec: Cannot set up configuration " 10711 "hda_codec: Cannot set up configuration "
8647 "from BIOS. Using base mode...\n"); 10712 "from BIOS. Using base mode...\n");
@@ -8675,16 +10740,872 @@ static int patch_alc861vd(struct hda_codec *codec)
8675} 10740}
8676 10741
8677/* 10742/*
10743 * ALC662 support
10744 *
10745 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10746 * configuration. Each pin widget can choose any input DACs and a mixer.
10747 * Each ADC is connected from a mixer of all inputs. This makes possible
10748 * 6-channel independent captures.
10749 *
10750 * In addition, an independent DAC for the multi-playback (not used in this
10751 * driver yet).
10752 */
10753#define ALC662_DIGOUT_NID 0x06
10754#define ALC662_DIGIN_NID 0x0a
10755
10756static hda_nid_t alc662_dac_nids[4] = {
10757 /* front, rear, clfe, rear_surr */
10758 0x02, 0x03, 0x04
10759};
10760
10761static hda_nid_t alc662_adc_nids[1] = {
10762 /* ADC1-2 */
10763 0x09,
10764};
10765/* input MUX */
10766/* FIXME: should be a matrix-type input source selection */
10767
10768static struct hda_input_mux alc662_capture_source = {
10769 .num_items = 4,
10770 .items = {
10771 { "Mic", 0x0 },
10772 { "Front Mic", 0x1 },
10773 { "Line", 0x2 },
10774 { "CD", 0x4 },
10775 },
10776};
10777
10778static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10779 .num_items = 2,
10780 .items = {
10781 { "Mic", 0x1 },
10782 { "Line", 0x2 },
10783 },
10784};
10785#define alc662_mux_enum_info alc_mux_enum_info
10786#define alc662_mux_enum_get alc_mux_enum_get
10787
10788static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10789 struct snd_ctl_elem_value *ucontrol)
10790{
10791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10792 struct alc_spec *spec = codec->spec;
10793 const struct hda_input_mux *imux = spec->input_mux;
10794 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10795 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10796 hda_nid_t nid = capture_mixers[adc_idx];
10797 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10798 unsigned int i, idx;
10799
10800 idx = ucontrol->value.enumerated.item[0];
10801 if (idx >= imux->num_items)
10802 idx = imux->num_items - 1;
10803 if (*cur_val == idx && !codec->in_resume)
10804 return 0;
10805 for (i = 0; i < imux->num_items; i++) {
10806 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10808 v | (imux->items[i].index << 8));
10809 }
10810 *cur_val = idx;
10811 return 1;
10812}
10813/*
10814 * 2ch mode
10815 */
10816static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10817 { 2, NULL }
10818};
10819
10820/*
10821 * 2ch mode
10822 */
10823static struct hda_verb alc662_3ST_ch2_init[] = {
10824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10828 { } /* end */
10829};
10830
10831/*
10832 * 6ch mode
10833 */
10834static struct hda_verb alc662_3ST_ch6_init[] = {
10835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10837 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10841 { } /* end */
10842};
10843
10844static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10845 { 2, alc662_3ST_ch2_init },
10846 { 6, alc662_3ST_ch6_init },
10847};
10848
10849/*
10850 * 2ch mode
10851 */
10852static struct hda_verb alc662_sixstack_ch6_init[] = {
10853 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10854 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10855 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10856 { } /* end */
10857};
10858
10859/*
10860 * 6ch mode
10861 */
10862static struct hda_verb alc662_sixstack_ch8_init[] = {
10863 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10864 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10866 { } /* end */
10867};
10868
10869static struct hda_channel_mode alc662_5stack_modes[2] = {
10870 { 2, alc662_sixstack_ch6_init },
10871 { 6, alc662_sixstack_ch8_init },
10872};
10873
10874/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10876 */
10877
10878static struct snd_kcontrol_new alc662_base_mixer[] = {
10879 /* output mixer control */
10880 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10889
10890 /*Input mixer control */
10891 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10894 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10896 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10899
10900 /* Capture mixer control */
10901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10903 {
10904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10905 .name = "Capture Source",
10906 .count = 1,
10907 .info = alc_mux_enum_info,
10908 .get = alc_mux_enum_get,
10909 .put = alc_mux_enum_put,
10910 },
10911 { } /* end */
10912};
10913
10914static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10916 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10930 {
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 /* .name = "Capture Source", */
10933 .name = "Input Source",
10934 .count = 1,
10935 .info = alc662_mux_enum_info,
10936 .get = alc662_mux_enum_get,
10937 .put = alc662_mux_enum_put,
10938 },
10939 { } /* end */
10940};
10941
10942static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10946 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10960 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10961 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10964 {
10965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10966 /* .name = "Capture Source", */
10967 .name = "Input Source",
10968 .count = 1,
10969 .info = alc662_mux_enum_info,
10970 .get = alc662_mux_enum_get,
10971 .put = alc662_mux_enum_put,
10972 },
10973 { } /* end */
10974};
10975
10976static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10979 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10980 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10988 {
10989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10990 /* .name = "Capture Source", */
10991 .name = "Input Source",
10992 .count = 1,
10993 .info = alc662_mux_enum_info,
10994 .get = alc662_mux_enum_get,
10995 .put = alc662_mux_enum_put,
10996 },
10997 { } /* end */
10998};
10999
11000static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11001 {
11002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11003 .name = "Channel Mode",
11004 .info = alc_ch_mode_info,
11005 .get = alc_ch_mode_get,
11006 .put = alc_ch_mode_put,
11007 },
11008 { } /* end */
11009};
11010
11011static struct hda_verb alc662_init_verbs[] = {
11012 /* ADC: mute amp left and right */
11013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11016
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11022
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029
11030 /* Front Pin: output 0 (0x0c) */
11031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Rear Pin: output 1 (0x0d) */
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11037
11038 /* CLFE Pin: output 2 (0x0e) */
11039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11041
11042 /* Mic (rear) pin: input vref at 80% */
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11045 /* Front Mic pin: input vref at 80% */
11046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11048 /* Line In pin: input */
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11051 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 /* CD pin widget for input */
11056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11057
11058 /* FIXME: use matrix-type input source selection */
11059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11060 /* Input mixer */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11065 { }
11066};
11067
11068static struct hda_verb alc662_sue_init_verbs[] = {
11069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11071 {}
11072};
11073
11074/*
11075 * generic initialization of ADC, input mixers and output mixers
11076 */
11077static struct hda_verb alc662_auto_init_verbs[] = {
11078 /*
11079 * Unmute ADC and set the default input to mic-in
11080 */
11081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083
11084 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11085 * mixer widget
11086 * Note: PASD motherboards uses the Line In 2 as the input for front
11087 * panel mic (mic 2)
11088 */
11089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11095
11096 /*
11097 * Set up output mixers (0x0c - 0x0f)
11098 */
11099 /* set vol=0 to output mixers */
11100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11103
11104 /* set up input amps for analog loopback */
11105 /* Amp Indices: DAC = 0, mixer = 1 */
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112
11113
11114 /* FIXME: use matrix-type input source selection */
11115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11116 /* Input mixer */
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11120 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11122
11123 { }
11124};
11125
11126/* capture mixer elements */
11127static struct snd_kcontrol_new alc662_capture_mixer[] = {
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11130 {
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* The multiple "Capture Source" controls confuse alsamixer
11133 * So call somewhat different..
11134 * FIXME: the controls appear in the "playback" view!
11135 */
11136 /* .name = "Capture Source", */
11137 .name = "Input Source",
11138 .count = 1,
11139 .info = alc882_mux_enum_info,
11140 .get = alc882_mux_enum_get,
11141 .put = alc882_mux_enum_put,
11142 },
11143 { } /* end */
11144};
11145
11146static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11147{
11148 unsigned int present;
11149 unsigned char bits;
11150
11151 present = snd_hda_codec_read(codec, 0x14, 0,
11152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11153 bits = present ? 0x80 : 0;
11154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11155 0x80, bits);
11156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11157 0x80, bits);
11158}
11159
11160static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11161{
11162 unsigned int present;
11163 unsigned char bits;
11164
11165 present = snd_hda_codec_read(codec, 0x1b, 0,
11166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11167 bits = present ? 0x80 : 0;
11168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11169 0x80, bits);
11170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11171 0x80, bits);
11172 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11173 0x80, bits);
11174 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11175 0x80, bits);
11176}
11177
11178static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11179 unsigned int res)
11180{
11181 if ((res >> 26) == ALC880_HP_EVENT)
11182 alc662_lenovo_101e_all_automute(codec);
11183 if ((res >> 26) == ALC880_FRONT_EVENT)
11184 alc662_lenovo_101e_ispeaker_automute(codec);
11185}
11186
11187
11188/* pcm configuration: identiacal with ALC880 */
11189#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11190#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11191#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11192#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11193
11194/*
11195 * configuration and preset
11196 */
11197static const char *alc662_models[ALC662_MODEL_LAST] = {
11198 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11199 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11200 [ALC662_3ST_6ch] = "3stack-6ch",
11201 [ALC662_5ST_DIG] = "6stack-dig",
11202 [ALC662_LENOVO_101E] = "lenovo-101e",
11203 [ALC662_AUTO] = "auto",
11204};
11205
11206static struct snd_pci_quirk alc662_cfg_tbl[] = {
11207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11208 {}
11209};
11210
11211static struct alc_config_preset alc662_presets[] = {
11212 [ALC662_3ST_2ch_DIG] = {
11213 .mixers = { alc662_3ST_2ch_mixer },
11214 .init_verbs = { alc662_init_verbs },
11215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11216 .dac_nids = alc662_dac_nids,
11217 .dig_out_nid = ALC662_DIGOUT_NID,
11218 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11219 .adc_nids = alc662_adc_nids,
11220 .dig_in_nid = ALC662_DIGIN_NID,
11221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11222 .channel_mode = alc662_3ST_2ch_modes,
11223 .input_mux = &alc662_capture_source,
11224 },
11225 [ALC662_3ST_6ch_DIG] = {
11226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11227 .init_verbs = { alc662_init_verbs },
11228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11229 .dac_nids = alc662_dac_nids,
11230 .dig_out_nid = ALC662_DIGOUT_NID,
11231 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11232 .adc_nids = alc662_adc_nids,
11233 .dig_in_nid = ALC662_DIGIN_NID,
11234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11235 .channel_mode = alc662_3ST_6ch_modes,
11236 .need_dac_fix = 1,
11237 .input_mux = &alc662_capture_source,
11238 },
11239 [ALC662_3ST_6ch] = {
11240 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11241 .init_verbs = { alc662_init_verbs },
11242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11243 .dac_nids = alc662_dac_nids,
11244 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11245 .adc_nids = alc662_adc_nids,
11246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11247 .channel_mode = alc662_3ST_6ch_modes,
11248 .need_dac_fix = 1,
11249 .input_mux = &alc662_capture_source,
11250 },
11251 [ALC662_5ST_DIG] = {
11252 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11253 .init_verbs = { alc662_init_verbs },
11254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11255 .dac_nids = alc662_dac_nids,
11256 .dig_out_nid = ALC662_DIGOUT_NID,
11257 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11258 .adc_nids = alc662_adc_nids,
11259 .dig_in_nid = ALC662_DIGIN_NID,
11260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11261 .channel_mode = alc662_5stack_modes,
11262 .input_mux = &alc662_capture_source,
11263 },
11264 [ALC662_LENOVO_101E] = {
11265 .mixers = { alc662_lenovo_101e_mixer },
11266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11268 .dac_nids = alc662_dac_nids,
11269 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11270 .adc_nids = alc662_adc_nids,
11271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11272 .channel_mode = alc662_3ST_2ch_modes,
11273 .input_mux = &alc662_lenovo_101e_capture_source,
11274 .unsol_event = alc662_lenovo_101e_unsol_event,
11275 .init_hook = alc662_lenovo_101e_all_automute,
11276 },
11277
11278};
11279
11280
11281/*
11282 * BIOS auto configuration
11283 */
11284
11285/* add playback controls from the parsed DAC table */
11286static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11287 const struct auto_pin_cfg *cfg)
11288{
11289 char name[32];
11290 static const char *chname[4] = {
11291 "Front", "Surround", NULL /*CLFE*/, "Side"
11292 };
11293 hda_nid_t nid;
11294 int i, err;
11295
11296 for (i = 0; i < cfg->line_outs; i++) {
11297 if (!spec->multiout.dac_nids[i])
11298 continue;
11299 nid = alc880_idx_to_mixer(i);
11300 if (i == 2) {
11301 /* Center/LFE */
11302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11303 "Center Playback Volume",
11304 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11305 HDA_OUTPUT));
11306 if (err < 0)
11307 return err;
11308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11309 "LFE Playback Volume",
11310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11311 HDA_OUTPUT));
11312 if (err < 0)
11313 return err;
11314 err = add_control(spec, ALC_CTL_BIND_MUTE,
11315 "Center Playback Switch",
11316 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11317 HDA_INPUT));
11318 if (err < 0)
11319 return err;
11320 err = add_control(spec, ALC_CTL_BIND_MUTE,
11321 "LFE Playback Switch",
11322 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11323 HDA_INPUT));
11324 if (err < 0)
11325 return err;
11326 } else {
11327 sprintf(name, "%s Playback Volume", chname[i]);
11328 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11329 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11330 HDA_OUTPUT));
11331 if (err < 0)
11332 return err;
11333 sprintf(name, "%s Playback Switch", chname[i]);
11334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11335 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11336 HDA_INPUT));
11337 if (err < 0)
11338 return err;
11339 }
11340 }
11341 return 0;
11342}
11343
11344/* add playback controls for speaker and HP outputs */
11345static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11346 const char *pfx)
11347{
11348 hda_nid_t nid;
11349 int err;
11350 char name[32];
11351
11352 if (!pin)
11353 return 0;
11354
11355 if (alc880_is_fixed_pin(pin)) {
11356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11357 /* printk("DAC nid=%x\n",nid); */
11358 /* specify the DAC as the extra output */
11359 if (!spec->multiout.hp_nid)
11360 spec->multiout.hp_nid = nid;
11361 else
11362 spec->multiout.extra_out_nid[0] = nid;
11363 /* control HP volume/switch on the output mixer amp */
11364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11365 sprintf(name, "%s Playback Volume", pfx);
11366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11368 if (err < 0)
11369 return err;
11370 sprintf(name, "%s Playback Switch", pfx);
11371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11373 if (err < 0)
11374 return err;
11375 } else if (alc880_is_multi_pin(pin)) {
11376 /* set manual connection */
11377 /* we have only a switch on HP-out PIN */
11378 sprintf(name, "%s Playback Switch", pfx);
11379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11381 if (err < 0)
11382 return err;
11383 }
11384 return 0;
11385}
11386
11387/* create playback/capture controls for input pins */
11388static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
11390{
11391 struct hda_input_mux *imux = &spec->private_imux;
11392 int i, err, idx;
11393
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
11395 if (alc880_is_input_pin(cfg->input_pins[i])) {
11396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i],
11399 idx, 0x0b);
11400 if (err < 0)
11401 return err;
11402 imux->items[imux->num_items].label =
11403 auto_pin_cfg_labels[i];
11404 imux->items[imux->num_items].index =
11405 alc880_input_pin_idx(cfg->input_pins[i]);
11406 imux->num_items++;
11407 }
11408 }
11409 return 0;
11410}
11411
11412static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11413 hda_nid_t nid, int pin_type,
11414 int dac_idx)
11415{
11416 /* set as output */
11417 snd_hda_codec_write(codec, nid, 0,
11418 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11419 snd_hda_codec_write(codec, nid, 0,
11420 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11421 /* need the manual connection? */
11422 if (alc880_is_multi_pin(nid)) {
11423 struct alc_spec *spec = codec->spec;
11424 int idx = alc880_multi_pin_idx(nid);
11425 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11426 AC_VERB_SET_CONNECT_SEL,
11427 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11428 }
11429}
11430
11431static void alc662_auto_init_multi_out(struct hda_codec *codec)
11432{
11433 struct alc_spec *spec = codec->spec;
11434 int i;
11435
11436 for (i = 0; i <= HDA_SIDE; i++) {
11437 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11438 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11439 if (nid)
11440 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11441 i);
11442 }
11443}
11444
11445static void alc662_auto_init_hp_out(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 hda_nid_t pin;
11449
11450 pin = spec->autocfg.hp_pins[0];
11451 if (pin) /* connect to front */
11452 /* use dac 0 */
11453 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11454}
11455
11456#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11457#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11458
11459static void alc662_auto_init_analog_input(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec = codec->spec;
11462 int i;
11463
11464 for (i = 0; i < AUTO_PIN_LAST; i++) {
11465 hda_nid_t nid = spec->autocfg.input_pins[i];
11466 if (alc662_is_input_pin(nid)) {
11467 snd_hda_codec_write(codec, nid, 0,
11468 AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 (i <= AUTO_PIN_FRONT_MIC ?
11470 PIN_VREF80 : PIN_IN));
11471 if (nid != ALC662_PIN_CD_NID)
11472 snd_hda_codec_write(codec, nid, 0,
11473 AC_VERB_SET_AMP_GAIN_MUTE,
11474 AMP_OUT_MUTE);
11475 }
11476 }
11477}
11478
11479static int alc662_parse_auto_config(struct hda_codec *codec)
11480{
11481 struct alc_spec *spec = codec->spec;
11482 int err;
11483 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11484
11485 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11486 alc662_ignore);
11487 if (err < 0)
11488 return err;
11489 if (!spec->autocfg.line_outs)
11490 return 0; /* can't find valid BIOS pin config */
11491
11492 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11493 if (err < 0)
11494 return err;
11495 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11496 if (err < 0)
11497 return err;
11498 err = alc662_auto_create_extra_out(spec,
11499 spec->autocfg.speaker_pins[0],
11500 "Speaker");
11501 if (err < 0)
11502 return err;
11503 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11504 "Headphone");
11505 if (err < 0)
11506 return err;
11507 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11508 if (err < 0)
11509 return err;
11510
11511 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11512
11513 if (spec->autocfg.dig_out_pin)
11514 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11515
11516 if (spec->kctl_alloc)
11517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11518
11519 spec->num_mux_defs = 1;
11520 spec->input_mux = &spec->private_imux;
11521
11522 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11523 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11524 spec->num_mixers++;
11525 return 1;
11526}
11527
11528/* additional initialization for auto-configuration model */
11529static void alc662_auto_init(struct hda_codec *codec)
11530{
11531 alc662_auto_init_multi_out(codec);
11532 alc662_auto_init_hp_out(codec);
11533 alc662_auto_init_analog_input(codec);
11534}
11535
11536static int patch_alc662(struct hda_codec *codec)
11537{
11538 struct alc_spec *spec;
11539 int err, board_config;
11540
11541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11542 if (!spec)
11543 return -ENOMEM;
11544
11545 codec->spec = spec;
11546
11547 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11548 alc662_models,
11549 alc662_cfg_tbl);
11550 if (board_config < 0) {
11551 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11552 "trying auto-probe from BIOS...\n");
11553 board_config = ALC662_AUTO;
11554 }
11555
11556 if (board_config == ALC662_AUTO) {
11557 /* automatic parse from the BIOS config */
11558 err = alc662_parse_auto_config(codec);
11559 if (err < 0) {
11560 alc_free(codec);
11561 return err;
11562 } else if (!err) {
11563 printk(KERN_INFO
11564 "hda_codec: Cannot set up configuration "
11565 "from BIOS. Using base mode...\n");
11566 board_config = ALC662_3ST_2ch_DIG;
11567 }
11568 }
11569
11570 if (board_config != ALC662_AUTO)
11571 setup_preset(spec, &alc662_presets[board_config]);
11572
11573 spec->stream_name_analog = "ALC662 Analog";
11574 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11575 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11576
11577 spec->stream_name_digital = "ALC662 Digital";
11578 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11579 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11580
11581 if (!spec->adc_nids && spec->input_mux) {
11582 spec->adc_nids = alc662_adc_nids;
11583 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11584 }
11585
11586 codec->patch_ops = alc_patch_ops;
11587 if (board_config == ALC662_AUTO)
11588 spec->init_hook = alc662_auto_init;
11589
11590 return 0;
11591}
11592
11593/*
8678 * patch entries 11594 * patch entries
8679 */ 11595 */
8680struct hda_codec_preset snd_hda_preset_realtek[] = { 11596struct hda_codec_preset snd_hda_preset_realtek[] = {
8681 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 11597 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
8682 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 11598 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11599 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
8683 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 11600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
8684 .patch = patch_alc861 }, 11601 .patch = patch_alc861 },
8685 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 11602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
8686 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 11603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
8687 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 11604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11606 .patch = patch_alc883 },
11607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11608 .patch = patch_alc662 },
8688 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 11609 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
8689 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 11610 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
8690 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 11611 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 6fcda9bcf0c..6d2ecc38905 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -304,6 +304,12 @@ struct hda_codec_preset snd_hda_preset_si3054[] = {
304 { .id = 0x10573055, .name = "Si3054", .patch = patch_si3054 }, 304 { .id = 0x10573055, .name = "Si3054", .patch = patch_si3054 },
305 { .id = 0x10573057, .name = "Si3054", .patch = patch_si3054 }, 305 { .id = 0x10573057, .name = "Si3054", .patch = patch_si3054 },
306 { .id = 0x10573155, .name = "Si3054", .patch = patch_si3054 }, 306 { .id = 0x10573155, .name = "Si3054", .patch = patch_si3054 },
307 /* VIA HDA on Clevo m540 */
308 { .id = 0x11063288, .name = "Si3054", .patch = patch_si3054 },
309 /* Asus A8J Modem (SM56) */
310 { .id = 0x15433155, .name = "Si3054", .patch = patch_si3054 },
311 /* LG LW20 modem */
312 { .id = 0x18540018, .name = "Si3054", .patch = patch_si3054 },
307 {} 313 {}
308}; 314};
309 315
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c94291bc536..3f25de72966 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -44,6 +44,7 @@ enum {
44 44
45enum { 45enum {
46 STAC_9205_REF, 46 STAC_9205_REF,
47 STAC_M43xx,
47 STAC_9205_MODELS 48 STAC_9205_MODELS
48}; 49};
49 50
@@ -51,6 +52,7 @@ enum {
51 STAC_925x_REF, 52 STAC_925x_REF,
52 STAC_M2_2, 53 STAC_M2_2,
53 STAC_MA6, 54 STAC_MA6,
55 STAC_PA6,
54 STAC_925x_MODELS 56 STAC_925x_MODELS
55}; 57};
56 58
@@ -58,10 +60,19 @@ enum {
58 STAC_D945_REF, 60 STAC_D945_REF,
59 STAC_D945GTP3, 61 STAC_D945GTP3,
60 STAC_D945GTP5, 62 STAC_D945GTP5,
63 STAC_922X_DELL,
64 STAC_INTEL_MAC_V1,
65 STAC_INTEL_MAC_V2,
66 STAC_INTEL_MAC_V3,
67 STAC_INTEL_MAC_V4,
68 STAC_INTEL_MAC_V5,
69 /* for backward compitability */
61 STAC_MACMINI, 70 STAC_MACMINI,
62 STAC_MACBOOK, 71 STAC_MACBOOK,
63 STAC_MACBOOK_PRO_V1, 72 STAC_MACBOOK_PRO_V1,
64 STAC_MACBOOK_PRO_V2, 73 STAC_MACBOOK_PRO_V2,
74 STAC_IMAC_INTEL,
75 STAC_IMAC_INTEL_20,
65 STAC_922X_MODELS 76 STAC_922X_MODELS
66}; 77};
67 78
@@ -151,6 +162,10 @@ static hda_nid_t stac925x_dac_nids[1] = {
151 0x02, 162 0x02,
152}; 163};
153 164
165static hda_nid_t stac925x_dmic_nids[1] = {
166 0x15,
167};
168
154static hda_nid_t stac922x_adc_nids[2] = { 169static hda_nid_t stac922x_adc_nids[2] = {
155 0x06, 0x07, 170 0x06, 0x07,
156}; 171};
@@ -175,8 +190,8 @@ static hda_nid_t stac9205_mux_nids[2] = {
175 0x19, 0x1a 190 0x19, 0x1a
176}; 191};
177 192
178static hda_nid_t stac9205_dmic_nids[3] = { 193static hda_nid_t stac9205_dmic_nids[2] = {
179 0x17, 0x18, 0 194 0x17, 0x18,
180}; 195};
181 196
182static hda_nid_t stac9200_pin_nids[8] = { 197static hda_nid_t stac9200_pin_nids[8] = {
@@ -204,7 +219,6 @@ static hda_nid_t stac9205_pin_nids[12] = {
204 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 219 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
205 0x0f, 0x14, 0x16, 0x17, 0x18, 220 0x0f, 0x14, 0x16, 0x17, 0x18,
206 0x21, 0x22, 221 0x21, 0x22,
207
208}; 222};
209 223
210static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, 224static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
@@ -320,8 +334,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
320}; 334};
321 335
322static struct snd_kcontrol_new stac925x_mixer[] = { 336static struct snd_kcontrol_new stac925x_mixer[] = {
323 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
324 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
325 { 337 {
326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
327 .name = "Input Source", 339 .name = "Input Source",
@@ -466,6 +478,16 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
466 "Dell XPS M1710", STAC_REF), 478 "Dell XPS M1710", STAC_REF),
467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, 479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
468 "Dell Precision M90", STAC_REF), 480 "Dell Precision M90", STAC_REF),
481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
482 "unknown Dell", STAC_REF),
483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
484 "Dell Inspiron 640m", STAC_REF),
485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
486 "Dell Inspiron 1501", STAC_REF),
487
488 /* Panasonic */
489 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
490
469 {} /* terminator */ 491 {} /* terminator */
470}; 492};
471 493
@@ -479,29 +501,38 @@ static unsigned int stac925x_MA6_pin_configs[8] = {
479 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, 501 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
480}; 502};
481 503
504static unsigned int stac925x_PA6_pin_configs[8] = {
505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
506 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
507};
508
482static unsigned int stac925xM2_2_pin_configs[8] = { 509static unsigned int stac925xM2_2_pin_configs[8] = {
483 0x40c003f3, 0x424503f2, 0x041800f4, 0x02a19020, 510 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
484 0x50a103F0, 0x90100210, 0x400003f1, 0x9033032e, 511 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
485}; 512};
486 513
487static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { 514static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
488 [STAC_REF] = ref925x_pin_configs, 515 [STAC_REF] = ref925x_pin_configs,
489 [STAC_M2_2] = stac925xM2_2_pin_configs, 516 [STAC_M2_2] = stac925xM2_2_pin_configs,
490 [STAC_MA6] = stac925x_MA6_pin_configs, 517 [STAC_MA6] = stac925x_MA6_pin_configs,
518 [STAC_PA6] = stac925x_PA6_pin_configs,
491}; 519};
492 520
493static const char *stac925x_models[STAC_925x_MODELS] = { 521static const char *stac925x_models[STAC_925x_MODELS] = {
494 [STAC_REF] = "ref", 522 [STAC_REF] = "ref",
495 [STAC_M2_2] = "m2-2", 523 [STAC_M2_2] = "m2-2",
496 [STAC_MA6] = "m6", 524 [STAC_MA6] = "m6",
525 [STAC_PA6] = "pa6",
497}; 526};
498 527
499static struct snd_pci_quirk stac925x_cfg_tbl[] = { 528static struct snd_pci_quirk stac925x_cfg_tbl[] = {
500 /* SigmaTel reference board */ 529 /* SigmaTel reference board */
501 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), 530 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
531 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
502 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), 532 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
503 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), 533 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
504 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), 534 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
535 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
505 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2), 536 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
506 {} /* terminator */ 537 {} /* terminator */
507}; 538};
@@ -524,42 +555,78 @@ static unsigned int d945gtp5_pin_configs[10] = {
524 0x02a19320, 0x40000100, 555 0x02a19320, 0x40000100,
525}; 556};
526 557
527static unsigned int macbook_pin_configs[10] = { 558static unsigned int intel_mac_v1_pin_configs[10] = {
528 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110, 559 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
529 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e, 560 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
561 0x400000fc, 0x400000fb,
562};
563
564static unsigned int intel_mac_v2_pin_configs[10] = {
565 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
566 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
567 0x400000fc, 0x400000fb,
568};
569
570static unsigned int intel_mac_v3_pin_configs[10] = {
571 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
572 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
530 0x400000fc, 0x400000fb, 573 0x400000fc, 0x400000fb,
531}; 574};
532 575
533static unsigned int macbook_pro_v1_pin_configs[10] = { 576static unsigned int intel_mac_v4_pin_configs[10] = {
534 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010, 577 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
535 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e, 578 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
536 0x02a19320, 0x400000fb 579 0x400000fc, 0x400000fb,
537}; 580};
538 581
539static unsigned int macbook_pro_v2_pin_configs[10] = { 582static unsigned int intel_mac_v5_pin_configs[10] = {
540 0x0221401f, 0x90a70120, 0x01813024, 0x01014010, 583 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
541 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e, 584 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
542 0x400000fc, 0x400000fb, 585 0x400000fc, 0x400000fb,
543}; 586};
544 587
588static unsigned int stac922x_dell_pin_configs[10] = {
589 0x0221121e, 0x408103ff, 0x02a1123e, 0x90100310,
590 0x408003f1, 0x0221122f, 0x03451340, 0x40c003f2,
591 0x50a003f3, 0x405003f4
592};
593
545static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { 594static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
546 [STAC_D945_REF] = ref922x_pin_configs, 595 [STAC_D945_REF] = ref922x_pin_configs,
547 [STAC_D945GTP3] = d945gtp3_pin_configs, 596 [STAC_D945GTP3] = d945gtp3_pin_configs,
548 [STAC_D945GTP5] = d945gtp5_pin_configs, 597 [STAC_D945GTP5] = d945gtp5_pin_configs,
549 [STAC_MACMINI] = d945gtp5_pin_configs, 598 [STAC_922X_DELL] = stac922x_dell_pin_configs,
550 [STAC_MACBOOK] = macbook_pin_configs, 599 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
551 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs, 600 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
552 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs, 601 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
602 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
603 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
604 /* for backward compitability */
605 [STAC_MACMINI] = intel_mac_v3_pin_configs,
606 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
607 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
608 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
609 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
610 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
553}; 611};
554 612
555static const char *stac922x_models[STAC_922X_MODELS] = { 613static const char *stac922x_models[STAC_922X_MODELS] = {
556 [STAC_D945_REF] = "ref", 614 [STAC_D945_REF] = "ref",
557 [STAC_D945GTP5] = "5stack", 615 [STAC_D945GTP5] = "5stack",
558 [STAC_D945GTP3] = "3stack", 616 [STAC_D945GTP3] = "3stack",
617 [STAC_922X_DELL] = "dell",
618 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
619 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
620 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
621 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
622 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
623 /* for backward compitability */
559 [STAC_MACMINI] = "macmini", 624 [STAC_MACMINI] = "macmini",
560 [STAC_MACBOOK] = "macbook", 625 [STAC_MACBOOK] = "macbook",
561 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", 626 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
562 [STAC_MACBOOK_PRO_V2] = "macbook-pro", 627 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
628 [STAC_IMAC_INTEL] = "imac-intel",
629 [STAC_IMAC_INTEL_20] = "imac-intel-20",
563}; 630};
564 631
565static struct snd_pci_quirk stac922x_cfg_tbl[] = { 632static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -622,7 +689,10 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
622 /* other systems */ 689 /* other systems */
623 /* Apple Mac Mini (early 2006) */ 690 /* Apple Mac Mini (early 2006) */
624 SND_PCI_QUIRK(0x8384, 0x7680, 691 SND_PCI_QUIRK(0x8384, 0x7680,
625 "Mac Mini", STAC_MACMINI), 692 "Mac Mini", STAC_INTEL_MAC_V3),
693 /* Dell */
694 SND_PCI_QUIRK(0x1028, 0x01d7, "Dell XPS M1210", STAC_922X_DELL),
695
626 {} /* terminator */ 696 {} /* terminator */
627}; 697};
628 698
@@ -703,7 +773,8 @@ static unsigned int ref9205_pin_configs[12] = {
703}; 773};
704 774
705static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { 775static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
706 ref9205_pin_configs, 776 [STAC_REF] = ref9205_pin_configs,
777 [STAC_M43xx] = NULL,
707}; 778};
708 779
709static const char *stac9205_models[STAC_9205_MODELS] = { 780static const char *stac9205_models[STAC_9205_MODELS] = {
@@ -714,6 +785,10 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
714 /* SigmaTel reference board */ 785 /* SigmaTel reference board */
715 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 786 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
716 "DFI LanParty", STAC_9205_REF), 787 "DFI LanParty", STAC_9205_REF),
788 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01f8,
789 "Dell Precision", STAC_M43xx),
790 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x01ff,
791 "Dell Precision", STAC_M43xx),
717 {} /* terminator */ 792 {} /* terminator */
718}; 793};
719 794
@@ -743,33 +818,56 @@ static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
743 return 0; 818 return 0;
744} 819}
745 820
821static void stac92xx_set_config_reg(struct hda_codec *codec,
822 hda_nid_t pin_nid, unsigned int pin_config)
823{
824 int i;
825 snd_hda_codec_write(codec, pin_nid, 0,
826 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
827 pin_config & 0x000000ff);
828 snd_hda_codec_write(codec, pin_nid, 0,
829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
830 (pin_config & 0x0000ff00) >> 8);
831 snd_hda_codec_write(codec, pin_nid, 0,
832 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
833 (pin_config & 0x00ff0000) >> 16);
834 snd_hda_codec_write(codec, pin_nid, 0,
835 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
836 pin_config >> 24);
837 i = snd_hda_codec_read(codec, pin_nid, 0,
838 AC_VERB_GET_CONFIG_DEFAULT,
839 0x00);
840 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
841 pin_nid, i);
842}
843
746static void stac92xx_set_config_regs(struct hda_codec *codec) 844static void stac92xx_set_config_regs(struct hda_codec *codec)
747{ 845{
748 int i; 846 int i;
749 struct sigmatel_spec *spec = codec->spec; 847 struct sigmatel_spec *spec = codec->spec;
750 unsigned int pin_cfg;
751 848
752 if (! spec->pin_nids || ! spec->pin_configs) 849 if (!spec->pin_configs)
753 return; 850 return;
754 851
755 for (i = 0; i < spec->num_pins; i++) { 852 for (i = 0; i < spec->num_pins; i++)
756 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 853 stac92xx_set_config_reg(codec, spec->pin_nids[i],
757 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, 854 spec->pin_configs[i]);
758 spec->pin_configs[i] & 0x000000ff); 855}
759 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 856
760 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 857static void stac92xx_enable_gpio_mask(struct hda_codec *codec,
761 (spec->pin_configs[i] & 0x0000ff00) >> 8); 858 int gpio_mask, int gpio_data)
762 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 859{
763 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 860 /* Configure GPIOx as output */
764 (spec->pin_configs[i] & 0x00ff0000) >> 16); 861 snd_hda_codec_write(codec, codec->afg, 0,
765 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 862 AC_VERB_SET_GPIO_DIRECTION, gpio_mask);
766 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 863 /* Configure GPIOx as CMOS */
767 spec->pin_configs[i] >> 24); 864 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
768 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, 865 /* Assert GPIOx */
769 AC_VERB_GET_CONFIG_DEFAULT, 866 snd_hda_codec_write(codec, codec->afg, 0,
770 0x00); 867 AC_VERB_SET_GPIO_DATA, gpio_data);
771 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); 868 /* Enable GPIOx */
772 } 869 snd_hda_codec_write(codec, codec->afg, 0,
870 AC_VERB_SET_GPIO_MASK, gpio_mask);
773} 871}
774 872
775/* 873/*
@@ -820,6 +918,17 @@ static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
820 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 918 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
821} 919}
822 920
921static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
922 struct hda_codec *codec,
923 unsigned int stream_tag,
924 unsigned int format,
925 struct snd_pcm_substream *substream)
926{
927 struct sigmatel_spec *spec = codec->spec;
928 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
929 stream_tag, format, substream);
930}
931
823 932
824/* 933/*
825 * Analog capture callbacks 934 * Analog capture callbacks
@@ -854,7 +963,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
854 /* NID is set in stac92xx_build_pcms */ 963 /* NID is set in stac92xx_build_pcms */
855 .ops = { 964 .ops = {
856 .open = stac92xx_dig_playback_pcm_open, 965 .open = stac92xx_dig_playback_pcm_open,
857 .close = stac92xx_dig_playback_pcm_close 966 .close = stac92xx_dig_playback_pcm_close,
967 .prepare = stac92xx_dig_playback_pcm_prepare
858 }, 968 },
859}; 969};
860 970
@@ -1055,11 +1165,23 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
1055static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) 1165static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1056{ 1166{
1057 struct sigmatel_spec *spec = codec->spec; 1167 struct sigmatel_spec *spec = codec->spec;
1168 unsigned int wcaps, wtype;
1169 int i, num_dacs = 0;
1170
1171 /* use the wcaps cache to count all DACs available for line-outs */
1172 for (i = 0; i < codec->num_nodes; i++) {
1173 wcaps = codec->wcaps[i];
1174 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1175 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1176 num_dacs++;
1177 }
1058 1178
1179 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1180
1059 switch (cfg->line_outs) { 1181 switch (cfg->line_outs) {
1060 case 3: 1182 case 3:
1061 /* add line-in as side */ 1183 /* add line-in as side */
1062 if (cfg->input_pins[AUTO_PIN_LINE]) { 1184 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1063 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; 1185 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1064 spec->line_switch = 1; 1186 spec->line_switch = 1;
1065 cfg->line_outs++; 1187 cfg->line_outs++;
@@ -1067,12 +1189,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1067 break; 1189 break;
1068 case 2: 1190 case 2:
1069 /* add line-in as clfe and mic as side */ 1191 /* add line-in as clfe and mic as side */
1070 if (cfg->input_pins[AUTO_PIN_LINE]) { 1192 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1071 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; 1193 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1072 spec->line_switch = 1; 1194 spec->line_switch = 1;
1073 cfg->line_outs++; 1195 cfg->line_outs++;
1074 } 1196 }
1075 if (cfg->input_pins[AUTO_PIN_MIC]) { 1197 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1076 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; 1198 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1077 spec->mic_switch = 1; 1199 spec->mic_switch = 1;
1078 cfg->line_outs++; 1200 cfg->line_outs++;
@@ -1080,12 +1202,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1080 break; 1202 break;
1081 case 1: 1203 case 1:
1082 /* add line-in as surr and mic as clfe */ 1204 /* add line-in as surr and mic as clfe */
1083 if (cfg->input_pins[AUTO_PIN_LINE]) { 1205 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1084 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; 1206 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1085 spec->line_switch = 1; 1207 spec->line_switch = 1;
1086 cfg->line_outs++; 1208 cfg->line_outs++;
1087 } 1209 }
1088 if (cfg->input_pins[AUTO_PIN_MIC]) { 1210 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1089 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; 1211 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1090 spec->mic_switch = 1; 1212 spec->mic_switch = 1;
1091 cfg->line_outs++; 1213 cfg->line_outs++;
@@ -1096,33 +1218,83 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1096 return 0; 1218 return 0;
1097} 1219}
1098 1220
1221
1222static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1223{
1224 int i;
1225
1226 for (i = 0; i < spec->multiout.num_dacs; i++) {
1227 if (spec->multiout.dac_nids[i] == nid)
1228 return 1;
1229 }
1230
1231 return 0;
1232}
1233
1099/* 1234/*
1100 * XXX The line_out pin widget connection list may not be set to the 1235 * Fill in the dac_nids table from the parsed pin configuration
1101 * desired DAC nid. This is the case on 927x where ports A and B can 1236 * This function only works when every pin in line_out_pins[]
1102 * be routed to several DACs. 1237 * contains atleast one DAC in its connection list. Some 92xx
1103 * 1238 * codecs are not connected directly to a DAC, such as the 9200
1104 * This requires an analysis of the line-out/hp pin configuration 1239 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1105 * to provide a best fit for pin/DAC configurations that are routable.
1106 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
1107 * A and B is not supported.
1108 */ 1240 */
1109/* fill in the dac_nids table from the parsed pin configuration */
1110static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, 1241static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1111 const struct auto_pin_cfg *cfg) 1242 struct auto_pin_cfg *cfg)
1112{ 1243{
1113 struct sigmatel_spec *spec = codec->spec; 1244 struct sigmatel_spec *spec = codec->spec;
1114 hda_nid_t nid; 1245 int i, j, conn_len = 0;
1115 int i; 1246 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1116 1247 unsigned int wcaps, wtype;
1117 /* check the pins hardwired to audio widget */ 1248
1118 for (i = 0; i < cfg->line_outs; i++) { 1249 for (i = 0; i < cfg->line_outs; i++) {
1119 nid = cfg->line_out_pins[i]; 1250 nid = cfg->line_out_pins[i];
1120 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, 1251 conn_len = snd_hda_get_connections(codec, nid, conn,
1121 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1252 HDA_MAX_CONNECTIONS);
1122 } 1253 for (j = 0; j < conn_len; j++) {
1254 wcaps = snd_hda_param_read(codec, conn[j],
1255 AC_PAR_AUDIO_WIDGET_CAP);
1256 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1257
1258 if (wtype != AC_WID_AUD_OUT ||
1259 (wcaps & AC_WCAP_DIGITAL))
1260 continue;
1261 /* conn[j] is a DAC routed to this line-out */
1262 if (!is_in_dac_nids(spec, conn[j]))
1263 break;
1264 }
1123 1265
1124 spec->multiout.num_dacs = cfg->line_outs; 1266 if (j == conn_len) {
1267 if (spec->multiout.num_dacs > 0) {
1268 /* we have already working output pins,
1269 * so let's drop the broken ones again
1270 */
1271 cfg->line_outs = spec->multiout.num_dacs;
1272 break;
1273 }
1274 /* error out, no available DAC found */
1275 snd_printk(KERN_ERR
1276 "%s: No available DAC for pin 0x%x\n",
1277 __func__, nid);
1278 return -ENODEV;
1279 }
1280
1281 spec->multiout.dac_nids[i] = conn[j];
1282 spec->multiout.num_dacs++;
1283 if (conn_len > 1) {
1284 /* select this DAC in the pin's input mux */
1285 snd_hda_codec_write(codec, nid, 0,
1286 AC_VERB_SET_CONNECT_SEL, j);
1287
1288 }
1289 }
1125 1290
1291 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1292 spec->multiout.num_dacs,
1293 spec->multiout.dac_nids[0],
1294 spec->multiout.dac_nids[1],
1295 spec->multiout.dac_nids[2],
1296 spec->multiout.dac_nids[3],
1297 spec->multiout.dac_nids[4]);
1126 return 0; 1298 return 0;
1127} 1299}
1128 1300
@@ -1189,12 +1361,8 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1189 1361
1190static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) 1362static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1191{ 1363{
1192 int i; 1364 if (is_in_dac_nids(spec, nid))
1193 1365 return 1;
1194 for (i = 0; i < spec->multiout.num_dacs; i++) {
1195 if (spec->multiout.dac_nids[i] == nid)
1196 return 1;
1197 }
1198 if (spec->multiout.hp_nid == nid) 1366 if (spec->multiout.hp_nid == nid)
1199 return 1; 1367 return 1;
1200 return 0; 1368 return 0;
@@ -1236,17 +1404,23 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1236 add_spec_dacs(spec, nid); 1404 add_spec_dacs(spec, nid);
1237 } 1405 }
1238 for (i = 0; i < cfg->speaker_outs; i++) { 1406 for (i = 0; i < cfg->speaker_outs; i++) {
1239 nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0, 1407 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1240 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1408 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1241 if (check_in_dac_nids(spec, nid)) 1409 if (check_in_dac_nids(spec, nid))
1242 nid = 0; 1410 nid = 0;
1411 if (! nid)
1412 continue;
1413 add_spec_dacs(spec, nid);
1414 }
1415 for (i = 0; i < cfg->line_outs; i++) {
1416 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1417 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1243 if (check_in_dac_nids(spec, nid)) 1418 if (check_in_dac_nids(spec, nid))
1244 nid = 0; 1419 nid = 0;
1245 if (! nid) 1420 if (! nid)
1246 continue; 1421 continue;
1247 add_spec_dacs(spec, nid); 1422 add_spec_dacs(spec, nid);
1248 } 1423 }
1249
1250 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { 1424 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1251 static const char *pfxs[] = { 1425 static const char *pfxs[] = {
1252 "Speaker", "External Speaker", "Speaker2", 1426 "Speaker", "External Speaker", "Speaker2",
@@ -1355,7 +1529,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
1355 imux->num_items++; 1529 imux->num_items++;
1356 } 1530 }
1357 1531
1358 if (imux->num_items == 1) { 1532 if (imux->num_items) {
1359 /* 1533 /*
1360 * Set the current input for the muxes. 1534 * Set the current input for the muxes.
1361 * The STAC9221 has two input muxes with identical source 1535 * The STAC9221 has two input muxes with identical source
@@ -1675,8 +1849,27 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1675{ 1849{
1676 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 1850 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1677 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 1851 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1678 if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN)) 1852
1679 return; 1853 if (pin_ctl & AC_PINCTL_IN_EN) {
1854 /*
1855 * we need to check the current set-up direction of
1856 * shared input pins since they can be switched via
1857 * "xxx as Output" mixer switch
1858 */
1859 struct sigmatel_spec *spec = codec->spec;
1860 struct auto_pin_cfg *cfg = &spec->autocfg;
1861 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1862 spec->line_switch) ||
1863 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1864 spec->mic_switch))
1865 return;
1866 }
1867
1868 /* if setting pin direction bits, clear the current
1869 direction bits first */
1870 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1871 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1872
1680 snd_hda_codec_write(codec, nid, 0, 1873 snd_hda_codec_write(codec, nid, 0,
1681 AC_VERB_SET_PIN_WIDGET_CONTROL, 1874 AC_VERB_SET_PIN_WIDGET_CONTROL,
1682 pin_ctl | flag); 1875 pin_ctl | flag);
@@ -1751,6 +1944,7 @@ static int stac92xx_resume(struct hda_codec *codec)
1751 1944
1752 stac92xx_init(codec); 1945 stac92xx_init(codec);
1753 stac92xx_set_config_regs(codec); 1946 stac92xx_set_config_regs(codec);
1947 snd_hda_resume_ctls(codec, spec->mixer);
1754 for (i = 0; i < spec->num_mixers; i++) 1948 for (i = 0; i < spec->num_mixers; i++)
1755 snd_hda_resume_ctls(codec, spec->mixers[i]); 1949 snd_hda_resume_ctls(codec, spec->mixers[i]);
1756 if (spec->multiout.dig_out_nid) 1950 if (spec->multiout.dig_out_nid)
@@ -1783,7 +1977,7 @@ static int patch_stac9200(struct hda_codec *codec)
1783 return -ENOMEM; 1977 return -ENOMEM;
1784 1978
1785 codec->spec = spec; 1979 codec->spec = spec;
1786 spec->num_pins = 8; 1980 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
1787 spec->pin_nids = stac9200_pin_nids; 1981 spec->pin_nids = stac9200_pin_nids;
1788 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, 1982 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
1789 stac9200_models, 1983 stac9200_models,
@@ -1833,14 +2027,15 @@ static int patch_stac925x(struct hda_codec *codec)
1833 return -ENOMEM; 2027 return -ENOMEM;
1834 2028
1835 codec->spec = spec; 2029 codec->spec = spec;
1836 spec->num_pins = 8; 2030 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
1837 spec->pin_nids = stac925x_pin_nids; 2031 spec->pin_nids = stac925x_pin_nids;
1838 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, 2032 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
1839 stac925x_models, 2033 stac925x_models,
1840 stac925x_cfg_tbl); 2034 stac925x_cfg_tbl);
1841 again: 2035 again:
1842 if (spec->board_config < 0) { 2036 if (spec->board_config < 0) {
1843 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x, using BIOS defaults\n"); 2037 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2038 "using BIOS defaults\n");
1844 err = stac92xx_save_bios_config_regs(codec); 2039 err = stac92xx_save_bios_config_regs(codec);
1845 if (err < 0) { 2040 if (err < 0) {
1846 stac92xx_free(codec); 2041 stac92xx_free(codec);
@@ -1858,7 +2053,18 @@ static int patch_stac925x(struct hda_codec *codec)
1858 spec->adc_nids = stac925x_adc_nids; 2053 spec->adc_nids = stac925x_adc_nids;
1859 spec->mux_nids = stac925x_mux_nids; 2054 spec->mux_nids = stac925x_mux_nids;
1860 spec->num_muxes = 1; 2055 spec->num_muxes = 1;
1861 spec->num_dmics = 0; 2056 switch (codec->vendor_id) {
2057 case 0x83847632: /* STAC9202 */
2058 case 0x83847633: /* STAC9202D */
2059 case 0x83847636: /* STAC9251 */
2060 case 0x83847637: /* STAC9251D */
2061 spec->num_dmics = 1;
2062 spec->dmic_nids = stac925x_dmic_nids;
2063 break;
2064 default:
2065 spec->num_dmics = 0;
2066 break;
2067 }
1862 2068
1863 spec->init = stac925x_core_init; 2069 spec->init = stac925x_core_init;
1864 spec->mixer = stac925x_mixer; 2070 spec->mixer = stac925x_mixer;
@@ -1893,23 +2099,41 @@ static int patch_stac922x(struct hda_codec *codec)
1893 return -ENOMEM; 2099 return -ENOMEM;
1894 2100
1895 codec->spec = spec; 2101 codec->spec = spec;
1896 spec->num_pins = 10; 2102 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
1897 spec->pin_nids = stac922x_pin_nids; 2103 spec->pin_nids = stac922x_pin_nids;
1898 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, 2104 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
1899 stac922x_models, 2105 stac922x_models,
1900 stac922x_cfg_tbl); 2106 stac922x_cfg_tbl);
1901 if (spec->board_config == STAC_MACMINI) { 2107 if (spec->board_config == STAC_INTEL_MAC_V3) {
1902 spec->gpio_mute = 1; 2108 spec->gpio_mute = 1;
1903 /* Intel Macs have all same PCI SSID, so we need to check 2109 /* Intel Macs have all same PCI SSID, so we need to check
1904 * codec SSID to distinguish the exact models 2110 * codec SSID to distinguish the exact models
1905 */ 2111 */
1906 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); 2112 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
1907 switch (codec->subsystem_id) { 2113 switch (codec->subsystem_id) {
1908 case 0x106b0200: /* MacBook Pro first generation */ 2114
1909 spec->board_config = STAC_MACBOOK_PRO_V1; 2115 case 0x106b0800:
2116 spec->board_config = STAC_INTEL_MAC_V1;
1910 break; 2117 break;
1911 case 0x106b1e00: /* MacBook Pro second generation */ 2118 case 0x106b0600:
1912 spec->board_config = STAC_MACBOOK_PRO_V2; 2119 case 0x106b0700:
2120 spec->board_config = STAC_INTEL_MAC_V2;
2121 break;
2122 case 0x106b0e00:
2123 case 0x106b0f00:
2124 case 0x106b1600:
2125 case 0x106b1700:
2126 case 0x106b0200:
2127 case 0x106b1e00:
2128 spec->board_config = STAC_INTEL_MAC_V3;
2129 break;
2130 case 0x106b1a00:
2131 case 0x00000100:
2132 spec->board_config = STAC_INTEL_MAC_V4;
2133 break;
2134 case 0x106b0a00:
2135 case 0x106b2200:
2136 spec->board_config = STAC_INTEL_MAC_V5;
1913 break; 2137 break;
1914 } 2138 }
1915 } 2139 }
@@ -1931,7 +2155,7 @@ static int patch_stac922x(struct hda_codec *codec)
1931 2155
1932 spec->adc_nids = stac922x_adc_nids; 2156 spec->adc_nids = stac922x_adc_nids;
1933 spec->mux_nids = stac922x_mux_nids; 2157 spec->mux_nids = stac922x_mux_nids;
1934 spec->num_muxes = 2; 2158 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
1935 spec->num_dmics = 0; 2159 spec->num_dmics = 0;
1936 2160
1937 spec->init = stac922x_core_init; 2161 spec->init = stac922x_core_init;
@@ -1956,6 +2180,13 @@ static int patch_stac922x(struct hda_codec *codec)
1956 2180
1957 codec->patch_ops = stac92xx_patch_ops; 2181 codec->patch_ops = stac92xx_patch_ops;
1958 2182
2183 /* Fix Mux capture level; max to 2 */
2184 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2185 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2186 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2187 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2188 (0 << AC_AMPCAP_MUTE_SHIFT));
2189
1959 return 0; 2190 return 0;
1960} 2191}
1961 2192
@@ -1969,7 +2200,7 @@ static int patch_stac927x(struct hda_codec *codec)
1969 return -ENOMEM; 2200 return -ENOMEM;
1970 2201
1971 codec->spec = spec; 2202 codec->spec = spec;
1972 spec->num_pins = 14; 2203 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
1973 spec->pin_nids = stac927x_pin_nids; 2204 spec->pin_nids = stac927x_pin_nids;
1974 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, 2205 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
1975 stac927x_models, 2206 stac927x_models,
@@ -1992,7 +2223,7 @@ static int patch_stac927x(struct hda_codec *codec)
1992 case STAC_D965_3ST: 2223 case STAC_D965_3ST:
1993 spec->adc_nids = stac927x_adc_nids; 2224 spec->adc_nids = stac927x_adc_nids;
1994 spec->mux_nids = stac927x_mux_nids; 2225 spec->mux_nids = stac927x_mux_nids;
1995 spec->num_muxes = 3; 2226 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
1996 spec->num_dmics = 0; 2227 spec->num_dmics = 0;
1997 spec->init = d965_core_init; 2228 spec->init = d965_core_init;
1998 spec->mixer = stac9227_mixer; 2229 spec->mixer = stac9227_mixer;
@@ -2000,7 +2231,7 @@ static int patch_stac927x(struct hda_codec *codec)
2000 case STAC_D965_5ST: 2231 case STAC_D965_5ST:
2001 spec->adc_nids = stac927x_adc_nids; 2232 spec->adc_nids = stac927x_adc_nids;
2002 spec->mux_nids = stac927x_mux_nids; 2233 spec->mux_nids = stac927x_mux_nids;
2003 spec->num_muxes = 3; 2234 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2004 spec->num_dmics = 0; 2235 spec->num_dmics = 0;
2005 spec->init = d965_core_init; 2236 spec->init = d965_core_init;
2006 spec->mixer = stac9227_mixer; 2237 spec->mixer = stac9227_mixer;
@@ -2008,14 +2239,16 @@ static int patch_stac927x(struct hda_codec *codec)
2008 default: 2239 default:
2009 spec->adc_nids = stac927x_adc_nids; 2240 spec->adc_nids = stac927x_adc_nids;
2010 spec->mux_nids = stac927x_mux_nids; 2241 spec->mux_nids = stac927x_mux_nids;
2011 spec->num_muxes = 3; 2242 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2012 spec->num_dmics = 0; 2243 spec->num_dmics = 0;
2013 spec->init = stac927x_core_init; 2244 spec->init = stac927x_core_init;
2014 spec->mixer = stac927x_mixer; 2245 spec->mixer = stac927x_mixer;
2015 } 2246 }
2016 2247
2017 spec->multiout.dac_nids = spec->dac_nids; 2248 spec->multiout.dac_nids = spec->dac_nids;
2018 2249 /* GPIO0 High = Enable EAPD */
2250 stac92xx_enable_gpio_mask(codec, 0x00000001, 0x00000001);
2251
2019 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); 2252 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2020 if (!err) { 2253 if (!err) {
2021 if (spec->board_config < 0) { 2254 if (spec->board_config < 0) {
@@ -2039,14 +2272,14 @@ static int patch_stac927x(struct hda_codec *codec)
2039static int patch_stac9205(struct hda_codec *codec) 2272static int patch_stac9205(struct hda_codec *codec)
2040{ 2273{
2041 struct sigmatel_spec *spec; 2274 struct sigmatel_spec *spec;
2042 int err; 2275 int err, gpio_mask, gpio_data;
2043 2276
2044 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2277 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2045 if (spec == NULL) 2278 if (spec == NULL)
2046 return -ENOMEM; 2279 return -ENOMEM;
2047 2280
2048 codec->spec = spec; 2281 codec->spec = spec;
2049 spec->num_pins = 14; 2282 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2050 spec->pin_nids = stac9205_pin_nids; 2283 spec->pin_nids = stac9205_pin_nids;
2051 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, 2284 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2052 stac9205_models, 2285 stac9205_models,
@@ -2067,28 +2300,30 @@ static int patch_stac9205(struct hda_codec *codec)
2067 2300
2068 spec->adc_nids = stac9205_adc_nids; 2301 spec->adc_nids = stac9205_adc_nids;
2069 spec->mux_nids = stac9205_mux_nids; 2302 spec->mux_nids = stac9205_mux_nids;
2070 spec->num_muxes = 2; 2303 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2071 spec->dmic_nids = stac9205_dmic_nids; 2304 spec->dmic_nids = stac9205_dmic_nids;
2072 spec->num_dmics = 2; 2305 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2073 spec->dmux_nid = 0x1d; 2306 spec->dmux_nid = 0x1d;
2074 2307
2075 spec->init = stac9205_core_init; 2308 spec->init = stac9205_core_init;
2076 spec->mixer = stac9205_mixer; 2309 spec->mixer = stac9205_mixer;
2077 2310
2078 spec->multiout.dac_nids = spec->dac_nids; 2311 spec->multiout.dac_nids = spec->dac_nids;
2312
2313 if (spec->board_config == STAC_M43xx) {
2314 /* Enable SPDIF in/out */
2315 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2316 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2317
2318 gpio_mask = 0x00000007; /* GPIO0-2 */
2319 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
2320 * GPIO2 High = Headphone Mute
2321 */
2322 gpio_data = 0x00000005;
2323 } else
2324 gpio_mask = gpio_data = 0x00000001; /* GPIO0 High = EAPD */
2079 2325
2080 /* Configure GPIO0 as EAPD output */ 2326 stac92xx_enable_gpio_mask(codec, gpio_mask, gpio_data);
2081 snd_hda_codec_write(codec, codec->afg, 0,
2082 AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
2083 /* Configure GPIO0 as CMOS */
2084 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
2085 /* Assert GPIO0 high */
2086 snd_hda_codec_write(codec, codec->afg, 0,
2087 AC_VERB_SET_GPIO_DATA, 0x00000001);
2088 /* Enable GPIO0 */
2089 snd_hda_codec_write(codec, codec->afg, 0,
2090 AC_VERB_SET_GPIO_MASK, 0x00000001);
2091
2092 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); 2327 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2093 if (!err) { 2328 if (!err) {
2094 if (spec->board_config < 0) { 2329 if (spec->board_config < 0) {
@@ -2123,8 +2358,8 @@ static struct hda_input_mux vaio_mux = {
2123 .num_items = 2, 2358 .num_items = 2,
2124 .items = { 2359 .items = {
2125 /* { "HP", 0x0 }, */ 2360 /* { "HP", 0x0 }, */
2126 { "Line", 0x1 }, 2361 { "Mic Jack", 0x1 },
2127 { "Mic", 0x2 }, 2362 { "Internal Mic", 0x2 },
2128 { "PCM", 0x3 }, 2363 { "PCM", 0x3 },
2129 } 2364 }
2130}; 2365};
@@ -2135,7 +2370,7 @@ static struct hda_verb vaio_init[] = {
2135 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ 2370 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2136 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ 2371 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ 2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ 2373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2139 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ 2374 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ 2375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ 2376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
@@ -2151,7 +2386,7 @@ static struct hda_verb vaio_ar_init[] = {
2151 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ 2386 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2152/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ 2387/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ 2388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ 2389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2155 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ 2390 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2156 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ 2391 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2157/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ 2392/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
@@ -2294,6 +2529,7 @@ static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2294 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 2529 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2295 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), 2530 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2296 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), 2531 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2532 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2297 {} 2533 {}
2298}; 2534};
2299 2535
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 2b11ac8689b..ba32d1e52cb 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -377,6 +377,17 @@ static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
377 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 377 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
378} 378}
379 379
380static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
381 struct hda_codec *codec,
382 unsigned int stream_tag,
383 unsigned int format,
384 struct snd_pcm_substream *substream)
385{
386 struct via_spec *spec = codec->spec;
387 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
388 stream_tag, format, substream);
389}
390
380/* 391/*
381 * Analog capture 392 * Analog capture
382 */ 393 */
@@ -433,7 +444,8 @@ static struct hda_pcm_stream vt1708_pcm_digital_playback = {
433 /* NID is set in via_build_pcms */ 444 /* NID is set in via_build_pcms */
434 .ops = { 445 .ops = {
435 .open = via_dig_playback_pcm_open, 446 .open = via_dig_playback_pcm_open,
436 .close = via_dig_playback_pcm_close 447 .close = via_dig_playback_pcm_close,
448 .prepare = via_dig_playback_pcm_prepare
437 }, 449 },
438}; 450};
439 451
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index 6e22d326df3..44bbb630b94 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -75,7 +75,7 @@ static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
75 75
76 76
77/* entry point */ 77/* entry point */
78const struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { 78struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
79 { 79 {
80 .subvendor = VT1724_SUBDEVICE_AV710, 80 .subvendor = VT1724_SUBDEVICE_AV710,
81 .name = "Chaintech AV-710", 81 .name = "Chaintech AV-710",
diff --git a/sound/pci/ice1712/amp.h b/sound/pci/ice1712/amp.h
index 7b667bad0c6..a0fc89b4812 100644
--- a/sound/pci/ice1712/amp.h
+++ b/sound/pci/ice1712/amp.h
@@ -42,7 +42,7 @@
42#define WM_DAC_CTRL 0x02 42#define WM_DAC_CTRL 0x02
43#define WM_INT_CTRL 0x03 43#define WM_INT_CTRL 0x03
44 44
45extern const struct snd_ice1712_card_info snd_vt1724_amp_cards[]; 45extern struct snd_ice1712_card_info snd_vt1724_amp_cards[];
46 46
47 47
48#endif /* __SOUND_AMP_H */ 48#endif /* __SOUND_AMP_H */
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 6941d85dfec..66bacde1ead 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1411,7 +1411,7 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
1411 * mixers 1411 * mixers
1412 */ 1412 */
1413 1413
1414static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = { 1414static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1415 { 1415 {
1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1417 .name = "Master Playback Switch", 1417 .name = "Master Playback Switch",
@@ -1526,7 +1526,7 @@ static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1526 } 1526 }
1527}; 1527};
1528 1528
1529static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 1529static struct snd_kcontrol_new wm_controls[] __devinitdata = {
1530 { 1530 {
1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1532 .name = "PCM Playback Switch", 1532 .name = "PCM Playback Switch",
@@ -1592,7 +1592,7 @@ static const struct snd_kcontrol_new wm_controls[] __devinitdata = {
1592 } 1592 }
1593}; 1593};
1594 1594
1595static const struct snd_kcontrol_new ac97_controls[] __devinitdata = { 1595static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1596 { 1596 {
1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1598 .name = "AC97 Playback Switch", 1598 .name = "AC97 Playback Switch",
@@ -1697,7 +1697,7 @@ static const struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1697 } 1697 }
1698}; 1698};
1699 1699
1700static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = { 1700static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1701 { 1701 {
1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1703 .name = "AC97 Playback Switch", 1703 .name = "AC97 Playback Switch",
@@ -1829,7 +1829,7 @@ static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1829 1829
1830}; 1830};
1831 1831
1832static const struct snd_kcontrol_new cs8415_controls[] __devinitdata = { 1832static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
1833 { 1833 {
1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
@@ -2107,7 +2107,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
2107 * hence the driver needs to sets up it properly. 2107 * hence the driver needs to sets up it properly.
2108 */ 2108 */
2109 2109
2110static const unsigned char aureon51_eeprom[] __devinitdata = { 2110static unsigned char aureon51_eeprom[] __devinitdata = {
2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */ 2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2123,7 +2123,7 @@ static const unsigned char aureon51_eeprom[] __devinitdata = {
2123 [ICE_EEP2_GPIO_STATE2] = 0x00, 2123 [ICE_EEP2_GPIO_STATE2] = 0x00,
2124}; 2124};
2125 2125
2126static const unsigned char aureon71_eeprom[] __devinitdata = { 2126static unsigned char aureon71_eeprom[] __devinitdata = {
2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2140,7 +2140,7 @@ static const unsigned char aureon71_eeprom[] __devinitdata = {
2140}; 2140};
2141#define prodigy71_eeprom aureon71_eeprom 2141#define prodigy71_eeprom aureon71_eeprom
2142 2142
2143static const unsigned char prodigy71lt_eeprom[] __devinitdata = { 2143static unsigned char prodigy71lt_eeprom[] __devinitdata = {
2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */ 2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2158,7 +2158,7 @@ static const unsigned char prodigy71lt_eeprom[] __devinitdata = {
2158#define prodigy71xt_eeprom prodigy71lt_eeprom 2158#define prodigy71xt_eeprom prodigy71lt_eeprom
2159 2159
2160/* entry point */ 2160/* entry point */
2161const struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = { 2161struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
2162 { 2162 {
2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY, 2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
2164 .name = "Terratec Aureon 5.1-Sky", 2164 .name = "Terratec Aureon 5.1-Sky",
diff --git a/sound/pci/ice1712/aureon.h b/sound/pci/ice1712/aureon.h
index 79e58e88ed4..c253b8e2c78 100644
--- a/sound/pci/ice1712/aureon.h
+++ b/sound/pci/ice1712/aureon.h
@@ -38,7 +38,7 @@
38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */ 38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */
39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/ 39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/
40 40
41extern const struct snd_ice1712_card_info snd_vt1724_aureon_cards[]; 41extern struct snd_ice1712_card_info snd_vt1724_aureon_cards[];
42 42
43/* GPIO bits */ 43/* GPIO bits */
44#define AUREON_CS8415_CS (1 << 22) 44#define AUREON_CS8415_CS (1 << 22)
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 3eeb36c6e98..af659800c9b 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -416,7 +416,7 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
416 return 0; 416 return 0;
417} 417}
418 418
419static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata = 419static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata =
420{ 420{
421 .access = (SNDRV_CTL_ELEM_ACCESS_READ), 421 .access = (SNDRV_CTL_ELEM_ACCESS_READ),
422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -429,7 +429,7 @@ static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __
429 * initialize the chips on M-Audio cards 429 * initialize the chips on M-Audio cards
430 */ 430 */
431 431
432static const struct snd_akm4xxx akm_audiophile __devinitdata = { 432static struct snd_akm4xxx akm_audiophile __devinitdata = {
433 .type = SND_AK4528, 433 .type = SND_AK4528,
434 .num_adcs = 2, 434 .num_adcs = 2,
435 .num_dacs = 2, 435 .num_dacs = 2,
@@ -438,7 +438,7 @@ static const struct snd_akm4xxx akm_audiophile __devinitdata = {
438 } 438 }
439}; 439};
440 440
441static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = { 441static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
442 .caddr = 2, 442 .caddr = 2,
443 .cif = 0, 443 .cif = 0,
444 .data_mask = ICE1712_DELTA_AP_DOUT, 444 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -450,7 +450,7 @@ static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
450 .mask_flags = 0, 450 .mask_flags = 0,
451}; 451};
452 452
453static const struct snd_akm4xxx akm_delta410 __devinitdata = { 453static struct snd_akm4xxx akm_delta410 __devinitdata = {
454 .type = SND_AK4529, 454 .type = SND_AK4529,
455 .num_adcs = 2, 455 .num_adcs = 2,
456 .num_dacs = 8, 456 .num_dacs = 8,
@@ -459,7 +459,7 @@ static const struct snd_akm4xxx akm_delta410 __devinitdata = {
459 } 459 }
460}; 460};
461 461
462static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = { 462static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
463 .caddr = 0, 463 .caddr = 0,
464 .cif = 0, 464 .cif = 0,
465 .data_mask = ICE1712_DELTA_AP_DOUT, 465 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -471,7 +471,7 @@ static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
471 .mask_flags = 0, 471 .mask_flags = 0,
472}; 472};
473 473
474static const struct snd_akm4xxx akm_delta1010lt __devinitdata = { 474static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
475 .type = SND_AK4524, 475 .type = SND_AK4524,
476 .num_adcs = 8, 476 .num_adcs = 8,
477 .num_dacs = 8, 477 .num_dacs = 8,
@@ -481,7 +481,7 @@ static const struct snd_akm4xxx akm_delta1010lt __devinitdata = {
481 } 481 }
482}; 482};
483 483
484static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = { 484static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
485 .caddr = 2, 485 .caddr = 2,
486 .cif = 0, /* the default level of the CIF pin from AK4524 */ 486 .cif = 0, /* the default level of the CIF pin from AK4524 */
487 .data_mask = ICE1712_DELTA_1010LT_DOUT, 487 .data_mask = ICE1712_DELTA_1010LT_DOUT,
@@ -493,7 +493,7 @@ static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
493 .mask_flags = 0, 493 .mask_flags = 0,
494}; 494};
495 495
496static const struct snd_akm4xxx akm_delta44 __devinitdata = { 496static struct snd_akm4xxx akm_delta44 __devinitdata = {
497 .type = SND_AK4524, 497 .type = SND_AK4524,
498 .num_adcs = 4, 498 .num_adcs = 4,
499 .num_dacs = 4, 499 .num_dacs = 4,
@@ -503,7 +503,7 @@ static const struct snd_akm4xxx akm_delta44 __devinitdata = {
503 } 503 }
504}; 504};
505 505
506static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = { 506static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
507 .caddr = 2, 507 .caddr = 2,
508 .cif = 0, /* the default level of the CIF pin from AK4524 */ 508 .cif = 0, /* the default level of the CIF pin from AK4524 */
509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA, 509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA,
@@ -515,7 +515,7 @@ static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
515 .mask_flags = 0, 515 .mask_flags = 0,
516}; 516};
517 517
518static const struct snd_akm4xxx akm_vx442 __devinitdata = { 518static struct snd_akm4xxx akm_vx442 __devinitdata = {
519 .type = SND_AK4524, 519 .type = SND_AK4524,
520 .num_adcs = 4, 520 .num_adcs = 4,
521 .num_dacs = 4, 521 .num_dacs = 4,
@@ -525,7 +525,7 @@ static const struct snd_akm4xxx akm_vx442 __devinitdata = {
525 } 525 }
526}; 526};
527 527
528static const struct snd_ak4xxx_private akm_vx442_priv __devinitdata = { 528static struct snd_ak4xxx_private akm_vx442_priv __devinitdata = {
529 .caddr = 2, 529 .caddr = 2,
530 .cif = 0, 530 .cif = 0,
531 .data_mask = ICE1712_VX442_DOUT, 531 .data_mask = ICE1712_VX442_DOUT,
@@ -650,15 +650,15 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
650 * additional controls for M-Audio cards 650 * additional controls for M-Audio cards
651 */ 651 */
652 652
653static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata = 653static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0); 654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
655static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata = 655static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0); 656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0);
657static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata = 657static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
659static const struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata = 659static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0); 660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
661static const struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata = 661static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
663 663
664 664
@@ -735,7 +735,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
735 735
736 736
737/* entry point */ 737/* entry point */
738const struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = { 738struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
739 { 739 {
740 .subvendor = ICE1712_SUBDEVICE_DELTA1010, 740 .subvendor = ICE1712_SUBDEVICE_DELTA1010,
741 .name = "M Audio Delta 1010", 741 .name = "M Audio Delta 1010",
diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
index e65d669af63..2697156607e 100644
--- a/sound/pci/ice1712/delta.h
+++ b/sound/pci/ice1712/delta.h
@@ -46,7 +46,7 @@
46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100 46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100
47 47
48/* entry point */ 48/* entry point */
49extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[]; 49extern struct snd_ice1712_card_info snd_ice1712_delta_cards[];
50 50
51 51
52/* 52/*
@@ -63,7 +63,7 @@ extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[];
63 /* look to CS8414 datasheet */ 63 /* look to CS8414 datasheet */
64#define ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK 0x04 64#define ICE1712_DELTA_SPDIF_OUT_STAT_CLOCK 0x04
65 /* S/PDIF output status clock */ 65 /* S/PDIF output status clock */
66 /* (writting on rising edge - 0->1) */ 66 /* (writing on rising edge - 0->1) */
67 /* all except Delta44 */ 67 /* all except Delta44 */
68 /* look to CS8404A datasheet */ 68 /* look to CS8404A datasheet */
69#define ICE1712_DELTA_SPDIF_OUT_STAT_DATA 0x08 69#define ICE1712_DELTA_SPDIF_OUT_STAT_DATA 0x08
@@ -100,7 +100,7 @@ extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[];
100 /* AKM4524 serial data */ 100 /* AKM4524 serial data */
101#define ICE1712_DELTA_CODEC_SERIAL_CLOCK 0x20 101#define ICE1712_DELTA_CODEC_SERIAL_CLOCK 0x20
102 /* AKM4524 serial clock */ 102 /* AKM4524 serial clock */
103 /* (writting on rising edge - 0->1 */ 103 /* (writing on rising edge - 0->1 */
104#define ICE1712_DELTA_CODEC_CHIP_A 0x40 104#define ICE1712_DELTA_CODEC_CHIP_A 0x40
105#define ICE1712_DELTA_CODEC_CHIP_B 0x80 105#define ICE1712_DELTA_CODEC_CHIP_B 0x80
106 /* 1 - select chip A or B */ 106 /* 1 - select chip A or B */
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 9b7ff302c07..b135389fec6 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -332,7 +332,7 @@ static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
332 332
333/* 333/*
334 */ 334 */
335static const struct snd_akm4xxx akm_ews88mt __devinitdata = { 335static struct snd_akm4xxx akm_ews88mt __devinitdata = {
336 .num_adcs = 8, 336 .num_adcs = 8,
337 .num_dacs = 8, 337 .num_dacs = 8,
338 .type = SND_AK4524, 338 .type = SND_AK4524,
@@ -342,7 +342,7 @@ static const struct snd_akm4xxx akm_ews88mt __devinitdata = {
342 } 342 }
343}; 343};
344 344
345static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = { 345static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
346 .caddr = 2, 346 .caddr = 2,
347 .cif = 1, /* CIF high */ 347 .cif = 1, /* CIF high */
348 .data_mask = ICE1712_EWS88_SERIAL_DATA, 348 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -354,7 +354,7 @@ static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
354 .mask_flags = 0, 354 .mask_flags = 0,
355}; 355};
356 356
357static const struct snd_akm4xxx akm_ewx2496 __devinitdata = { 357static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
358 .num_adcs = 2, 358 .num_adcs = 2,
359 .num_dacs = 2, 359 .num_dacs = 2,
360 .type = SND_AK4524, 360 .type = SND_AK4524,
@@ -363,7 +363,7 @@ static const struct snd_akm4xxx akm_ewx2496 __devinitdata = {
363 } 363 }
364}; 364};
365 365
366static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = { 366static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
367 .caddr = 2, 367 .caddr = 2,
368 .cif = 1, /* CIF high */ 368 .cif = 1, /* CIF high */
369 .data_mask = ICE1712_EWS88_SERIAL_DATA, 369 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -375,7 +375,7 @@ static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
375 .mask_flags = 0, 375 .mask_flags = 0,
376}; 376};
377 377
378static const struct snd_akm4xxx akm_6fire __devinitdata = { 378static struct snd_akm4xxx akm_6fire __devinitdata = {
379 .num_adcs = 6, 379 .num_adcs = 6,
380 .num_dacs = 6, 380 .num_dacs = 6,
381 .type = SND_AK4524, 381 .type = SND_AK4524,
@@ -384,7 +384,7 @@ static const struct snd_akm4xxx akm_6fire __devinitdata = {
384 } 384 }
385}; 385};
386 386
387static const struct snd_ak4xxx_private akm_6fire_priv __devinitdata = { 387static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
388 .caddr = 2, 388 .caddr = 2,
389 .cif = 1, /* CIF high */ 389 .cif = 1, /* CIF high */
390 .data_mask = ICE1712_6FIRE_SERIAL_DATA, 390 .data_mask = ICE1712_6FIRE_SERIAL_DATA,
@@ -578,7 +578,7 @@ static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct sn
578 return val != nval; 578 return val != nval;
579} 579}
580 580
581static const struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = { 581static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
582 { 582 {
583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
584 .name = "Input Sensitivity Switch", 584 .name = "Input Sensitivity Switch",
@@ -678,7 +678,7 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
678 return ndata != data; 678 return ndata != data;
679} 679}
680 680
681static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = { 681static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
683 .name = "Input Sensitivity Switch", 683 .name = "Input Sensitivity Switch",
684 .info = snd_ice1712_ewx_io_sense_info, 684 .info = snd_ice1712_ewx_io_sense_info,
@@ -687,7 +687,7 @@ static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitda
687 .count = 8, 687 .count = 8,
688}; 688};
689 689
690static const struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = { 690static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
692 .name = "Output Sensitivity Switch", 692 .name = "Output Sensitivity Switch",
693 .info = snd_ice1712_ewx_io_sense_info, 693 .info = snd_ice1712_ewx_io_sense_info,
@@ -769,7 +769,7 @@ static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct
769 .private_value = xshift | (xinvert << 8),\ 769 .private_value = xshift | (xinvert << 8),\
770} 770}
771 771
772static const struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = { 772static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */ 773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0), 774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0), 775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
@@ -909,7 +909,7 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, str
909 .private_value = xshift | (xinvert << 8),\ 909 .private_value = xshift | (xinvert << 8),\
910} 910}
911 911
912static const struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = { 912static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
913 { 913 {
914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
915 .name = "Analog Input Select", 915 .name = "Analog Input Select",
@@ -989,7 +989,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
989 989
990 990
991/* entry point */ 991/* entry point */
992const struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = { 992struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
993 { 993 {
994 .subvendor = ICE1712_SUBDEVICE_EWX2496, 994 .subvendor = ICE1712_SUBDEVICE_EWX2496,
995 .name = "TerraTec EWX24/96", 995 .name = "TerraTec EWX24/96",
diff --git a/sound/pci/ice1712/ews.h b/sound/pci/ice1712/ews.h
index df449b4741f..a12a0b05355 100644
--- a/sound/pci/ice1712/ews.h
+++ b/sound/pci/ice1712/ews.h
@@ -40,7 +40,7 @@
40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111 40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111
41 41
42/* entry point */ 42/* entry point */
43extern const struct snd_ice1712_card_info snd_ice1712_ews_cards[]; 43extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
44 44
45 45
46/* TerraTec EWX 24/96 configuration definitions */ 46/* TerraTec EWX 24/96 configuration definitions */
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index df97313aaf8..8203562ef7e 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -239,7 +239,7 @@ static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip)
239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice) 239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
240{ 240{
241 /* Hoontech STDSP24 with modified hardware */ 241 /* Hoontech STDSP24 with modified hardware */
242 static const struct snd_akm4xxx akm_stdsp24_mv __devinitdata = { 242 static struct snd_akm4xxx akm_stdsp24_mv __devinitdata = {
243 .num_adcs = 2, 243 .num_adcs = 2,
244 .num_dacs = 2, 244 .num_dacs = 2,
245 .type = SND_AK4524, 245 .type = SND_AK4524,
@@ -248,7 +248,7 @@ static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
248 } 248 }
249 }; 249 };
250 250
251 static const struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = { 251 static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
252 .caddr = 2, 252 .caddr = 2,
253 .cif = 1, /* CIF high */ 253 .cif = 1, /* CIF high */
254 .data_mask = ICE1712_STDSP24_SERIAL_DATA, 254 .data_mask = ICE1712_STDSP24_SERIAL_DATA,
@@ -298,7 +298,7 @@ static int __devinit snd_ice1712_ez8_init(struct snd_ice1712 *ice)
298 298
299 299
300/* entry point */ 300/* entry point */
301const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = { 301struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
302 { 302 {
303 .subvendor = ICE1712_SUBDEVICE_STDSP24, 303 .subvendor = ICE1712_SUBDEVICE_STDSP24,
304 .name = "Hoontech SoundTrack Audio DSP24", 304 .name = "Hoontech SoundTrack Audio DSP24",
diff --git a/sound/pci/ice1712/hoontech.h b/sound/pci/ice1712/hoontech.h
index b62d6e4f6c7..1ee538b20fb 100644
--- a/sound/pci/ice1712/hoontech.h
+++ b/sound/pci/ice1712/hoontech.h
@@ -35,7 +35,7 @@
35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */ 35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */
36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */ 36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */
37 37
38extern const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[]; 38extern struct snd_ice1712_card_info snd_ice1712_hoontech_cards[];
39 39
40 40
41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */ 41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 830a1bbd711..6630a0ae952 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -287,7 +287,7 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru
287 return val != nval; 287 return val != nval;
288} 288}
289 289
290static const struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { 290static struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
292 .name = "Digital Mixer To AC97", 292 .name = "Digital Mixer To AC97",
293 .info = snd_ice1712_digmix_route_ac97_info, 293 .info = snd_ice1712_digmix_route_ac97_info,
@@ -977,11 +977,9 @@ static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream,
977 { 977 {
978 unsigned int what = 0; 978 unsigned int what = 0;
979 unsigned int old; 979 unsigned int old;
980 struct list_head *pos;
981 struct snd_pcm_substream *s; 980 struct snd_pcm_substream *s;
982 981
983 snd_pcm_group_for_each(pos, substream) { 982 snd_pcm_group_for_each_entry(s, substream) {
984 s = snd_pcm_group_substream_entry(pos);
985 if (s == ice->playback_pro_substream) { 983 if (s == ice->playback_pro_substream) {
986 what |= ICE1712_PLAYBACK_START; 984 what |= ICE1712_PLAYBACK_START;
987 snd_pcm_trigger_done(s, substream); 985 snd_pcm_trigger_done(s, substream);
@@ -1380,7 +1378,7 @@ static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struc
1380 1378
1381static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0); 1379static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
1382 1380
1383static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = { 1381static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
1384 { 1382 {
1385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1386 .name = "Multi Playback Switch", 1384 .name = "Multi Playback Switch",
@@ -1404,7 +1402,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devini
1404 }, 1402 },
1405}; 1403};
1406 1404
1407static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = { 1405static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
1408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1409 .name = "H/W Multi Capture Switch", 1407 .name = "H/W Multi Capture Switch",
1410 .info = snd_ice1712_pro_mixer_switch_info, 1408 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1413,7 +1411,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __d
1413 .private_value = 10, 1411 .private_value = 10,
1414}; 1412};
1415 1413
1416static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { 1414static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH), 1416 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH),
1419 .info = snd_ice1712_pro_mixer_switch_info, 1417 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1423,7 +1421,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __de
1423 .count = 2, 1421 .count = 2,
1424}; 1422};
1425 1423
1426static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = { 1424static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
1427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1428 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1426 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1429 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 1427 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1435,7 +1433,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __d
1435 .tlv = { .p = db_scale_playback } 1433 .tlv = { .p = db_scale_playback }
1436}; 1434};
1437 1435
1438static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { 1436static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
1439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1440 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME), 1438 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME),
1441 .info = snd_ice1712_pro_mixer_volume_info, 1439 .info = snd_ice1712_pro_mixer_volume_info,
@@ -1627,7 +1625,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol,
1627 return 0; 1625 return 0;
1628} 1626}
1629 1627
1630static const struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = { 1628static struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = {
1631 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1629 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1632 .name = "ICE1712 EEPROM", 1630 .name = "ICE1712 EEPROM",
1633 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1631 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1663,7 +1661,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol,
1663 return 0; 1661 return 0;
1664} 1662}
1665 1663
1666static const struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = 1664static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
1667{ 1665{
1668 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1666 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1669 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1667 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1714,7 +1712,7 @@ static int snd_ice1712_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1714 return 0; 1712 return 0;
1715} 1713}
1716 1714
1717static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata = 1715static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1718{ 1716{
1719 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1717 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1720 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1718 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1723,7 +1721,7 @@ static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1723 .get = snd_ice1712_spdif_maskc_get, 1721 .get = snd_ice1712_spdif_maskc_get,
1724}; 1722};
1725 1723
1726static const struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata = 1724static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
1727{ 1725{
1728 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1726 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1729 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1727 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1750,7 +1748,7 @@ static int snd_ice1712_spdif_stream_put(struct snd_kcontrol *kcontrol,
1750 return 0; 1748 return 0;
1751} 1749}
1752 1750
1753static const struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata = 1751static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
1754{ 1752{
1755 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1753 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1756 SNDRV_CTL_ELEM_ACCESS_INACTIVE), 1754 SNDRV_CTL_ELEM_ACCESS_INACTIVE),
@@ -1891,7 +1889,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1891 return change; 1889 return change;
1892} 1890}
1893 1891
1894static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = { 1892static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
1895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1896 .name = "Multi Track Internal Clock", 1894 .name = "Multi Track Internal Clock",
1897 .info = snd_ice1712_pro_internal_clock_info, 1895 .info = snd_ice1712_pro_internal_clock_info,
@@ -1962,7 +1960,7 @@ static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcont
1962 return change; 1960 return change;
1963} 1961}
1964 1962
1965static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = { 1963static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
1966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1967 .name = "Multi Track Internal Clock Default", 1965 .name = "Multi Track Internal Clock Default",
1968 .info = snd_ice1712_pro_internal_clock_default_info, 1966 .info = snd_ice1712_pro_internal_clock_default_info,
@@ -2001,7 +1999,7 @@ static int snd_ice1712_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
2001 return change; 1999 return change;
2002} 2000}
2003 2001
2004static const struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = { 2002static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
2005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2006 .name = "Multi Track Rate Locking", 2004 .name = "Multi Track Rate Locking",
2007 .info = snd_ice1712_pro_rate_locking_info, 2005 .info = snd_ice1712_pro_rate_locking_info,
@@ -2040,7 +2038,7 @@ static int snd_ice1712_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
2040 return change; 2038 return change;
2041} 2039}
2042 2040
2043static const struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = { 2041static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
2044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2045 .name = "Multi Track Rate Reset", 2043 .name = "Multi Track Rate Reset",
2046 .info = snd_ice1712_pro_rate_reset_info, 2044 .info = snd_ice1712_pro_rate_reset_info,
@@ -2207,7 +2205,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
2207 return change; 2205 return change;
2208} 2206}
2209 2207
2210static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = { 2208static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
2211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2212 .name = "H/W Playback Route", 2210 .name = "H/W Playback Route",
2213 .info = snd_ice1712_pro_route_info, 2211 .info = snd_ice1712_pro_route_info,
@@ -2215,7 +2213,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devini
2215 .put = snd_ice1712_pro_route_analog_put, 2213 .put = snd_ice1712_pro_route_analog_put,
2216}; 2214};
2217 2215
2218static const struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { 2216static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
2219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2220 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 2218 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
2221 .info = snd_ice1712_pro_route_info, 2219 .info = snd_ice1712_pro_route_info,
@@ -2257,7 +2255,7 @@ static int snd_ice1712_pro_volume_rate_put(struct snd_kcontrol *kcontrol,
2257 return change; 2255 return change;
2258} 2256}
2259 2257
2260static const struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = { 2258static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
2261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2262 .name = "Multi Track Volume Rate", 2260 .name = "Multi Track Volume Rate",
2263 .info = snd_ice1712_pro_volume_rate_info, 2261 .info = snd_ice1712_pro_volume_rate_info,
@@ -2290,7 +2288,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
2290 return 0; 2288 return 0;
2291} 2289}
2292 2290
2293static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = { 2291static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
2294 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2295 .name = "Multi Track Peak", 2293 .name = "Multi Track Peak",
2296 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 2294 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -2305,7 +2303,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata =
2305/* 2303/*
2306 * list of available boards 2304 * list of available boards
2307 */ 2305 */
2308static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2306static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2309 snd_ice1712_hoontech_cards, 2307 snd_ice1712_hoontech_cards,
2310 snd_ice1712_delta_cards, 2308 snd_ice1712_delta_cards,
2311 snd_ice1712_ews_cards, 2309 snd_ice1712_ews_cards,
@@ -2329,7 +2327,7 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2329{ 2327{
2330 int dev = 0xa0; /* EEPROM device address */ 2328 int dev = 0xa0; /* EEPROM device address */
2331 unsigned int i, size; 2329 unsigned int i, size;
2332 const struct snd_ice1712_card_info **tbl, *c; 2330 struct snd_ice1712_card_info * const *tbl, *c;
2333 2331
2334 if (! modelname || ! *modelname) { 2332 if (! modelname || ! *modelname) {
2335 ice->eeprom.subvendor = 0; 2333 ice->eeprom.subvendor = 0;
@@ -2658,7 +2656,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
2658 * 2656 *
2659 */ 2657 */
2660 2658
2661static const struct snd_ice1712_card_info no_matched __devinitdata; 2659static struct snd_ice1712_card_info no_matched __devinitdata;
2662 2660
2663static int __devinit snd_ice1712_probe(struct pci_dev *pci, 2661static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2664 const struct pci_device_id *pci_id) 2662 const struct pci_device_id *pci_id)
@@ -2667,7 +2665,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2667 struct snd_card *card; 2665 struct snd_card *card;
2668 struct snd_ice1712 *ice; 2666 struct snd_ice1712 *ice;
2669 int pcm_dev = 0, err; 2667 int pcm_dev = 0, err;
2670 const struct snd_ice1712_card_info **tbl, *c; 2668 struct snd_ice1712_card_info * const *tbl, *c;
2671 2669
2672 if (dev >= SNDRV_CARDS) 2670 if (dev >= SNDRV_CARDS)
2673 return -ENODEV; 2671 return -ENODEV;
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index c3d9feaaf57..6ac486d9c13 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -397,6 +397,9 @@ struct snd_ice1712 {
397 struct ak4114 *ak4114; 397 struct ak4114 *ak4114;
398 unsigned int analog: 1; 398 unsigned int analog: 1;
399 } juli; 399 } juli;
400 struct {
401 struct ak4114 *ak4114;
402 } prodigy192;
400 } spec; 403 } spec;
401 404
402}; 405};
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1127ebdf5fe..ee620dea7ef 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -337,13 +337,11 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
338 unsigned char what; 338 unsigned char what;
339 unsigned char old; 339 unsigned char old;
340 struct list_head *pos;
341 struct snd_pcm_substream *s; 340 struct snd_pcm_substream *s;
342 341
343 what = 0; 342 what = 0;
344 snd_pcm_group_for_each(pos, substream) { 343 snd_pcm_group_for_each_entry(s, substream) {
345 const struct vt1724_pcm_reg *reg; 344 const struct vt1724_pcm_reg *reg;
346 s = snd_pcm_group_substream_entry(pos);
347 reg = s->runtime->private_data; 345 reg = s->runtime->private_data;
348 what |= reg->start; 346 what |= reg->start;
349 snd_pcm_trigger_done(s, substream); 347 snd_pcm_trigger_done(s, substream);
@@ -1318,7 +1316,7 @@ static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
1318 return 0; 1316 return 0;
1319} 1317}
1320 1318
1321static const struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = { 1319static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = {
1322 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1320 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1323 .name = "ICE1724 EEPROM", 1321 .name = "ICE1724 EEPROM",
1324 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1322 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1431,7 +1429,7 @@ static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
1431 return (val != old); 1429 return (val != old);
1432} 1430}
1433 1431
1434static const struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata = 1432static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
1435{ 1433{
1436 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1434 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1437 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1435 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1463,7 +1461,7 @@ static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1463 return 0; 1461 return 0;
1464} 1462}
1465 1463
1466static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata = 1464static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1467{ 1465{
1468 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1466 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1469 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1467 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1472,7 +1470,7 @@ static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1472 .get = snd_vt1724_spdif_maskc_get, 1470 .get = snd_vt1724_spdif_maskc_get,
1473}; 1471};
1474 1472
1475static const struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata = 1473static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
1476{ 1474{
1477 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1475 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1478 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1476 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1517,7 +1515,7 @@ static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol,
1517 return old != val; 1515 return old != val;
1518} 1516}
1519 1517
1520static const struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata = 1518static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
1521{ 1519{
1522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1523 /* FIXME: the following conflict with IEC958 Playback Route */ 1521 /* FIXME: the following conflict with IEC958 Playback Route */
@@ -1668,7 +1666,12 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1668 spin_lock_irq(&ice->reg_lock); 1666 spin_lock_irq(&ice->reg_lock);
1669 oval = inb(ICEMT1724(ice, RATE)); 1667 oval = inb(ICEMT1724(ice, RATE));
1670 if (ucontrol->value.enumerated.item[0] == spdif) { 1668 if (ucontrol->value.enumerated.item[0] == spdif) {
1669 unsigned char i2s_oval;
1671 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); 1670 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
1671 /* setting 256fs */
1672 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT));
1673 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X,
1674 ICEMT1724(ice, I2S_FORMAT));
1672 } else { 1675 } else {
1673 rate = rates[ucontrol->value.integer.value[0] % 15]; 1676 rate = rates[ucontrol->value.integer.value[0] % 15];
1674 if (rate <= get_max_rate(ice)) { 1677 if (rate <= get_max_rate(ice)) {
@@ -1695,7 +1698,7 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1695 return change; 1698 return change;
1696} 1699}
1697 1700
1698static const struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { 1701static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
1699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1700 .name = "Multi Track Internal Clock", 1703 .name = "Multi Track Internal Clock",
1701 .info = snd_vt1724_pro_internal_clock_info, 1704 .info = snd_vt1724_pro_internal_clock_info,
@@ -1734,7 +1737,7 @@ static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
1734 return change; 1737 return change;
1735} 1738}
1736 1739
1737static const struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = { 1740static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
1738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1739 .name = "Multi Track Rate Locking", 1742 .name = "Multi Track Rate Locking",
1740 .info = snd_vt1724_pro_rate_locking_info, 1743 .info = snd_vt1724_pro_rate_locking_info,
@@ -1773,7 +1776,7 @@ static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
1773 return change; 1776 return change;
1774} 1777}
1775 1778
1776static const struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = { 1779static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
1777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1778 .name = "Multi Track Rate Reset", 1781 .name = "Multi Track Rate Reset",
1779 .info = snd_vt1724_pro_rate_reset_info, 1782 .info = snd_vt1724_pro_rate_reset_info,
@@ -1892,7 +1895,7 @@ static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
1892 digital_route_shift(idx)); 1895 digital_route_shift(idx));
1893} 1896}
1894 1897
1895static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = { 1898static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = {
1896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1897 .name = "H/W Playback Route", 1900 .name = "H/W Playback Route",
1898 .info = snd_vt1724_pro_route_info, 1901 .info = snd_vt1724_pro_route_info,
@@ -1900,7 +1903,7 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinit
1900 .put = snd_vt1724_pro_route_analog_put, 1903 .put = snd_vt1724_pro_route_analog_put,
1901}; 1904};
1902 1905
1903static const struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = { 1906static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
1904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1905 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 1908 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
1906 .info = snd_vt1724_pro_route_info, 1909 .info = snd_vt1724_pro_route_info,
@@ -1936,7 +1939,7 @@ static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
1936 return 0; 1939 return 0;
1937} 1940}
1938 1941
1939static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = { 1942static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1941 .name = "Multi Track Peak", 1944 .name = "Multi Track Peak",
1942 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 1945 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -1948,9 +1951,9 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1948 * 1951 *
1949 */ 1952 */
1950 1953
1951static const struct snd_ice1712_card_info no_matched __devinitdata; 1954static struct snd_ice1712_card_info no_matched __devinitdata;
1952 1955
1953static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 1956static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
1954 snd_vt1724_revo_cards, 1957 snd_vt1724_revo_cards,
1955 snd_vt1724_amp_cards, 1958 snd_vt1724_amp_cards,
1956 snd_vt1724_aureon_cards, 1959 snd_vt1724_aureon_cards,
@@ -2009,7 +2012,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2009{ 2012{
2010 const int dev = 0xa0; /* EEPROM device address */ 2013 const int dev = 0xa0; /* EEPROM device address */
2011 unsigned int i, size; 2014 unsigned int i, size;
2012 const struct snd_ice1712_card_info **tbl, *c; 2015 struct snd_ice1712_card_info * const *tbl, *c;
2013 2016
2014 if (! modelname || ! *modelname) { 2017 if (! modelname || ! *modelname) {
2015 ice->eeprom.subvendor = 0; 2018 ice->eeprom.subvendor = 0;
@@ -2308,7 +2311,7 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2308 struct snd_card *card; 2311 struct snd_card *card;
2309 struct snd_ice1712 *ice; 2312 struct snd_ice1712 *ice;
2310 int pcm_dev = 0, err; 2313 int pcm_dev = 0, err;
2311 const struct snd_ice1712_card_info **tbl, *c; 2314 struct snd_ice1712_card_info * const *tbl, *c;
2312 2315
2313 if (dev >= SNDRV_CARDS) 2316 if (dev >= SNDRV_CARDS)
2314 return -ENODEV; 2317 return -ENODEV;
@@ -2347,6 +2350,14 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2347 } 2350 }
2348 c = &no_matched; 2351 c = &no_matched;
2349 __found: 2352 __found:
2353 /*
2354 * VT1724 has separate DMAs for the analog and the SPDIF streams while
2355 * ICE1712 has only one for both (mixed up).
2356 *
2357 * Confusingly the analog PCM is named "professional" here because it
2358 * was called so in ice1712 driver, and vt1724 driver is derived from
2359 * ice1712 driver.
2360 */
2350 2361
2351 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2362 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) {
2352 snd_card_free(card); 2363 snd_card_free(card);
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index d88172fa95d..3d8e74e493d 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -125,7 +125,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
125 snd_akm4xxx_reset(ak, 0); 125 snd_akm4xxx_reset(ak, 0);
126} 126}
127 127
128static const struct snd_akm4xxx akm_juli_dac __devinitdata = { 128static struct snd_akm4xxx akm_juli_dac __devinitdata = {
129 .type = SND_AK4358, 129 .type = SND_AK4358,
130 .num_dacs = 2, 130 .num_dacs = 2,
131 .ops = { 131 .ops = {
@@ -138,7 +138,16 @@ static const struct snd_akm4xxx akm_juli_dac __devinitdata = {
138 138
139static int __devinit juli_add_controls(struct snd_ice1712 *ice) 139static int __devinit juli_add_controls(struct snd_ice1712 *ice)
140{ 140{
141 return snd_ice1712_akm4xxx_build_controls(ice); 141 int err;
142 err = snd_ice1712_akm4xxx_build_controls(ice);
143 if (err < 0)
144 return err;
145 /* only capture SPDIF over AK4114 */
146 err = snd_ak4114_build(ice->spec.juli.ak4114, NULL,
147 ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
148 if (err < 0)
149 return err;
150 return 0;
142} 151}
143 152
144/* 153/*
@@ -160,13 +169,6 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
160 int err; 169 int err;
161 struct snd_akm4xxx *ak; 170 struct snd_akm4xxx *ak;
162 171
163#if 0
164 for (err = 0; err < 0x20; err++)
165 juli_ak4114_read(ice, err);
166 juli_ak4114_write(ice, 0, 0x0f);
167 juli_ak4114_read(ice, 0);
168 juli_ak4114_read(ice, 1);
169#endif
170 err = snd_ak4114_create(ice->card, 172 err = snd_ak4114_create(ice->card,
171 juli_ak4114_read, 173 juli_ak4114_read,
172 juli_ak4114_write, 174 juli_ak4114_write,
@@ -206,7 +208,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
206 * hence the driver needs to sets up it properly. 208 * hence the driver needs to sets up it properly.
207 */ 209 */
208 210
209static const unsigned char juli_eeprom[] __devinitdata = { 211static unsigned char juli_eeprom[] __devinitdata = {
210 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */ 212 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */
211 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 213 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
212 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 214 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -223,7 +225,7 @@ static const unsigned char juli_eeprom[] __devinitdata = {
223}; 225};
224 226
225/* entry point */ 227/* entry point */
226const struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = { 228struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = {
227 { 229 {
228 .subvendor = VT1724_SUBDEVICE_JULI, 230 .subvendor = VT1724_SUBDEVICE_JULI,
229 .name = "ESI Juli@", 231 .name = "ESI Juli@",
diff --git a/sound/pci/ice1712/juli.h b/sound/pci/ice1712/juli.h
index 1b9294f8bce..d9f8534fd92 100644
--- a/sound/pci/ice1712/juli.h
+++ b/sound/pci/ice1712/juli.h
@@ -5,6 +5,6 @@
5 5
6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */ 6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */
7 7
8extern const struct snd_ice1712_card_info snd_vt1724_juli_cards[]; 8extern struct snd_ice1712_card_info snd_vt1724_juli_cards[];
9 9
10#endif /* __SOUND_JULI_H */ 10#endif /* __SOUND_JULI_H */
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 0751718f4d7..40a9098af77 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -89,13 +89,13 @@ static const unsigned char wm_vol[256] = {
89#define WM_VOL_MAX (sizeof(wm_vol) - 1) 89#define WM_VOL_MAX (sizeof(wm_vol) - 1)
90#define WM_VOL_MUTE 0x8000 90#define WM_VOL_MUTE 0x8000
91 91
92static const struct snd_akm4xxx akm_phase22 __devinitdata = { 92static struct snd_akm4xxx akm_phase22 __devinitdata = {
93 .type = SND_AK4524, 93 .type = SND_AK4524,
94 .num_dacs = 2, 94 .num_dacs = 2,
95 .num_adcs = 2, 95 .num_adcs = 2,
96}; 96};
97 97
98static const struct snd_ak4xxx_private akm_phase22_priv __devinitdata = { 98static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
99 .caddr = 2, 99 .caddr = 2,
100 .cif = 1, 100 .cif = 1,
101 .data_mask = 1 << 4, 101 .data_mask = 1 << 4,
@@ -152,7 +152,7 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
152 return 0; 152 return 0;
153} 153}
154 154
155static const unsigned char phase22_eeprom[] __devinitdata = { 155static unsigned char phase22_eeprom[] __devinitdata = {
156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */ 156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */
157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */ 158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */
@@ -168,7 +168,7 @@ static const unsigned char phase22_eeprom[] __devinitdata = {
168 [ICE_EEP2_GPIO_STATE2] = 0x00, 168 [ICE_EEP2_GPIO_STATE2] = 0x00,
169}; 169};
170 170
171static const unsigned char phase28_eeprom[] __devinitdata = { 171static unsigned char phase28_eeprom[] __devinitdata = {
172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -700,7 +700,7 @@ static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ct
700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); 700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); 701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
702 702
703static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = { 703static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
704 { 704 {
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 .name = "Master Playback Switch", 706 .name = "Master Playback Switch",
@@ -815,7 +815,7 @@ static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
815 } 815 }
816}; 816};
817 817
818static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 818static struct snd_kcontrol_new wm_controls[] __devinitdata = {
819 { 819 {
820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
821 .name = "PCM Playback Switch", 821 .name = "PCM Playback Switch",
@@ -870,7 +870,7 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
870 return 0; 870 return 0;
871} 871}
872 872
873const struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { 873struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
874 { 874 {
875 .subvendor = VT1724_SUBDEVICE_PHASE22, 875 .subvendor = VT1724_SUBDEVICE_PHASE22,
876 .name = "Terratec PHASE 22", 876 .name = "Terratec PHASE 22",
diff --git a/sound/pci/ice1712/phase.h b/sound/pci/ice1712/phase.h
index ad379a99bf9..13e841b5548 100644
--- a/sound/pci/ice1712/phase.h
+++ b/sound/pci/ice1712/phase.h
@@ -31,7 +31,7 @@
31#define VT1724_SUBDEVICE_PHASE28 0x3b154911 31#define VT1724_SUBDEVICE_PHASE28 0x3b154911
32 32
33/* entry point */ 33/* entry point */
34extern const struct snd_ice1712_card_info snd_vt1724_phase_cards[]; 34extern struct snd_ice1712_card_info snd_vt1724_phase_cards[];
35 35
36/* PHASE28 GPIO bits */ 36/* PHASE28 GPIO bits */
37#define PHASE28_SPI_MISO (1 << 21) 37#define PHASE28_SPI_MISO (1 << 21)
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 9552497f076..01c69453dde 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -571,7 +571,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
571 * mixers 571 * mixers
572 */ 572 */
573 573
574static const struct snd_kcontrol_new pontis_controls[] __devinitdata = { 574static struct snd_kcontrol_new pontis_controls[] __devinitdata = {
575 { 575 {
576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -826,7 +826,7 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
826 * hence the driver needs to sets up it properly. 826 * hence the driver needs to sets up it properly.
827 */ 827 */
828 828
829static const unsigned char pontis_eeprom[] __devinitdata = { 829static unsigned char pontis_eeprom[] __devinitdata = {
830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */ 830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */
831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -843,7 +843,7 @@ static const unsigned char pontis_eeprom[] __devinitdata = {
843}; 843};
844 844
845/* entry point */ 845/* entry point */
846const struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = { 846struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = {
847 { 847 {
848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300, 848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300,
849 .name = "Pontis MS300", 849 .name = "Pontis MS300",
diff --git a/sound/pci/ice1712/pontis.h b/sound/pci/ice1712/pontis.h
index 1a418255c19..d0d1378b935 100644
--- a/sound/pci/ice1712/pontis.h
+++ b/sound/pci/ice1712/pontis.h
@@ -28,6 +28,6 @@
28 28
29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */ 29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */
30 30
31extern const struct snd_ice1712_card_info snd_vt1720_pontis_cards[]; 31extern struct snd_ice1712_card_info snd_vt1720_pontis_cards[];
32 32
33#endif /* __SOUND_PONTIS_H */ 33#endif /* __SOUND_PONTIS_H */
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 31cc66eb9f8..4bae7305a79 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -2,6 +2,37 @@
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT) 2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 * 3 *
4 * Lowlevel functions for AudioTrak Prodigy 192 cards 4 * Lowlevel functions for AudioTrak Prodigy 192 cards
5 * Supported IEC958 input from optional MI/ODI/O add-on card.
6 *
7 * Specifics (SW, HW):
8 * -------------------
9 * * 49.5MHz crystal
10 * * SPDIF-OUT on the card:
11 * - coax (through isolation transformer)/toslink supplied by
12 * 74HC04 gates - 3 in parallel
13 * - output switched between on-board CD drive dig-out connector
14 * and ice1724 SPDTX pin, using 74HC02 NOR gates, controlled
15 * by GPIO20 (0 = CD dig-out, 1 = SPDTX)
16 * * SPDTX goes straight to MI/ODI/O card's SPDIF-OUT coax
17 *
18 * * MI/ODI/O card: AK4114 based, used for iec958 input only
19 * - toslink input -> RX0
20 * - coax input -> RX1
21 * - 4wire protocol:
22 * AK4114 ICE1724
23 * ------------------------------
24 * CDTO (pin 32) -- GPIO11 pin 86
25 * CDTI (pin 33) -- GPIO10 pin 77
26 * CCLK (pin 34) -- GPIO9 pin 76
27 * CSN (pin 35) -- GPIO8 pin 75
28 * - output data Mode 7 (24bit, I2S, slave)
29 * - both MCKO1 and MCKO2 of ak4114 are fed to FPGA, which
30 * outputs master clock to SPMCLKIN of ice1724.
31 * Experimentally I found out that only a combination of
32 * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
33 * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
34 * sampling rate. That means the the FPGA doubles the
35 * MCK01 rate.
5 * 36 *
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de> 37 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
7 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca> 38 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
@@ -356,6 +387,47 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
356 return 0; 387 return 0;
357} 388}
358#endif 389#endif
390static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
392{
393 static char *texts[2] = { "Line In", "Mic" };
394
395 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
396 uinfo->count = 1;
397 uinfo->value.enumerated.items = 2;
398
399 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
400 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
401 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
402
403 return 0;
404}
405
406
407static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
409{
410 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
411 unsigned char val;
412
413 val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
414 ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1;
415 return 0;
416}
417
418static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
420{
421 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
422 unsigned char new, old;
423 int change;
424 old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
425 new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80);
426 change = (new != old);
427 if (change)
428 stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
429 return change;
430}
359 431
360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 432static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 433static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -364,7 +436,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
364 * mixers 436 * mixers
365 */ 437 */
366 438
367static const struct snd_kcontrol_new stac_controls[] __devinitdata = { 439static struct snd_kcontrol_new stac_controls[] __devinitdata = {
368 { 440 {
369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
370 .name = "Master Playback Switch", 442 .name = "Master Playback Switch",
@@ -406,7 +478,7 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
406 }, 478 },
407 { 479 {
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 .name = "ADC Switch", 481 .name = "ADC Capture Switch",
410 .count = 1, 482 .count = 1,
411 .info = stac9460_adc_mute_info, 483 .info = stac9460_adc_mute_info,
412 .get = stac9460_adc_mute_get, 484 .get = stac9460_adc_mute_get,
@@ -417,13 +489,21 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
418 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 490 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
419 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 491 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
420 .name = "ADC Volume", 492 .name = "ADC Capture Volume",
421 .count = 1, 493 .count = 1,
422 .info = stac9460_adc_vol_info, 494 .info = stac9460_adc_vol_info,
423 .get = stac9460_adc_vol_get, 495 .get = stac9460_adc_vol_get,
424 .put = stac9460_adc_vol_put, 496 .put = stac9460_adc_vol_put,
425 .tlv = { .p = db_scale_adc } 497 .tlv = { .p = db_scale_adc }
426 }, 498 },
499 {
500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
501 .name = "Analog Capture Input",
502 .info = stac9460_mic_sw_info,
503 .get = stac9460_mic_sw_get,
504 .put = stac9460_mic_sw_put,
505
506 },
427#if 0 507#if 0
428 { 508 {
429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -456,19 +536,261 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
456#endif 536#endif
457}; 537};
458 538
539
540/* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O */
541/* CDTO (pin 32) -- GPIO11 pin 86
542 * CDTI (pin 33) -- GPIO10 pin 77
543 * CCLK (pin 34) -- GPIO9 pin 76
544 * CSN (pin 35) -- GPIO8 pin 75
545 */
546#define AK4114_ADDR 0x00 /* C1-C0: Chip Address
547 * (According to datasheet fixed to “00â€)
548 */
549
550/*
551 * 4wire ak4114 protocol - writing data
552 */
553static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
554 unsigned int data, int idx)
555{
556 for (; idx >= 0; idx--) {
557 /* drop clock */
558 gpio &= ~VT1724_PRODIGY192_CCLK;
559 snd_ice1712_gpio_write(ice, gpio);
560 udelay(1);
561 /* set data */
562 if (data & (1 << idx))
563 gpio |= VT1724_PRODIGY192_CDOUT;
564 else
565 gpio &= ~VT1724_PRODIGY192_CDOUT;
566 snd_ice1712_gpio_write(ice, gpio);
567 udelay(1);
568 /* raise clock */
569 gpio |= VT1724_PRODIGY192_CCLK;
570 snd_ice1712_gpio_write(ice, gpio);
571 udelay(1);
572 }
573}
574
575/*
576 * 4wire ak4114 protocol - reading data
577 */
578static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
579 int idx)
580{
581 unsigned char data = 0;
582
583 for (; idx >= 0; idx--) {
584 /* drop clock */
585 gpio &= ~VT1724_PRODIGY192_CCLK;
586 snd_ice1712_gpio_write(ice, gpio);
587 udelay(1);
588 /* read data */
589 if (snd_ice1712_gpio_read(ice) & VT1724_PRODIGY192_CDIN)
590 data |= (1 << idx);
591 udelay(1);
592 /* raise clock */
593 gpio |= VT1724_PRODIGY192_CCLK;
594 snd_ice1712_gpio_write(ice, gpio);
595 udelay(1);
596 }
597 return data;
598}
599/*
600 * 4wire ak4114 protocol - starting sequence
601 */
602static unsigned int prodigy192_4wire_start(struct snd_ice1712 *ice)
603{
604 unsigned int tmp;
605
606 snd_ice1712_save_gpio_status(ice);
607 tmp = snd_ice1712_gpio_read(ice);
608
609 tmp |= VT1724_PRODIGY192_CCLK; /* high at init */
610 tmp &= ~VT1724_PRODIGY192_CS; /* drop chip select */
611 snd_ice1712_gpio_write(ice, tmp);
612 udelay(1);
613 return tmp;
614}
615
616/*
617 * 4wire ak4114 protocol - final sequence
618 */
619static void prodigy192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
620{
621 tmp |= VT1724_PRODIGY192_CS; /* raise chip select */
622 snd_ice1712_gpio_write(ice, tmp);
623 udelay(1);
624 snd_ice1712_restore_gpio_status(ice);
625}
626
627/*
628 * Write data to addr register of ak4114
629 */
630static void prodigy192_ak4114_write(void *private_data, unsigned char addr,
631 unsigned char data)
632{
633 struct snd_ice1712 *ice = private_data;
634 unsigned int tmp, addrdata;
635 tmp = prodigy192_4wire_start(ice);
636 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
637 addrdata = (addrdata << 8) | data;
638 write_data(ice, tmp, addrdata, 15);
639 prodigy192_4wire_finish(ice, tmp);
640}
641
642/*
643 * Read data from addr register of ak4114
644 */
645static unsigned char prodigy192_ak4114_read(void *private_data,
646 unsigned char addr)
647{
648 struct snd_ice1712 *ice = private_data;
649 unsigned int tmp;
650 unsigned char data;
651
652 tmp = prodigy192_4wire_start(ice);
653 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
654 data = read_data(ice, tmp, 7);
655 prodigy192_4wire_finish(ice, tmp);
656 return data;
657}
658
659
660static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_info *uinfo)
662{
663 static char *texts[2] = { "Toslink", "Coax" };
664
665 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
666 uinfo->count = 1;
667 uinfo->value.enumerated.items = 2;
668 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
669 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
670 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
671 return 0;
672}
673
674
675static int ak4114_input_sw_get(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_value *ucontrol)
677{
678 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
679 unsigned char val;
680
681 val = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
682 /* AK4114_IPS0 bit = 0 -> RX0 = Toslink
683 * AK4114_IPS0 bit = 1 -> RX1 = Coax
684 */
685 ucontrol->value.enumerated.item[0] = (val & AK4114_IPS0) ? 1 : 0;
686 return 0;
687}
688
689static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
693 unsigned char new, old, itemvalue;
694 int change;
695
696 old = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
697 /* AK4114_IPS0 could be any bit */
698 itemvalue = (ucontrol->value.enumerated.item[0]) ? 0xff : 0x00;
699
700 new = (itemvalue & AK4114_IPS0) | (old & ~AK4114_IPS0);
701 change = (new != old);
702 if (change)
703 prodigy192_ak4114_write(ice, AK4114_REG_IO1, new);
704 return change;
705}
706
707
708static struct snd_kcontrol_new ak4114_controls[] __devinitdata = {
709 {
710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
711 .name = "MIODIO IEC958 Capture Input",
712 .info = ak4114_input_sw_info,
713 .get = ak4114_input_sw_get,
714 .put = ak4114_input_sw_put,
715
716 }
717};
718
719
720static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
721{
722 static const unsigned char ak4114_init_vals[] = {
723 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
724 /* ice1724 expects I2S and provides clock,
725 * DEM0 disables the deemphasis filter
726 */
727 AK4114_DIF_I24I2S | AK4114_DEM0 ,
728 AK4114_TX1E,
729 AK4114_EFH_1024 | AK4114_DIT, /* default input RX0 */
730 0,
731 0
732 };
733 static const unsigned char ak4114_init_txcsb[] = {
734 0x41, 0x02, 0x2c, 0x00, 0x00
735 };
736
737 return snd_ak4114_create(ice->card,
738 prodigy192_ak4114_read,
739 prodigy192_ak4114_write,
740 ak4114_init_vals, ak4114_init_txcsb,
741 ice, &ice->spec.prodigy192.ak4114);
742}
743
459static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice) 744static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
460{ 745{
461 unsigned int i; 746 unsigned int i;
462 int err; 747 int err;
463 748
464 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) { 749 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {
465 err = snd_ctl_add(ice->card, snd_ctl_new1(&stac_controls[i], ice)); 750 err = snd_ctl_add(ice->card,
751 snd_ctl_new1(&stac_controls[i], ice));
752 if (err < 0)
753 return err;
754 }
755 if (ice->spec.prodigy192.ak4114) {
756 /* ak4114 is connected */
757 for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {
758 err = snd_ctl_add(ice->card,
759 snd_ctl_new1(&ak4114_controls[i],
760 ice));
761 if (err < 0)
762 return err;
763 }
764 err = snd_ak4114_build(ice->spec.prodigy192.ak4114,
765 NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */
766 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
466 if (err < 0) 767 if (err < 0)
467 return err; 768 return err;
468 } 769 }
469 return 0; 770 return 0;
470} 771}
471 772
773/*
774 * check for presence of MI/ODI/O add-on card with digital inputs
775 */
776static int prodigy192_miodio_exists(struct snd_ice1712 *ice)
777{
778
779 unsigned char orig_value;
780 const unsigned char test_data = 0xd1; /* random value */
781 unsigned char addr = AK4114_REG_INT0_MASK; /* random SAFE address */
782 int exists = 0;
783
784 orig_value = prodigy192_ak4114_read(ice, addr);
785 prodigy192_ak4114_write(ice, addr, test_data);
786 if (prodigy192_ak4114_read(ice, addr) == test_data) {
787 /* ak4114 seems to communicate, apparently exists */
788 /* writing back original value */
789 prodigy192_ak4114_write(ice, addr, orig_value);
790 exists = 1;
791 }
792 return exists;
793}
472 794
473/* 795/*
474 * initialize the chip 796 * initialize the chip
@@ -487,16 +809,30 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
487 (unsigned short)-1 809 (unsigned short)-1
488 }; 810 };
489 const unsigned short *p; 811 const unsigned short *p;
812 int err = 0;
490 813
491 /* prodigy 192 */ 814 /* prodigy 192 */
492 ice->num_total_dacs = 6; 815 ice->num_total_dacs = 6;
493 ice->num_total_adcs = 2; 816 ice->num_total_adcs = 2;
817 ice->vt1720 = 0; /* ice1724, e.g. 23 GPIOs */
494 818
495 /* initialize codec */ 819 /* initialize codec */
496 p = stac_inits_prodigy; 820 p = stac_inits_prodigy;
497 for (; *p != (unsigned short)-1; p += 2) 821 for (; *p != (unsigned short)-1; p += 2)
498 stac9460_put(ice, p[0], p[1]); 822 stac9460_put(ice, p[0], p[1]);
499 823
824 /* MI/ODI/O add on card with AK4114 */
825 if (prodigy192_miodio_exists(ice)) {
826 err = prodigy192_ak4114_init(ice);
827 /* from this moment if err = 0 then
828 * ice->spec.prodigy192.ak4114 should not be null
829 */
830 snd_printdd("AK4114 initialized with status %d\n", err);
831 } else
832 snd_printdd("AK4114 not found\n");
833 if (err < 0)
834 return err;
835
500 return 0; 836 return 0;
501} 837}
502 838
@@ -506,25 +842,31 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
506 * hence the driver needs to sets up it properly. 842 * hence the driver needs to sets up it properly.
507 */ 843 */
508 844
509static const unsigned char prodigy71_eeprom[] __devinitdata = { 845static unsigned char prodigy71_eeprom[] __devinitdata = {
510 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC, 4DACs */ 846 [ICE_EEP2_SYSCONF] = 0x6a, /* 49MHz crystal, mpu401,
847 * spdif-in+ 1 stereo ADC,
848 * 3 stereo DACs
849 */
511 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 850 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
512 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 851 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
513 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 852 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
514 [ICE_EEP2_GPIO_DIR] = 0xff, 853 [ICE_EEP2_GPIO_DIR] = 0xff,
515 [ICE_EEP2_GPIO_DIR1] = 0xff, 854 [ICE_EEP2_GPIO_DIR1] = ~(VT1724_PRODIGY192_CDIN >> 8) ,
516 [ICE_EEP2_GPIO_DIR2] = 0xbf, 855 [ICE_EEP2_GPIO_DIR2] = 0xbf,
517 [ICE_EEP2_GPIO_MASK] = 0x00, 856 [ICE_EEP2_GPIO_MASK] = 0x00,
518 [ICE_EEP2_GPIO_MASK1] = 0x00, 857 [ICE_EEP2_GPIO_MASK1] = 0x00,
519 [ICE_EEP2_GPIO_MASK2] = 0x00, 858 [ICE_EEP2_GPIO_MASK2] = 0x00,
520 [ICE_EEP2_GPIO_STATE] = 0x00, 859 [ICE_EEP2_GPIO_STATE] = 0x00,
521 [ICE_EEP2_GPIO_STATE1] = 0x00, 860 [ICE_EEP2_GPIO_STATE1] = 0x00,
522 [ICE_EEP2_GPIO_STATE2] = 0x00, 861 [ICE_EEP2_GPIO_STATE2] = 0x10, /* GPIO20: 0 = CD drive dig. input
862 * passthrough,
863 * 1 = SPDIF-OUT from ice1724
864 */
523}; 865};
524 866
525 867
526/* entry point */ 868/* entry point */
527const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = { 869struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
528 { 870 {
529 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE, 871 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE,
530 .name = "Audiotrak Prodigy 192", 872 .name = "Audiotrak Prodigy 192",
diff --git a/sound/pci/ice1712/prodigy192.h b/sound/pci/ice1712/prodigy192.h
index 2fa2e62b9e0..16a53b459c7 100644
--- a/sound/pci/ice1712/prodigy192.h
+++ b/sound/pci/ice1712/prodigy192.h
@@ -5,7 +5,15 @@
5#define PRODIGY192_STAC9460_ADDR 0x54 5#define PRODIGY192_STAC9460_ADDR 0x54
6 6
7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */ 7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */
8/*
9 * AudioTrak Prodigy192 GPIO definitions for MI/ODI/O card with
10 * AK4114 (SPDIF-IN)
11 */
12#define VT1724_PRODIGY192_CS (1 << 8) /* GPIO8, pin 75 */
13#define VT1724_PRODIGY192_CCLK (1 << 9) /* GPIO9, pin 76 */
14#define VT1724_PRODIGY192_CDOUT (1 << 10) /* GPIO10, pin 77 */
15#define VT1724_PRODIGY192_CDIN (1 << 11) /* GPIO11, pin 86 */
8 16
9extern const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[]; 17extern struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[];
10 18
11#endif /* __SOUND_PRODIGY192_H */ 19#endif /* __SOUND_PRODIGY192_H */
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 025a7e8497c..d18a31e188a 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -186,7 +186,12 @@ static int revo51_i2c_init(struct snd_ice1712 *ice,
186#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch } 186#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
187 187
188static const struct snd_akm4xxx_dac_channel revo71_front[] = { 188static const struct snd_akm4xxx_dac_channel revo71_front[] = {
189 AK_DAC("PCM Playback Volume", 2) 189 {
190 .name = "PCM Playback Volume",
191 .num_channels = 2,
192 /* front channels DAC supports muting */
193 .switch_name = "PCM Playback Switch",
194 },
190}; 195};
191 196
192static const struct snd_akm4xxx_dac_channel revo71_surround[] = { 197static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
@@ -219,7 +224,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
219 }, 224 },
220}; 225};
221 226
222static const struct snd_akm4xxx akm_revo_front __devinitdata = { 227static struct snd_akm4xxx akm_revo_front __devinitdata = {
223 .type = SND_AK4381, 228 .type = SND_AK4381,
224 .num_dacs = 2, 229 .num_dacs = 2,
225 .ops = { 230 .ops = {
@@ -228,7 +233,7 @@ static const struct snd_akm4xxx akm_revo_front __devinitdata = {
228 .dac_info = revo71_front, 233 .dac_info = revo71_front,
229}; 234};
230 235
231static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 236static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
232 .caddr = 1, 237 .caddr = 1,
233 .cif = 0, 238 .cif = 0,
234 .data_mask = VT1724_REVO_CDOUT, 239 .data_mask = VT1724_REVO_CDOUT,
@@ -240,7 +245,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
240 .mask_flags = 0, 245 .mask_flags = 0,
241}; 246};
242 247
243static const struct snd_akm4xxx akm_revo_surround __devinitdata = { 248static struct snd_akm4xxx akm_revo_surround __devinitdata = {
244 .type = SND_AK4355, 249 .type = SND_AK4355,
245 .idx_offset = 1, 250 .idx_offset = 1,
246 .num_dacs = 6, 251 .num_dacs = 6,
@@ -250,7 +255,7 @@ static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
250 .dac_info = revo71_surround, 255 .dac_info = revo71_surround,
251}; 256};
252 257
253static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 258static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
254 .caddr = 3, 259 .caddr = 3,
255 .cif = 0, 260 .cif = 0,
256 .data_mask = VT1724_REVO_CDOUT, 261 .data_mask = VT1724_REVO_CDOUT,
@@ -262,7 +267,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
262 .mask_flags = 0, 267 .mask_flags = 0,
263}; 268};
264 269
265static const struct snd_akm4xxx akm_revo51 __devinitdata = { 270static struct snd_akm4xxx akm_revo51 __devinitdata = {
266 .type = SND_AK4358, 271 .type = SND_AK4358,
267 .num_dacs = 6, 272 .num_dacs = 6,
268 .ops = { 273 .ops = {
@@ -271,7 +276,7 @@ static const struct snd_akm4xxx akm_revo51 __devinitdata = {
271 .dac_info = revo51_dac, 276 .dac_info = revo51_dac,
272}; 277};
273 278
274static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 279static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
275 .caddr = 2, 280 .caddr = 2,
276 .cif = 0, 281 .cif = 0,
277 .data_mask = VT1724_REVO_CDOUT, 282 .data_mask = VT1724_REVO_CDOUT,
@@ -283,13 +288,13 @@ static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
283 .mask_flags = 0, 288 .mask_flags = 0,
284}; 289};
285 290
286static const struct snd_akm4xxx akm_revo51_adc __devinitdata = { 291static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
287 .type = SND_AK5365, 292 .type = SND_AK5365,
288 .num_adcs = 2, 293 .num_adcs = 2,
289 .adc_info = revo51_adc, 294 .adc_info = revo51_adc,
290}; 295};
291 296
292static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { 297static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
293 .caddr = 2, 298 .caddr = 2,
294 .cif = 0, 299 .cif = 0,
295 .data_mask = VT1724_REVO_CDOUT, 300 .data_mask = VT1724_REVO_CDOUT,
@@ -324,7 +329,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
324 AK_DAC("PCM Playback Volume", 2) 329 AK_DAC("PCM Playback Volume", 2)
325}; 330};
326 331
327static const struct snd_akm4xxx akm_ap192 __devinitdata = { 332static struct snd_akm4xxx akm_ap192 __devinitdata = {
328 .type = SND_AK4358, 333 .type = SND_AK4358,
329 .num_dacs = 2, 334 .num_dacs = 2,
330 .ops = { 335 .ops = {
@@ -333,7 +338,7 @@ static const struct snd_akm4xxx akm_ap192 __devinitdata = {
333 .dac_info = ap192_dac, 338 .dac_info = ap192_dac,
334}; 339};
335 340
336static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = { 341static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
337 .caddr = 2, 342 .caddr = 2,
338 .cif = 0, 343 .cif = 0,
339 .data_mask = VT1724_REVO_CDOUT, 344 .data_mask = VT1724_REVO_CDOUT,
@@ -405,7 +410,7 @@ static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
405 return data; 410 return data;
406} 411}
407 412
408static unsigned char ap192_4wire_start(struct snd_ice1712 *ice) 413static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
409{ 414{
410 unsigned int tmp; 415 unsigned int tmp;
411 416
@@ -454,7 +459,7 @@ static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
454 return data; 459 return data;
455} 460}
456 461
457static int ap192_ak4114_init(struct snd_ice1712 *ice) 462static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
458{ 463{
459 static const unsigned char ak4114_init_vals[] = { 464 static const unsigned char ak4114_init_vals[] = {
460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, 465 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
@@ -582,7 +587,7 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
582} 587}
583 588
584/* entry point */ 589/* entry point */
585const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { 590struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
586 { 591 {
587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71, 592 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
588 .name = "M Audio Revolution-7.1", 593 .name = "M Audio Revolution-7.1",
diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h
index 2a24488fad8..a3ba425911c 100644
--- a/sound/pci/ice1712/revo.h
+++ b/sound/pci/ice1712/revo.h
@@ -34,7 +34,7 @@
34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236 34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236
35 35
36/* entry point */ 36/* entry point */
37extern const struct snd_ice1712_card_info snd_vt1724_revo_cards[]; 37extern struct snd_ice1712_card_info snd_vt1724_revo_cards[];
38 38
39 39
40/* 40/*
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c
index 72b060d63c2..239524158fe 100644
--- a/sound/pci/ice1712/vt1720_mobo.c
+++ b/sound/pci/ice1712/vt1720_mobo.c
@@ -56,7 +56,7 @@ static int __devinit k8x800_add_controls(struct snd_ice1712 *ice)
56 56
57/* EEPROM image */ 57/* EEPROM image */
58 58
59static const unsigned char k8x800_eeprom[] __devinitdata = { 59static unsigned char k8x800_eeprom[] __devinitdata = {
60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
62 [ICE_EEP2_I2S] = 0x00, /* - */ 62 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -72,7 +72,7 @@ static const unsigned char k8x800_eeprom[] __devinitdata = {
72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */ 72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */
73}; 73};
74 74
75static const unsigned char sn25p_eeprom[] __devinitdata = { 75static unsigned char sn25p_eeprom[] __devinitdata = {
76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
78 [ICE_EEP2_I2S] = 0x00, /* - */ 78 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -90,7 +90,7 @@ static const unsigned char sn25p_eeprom[] __devinitdata = {
90 90
91 91
92/* entry point */ 92/* entry point */
93const struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = { 93struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
94 { 94 {
95 .subvendor = VT1720_SUBDEVICE_K8X800, 95 .subvendor = VT1720_SUBDEVICE_K8X800,
96 .name = "Albatron K8X800 Pro II", 96 .name = "Albatron K8X800 Pro II",
diff --git a/sound/pci/ice1712/vt1720_mobo.h b/sound/pci/ice1712/vt1720_mobo.h
index 70af3ad64a5..0b1b0ee1bea 100644
--- a/sound/pci/ice1712/vt1720_mobo.h
+++ b/sound/pci/ice1712/vt1720_mobo.h
@@ -36,6 +36,6 @@
36#define VT1720_SUBDEVICE_9CJS 0x0f272327 36#define VT1720_SUBDEVICE_9CJS 0x0f272327
37#define VT1720_SUBDEVICE_SN25P 0x97123650 37#define VT1720_SUBDEVICE_SN25P 0x97123650
38 38
39extern const struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; 39extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[];
40 40
41#endif /* __SOUND_VT1720_MOBO_H */ 41#endif /* __SOUND_VT1720_MOBO_H */
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c
index 4a706b16a0b..04e535c8542 100644
--- a/sound/pci/ice1712/wtm.c
+++ b/sound/pci/ice1712/wtm.c
@@ -409,7 +409,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
409/* 409/*
410 * Control tabs 410 * Control tabs
411 */ 411 */
412static const struct snd_kcontrol_new stac9640_controls[] __devinitdata = { 412static struct snd_kcontrol_new stac9640_controls[] __devinitdata = {
413 { 413 {
414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
415 .name = "Master Playback Switch", 415 .name = "Master Playback Switch",
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 7cf2dcb9d8d..da9734073db 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1799,6 +1799,18 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1799 }, 1799 },
1800 { 1800 {
1801 .subvendor = 0x1028, 1801 .subvendor = 0x1028,
1802 .subdevice = 0x0186,
1803 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1804 .type = AC97_TUNE_HP_MUTE_LED
1805 },
1806 {
1807 .subvendor = 0x1028,
1808 .subdevice = 0x0188,
1809 .name = "Dell Inspiron 6000",
1810 .type = AC97_TUNE_HP_MUTE_LED /* cf. Malone #41015 */
1811 },
1812 {
1813 .subvendor = 0x1028,
1802 .subdevice = 0x0191, 1814 .subdevice = 0x0191,
1803 .name = "Dell Inspiron 8600", 1815 .name = "Dell Inspiron 8600",
1804 .type = AC97_TUNE_HP_ONLY 1816 .type = AC97_TUNE_HP_ONLY
@@ -1819,7 +1831,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1819 .subvendor = 0x103c, 1831 .subvendor = 0x103c,
1820 .subdevice = 0x088c, 1832 .subdevice = 0x088c,
1821 .name = "HP nc8000", 1833 .name = "HP nc8000",
1822 .type = AC97_TUNE_MUTE_LED 1834 .type = AC97_TUNE_HP_MUTE_LED
1823 }, 1835 },
1824 { 1836 {
1825 .subvendor = 0x103c, 1837 .subvendor = 0x103c,
@@ -1913,6 +1925,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1913 }, 1925 },
1914 { 1926 {
1915 .subvendor = 0x10cf, 1927 .subvendor = 0x10cf,
1928 .subdevice = 0x127e,
1929 .name = "Fujitsu Lifebook C1211D",
1930 .type = AC97_TUNE_HP_ONLY
1931 },
1932 {
1933 .subvendor = 0x10cf,
1916 .subdevice = 0x12ec, 1934 .subdevice = 0x12ec,
1917 .name = "Fujitsu-Siemens 4010", 1935 .name = "Fujitsu-Siemens 4010",
1918 .type = AC97_TUNE_HP_ONLY 1936 .type = AC97_TUNE_HP_ONLY
@@ -2493,6 +2511,7 @@ static int intel8x0_resume(struct pci_dev *pci)
2493 return -EIO; 2511 return -EIO;
2494 } 2512 }
2495 pci_set_master(pci); 2513 pci_set_master(pci);
2514 snd_intel8x0_chip_init(chip, 0);
2496 if (request_irq(pci->irq, snd_intel8x0_interrupt, 2515 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2497 IRQF_SHARED, card->shortname, chip)) { 2516 IRQF_SHARED, card->shortname, chip)) {
2498 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " 2517 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
@@ -2502,7 +2521,6 @@ static int intel8x0_resume(struct pci_dev *pci)
2502 } 2521 }
2503 chip->irq = pci->irq; 2522 chip->irq = pci->irq;
2504 synchronize_irq(chip->irq); 2523 synchronize_irq(chip->irq);
2505 snd_intel8x0_chip_init(chip, 0);
2506 2524
2507 /* re-initialize mixer stuff */ 2525 /* re-initialize mixer stuff */
2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { 2526 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
@@ -2862,16 +2880,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA; 2880 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA;
2863 chip->int_sta_mask = int_sta_masks; 2881 chip->int_sta_mask = int_sta_masks;
2864 2882
2865 /* request irq after initializaing int_sta_mask, etc */
2866 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2867 IRQF_SHARED, card->shortname, chip)) {
2868 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2869 snd_intel8x0_free(chip);
2870 return -EBUSY;
2871 }
2872 chip->irq = pci->irq;
2873 pci_set_master(pci); 2883 pci_set_master(pci);
2874 synchronize_irq(chip->irq);
2875 2884
2876 switch(chip->device_type) { 2885 switch(chip->device_type) {
2877 case DEVICE_INTEL_ICH4: 2886 case DEVICE_INTEL_ICH4:
@@ -2901,6 +2910,15 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2901 return err; 2910 return err;
2902 } 2911 }
2903 2912
2913 /* request irq after initializaing int_sta_mask, etc */
2914 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2915 IRQF_SHARED, card->shortname, chip)) {
2916 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2917 snd_intel8x0_free(chip);
2918 return -EBUSY;
2919 }
2920 chip->irq = pci->irq;
2921
2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2922 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
2905 snd_intel8x0_free(chip); 2923 snd_intel8x0_free(chip);
2906 return err; 2924 return err;
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 21d0899ac38..5338243fb03 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -264,9 +264,7 @@ enum MonitorModeSelector {
264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement 264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement
265 // from the card after sending a command. 265 // from the card after sending a command.
266 266
267#define FIRMWARE_IN_THE_KERNEL 267#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
268
269#ifdef FIRMWARE_IN_THE_KERNEL
270#include "korg1212-firmware.h" 268#include "korg1212-firmware.h"
271static const struct firmware static_dsp_code = { 269static const struct firmware static_dsp_code = {
272 .data = (u8 *)dspCode, 270 .data = (u8 *)dspCode,
@@ -418,6 +416,9 @@ struct snd_korg1212 {
418MODULE_DESCRIPTION("korg1212"); 416MODULE_DESCRIPTION("korg1212");
419MODULE_LICENSE("GPL"); 417MODULE_LICENSE("GPL");
420MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}"); 418MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
419#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
420MODULE_FIRMWARE("korg/k1212.dsp");
421#endif
421 422
422static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 423static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
423static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 424static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2342,26 +2343,25 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2342 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + 2343 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
2343 offsetof(struct KorgSharedBuffer, AdatTimeCode); 2344 offsetof(struct KorgSharedBuffer, AdatTimeCode);
2344 2345
2346#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2347 dsp_code = &static_dsp_code;
2348#else
2345 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); 2349 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
2346 if (err < 0) { 2350 if (err < 0) {
2347 release_firmware(dsp_code); 2351 release_firmware(dsp_code);
2348#ifdef FIRMWARE_IN_THE_KERNEL
2349 dsp_code = &static_dsp_code;
2350#else
2351 snd_printk(KERN_ERR "firmware not available\n"); 2352 snd_printk(KERN_ERR "firmware not available\n");
2352 snd_korg1212_free(korg1212); 2353 snd_korg1212_free(korg1212);
2353 return err; 2354 return err;
2354#endif
2355 } 2355 }
2356#endif
2356 2357
2357 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2358 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2358 dsp_code->size, &korg1212->dma_dsp) < 0) { 2359 dsp_code->size, &korg1212->dma_dsp) < 0) {
2359 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); 2360 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
2360 snd_korg1212_free(korg1212); 2361 snd_korg1212_free(korg1212);
2361#ifdef FIRMWARE_IN_THE_KERNEL 2362#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2362 if (dsp_code != &static_dsp_code) 2363 release_firmware(dsp_code);
2363#endif 2364#endif
2364 release_firmware(dsp_code);
2365 return -ENOMEM; 2365 return -ENOMEM;
2366 } 2366 }
2367 2367
@@ -2371,10 +2371,9 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2371 2371
2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size); 2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
2373 2373
2374#ifdef FIRMWARE_IN_THE_KERNEL 2374#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2375 if (dsp_code != &static_dsp_code) 2375 release_firmware(dsp_code);
2376#endif 2376#endif
2377 release_firmware(dsp_code);
2378 2377
2379 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); 2378 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
2380 2379
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 4526904e3f8..8a5ff1cb536 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -59,6 +59,10 @@ MODULE_SUPPORTED_DEVICE("{{ESS,Maestro3 PCI},"
59 "{ESS,Allegro PCI}," 59 "{ESS,Allegro PCI},"
60 "{ESS,Allegro-1 PCI}," 60 "{ESS,Allegro-1 PCI},"
61 "{ESS,Canyon3D-2/LE PCI}}"); 61 "{ESS,Canyon3D-2/LE PCI}}");
62#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
63MODULE_FIRMWARE("ess/maestro3_assp_kernel.fw");
64MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
65#endif
62 66
63static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 67static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
64static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 68static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2101,9 +2105,7 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2101} 2105}
2102 2106
2103 2107
2104#define FIRMWARE_IN_THE_KERNEL 2108#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2105
2106#ifdef FIRMWARE_IN_THE_KERNEL
2107 2109
2108/* 2110/*
2109 * DSP Code images 2111 * DSP Code images
@@ -2242,7 +2244,7 @@ static const struct firmware assp_minisrc = {
2242 .size = sizeof assp_minisrc_image 2244 .size = sizeof assp_minisrc_image
2243}; 2245};
2244 2246
2245#endif /* FIRMWARE_IN_THE_KERNEL */ 2247#else /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2246 2248
2247#ifdef __LITTLE_ENDIAN 2249#ifdef __LITTLE_ENDIAN
2248static inline void snd_m3_convert_from_le(const struct firmware *fw) { } 2250static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
@@ -2257,6 +2259,8 @@ static void snd_m3_convert_from_le(const struct firmware *fw)
2257} 2259}
2258#endif 2260#endif
2259 2261
2262#endif /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2263
2260 2264
2261/* 2265/*
2262 * initialize ASSP 2266 * initialize ASSP
@@ -2550,14 +2554,10 @@ static int snd_m3_free(struct snd_m3 *chip)
2550 if (chip->iobase) 2554 if (chip->iobase)
2551 pci_release_regions(chip->pci); 2555 pci_release_regions(chip->pci);
2552 2556
2553#ifdef FIRMWARE_IN_THE_KERNEL 2557#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2554 if (chip->assp_kernel_image != &assp_kernel) 2558 release_firmware(chip->assp_kernel_image);
2559 release_firmware(chip->assp_minisrc_image);
2555#endif 2560#endif
2556 release_firmware(chip->assp_kernel_image);
2557#ifdef FIRMWARE_IN_THE_KERNEL
2558 if (chip->assp_minisrc_image != &assp_minisrc)
2559#endif
2560 release_firmware(chip->assp_minisrc_image);
2561 2561
2562 pci_disable_device(chip->pci); 2562 pci_disable_device(chip->pci);
2563 kfree(chip); 2563 kfree(chip);
@@ -2747,29 +2747,29 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2747 return -ENOMEM; 2747 return -ENOMEM;
2748 } 2748 }
2749 2749
2750#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2751 chip->assp_kernel_image = &assp_kernel;
2752#else
2750 err = request_firmware(&chip->assp_kernel_image, 2753 err = request_firmware(&chip->assp_kernel_image,
2751 "ess/maestro3_assp_kernel.fw", &pci->dev); 2754 "ess/maestro3_assp_kernel.fw", &pci->dev);
2752 if (err < 0) { 2755 if (err < 0) {
2753#ifdef FIRMWARE_IN_THE_KERNEL
2754 chip->assp_kernel_image = &assp_kernel;
2755#else
2756 snd_m3_free(chip); 2756 snd_m3_free(chip);
2757 return err; 2757 return err;
2758#endif
2759 } else 2758 } else
2760 snd_m3_convert_from_le(chip->assp_kernel_image); 2759 snd_m3_convert_from_le(chip->assp_kernel_image);
2760#endif
2761 2761
2762#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2763 chip->assp_minisrc_image = &assp_minisrc;
2764#else
2762 err = request_firmware(&chip->assp_minisrc_image, 2765 err = request_firmware(&chip->assp_minisrc_image,
2763 "ess/maestro3_assp_minisrc.fw", &pci->dev); 2766 "ess/maestro3_assp_minisrc.fw", &pci->dev);
2764 if (err < 0) { 2767 if (err < 0) {
2765#ifdef FIRMWARE_IN_THE_KERNEL
2766 chip->assp_minisrc_image = &assp_minisrc;
2767#else
2768 snd_m3_free(chip); 2768 snd_m3_free(chip);
2769 return err; 2769 return err;
2770#endif
2771 } else 2770 } else
2772 snd_m3_convert_from_le(chip->assp_minisrc_image); 2771 snd_m3_convert_from_le(chip->assp_minisrc_image);
2772#endif
2773 2773
2774 if ((err = pci_request_regions(pci, card->driver)) < 0) { 2774 if ((err = pci_request_regions(pci, card->driver)) < 0) {
2775 snd_m3_free(chip); 2775 snd_m3_free(chip);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 21386da3bc8..ac007cec087 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -472,7 +472,7 @@ static int snd_mixart_prepare(struct snd_pcm_substream *subs)
472 struct snd_mixart *chip = snd_pcm_substream_chip(subs); 472 struct snd_mixart *chip = snd_pcm_substream_chip(subs);
473 struct mixart_stream *stream = subs->runtime->private_data; 473 struct mixart_stream *stream = subs->runtime->private_data;
474 474
475 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ 475 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
476 476
477 snd_printdd("snd_mixart_prepare\n"); 477 snd_printdd("snd_mixart_prepare\n");
478 478
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index ca05075c67c..170781a7229 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -24,6 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <linux/vmalloc.h>
27#include <asm/io.h> 28#include <asm/io.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include "mixart.h" 30#include "mixart.h"
@@ -565,6 +566,9 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
565 return 0; 566 return 0;
566} 567}
567 568
569MODULE_FIRMWARE("mixart/miXart8.xlx");
570MODULE_FIRMWARE("mixart/miXart8.elf");
571MODULE_FIRMWARE("mixart/miXart8AES.xlx");
568 572
569#else /* old style firmware loading */ 573#else /* old style firmware loading */
570 574
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 03b3a4792f7..c7621bd770a 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1533,7 +1533,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1533 printk(KERN_ERR " force the driver to load by " 1533 printk(KERN_ERR " force the driver to load by "
1534 "passing in the module parameter\n"); 1534 "passing in the module parameter\n");
1535 printk(KERN_ERR " force_ac97=1\n"); 1535 printk(KERN_ERR " force_ac97=1\n");
1536 printk(KERN_ERR " or try sb16 or cs423x drivers instead.\n"); 1536 printk(KERN_ERR " or try sb16, opl3sa2, or "
1537 "cs423x drivers instead.\n");
1537 err = -ENXIO; 1538 err = -ENXIO;
1538 goto __error; 1539 goto __error;
1539 } 1540 }
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index d97413484ae..f7f6a687f03 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -638,22 +638,22 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) 638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
639{ 639{
640 struct pcxhr_stream *stream; 640 struct pcxhr_stream *stream;
641 struct list_head *pos;
642 struct snd_pcm_substream *s; 641 struct snd_pcm_substream *s;
643 int i;
644 642
645 switch (cmd) { 643 switch (cmd) {
646 case SNDRV_PCM_TRIGGER_START: 644 case SNDRV_PCM_TRIGGER_START:
647 snd_printdd("SNDRV_PCM_TRIGGER_START\n"); 645 snd_printdd("SNDRV_PCM_TRIGGER_START\n");
648 i = 0; 646 if (snd_pcm_stream_linked(subs)) {
649 snd_pcm_group_for_each(pos, subs) { 647 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
650 s = snd_pcm_group_substream_entry(pos); 648 snd_pcm_group_for_each_entry(s, subs) {
651 stream = s->runtime->private_data; 649 stream = s->runtime->private_data;
652 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; 650 stream->status =
653 snd_pcm_trigger_done(s, subs); 651 PCXHR_STREAM_STATUS_SCHEDULE_RUN;
654 i++; 652 snd_pcm_trigger_done(s, subs);
655 } 653 }
656 if (i==1) { 654 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
655 } else {
656 stream = subs->runtime->private_data;
657 snd_printdd("Only one Substream %c %d\n", 657 snd_printdd("Only one Substream %c %d\n",
658 stream->pipe->is_capture ? 'C' : 'P', 658 stream->pipe->is_capture ? 'C' : 'P',
659 stream->pipe->first_audio); 659 stream->pipe->first_audio);
@@ -665,15 +665,11 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
665 if (pcxhr_set_stream_state(stream)) 665 if (pcxhr_set_stream_state(stream))
666 return -EINVAL; 666 return -EINVAL;
667 stream->status = PCXHR_STREAM_STATUS_RUNNING; 667 stream->status = PCXHR_STREAM_STATUS_RUNNING;
668 } else {
669 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
670 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
671 } 668 }
672 break; 669 break;
673 case SNDRV_PCM_TRIGGER_STOP: 670 case SNDRV_PCM_TRIGGER_STOP:
674 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); 671 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
675 snd_pcm_group_for_each(pos, subs) { 672 snd_pcm_group_for_each_entry(s, subs) {
676 s = snd_pcm_group_substream_entry(pos);
677 stream = s->runtime->private_data; 673 stream = s->runtime->private_data;
678 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; 674 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP;
679 if (pcxhr_set_stream_state(stream)) 675 if (pcxhr_set_stream_state(stream))
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index 369c19fea98..d55d8bc90ee 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -356,6 +356,12 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
356 return 0; 356 return 0;
357} 357}
358 358
359MODULE_FIRMWARE("pcxhr/xi_1_882.dat");
360MODULE_FIRMWARE("pcxhr/xc_1_882.dat");
361MODULE_FIRMWARE("pcxhr/e321_512.e56");
362MODULE_FIRMWARE("pcxhr/b321_512.b56");
363MODULE_FIRMWARE("pcxhr/d321_512.d56");
364
359#else /* old style firmware loading */ 365#else /* old style firmware loading */
360 366
361/* pcxhr hwdep interface id string */ 367/* pcxhr hwdep interface id string */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 952625dead5..8e5410483e6 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -117,6 +117,7 @@ MODULE_AUTHOR("Peter Gruber <nokos@gmx.net>");
117MODULE_DESCRIPTION("riptide"); 117MODULE_DESCRIPTION("riptide");
118MODULE_LICENSE("GPL"); 118MODULE_LICENSE("GPL");
119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}"); 119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}");
120MODULE_FIRMWARE("riptide.hex");
120 121
121static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 122static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
122static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 123static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 6bb7ac650ec..618653e2256 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1078,12 +1078,10 @@ static int
1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1079{ 1079{
1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream); 1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream);
1081 struct list_head *pos;
1082 struct snd_pcm_substream *s; 1081 struct snd_pcm_substream *s;
1083 1082
1084 spin_lock(&rme32->lock); 1083 spin_lock(&rme32->lock);
1085 snd_pcm_group_for_each(pos, substream) { 1084 snd_pcm_group_for_each_entry(s, substream) {
1086 s = snd_pcm_group_substream_entry(pos);
1087 if (s != rme32->playback_substream && 1085 if (s != rme32->playback_substream &&
1088 s != rme32->capture_substream) 1086 s != rme32->capture_substream)
1089 continue; 1087 continue;
@@ -1110,8 +1108,7 @@ snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1110 1108
1111 /* prefill playback buffer */ 1109 /* prefill playback buffer */
1112 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) { 1110 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) {
1113 snd_pcm_group_for_each(pos, substream) { 1111 snd_pcm_group_for_each_entry(s, substream) {
1114 s = snd_pcm_group_substream_entry(pos);
1115 if (s == rme32->playback_substream) { 1112 if (s == rme32->playback_substream) {
1116 s->ops->ack(s); 1113 s->ops->ack(s);
1117 break; 1114 break;
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 89b3c7ff503..3b3ef657f73 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -60,6 +60,12 @@ MODULE_LICENSE("GPL");
60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP}," 60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
61 "{RME HDSP-9652}," 61 "{RME HDSP-9652},"
62 "{RME HDSP-9632}}"); 62 "{RME HDSP-9632}}");
63#ifdef HDSP_FW_LOADER
64MODULE_FIRMWARE("multiface_firmware.bin");
65MODULE_FIRMWARE("multiface_firmware_rev11.bin");
66MODULE_FIRMWARE("digiface_firmware.bin");
67MODULE_FIRMWARE("digiface_firmware_rev11.bin");
68#endif
63 69
64#define HDSP_MAX_CHANNELS 26 70#define HDSP_MAX_CHANNELS 26
65#define HDSP_MAX_DS_CHANNELS 14 71#define HDSP_MAX_DS_CHANNELS 14
@@ -275,6 +281,11 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
275#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0) 281#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0)
276#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1) 282#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1)
277#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0) 283#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
284/* RME says n = 104857600000000, but in the windows MADI driver, I see:
285 return 104857600000000 / rate; // 100 MHz
286 return 110100480000000 / rate; // 105 MHz
287*/
288#define DDS_NUMERATOR 104857600000000ULL; /* = 2^20 * 10^8 */
278 289
279#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask) 290#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask)
280#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1) 291#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1)
@@ -1001,11 +1012,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1001 else if (rate >= 56000) 1012 else if (rate >= 56000)
1002 rate /= 2; 1013 rate /= 2;
1003 1014
1004 /* RME says n = 104857600000000, but in the windows MADI driver, I see: 1015 n = DDS_NUMERATOR;
1005// return 104857600000000 / rate; // 100 MHz
1006 return 110100480000000 / rate; // 105 MHz
1007 */
1008 n = 104857600000000ULL; /* = 2^20 * 10^8 */
1009 div64_32(&n, rate, &r); 1016 div64_32(&n, rate, &r);
1010 /* n should be less than 2^32 for being written to FREQ register */ 1017 /* n should be less than 2^32 for being written to FREQ register */
1011 snd_assert((n >> 32) == 0); 1018 snd_assert((n >> 32) == 0);
@@ -3085,11 +3092,83 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3085 return 0; 3092 return 0;
3086} 3093}
3087 3094
3095#define HDSP_DDS_OFFSET(xname, xindex) \
3096{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3097 .name = xname, \
3098 .index = xindex, \
3099 .info = snd_hdsp_info_dds_offset, \
3100 .get = snd_hdsp_get_dds_offset, \
3101 .put = snd_hdsp_put_dds_offset \
3102}
3103
3104static int hdsp_dds_offset(struct hdsp *hdsp)
3105{
3106 u64 n;
3107 u32 r;
3108 unsigned int dds_value = hdsp->dds_value;
3109 int system_sample_rate = hdsp->system_sample_rate;
3110
3111 n = DDS_NUMERATOR;
3112 /*
3113 * dds_value = n / rate
3114 * rate = n / dds_value
3115 */
3116 div64_32(&n, dds_value, &r);
3117 if (system_sample_rate >= 112000)
3118 n *= 4;
3119 else if (system_sample_rate >= 56000)
3120 n *= 2;
3121 return ((int)n) - system_sample_rate;
3122}
3123
3124static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz)
3125{
3126 int rate = hdsp->system_sample_rate + offset_hz;
3127 hdsp_set_dds_value(hdsp, rate);
3128 return 0;
3129}
3130
3131static int snd_hdsp_info_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
3132{
3133 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
3134 uinfo->count = 1;
3135 uinfo->value.integer.min = -5000;
3136 uinfo->value.integer.max = 5000;
3137 return 0;
3138}
3139
3140static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3141{
3142 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3143
3144 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
3145 return 0;
3146}
3147
3148static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3149{
3150 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3151 int change;
3152 int val;
3153
3154 if (!snd_hdsp_use_is_exclusive(hdsp))
3155 return -EBUSY;
3156 val = ucontrol->value.enumerated.item[0];
3157 spin_lock_irq(&hdsp->lock);
3158 if (val != hdsp_dds_offset(hdsp))
3159 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0;
3160 else
3161 change = 0;
3162 spin_unlock_irq(&hdsp->lock);
3163 return change;
3164}
3165
3088static struct snd_kcontrol_new snd_hdsp_9632_controls[] = { 3166static struct snd_kcontrol_new snd_hdsp_9632_controls[] = {
3089HDSP_DA_GAIN("DA Gain", 0), 3167HDSP_DA_GAIN("DA Gain", 0),
3090HDSP_AD_GAIN("AD Gain", 0), 3168HDSP_AD_GAIN("AD Gain", 0),
3091HDSP_PHONE_GAIN("Phones Gain", 0), 3169HDSP_PHONE_GAIN("Phones Gain", 0),
3092HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0) 3170HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0),
3171HDSP_DDS_OFFSET("DDS Sample Rate Offset", 0)
3093}; 3172};
3094 3173
3095static struct snd_kcontrol_new snd_hdsp_controls[] = { 3174static struct snd_kcontrol_new snd_hdsp_controls[] = {
@@ -3780,11 +3859,9 @@ static int snd_hdsp_reset(struct snd_pcm_substream *substream)
3780 else 3859 else
3781 runtime->status->hw_ptr = 0; 3860 runtime->status->hw_ptr = 0;
3782 if (other) { 3861 if (other) {
3783 struct list_head *pos;
3784 struct snd_pcm_substream *s; 3862 struct snd_pcm_substream *s;
3785 struct snd_pcm_runtime *oruntime = other->runtime; 3863 struct snd_pcm_runtime *oruntime = other->runtime;
3786 snd_pcm_group_for_each(pos, substream) { 3864 snd_pcm_group_for_each_entry(s, substream) {
3787 s = snd_pcm_group_substream_entry(pos);
3788 if (s == other) { 3865 if (s == other) {
3789 oruntime->status->hw_ptr = runtime->status->hw_ptr; 3866 oruntime->status->hw_ptr = runtime->status->hw_ptr;
3790 break; 3867 break;
@@ -3933,10 +4010,8 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
3933 other = hdsp->playback_substream; 4010 other = hdsp->playback_substream;
3934 4011
3935 if (other) { 4012 if (other) {
3936 struct list_head *pos;
3937 struct snd_pcm_substream *s; 4013 struct snd_pcm_substream *s;
3938 snd_pcm_group_for_each(pos, substream) { 4014 snd_pcm_group_for_each_entry(s, substream) {
3939 s = snd_pcm_group_substream_entry(pos);
3940 if (s == other) { 4015 if (s == other) {
3941 snd_pcm_trigger_done(s, substream); 4016 snd_pcm_trigger_done(s, substream);
3942 if (cmd == SNDRV_PCM_TRIGGER_START) 4017 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 6e95857e4e6..143185e7e4d 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -91,8 +91,10 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
91#define HDSPM_controlRegister 64 91#define HDSPM_controlRegister 64
92#define HDSPM_interruptConfirmation 96 92#define HDSPM_interruptConfirmation 96
93#define HDSPM_control2Reg 256 /* not in specs ???????? */ 93#define HDSPM_control2Reg 256 /* not in specs ???????? */
94#define HDSPM_freqReg 256 /* for AES32 */
94#define HDSPM_midiDataOut0 352 /* just believe in old code */ 95#define HDSPM_midiDataOut0 352 /* just believe in old code */
95#define HDSPM_midiDataOut1 356 96#define HDSPM_midiDataOut1 356
97#define HDSPM_eeprom_wr 384 /* for AES32 */
96 98
97/* DMA enable for 64 channels, only Bit 0 is relevant */ 99/* DMA enable for 64 channels, only Bit 0 is relevant */
98#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */ 100#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */
@@ -389,9 +391,8 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
389 size is the same regardless of the number of channels, and 391 size is the same regardless of the number of channels, and
390 also the latency to use. 392 also the latency to use.
391 for one direction !!! 393 for one direction !!!
392 => need to mupltiply by 2!!
393*/ 394*/
394#define HDSPM_DMA_AREA_BYTES (2 * HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) 395#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
395#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) 396#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
396 397
397/* revisions >= 230 indicate AES32 card */ 398/* revisions >= 230 indicate AES32 card */
@@ -484,28 +485,6 @@ static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = {
484 56, 57, 58, 59, 60, 61, 62, 63 485 56, 57, 58, 59, 60, 61, 62, 63
485}; 486};
486 487
487static char channel_map_madi_ds[HDSPM_MAX_CHANNELS] = {
488 0, 2, 4, 6, 8, 10, 12, 14,
489 16, 18, 20, 22, 24, 26, 28, 30,
490 32, 34, 36, 38, 40, 42, 44, 46,
491 48, 50, 52, 54, 56, 58, 60, 62,
492 -1, -1, -1, -1, -1, -1, -1, -1,
493 -1, -1, -1, -1, -1, -1, -1, -1,
494 -1, -1, -1, -1, -1, -1, -1, -1,
495 -1, -1, -1, -1, -1, -1, -1, -1
496};
497
498static char channel_map_madi_qs[HDSPM_MAX_CHANNELS] = {
499 0, 4, 8, 12, 16, 20, 24, 28,
500 32, 36, 40, 44, 48, 52, 56, 60
501 -1, -1, -1, -1, -1, -1, -1, -1,
502 -1, -1, -1, -1, -1, -1, -1, -1,
503 -1, -1, -1, -1, -1, -1, -1, -1,
504 -1, -1, -1, -1, -1, -1, -1, -1,
505 -1, -1, -1, -1, -1, -1, -1, -1,
506 -1, -1, -1, -1, -1, -1, -1, -1
507};
508
509 488
510static struct pci_device_id snd_hdspm_ids[] __devinitdata = { 489static struct pci_device_id snd_hdspm_ids[] __devinitdata = {
511 { 490 {
@@ -818,6 +797,27 @@ static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames)
818 return 0; 797 return 0;
819} 798}
820 799
800static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
801{
802 u64 n;
803 u32 r;
804
805 if (rate >= 112000)
806 rate /= 4;
807 else if (rate >= 56000)
808 rate /= 2;
809
810 /* RME says n = 104857600000000, but in the windows MADI driver, I see:
811// return 104857600000000 / rate; // 100 MHz
812 return 110100480000000 / rate; // 105 MHz
813 */
814 //n = 104857600000000ULL; /* = 2^20 * 10^8 */
815 n = 110100480000000ULL; /* Value checked for AES32 and MADI */
816 div64_32(&n, rate, &r);
817 /* n should be less than 2^32 for being written to FREQ register */
818 snd_assert((n >> 32) == 0);
819 hdspm_write(hdspm, HDSPM_freqReg, (u32)n);
820}
821 821
822/* dummy set rate lets see what happens */ 822/* dummy set rate lets see what happens */
823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) 823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
@@ -943,12 +943,16 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
943 hdspm->control_register |= rate_bits; 943 hdspm->control_register |= rate_bits;
944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
945 945
946 if (rate > 96000 /* 64000*/) 946 /* For AES32, need to set DDS value in FREQ register
947 hdspm->channel_map = channel_map_madi_qs; 947 For MADI, also apparently */
948 else if (rate > 48000) 948 hdspm_set_dds_value(hdspm, rate);
949 hdspm->channel_map = channel_map_madi_ds; 949
950 else 950 if (hdspm->is_aes32 && rate != current_rate)
951 hdspm->channel_map = channel_map_madi_ss; 951 hdspm_write(hdspm, HDSPM_eeprom_wr, 0);
952
953 /* For AES32 and for MADI (at least rev 204), channel_map needs to
954 * always be channel_map_madi_ss, whatever the sample rate */
955 hdspm->channel_map = channel_map_madi_ss;
952 956
953 hdspm->system_sample_rate = rate; 957 hdspm->system_sample_rate = rate;
954 958
@@ -3184,8 +3188,8 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
3184 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, 3188 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
3185 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); 3189 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
3186 snd_iprintf(buffer, 3190 snd_iprintf(buffer,
3187 "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n", 3191 "Register: ctrl1=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n",
3188 hdspm->control_register, hdspm->control2_register, 3192 hdspm->control_register,
3189 status, status2, timecode); 3193 status, status2, timecode);
3190 3194
3191 snd_iprintf(buffer, "--- Settings ---\n"); 3195 snd_iprintf(buffer, "--- Settings ---\n");
@@ -3377,13 +3381,16 @@ static int snd_hdspm_set_defaults(struct hdspm * hdspm)
3377 3381
3378 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 3382 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
3379 3383
3384 if (!hdspm->is_aes32) {
3385 /* No control2 register for AES32 */
3380#ifdef SNDRV_BIG_ENDIAN 3386#ifdef SNDRV_BIG_ENDIAN
3381 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; 3387 hdspm->control2_register = HDSPM_BIGENDIAN_MODE;
3382#else 3388#else
3383 hdspm->control2_register = 0; 3389 hdspm->control2_register = 0;
3384#endif 3390#endif
3385 3391
3386 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); 3392 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register);
3393 }
3387 hdspm_compute_period_size(hdspm); 3394 hdspm_compute_period_size(hdspm);
3388 3395
3389 /* silence everything */ 3396 /* silence everything */
@@ -3575,11 +3582,9 @@ static int snd_hdspm_reset(struct snd_pcm_substream *substream)
3575 else 3582 else
3576 runtime->status->hw_ptr = 0; 3583 runtime->status->hw_ptr = 0;
3577 if (other) { 3584 if (other) {
3578 struct list_head *pos;
3579 struct snd_pcm_substream *s; 3585 struct snd_pcm_substream *s;
3580 struct snd_pcm_runtime *oruntime = other->runtime; 3586 struct snd_pcm_runtime *oruntime = other->runtime;
3581 snd_pcm_group_for_each(pos, substream) { 3587 snd_pcm_group_for_each_entry(s, substream) {
3582 s = snd_pcm_group_substream_entry(pos);
3583 if (s == other) { 3588 if (s == other) {
3584 oruntime->status->hw_ptr = 3589 oruntime->status->hw_ptr =
3585 runtime->status->hw_ptr; 3590 runtime->status->hw_ptr;
@@ -3658,11 +3663,10 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3658 3663
3659 /* Memory allocation, takashi's method, dont know if we should spinlock */ 3664 /* Memory allocation, takashi's method, dont know if we should spinlock */
3660 /* malloc all buffer even if not enabled to get sure */ 3665 /* malloc all buffer even if not enabled to get sure */
3661 /* malloc only needed bytes */ 3666 /* Update for MADI rev 204: we need to allocate for all channels,
3667 * otherwise it doesn't work at 96kHz */
3662 err = 3668 err =
3663 snd_pcm_lib_malloc_pages(substream, 3669 snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES);
3664 HDSPM_CHANNEL_BUFFER_BYTES *
3665 params_channels(params));
3666 if (err < 0) 3670 if (err < 0)
3667 return err; 3671 return err;
3668 3672
@@ -3698,6 +3702,13 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3698 "playback" : "capture", 3702 "playback" : "capture",
3699 snd_pcm_sgbuf_get_addr(sgbuf, 0)); 3703 snd_pcm_sgbuf_get_addr(sgbuf, 0));
3700 */ 3704 */
3705 /*
3706 snd_printdd("set_hwparams: %s %d Hz, %d channels, bs = %d\n",
3707 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
3708 "playback" : "capture",
3709 params_rate(params), params_channels(params),
3710 params_buffer_size(params));
3711 */
3701 return 0; 3712 return 0;
3702} 3713}
3703 3714
@@ -3791,10 +3802,8 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
3791 other = hdspm->playback_substream; 3802 other = hdspm->playback_substream;
3792 3803
3793 if (other) { 3804 if (other) {
3794 struct list_head *pos;
3795 struct snd_pcm_substream *s; 3805 struct snd_pcm_substream *s;
3796 snd_pcm_group_for_each(pos, substream) { 3806 snd_pcm_group_for_each_entry(s, substream) {
3797 s = snd_pcm_group_substream_entry(pos);
3798 if (s == other) { 3807 if (s == other) {
3799 snd_pcm_trigger_done(s, substream); 3808 snd_pcm_trigger_done(s, substream);
3800 if (cmd == SNDRV_PCM_TRIGGER_START) 3809 if (cmd == SNDRV_PCM_TRIGGER_START)
@@ -3904,16 +3913,16 @@ static int snd_hdspm_hw_rule_channels_rate(struct snd_pcm_hw_params *params,
3904 struct snd_interval *r = 3913 struct snd_interval *r =
3905 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3914 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3906 3915
3907 if (r->min > 48000) { 3916 if (r->min > 48000 && r->max <= 96000) {
3908 struct snd_interval t = { 3917 struct snd_interval t = {
3909 .min = 1, 3918 .min = hdspm->ds_channels,
3910 .max = hdspm->ds_channels, 3919 .max = hdspm->ds_channels,
3911 .integer = 1, 3920 .integer = 1,
3912 }; 3921 };
3913 return snd_interval_refine(c, &t); 3922 return snd_interval_refine(c, &t);
3914 } else if (r->max < 64000) { 3923 } else if (r->max < 64000) {
3915 struct snd_interval t = { 3924 struct snd_interval t = {
3916 .min = 1, 3925 .min = hdspm->ss_channels,
3917 .max = hdspm->ss_channels, 3926 .max = hdspm->ss_channels,
3918 .integer = 1, 3927 .integer = 1,
3919 }; 3928 };
@@ -3931,14 +3940,14 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3931 struct snd_interval *r = 3940 struct snd_interval *r =
3932 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3941 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3933 3942
3934 if (c->min <= hdspm->ss_channels) { 3943 if (c->min >= hdspm->ss_channels) {
3935 struct snd_interval t = { 3944 struct snd_interval t = {
3936 .min = 32000, 3945 .min = 32000,
3937 .max = 48000, 3946 .max = 48000,
3938 .integer = 1, 3947 .integer = 1,
3939 }; 3948 };
3940 return snd_interval_refine(r, &t); 3949 return snd_interval_refine(r, &t);
3941 } else if (c->max > hdspm->ss_channels) { 3950 } else if (c->max <= hdspm->ds_channels) {
3942 struct snd_interval t = { 3951 struct snd_interval t = {
3943 .min = 64000, 3952 .min = 64000,
3944 .max = 96000, 3953 .max = 96000,
@@ -3950,13 +3959,39 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3950 return 0; 3959 return 0;
3951} 3960}
3952 3961
3962static int snd_hdspm_hw_rule_channels(struct snd_pcm_hw_params *params,
3963 struct snd_pcm_hw_rule *rule)
3964{
3965 unsigned int list[3];
3966 struct hdspm *hdspm = rule->private;
3967 struct snd_interval *c = hw_param_interval(params,
3968 SNDRV_PCM_HW_PARAM_CHANNELS);
3969 if (hdspm->is_aes32) {
3970 list[0] = hdspm->qs_channels;
3971 list[1] = hdspm->ds_channels;
3972 list[2] = hdspm->ss_channels;
3973 return snd_interval_list(c, 3, list, 0);
3974 } else {
3975 list[0] = hdspm->ds_channels;
3976 list[1] = hdspm->ss_channels;
3977 return snd_interval_list(c, 2, list, 0);
3978 }
3979}
3980
3981
3982static unsigned int hdspm_aes32_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
3983
3984static struct snd_pcm_hw_constraint_list hdspm_hw_constraints_aes32_sample_rates = {
3985 .count = ARRAY_SIZE(hdspm_aes32_sample_rates),
3986 .list = hdspm_aes32_sample_rates,
3987 .mask = 0
3988};
3989
3953static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) 3990static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3954{ 3991{
3955 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3992 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3956 struct snd_pcm_runtime *runtime = substream->runtime; 3993 struct snd_pcm_runtime *runtime = substream->runtime;
3957 3994
3958 snd_printdd("Open device substream %d\n", substream->stream);
3959
3960 spin_lock_irq(&hdspm->lock); 3995 spin_lock_irq(&hdspm->lock);
3961 3996
3962 snd_pcm_set_sync(substream); 3997 snd_pcm_set_sync(substream);
@@ -3977,14 +4012,21 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3977 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4012 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
3978 &hw_constraints_period_sizes); 4013 &hw_constraints_period_sizes);
3979 4014
3980 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4015 if (hdspm->is_aes32) {
3981 snd_hdspm_hw_rule_channels_rate, hdspm, 4016 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
3982 SNDRV_PCM_HW_PARAM_RATE, -1); 4017 &hdspm_hw_constraints_aes32_sample_rates);
3983 4018 } else {
3984 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4019 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3985 snd_hdspm_hw_rule_rate_channels, hdspm, 4020 snd_hdspm_hw_rule_channels, hdspm,
3986 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4021 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
3987 4022 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4023 snd_hdspm_hw_rule_channels_rate, hdspm,
4024 SNDRV_PCM_HW_PARAM_RATE, -1);
4025
4026 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4027 snd_hdspm_hw_rule_rate_channels, hdspm,
4028 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4029 }
3988 return 0; 4030 return 0;
3989} 4031}
3990 4032
@@ -4024,14 +4066,21 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
4024 snd_pcm_hw_constraint_list(runtime, 0, 4066 snd_pcm_hw_constraint_list(runtime, 0,
4025 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4067 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
4026 &hw_constraints_period_sizes); 4068 &hw_constraints_period_sizes);
4027 4069 if (hdspm->is_aes32) {
4028 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4070 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4029 snd_hdspm_hw_rule_channels_rate, hdspm, 4071 &hdspm_hw_constraints_aes32_sample_rates);
4030 SNDRV_PCM_HW_PARAM_RATE, -1); 4072 } else {
4031 4073 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4032 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4074 snd_hdspm_hw_rule_channels, hdspm,
4033 snd_hdspm_hw_rule_rate_channels, hdspm, 4075 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4034 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4076 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4077 snd_hdspm_hw_rule_channels_rate, hdspm,
4078 SNDRV_PCM_HW_PARAM_RATE, -1);
4079
4080 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4081 snd_hdspm_hw_rule_rate_channels, hdspm,
4082 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4083 }
4035 return 0; 4084 return 0;
4036} 4085}
4037 4086
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index cc3bdececce..2de27405a0b 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -406,7 +406,7 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
406 } else if (!frag) 406 } else if (!frag)
407 return 0; 407 return 0;
408 offset -= rme9652->max_jitter; 408 offset -= rme9652->max_jitter;
409 if (offset < 0) 409 if ((int)offset < 0)
410 offset += period_size * 2; 410 offset += period_size * 2;
411 } else { 411 } else {
412 if (offset > period_size + rme9652->max_jitter) { 412 if (offset > period_size + rme9652->max_jitter) {
@@ -1992,11 +1992,9 @@ static int snd_rme9652_reset(struct snd_pcm_substream *substream)
1992 else 1992 else
1993 runtime->status->hw_ptr = 0; 1993 runtime->status->hw_ptr = 0;
1994 if (other) { 1994 if (other) {
1995 struct list_head *pos;
1996 struct snd_pcm_substream *s; 1995 struct snd_pcm_substream *s;
1997 struct snd_pcm_runtime *oruntime = other->runtime; 1996 struct snd_pcm_runtime *oruntime = other->runtime;
1998 snd_pcm_group_for_each(pos, substream) { 1997 snd_pcm_group_for_each_entry(s, substream) {
1999 s = snd_pcm_group_substream_entry(pos);
2000 if (s == other) { 1998 if (s == other) {
2001 oruntime->status->hw_ptr = runtime->status->hw_ptr; 1999 oruntime->status->hw_ptr = runtime->status->hw_ptr;
2002 break; 2000 break;
@@ -2140,10 +2138,8 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
2140 other = rme9652->playback_substream; 2138 other = rme9652->playback_substream;
2141 2139
2142 if (other) { 2140 if (other) {
2143 struct list_head *pos;
2144 struct snd_pcm_substream *s; 2141 struct snd_pcm_substream *s;
2145 snd_pcm_group_for_each(pos, substream) { 2142 snd_pcm_group_for_each_entry(s, substream) {
2146 s = snd_pcm_group_substream_entry(pos);
2147 if (s == other) { 2143 if (s == other) {
2148 snd_pcm_trigger_done(s, substream); 2144 snd_pcm_trigger_done(s, substream);
2149 if (cmd == SNDRV_PCM_TRIGGER_START) 2145 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 3bff32167f6..7ca60627246 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -1540,7 +1540,6 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1540 1540
1541{ 1541{
1542 struct snd_trident *trident = snd_pcm_substream_chip(substream); 1542 struct snd_trident *trident = snd_pcm_substream_chip(substream);
1543 struct list_head *pos;
1544 struct snd_pcm_substream *s; 1543 struct snd_pcm_substream *s;
1545 unsigned int what, whati, capture_flag, spdif_flag; 1544 unsigned int what, whati, capture_flag, spdif_flag;
1546 struct snd_trident_voice *voice, *evoice; 1545 struct snd_trident_voice *voice, *evoice;
@@ -1563,8 +1562,7 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1563 what = whati = capture_flag = spdif_flag = 0; 1562 what = whati = capture_flag = spdif_flag = 0;
1564 spin_lock(&trident->reg_lock); 1563 spin_lock(&trident->reg_lock);
1565 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; 1564 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
1566 snd_pcm_group_for_each(pos, substream) { 1565 snd_pcm_group_for_each_entry(s, substream) {
1567 s = snd_pcm_group_substream_entry(pos);
1568 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { 1566 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) {
1569 voice = s->runtime->private_data; 1567 voice = s->runtime->private_data;
1570 evoice = voice->extra; 1568 evoice = voice->extra;
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index a28992269f5..6ea09df0c73 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2098,7 +2098,7 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
2098 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 2098 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
2099 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 2099 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
2100 break; 2100 break;
2101 schedule_timeout_uninterruptible(1); 2101 schedule_timeout(1);
2102 } while (time_before(jiffies, end_time)); 2102 } while (time_before(jiffies, end_time));
2103 2103
2104 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 2104 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -2117,7 +2117,7 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
2117 chip->ac97_secondary = 1; 2117 chip->ac97_secondary = 1;
2118 goto __ac97_ok2; 2118 goto __ac97_ok2;
2119 } 2119 }
2120 schedule_timeout_interruptible(1); 2120 schedule_timeout(1);
2121 } while (time_before(jiffies, end_time)); 2121 } while (time_before(jiffies, end_time));
2122 /* This is ok, the most of motherboards have only one codec */ 2122 /* This is ok, the most of motherboards have only one codec */
2123 2123
@@ -2431,7 +2431,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2431{ 2431{
2432 struct snd_card *card; 2432 struct snd_card *card;
2433 struct via82xx *chip; 2433 struct via82xx *chip;
2434 unsigned char revision;
2435 int chip_type = 0, card_type; 2434 int chip_type = 0, card_type;
2436 unsigned int i; 2435 unsigned int i;
2437 int err; 2436 int err;
@@ -2441,18 +2440,17 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2441 return -ENOMEM; 2440 return -ENOMEM;
2442 2441
2443 card_type = pci_id->driver_data; 2442 card_type = pci_id->driver_data;
2444 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
2445 switch (card_type) { 2443 switch (card_type) {
2446 case TYPE_CARD_VIA686: 2444 case TYPE_CARD_VIA686:
2447 strcpy(card->driver, "VIA686A"); 2445 strcpy(card->driver, "VIA686A");
2448 sprintf(card->shortname, "VIA 82C686A/B rev%x", revision); 2446 sprintf(card->shortname, "VIA 82C686A/B rev%x", pci->revision);
2449 chip_type = TYPE_VIA686; 2447 chip_type = TYPE_VIA686;
2450 break; 2448 break;
2451 case TYPE_CARD_VIA8233: 2449 case TYPE_CARD_VIA8233:
2452 chip_type = TYPE_VIA8233; 2450 chip_type = TYPE_VIA8233;
2453 sprintf(card->shortname, "VIA 823x rev%x", revision); 2451 sprintf(card->shortname, "VIA 823x rev%x", pci->revision);
2454 for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { 2452 for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) {
2455 if (revision == via823x_cards[i].revision) { 2453 if (pci->revision == via823x_cards[i].revision) {
2456 chip_type = via823x_cards[i].type; 2454 chip_type = via823x_cards[i].type;
2457 strcpy(card->shortname, via823x_cards[i].name); 2455 strcpy(card->shortname, via823x_cards[i].name);
2458 break; 2456 break;
@@ -2460,7 +2458,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2460 } 2458 }
2461 if (chip_type != TYPE_VIA8233A) { 2459 if (chip_type != TYPE_VIA8233A) {
2462 if (dxs_support == VIA_DXS_AUTO) 2460 if (dxs_support == VIA_DXS_AUTO)
2463 dxs_support = check_dxs_list(pci, revision); 2461 dxs_support = check_dxs_list(pci, pci->revision);
2464 /* force to use VIA8233 or 8233A model according to 2462 /* force to use VIA8233 or 8233A model according to
2465 * dxs_support module option 2463 * dxs_support module option
2466 */ 2464 */
@@ -2471,7 +2469,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2471 } 2469 }
2472 if (chip_type == TYPE_VIA8233A) 2470 if (chip_type == TYPE_VIA8233A)
2473 strcpy(card->driver, "VIA8233A"); 2471 strcpy(card->driver, "VIA8233A");
2474 else if (revision >= VIA_REV_8237) 2472 else if (pci->revision >= VIA_REV_8237)
2475 strcpy(card->driver, "VIA8237"); /* no slog assignment */ 2473 strcpy(card->driver, "VIA8237"); /* no slog assignment */
2476 else 2474 else
2477 strcpy(card->driver, "VIA8233"); 2475 strcpy(card->driver, "VIA8233");
@@ -2482,7 +2480,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2482 goto __error; 2480 goto __error;
2483 } 2481 }
2484 2482
2485 if ((err = snd_via82xx_create(card, pci, chip_type, revision, 2483 if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision,
2486 ac97_clock, &chip)) < 0) 2484 ac97_clock, &chip)) < 0)
2487 goto __error; 2485 goto __error;
2488 card->private_data = chip; 2486 card->private_data = chip;
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index b338e15db0d..72425e73aba 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -983,7 +983,7 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
983 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 983 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
984 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 984 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
985 break; 985 break;
986 schedule_timeout_uninterruptible(1); 986 schedule_timeout(1);
987 } while (time_before(jiffies, end_time)); 987 } while (time_before(jiffies, end_time));
988 988
989 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 989 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
@@ -1001,7 +1001,7 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
1001 chip->ac97_secondary = 1; 1001 chip->ac97_secondary = 1;
1002 goto __ac97_ok2; 1002 goto __ac97_ok2;
1003 } 1003 }
1004 schedule_timeout_interruptible(1); 1004 schedule_timeout(1);
1005 } while (time_before(jiffies, end_time)); 1005 } while (time_before(jiffies, end_time));
1006 /* This is ok, the most of motherboards have only one codec */ 1006 /* This is ok, the most of motherboards have only one codec */
1007 1007
@@ -1162,7 +1162,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1162{ 1162{
1163 struct snd_card *card; 1163 struct snd_card *card;
1164 struct via82xx_modem *chip; 1164 struct via82xx_modem *chip;
1165 unsigned char revision;
1166 int chip_type = 0, card_type; 1165 int chip_type = 0, card_type;
1167 unsigned int i; 1166 unsigned int i;
1168 int err; 1167 int err;
@@ -1172,7 +1171,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1172 return -ENOMEM; 1171 return -ENOMEM;
1173 1172
1174 card_type = pci_id->driver_data; 1173 card_type = pci_id->driver_data;
1175 pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
1176 switch (card_type) { 1174 switch (card_type) {
1177 case TYPE_CARD_VIA82XX_MODEM: 1175 case TYPE_CARD_VIA82XX_MODEM:
1178 strcpy(card->driver, "VIA82XX-MODEM"); 1176 strcpy(card->driver, "VIA82XX-MODEM");
@@ -1184,7 +1182,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1184 goto __error; 1182 goto __error;
1185 } 1183 }
1186 1184
1187 if ((err = snd_via82xx_create(card, pci, chip_type, revision, 1185 if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision,
1188 ac97_clock, &chip)) < 0) 1186 ac97_clock, &chip)) < 0)
1189 goto __error; 1187 goto __error;
1190 card->private_data = chip; 1188 card->private_data = chip;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index fd12674d039..ab7a81c3570 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -1998,9 +1998,7 @@ static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip)
1998 } 1998 }
1999} 1999}
2000 2000
2001#define FIRMWARE_IN_THE_KERNEL 2001#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2002
2003#ifdef FIRMWARE_IN_THE_KERNEL
2004 2002
2005#include "ymfpci_image.h" 2003#include "ymfpci_image.h"
2006 2004
@@ -2018,6 +2016,24 @@ static struct firmware snd_ymfpci_controller_1e_microcode = {
2018}; 2016};
2019#endif 2017#endif
2020 2018
2019#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2020static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2021{
2022 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2023 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2024 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2025 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
2026 chip->device_id == PCI_DEVICE_ID_YAMAHA_754)
2027 chip->controller_microcode =
2028 &snd_ymfpci_controller_1e_microcode;
2029 else
2030 chip->controller_microcode =
2031 &snd_ymfpci_controller_microcode;
2032 return 0;
2033}
2034
2035#else /* use fw_loader */
2036
2021#ifdef __LITTLE_ENDIAN 2037#ifdef __LITTLE_ENDIAN
2022static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { } 2038static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { }
2023#else 2039#else
@@ -2046,13 +2062,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2046 err = -EINVAL; 2062 err = -EINVAL;
2047 } 2063 }
2048 } 2064 }
2049 if (err < 0) { 2065 if (err < 0)
2050#ifdef FIRMWARE_IN_THE_KERNEL
2051 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2052#else
2053 return err; 2066 return err;
2054#endif
2055 }
2056 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || 2067 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2057 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || 2068 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2058 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || 2069 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
@@ -2069,18 +2080,17 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2069 err = -EINVAL; 2080 err = -EINVAL;
2070 } 2081 }
2071 } 2082 }
2072 if (err < 0) { 2083 if (err < 0)
2073#ifdef FIRMWARE_IN_THE_KERNEL
2074 chip->controller_microcode =
2075 is_1e ? &snd_ymfpci_controller_1e_microcode
2076 : &snd_ymfpci_controller_microcode;
2077#else
2078 return err; 2084 return err;
2079#endif
2080 }
2081 return 0; 2085 return 0;
2082} 2086}
2083 2087
2088MODULE_FIRMWARE("yamaha/ds1_dsp.fw");
2089MODULE_FIRMWARE("yamaha/ds1_ctrl.fw");
2090MODULE_FIRMWARE("yamaha/ds1e_ctrl.fw");
2091
2092#endif
2093
2084static void snd_ymfpci_download_image(struct snd_ymfpci *chip) 2094static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
2085{ 2095{
2086 int i; 2096 int i;
@@ -2259,15 +2269,10 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2259 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2269 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
2260 2270
2261 pci_disable_device(chip->pci); 2271 pci_disable_device(chip->pci);
2262#ifdef FIRMWARE_IN_THE_KERNEL 2272#ifndef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2263 if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode) 2273 release_firmware(chip->dsp_microcode);
2264#endif 2274 release_firmware(chip->controller_microcode);
2265 release_firmware(chip->dsp_microcode);
2266#ifdef FIRMWARE_IN_THE_KERNEL
2267 if (chip->controller_microcode != &snd_ymfpci_controller_microcode &&
2268 chip->controller_microcode != &snd_ymfpci_controller_1e_microcode)
2269#endif 2275#endif
2270 release_firmware(chip->controller_microcode);
2271 kfree(chip); 2276 kfree(chip);
2272 return 0; 2277 return 0;
2273} 2278}
@@ -2399,7 +2404,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
2399 chip->pci = pci; 2404 chip->pci = pci;
2400 chip->irq = -1; 2405 chip->irq = -1;
2401 chip->device_id = pci->device; 2406 chip->device_id = pci->device;
2402 pci_read_config_byte(pci, PCI_REVISION_ID, &chip->rev); 2407 chip->rev = pci->revision;
2403 chip->reg_area_phys = pci_resource_start(pci, 0); 2408 chip->reg_area_phys = pci_resource_start(pci, 0);
2404 chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000); 2409 chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000);
2405 pci_set_master(pci); 2410 pci_set_master(pci);
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 363bcb5f08e..c57e127d9cc 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -297,7 +297,7 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
297 297
298 /* find an empty slot from the card list */ 298 /* find an empty slot from the card list */
299 for (i = 0; i < SNDRV_CARDS; i++) { 299 for (i = 0; i < SNDRV_CARDS; i++) {
300 if (! card_alloc & (1 << i)) 300 if (!(card_alloc & (1 << i)))
301 break; 301 break;
302 } 302 }
303 if (i >= SNDRV_CARDS) { 303 if (i >= SNDRV_CARDS) {
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig
index a3fb1496e4d..cacb0b13688 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -33,3 +33,23 @@ config SND_POWERMAC_AUTO_DRC
33 option. 33 option.
34 34
35endmenu 35endmenu
36
37menu "ALSA PowerPC devices"
38 depends on SND!=n && ( PPC64 || PPC32 )
39
40config SND_PS3
41 tristate "PS3 Audio support"
42 depends on SND && PS3_PS3AV
43 select SND_PCM
44 default m
45 help
46 Say Y here to include support for audio on the PS3
47
48 To compile this driver as a module, choose M here: the module
49 will be called snd_ps3.
50
51config SND_PS3_DEFAULT_START_DELAY
52 int "Startup delay time in ms"
53 depends on SND_PS3
54 default "2000"
55endmenu
diff --git a/sound/ppc/Makefile b/sound/ppc/Makefile
index 4d95c652c8c..eacee2d0675 100644
--- a/sound/ppc/Makefile
+++ b/sound/ppc/Makefile
@@ -6,4 +6,5 @@
6snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o keywest.o beep.o 6snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o keywest.o beep.o
7 7
8# Toplevel Module Dependency 8# Toplevel Module Dependency
9obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o 9obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o
10obj-$(CONFIG_SND_PS3) += snd_ps3.o
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c
index 5f38f670102..a1aa89f2faf 100644
--- a/sound/ppc/beep.c
+++ b/sound/ppc/beep.c
@@ -118,7 +118,7 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type,
118 default: return -1; 118 default: return -1;
119 } 119 }
120 120
121 chip = dev->private; 121 chip = input_get_drvdata(dev);
122 if (! chip || (beep = chip->beep) == NULL) 122 if (! chip || (beep = chip->beep) == NULL)
123 return -1; 123 return -1;
124 124
@@ -239,8 +239,8 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
239 input_dev->evbit[0] = BIT(EV_SND); 239 input_dev->evbit[0] = BIT(EV_SND);
240 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 240 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
241 input_dev->event = snd_pmac_beep_event; 241 input_dev->event = snd_pmac_beep_event;
242 input_dev->private = chip; 242 input_dev->dev.parent = &chip->pdev->dev;
243 input_dev->cdev.dev = &chip->pdev->dev; 243 input_set_drvdata(input_dev, chip);
244 244
245 beep->dev = input_dev; 245 beep->dev = input_dev;
246 beep->buf = dmabuf; 246 beep->buf = dmabuf;
@@ -251,8 +251,8 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
251 err = snd_ctl_add(chip->card, beep_ctl); 251 err = snd_ctl_add(chip->card, beep_ctl);
252 if (err < 0) 252 if (err < 0)
253 goto fail1; 253 goto fail1;
254 254
255 chip->beep = beep; 255 chip->beep = beep;
256 256
257 err = input_register_device(beep->dev); 257 err = input_register_device(beep->dev);
258 if (err) 258 if (err)
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 5a2bef44a2f..7a22f0f3784 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -775,7 +775,8 @@ static int snd_pmac_free(struct snd_pmac *chip)
775 out_le32(&chip->awacs->control, in_le32(&chip->awacs->control) & 0xfff); 775 out_le32(&chip->awacs->control, in_le32(&chip->awacs->control) & 0xfff);
776 } 776 }
777 777
778 snd_pmac_sound_feature(chip, 0); 778 if (chip->node)
779 snd_pmac_sound_feature(chip, 0);
779 780
780 /* clean up mixer if any */ 781 /* clean up mixer if any */
781 if (chip->mixer_free) 782 if (chip->mixer_free)
@@ -925,6 +926,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
925 } 926 }
926 if (! sound) { 927 if (! sound) {
927 of_node_put(chip->node); 928 of_node_put(chip->node);
929 chip->node = NULL;
928 return -ENODEV; 930 return -ENODEV;
929 } 931 }
930 prop = of_get_property(sound, "sub-frame", NULL); 932 prop = of_get_property(sound, "sub-frame", NULL);
@@ -937,7 +939,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
937 printk(KERN_INFO "snd-powermac no longer handles any " 939 printk(KERN_INFO "snd-powermac no longer handles any "
938 "machines with a layout-id property " 940 "machines with a layout-id property "
939 "in the device-tree, use snd-aoa.\n"); 941 "in the device-tree, use snd-aoa.\n");
942 of_node_put(sound);
940 of_node_put(chip->node); 943 of_node_put(chip->node);
944 chip->node = NULL;
941 return -ENODEV; 945 return -ENODEV;
942 } 946 }
943 /* This should be verified on older screamers */ 947 /* This should be verified on older screamers */
@@ -1297,8 +1301,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1297 return 0; 1301 return 0;
1298 1302
1299 __error: 1303 __error:
1300 if (chip->pdev)
1301 pci_dev_put(chip->pdev);
1302 snd_pmac_free(chip); 1304 snd_pmac_free(chip);
1303 return err; 1305 return err;
1304} 1306}
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
new file mode 100644
index 00000000000..1aa0b467599
--- /dev/null
+++ b/sound/ppc/snd_ps3.c
@@ -0,0 +1,1125 @@
1/*
2 * Audio support for PS3
3 * Copyright (C) 2007 Sony Computer Entertainment Inc.
4 * All rights reserved.
5 * Copyright 2006, 2007 Sony Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2 of the Licence.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/init.h>
22#include <linux/slab.h>
23#include <linux/io.h>
24#include <linux/interrupt.h>
25#include <sound/driver.h>
26#include <sound/core.h>
27#include <sound/initval.h>
28#include <sound/pcm.h>
29#include <sound/asound.h>
30#include <sound/memalloc.h>
31#include <sound/pcm_params.h>
32#include <sound/control.h>
33#include <linux/dmapool.h>
34#include <linux/dma-mapping.h>
35#include <asm/firmware.h>
36#include <linux/io.h>
37#include <asm/dma.h>
38#include <asm/lv1call.h>
39#include <asm/ps3.h>
40#include <asm/ps3av.h>
41
42#include "snd_ps3_reg.h"
43#include "snd_ps3.h"
44
45MODULE_LICENSE("GPL v2");
46MODULE_DESCRIPTION("PS3 sound driver");
47MODULE_AUTHOR("Sony Computer Entertainment Inc.");
48
49/* module entries */
50static int __init snd_ps3_init(void);
51static void __exit snd_ps3_exit(void);
52
53/* ALSA snd driver ops */
54static int snd_ps3_pcm_open(struct snd_pcm_substream *substream);
55static int snd_ps3_pcm_close(struct snd_pcm_substream *substream);
56static int snd_ps3_pcm_prepare(struct snd_pcm_substream *substream);
57static int snd_ps3_pcm_trigger(struct snd_pcm_substream *substream,
58 int cmd);
59static snd_pcm_uframes_t snd_ps3_pcm_pointer(struct snd_pcm_substream
60 *substream);
61static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream,
62 struct snd_pcm_hw_params *hw_params);
63static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream);
64
65
66/* ps3_system_bus_driver entries */
67static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev);
68static int snd_ps3_driver_remove(struct ps3_system_bus_device *dev);
69
70/* address setup */
71static int snd_ps3_map_mmio(void);
72static void snd_ps3_unmap_mmio(void);
73static int snd_ps3_allocate_irq(void);
74static void snd_ps3_free_irq(void);
75static void snd_ps3_audio_set_base_addr(uint64_t ioaddr_start);
76
77/* interrupt handler */
78static irqreturn_t snd_ps3_interrupt(int irq, void *dev_id);
79
80
81/* set sampling rate/format */
82static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream);
83/* take effect parameter change */
84static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card);
85/* initialize avsetting and take it effect */
86static int snd_ps3_init_avsetting(struct snd_ps3_card_info *card);
87/* setup dma */
88static int snd_ps3_program_dma(struct snd_ps3_card_info *card,
89 enum snd_ps3_dma_filltype filltype);
90static void snd_ps3_wait_for_dma_stop(struct snd_ps3_card_info *card);
91
92static dma_addr_t v_to_bus(struct snd_ps3_card_info *, void *vaddr, int ch);
93
94
95module_init(snd_ps3_init);
96module_exit(snd_ps3_exit);
97
98/*
99 * global
100 */
101static struct snd_ps3_card_info the_card;
102
103static int snd_ps3_start_delay = CONFIG_SND_PS3_DEFAULT_START_DELAY;
104
105module_param_named(start_delay, snd_ps3_start_delay, uint, 0644);
106MODULE_PARM_DESC(start_delay, "time to insert silent data in milisec");
107
108static int index = SNDRV_DEFAULT_IDX1;
109static char *id = SNDRV_DEFAULT_STR1;
110
111module_param(index, int, 0444);
112MODULE_PARM_DESC(index, "Index value for PS3 soundchip.");
113module_param(id, charp, 0444);
114MODULE_PARM_DESC(id, "ID string for PS3 soundchip.");
115
116
117/*
118 * PS3 audio register access
119 */
120static inline u32 read_reg(unsigned int reg)
121{
122 return in_be32(the_card.mapped_mmio_vaddr + reg);
123}
124static inline void write_reg(unsigned int reg, u32 val)
125{
126 out_be32(the_card.mapped_mmio_vaddr + reg, val);
127}
128static inline void update_reg(unsigned int reg, u32 or_val)
129{
130 u32 newval = read_reg(reg) | or_val;
131 write_reg(reg, newval);
132}
133static inline void update_mask_reg(unsigned int reg, u32 mask, u32 or_val)
134{
135 u32 newval = (read_reg(reg) & mask) | or_val;
136 write_reg(reg, newval);
137}
138
139/*
140 * ALSA defs
141 */
142const static struct snd_pcm_hardware snd_ps3_pcm_hw = {
143 .info = (SNDRV_PCM_INFO_MMAP |
144 SNDRV_PCM_INFO_NONINTERLEAVED |
145 SNDRV_PCM_INFO_MMAP_VALID),
146 .formats = (SNDRV_PCM_FMTBIT_S16_BE |
147 SNDRV_PCM_FMTBIT_S24_BE),
148 .rates = (SNDRV_PCM_RATE_44100 |
149 SNDRV_PCM_RATE_48000 |
150 SNDRV_PCM_RATE_88200 |
151 SNDRV_PCM_RATE_96000),
152 .rate_min = 44100,
153 .rate_max = 96000,
154
155 .channels_min = 2, /* stereo only */
156 .channels_max = 2,
157
158 .buffer_bytes_max = PS3_AUDIO_FIFO_SIZE * 64,
159
160 /* interrupt by four stages */
161 .period_bytes_min = PS3_AUDIO_FIFO_STAGE_SIZE * 4,
162 .period_bytes_max = PS3_AUDIO_FIFO_STAGE_SIZE * 4,
163
164 .periods_min = 16,
165 .periods_max = 32, /* buffer_size_max/ period_bytes_max */
166
167 .fifo_size = PS3_AUDIO_FIFO_SIZE
168};
169
170static struct snd_pcm_ops snd_ps3_pcm_spdif_ops =
171{
172 .open = snd_ps3_pcm_open,
173 .close = snd_ps3_pcm_close,
174 .prepare = snd_ps3_pcm_prepare,
175 .ioctl = snd_pcm_lib_ioctl,
176 .trigger = snd_ps3_pcm_trigger,
177 .pointer = snd_ps3_pcm_pointer,
178 .hw_params = snd_ps3_pcm_hw_params,
179 .hw_free = snd_ps3_pcm_hw_free
180};
181
182static int snd_ps3_verify_dma_stop(struct snd_ps3_card_info *card,
183 int count, int force_stop)
184{
185 int dma_ch, done, retries, stop_forced = 0;
186 uint32_t status;
187
188 for (dma_ch = 0; dma_ch < 8; dma_ch ++) {
189 retries = count;
190 do {
191 status = read_reg(PS3_AUDIO_KICK(dma_ch)) &
192 PS3_AUDIO_KICK_STATUS_MASK;
193 switch (status) {
194 case PS3_AUDIO_KICK_STATUS_DONE:
195 case PS3_AUDIO_KICK_STATUS_NOTIFY:
196 case PS3_AUDIO_KICK_STATUS_CLEAR:
197 case PS3_AUDIO_KICK_STATUS_ERROR:
198 done = 1;
199 break;
200 default:
201 done = 0;
202 udelay(10);
203 }
204 } while (!done && --retries);
205 if (!retries && force_stop) {
206 pr_info("%s: DMA ch %d is not stopped.",
207 __func__, dma_ch);
208 /* last resort. force to stop dma.
209 * NOTE: this cause DMA done interrupts
210 */
211 update_reg(PS3_AUDIO_CONFIG, PS3_AUDIO_CONFIG_CLEAR);
212 stop_forced = 1;
213 }
214 }
215 return stop_forced;
216}
217
218/*
219 * wait for all dma is done.
220 * NOTE: caller should reset card->running before call.
221 * If not, the interrupt handler will re-start DMA,
222 * then DMA is never stopped.
223 */
224static void snd_ps3_wait_for_dma_stop(struct snd_ps3_card_info *card)
225{
226 int stop_forced;
227 /*
228 * wait for the last dma is done
229 */
230
231 /*
232 * expected maximum DMA done time is 5.7ms + something (DMA itself).
233 * 5.7ms is from 16bit/sample 2ch 44.1Khz; the time next
234 * DMA kick event would occur.
235 */
236 stop_forced = snd_ps3_verify_dma_stop(card, 700, 1);
237
238 /*
239 * clear outstanding interrupts.
240 */
241 update_reg(PS3_AUDIO_INTR_0, 0);
242 update_reg(PS3_AUDIO_AX_IS, 0);
243
244 /*
245 *revert CLEAR bit since it will not reset automatically after DMA stop
246 */
247 if (stop_forced)
248 update_mask_reg(PS3_AUDIO_CONFIG, ~PS3_AUDIO_CONFIG_CLEAR, 0);
249 /* ensure the hardware sees changes */
250 wmb();
251}
252
253static void snd_ps3_kick_dma(struct snd_ps3_card_info *card)
254{
255
256 update_reg(PS3_AUDIO_KICK(0), PS3_AUDIO_KICK_REQUEST);
257 /* ensure the hardware sees the change */
258 wmb();
259}
260
261/*
262 * convert virtual addr to ioif bus addr.
263 */
264static dma_addr_t v_to_bus(struct snd_ps3_card_info *card,
265 void * paddr,
266 int ch)
267{
268 return card->dma_start_bus_addr[ch] +
269 (paddr - card->dma_start_vaddr[ch]);
270};
271
272
273/*
274 * increment ring buffer pointer.
275 * NOTE: caller must hold write spinlock
276 */
277static void snd_ps3_bump_buffer(struct snd_ps3_card_info *card,
278 enum snd_ps3_ch ch, size_t byte_count,
279 int stage)
280{
281 if (!stage)
282 card->dma_last_transfer_vaddr[ch] =
283 card->dma_next_transfer_vaddr[ch];
284 card->dma_next_transfer_vaddr[ch] += byte_count;
285 if ((card->dma_start_vaddr[ch] + (card->dma_buffer_size / 2)) <=
286 card->dma_next_transfer_vaddr[ch]) {
287 card->dma_next_transfer_vaddr[ch] = card->dma_start_vaddr[ch];
288 }
289}
290/*
291 * setup dmac to send data to audio and attenuate samples on the ring buffer
292 */
293static int snd_ps3_program_dma(struct snd_ps3_card_info *card,
294 enum snd_ps3_dma_filltype filltype)
295{
296 /* this dmac does not support over 4G */
297 uint32_t dma_addr;
298 int fill_stages, dma_ch, stage;
299 enum snd_ps3_ch ch;
300 uint32_t ch0_kick_event = 0; /* initialize to mute gcc */
301 void *start_vaddr;
302 unsigned long irqsave;
303 int silent = 0;
304
305 switch (filltype) {
306 case SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL:
307 silent = 1;
308 /* intentionally fall thru */
309 case SND_PS3_DMA_FILLTYPE_FIRSTFILL:
310 ch0_kick_event = PS3_AUDIO_KICK_EVENT_ALWAYS;
311 break;
312
313 case SND_PS3_DMA_FILLTYPE_SILENT_RUNNING:
314 silent = 1;
315 /* intentionally fall thru */
316 case SND_PS3_DMA_FILLTYPE_RUNNING:
317 ch0_kick_event = PS3_AUDIO_KICK_EVENT_SERIALOUT0_EMPTY;
318 break;
319 }
320
321 snd_ps3_verify_dma_stop(card, 700, 0);
322 fill_stages = 4;
323 spin_lock_irqsave(&card->dma_lock, irqsave);
324 for (ch = 0; ch < 2; ch++) {
325 start_vaddr = card->dma_next_transfer_vaddr[0];
326 for (stage = 0; stage < fill_stages; stage ++) {
327 dma_ch = stage * 2 + ch;
328 if (silent)
329 dma_addr = card->null_buffer_start_dma_addr;
330 else
331 dma_addr =
332 v_to_bus(card,
333 card->dma_next_transfer_vaddr[ch],
334 ch);
335
336 write_reg(PS3_AUDIO_SOURCE(dma_ch),
337 (PS3_AUDIO_SOURCE_TARGET_SYSTEM_MEMORY |
338 dma_addr));
339
340 /* dst: fixed to 3wire#0 */
341 if (ch == 0)
342 write_reg(PS3_AUDIO_DEST(dma_ch),
343 (PS3_AUDIO_DEST_TARGET_AUDIOFIFO |
344 PS3_AUDIO_AO_3W_LDATA(0)));
345 else
346 write_reg(PS3_AUDIO_DEST(dma_ch),
347 (PS3_AUDIO_DEST_TARGET_AUDIOFIFO |
348 PS3_AUDIO_AO_3W_RDATA(0)));
349
350 /* count always 1 DMA block (1/2 stage = 128 bytes) */
351 write_reg(PS3_AUDIO_DMASIZE(dma_ch), 0);
352 /* bump pointer if needed */
353 if (!silent)
354 snd_ps3_bump_buffer(card, ch,
355 PS3_AUDIO_DMAC_BLOCK_SIZE,
356 stage);
357
358 /* kick event */
359 if (dma_ch == 0)
360 write_reg(PS3_AUDIO_KICK(dma_ch),
361 ch0_kick_event);
362 else
363 write_reg(PS3_AUDIO_KICK(dma_ch),
364 PS3_AUDIO_KICK_EVENT_AUDIO_DMA(dma_ch
365 - 1) |
366 PS3_AUDIO_KICK_REQUEST);
367 }
368 }
369 /* ensure the hardware sees the change */
370 wmb();
371 spin_unlock_irqrestore(&card->dma_lock, irqsave);
372
373 return 0;
374}
375
376/*
377 * audio mute on/off
378 * mute_on : 0 output enabled
379 * 1 mute
380 */
381static int snd_ps3_mute(int mute_on)
382{
383 return ps3av_audio_mute(mute_on);
384}
385
386/*
387 * PCM operators
388 */
389static int snd_ps3_pcm_open(struct snd_pcm_substream *substream)
390{
391 struct snd_pcm_runtime *runtime = substream->runtime;
392 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
393 int pcm_index;
394
395 pcm_index = substream->pcm->device;
396 /* to retrieve substream/runtime in interrupt handler */
397 card->substream = substream;
398
399 runtime->hw = snd_ps3_pcm_hw;
400
401 card->start_delay = snd_ps3_start_delay;
402
403 /* mute off */
404 snd_ps3_mute(0); /* this function sleep */
405
406 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
407 PS3_AUDIO_FIFO_STAGE_SIZE * 4 * 2);
408 return 0;
409};
410
411static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream,
412 struct snd_pcm_hw_params *hw_params)
413{
414 size_t size;
415
416 /* alloc transport buffer */
417 size = params_buffer_bytes(hw_params);
418 snd_pcm_lib_malloc_pages(substream, size);
419 return 0;
420};
421
422static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream,
423 unsigned int delay_ms)
424{
425 int ret;
426 int rate ;
427
428 rate = substream->runtime->rate;
429 ret = snd_pcm_format_size(substream->runtime->format,
430 rate * delay_ms / 1000)
431 * substream->runtime->channels;
432
433 pr_debug(KERN_ERR "%s: time=%d rate=%d bytes=%ld, frames=%d, ret=%d\n",
434 __func__,
435 delay_ms,
436 rate,
437 snd_pcm_format_size(substream->runtime->format, rate),
438 rate * delay_ms / 1000,
439 ret);
440
441 return ret;
442};
443
444static int snd_ps3_pcm_prepare(struct snd_pcm_substream *substream)
445{
446 struct snd_pcm_runtime *runtime = substream->runtime;
447 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
448 unsigned long irqsave;
449
450 if (!snd_ps3_set_avsetting(substream)) {
451 /* some parameter changed */
452 write_reg(PS3_AUDIO_AX_IE,
453 PS3_AUDIO_AX_IE_ASOBEIE(0) |
454 PS3_AUDIO_AX_IE_ASOBUIE(0));
455 /*
456 * let SPDIF device re-lock with SPDIF signal,
457 * start with some silence
458 */
459 card->silent = snd_ps3_delay_to_bytes(substream,
460 card->start_delay) /
461 (PS3_AUDIO_FIFO_STAGE_SIZE * 4); /* every 4 times */
462 }
463
464 /* restart ring buffer pointer */
465 spin_lock_irqsave(&card->dma_lock, irqsave);
466 {
467 card->dma_buffer_size = runtime->dma_bytes;
468
469 card->dma_last_transfer_vaddr[SND_PS3_CH_L] =
470 card->dma_next_transfer_vaddr[SND_PS3_CH_L] =
471 card->dma_start_vaddr[SND_PS3_CH_L] =
472 runtime->dma_area;
473 card->dma_start_bus_addr[SND_PS3_CH_L] = runtime->dma_addr;
474
475 card->dma_last_transfer_vaddr[SND_PS3_CH_R] =
476 card->dma_next_transfer_vaddr[SND_PS3_CH_R] =
477 card->dma_start_vaddr[SND_PS3_CH_R] =
478 runtime->dma_area + (runtime->dma_bytes / 2);
479 card->dma_start_bus_addr[SND_PS3_CH_R] =
480 runtime->dma_addr + (runtime->dma_bytes / 2);
481
482 pr_debug("%s: vaddr=%p bus=%#lx\n", __func__,
483 card->dma_start_vaddr[SND_PS3_CH_L],
484 card->dma_start_bus_addr[SND_PS3_CH_L]);
485
486 }
487 spin_unlock_irqrestore(&card->dma_lock, irqsave);
488
489 /* ensure the hardware sees the change */
490 mb();
491
492 return 0;
493};
494
495static int snd_ps3_pcm_trigger(struct snd_pcm_substream *substream,
496 int cmd)
497{
498 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
499 int ret = 0;
500
501 switch (cmd) {
502 case SNDRV_PCM_TRIGGER_START:
503 /* clear outstanding interrupts */
504 update_reg(PS3_AUDIO_AX_IS, 0);
505
506 spin_lock(&card->dma_lock);
507 {
508 card->running = 1;
509 }
510 spin_unlock(&card->dma_lock);
511
512 snd_ps3_program_dma(card,
513 SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL);
514 snd_ps3_kick_dma(card);
515 while (read_reg(PS3_AUDIO_KICK(7)) &
516 PS3_AUDIO_KICK_STATUS_MASK) {
517 udelay(1);
518 }
519 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_RUNNING);
520 snd_ps3_kick_dma(card);
521 break;
522
523 case SNDRV_PCM_TRIGGER_STOP:
524 spin_lock(&card->dma_lock);
525 {
526 card->running = 0;
527 }
528 spin_unlock(&card->dma_lock);
529 snd_ps3_wait_for_dma_stop(card);
530 break;
531 default:
532 break;
533
534 }
535
536 return ret;
537};
538
539/*
540 * report current pointer
541 */
542static snd_pcm_uframes_t snd_ps3_pcm_pointer(
543 struct snd_pcm_substream *substream)
544{
545 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
546 size_t bytes;
547 snd_pcm_uframes_t ret;
548
549 spin_lock(&card->dma_lock);
550 {
551 bytes = (size_t)(card->dma_last_transfer_vaddr[SND_PS3_CH_L] -
552 card->dma_start_vaddr[SND_PS3_CH_L]);
553 }
554 spin_unlock(&card->dma_lock);
555
556 ret = bytes_to_frames(substream->runtime, bytes * 2);
557
558 return ret;
559};
560
561static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream)
562{
563 int ret;
564 ret = snd_pcm_lib_free_pages(substream);
565 return ret;
566};
567
568static int snd_ps3_pcm_close(struct snd_pcm_substream *substream)
569{
570 /* mute on */
571 snd_ps3_mute(1);
572 return 0;
573};
574
575static void snd_ps3_audio_fixup(struct snd_ps3_card_info *card)
576{
577 /*
578 * avsetting driver seems to never change the followings
579 * so, init them here once
580 */
581
582 /* no dma interrupt needed */
583 write_reg(PS3_AUDIO_INTR_EN_0, 0);
584
585 /* use every 4 buffer empty interrupt */
586 update_mask_reg(PS3_AUDIO_AX_IC,
587 PS3_AUDIO_AX_IC_AASOIMD_MASK,
588 PS3_AUDIO_AX_IC_AASOIMD_EVERY4);
589
590 /* enable 3wire clocks */
591 update_mask_reg(PS3_AUDIO_AO_3WMCTRL,
592 ~(PS3_AUDIO_AO_3WMCTRL_ASOBCLKD_DISABLED |
593 PS3_AUDIO_AO_3WMCTRL_ASOLRCKD_DISABLED),
594 0);
595 update_reg(PS3_AUDIO_AO_3WMCTRL,
596 PS3_AUDIO_AO_3WMCTRL_ASOPLRCK_DEFAULT);
597}
598
599/*
600 * av setting
601 * NOTE: calling this function may generate audio interrupt.
602 */
603static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card)
604{
605 int ret, retries, i;
606 pr_debug("%s: start\n", __func__);
607
608 ret = ps3av_set_audio_mode(card->avs.avs_audio_ch,
609 card->avs.avs_audio_rate,
610 card->avs.avs_audio_width,
611 card->avs.avs_audio_format,
612 card->avs.avs_audio_source);
613 /*
614 * Reset the following unwanted settings:
615 */
616
617 /* disable all 3wire buffers */
618 update_mask_reg(PS3_AUDIO_AO_3WMCTRL,
619 ~(PS3_AUDIO_AO_3WMCTRL_ASOEN(0) |
620 PS3_AUDIO_AO_3WMCTRL_ASOEN(1) |
621 PS3_AUDIO_AO_3WMCTRL_ASOEN(2) |
622 PS3_AUDIO_AO_3WMCTRL_ASOEN(3)),
623 0);
624 wmb(); /* ensure the hardware sees the change */
625 /* wait for actually stopped */
626 retries = 1000;
627 while ((read_reg(PS3_AUDIO_AO_3WMCTRL) &
628 (PS3_AUDIO_AO_3WMCTRL_ASORUN(0) |
629 PS3_AUDIO_AO_3WMCTRL_ASORUN(1) |
630 PS3_AUDIO_AO_3WMCTRL_ASORUN(2) |
631 PS3_AUDIO_AO_3WMCTRL_ASORUN(3))) &&
632 --retries) {
633 udelay(1);
634 }
635
636 /* reset buffer pointer */
637 for (i = 0; i < 4; i++) {
638 update_reg(PS3_AUDIO_AO_3WCTRL(i),
639 PS3_AUDIO_AO_3WCTRL_ASOBRST_RESET);
640 udelay(10);
641 }
642 wmb(); /* ensure the hardware actually start resetting */
643
644 /* enable 3wire#0 buffer */
645 update_reg(PS3_AUDIO_AO_3WMCTRL, PS3_AUDIO_AO_3WMCTRL_ASOEN(0));
646
647
648 /* In 24bit mode,ALSA inserts a zero byte at first byte of per sample */
649 update_mask_reg(PS3_AUDIO_AO_3WCTRL(0),
650 ~PS3_AUDIO_AO_3WCTRL_ASODF,
651 PS3_AUDIO_AO_3WCTRL_ASODF_LSB);
652 update_mask_reg(PS3_AUDIO_AO_SPDCTRL(0),
653 ~PS3_AUDIO_AO_SPDCTRL_SPODF,
654 PS3_AUDIO_AO_SPDCTRL_SPODF_LSB);
655 /* ensure all the setting above is written back to register */
656 wmb();
657 /* avsetting driver altered AX_IE, caller must reset it if you want */
658 pr_debug("%s: end\n", __func__);
659 return ret;
660}
661
662static int snd_ps3_init_avsetting(struct snd_ps3_card_info *card)
663{
664 int ret;
665 pr_debug("%s: start\n", __func__);
666 card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2;
667 card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K;
668 card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16;
669 card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM;
670 card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL;
671
672 ret = snd_ps3_change_avsetting(card);
673
674 snd_ps3_audio_fixup(card);
675
676 /* to start to generate SPDIF signal, fill data */
677 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL);
678 snd_ps3_kick_dma(card);
679 pr_debug("%s: end\n", __func__);
680 return ret;
681}
682
683/*
684 * set sampling rate according to the substream
685 */
686static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream)
687{
688 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
689 struct snd_ps3_avsetting_info avs;
690
691 avs = card->avs;
692
693 pr_debug("%s: called freq=%d width=%d\n", __func__,
694 substream->runtime->rate,
695 snd_pcm_format_width(substream->runtime->format));
696
697 pr_debug("%s: before freq=%d width=%d\n", __func__,
698 card->avs.avs_audio_rate, card->avs.avs_audio_width);
699
700 /* sample rate */
701 switch (substream->runtime->rate) {
702 case 44100:
703 avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_44K;
704 break;
705 case 48000:
706 avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K;
707 break;
708 case 88200:
709 avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_88K;
710 break;
711 case 96000:
712 avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_96K;
713 break;
714 default:
715 pr_info("%s: invalid rate %d\n", __func__,
716 substream->runtime->rate);
717 return 1;
718 }
719
720 /* width */
721 switch (snd_pcm_format_width(substream->runtime->format)) {
722 case 16:
723 avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16;
724 break;
725 case 24:
726 avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_24;
727 break;
728 default:
729 pr_info("%s: invalid width %d\n", __func__,
730 snd_pcm_format_width(substream->runtime->format));
731 return 1;
732 }
733
734 if ((card->avs.avs_audio_width != avs.avs_audio_width) ||
735 (card->avs.avs_audio_rate != avs.avs_audio_rate)) {
736 card->avs = avs;
737 snd_ps3_change_avsetting(card);
738
739 pr_debug("%s: after freq=%d width=%d\n", __func__,
740 card->avs.avs_audio_rate, card->avs.avs_audio_width);
741
742 return 0;
743 } else
744 return 1;
745}
746
747
748
749static int snd_ps3_map_mmio(void)
750{
751 the_card.mapped_mmio_vaddr =
752 ioremap(the_card.ps3_dev->m_region->bus_addr,
753 the_card.ps3_dev->m_region->len);
754
755 if (!the_card.mapped_mmio_vaddr) {
756 pr_info("%s: ioremap 0 failed p=%#lx l=%#lx \n",
757 __func__, the_card.ps3_dev->m_region->lpar_addr,
758 the_card.ps3_dev->m_region->len);
759 return -ENXIO;
760 }
761
762 return 0;
763};
764
765static void snd_ps3_unmap_mmio(void)
766{
767 iounmap(the_card.mapped_mmio_vaddr);
768 the_card.mapped_mmio_vaddr = NULL;
769}
770
771static int snd_ps3_allocate_irq(void)
772{
773 int ret;
774 u64 lpar_addr, lpar_size;
775 u64 __iomem *mapped;
776
777 /* FIXME: move this to device_init (H/W probe) */
778
779 /* get irq outlet */
780 ret = lv1_gpu_device_map(1, &lpar_addr, &lpar_size);
781 if (ret) {
782 pr_info("%s: device map 1 failed %d\n", __func__,
783 ret);
784 return -ENXIO;
785 }
786
787 mapped = ioremap(lpar_addr, lpar_size);
788 if (!mapped) {
789 pr_info("%s: ioremap 1 failed \n", __func__);
790 return -ENXIO;
791 }
792
793 the_card.audio_irq_outlet = in_be64(mapped);
794
795 iounmap(mapped);
796 ret = lv1_gpu_device_unmap(1);
797 if (ret)
798 pr_info("%s: unmap 1 failed\n", __func__);
799
800 /* irq */
801 ret = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY,
802 the_card.audio_irq_outlet,
803 &the_card.irq_no);
804 if (ret) {
805 pr_info("%s:ps3_alloc_irq failed (%d)\n", __func__, ret);
806 return ret;
807 }
808
809 ret = request_irq(the_card.irq_no, snd_ps3_interrupt, IRQF_DISABLED,
810 SND_PS3_DRIVER_NAME, &the_card);
811 if (ret) {
812 pr_info("%s: request_irq failed (%d)\n", __func__, ret);
813 goto cleanup_irq;
814 }
815
816 return 0;
817
818 cleanup_irq:
819 ps3_irq_plug_destroy(the_card.irq_no);
820 return ret;
821};
822
823static void snd_ps3_free_irq(void)
824{
825 free_irq(the_card.irq_no, &the_card);
826 ps3_irq_plug_destroy(the_card.irq_no);
827}
828
829static void snd_ps3_audio_set_base_addr(uint64_t ioaddr_start)
830{
831 uint64_t val;
832 int ret;
833
834 val = (ioaddr_start & (0x0fUL << 32)) >> (32 - 20) |
835 (0x03UL << 24) |
836 (0x0fUL << 12) |
837 (PS3_AUDIO_IOID);
838
839 ret = lv1_gpu_attribute(0x100, 0x007, val, 0, 0);
840 if (ret)
841 pr_info("%s: gpu_attribute failed %d\n", __func__,
842 ret);
843}
844
845static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
846{
847 int ret;
848 u64 lpar_addr, lpar_size;
849
850 BUG_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1));
851 BUG_ON(dev->match_id != PS3_MATCH_ID_SOUND);
852
853 the_card.ps3_dev = dev;
854
855 ret = ps3_open_hv_device(dev);
856
857 if (ret)
858 return -ENXIO;
859
860 /* setup MMIO */
861 ret = lv1_gpu_device_map(2, &lpar_addr, &lpar_size);
862 if (ret) {
863 pr_info("%s: device map 2 failed %d\n", __func__, ret);
864 goto clean_open;
865 }
866 ps3_mmio_region_init(dev, dev->m_region, lpar_addr, lpar_size,
867 PAGE_SHIFT);
868
869 ret = snd_ps3_map_mmio();
870 if (ret)
871 goto clean_dev_map;
872
873 /* setup DMA area */
874 ps3_dma_region_init(dev, dev->d_region,
875 PAGE_SHIFT, /* use system page size */
876 0, /* dma type; not used */
877 NULL,
878 _ALIGN_UP(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
879 dev->d_region->ioid = PS3_AUDIO_IOID;
880
881 ret = ps3_dma_region_create(dev->d_region);
882 if (ret) {
883 pr_info("%s: region_create\n", __func__);
884 goto clean_mmio;
885 }
886
887 snd_ps3_audio_set_base_addr(dev->d_region->bus_addr);
888
889 /* CONFIG_SND_PS3_DEFAULT_START_DELAY */
890 the_card.start_delay = snd_ps3_start_delay;
891
892 /* irq */
893 if (snd_ps3_allocate_irq()) {
894 ret = -ENXIO;
895 goto clean_dma_region;
896 }
897
898 /* create card instance */
899 the_card.card = snd_card_new(index, id, THIS_MODULE, 0);
900 if (!the_card.card) {
901 ret = -ENXIO;
902 goto clean_irq;
903 }
904
905 strcpy(the_card.card->driver, "PS3");
906 strcpy(the_card.card->shortname, "PS3");
907 strcpy(the_card.card->longname, "PS3 sound");
908 /* create PCM devices instance */
909 /* NOTE:this driver works assuming pcm:substream = 1:1 */
910 ret = snd_pcm_new(the_card.card,
911 "SPDIF",
912 0, /* instance index, will be stored pcm.device*/
913 1, /* output substream */
914 0, /* input substream */
915 &(the_card.pcm));
916 if (ret)
917 goto clean_card;
918
919 the_card.pcm->private_data = &the_card;
920 strcpy(the_card.pcm->name, "SPDIF");
921
922 /* set pcm ops */
923 snd_pcm_set_ops(the_card.pcm, SNDRV_PCM_STREAM_PLAYBACK,
924 &snd_ps3_pcm_spdif_ops);
925
926 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED;
927 /* pre-alloc PCM DMA buffer*/
928 ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm,
929 SNDRV_DMA_TYPE_DEV,
930 &dev->core,
931 SND_PS3_PCM_PREALLOC_SIZE,
932 SND_PS3_PCM_PREALLOC_SIZE);
933 if (ret < 0) {
934 pr_info("%s: prealloc failed\n", __func__);
935 goto clean_card;
936 }
937
938 /*
939 * allocate null buffer
940 * its size should be lager than PS3_AUDIO_FIFO_STAGE_SIZE * 2
941 * PAGE_SIZE is enogh
942 */
943 if (!(the_card.null_buffer_start_vaddr =
944 dma_alloc_coherent(&the_card.ps3_dev->core,
945 PAGE_SIZE,
946 &the_card.null_buffer_start_dma_addr,
947 GFP_KERNEL))) {
948 pr_info("%s: nullbuffer alloc failed\n", __func__);
949 goto clean_preallocate;
950 }
951 pr_debug("%s: null vaddr=%p dma=%#lx\n", __func__,
952 the_card.null_buffer_start_vaddr,
953 the_card.null_buffer_start_dma_addr);
954 /* set default sample rate/word width */
955 snd_ps3_init_avsetting(&the_card);
956
957 /* register the card */
958 ret = snd_card_register(the_card.card);
959 if (ret < 0)
960 goto clean_dma_map;
961
962 pr_info("%s started. start_delay=%dms\n",
963 the_card.card->longname, the_card.start_delay);
964 return 0;
965
966clean_dma_map:
967 dma_free_coherent(&the_card.ps3_dev->core,
968 PAGE_SIZE,
969 the_card.null_buffer_start_vaddr,
970 the_card.null_buffer_start_dma_addr);
971clean_preallocate:
972 snd_pcm_lib_preallocate_free_for_all(the_card.pcm);
973clean_card:
974 snd_card_free(the_card.card);
975clean_irq:
976 snd_ps3_free_irq();
977clean_dma_region:
978 ps3_dma_region_free(dev->d_region);
979clean_mmio:
980 snd_ps3_unmap_mmio();
981clean_dev_map:
982 lv1_gpu_device_unmap(2);
983clean_open:
984 ps3_close_hv_device(dev);
985 /*
986 * there is no destructor function to pcm.
987 * midlayer automatically releases if the card removed
988 */
989 return ret;
990}; /* snd_ps3_probe */
991
992/* called when module removal */
993static int snd_ps3_driver_remove(struct ps3_system_bus_device *dev)
994{
995 int ret;
996 pr_info("%s:start id=%d\n", __func__, dev->match_id);
997 if (dev->match_id != PS3_MATCH_ID_SOUND)
998 return -ENXIO;
999
1000 /*
1001 * ctl and preallocate buffer will be freed in
1002 * snd_card_free
1003 */
1004 ret = snd_card_free(the_card.card);
1005 if (ret)
1006 pr_info("%s: ctl freecard=%d\n", __func__, ret);
1007
1008 dma_free_coherent(&dev->core,
1009 PAGE_SIZE,
1010 the_card.null_buffer_start_vaddr,
1011 the_card.null_buffer_start_dma_addr);
1012
1013 ps3_dma_region_free(dev->d_region);
1014
1015 snd_ps3_free_irq();
1016 snd_ps3_unmap_mmio();
1017
1018 lv1_gpu_device_unmap(2);
1019 ps3_close_hv_device(dev);
1020 pr_info("%s:end id=%d\n", __func__, dev->match_id);
1021 return 0;
1022} /* snd_ps3_remove */
1023
1024static struct ps3_system_bus_driver snd_ps3_bus_driver_info = {
1025 .match_id = PS3_MATCH_ID_SOUND,
1026 .probe = snd_ps3_driver_probe,
1027 .remove = snd_ps3_driver_remove,
1028 .shutdown = snd_ps3_driver_remove,
1029 .core = {
1030 .name = SND_PS3_DRIVER_NAME,
1031 .owner = THIS_MODULE,
1032 },
1033};
1034
1035
1036/*
1037 * Interrupt handler
1038 */
1039static irqreturn_t snd_ps3_interrupt(int irq, void *dev_id)
1040{
1041
1042 uint32_t port_intr;
1043 int underflow_occured = 0;
1044 struct snd_ps3_card_info *card = dev_id;
1045
1046 if (!card->running) {
1047 update_reg(PS3_AUDIO_AX_IS, 0);
1048 update_reg(PS3_AUDIO_INTR_0, 0);
1049 return IRQ_HANDLED;
1050 }
1051
1052 port_intr = read_reg(PS3_AUDIO_AX_IS);
1053 /*
1054 *serial buffer empty detected (every 4 times),
1055 *program next dma and kick it
1056 */
1057 if (port_intr & PS3_AUDIO_AX_IE_ASOBEIE(0)) {
1058 write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBEIE(0));
1059 if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) {
1060 write_reg(PS3_AUDIO_AX_IS, port_intr);
1061 underflow_occured = 1;
1062 }
1063 if (card->silent) {
1064 /* we are still in silent time */
1065 snd_ps3_program_dma(card,
1066 (underflow_occured) ?
1067 SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL :
1068 SND_PS3_DMA_FILLTYPE_SILENT_RUNNING);
1069 snd_ps3_kick_dma(card);
1070 card->silent --;
1071 } else {
1072 snd_ps3_program_dma(card,
1073 (underflow_occured) ?
1074 SND_PS3_DMA_FILLTYPE_FIRSTFILL :
1075 SND_PS3_DMA_FILLTYPE_RUNNING);
1076 snd_ps3_kick_dma(card);
1077 snd_pcm_period_elapsed(card->substream);
1078 }
1079 } else if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) {
1080 write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBUIE(0));
1081 /*
1082 * serial out underflow, but buffer empty not detected.
1083 * in this case, fill fifo with 0 to recover. After
1084 * filling dummy data, serial automatically start to
1085 * consume them and then will generate normal buffer
1086 * empty interrupts.
1087 * If both buffer underflow and buffer empty are occured,
1088 * it is better to do nomal data transfer than empty one
1089 */
1090 snd_ps3_program_dma(card,
1091 SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL);
1092 snd_ps3_kick_dma(card);
1093 snd_ps3_program_dma(card,
1094 SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL);
1095 snd_ps3_kick_dma(card);
1096 }
1097 /* clear interrupt cause */
1098 return IRQ_HANDLED;
1099};
1100
1101/*
1102 * module/subsystem initialize/terminate
1103 */
1104static int __init snd_ps3_init(void)
1105{
1106 int ret;
1107
1108 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
1109 return -ENXIO;
1110
1111 memset(&the_card, 0, sizeof(the_card));
1112 spin_lock_init(&the_card.dma_lock);
1113
1114 /* register systembus DRIVER, this calls our probe() func */
1115 ret = ps3_system_bus_driver_register(&snd_ps3_bus_driver_info);
1116
1117 return ret;
1118}
1119
1120static void __exit snd_ps3_exit(void)
1121{
1122 ps3_system_bus_driver_unregister(&snd_ps3_bus_driver_info);
1123}
1124
1125MODULE_ALIAS(PS3_MODULE_ALIAS_SOUND);
diff --git a/sound/ppc/snd_ps3.h b/sound/ppc/snd_ps3.h
new file mode 100644
index 00000000000..4b7e6fbbe50
--- /dev/null
+++ b/sound/ppc/snd_ps3.h
@@ -0,0 +1,135 @@
1/*
2 * Audio support for PS3
3 * Copyright (C) 2007 Sony Computer Entertainment Inc.
4 * All rights reserved.
5 * Copyright 2006, 2007 Sony Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2 of the Licence.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#if !defined(_SND_PS3_H_)
22#define _SND_PS3_H_
23
24#include <linux/irqreturn.h>
25
26#define SND_PS3_DRIVER_NAME "snd_ps3"
27
28enum snd_ps3_out_channel {
29 SND_PS3_OUT_SPDIF_0,
30 SND_PS3_OUT_SPDIF_1,
31 SND_PS3_OUT_SERIAL_0,
32 SND_PS3_OUT_DEVS
33};
34
35enum snd_ps3_dma_filltype {
36 SND_PS3_DMA_FILLTYPE_FIRSTFILL,
37 SND_PS3_DMA_FILLTYPE_RUNNING,
38 SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL,
39 SND_PS3_DMA_FILLTYPE_SILENT_RUNNING
40};
41
42enum snd_ps3_ch {
43 SND_PS3_CH_L = 0,
44 SND_PS3_CH_R = 1,
45 SND_PS3_CH_MAX = 2
46};
47
48struct snd_ps3_avsetting_info {
49 uint32_t avs_audio_ch; /* fixed */
50 uint32_t avs_audio_rate;
51 uint32_t avs_audio_width;
52 uint32_t avs_audio_format; /* fixed */
53 uint32_t avs_audio_source; /* fixed */
54};
55/*
56 * PS3 audio 'card' instance
57 * there should be only ONE hardware.
58 */
59struct snd_ps3_card_info {
60 struct ps3_system_bus_device *ps3_dev;
61 struct snd_card *card;
62
63 struct snd_pcm *pcm;
64 struct snd_pcm_substream *substream;
65
66 /* hvc info */
67 u64 audio_lpar_addr;
68 u64 audio_lpar_size;
69
70 /* registers */
71 void __iomem *mapped_mmio_vaddr;
72
73 /* irq */
74 u64 audio_irq_outlet;
75 unsigned int irq_no;
76
77 /* remember avsetting */
78 struct snd_ps3_avsetting_info avs;
79
80 /* dma buffer management */
81 spinlock_t dma_lock;
82 /* dma_lock start */
83 void * dma_start_vaddr[2]; /* 0 for L, 1 for R */
84 dma_addr_t dma_start_bus_addr[2];
85 size_t dma_buffer_size;
86 void * dma_last_transfer_vaddr[2];
87 void * dma_next_transfer_vaddr[2];
88 int silent;
89 /* dma_lock end */
90
91 int running;
92
93 /* null buffer */
94 void *null_buffer_start_vaddr;
95 dma_addr_t null_buffer_start_dma_addr;
96
97 /* start delay */
98 unsigned int start_delay;
99
100};
101
102
103/* PS3 audio DMAC block size in bytes */
104#define PS3_AUDIO_DMAC_BLOCK_SIZE (128)
105/* one stage (stereo) of audio FIFO in bytes */
106#define PS3_AUDIO_FIFO_STAGE_SIZE (256)
107/* how many stages the fifo have */
108#define PS3_AUDIO_FIFO_STAGE_COUNT (8)
109/* fifo size 128 bytes * 8 stages * stereo (2ch) */
110#define PS3_AUDIO_FIFO_SIZE \
111 (PS3_AUDIO_FIFO_STAGE_SIZE * PS3_AUDIO_FIFO_STAGE_COUNT)
112
113/* PS3 audio DMAC max block count in one dma shot = 128 (0x80) blocks*/
114#define PS3_AUDIO_DMAC_MAX_BLOCKS (PS3_AUDIO_DMASIZE_BLOCKS_MASK + 1)
115
116#define PS3_AUDIO_NORMAL_DMA_START_CH (0)
117#define PS3_AUDIO_NORMAL_DMA_COUNT (8)
118#define PS3_AUDIO_NULL_DMA_START_CH \
119 (PS3_AUDIO_NORMAL_DMA_START_CH + PS3_AUDIO_NORMAL_DMA_COUNT)
120#define PS3_AUDIO_NULL_DMA_COUNT (2)
121
122#define SND_PS3_MAX_VOL (0x0F)
123#define SND_PS3_MIN_VOL (0x00)
124#define SND_PS3_MIN_ATT SND_PS3_MIN_VOL
125#define SND_PS3_MAX_ATT SND_PS3_MAX_VOL
126
127#define SND_PS3_PCM_PREALLOC_SIZE \
128 (PS3_AUDIO_DMAC_BLOCK_SIZE * PS3_AUDIO_DMAC_MAX_BLOCKS * 4)
129
130#define SND_PS3_DMA_REGION_SIZE \
131 (SND_PS3_PCM_PREALLOC_SIZE + PAGE_SIZE)
132
133#define PS3_AUDIO_IOID (1UL)
134
135#endif /* _SND_PS3_H_ */
diff --git a/sound/ppc/snd_ps3_reg.h b/sound/ppc/snd_ps3_reg.h
new file mode 100644
index 00000000000..03fdee4aaaf
--- /dev/null
+++ b/sound/ppc/snd_ps3_reg.h
@@ -0,0 +1,891 @@
1/*
2 * Audio support for PS3
3 * Copyright (C) 2007 Sony Computer Entertainment Inc.
4 * Copyright 2006, 2007 Sony Corporation
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * interrupt / configure registers
23 */
24
25#define PS3_AUDIO_INTR_0 (0x00000100)
26#define PS3_AUDIO_INTR_EN_0 (0x00000140)
27#define PS3_AUDIO_CONFIG (0x00000200)
28
29/*
30 * DMAC registers
31 * n:0..9
32 */
33#define PS3_AUDIO_DMAC_REGBASE(x) (0x0000210 + 0x20 * (x))
34
35#define PS3_AUDIO_KICK(n) (PS3_AUDIO_DMAC_REGBASE(n) + 0x00)
36#define PS3_AUDIO_SOURCE(n) (PS3_AUDIO_DMAC_REGBASE(n) + 0x04)
37#define PS3_AUDIO_DEST(n) (PS3_AUDIO_DMAC_REGBASE(n) + 0x08)
38#define PS3_AUDIO_DMASIZE(n) (PS3_AUDIO_DMAC_REGBASE(n) + 0x0C)
39
40/*
41 * mute control
42 */
43#define PS3_AUDIO_AX_MCTRL (0x00004000)
44#define PS3_AUDIO_AX_ISBP (0x00004004)
45#define PS3_AUDIO_AX_AOBP (0x00004008)
46#define PS3_AUDIO_AX_IC (0x00004010)
47#define PS3_AUDIO_AX_IE (0x00004014)
48#define PS3_AUDIO_AX_IS (0x00004018)
49
50/*
51 * three wire serial
52 * n:0..3
53 */
54#define PS3_AUDIO_AO_MCTRL (0x00006000)
55#define PS3_AUDIO_AO_3WMCTRL (0x00006004)
56
57#define PS3_AUDIO_AO_3WCTRL(n) (0x00006200 + 0x200 * (n))
58
59/*
60 * S/PDIF
61 * n:0..1
62 * x:0..11
63 * y:0..5
64 */
65#define PS3_AUDIO_AO_SPD_REGBASE(n) (0x00007200 + 0x200 * (n))
66
67#define PS3_AUDIO_AO_SPDCTRL(n) \
68 (PS3_AUDIO_AO_SPD_REGBASE(n) + 0x00)
69#define PS3_AUDIO_AO_SPDUB(n, x) \
70 (PS3_AUDIO_AO_SPD_REGBASE(n) + 0x04 + 0x04 * (x))
71#define PS3_AUDIO_AO_SPDCS(n, y) \
72 (PS3_AUDIO_AO_SPD_REGBASE(n) + 0x34 + 0x04 * (y))
73
74
75/*
76 PS3_AUDIO_INTR_0 register tells an interrupt handler which audio
77 DMA channel triggered the interrupt. The interrupt status for a channel
78 can be cleared by writing a '1' to the corresponding bit. A new interrupt
79 cannot be generated until the previous interrupt has been cleared.
80
81 Note that the status reported by PS3_AUDIO_INTR_0 is independent of the
82 value of PS3_AUDIO_INTR_EN_0.
83
84 31 24 23 16 15 8 7 0
85 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
86 |0 0 0 0 0 0 0 0 0 0 0 0 0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C| INTR_0
87 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
88*/
89#define PS3_AUDIO_INTR_0_CHAN(n) (1 << ((n) * 2))
90#define PS3_AUDIO_INTR_0_CHAN9 PS3_AUDIO_INTR_0_CHAN(9)
91#define PS3_AUDIO_INTR_0_CHAN8 PS3_AUDIO_INTR_0_CHAN(8)
92#define PS3_AUDIO_INTR_0_CHAN7 PS3_AUDIO_INTR_0_CHAN(7)
93#define PS3_AUDIO_INTR_0_CHAN6 PS3_AUDIO_INTR_0_CHAN(6)
94#define PS3_AUDIO_INTR_0_CHAN5 PS3_AUDIO_INTR_0_CHAN(5)
95#define PS3_AUDIO_INTR_0_CHAN4 PS3_AUDIO_INTR_0_CHAN(4)
96#define PS3_AUDIO_INTR_0_CHAN3 PS3_AUDIO_INTR_0_CHAN(3)
97#define PS3_AUDIO_INTR_0_CHAN2 PS3_AUDIO_INTR_0_CHAN(2)
98#define PS3_AUDIO_INTR_0_CHAN1 PS3_AUDIO_INTR_0_CHAN(1)
99#define PS3_AUDIO_INTR_0_CHAN0 PS3_AUDIO_INTR_0_CHAN(0)
100
101/*
102 The PS3_AUDIO_INTR_EN_0 register specifies which DMA channels can generate
103 an interrupt to the PU. Each bit of PS3_AUDIO_INTR_EN_0 is ANDed with the
104 corresponding bit in PS3_AUDIO_INTR_0. The resulting bits are OR'd together
105 to generate the Audio interrupt.
106
107 31 24 23 16 15 8 7 0
108 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
109 |0 0 0 0 0 0 0 0 0 0 0 0 0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C|0|C| INTR_EN_0
110 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
111
112 Bit assignments are same as PS3_AUDIO_INTR_0
113*/
114
115/*
116 PS3_AUDIO_CONFIG
117 31 24 23 16 15 8 7 0
118 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
119 |0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 C|0 0 0 0 0 0 0 0| CONFIG
120 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
121
122*/
123
124/* The CLEAR field cancels all pending transfers, and stops any running DMA
125 transfers. Any interrupts associated with the canceled transfers
126 will occur as if the transfer had finished.
127 Since this bit is designed to recover from DMA related issues
128 which are caused by unpredictable situations, it is prefered to wait
129 for normal DMA transfer end without using this bit.
130*/
131#define PS3_AUDIO_CONFIG_CLEAR (1 << 8) /* RWIVF */
132
133/*
134 PS3_AUDIO_AX_MCTRL: Audio Port Mute Control Register
135
136 31 24 23 16 15 8 7 0
137 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
138 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|A|A|A|0 0 0 0 0 0 0|S|S|A|A|A|A| AX_MCTRL
139 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
140*/
141
142/* 3 Wire Audio Serial Output Channel Mutes (0..3) */
143#define PS3_AUDIO_AX_MCTRL_ASOMT(n) (1 << (3 - (n))) /* RWIVF */
144#define PS3_AUDIO_AX_MCTRL_ASO3MT (1 << 0) /* RWIVF */
145#define PS3_AUDIO_AX_MCTRL_ASO2MT (1 << 1) /* RWIVF */
146#define PS3_AUDIO_AX_MCTRL_ASO1MT (1 << 2) /* RWIVF */
147#define PS3_AUDIO_AX_MCTRL_ASO0MT (1 << 3) /* RWIVF */
148
149/* S/PDIF mutes (0,1)*/
150#define PS3_AUDIO_AX_MCTRL_SPOMT(n) (1 << (5 - (n))) /* RWIVF */
151#define PS3_AUDIO_AX_MCTRL_SPO1MT (1 << 4) /* RWIVF */
152#define PS3_AUDIO_AX_MCTRL_SPO0MT (1 << 5) /* RWIVF */
153
154/* All 3 Wire Serial Outputs Mute */
155#define PS3_AUDIO_AX_MCTRL_AASOMT (1 << 13) /* RWIVF */
156
157/* All S/PDIF Mute */
158#define PS3_AUDIO_AX_MCTRL_ASPOMT (1 << 14) /* RWIVF */
159
160/* All Audio Outputs Mute */
161#define PS3_AUDIO_AX_MCTRL_AAOMT (1 << 15) /* RWIVF */
162
163/*
164 S/PDIF Outputs Buffer Read/Write Pointer Register
165
166 31 24 23 16 15 8 7 0
167 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
168 |0 0 0 0 0 0 0 0|0|SPO0B|0|SPO1B|0 0 0 0 0 0 0 0|0|SPO0B|0|SPO1B| AX_ISBP
169 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
170
171*/
172/*
173 S/PDIF Output Channel Read Buffer Numbers
174 Buffer number is value of field.
175 Indicates current read access buffer ID from Audio Data
176 Transfer controller of S/PDIF Output
177*/
178
179#define PS3_AUDIO_AX_ISBP_SPOBRN_MASK(n) (0x7 << 4 * (1 - (n))) /* R-IUF */
180#define PS3_AUDIO_AX_ISBP_SPO1BRN_MASK (0x7 << 0) /* R-IUF */
181#define PS3_AUDIO_AX_ISBP_SPO0BRN_MASK (0x7 << 4) /* R-IUF */
182
183/*
184S/PDIF Output Channel Buffer Write Numbers
185Indicates current write access buffer ID from bus master.
186*/
187#define PS3_AUDIO_AX_ISBP_SPOBWN_MASK(n) (0x7 << 4 * (5 - (n))) /* R-IUF */
188#define PS3_AUDIO_AX_ISBP_SPO1BWN_MASK (0x7 << 16) /* R-IUF */
189#define PS3_AUDIO_AX_ISBP_SPO0BWN_MASK (0x7 << 20) /* R-IUF */
190
191/*
192 3 Wire Audio Serial Outputs Buffer Read/Write
193 Pointer Register
194 Buffer number is value of field
195
196 31 24 23 16 15 8 7 0
197 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
198 |0|ASO0B|0|ASO1B|0|ASO2B|0|ASO3B|0|ASO0B|0|ASO1B|0|ASO2B|0|ASO3B| AX_AOBP
199 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
200*/
201
202/*
2033 Wire Audio Serial Output Channel Buffer Read Numbers
204Indicates current read access buffer Id from Audio Data Transfer
205Controller of 3 Wire Audio Serial Output Channels
206*/
207#define PS3_AUDIO_AX_AOBP_ASOBRN_MASK(n) (0x7 << 4 * (3 - (n))) /* R-IUF */
208
209#define PS3_AUDIO_AX_AOBP_ASO3BRN_MASK (0x7 << 0) /* R-IUF */
210#define PS3_AUDIO_AX_AOBP_ASO2BRN_MASK (0x7 << 4) /* R-IUF */
211#define PS3_AUDIO_AX_AOBP_ASO1BRN_MASK (0x7 << 8) /* R-IUF */
212#define PS3_AUDIO_AX_AOBP_ASO0BRN_MASK (0x7 << 12) /* R-IUF */
213
214/*
2153 Wire Audio Serial Output Channel Buffer Write Numbers
216Indicates current write access buffer ID from bus master.
217*/
218#define PS3_AUDIO_AX_AOBP_ASOBWN_MASK(n) (0x7 << 4 * (7 - (n))) /* R-IUF */
219
220#define PS3_AUDIO_AX_AOBP_ASO3BWN_MASK (0x7 << 16) /* R-IUF */
221#define PS3_AUDIO_AX_AOBP_ASO2BWN_MASK (0x7 << 20) /* R-IUF */
222#define PS3_AUDIO_AX_AOBP_ASO1BWN_MASK (0x7 << 24) /* R-IUF */
223#define PS3_AUDIO_AX_AOBP_ASO0BWN_MASK (0x7 << 28) /* R-IUF */
224
225
226
227/*
228Audio Port Interrupt Condition Register
229For the fields in this register, the following values apply:
2300 = Interrupt is generated every interrupt event.
2311 = Interrupt is generated every 2 interrupt events.
2322 = Interrupt is generated every 4 interrupt events.
2333 = Reserved
234
235
236 31 24 23 16 15 8 7 0
237 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
238 |0 0 0 0 0 0 0 0|0 0|SPO|0 0|SPO|0 0|AAS|0 0 0 0 0 0 0 0 0 0 0 0| AX_IC
239 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
240*/
241/*
242All 3-Wire Audio Serial Outputs Interrupt Mode
243Configures the Interrupt and Signal Notification
244condition of all 3-wire Audio Serial Outputs.
245*/
246#define PS3_AUDIO_AX_IC_AASOIMD_MASK (0x3 << 12) /* RWIVF */
247#define PS3_AUDIO_AX_IC_AASOIMD_EVERY1 (0x0 << 12) /* RWI-V */
248#define PS3_AUDIO_AX_IC_AASOIMD_EVERY2 (0x1 << 12) /* RW--V */
249#define PS3_AUDIO_AX_IC_AASOIMD_EVERY4 (0x2 << 12) /* RW--V */
250
251/*
252S/PDIF Output Channel Interrupt Modes
253Configures the Interrupt and signal Notification
254conditions of S/PDIF output channels.
255*/
256#define PS3_AUDIO_AX_IC_SPO1IMD_MASK (0x3 << 16) /* RWIVF */
257#define PS3_AUDIO_AX_IC_SPO1IMD_EVERY1 (0x0 << 16) /* RWI-V */
258#define PS3_AUDIO_AX_IC_SPO1IMD_EVERY2 (0x1 << 16) /* RW--V */
259#define PS3_AUDIO_AX_IC_SPO1IMD_EVERY4 (0x2 << 16) /* RW--V */
260
261#define PS3_AUDIO_AX_IC_SPO0IMD_MASK (0x3 << 20) /* RWIVF */
262#define PS3_AUDIO_AX_IC_SPO0IMD_EVERY1 (0x0 << 20) /* RWI-V */
263#define PS3_AUDIO_AX_IC_SPO0IMD_EVERY2 (0x1 << 20) /* RW--V */
264#define PS3_AUDIO_AX_IC_SPO0IMD_EVERY4 (0x2 << 20) /* RW--V */
265
266/*
267Audio Port interrupt Enable Register
268Configures whether to enable or disable each Interrupt Generation.
269
270
271 31 24 23 16 15 8 7 0
272 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
273 |0 0 0 0 0 0 0 0|S|S|0 0|A|A|A|A|0 0 0 0|S|S|0 0|S|S|0 0|A|A|A|A| AX_IE
274 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
275
276*/
277
278/*
2793 Wire Audio Serial Output Channel Buffer Underflow
280Interrupt Enables
281Select enable/disable of Buffer Underflow Interrupts for
2823-Wire Audio Serial Output Channels
283DISABLED=Interrupt generation disabled.
284*/
285#define PS3_AUDIO_AX_IE_ASOBUIE(n) (1 << (3 - (n))) /* RWIVF */
286#define PS3_AUDIO_AX_IE_ASO3BUIE (1 << 0) /* RWIVF */
287#define PS3_AUDIO_AX_IE_ASO2BUIE (1 << 1) /* RWIVF */
288#define PS3_AUDIO_AX_IE_ASO1BUIE (1 << 2) /* RWIVF */
289#define PS3_AUDIO_AX_IE_ASO0BUIE (1 << 3) /* RWIVF */
290
291/* S/PDIF Output Channel Buffer Underflow Interrupt Enables */
292
293#define PS3_AUDIO_AX_IE_SPOBUIE(n) (1 << (7 - (n))) /* RWIVF */
294#define PS3_AUDIO_AX_IE_SPO1BUIE (1 << 6) /* RWIVF */
295#define PS3_AUDIO_AX_IE_SPO0BUIE (1 << 7) /* RWIVF */
296
297/* S/PDIF Output Channel One Block Transfer Completion Interrupt Enables */
298
299#define PS3_AUDIO_AX_IE_SPOBTCIE(n) (1 << (11 - (n))) /* RWIVF */
300#define PS3_AUDIO_AX_IE_SPO1BTCIE (1 << 10) /* RWIVF */
301#define PS3_AUDIO_AX_IE_SPO0BTCIE (1 << 11) /* RWIVF */
302
303/* 3-Wire Audio Serial Output Channel Buffer Empty Interrupt Enables */
304
305#define PS3_AUDIO_AX_IE_ASOBEIE(n) (1 << (19 - (n))) /* RWIVF */
306#define PS3_AUDIO_AX_IE_ASO3BEIE (1 << 16) /* RWIVF */
307#define PS3_AUDIO_AX_IE_ASO2BEIE (1 << 17) /* RWIVF */
308#define PS3_AUDIO_AX_IE_ASO1BEIE (1 << 18) /* RWIVF */
309#define PS3_AUDIO_AX_IE_ASO0BEIE (1 << 19) /* RWIVF */
310
311/* S/PDIF Output Channel Buffer Empty Interrupt Enables */
312
313#define PS3_AUDIO_AX_IE_SPOBEIE(n) (1 << (23 - (n))) /* RWIVF */
314#define PS3_AUDIO_AX_IE_SPO1BEIE (1 << 22) /* RWIVF */
315#define PS3_AUDIO_AX_IE_SPO0BEIE (1 << 23) /* RWIVF */
316
317/*
318Audio Port Interrupt Status Register
319Indicates Interrupt status, which interrupt has occured, and can clear
320each interrupt in this register.
321Writing 1b to a field containing 1b clears field and de-asserts interrupt.
322Writing 0b to a field has no effect.
323Field vaules are the following:
3240 - Interrupt hasn't occured.
3251 - Interrupt has occured.
326
327
328 31 24 23 16 15 8 7 0
329 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
330 |0 0 0 0 0 0 0 0|S|S|0 0|A|A|A|A|0 0 0 0|S|S|0 0|S|S|0 0|A|A|A|A| AX_IS
331 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
332
333 Bit assignment are same as AX_IE
334*/
335
336/*
337Audio Output Master Control Register
338Configures Master Clock and other master Audio Output Settings
339
340
341 31 24 23 16 15 8 7 0
342 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
343 |0|SCKSE|0|SCKSE| MR0 | MR1 |MCL|MCL|0 0 0 0|0 0 0 0 0 0 0 0| AO_MCTRL
344 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
345*/
346
347/*
348MCLK Output Control
349Controls mclko[1] output.
3500 - Disable output (fixed at High)
3511 - Output clock produced by clock selected
352with scksel1 by mr1
3532 - Reserved
3543 - Reserved
355*/
356
357#define PS3_AUDIO_AO_MCTRL_MCLKC1_MASK (0x3 << 12) /* RWIVF */
358#define PS3_AUDIO_AO_MCTRL_MCLKC1_DISABLED (0x0 << 12) /* RWI-V */
359#define PS3_AUDIO_AO_MCTRL_MCLKC1_ENABLED (0x1 << 12) /* RW--V */
360#define PS3_AUDIO_AO_MCTRL_MCLKC1_RESVD2 (0x2 << 12) /* RW--V */
361#define PS3_AUDIO_AO_MCTRL_MCLKC1_RESVD3 (0x3 << 12) /* RW--V */
362
363/*
364MCLK Output Control
365Controls mclko[0] output.
3660 - Disable output (fixed at High)
3671 - Output clock produced by clock selected
368with SCKSEL0 by MR0
3692 - Reserved
3703 - Reserved
371*/
372#define PS3_AUDIO_AO_MCTRL_MCLKC0_MASK (0x3 << 14) /* RWIVF */
373#define PS3_AUDIO_AO_MCTRL_MCLKC0_DISABLED (0x0 << 14) /* RWI-V */
374#define PS3_AUDIO_AO_MCTRL_MCLKC0_ENABLED (0x1 << 14) /* RW--V */
375#define PS3_AUDIO_AO_MCTRL_MCLKC0_RESVD2 (0x2 << 14) /* RW--V */
376#define PS3_AUDIO_AO_MCTRL_MCLKC0_RESVD3 (0x3 << 14) /* RW--V */
377/*
378Master Clock Rate 1
379Sets the divide ration of Master Clock1 (clock output from
380mclko[1] for the input clock selected by scksel1.
381*/
382#define PS3_AUDIO_AO_MCTRL_MR1_MASK (0xf << 16)
383#define PS3_AUDIO_AO_MCTRL_MR1_DEFAULT (0x0 << 16) /* RWI-V */
384/*
385Master Clock Rate 0
386Sets the divide ratio of Master Clock0 (clock output from
387mclko[0] for the input clock selected by scksel0).
388*/
389#define PS3_AUDIO_AO_MCTRL_MR0_MASK (0xf << 20) /* RWIVF */
390#define PS3_AUDIO_AO_MCTRL_MR0_DEFAULT (0x0 << 20) /* RWI-V */
391/*
392System Clock Select 0/1
393Selects the system clock to be used as Master Clock 0/1
394Input the system clock that is appropriate for the sampling
395rate.
396*/
397#define PS3_AUDIO_AO_MCTRL_SCKSEL1_MASK (0x7 << 24) /* RWIVF */
398#define PS3_AUDIO_AO_MCTRL_SCKSEL1_DEFAULT (0x2 << 24) /* RWI-V */
399
400#define PS3_AUDIO_AO_MCTRL_SCKSEL0_MASK (0x7 << 28) /* RWIVF */
401#define PS3_AUDIO_AO_MCTRL_SCKSEL0_DEFAULT (0x2 << 28) /* RWI-V */
402
403
404/*
4053-Wire Audio Output Master Control Register
406Configures clock, 3-Wire Audio Serial Output Enable, and
407other 3-Wire Audio Serial Output Master Settings
408
409
410 31 24 23 16 15 8 7 0
411 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
412 |A|A|A|A|0 0 0|A| ASOSR |0 0 0 0|A|A|A|A|A|A|0|1|0 0 0 0 0 0 0 0| AO_3WMCTRL
413 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
414*/
415
416
417/*
418LRCKO Polarity
4190 - Reserved
4201 - default
421*/
422#define PS3_AUDIO_AO_3WMCTRL_ASOPLRCK (1 << 8) /* RWIVF */
423#define PS3_AUDIO_AO_3WMCTRL_ASOPLRCK_DEFAULT (1 << 8) /* RW--V */
424
425/* LRCK Output Disable */
426
427#define PS3_AUDIO_AO_3WMCTRL_ASOLRCKD (1 << 10) /* RWIVF */
428#define PS3_AUDIO_AO_3WMCTRL_ASOLRCKD_ENABLED (0 << 10) /* RW--V */
429#define PS3_AUDIO_AO_3WMCTRL_ASOLRCKD_DISABLED (1 << 10) /* RWI-V */
430
431/* Bit Clock Output Disable */
432
433#define PS3_AUDIO_AO_3WMCTRL_ASOBCLKD (1 << 11) /* RWIVF */
434#define PS3_AUDIO_AO_3WMCTRL_ASOBCLKD_ENABLED (0 << 11) /* RW--V */
435#define PS3_AUDIO_AO_3WMCTRL_ASOBCLKD_DISABLED (1 << 11) /* RWI-V */
436
437/*
4383-Wire Audio Serial Output Channel 0-3 Operational
439Status. Each bit becomes 1 after each 3-Wire Audio
440Serial Output Channel N is in action by setting 1 to
441asoen.
442Each bit becomes 0 after each 3-Wire Audio Serial Output
443Channel N is out of action by setting 0 to asoen.
444*/
445#define PS3_AUDIO_AO_3WMCTRL_ASORUN(n) (1 << (15 - (n))) /* R-IVF */
446#define PS3_AUDIO_AO_3WMCTRL_ASORUN_STOPPED(n) (0 << (15 - (n))) /* R-I-V */
447#define PS3_AUDIO_AO_3WMCTRL_ASORUN_RUNNING(n) (1 << (15 - (n))) /* R---V */
448#define PS3_AUDIO_AO_3WMCTRL_ASORUN0 \
449 PS3_AUDIO_AO_3WMCTRL_ASORUN(0)
450#define PS3_AUDIO_AO_3WMCTRL_ASORUN0_STOPPED \
451 PS3_AUDIO_AO_3WMCTRL_ASORUN_STOPPED(0)
452#define PS3_AUDIO_AO_3WMCTRL_ASORUN0_RUNNING \
453 PS3_AUDIO_AO_3WMCTRL_ASORUN_RUNNING(0)
454#define PS3_AUDIO_AO_3WMCTRL_ASORUN1 \
455 PS3_AUDIO_AO_3WMCTRL_ASORUN(1)
456#define PS3_AUDIO_AO_3WMCTRL_ASORUN1_STOPPED \
457 PS3_AUDIO_AO_3WMCTRL_ASORUN_STOPPED(1)
458#define PS3_AUDIO_AO_3WMCTRL_ASORUN1_RUNNING \
459 PS3_AUDIO_AO_3WMCTRL_ASORUN_RUNNING(1)
460#define PS3_AUDIO_AO_3WMCTRL_ASORUN2 \
461 PS3_AUDIO_AO_3WMCTRL_ASORUN(2)
462#define PS3_AUDIO_AO_3WMCTRL_ASORUN2_STOPPED \
463 PS3_AUDIO_AO_3WMCTRL_ASORUN_STOPPED(2)
464#define PS3_AUDIO_AO_3WMCTRL_ASORUN2_RUNNING \
465 PS3_AUDIO_AO_3WMCTRL_ASORUN_RUNNING(2)
466#define PS3_AUDIO_AO_3WMCTRL_ASORUN3 \
467 PS3_AUDIO_AO_3WMCTRL_ASORUN(3)
468#define PS3_AUDIO_AO_3WMCTRL_ASORUN3_STOPPED \
469 PS3_AUDIO_AO_3WMCTRL_ASORUN_STOPPED(3)
470#define PS3_AUDIO_AO_3WMCTRL_ASORUN3_RUNNING \
471 PS3_AUDIO_AO_3WMCTRL_ASORUN_RUNNING(3)
472
473/*
474Sampling Rate
475Specifies the divide ratio of the bit clock (clock output
476from bclko) used by the 3-wire Audio Output Clock, whcih
477is applied to the master clock selected by mcksel.
478Data output is synchronized with this clock.
479*/
480#define PS3_AUDIO_AO_3WMCTRL_ASOSR_MASK (0xf << 20) /* RWIVF */
481#define PS3_AUDIO_AO_3WMCTRL_ASOSR_DIV2 (0x1 << 20) /* RWI-V */
482#define PS3_AUDIO_AO_3WMCTRL_ASOSR_DIV4 (0x2 << 20) /* RW--V */
483#define PS3_AUDIO_AO_3WMCTRL_ASOSR_DIV8 (0x4 << 20) /* RW--V */
484#define PS3_AUDIO_AO_3WMCTRL_ASOSR_DIV12 (0x6 << 20) /* RW--V */
485
486/*
487Master Clock Select
4880 - Master Clock 0
4891 - Master Clock 1
490*/
491#define PS3_AUDIO_AO_3WMCTRL_ASOMCKSEL (1 << 24) /* RWIVF */
492#define PS3_AUDIO_AO_3WMCTRL_ASOMCKSEL_CLK0 (0 << 24) /* RWI-V */
493#define PS3_AUDIO_AO_3WMCTRL_ASOMCKSEL_CLK1 (1 << 24) /* RW--V */
494
495/*
496Enables and disables 4ch 3-Wire Audio Serial Output
497operation. Each Bit from 0 to 3 corresponds to an
498output channel, which means that each output channel
499can be enabled or disabled individually. When
500multiple channels are enabled at the same time, output
501operations are performed in synchronization.
502Bit 0 - Output Channel 0 (SDOUT[0])
503Bit 1 - Output Channel 1 (SDOUT[1])
504Bit 2 - Output Channel 2 (SDOUT[2])
505Bit 3 - Output Channel 3 (SDOUT[3])
506*/
507#define PS3_AUDIO_AO_3WMCTRL_ASOEN(n) (1 << (31 - (n))) /* RWIVF */
508#define PS3_AUDIO_AO_3WMCTRL_ASOEN_DISABLED(n) (0 << (31 - (n))) /* RWI-V */
509#define PS3_AUDIO_AO_3WMCTRL_ASOEN_ENABLED(n) (1 << (31 - (n))) /* RW--V */
510
511#define PS3_AUDIO_AO_3WMCTRL_ASOEN0 \
512 PS3_AUDIO_AO_3WMCTRL_ASOEN(0) /* RWIVF */
513#define PS3_AUDIO_AO_3WMCTRL_ASOEN0_DISABLED \
514 PS3_AUDIO_AO_3WMCTRL_ASOEN_DISABLED(0) /* RWI-V */
515#define PS3_AUDIO_AO_3WMCTRL_ASOEN0_ENABLED \
516 PS3_AUDIO_AO_3WMCTRL_ASOEN_ENABLED(0) /* RW--V */
517#define PS3_AUDIO_A1_3WMCTRL_ASOEN0 \
518 PS3_AUDIO_AO_3WMCTRL_ASOEN(1) /* RWIVF */
519#define PS3_AUDIO_A1_3WMCTRL_ASOEN0_DISABLED \
520 PS3_AUDIO_AO_3WMCTRL_ASOEN_DISABLED(1) /* RWI-V */
521#define PS3_AUDIO_A1_3WMCTRL_ASOEN0_ENABLED \
522 PS3_AUDIO_AO_3WMCTRL_ASOEN_ENABLED(1) /* RW--V */
523#define PS3_AUDIO_A2_3WMCTRL_ASOEN0 \
524 PS3_AUDIO_AO_3WMCTRL_ASOEN(2) /* RWIVF */
525#define PS3_AUDIO_A2_3WMCTRL_ASOEN0_DISABLED \
526 PS3_AUDIO_AO_3WMCTRL_ASOEN_DISABLED(2) /* RWI-V */
527#define PS3_AUDIO_A2_3WMCTRL_ASOEN0_ENABLED \
528 PS3_AUDIO_AO_3WMCTRL_ASOEN_ENABLED(2) /* RW--V */
529#define PS3_AUDIO_A3_3WMCTRL_ASOEN0 \
530 PS3_AUDIO_AO_3WMCTRL_ASOEN(3) /* RWIVF */
531#define PS3_AUDIO_A3_3WMCTRL_ASOEN0_DISABLED \
532 PS3_AUDIO_AO_3WMCTRL_ASOEN_DISABLED(3) /* RWI-V */
533#define PS3_AUDIO_A3_3WMCTRL_ASOEN0_ENABLED \
534 PS3_AUDIO_AO_3WMCTRL_ASOEN_ENABLED(3) /* RW--V */
535
536/*
5373-Wire Audio Serial output Channel 0-3 Control Register
538Configures settings for 3-Wire Serial Audio Output Channel 0-3
539
540
541 31 24 23 16 15 8 7 0
542 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
543 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|A|0 0 0 0|A|0|ASO|0 0 0|0|0|0|0|0| AO_3WCTRL
544 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
545
546*/
547/*
548Data Bit Mode
549Specifies the number of data bits
5500 - 16 bits
5511 - reserved
5522 - 20 bits
5533 - 24 bits
554*/
555#define PS3_AUDIO_AO_3WCTRL_ASODB_MASK (0x3 << 8) /* RWIVF */
556#define PS3_AUDIO_AO_3WCTRL_ASODB_16BIT (0x0 << 8) /* RWI-V */
557#define PS3_AUDIO_AO_3WCTRL_ASODB_RESVD (0x1 << 8) /* RWI-V */
558#define PS3_AUDIO_AO_3WCTRL_ASODB_20BIT (0x2 << 8) /* RW--V */
559#define PS3_AUDIO_AO_3WCTRL_ASODB_24BIT (0x3 << 8) /* RW--V */
560/*
561Data Format Mode
562Specifies the data format where (LSB side or MSB) the data(in 20 bit
563or 24 bit resolution mode) is put in a 32 bit field.
5640 - Data put on LSB side
5651 - Data put on MSB side
566*/
567#define PS3_AUDIO_AO_3WCTRL_ASODF (1 << 11) /* RWIVF */
568#define PS3_AUDIO_AO_3WCTRL_ASODF_LSB (0 << 11) /* RWI-V */
569#define PS3_AUDIO_AO_3WCTRL_ASODF_MSB (1 << 11) /* RW--V */
570/*
571Buffer Reset
572Performs buffer reset. Writing 1 to this bit initializes the
573corresponding 3-Wire Audio Output buffers(both L and R).
574*/
575#define PS3_AUDIO_AO_3WCTRL_ASOBRST (1 << 16) /* CWIVF */
576#define PS3_AUDIO_AO_3WCTRL_ASOBRST_IDLE (0 << 16) /* -WI-V */
577#define PS3_AUDIO_AO_3WCTRL_ASOBRST_RESET (1 << 16) /* -W--T */
578
579/*
580S/PDIF Audio Output Channel 0/1 Control Register
581Configures settings for S/PDIF Audio Output Channel 0/1.
582
583 31 24 23 16 15 8 7 0
584 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
585 |S|0 0 0|S|0 0|S| SPOSR |0 0|SPO|0 0 0 0|S|0|SPO|0 0 0 0 0 0 0|S| AO_SPDCTRL
586 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
587*/
588/*
589Buffer reset. Writing 1 to this bit initializes the
590corresponding S/PDIF output buffer pointer.
591*/
592#define PS3_AUDIO_AO_SPDCTRL_SPOBRST (1 << 0) /* CWIVF */
593#define PS3_AUDIO_AO_SPDCTRL_SPOBRST_IDLE (0 << 0) /* -WI-V */
594#define PS3_AUDIO_AO_SPDCTRL_SPOBRST_RESET (1 << 0) /* -W--T */
595
596/*
597Data Bit Mode
598Specifies number of data bits
5990 - 16 bits
6001 - Reserved
6012 - 20 bits
6023 - 24 bits
603*/
604#define PS3_AUDIO_AO_SPDCTRL_SPODB_MASK (0x3 << 8) /* RWIVF */
605#define PS3_AUDIO_AO_SPDCTRL_SPODB_16BIT (0x0 << 8) /* RWI-V */
606#define PS3_AUDIO_AO_SPDCTRL_SPODB_RESVD (0x1 << 8) /* RW--V */
607#define PS3_AUDIO_AO_SPDCTRL_SPODB_20BIT (0x2 << 8) /* RW--V */
608#define PS3_AUDIO_AO_SPDCTRL_SPODB_24BIT (0x3 << 8) /* RW--V */
609/*
610Data format Mode
611Specifies the data format, where (LSB side or MSB)
612the data(in 20 or 24 bit resolution) is put in the
61332 bit field.
6140 - LSB Side
6151 - MSB Side
616*/
617#define PS3_AUDIO_AO_SPDCTRL_SPODF (1 << 11) /* RWIVF */
618#define PS3_AUDIO_AO_SPDCTRL_SPODF_LSB (0 << 11) /* RWI-V */
619#define PS3_AUDIO_AO_SPDCTRL_SPODF_MSB (1 << 11) /* RW--V */
620/*
621Source Select
622Specifies the source of the S/PDIF output. When 0, output
623operation is controlled by 3wen[0] of AO_3WMCTRL register.
624The SR must have the same setting as the a0_3wmctrl reg.
6250 - 3-Wire Audio OUT Ch0 Buffer
6261 - S/PDIF buffer
627*/
628#define PS3_AUDIO_AO_SPDCTRL_SPOSS_MASK (0x3 << 16) /* RWIVF */
629#define PS3_AUDIO_AO_SPDCTRL_SPOSS_3WEN (0x0 << 16) /* RWI-V */
630#define PS3_AUDIO_AO_SPDCTRL_SPOSS_SPDIF (0x1 << 16) /* RW--V */
631/*
632Sampling Rate
633Specifies the divide ratio of the bit clock (clock output
634from bclko) used by the S/PDIF Output Clock, which
635is applied to the master clock selected by mcksel.
636*/
637#define PS3_AUDIO_AO_SPDCTRL_SPOSR (0xf << 20) /* RWIVF */
638#define PS3_AUDIO_AO_SPDCTRL_SPOSR_DIV2 (0x1 << 20) /* RWI-V */
639#define PS3_AUDIO_AO_SPDCTRL_SPOSR_DIV4 (0x2 << 20) /* RW--V */
640#define PS3_AUDIO_AO_SPDCTRL_SPOSR_DIV8 (0x4 << 20) /* RW--V */
641#define PS3_AUDIO_AO_SPDCTRL_SPOSR_DIV12 (0x6 << 20) /* RW--V */
642/*
643Master Clock Select
6440 - Master Clock 0
6451 - Master Clock 1
646*/
647#define PS3_AUDIO_AO_SPDCTRL_SPOMCKSEL (1 << 24) /* RWIVF */
648#define PS3_AUDIO_AO_SPDCTRL_SPOMCKSEL_CLK0 (0 << 24) /* RWI-V */
649#define PS3_AUDIO_AO_SPDCTRL_SPOMCKSEL_CLK1 (1 << 24) /* RW--V */
650
651/*
652S/PDIF Output Channel Operational Status
653This bit becomes 1 after S/PDIF Output Channel is in
654action by setting 1 to spoen. This bit becomes 0
655after S/PDIF Output Channel is out of action by setting
6560 to spoen.
657*/
658#define PS3_AUDIO_AO_SPDCTRL_SPORUN (1 << 27) /* R-IVF */
659#define PS3_AUDIO_AO_SPDCTRL_SPORUN_STOPPED (0 << 27) /* R-I-V */
660#define PS3_AUDIO_AO_SPDCTRL_SPORUN_RUNNING (1 << 27) /* R---V */
661
662/*
663S/PDIF Audio Output Channel Output Enable
664Enables and disables output operation. This bit is used
665only when sposs = 1
666*/
667#define PS3_AUDIO_AO_SPDCTRL_SPOEN (1 << 31) /* RWIVF */
668#define PS3_AUDIO_AO_SPDCTRL_SPOEN_DISABLED (0 << 31) /* RWI-V */
669#define PS3_AUDIO_AO_SPDCTRL_SPOEN_ENABLED (1 << 31) /* RW--V */
670
671/*
672S/PDIF Audio Output Channel Channel Status
673Setting Registers.
674Configures channel status bit settings for each block
675(192 bits).
676Output is performed from the MSB(AO_SPDCS0 register bit 31).
677The same value is added for subframes within the same frame.
678 31 24 23 16 15 8 7 0
679 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
680 | SPOCS | AO_SPDCS
681 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
682
683S/PDIF Audio Output Channel User Bit Setting
684Configures user bit settings for each block (384 bits).
685Output is performed from the MSB(ao_spdub0 register bit 31).
686
687
688 31 24 23 16 15 8 7 0
689 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
690 | SPOUB | AO_SPDUB
691 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
692*/
693/*****************************************************************************
694 *
695 * DMAC register
696 *
697 *****************************************************************************/
698/*
699The PS3_AUDIO_KICK register is used to initiate a DMA transfer and monitor
700its status
701
702 31 24 23 16 15 8 7 0
703 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
704 |0 0 0 0 0|STATU|0 0 0| EVENT |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|R| KICK
705 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
706*/
707/*
708The REQUEST field is written to ACTIVE to initiate a DMA request when EVENT
709occurs.
710It will return to the DONE state when the request is completed.
711The registers for a DMA channel should only be written if REQUEST is IDLE.
712*/
713
714#define PS3_AUDIO_KICK_REQUEST (1 << 0) /* RWIVF */
715#define PS3_AUDIO_KICK_REQUEST_IDLE (0 << 0) /* RWI-V */
716#define PS3_AUDIO_KICK_REQUEST_ACTIVE (1 << 0) /* -W--T */
717
718/*
719 *The EVENT field is used to set the event in which
720 *the DMA request becomes active.
721 */
722#define PS3_AUDIO_KICK_EVENT_MASK (0x1f << 16) /* RWIVF */
723#define PS3_AUDIO_KICK_EVENT_ALWAYS (0x00 << 16) /* RWI-V */
724#define PS3_AUDIO_KICK_EVENT_SERIALOUT0_EMPTY (0x01 << 16) /* RW--V */
725#define PS3_AUDIO_KICK_EVENT_SERIALOUT0_UNDERFLOW (0x02 << 16) /* RW--V */
726#define PS3_AUDIO_KICK_EVENT_SERIALOUT1_EMPTY (0x03 << 16) /* RW--V */
727#define PS3_AUDIO_KICK_EVENT_SERIALOUT1_UNDERFLOW (0x04 << 16) /* RW--V */
728#define PS3_AUDIO_KICK_EVENT_SERIALOUT2_EMPTY (0x05 << 16) /* RW--V */
729#define PS3_AUDIO_KICK_EVENT_SERIALOUT2_UNDERFLOW (0x06 << 16) /* RW--V */
730#define PS3_AUDIO_KICK_EVENT_SERIALOUT3_EMPTY (0x07 << 16) /* RW--V */
731#define PS3_AUDIO_KICK_EVENT_SERIALOUT3_UNDERFLOW (0x08 << 16) /* RW--V */
732#define PS3_AUDIO_KICK_EVENT_SPDIF0_BLOCKTRANSFERCOMPLETE \
733 (0x09 << 16) /* RW--V */
734#define PS3_AUDIO_KICK_EVENT_SPDIF0_UNDERFLOW (0x0A << 16) /* RW--V */
735#define PS3_AUDIO_KICK_EVENT_SPDIF0_EMPTY (0x0B << 16) /* RW--V */
736#define PS3_AUDIO_KICK_EVENT_SPDIF1_BLOCKTRANSFERCOMPLETE \
737 (0x0C << 16) /* RW--V */
738#define PS3_AUDIO_KICK_EVENT_SPDIF1_UNDERFLOW (0x0D << 16) /* RW--V */
739#define PS3_AUDIO_KICK_EVENT_SPDIF1_EMPTY (0x0E << 16) /* RW--V */
740
741#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA(n) \
742 ((0x13 + (n)) << 16) /* RW--V */
743#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA0 (0x13 << 16) /* RW--V */
744#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA1 (0x14 << 16) /* RW--V */
745#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA2 (0x15 << 16) /* RW--V */
746#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA3 (0x16 << 16) /* RW--V */
747#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA4 (0x17 << 16) /* RW--V */
748#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA5 (0x18 << 16) /* RW--V */
749#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA6 (0x19 << 16) /* RW--V */
750#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA7 (0x1A << 16) /* RW--V */
751#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA8 (0x1B << 16) /* RW--V */
752#define PS3_AUDIO_KICK_EVENT_AUDIO_DMA9 (0x1C << 16) /* RW--V */
753
754/*
755The STATUS field can be used to monitor the progress of a DMA request.
756DONE indicates the previous request has completed.
757EVENT indicates that the DMA engine is waiting for the EVENT to occur.
758PENDING indicates that the DMA engine has not started processing this
759request, but the EVENT has occured.
760DMA indicates that the data transfer is in progress.
761NOTIFY indicates that the notifier signalling end of transfer is being written.
762CLEAR indicated that the previous transfer was cleared.
763ERROR indicates the previous transfer requested an unsupported
764source/destination combination.
765*/
766
767#define PS3_AUDIO_KICK_STATUS_MASK (0x7 << 24) /* R-IVF */
768#define PS3_AUDIO_KICK_STATUS_DONE (0x0 << 24) /* R-I-V */
769#define PS3_AUDIO_KICK_STATUS_EVENT (0x1 << 24) /* R---V */
770#define PS3_AUDIO_KICK_STATUS_PENDING (0x2 << 24) /* R---V */
771#define PS3_AUDIO_KICK_STATUS_DMA (0x3 << 24) /* R---V */
772#define PS3_AUDIO_KICK_STATUS_NOTIFY (0x4 << 24) /* R---V */
773#define PS3_AUDIO_KICK_STATUS_CLEAR (0x5 << 24) /* R---V */
774#define PS3_AUDIO_KICK_STATUS_ERROR (0x6 << 24) /* R---V */
775
776/*
777The PS3_AUDIO_SOURCE register specifies the source address for transfers.
778
779
780 31 24 23 16 15 8 7 0
781 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
782 | START |0 0 0 0 0|TAR| SOURCE
783 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
784*/
785
786/*
787The Audio DMA engine uses 128-byte transfers, thus the address must be aligned
788to a 128 byte boundary. The low seven bits are assumed to be 0.
789*/
790
791#define PS3_AUDIO_SOURCE_START_MASK (0x01FFFFFF << 7) /* RWIUF */
792
793/*
794The TARGET field specifies the memory space containing the source address.
795*/
796
797#define PS3_AUDIO_SOURCE_TARGET_MASK (3 << 0) /* RWIVF */
798#define PS3_AUDIO_SOURCE_TARGET_SYSTEM_MEMORY (2 << 0) /* RW--V */
799
800/*
801The PS3_AUDIO_DEST register specifies the destination address for transfers.
802
803
804 31 24 23 16 15 8 7 0
805 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
806 | START |0 0 0 0 0|TAR| DEST
807 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
808*/
809
810/*
811The Audio DMA engine uses 128-byte transfers, thus the address must be aligned
812to a 128 byte boundary. The low seven bits are assumed to be 0.
813*/
814
815#define PS3_AUDIO_DEST_START_MASK (0x01FFFFFF << 7) /* RWIUF */
816
817/*
818The TARGET field specifies the memory space containing the destination address
819AUDIOFIFO = Audio WriteData FIFO,
820*/
821
822#define PS3_AUDIO_DEST_TARGET_MASK (3 << 0) /* RWIVF */
823#define PS3_AUDIO_DEST_TARGET_AUDIOFIFO (1 << 0) /* RW--V */
824
825/*
826PS3_AUDIO_DMASIZE specifies the number of 128-byte blocks + 1 to transfer.
827So a value of 0 means 128-bytes will get transfered.
828
829
830 31 24 23 16 15 8 7 0
831 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
832 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0| BLOCKS | DMASIZE
833 +-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-+
834*/
835
836
837#define PS3_AUDIO_DMASIZE_BLOCKS_MASK (0x7f << 0) /* RWIUF */
838
839/*
840 * source/destination address for internal fifos
841 */
842#define PS3_AUDIO_AO_3W_LDATA(n) (0x1000 + (0x100 * (n)))
843#define PS3_AUDIO_AO_3W_RDATA(n) (0x1080 + (0x100 * (n)))
844
845#define PS3_AUDIO_AO_SPD_DATA(n) (0x2000 + (0x400 * (n)))
846
847
848/*
849 * field attiribute
850 *
851 * Read
852 * ' ' = Other Information
853 * '-' = Field is part of a write-only register
854 * 'C' = Value read is always the same, constant value line follows (C)
855 * 'R' = Value is read
856 *
857 * Write
858 * ' ' = Other Information
859 * '-' = Must not be written (D), value ignored when written (R,A,F)
860 * 'W' = Can be written
861 *
862 * Internal State
863 * ' ' = Other Information
864 * '-' = No internal state
865 * 'X' = Internal state, initial value is unknown
866 * 'I' = Internal state, initial value is known and follows (I)
867 *
868 * Declaration/Size
869 * ' ' = Other Information
870 * '-' = Does Not Apply
871 * 'V' = Type is void
872 * 'U' = Type is unsigned integer
873 * 'S' = Type is signed integer
874 * 'F' = Type is IEEE floating point
875 * '1' = Byte size (008)
876 * '2' = Short size (016)
877 * '3' = Three byte size (024)
878 * '4' = Word size (032)
879 * '8' = Double size (064)
880 *
881 * Define Indicator
882 * ' ' = Other Information
883 * 'D' = Device
884 * 'M' = Memory
885 * 'R' = Register
886 * 'A' = Array of Registers
887 * 'F' = Field
888 * 'V' = Value
889 * 'T' = Task
890 */
891
diff --git a/sound/sh/Kconfig b/sound/sh/Kconfig
new file mode 100644
index 00000000000..b7e08ef22a9
--- /dev/null
+++ b/sound/sh/Kconfig
@@ -0,0 +1,14 @@
1# ALSA SH drivers
2
3menu "SUPERH devices"
4 depends on SND!=n && SUPERH
5
6config SND_AICA
7 tristate "Dreamcast Yamaha AICA sound"
8 depends on SH_DREAMCAST && SND
9 select SND_PCM
10 help
11 ALSA Sound driver for the SEGA Dreamcast console.
12
13endmenu
14
diff --git a/sound/sh/Makefile b/sound/sh/Makefile
new file mode 100644
index 00000000000..8fdcb6e26f0
--- /dev/null
+++ b/sound/sh/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for ALSA
3#
4
5snd-aica-objs := aica.o
6
7# Toplevel Module Dependency
8obj-$(CONFIG_SND_AICA) += snd-aica.o
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
new file mode 100644
index 00000000000..739786529ca
--- /dev/null
+++ b/sound/sh/aica.c
@@ -0,0 +1,665 @@
1/*
2* This code is licenced under
3* the General Public Licence
4* version 2
5*
6* Copyright Adrian McMenamin 2005, 2006, 2007
7* <adrian@mcmen.demon.co.uk>
8* Requires firmware (BSD licenced) available from:
9* http://linuxdc.cvs.sourceforge.net/linuxdc/linux-sh-dc/sound/oss/aica/firmware/
10* or the maintainer
11*
12* This program is free software; you can redistribute it and/or modify
13* it under the terms of version 2 of the GNU General Public License as published by
14* the Free Software Foundation.
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/init.h>
28#include <linux/jiffies.h>
29#include <linux/slab.h>
30#include <linux/time.h>
31#include <linux/wait.h>
32#include <linux/moduleparam.h>
33#include <linux/platform_device.h>
34#include <linux/firmware.h>
35#include <linux/timer.h>
36#include <linux/delay.h>
37#include <linux/workqueue.h>
38#include <sound/driver.h>
39#include <sound/core.h>
40#include <sound/control.h>
41#include <sound/pcm.h>
42#include <sound/initval.h>
43#include <sound/info.h>
44#include <asm/io.h>
45#include <asm/dma.h>
46#include <asm/dreamcast/sysasic.h>
47#include "aica.h"
48
49MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
50MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver");
51MODULE_LICENSE("GPL");
52MODULE_SUPPORTED_DEVICE("{{Yamaha/SEGA, AICA}}");
53
54/* module parameters */
55#define CARD_NAME "AICA"
56static int index = -1;
57static char *id;
58static int enable = 1;
59module_param(index, int, 0444);
60MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
61module_param(id, charp, 0444);
62MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
63module_param(enable, bool, 0644);
64MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
65
66/* Use workqueue */
67static struct workqueue_struct *aica_queue;
68
69/* Simple platform device */
70static struct platform_device *pd;
71static struct resource aica_memory_space[2] = {
72 {
73 .name = "AICA ARM CONTROL",
74 .start = ARM_RESET_REGISTER,
75 .flags = IORESOURCE_MEM,
76 .end = ARM_RESET_REGISTER + 3,
77 },
78 {
79 .name = "AICA Sound RAM",
80 .start = SPU_MEMORY_BASE,
81 .flags = IORESOURCE_MEM,
82 .end = SPU_MEMORY_BASE + 0x200000 - 1,
83 },
84};
85
86/* SPU specific functions */
87/* spu_write_wait - wait for G2-SH FIFO to clear */
88static void spu_write_wait(void)
89{
90 int time_count;
91 time_count = 0;
92 while (1) {
93 if (!(readl(G2_FIFO) & 0x11))
94 break;
95 /* To ensure hardware failure doesn't wedge kernel */
96 time_count++;
97 if (time_count > 0x10000) {
98 snd_printk
99 ("WARNING: G2 FIFO appears to be blocked.\n");
100 break;
101 }
102 }
103}
104
105/* spu_memset - write to memory in SPU address space */
106static void spu_memset(u32 toi, u32 what, int length)
107{
108 int i;
109 snd_assert(length % 4 == 0, return);
110 for (i = 0; i < length; i++) {
111 if (!(i % 8))
112 spu_write_wait();
113 writel(what, toi + SPU_MEMORY_BASE);
114 toi++;
115 }
116}
117
118/* spu_memload - write to SPU address space */
119static void spu_memload(u32 toi, void *from, int length)
120{
121 u32 *froml = from;
122 u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);
123 int i;
124 u32 val;
125 length = DIV_ROUND_UP(length, 4);
126 spu_write_wait();
127 for (i = 0; i < length; i++) {
128 if (!(i % 8))
129 spu_write_wait();
130 val = *froml;
131 writel(val, to);
132 froml++;
133 to++;
134 }
135}
136
137/* spu_disable - set spu registers to stop sound output */
138static void spu_disable(void)
139{
140 int i;
141 u32 regval;
142 spu_write_wait();
143 regval = readl(ARM_RESET_REGISTER);
144 regval |= 1;
145 spu_write_wait();
146 writel(regval, ARM_RESET_REGISTER);
147 for (i = 0; i < 64; i++) {
148 spu_write_wait();
149 regval = readl(SPU_REGISTER_BASE + (i * 0x80));
150 regval = (regval & ~0x4000) | 0x8000;
151 spu_write_wait();
152 writel(regval, SPU_REGISTER_BASE + (i * 0x80));
153 }
154}
155
156/* spu_enable - set spu registers to enable sound output */
157static void spu_enable(void)
158{
159 u32 regval = readl(ARM_RESET_REGISTER);
160 regval &= ~1;
161 spu_write_wait();
162 writel(regval, ARM_RESET_REGISTER);
163}
164
165/*
166 * Halt the sound processor, clear the memory,
167 * load some default ARM7 code, and then restart ARM7
168*/
169static void spu_reset(void)
170{
171 spu_disable();
172 spu_memset(0, 0, 0x200000 / 4);
173 /* Put ARM7 in endless loop */
174 ctrl_outl(0xea000002, SPU_MEMORY_BASE);
175 spu_enable();
176}
177
178/* aica_chn_start - write to spu to start playback */
179static void aica_chn_start(void)
180{
181 spu_write_wait();
182 writel(AICA_CMD_KICK | AICA_CMD_START, (u32 *) AICA_CONTROL_POINT);
183}
184
185/* aica_chn_halt - write to spu to halt playback */
186static void aica_chn_halt(void)
187{
188 spu_write_wait();
189 writel(AICA_CMD_KICK | AICA_CMD_STOP, (u32 *) AICA_CONTROL_POINT);
190}
191
192/* ALSA code below */
193static struct snd_pcm_hardware snd_pcm_aica_playback_hw = {
194 .info = (SNDRV_PCM_INFO_NONINTERLEAVED),
195 .formats =
196 (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |
197 SNDRV_PCM_FMTBIT_IMA_ADPCM),
198 .rates = SNDRV_PCM_RATE_8000_48000,
199 .rate_min = 8000,
200 .rate_max = 48000,
201 .channels_min = 1,
202 .channels_max = 2,
203 .buffer_bytes_max = AICA_BUFFER_SIZE,
204 .period_bytes_min = AICA_PERIOD_SIZE,
205 .period_bytes_max = AICA_PERIOD_SIZE,
206 .periods_min = AICA_PERIOD_NUMBER,
207 .periods_max = AICA_PERIOD_NUMBER,
208};
209
210static int aica_dma_transfer(int channels, int buffer_size,
211 struct snd_pcm_substream *substream)
212{
213 int q, err, period_offset;
214 struct snd_card_aica *dreamcastcard;
215 struct snd_pcm_runtime *runtime;
216 err = 0;
217 dreamcastcard = substream->pcm->private_data;
218 period_offset = dreamcastcard->clicks;
219 period_offset %= (AICA_PERIOD_NUMBER / channels);
220 runtime = substream->runtime;
221 for (q = 0; q < channels; q++) {
222 err = dma_xfer(AICA_DMA_CHANNEL,
223 (unsigned long) (runtime->dma_area +
224 (AICA_BUFFER_SIZE * q) /
225 channels +
226 AICA_PERIOD_SIZE *
227 period_offset),
228 AICA_CHANNEL0_OFFSET + q * CHANNEL_OFFSET +
229 AICA_PERIOD_SIZE * period_offset,
230 buffer_size / channels, AICA_DMA_MODE);
231 if (unlikely(err < 0))
232 break;
233 dma_wait_for_completion(AICA_DMA_CHANNEL);
234 }
235 return err;
236}
237
238static void startup_aica(struct snd_card_aica *dreamcastcard)
239{
240 spu_memload(AICA_CHANNEL0_CONTROL_OFFSET,
241 dreamcastcard->channel, sizeof(struct aica_channel));
242 aica_chn_start();
243}
244
245static void run_spu_dma(struct work_struct *work)
246{
247 int buffer_size;
248 struct snd_pcm_runtime *runtime;
249 struct snd_card_aica *dreamcastcard;
250 dreamcastcard =
251 container_of(work, struct snd_card_aica, spu_dma_work);
252 runtime = dreamcastcard->substream->runtime;
253 if (unlikely(dreamcastcard->dma_check == 0)) {
254 buffer_size =
255 frames_to_bytes(runtime, runtime->buffer_size);
256 if (runtime->channels > 1)
257 dreamcastcard->channel->flags |= 0x01;
258 aica_dma_transfer(runtime->channels, buffer_size,
259 dreamcastcard->substream);
260 startup_aica(dreamcastcard);
261 dreamcastcard->clicks =
262 buffer_size / (AICA_PERIOD_SIZE * runtime->channels);
263 return;
264 } else {
265 aica_dma_transfer(runtime->channels,
266 AICA_PERIOD_SIZE * runtime->channels,
267 dreamcastcard->substream);
268 snd_pcm_period_elapsed(dreamcastcard->substream);
269 dreamcastcard->clicks++;
270 if (unlikely(dreamcastcard->clicks >= AICA_PERIOD_NUMBER))
271 dreamcastcard->clicks %= AICA_PERIOD_NUMBER;
272 mod_timer(&dreamcastcard->timer, jiffies + 1);
273 }
274}
275
276static void aica_period_elapsed(unsigned long timer_var)
277{
278 /*timer function - so cannot sleep */
279 int play_period;
280 struct snd_pcm_runtime *runtime;
281 struct snd_pcm_substream *substream;
282 struct snd_card_aica *dreamcastcard;
283 substream = (struct snd_pcm_substream *) timer_var;
284 runtime = substream->runtime;
285 dreamcastcard = substream->pcm->private_data;
286 /* Have we played out an additional period? */
287 play_period =
288 frames_to_bytes(runtime,
289 readl
290 (AICA_CONTROL_CHANNEL_SAMPLE_NUMBER)) /
291 AICA_PERIOD_SIZE;
292 if (play_period == dreamcastcard->current_period) {
293 /* reschedule the timer */
294 mod_timer(&(dreamcastcard->timer), jiffies + 1);
295 return;
296 }
297 if (runtime->channels > 1)
298 dreamcastcard->current_period = play_period;
299 if (unlikely(dreamcastcard->dma_check == 0))
300 dreamcastcard->dma_check = 1;
301 queue_work(aica_queue, &(dreamcastcard->spu_dma_work));
302}
303
304static void spu_begin_dma(struct snd_pcm_substream *substream)
305{
306 struct snd_card_aica *dreamcastcard;
307 struct snd_pcm_runtime *runtime;
308 runtime = substream->runtime;
309 dreamcastcard = substream->pcm->private_data;
310 /*get the queue to do the work */
311 queue_work(aica_queue, &(dreamcastcard->spu_dma_work));
312 /* Timer may already be running */
313 if (unlikely(dreamcastcard->timer.data)) {
314 mod_timer(&dreamcastcard->timer, jiffies + 4);
315 return;
316 }
317 init_timer(&(dreamcastcard->timer));
318 dreamcastcard->timer.data = (unsigned long) substream;
319 dreamcastcard->timer.function = aica_period_elapsed;
320 dreamcastcard->timer.expires = jiffies + 4;
321 add_timer(&(dreamcastcard->timer));
322}
323
324static int snd_aicapcm_pcm_open(struct snd_pcm_substream
325 *substream)
326{
327 struct snd_pcm_runtime *runtime;
328 struct aica_channel *channel;
329 struct snd_card_aica *dreamcastcard;
330 if (!enable)
331 return -ENOENT;
332 dreamcastcard = substream->pcm->private_data;
333 channel = kmalloc(sizeof(struct aica_channel), GFP_KERNEL);
334 if (!channel)
335 return -ENOMEM;
336 /* set defaults for channel */
337 channel->sfmt = SM_8BIT;
338 channel->cmd = AICA_CMD_START;
339 channel->vol = dreamcastcard->master_volume;
340 channel->pan = 0x80;
341 channel->pos = 0;
342 channel->flags = 0; /* default to mono */
343 dreamcastcard->channel = channel;
344 runtime = substream->runtime;
345 runtime->hw = snd_pcm_aica_playback_hw;
346 spu_enable();
347 dreamcastcard->clicks = 0;
348 dreamcastcard->current_period = 0;
349 dreamcastcard->dma_check = 0;
350 return 0;
351}
352
353static int snd_aicapcm_pcm_close(struct snd_pcm_substream
354 *substream)
355{
356 struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
357 flush_workqueue(aica_queue);
358 if (dreamcastcard->timer.data)
359 del_timer(&dreamcastcard->timer);
360 kfree(dreamcastcard->channel);
361 spu_disable();
362 return 0;
363}
364
365static int snd_aicapcm_pcm_hw_free(struct snd_pcm_substream
366 *substream)
367{
368 /* Free the DMA buffer */
369 return snd_pcm_lib_free_pages(substream);
370}
371
372static int snd_aicapcm_pcm_hw_params(struct snd_pcm_substream
373 *substream, struct snd_pcm_hw_params
374 *hw_params)
375{
376 /* Allocate a DMA buffer using ALSA built-ins */
377 return
378 snd_pcm_lib_malloc_pages(substream,
379 params_buffer_bytes(hw_params));
380}
381
382static int snd_aicapcm_pcm_prepare(struct snd_pcm_substream
383 *substream)
384{
385 struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
386 if ((substream->runtime)->format == SNDRV_PCM_FORMAT_S16_LE)
387 dreamcastcard->channel->sfmt = SM_16BIT;
388 dreamcastcard->channel->freq = substream->runtime->rate;
389 dreamcastcard->substream = substream;
390 return 0;
391}
392
393static int snd_aicapcm_pcm_trigger(struct snd_pcm_substream
394 *substream, int cmd)
395{
396 switch (cmd) {
397 case SNDRV_PCM_TRIGGER_START:
398 spu_begin_dma(substream);
399 break;
400 case SNDRV_PCM_TRIGGER_STOP:
401 aica_chn_halt();
402 break;
403 default:
404 return -EINVAL;
405 }
406 return 0;
407}
408
409static unsigned long snd_aicapcm_pcm_pointer(struct snd_pcm_substream
410 *substream)
411{
412 return readl(AICA_CONTROL_CHANNEL_SAMPLE_NUMBER);
413}
414
415static struct snd_pcm_ops snd_aicapcm_playback_ops = {
416 .open = snd_aicapcm_pcm_open,
417 .close = snd_aicapcm_pcm_close,
418 .ioctl = snd_pcm_lib_ioctl,
419 .hw_params = snd_aicapcm_pcm_hw_params,
420 .hw_free = snd_aicapcm_pcm_hw_free,
421 .prepare = snd_aicapcm_pcm_prepare,
422 .trigger = snd_aicapcm_pcm_trigger,
423 .pointer = snd_aicapcm_pcm_pointer,
424};
425
426/* TO DO: set up to handle more than one pcm instance */
427static int __init snd_aicapcmchip(struct snd_card_aica
428 *dreamcastcard, int pcm_index)
429{
430 struct snd_pcm *pcm;
431 int err;
432 /* AICA has no capture ability */
433 err =
434 snd_pcm_new(dreamcastcard->card, "AICA PCM", pcm_index, 1, 0,
435 &pcm);
436 if (unlikely(err < 0))
437 return err;
438 pcm->private_data = dreamcastcard;
439 strcpy(pcm->name, "AICA PCM");
440 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
441 &snd_aicapcm_playback_ops);
442 /* Allocate the DMA buffers */
443 err =
444 snd_pcm_lib_preallocate_pages_for_all(pcm,
445 SNDRV_DMA_TYPE_CONTINUOUS,
446 snd_dma_continuous_data
447 (GFP_KERNEL),
448 AICA_BUFFER_SIZE,
449 AICA_BUFFER_SIZE);
450 return err;
451}
452
453/* Mixer controls */
454static int aica_pcmswitch_info(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_info *uinfo)
456{
457 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
458 uinfo->count = 1;
459 uinfo->value.integer.min = 0;
460 uinfo->value.integer.max = 1;
461 return 0;
462}
463
464static int aica_pcmswitch_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
466{
467 ucontrol->value.integer.value[0] = 1; /* TO DO: Fix me */
468 return 0;
469}
470
471static int aica_pcmswitch_put(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
473{
474 if (ucontrol->value.integer.value[0] == 1)
475 return 0; /* TO DO: Fix me */
476 else
477 aica_chn_halt();
478 return 0;
479}
480
481static int aica_pcmvolume_info(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_info *uinfo)
483{
484 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
485 uinfo->count = 1;
486 uinfo->value.integer.min = 0;
487 uinfo->value.integer.max = 0xFF;
488 return 0;
489}
490
491static int aica_pcmvolume_get(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
493{
494 struct snd_card_aica *dreamcastcard;
495 dreamcastcard = kcontrol->private_data;
496 if (unlikely(!dreamcastcard->channel))
497 return -ETXTBSY; /* we've not yet been set up */
498 ucontrol->value.integer.value[0] = dreamcastcard->channel->vol;
499 return 0;
500}
501
502static int aica_pcmvolume_put(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_value *ucontrol)
504{
505 struct snd_card_aica *dreamcastcard;
506 dreamcastcard = kcontrol->private_data;
507 if (unlikely(!dreamcastcard->channel))
508 return -ETXTBSY;
509 if (unlikely(dreamcastcard->channel->vol ==
510 ucontrol->value.integer.value[0]))
511 return 0;
512 dreamcastcard->channel->vol = ucontrol->value.integer.value[0];
513 dreamcastcard->master_volume = ucontrol->value.integer.value[0];
514 spu_memload(AICA_CHANNEL0_CONTROL_OFFSET,
515 dreamcastcard->channel, sizeof(struct aica_channel));
516 return 1;
517}
518
519static struct snd_kcontrol_new snd_aica_pcmswitch_control __devinitdata = {
520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
521 .name = "PCM Playback Switch",
522 .index = 0,
523 .info = aica_pcmswitch_info,
524 .get = aica_pcmswitch_get,
525 .put = aica_pcmswitch_put
526};
527
528static struct snd_kcontrol_new snd_aica_pcmvolume_control __devinitdata = {
529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
530 .name = "PCM Playback Volume",
531 .index = 0,
532 .info = aica_pcmvolume_info,
533 .get = aica_pcmvolume_get,
534 .put = aica_pcmvolume_put
535};
536
537static int load_aica_firmware(void)
538{
539 int err;
540 const struct firmware *fw_entry;
541 spu_reset();
542 err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev);
543 if (unlikely(err))
544 return err;
545 /* write firware into memory */
546 spu_disable();
547 spu_memload(0, fw_entry->data, fw_entry->size);
548 spu_enable();
549 release_firmware(fw_entry);
550 return err;
551}
552
553static int __devinit add_aicamixer_controls(struct snd_card_aica
554 *dreamcastcard)
555{
556 int err;
557 err = snd_ctl_add
558 (dreamcastcard->card,
559 snd_ctl_new1(&snd_aica_pcmvolume_control, dreamcastcard));
560 if (unlikely(err < 0))
561 return err;
562 err = snd_ctl_add
563 (dreamcastcard->card,
564 snd_ctl_new1(&snd_aica_pcmswitch_control, dreamcastcard));
565 if (unlikely(err < 0))
566 return err;
567 return 0;
568}
569
570static int snd_aica_remove(struct platform_device *devptr)
571{
572 struct snd_card_aica *dreamcastcard;
573 dreamcastcard = platform_get_drvdata(devptr);
574 if (unlikely(!dreamcastcard))
575 return -ENODEV;
576 snd_card_free(dreamcastcard->card);
577 kfree(dreamcastcard);
578 platform_set_drvdata(devptr, NULL);
579 return 0;
580}
581
582static int __init snd_aica_probe(struct platform_device *devptr)
583{
584 int err;
585 struct snd_card_aica *dreamcastcard;
586 dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
587 if (unlikely(!dreamcastcard))
588 return -ENOMEM;
589 dreamcastcard->card =
590 snd_card_new(index, SND_AICA_DRIVER, THIS_MODULE, 0);
591 if (unlikely(!dreamcastcard->card)) {
592 kfree(dreamcastcard);
593 return -ENODEV;
594 }
595 strcpy(dreamcastcard->card->driver, "snd_aica");
596 strcpy(dreamcastcard->card->shortname, SND_AICA_DRIVER);
597 strcpy(dreamcastcard->card->longname,
598 "Yamaha AICA Super Intelligent Sound Processor for SEGA Dreamcast");
599 /* Prepare to use the queue */
600 INIT_WORK(&(dreamcastcard->spu_dma_work), run_spu_dma);
601 /* Load the PCM 'chip' */
602 err = snd_aicapcmchip(dreamcastcard, 0);
603 if (unlikely(err < 0))
604 goto freedreamcast;
605 snd_card_set_dev(dreamcastcard->card, &devptr->dev);
606 dreamcastcard->timer.data = 0;
607 dreamcastcard->channel = NULL;
608 /* Add basic controls */
609 err = add_aicamixer_controls(dreamcastcard);
610 if (unlikely(err < 0))
611 goto freedreamcast;
612 /* Register the card with ALSA subsystem */
613 err = snd_card_register(dreamcastcard->card);
614 if (unlikely(err < 0))
615 goto freedreamcast;
616 platform_set_drvdata(devptr, dreamcastcard);
617 aica_queue = create_workqueue(CARD_NAME);
618 if (unlikely(!aica_queue))
619 goto freedreamcast;
620 snd_printk
621 ("ALSA Driver for Yamaha AICA Super Intelligent Sound Processor\n");
622 return 0;
623 freedreamcast:
624 snd_card_free(dreamcastcard->card);
625 kfree(dreamcastcard);
626 return err;
627}
628
629static struct platform_driver snd_aica_driver = {
630 .probe = snd_aica_probe,
631 .remove = snd_aica_remove,
632 .driver = {
633 .name = SND_AICA_DRIVER},
634};
635
636static int __init aica_init(void)
637{
638 int err;
639 err = platform_driver_register(&snd_aica_driver);
640 if (unlikely(err < 0))
641 return err;
642 pd = platform_device_register_simple(SND_AICA_DRIVER, -1,
643 aica_memory_space, 2);
644 if (unlikely(IS_ERR(pd))) {
645 platform_driver_unregister(&snd_aica_driver);
646 return PTR_ERR(pd);
647 }
648 /* Load the firmware */
649 return load_aica_firmware();
650}
651
652static void __exit aica_exit(void)
653{
654 /* Destroy the aica kernel thread *
655 * being extra cautious to check if it exists*/
656 if (likely(aica_queue))
657 destroy_workqueue(aica_queue);
658 platform_device_unregister(pd);
659 platform_driver_unregister(&snd_aica_driver);
660 /* Kill any sound still playing and reset ARM7 to safe state */
661 spu_reset();
662}
663
664module_init(aica_init);
665module_exit(aica_exit);
diff --git a/sound/sh/aica.h b/sound/sh/aica.h
new file mode 100644
index 00000000000..8c11e3d10a5
--- /dev/null
+++ b/sound/sh/aica.h
@@ -0,0 +1,81 @@
1/* aica.h
2 * Header file for ALSA driver for
3 * Sega Dreamcast Yamaha AICA sound
4 * Copyright Adrian McMenamin
5 * <adrian@mcmen.demon.co.uk>
6 * 2006
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of version 2 of the GNU General Public License as published by
10 * the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23/* SPU memory and register constants etc */
24#define G2_FIFO 0xa05f688c
25#define SPU_MEMORY_BASE 0xA0800000
26#define ARM_RESET_REGISTER 0xA0702C00
27#define SPU_REGISTER_BASE 0xA0700000
28
29/* AICA channels stuff */
30#define AICA_CONTROL_POINT 0xA0810000
31#define AICA_CONTROL_CHANNEL_SAMPLE_NUMBER 0xA0810008
32#define AICA_CHANNEL0_CONTROL_OFFSET 0x10004
33
34/* Command values */
35#define AICA_CMD_KICK 0x80000000
36#define AICA_CMD_NONE 0
37#define AICA_CMD_START 1
38#define AICA_CMD_STOP 2
39#define AICA_CMD_VOL 3
40
41/* Sound modes */
42#define SM_8BIT 1
43#define SM_16BIT 0
44#define SM_ADPCM 2
45
46/* Buffer and period size */
47#define AICA_BUFFER_SIZE 0x8000
48#define AICA_PERIOD_SIZE 0x800
49#define AICA_PERIOD_NUMBER 16
50
51#define AICA_CHANNEL0_OFFSET 0x11000
52#define AICA_CHANNEL1_OFFSET 0x21000
53#define CHANNEL_OFFSET 0x10000
54
55#define AICA_DMA_CHANNEL 0
56#define AICA_DMA_MODE 5
57
58#define SND_AICA_DRIVER "AICA"
59
60struct aica_channel {
61 uint32_t cmd; /* Command ID */
62 uint32_t pos; /* Sample position */
63 uint32_t length; /* Sample length */
64 uint32_t freq; /* Frequency */
65 uint32_t vol; /* Volume 0-255 */
66 uint32_t pan; /* Pan 0-255 */
67 uint32_t sfmt; /* Sound format */
68 uint32_t flags; /* Bit flags */
69};
70
71struct snd_card_aica {
72 struct work_struct spu_dma_work;
73 struct snd_card *card;
74 struct aica_channel *channel;
75 struct snd_pcm_substream *substream;
76 int clicks;
77 int current_period;
78 struct timer_list timer;
79 int master_volume;
80 int dma_check;
81};
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index dccaa4be679..97b25523317 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -2,31 +2,32 @@
2# SoC audio configuration 2# SoC audio configuration
3# 3#
4 4
5menu "SoC audio support" 5menu "System on Chip audio support"
6 depends on SND!=n 6 depends on SND!=n
7 7
8config SND_SOC_AC97_BUS 8config SND_SOC_AC97_BUS
9 bool 9 bool
10 10
11config SND_SOC 11config SND_SOC
12 tristate "SoC audio support" 12 tristate "ALSA for SoC audio support"
13 depends on SND 13 depends on SND
14 select SND_PCM 14 select SND_PCM
15 ---help--- 15 ---help---
16 16
17 If you want SoC support, you should say Y here and also to the 17 If you want ASoC support, you should say Y here and also to the
18 specific driver for your SoC below. You will also need to select the 18 specific driver for your SoC platform below.
19 specific codec(s) attached to the SoC 19
20 ASoC provides power efficient ALSA support for embedded battery powered
21 SoC based systems like PDA's, Phones and Personal Media Players.
20 22
21 This SoC audio support can also be built as a module. If so, the module 23 This ASoC audio support can also be built as a module. If so, the module
22 will be called snd-soc-core. 24 will be called snd-soc-core.
23 25
24# All the supported Soc's 26# All the supported Soc's
25menu "SoC Platforms"
26depends on SND_SOC
27source "sound/soc/at91/Kconfig" 27source "sound/soc/at91/Kconfig"
28source "sound/soc/pxa/Kconfig" 28source "sound/soc/pxa/Kconfig"
29endmenu 29source "sound/soc/s3c24xx/Kconfig"
30source "sound/soc/sh/Kconfig"
30 31
31# Supported codecs 32# Supported codecs
32source "sound/soc/codecs/Kconfig" 33source "sound/soc/codecs/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 98e6f49dafc..30414037763 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,4 +1,4 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o 1snd-soc-core-objs := soc-core.o soc-dapm.o
2 2
3obj-$(CONFIG_SND_SOC) += snd-soc-core.o 3obj-$(CONFIG_SND_SOC) += snd-soc-core.o
4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ 4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/
diff --git a/sound/soc/at91/Kconfig b/sound/soc/at91/Kconfig
index a5b2558916c..5cb93fd3a40 100644
--- a/sound/soc/at91/Kconfig
+++ b/sound/soc/at91/Kconfig
@@ -1,5 +1,3 @@
1menu "SoC Audio for the Atmel AT91"
2
3config SND_AT91_SOC 1config SND_AT91_SOC
4 tristate "SoC Audio for the Atmel AT91 System-on-Chip" 2 tristate "SoC Audio for the Atmel AT91 System-on-Chip"
5 depends on ARCH_AT91 && SND_SOC 3 depends on ARCH_AT91 && SND_SOC
@@ -8,13 +6,13 @@ config SND_AT91_SOC
8 the AT91 SSC interface. You will also need 6 the AT91 SSC interface. You will also need
9 to select the audio interfaces to support below. 7 to select the audio interfaces to support below.
10 8
11config SND_AT91_SOC_I2S 9config SND_AT91_SOC_SSC
12 tristate 10 tristate
13 11
14config SND_AT91_SOC_ETI_B1_WM8731 12config SND_AT91_SOC_ETI_B1_WM8731
15 tristate "SoC I2S Audio support for WM8731-based Endrelia ETI-B1 boards" 13 tristate "SoC Audio support for WM8731-based Endrelia ETI-B1 boards"
16 depends on SND_AT91_SOC && (MACH_ETI_B1 || MACH_ETI_C1) 14 depends on SND_AT91_SOC && (MACH_ETI_B1 || MACH_ETI_C1)
17 select SND_AT91_SOC_I2S 15 select SND_AT91_SOC_SSC
18 select SND_SOC_WM8731 16 select SND_SOC_WM8731
19 help 17 help
20 Say Y if you want to add support for SoC audio on WM8731-based 18 Say Y if you want to add support for SoC audio on WM8731-based
@@ -27,5 +25,3 @@ config SND_AT91_SOC_ETI_SLAVE
27 help 25 help
28 Say Y if you want to run with the AT91 SSC generating the BCLK 26 Say Y if you want to run with the AT91 SSC generating the BCLK
29 and LRC signals on Endrelia boards. 27 and LRC signals on Endrelia boards.
30
31endmenu
diff --git a/sound/soc/at91/Makefile b/sound/soc/at91/Makefile
index b77b01ab202..f23da17cc32 100644
--- a/sound/soc/at91/Makefile
+++ b/sound/soc/at91/Makefile
@@ -1,9 +1,9 @@
1# AT91 Platform Support 1# AT91 Platform Support
2snd-soc-at91-objs := at91-pcm.o 2snd-soc-at91-objs := at91-pcm.o
3snd-soc-at91-i2s-objs := at91-i2s.o 3snd-soc-at91-ssc-objs := at91-ssc.o
4 4
5obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o 5obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o
6obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o 6obj-$(CONFIG_SND_AT91_SOC_SSC) += snd-soc-at91-ssc.o
7 7
8# AT91 Machine Support 8# AT91 Machine Support
9snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o 9snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o
diff --git a/sound/soc/at91/at91-i2s.c b/sound/soc/at91/at91-ssc.c
index 9fc0c038888..3d4e32cff75 100644
--- a/sound/soc/at91/at91-i2s.c
+++ b/sound/soc/at91/at91-ssc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * at91-i2s.c -- ALSA SoC I2S Audio Layer Platform driver 2 * at91-ssc.c -- ALSA SoC AT91 SSC Audio Layer Platform driver
3 * 3 *
4 * Author: Frank Mandarino <fmandarino@endrelia.com> 4 * Author: Frank Mandarino <fmandarino@endrelia.com>
5 * Endrelia Technologies Inc. 5 * Endrelia Technologies Inc.
@@ -25,6 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <sound/core.h> 26#include <sound/core.h>
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
28#include <sound/initval.h> 29#include <sound/initval.h>
29#include <sound/soc.h> 30#include <sound/soc.h>
30 31
@@ -33,10 +34,10 @@
33#include <asm/arch/at91_ssc.h> 34#include <asm/arch/at91_ssc.h>
34 35
35#include "at91-pcm.h" 36#include "at91-pcm.h"
36#include "at91-i2s.h" 37#include "at91-ssc.h"
37 38
38#if 0 39#if 0
39#define DBG(x...) printk(KERN_DEBUG "at91-i2s:" x) 40#define DBG(x...) printk(KERN_DEBUG "at91-ssc:" x)
40#else 41#else
41#define DBG(x...) 42#define DBG(x...)
42#endif 43#endif
@@ -92,33 +93,33 @@ static struct at91_ssc_mask ssc_rx_mask = {
92 */ 93 */
93static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = { 94static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
94 {{ 95 {{
95 .name = "SSC0/I2S PCM Stereo out", 96 .name = "SSC0 PCM out",
96 .pdc = &pdc_tx_reg, 97 .pdc = &pdc_tx_reg,
97 .mask = &ssc_tx_mask, 98 .mask = &ssc_tx_mask,
98 }, 99 },
99 { 100 {
100 .name = "SSC0/I2S PCM Stereo in", 101 .name = "SSC0 PCM in",
101 .pdc = &pdc_rx_reg, 102 .pdc = &pdc_rx_reg,
102 .mask = &ssc_rx_mask, 103 .mask = &ssc_rx_mask,
103 }}, 104 }},
104#if NUM_SSC_DEVICES == 3 105#if NUM_SSC_DEVICES == 3
105 {{ 106 {{
106 .name = "SSC1/I2S PCM Stereo out", 107 .name = "SSC1 PCM out",
107 .pdc = &pdc_tx_reg, 108 .pdc = &pdc_tx_reg,
108 .mask = &ssc_tx_mask, 109 .mask = &ssc_tx_mask,
109 }, 110 },
110 { 111 {
111 .name = "SSC1/I2S PCM Stereo in", 112 .name = "SSC1 PCM in",
112 .pdc = &pdc_rx_reg, 113 .pdc = &pdc_rx_reg,
113 .mask = &ssc_rx_mask, 114 .mask = &ssc_rx_mask,
114 }}, 115 }},
115 {{ 116 {{
116 .name = "SSC2/I2S PCM Stereo out", 117 .name = "SSC2 PCM out",
117 .pdc = &pdc_tx_reg, 118 .pdc = &pdc_tx_reg,
118 .mask = &ssc_tx_mask, 119 .mask = &ssc_tx_mask,
119 }, 120 },
120 { 121 {
121 .name = "SSC1/I2S PCM Stereo in", 122 .name = "SSC2 PCM in",
122 .pdc = &pdc_rx_reg, 123 .pdc = &pdc_rx_reg,
123 .mask = &ssc_rx_mask, 124 .mask = &ssc_rx_mask,
124 }}, 125 }},
@@ -151,33 +152,33 @@ static struct at91_ssc_info {
151} ssc_info[NUM_SSC_DEVICES] = { 152} ssc_info[NUM_SSC_DEVICES] = {
152 { 153 {
153 .name = "ssc0", 154 .name = "ssc0",
154 .lock = SPIN_LOCK_UNLOCKED, 155 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[0].lock),
155 .dir_mask = 0, 156 .dir_mask = 0,
156 .initialized = 0, 157 .initialized = 0,
157 }, 158 },
158#if NUM_SSC_DEVICES == 3 159#if NUM_SSC_DEVICES == 3
159 { 160 {
160 .name = "ssc1", 161 .name = "ssc1",
161 .lock = SPIN_LOCK_UNLOCKED, 162 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock),
162 .dir_mask = 0, 163 .dir_mask = 0,
163 .initialized = 0, 164 .initialized = 0,
164 }, 165 },
165 { 166 {
166 .name = "ssc2", 167 .name = "ssc2",
167 .lock = SPIN_LOCK_UNLOCKED, 168 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[2].lock),
168 .dir_mask = 0, 169 .dir_mask = 0,
169 .initialized = 0, 170 .initialized = 0,
170 }, 171 },
171#endif 172#endif
172}; 173};
173 174
174static unsigned int at91_i2s_sysclk; 175static unsigned int at91_ssc_sysclk;
175 176
176/* 177/*
177 * SSC interrupt handler. Passes PDC interrupts to the DMA 178 * SSC interrupt handler. Passes PDC interrupts to the DMA
178 * interrupt handler in the PCM driver. 179 * interrupt handler in the PCM driver.
179 */ 180 */
180static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id) 181static irqreturn_t at91_ssc_interrupt(int irq, void *dev_id)
181{ 182{
182 struct at91_ssc_info *ssc_p = dev_id; 183 struct at91_ssc_info *ssc_p = dev_id;
183 struct at91_pcm_dma_params *dma_params; 184 struct at91_pcm_dma_params *dma_params;
@@ -209,13 +210,13 @@ static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id)
209/* 210/*
210 * Startup. Only that one substream allowed in each direction. 211 * Startup. Only that one substream allowed in each direction.
211 */ 212 */
212static int at91_i2s_startup(struct snd_pcm_substream *substream) 213static int at91_ssc_startup(struct snd_pcm_substream *substream)
213{ 214{
214 struct snd_soc_pcm_runtime *rtd = substream->private_data; 215 struct snd_soc_pcm_runtime *rtd = substream->private_data;
215 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 216 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
216 int dir_mask; 217 int dir_mask;
217 218
218 DBG("i2s_startup: SSC_SR=0x%08lx\n", 219 DBG("ssc_startup: SSC_SR=0x%08lx\n",
219 at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)); 220 at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
220 dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2; 221 dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2;
221 222
@@ -234,7 +235,7 @@ static int at91_i2s_startup(struct snd_pcm_substream *substream)
234 * Shutdown. Clear DMA parameters and shutdown the SSC if there 235 * Shutdown. Clear DMA parameters and shutdown the SSC if there
235 * are no other substreams open. 236 * are no other substreams open.
236 */ 237 */
237static void at91_i2s_shutdown(struct snd_pcm_substream *substream) 238static void at91_ssc_shutdown(struct snd_pcm_substream *substream)
238{ 239{
239 struct snd_soc_pcm_runtime *rtd = substream->private_data; 240 struct snd_soc_pcm_runtime *rtd = substream->private_data;
240 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 241 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
@@ -281,7 +282,7 @@ static void at91_i2s_shutdown(struct snd_pcm_substream *substream)
281/* 282/*
282 * Record the SSC system clock rate. 283 * Record the SSC system clock rate.
283 */ 284 */
284static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai, 285static int at91_ssc_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
285 int clk_id, unsigned int freq, int dir) 286 int clk_id, unsigned int freq, int dir)
286{ 287{
287 /* 288 /*
@@ -291,7 +292,7 @@ static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
291 */ 292 */
292 switch (clk_id) { 293 switch (clk_id) {
293 case AT91_SYSCLK_MCK: 294 case AT91_SYSCLK_MCK:
294 at91_i2s_sysclk = freq; 295 at91_ssc_sysclk = freq;
295 break; 296 break;
296 default: 297 default:
297 return -EINVAL; 298 return -EINVAL;
@@ -303,14 +304,11 @@ static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
303/* 304/*
304 * Record the DAI format for use in hw_params(). 305 * Record the DAI format for use in hw_params().
305 */ 306 */
306static int at91_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai, 307static int at91_ssc_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
307 unsigned int fmt) 308 unsigned int fmt)
308{ 309{
309 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 310 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
310 311
311 if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S)
312 return -EINVAL;
313
314 ssc_p->daifmt = fmt; 312 ssc_p->daifmt = fmt;
315 return 0; 313 return 0;
316} 314}
@@ -318,7 +316,7 @@ static int at91_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
318/* 316/*
319 * Record SSC clock dividers for use in hw_params(). 317 * Record SSC clock dividers for use in hw_params().
320 */ 318 */
321static int at91_i2s_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai, 319static int at91_ssc_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
322 int div_id, int div) 320 int div_id, int div)
323{ 321{
324 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 322 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
@@ -355,7 +353,7 @@ static int at91_i2s_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
355/* 353/*
356 * Configure the SSC. 354 * Configure the SSC.
357 */ 355 */
358static int at91_i2s_hw_params(struct snd_pcm_substream *substream, 356static int at91_ssc_hw_params(struct snd_pcm_substream *substream,
359 struct snd_pcm_hw_params *params) 357 struct snd_pcm_hw_params *params)
360{ 358{
361 struct snd_soc_pcm_runtime *rtd = substream->private_data; 359 struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -391,20 +389,50 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
391 channels = params_channels(params); 389 channels = params_channels(params);
392 390
393 /* 391 /*
392 * Determine sample size in bits and the PDC increment.
393 */
394 switch(params_format(params)) {
395 case SNDRV_PCM_FORMAT_S8:
396 bits = 8;
397 dma_params->pdc_xfer_size = 1;
398 break;
399 case SNDRV_PCM_FORMAT_S16_LE:
400 bits = 16;
401 dma_params->pdc_xfer_size = 2;
402 break;
403 case SNDRV_PCM_FORMAT_S24_LE:
404 bits = 24;
405 dma_params->pdc_xfer_size = 4;
406 break;
407 case SNDRV_PCM_FORMAT_S32_LE:
408 bits = 32;
409 dma_params->pdc_xfer_size = 4;
410 break;
411 default:
412 printk(KERN_WARNING "at91-ssc: unsupported PCM format");
413 return -EINVAL;
414 }
415
416 /*
394 * The SSC only supports up to 16-bit samples in I2S format, due 417 * The SSC only supports up to 16-bit samples in I2S format, due
395 * to the size of the Frame Mode Register FSLEN field. Also, I2S 418 * to the size of the Frame Mode Register FSLEN field.
396 * implies signed data.
397 */ 419 */
398 bits = 16; 420 if ((ssc_p->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S
399 dma_params->pdc_xfer_size = 2; 421 && bits > 16) {
422 printk(KERN_WARNING
423 "at91-ssc: sample size %d is too large for I2S\n", bits);
424 return -EINVAL;
425 }
400 426
401 /* 427 /*
402 * Compute SSC register settings. 428 * Compute SSC register settings.
403 */ 429 */
404 switch (ssc_p->daifmt) { 430 switch (ssc_p->daifmt
405 case SND_SOC_DAIFMT_CBS_CFS: 431 & (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_MASTER_MASK)) {
432
433 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS:
406 /* 434 /*
407 * SSC provides BCLK and LRC clocks. 435 * I2S format, SSC provides BCLK and LRC clocks.
408 * 436 *
409 * The SSC transmit and receive clocks are generated from the 437 * The SSC transmit and receive clocks are generated from the
410 * MCK divider, and the BCLK signal is output on the SSC TK line. 438 * MCK divider, and the BCLK signal is output on the SSC TK line.
@@ -441,10 +469,9 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
441 | (((bits - 1) << 0) & AT91_SSC_DATALEN); 469 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
442 break; 470 break;
443 471
444 case SND_SOC_DAIFMT_CBM_CFM: 472 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM:
445
446 /* 473 /*
447 * CODEC supplies BCLK and LRC clocks. 474 * I2S format, CODEC supplies BCLK and LRC clocks.
448 * 475 *
449 * The SSC transmit clock is obtained from the BCLK signal on 476 * The SSC transmit clock is obtained from the BCLK signal on
450 * on the TK line, and the SSC receive clock is generated from the 477 * on the TK line, and the SSC receive clock is generated from the
@@ -490,10 +517,51 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
490 | (((bits - 1) << 0) & AT91_SSC_DATALEN); 517 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
491 break; 518 break;
492 519
493 case SND_SOC_DAIFMT_CBS_CFM: 520 case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS:
494 case SND_SOC_DAIFMT_CBM_CFS: 521 /*
522 * DSP/PCM Mode A format, SSC provides BCLK and LRC clocks.
523 *
524 * The SSC transmit and receive clocks are generated from the
525 * MCK divider, and the BCLK signal is output on the SSC TK line.
526 */
527 rcmr = (( ssc_p->rcmr_period << 24) & AT91_SSC_PERIOD)
528 | (( 1 << 16) & AT91_SSC_STTDLY)
529 | (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
530 | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
531 | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
532 | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
533
534 rfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
535 | (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
536 | (( 0 << 16) & AT91_SSC_FSLEN)
537 | (((channels - 1) << 8) & AT91_SSC_DATNB)
538 | (( 1 << 7) & AT91_SSC_MSBF)
539 | (( 0 << 5) & AT91_SSC_LOOP)
540 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
541
542 tcmr = (( ssc_p->tcmr_period << 24) & AT91_SSC_PERIOD)
543 | (( 1 << 16) & AT91_SSC_STTDLY)
544 | (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
545 | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
546 | (( AT91_SSC_CKO_CONTINUOUS ) & AT91_SSC_CKO)
547 | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
548
549 tfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
550 | (( 0 << 23) & AT91_SSC_FSDEN)
551 | (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
552 | (( 0 << 16) & AT91_SSC_FSLEN)
553 | (((channels - 1) << 8) & AT91_SSC_DATNB)
554 | (( 1 << 7) & AT91_SSC_MSBF)
555 | (( 0 << 5) & AT91_SSC_DATDEF)
556 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
557
558
559
560 break;
561
562 case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBM_CFM:
495 default: 563 default:
496 printk(KERN_WARNING "at91-i2s: unsupported DAI format 0x%x.\n", 564 printk(KERN_WARNING "at91-ssc: unsupported DAI format 0x%x.\n",
497 ssc_p->daifmt); 565 ssc_p->daifmt);
498 return -EINVAL; 566 return -EINVAL;
499 break; 567 break;
@@ -518,9 +586,9 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
518 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNPR, 0); 586 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNPR, 0);
519 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNCR, 0); 587 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNCR, 0);
520 588
521 if ((ret = request_irq(ssc_p->ssc.pid, at91_i2s_interrupt, 589 if ((ret = request_irq(ssc_p->ssc.pid, at91_ssc_interrupt,
522 0, ssc_p->name, ssc_p)) < 0) { 590 0, ssc_p->name, ssc_p)) < 0) {
523 printk(KERN_WARNING "at91-i2s: request_irq failure\n"); 591 printk(KERN_WARNING "at91-ssc: request_irq failure\n");
524 592
525 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid); 593 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
526 at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid); 594 at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
@@ -546,7 +614,7 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
546} 614}
547 615
548 616
549static int at91_i2s_prepare(struct snd_pcm_substream *substream) 617static int at91_ssc_prepare(struct snd_pcm_substream *substream)
550{ 618{
551 struct snd_soc_pcm_runtime *rtd = substream->private_data; 619 struct snd_soc_pcm_runtime *rtd = substream->private_data;
552 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 620 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
@@ -566,7 +634,7 @@ static int at91_i2s_prepare(struct snd_pcm_substream *substream)
566 634
567 635
568#ifdef CONFIG_PM 636#ifdef CONFIG_PM
569static int at91_i2s_suspend(struct platform_device *pdev, 637static int at91_ssc_suspend(struct platform_device *pdev,
570 struct snd_soc_cpu_dai *cpu_dai) 638 struct snd_soc_cpu_dai *cpu_dai)
571{ 639{
572 struct at91_ssc_info *ssc_p; 640 struct at91_ssc_info *ssc_p;
@@ -594,7 +662,7 @@ static int at91_i2s_suspend(struct platform_device *pdev,
594 return 0; 662 return 0;
595} 663}
596 664
597static int at91_i2s_resume(struct platform_device *pdev, 665static int at91_ssc_resume(struct platform_device *pdev,
598 struct snd_soc_cpu_dai *cpu_dai) 666 struct snd_soc_cpu_dai *cpu_dai)
599{ 667{
600 struct at91_ssc_info *ssc_p; 668 struct at91_ssc_info *ssc_p;
@@ -620,102 +688,105 @@ static int at91_i2s_resume(struct platform_device *pdev,
620} 688}
621 689
622#else 690#else
623#define at91_i2s_suspend NULL 691#define at91_ssc_suspend NULL
624#define at91_i2s_resume NULL 692#define at91_ssc_resume NULL
625#endif 693#endif
626 694
627#define AT91_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 695#define AT91_SSC_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
628 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 696 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
629 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ 697 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
630 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ 698 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
631 SNDRV_PCM_RATE_96000) 699 SNDRV_PCM_RATE_96000)
632 700
633struct snd_soc_cpu_dai at91_i2s_dai[NUM_SSC_DEVICES] = { 701#define AT91_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
634 { .name = "at91_ssc0/i2s", 702 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
703
704struct snd_soc_cpu_dai at91_ssc_dai[NUM_SSC_DEVICES] = {
705 { .name = "at91-ssc0",
635 .id = 0, 706 .id = 0,
636 .type = SND_SOC_DAI_I2S, 707 .type = SND_SOC_DAI_PCM,
637 .suspend = at91_i2s_suspend, 708 .suspend = at91_ssc_suspend,
638 .resume = at91_i2s_resume, 709 .resume = at91_ssc_resume,
639 .playback = { 710 .playback = {
640 .channels_min = 1, 711 .channels_min = 1,
641 .channels_max = 2, 712 .channels_max = 2,
642 .rates = AT91_I2S_RATES, 713 .rates = AT91_SSC_RATES,
643 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 714 .formats = AT91_SSC_FORMATS,},
644 .capture = { 715 .capture = {
645 .channels_min = 1, 716 .channels_min = 1,
646 .channels_max = 2, 717 .channels_max = 2,
647 .rates = AT91_I2S_RATES, 718 .rates = AT91_SSC_RATES,
648 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 719 .formats = AT91_SSC_FORMATS,},
649 .ops = { 720 .ops = {
650 .startup = at91_i2s_startup, 721 .startup = at91_ssc_startup,
651 .shutdown = at91_i2s_shutdown, 722 .shutdown = at91_ssc_shutdown,
652 .prepare = at91_i2s_prepare, 723 .prepare = at91_ssc_prepare,
653 .hw_params = at91_i2s_hw_params,}, 724 .hw_params = at91_ssc_hw_params,},
654 .dai_ops = { 725 .dai_ops = {
655 .set_sysclk = at91_i2s_set_dai_sysclk, 726 .set_sysclk = at91_ssc_set_dai_sysclk,
656 .set_fmt = at91_i2s_set_dai_fmt, 727 .set_fmt = at91_ssc_set_dai_fmt,
657 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 728 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
658 .private_data = &ssc_info[0].ssc, 729 .private_data = &ssc_info[0].ssc,
659 }, 730 },
660#if NUM_SSC_DEVICES == 3 731#if NUM_SSC_DEVICES == 3
661 { .name = "at91_ssc1/i2s", 732 { .name = "at91-ssc1",
662 .id = 1, 733 .id = 1,
663 .type = SND_SOC_DAI_I2S, 734 .type = SND_SOC_DAI_PCM,
664 .suspend = at91_i2s_suspend, 735 .suspend = at91_ssc_suspend,
665 .resume = at91_i2s_resume, 736 .resume = at91_ssc_resume,
666 .playback = { 737 .playback = {
667 .channels_min = 1, 738 .channels_min = 1,
668 .channels_max = 2, 739 .channels_max = 2,
669 .rates = AT91_I2S_RATES, 740 .rates = AT91_SSC_RATES,
670 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 741 .formats = AT91_SSC_FORMATS,},
671 .capture = { 742 .capture = {
672 .channels_min = 1, 743 .channels_min = 1,
673 .channels_max = 2, 744 .channels_max = 2,
674 .rates = AT91_I2S_RATES, 745 .rates = AT91_SSC_RATES,
675 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 746 .formats = AT91_SSC_FORMATS,},
676 .ops = { 747 .ops = {
677 .startup = at91_i2s_startup, 748 .startup = at91_ssc_startup,
678 .shutdown = at91_i2s_shutdown, 749 .shutdown = at91_ssc_shutdown,
679 .prepare = at91_i2s_prepare, 750 .prepare = at91_ssc_prepare,
680 .hw_params = at91_i2s_hw_params,}, 751 .hw_params = at91_ssc_hw_params,},
681 .dai_ops = { 752 .dai_ops = {
682 .set_sysclk = at91_i2s_set_dai_sysclk, 753 .set_sysclk = at91_ssc_set_dai_sysclk,
683 .set_fmt = at91_i2s_set_dai_fmt, 754 .set_fmt = at91_ssc_set_dai_fmt,
684 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 755 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
685 .private_data = &ssc_info[1].ssc, 756 .private_data = &ssc_info[1].ssc,
686 }, 757 },
687 { .name = "at91_ssc2/i2s", 758 { .name = "at91-ssc2",
688 .id = 2, 759 .id = 2,
689 .type = SND_SOC_DAI_I2S, 760 .type = SND_SOC_DAI_PCM,
690 .suspend = at91_i2s_suspend, 761 .suspend = at91_ssc_suspend,
691 .resume = at91_i2s_resume, 762 .resume = at91_ssc_resume,
692 .playback = { 763 .playback = {
693 .channels_min = 1, 764 .channels_min = 1,
694 .channels_max = 2, 765 .channels_max = 2,
695 .rates = AT91_I2S_RATES, 766 .rates = AT91_SSC_RATES,
696 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 767 .formats = AT91_SSC_FORMATS,},
697 .capture = { 768 .capture = {
698 .channels_min = 1, 769 .channels_min = 1,
699 .channels_max = 2, 770 .channels_max = 2,
700 .rates = AT91_I2S_RATES, 771 .rates = AT91_SSC_RATES,
701 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 772 .formats = AT91_SSC_FORMATS,},
702 .ops = { 773 .ops = {
703 .startup = at91_i2s_startup, 774 .startup = at91_ssc_startup,
704 .shutdown = at91_i2s_shutdown, 775 .shutdown = at91_ssc_shutdown,
705 .prepare = at91_i2s_prepare, 776 .prepare = at91_ssc_prepare,
706 .hw_params = at91_i2s_hw_params,}, 777 .hw_params = at91_ssc_hw_params,},
707 .dai_ops = { 778 .dai_ops = {
708 .set_sysclk = at91_i2s_set_dai_sysclk, 779 .set_sysclk = at91_ssc_set_dai_sysclk,
709 .set_fmt = at91_i2s_set_dai_fmt, 780 .set_fmt = at91_ssc_set_dai_fmt,
710 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 781 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
711 .private_data = &ssc_info[2].ssc, 782 .private_data = &ssc_info[2].ssc,
712 }, 783 },
713#endif 784#endif
714}; 785};
715 786
716EXPORT_SYMBOL_GPL(at91_i2s_dai); 787EXPORT_SYMBOL_GPL(at91_ssc_dai);
717 788
718/* Module information */ 789/* Module information */
719MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com"); 790MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com");
720MODULE_DESCRIPTION("AT91 I2S ASoC Interface"); 791MODULE_DESCRIPTION("AT91 SSC ASoC Interface");
721MODULE_LICENSE("GPL"); 792MODULE_LICENSE("GPL");
diff --git a/sound/soc/at91/at91-i2s.h b/sound/soc/at91/at91-ssc.h
index f8a875ba0cc..b188f973df9 100644
--- a/sound/soc/at91/at91-i2s.h
+++ b/sound/soc/at91/at91-ssc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * at91-i2s.h - ALSA I2S interface for the Atmel AT91 SoC 2 * at91-ssc.h - ALSA SSC interface for the Atmel AT91 SoC
3 * 3 *
4 * Author: Frank Mandarino <fmandarino@endrelia.com> 4 * Author: Frank Mandarino <fmandarino@endrelia.com>
5 * Endrelia Technologies Inc. 5 * Endrelia Technologies Inc.
@@ -10,18 +10,18 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#ifndef _AT91_I2S_H 13#ifndef _AT91_SSC_H
14#define _AT91_I2S_H 14#define _AT91_SSC_H
15 15
16/* I2S system clock ids */ 16/* SSC system clock ids */
17#define AT91_SYSCLK_MCK 0 /* SSC uses AT91 MCK as system clock */ 17#define AT91_SYSCLK_MCK 0 /* SSC uses AT91 MCK as system clock */
18 18
19/* I2S divider ids */ 19/* SSC divider ids */
20#define AT91SSC_CMR_DIV 0 /* MCK divider for BCLK */ 20#define AT91SSC_CMR_DIV 0 /* MCK divider for BCLK */
21#define AT91SSC_TCMR_PERIOD 1 /* BCLK divider for transmit FS */ 21#define AT91SSC_TCMR_PERIOD 1 /* BCLK divider for transmit FS */
22#define AT91SSC_RCMR_PERIOD 2 /* BCLK divider for receive FS */ 22#define AT91SSC_RCMR_PERIOD 2 /* BCLK divider for receive FS */
23 23
24extern struct snd_soc_cpu_dai at91_i2s_dai[]; 24extern struct snd_soc_cpu_dai at91_ssc_dai[];
25 25
26#endif /* _AT91_I2S_H */ 26#endif /* _AT91_SSC_H */
27 27
diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c
index 8179df3bb2f..820a676c56b 100644
--- a/sound/soc/at91/eti_b1_wm8731.c
+++ b/sound/soc/at91/eti_b1_wm8731.c
@@ -40,7 +40,7 @@
40 40
41#include "../codecs/wm8731.h" 41#include "../codecs/wm8731.h"
42#include "at91-pcm.h" 42#include "at91-pcm.h"
43#include "at91-i2s.h" 43#include "at91-ssc.h"
44 44
45#if 0 45#if 0
46#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731: " x) 46#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731: " x)
@@ -248,15 +248,15 @@ static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
248 248
249static struct snd_soc_dai_link eti_b1_dai = { 249static struct snd_soc_dai_link eti_b1_dai = {
250 .name = "WM8731", 250 .name = "WM8731",
251 .stream_name = "WM8731", 251 .stream_name = "WM8731 PCM",
252 .cpu_dai = &at91_i2s_dai[1], 252 .cpu_dai = &at91_ssc_dai[1],
253 .codec_dai = &wm8731_dai, 253 .codec_dai = &wm8731_dai,
254 .init = eti_b1_wm8731_init, 254 .init = eti_b1_wm8731_init,
255 .ops = &eti_b1_ops, 255 .ops = &eti_b1_ops,
256}; 256};
257 257
258static struct snd_soc_machine snd_soc_machine_eti_b1 = { 258static struct snd_soc_machine snd_soc_machine_eti_b1 = {
259 .name = "ETI_B1", 259 .name = "ETI_B1_WM8731",
260 .dai_link = &eti_b1_dai, 260 .dai_link = &eti_b1_dai,
261 .num_links = 1, 261 .num_links = 1,
262}; 262};
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ec2a2787957..e5fb437b86e 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -10,6 +10,10 @@ config SND_SOC_WM8750
10 tristate 10 tristate
11 depends on SND_SOC 11 depends on SND_SOC
12 12
13config SND_SOC_WM8753
14 tristate
15 depends on SND_SOC
16
13config SND_SOC_WM9712 17config SND_SOC_WM9712
14 tristate 18 tristate
15 depends on SND_SOC 19 depends on SND_SOC
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 3249a6e4f1d..e39a747a17c 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -1,9 +1,11 @@
1snd-soc-ac97-objs := ac97.o 1snd-soc-ac97-objs := ac97.o
2snd-soc-wm8731-objs := wm8731.o 2snd-soc-wm8731-objs := wm8731.o
3snd-soc-wm8750-objs := wm8750.o 3snd-soc-wm8750-objs := wm8750.o
4snd-soc-wm8753-objs := wm8753.o
4snd-soc-wm9712-objs := wm9712.o 5snd-soc-wm9712-objs := wm9712.o
5 6
6obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o 7obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o
7obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o 8obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o
8obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o 9obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o
10obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o
9obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 11obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index 55bc55eb6e2..0b8a6f8b366 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -43,8 +43,9 @@ static int ac97_prepare(struct snd_pcm_substream *substream)
43#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 43#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
44 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 44 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
45 45
46static struct snd_soc_codec_dai ac97_dai = { 46struct snd_soc_codec_dai ac97_dai = {
47 .name = "AC97 HiFi", 47 .name = "AC97 HiFi",
48 .type = SND_SOC_DAI_AC97,
48 .playback = { 49 .playback = {
49 .stream_name = "AC97 Playback", 50 .stream_name = "AC97 Playback",
50 .channels_min = 1, 51 .channels_min = 1,
@@ -60,6 +61,7 @@ static struct snd_soc_codec_dai ac97_dai = {
60 .ops = { 61 .ops = {
61 .prepare = ac97_prepare,}, 62 .prepare = ac97_prepare,},
62}; 63};
64EXPORT_SYMBOL_GPL(ac97_dai);
63 65
64static unsigned int ac97_read(struct snd_soc_codec *codec, 66static unsigned int ac97_read(struct snd_soc_codec *codec,
65 unsigned int reg) 67 unsigned int reg)
diff --git a/sound/soc/codecs/ac97.h b/sound/soc/codecs/ac97.h
index 930ddfc2321..2bf6d69fd06 100644
--- a/sound/soc/codecs/ac97.h
+++ b/sound/soc/codecs/ac97.h
@@ -14,5 +14,6 @@
14#define __LINUX_SND_SOC_AC97_H 14#define __LINUX_SND_SOC_AC97_H
15 15
16extern struct snd_soc_codec_device soc_codec_dev_ac97; 16extern struct snd_soc_codec_device soc_codec_dev_ac97;
17extern struct snd_soc_codec_dai ac97_dai;
17 18
18#endif 19#endif
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 7073e8e294f..28684eeda73 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -808,7 +808,7 @@ static int wm8750_init(struct snd_soc_device *socdev)
808 codec->dai = &wm8750_dai; 808 codec->dai = &wm8750_dai;
809 codec->num_dai = 1; 809 codec->num_dai = 1;
810 codec->reg_cache_size = sizeof(wm8750_reg); 810 codec->reg_cache_size = sizeof(wm8750_reg);
811 codec->reg_cache = kmemdup(wm8750_reg, sizeof(wm8750_reg), GFP_KRENEL); 811 codec->reg_cache = kmemdup(wm8750_reg, sizeof(wm8750_reg), GFP_KERNEL);
812 if (codec->reg_cache == NULL) 812 if (codec->reg_cache == NULL)
813 return -ENOMEM; 813 return -ENOMEM;
814 814
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
new file mode 100644
index 00000000000..efced934566
--- /dev/null
+++ b/sound/soc/codecs/wm8753.c
@@ -0,0 +1,1811 @@
1/*
2 * wm8753.c -- WM8753 ALSA Soc Audio driver
3 *
4 * Copyright 2003 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Notes:
14 * The WM8753 is a low power, high quality stereo codec with integrated PCM
15 * codec designed for portable digital telephony applications.
16 *
17 * Dual DAI:-
18 *
19 * This driver support 2 DAI PCM's. This makes the default PCM available for
20 * HiFi audio (e.g. MP3, ogg) playback/capture and the other PCM available for
21 * voice.
22 *
23 * Please note that the voice PCM can be connected directly to a Bluetooth
24 * codec or GSM modem and thus cannot be read or written to, although it is
25 * available to be configured with snd_hw_params(), etc and kcontrols in the
26 * normal alsa manner.
27 *
28 * Fast DAI switching:-
29 *
30 * The driver can now fast switch between the DAI configurations via a
31 * an alsa kcontrol. This allows the PCM to remain open.
32 *
33 */
34
35#include <linux/module.h>
36#include <linux/moduleparam.h>
37#include <linux/version.h>
38#include <linux/kernel.h>
39#include <linux/init.h>
40#include <linux/delay.h>
41#include <linux/pm.h>
42#include <linux/i2c.h>
43#include <linux/platform_device.h>
44#include <sound/driver.h>
45#include <sound/core.h>
46#include <sound/pcm.h>
47#include <sound/pcm_params.h>
48#include <sound/soc.h>
49#include <sound/soc-dapm.h>
50#include <sound/initval.h>
51#include <asm/div64.h>
52
53#include "wm8753.h"
54
55#define AUDIO_NAME "wm8753"
56#define WM8753_VERSION "0.16"
57
58/*
59 * Debug
60 */
61
62#define WM8753_DEBUG 0
63
64#ifdef WM8753_DEBUG
65#define dbg(format, arg...) \
66 printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
67#else
68#define dbg(format, arg...) do {} while (0)
69#endif
70#define err(format, arg...) \
71 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
72#define info(format, arg...) \
73 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
74#define warn(format, arg...) \
75 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
76
77static int caps_charge = 2000;
78module_param(caps_charge, int, 0);
79MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
80
81static void wm8753_set_dai_mode(struct snd_soc_codec *codec,
82 unsigned int mode);
83
84/* codec private data */
85struct wm8753_priv {
86 unsigned int sysclk;
87 unsigned int pcmclk;
88};
89
90/*
91 * wm8753 register cache
92 * We can't read the WM8753 register space when we
93 * are using 2 wire for device control, so we cache them instead.
94 */
95static const u16 wm8753_reg[] = {
96 0x0008, 0x0000, 0x000a, 0x000a,
97 0x0033, 0x0000, 0x0007, 0x00ff,
98 0x00ff, 0x000f, 0x000f, 0x007b,
99 0x0000, 0x0032, 0x0000, 0x00c3,
100 0x00c3, 0x00c0, 0x0000, 0x0000,
101 0x0000, 0x0000, 0x0000, 0x0000,
102 0x0000, 0x0000, 0x0000, 0x0000,
103 0x0000, 0x0000, 0x0000, 0x0055,
104 0x0005, 0x0050, 0x0055, 0x0050,
105 0x0055, 0x0050, 0x0055, 0x0079,
106 0x0079, 0x0079, 0x0079, 0x0079,
107 0x0000, 0x0000, 0x0000, 0x0000,
108 0x0097, 0x0097, 0x0000, 0x0004,
109 0x0000, 0x0083, 0x0024, 0x01ba,
110 0x0000, 0x0083, 0x0024, 0x01ba,
111 0x0000, 0x0000
112};
113
114/*
115 * read wm8753 register cache
116 */
117static inline unsigned int wm8753_read_reg_cache(struct snd_soc_codec *codec,
118 unsigned int reg)
119{
120 u16 *cache = codec->reg_cache;
121 if (reg < 1 || reg > (ARRAY_SIZE(wm8753_reg) + 1))
122 return -1;
123 return cache[reg - 1];
124}
125
126/*
127 * write wm8753 register cache
128 */
129static inline void wm8753_write_reg_cache(struct snd_soc_codec *codec,
130 unsigned int reg, unsigned int value)
131{
132 u16 *cache = codec->reg_cache;
133 if (reg < 1 || reg > 0x3f)
134 return;
135 cache[reg - 1] = value;
136}
137
138/*
139 * write to the WM8753 register space
140 */
141static int wm8753_write(struct snd_soc_codec *codec, unsigned int reg,
142 unsigned int value)
143{
144 u8 data[2];
145
146 /* data is
147 * D15..D9 WM8753 register offset
148 * D8...D0 register data
149 */
150 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
151 data[1] = value & 0x00ff;
152
153 wm8753_write_reg_cache (codec, reg, value);
154 if (codec->hw_write(codec->control_data, data, 2) == 2)
155 return 0;
156 else
157 return -EIO;
158}
159
160#define wm8753_reset(c) wm8753_write(c, WM8753_RESET, 0)
161
162/*
163 * WM8753 Controls
164 */
165static const char *wm8753_base[] = {"Linear Control", "Adaptive Boost"};
166static const char *wm8753_base_filter[] =
167 {"130Hz @ 48kHz", "200Hz @ 48kHz", "100Hz @ 16kHz", "400Hz @ 48kHz",
168 "100Hz @ 8kHz", "200Hz @ 8kHz"};
169static const char *wm8753_treble[] = {"8kHz", "4kHz"};
170static const char *wm8753_alc_func[] = {"Off", "Right", "Left", "Stereo"};
171static const char *wm8753_ng_type[] = {"Constant PGA Gain", "Mute ADC Output"};
172static const char *wm8753_3d_func[] = {"Capture", "Playback"};
173static const char *wm8753_3d_uc[] = {"2.2kHz", "1.5kHz"};
174static const char *wm8753_3d_lc[] = {"200Hz", "500Hz"};
175static const char *wm8753_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz"};
176static const char *wm8753_mono_mix[] = {"Stereo", "Left", "Right", "Mono"};
177static const char *wm8753_dac_phase[] = {"Non Inverted", "Inverted"};
178static const char *wm8753_line_mix[] = {"Line 1 + 2", "Line 1 - 2",
179 "Line 1", "Line 2"};
180static const char *wm8753_mono_mux[] = {"Line Mix", "Rx Mix"};
181static const char *wm8753_right_mux[] = {"Line 2", "Rx Mix"};
182static const char *wm8753_left_mux[] = {"Line 1", "Rx Mix"};
183static const char *wm8753_rxmsel[] = {"RXP - RXN", "RXP + RXN", "RXP", "RXN"};
184static const char *wm8753_sidetone_mux[] = {"Left PGA", "Mic 1", "Mic 2",
185 "Right PGA"};
186static const char *wm8753_mono2_src[] = {"Inverted Mono 1", "Left", "Right",
187 "Left + Right"};
188static const char *wm8753_out3[] = {"VREF", "ROUT2", "Left + Right"};
189static const char *wm8753_out4[] = {"VREF", "Capture ST", "LOUT2"};
190static const char *wm8753_radcsel[] = {"PGA", "Line or RXP-RXN", "Sidetone"};
191static const char *wm8753_ladcsel[] = {"PGA", "Line or RXP-RXN", "Line"};
192static const char *wm8753_mono_adc[] = {"Stereo", "Analogue Mix Left",
193 "Analogue Mix Right", "Digital Mono Mix"};
194static const char *wm8753_adc_hp[] = {"3.4Hz @ 48kHz", "82Hz @ 16k",
195 "82Hz @ 8kHz", "170Hz @ 8kHz"};
196static const char *wm8753_adc_filter[] = {"HiFi", "Voice"};
197static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"};
199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
200 "Channel Swap"};
201
202static const struct soc_enum wm8753_enum[] = {
203SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base),
204SOC_ENUM_SINGLE(WM8753_BASS, 4, 6, wm8753_base_filter),
205SOC_ENUM_SINGLE(WM8753_TREBLE, 6, 2, wm8753_treble),
206SOC_ENUM_SINGLE(WM8753_ALC1, 7, 4, wm8753_alc_func),
207SOC_ENUM_SINGLE(WM8753_NGATE, 1, 2, wm8753_ng_type),
208SOC_ENUM_SINGLE(WM8753_3D, 7, 2, wm8753_3d_func),
209SOC_ENUM_SINGLE(WM8753_3D, 6, 2, wm8753_3d_uc),
210SOC_ENUM_SINGLE(WM8753_3D, 5, 2, wm8753_3d_lc),
211SOC_ENUM_SINGLE(WM8753_DAC, 1, 4, wm8753_deemp),
212SOC_ENUM_SINGLE(WM8753_DAC, 4, 4, wm8753_mono_mix),
213SOC_ENUM_SINGLE(WM8753_DAC, 6, 2, wm8753_dac_phase),
214SOC_ENUM_SINGLE(WM8753_INCTL1, 3, 4, wm8753_line_mix),
215SOC_ENUM_SINGLE(WM8753_INCTL1, 2, 2, wm8753_mono_mux),
216SOC_ENUM_SINGLE(WM8753_INCTL1, 1, 2, wm8753_right_mux),
217SOC_ENUM_SINGLE(WM8753_INCTL1, 0, 2, wm8753_left_mux),
218SOC_ENUM_SINGLE(WM8753_INCTL2, 6, 4, wm8753_rxmsel),
219SOC_ENUM_SINGLE(WM8753_INCTL2, 4, 4, wm8753_sidetone_mux),
220SOC_ENUM_SINGLE(WM8753_OUTCTL, 7, 4, wm8753_mono2_src),
221SOC_ENUM_SINGLE(WM8753_OUTCTL, 0, 3, wm8753_out3),
222SOC_ENUM_SINGLE(WM8753_ADCTL2, 7, 3, wm8753_out4),
223SOC_ENUM_SINGLE(WM8753_ADCIN, 2, 3, wm8753_radcsel),
224SOC_ENUM_SINGLE(WM8753_ADCIN, 0, 3, wm8753_ladcsel),
225SOC_ENUM_SINGLE(WM8753_ADCIN, 4, 4, wm8753_mono_adc),
226SOC_ENUM_SINGLE(WM8753_ADC, 2, 4, wm8753_adc_hp),
227SOC_ENUM_SINGLE(WM8753_ADC, 4, 2, wm8753_adc_filter),
228SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel),
229SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode),
230SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel),
231};
232
233
234static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
235 struct snd_ctl_elem_value *ucontrol)
236{
237 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
238 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL);
239
240 ucontrol->value.integer.value[0] = (mode & 0xc) >> 2;
241 return 0;
242}
243
244static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
245 struct snd_ctl_elem_value *ucontrol)
246{
247 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
248 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL);
249
250 if (((mode &0xc) >> 2) == ucontrol->value.integer.value[0])
251 return 0;
252
253 mode &= 0xfff3;
254 mode |= (ucontrol->value.integer.value[0] << 2);
255
256 wm8753_write(codec, WM8753_IOCTL, mode);
257 wm8753_set_dai_mode(codec, ucontrol->value.integer.value[0]);
258 return 1;
259}
260
261static const struct snd_kcontrol_new wm8753_snd_controls[] = {
262SOC_DOUBLE_R("PCM Volume", WM8753_LDAC, WM8753_RDAC, 0, 255, 0),
263
264SOC_DOUBLE_R("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0),
265
266SOC_DOUBLE_R("Headphone Playback Volume", WM8753_LOUT1V, WM8753_ROUT1V, 0, 127, 0),
267SOC_DOUBLE_R("Speaker Playback Volume", WM8753_LOUT2V, WM8753_ROUT2V, 0, 127, 0),
268
269SOC_SINGLE("Mono Playback Volume", WM8753_MOUTV, 0, 127, 0),
270
271SOC_DOUBLE_R("Bypass Playback Volume", WM8753_LOUTM1, WM8753_ROUTM1, 4, 7, 1),
272SOC_DOUBLE_R("Sidetone Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 4, 7, 1),
273SOC_DOUBLE_R("Voice Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 0, 7, 1),
274
275SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8753_LOUT1V, WM8753_ROUT1V, 7, 1, 0),
276SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7, 1, 0),
277
278SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1),
279SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1),
280SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 4, 7, 1),
281SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
282
283SOC_ENUM("Bass Boost", wm8753_enum[0]),
284SOC_ENUM("Bass Filter", wm8753_enum[1]),
285SOC_SINGLE("Bass Volume", WM8753_BASS, 0, 15, 1),
286
287SOC_SINGLE("Treble Volume", WM8753_TREBLE, 0, 15, 1),
288SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
289
290SOC_DOUBLE("Sidetone Capture Volume", WM8753_RECMIX1, 0, 4, 7, 1),
291SOC_SINGLE("Voice Sidetone Capture Volume", WM8753_RECMIX2, 0, 7, 1),
292
293SOC_DOUBLE_R("Capture Volume", WM8753_LINVOL, WM8753_RINVOL, 0, 63, 0),
294SOC_DOUBLE_R("Capture ZC Switch", WM8753_LINVOL, WM8753_RINVOL, 6, 1, 0),
295SOC_DOUBLE_R("Capture Switch", WM8753_LINVOL, WM8753_RINVOL, 7, 1, 1),
296
297SOC_ENUM("Capture Filter Select", wm8753_enum[23]),
298SOC_ENUM("Capture Filter Cut-off", wm8753_enum[24]),
299SOC_SINGLE("Capture Filter Switch", WM8753_ADC, 0, 1, 1),
300
301SOC_SINGLE("ALC Capture Target Volume", WM8753_ALC1, 0, 7, 0),
302SOC_SINGLE("ALC Capture Max Volume", WM8753_ALC1, 4, 7, 0),
303SOC_ENUM("ALC Capture Function", wm8753_enum[3]),
304SOC_SINGLE("ALC Capture ZC Switch", WM8753_ALC2, 8, 1, 0),
305SOC_SINGLE("ALC Capture Hold Time", WM8753_ALC2, 0, 15, 1),
306SOC_SINGLE("ALC Capture Decay Time", WM8753_ALC3, 4, 15, 1),
307SOC_SINGLE("ALC Capture Attack Time", WM8753_ALC3, 0, 15, 0),
308SOC_SINGLE("ALC Capture NG Threshold", WM8753_NGATE, 3, 31, 0),
309SOC_ENUM("ALC Capture NG Type", wm8753_enum[4]),
310SOC_SINGLE("ALC Capture NG Switch", WM8753_NGATE, 0, 1, 0),
311
312SOC_ENUM("3D Function", wm8753_enum[5]),
313SOC_ENUM("3D Upper Cut-off", wm8753_enum[6]),
314SOC_ENUM("3D Lower Cut-off", wm8753_enum[7]),
315SOC_SINGLE("3D Volume", WM8753_3D, 1, 15, 0),
316SOC_SINGLE("3D Switch", WM8753_3D, 0, 1, 0),
317
318SOC_SINGLE("Capture 6dB Attenuate", WM8753_ADCTL1, 2, 1, 0),
319SOC_SINGLE("Playback 6dB Attenuate", WM8753_ADCTL1, 1, 1, 0),
320
321SOC_ENUM("De-emphasis", wm8753_enum[8]),
322SOC_ENUM("Playback Mono Mix", wm8753_enum[9]),
323SOC_ENUM("Playback Phase", wm8753_enum[10]),
324
325SOC_SINGLE("Mic2 Capture Volume", WM8753_INCTL1, 7, 3, 0),
326SOC_SINGLE("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0),
327
328SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
329
330SOC_ENUM("ADC Data Select", wm8753_enum[27]),
331};
332
333/* add non dapm controls */
334static int wm8753_add_controls(struct snd_soc_codec *codec)
335{
336 int err, i;
337
338 for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) {
339 err = snd_ctl_add(codec->card,
340 snd_soc_cnew(&wm8753_snd_controls[i],codec, NULL));
341 if (err < 0)
342 return err;
343 }
344 return 0;
345}
346
347/*
348 * _DAPM_ Controls
349 */
350
351/* Left Mixer */
352static const struct snd_kcontrol_new wm8753_left_mixer_controls[] = {
353SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_LOUTM2, 8, 1, 0),
354SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_LOUTM2, 7, 1, 0),
355SOC_DAPM_SINGLE("Left Playback Switch", WM8753_LOUTM1, 8, 1, 0),
356SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_LOUTM1, 7, 1, 0),
357};
358
359/* Right mixer */
360static const struct snd_kcontrol_new wm8753_right_mixer_controls[] = {
361SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_ROUTM2, 8, 1, 0),
362SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_ROUTM2, 7, 1, 0),
363SOC_DAPM_SINGLE("Right Playback Switch", WM8753_ROUTM1, 8, 1, 0),
364SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_ROUTM1, 7, 1, 0),
365};
366
367/* Mono mixer */
368static const struct snd_kcontrol_new wm8753_mono_mixer_controls[] = {
369SOC_DAPM_SINGLE("Left Playback Switch", WM8753_MOUTM1, 8, 1, 0),
370SOC_DAPM_SINGLE("Right Playback Switch", WM8753_MOUTM2, 8, 1, 0),
371SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_MOUTM2, 3, 1, 0),
372SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_MOUTM2, 7, 1, 0),
373SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_MOUTM1, 7, 1, 0),
374};
375
376/* Mono 2 Mux */
377static const struct snd_kcontrol_new wm8753_mono2_controls =
378SOC_DAPM_ENUM("Route", wm8753_enum[17]);
379
380/* Out 3 Mux */
381static const struct snd_kcontrol_new wm8753_out3_controls =
382SOC_DAPM_ENUM("Route", wm8753_enum[18]);
383
384/* Out 4 Mux */
385static const struct snd_kcontrol_new wm8753_out4_controls =
386SOC_DAPM_ENUM("Route", wm8753_enum[19]);
387
388/* ADC Mono Mix */
389static const struct snd_kcontrol_new wm8753_adc_mono_controls =
390SOC_DAPM_ENUM("Route", wm8753_enum[22]);
391
392/* Record mixer */
393static const struct snd_kcontrol_new wm8753_record_mixer_controls[] = {
394SOC_DAPM_SINGLE("Voice Capture Switch", WM8753_RECMIX2, 3, 1, 0),
395SOC_DAPM_SINGLE("Left Capture Switch", WM8753_RECMIX1, 3, 1, 0),
396SOC_DAPM_SINGLE("Right Capture Switch", WM8753_RECMIX1, 7, 1, 0),
397};
398
399/* Left ADC mux */
400static const struct snd_kcontrol_new wm8753_adc_left_controls =
401SOC_DAPM_ENUM("Route", wm8753_enum[21]);
402
403/* Right ADC mux */
404static const struct snd_kcontrol_new wm8753_adc_right_controls =
405SOC_DAPM_ENUM("Route", wm8753_enum[20]);
406
407/* MIC mux */
408static const struct snd_kcontrol_new wm8753_mic_mux_controls =
409SOC_DAPM_ENUM("Route", wm8753_enum[16]);
410
411/* ALC mixer */
412static const struct snd_kcontrol_new wm8753_alc_mixer_controls[] = {
413SOC_DAPM_SINGLE("Line Capture Switch", WM8753_INCTL2, 3, 1, 0),
414SOC_DAPM_SINGLE("Mic2 Capture Switch", WM8753_INCTL2, 2, 1, 0),
415SOC_DAPM_SINGLE("Mic1 Capture Switch", WM8753_INCTL2, 1, 1, 0),
416SOC_DAPM_SINGLE("Rx Capture Switch", WM8753_INCTL2, 0, 1, 0),
417};
418
419/* Left Line mux */
420static const struct snd_kcontrol_new wm8753_line_left_controls =
421SOC_DAPM_ENUM("Route", wm8753_enum[14]);
422
423/* Right Line mux */
424static const struct snd_kcontrol_new wm8753_line_right_controls =
425SOC_DAPM_ENUM("Route", wm8753_enum[13]);
426
427/* Mono Line mux */
428static const struct snd_kcontrol_new wm8753_line_mono_controls =
429SOC_DAPM_ENUM("Route", wm8753_enum[12]);
430
431/* Line mux and mixer */
432static const struct snd_kcontrol_new wm8753_line_mux_mix_controls =
433SOC_DAPM_ENUM("Route", wm8753_enum[11]);
434
435/* Rx mux and mixer */
436static const struct snd_kcontrol_new wm8753_rx_mux_mix_controls =
437SOC_DAPM_ENUM("Route", wm8753_enum[15]);
438
439/* Mic Selector Mux */
440static const struct snd_kcontrol_new wm8753_mic_sel_mux_controls =
441SOC_DAPM_ENUM("Route", wm8753_enum[25]);
442
443static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
444SND_SOC_DAPM_MICBIAS("Mic Bias", WM8753_PWR1, 5, 0),
445SND_SOC_DAPM_MIXER("Left Mixer", WM8753_PWR4, 0, 0,
446 &wm8753_left_mixer_controls[0], ARRAY_SIZE(wm8753_left_mixer_controls)),
447SND_SOC_DAPM_PGA("Left Out 1", WM8753_PWR3, 8, 0, NULL, 0),
448SND_SOC_DAPM_PGA("Left Out 2", WM8753_PWR3, 6, 0, NULL, 0),
449SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", WM8753_PWR1, 3, 0),
450SND_SOC_DAPM_OUTPUT("LOUT1"),
451SND_SOC_DAPM_OUTPUT("LOUT2"),
452SND_SOC_DAPM_MIXER("Right Mixer", WM8753_PWR4, 1, 0,
453 &wm8753_right_mixer_controls[0], ARRAY_SIZE(wm8753_right_mixer_controls)),
454SND_SOC_DAPM_PGA("Right Out 1", WM8753_PWR3, 7, 0, NULL, 0),
455SND_SOC_DAPM_PGA("Right Out 2", WM8753_PWR3, 5, 0, NULL, 0),
456SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", WM8753_PWR1, 2, 0),
457SND_SOC_DAPM_OUTPUT("ROUT1"),
458SND_SOC_DAPM_OUTPUT("ROUT2"),
459SND_SOC_DAPM_MIXER("Mono Mixer", WM8753_PWR4, 2, 0,
460 &wm8753_mono_mixer_controls[0], ARRAY_SIZE(wm8753_mono_mixer_controls)),
461SND_SOC_DAPM_PGA("Mono Out 1", WM8753_PWR3, 2, 0, NULL, 0),
462SND_SOC_DAPM_PGA("Mono Out 2", WM8753_PWR3, 1, 0, NULL, 0),
463SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", WM8753_PWR1, 4, 0),
464SND_SOC_DAPM_OUTPUT("MONO1"),
465SND_SOC_DAPM_MUX("Mono 2 Mux", SND_SOC_NOPM, 0, 0, &wm8753_mono2_controls),
466SND_SOC_DAPM_OUTPUT("MONO2"),
467SND_SOC_DAPM_MIXER("Out3 Left + Right", -1, 0, 0, NULL, 0),
468SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out3_controls),
469SND_SOC_DAPM_PGA("Out 3", WM8753_PWR3, 4, 0, NULL, 0),
470SND_SOC_DAPM_OUTPUT("OUT3"),
471SND_SOC_DAPM_MUX("Out4 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out4_controls),
472SND_SOC_DAPM_PGA("Out 4", WM8753_PWR3, 3, 0, NULL, 0),
473SND_SOC_DAPM_OUTPUT("OUT4"),
474SND_SOC_DAPM_MIXER("Playback Mixer", WM8753_PWR4, 3, 0,
475 &wm8753_record_mixer_controls[0],
476 ARRAY_SIZE(wm8753_record_mixer_controls)),
477SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8753_PWR2, 3, 0),
478SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8753_PWR2, 2, 0),
479SND_SOC_DAPM_MUX("Capture Left Mixer", SND_SOC_NOPM, 0, 0,
480 &wm8753_adc_mono_controls),
481SND_SOC_DAPM_MUX("Capture Right Mixer", SND_SOC_NOPM, 0, 0,
482 &wm8753_adc_mono_controls),
483SND_SOC_DAPM_MUX("Capture Left Mux", SND_SOC_NOPM, 0, 0,
484 &wm8753_adc_left_controls),
485SND_SOC_DAPM_MUX("Capture Right Mux", SND_SOC_NOPM, 0, 0,
486 &wm8753_adc_right_controls),
487SND_SOC_DAPM_MUX("Mic Sidetone Mux", SND_SOC_NOPM, 0, 0,
488 &wm8753_mic_mux_controls),
489SND_SOC_DAPM_PGA("Left Capture Volume", WM8753_PWR2, 5, 0, NULL, 0),
490SND_SOC_DAPM_PGA("Right Capture Volume", WM8753_PWR2, 4, 0, NULL, 0),
491SND_SOC_DAPM_MIXER("ALC Mixer", WM8753_PWR2, 6, 0,
492 &wm8753_alc_mixer_controls[0], ARRAY_SIZE(wm8753_alc_mixer_controls)),
493SND_SOC_DAPM_MUX("Line Left Mux", SND_SOC_NOPM, 0, 0,
494 &wm8753_line_left_controls),
495SND_SOC_DAPM_MUX("Line Right Mux", SND_SOC_NOPM, 0, 0,
496 &wm8753_line_right_controls),
497SND_SOC_DAPM_MUX("Line Mono Mux", SND_SOC_NOPM, 0, 0,
498 &wm8753_line_mono_controls),
499SND_SOC_DAPM_MUX("Line Mixer", WM8753_PWR2, 0, 0,
500 &wm8753_line_mux_mix_controls),
501SND_SOC_DAPM_MUX("Rx Mixer", WM8753_PWR2, 1, 0,
502 &wm8753_rx_mux_mix_controls),
503SND_SOC_DAPM_PGA("Mic 1 Volume", WM8753_PWR2, 8, 0, NULL, 0),
504SND_SOC_DAPM_PGA("Mic 2 Volume", WM8753_PWR2, 7, 0, NULL, 0),
505SND_SOC_DAPM_MUX("Mic Selection Mux", SND_SOC_NOPM, 0, 0,
506 &wm8753_mic_sel_mux_controls),
507SND_SOC_DAPM_INPUT("LINE1"),
508SND_SOC_DAPM_INPUT("LINE2"),
509SND_SOC_DAPM_INPUT("RXP"),
510SND_SOC_DAPM_INPUT("RXN"),
511SND_SOC_DAPM_INPUT("ACIN"),
512SND_SOC_DAPM_OUTPUT("ACOP"),
513SND_SOC_DAPM_INPUT("MIC1N"),
514SND_SOC_DAPM_INPUT("MIC1"),
515SND_SOC_DAPM_INPUT("MIC2N"),
516SND_SOC_DAPM_INPUT("MIC2"),
517SND_SOC_DAPM_VMID("VREF"),
518};
519
520static const char *audio_map[][3] = {
521 /* left mixer */
522 {"Left Mixer", "Left Playback Switch", "Left DAC"},
523 {"Left Mixer", "Voice Playback Switch", "Voice DAC"},
524 {"Left Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
525 {"Left Mixer", "Bypass Playback Switch", "Line Left Mux"},
526
527 /* right mixer */
528 {"Right Mixer", "Right Playback Switch", "Right DAC"},
529 {"Right Mixer", "Voice Playback Switch", "Voice DAC"},
530 {"Right Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
531 {"Right Mixer", "Bypass Playback Switch", "Line Right Mux"},
532
533 /* mono mixer */
534 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
535 {"Mono Mixer", "Left Playback Switch", "Left DAC"},
536 {"Mono Mixer", "Right Playback Switch", "Right DAC"},
537 {"Mono Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
538 {"Mono Mixer", "Bypass Playback Switch", "Line Mono Mux"},
539
540 /* left out */
541 {"Left Out 1", NULL, "Left Mixer"},
542 {"Left Out 2", NULL, "Left Mixer"},
543 {"LOUT1", NULL, "Left Out 1"},
544 {"LOUT2", NULL, "Left Out 2"},
545
546 /* right out */
547 {"Right Out 1", NULL, "Right Mixer"},
548 {"Right Out 2", NULL, "Right Mixer"},
549 {"ROUT1", NULL, "Right Out 1"},
550 {"ROUT2", NULL, "Right Out 2"},
551
552 /* mono 1 out */
553 {"Mono Out 1", NULL, "Mono Mixer"},
554 {"MONO1", NULL, "Mono Out 1"},
555
556 /* mono 2 out */
557 {"Mono 2 Mux", "Left + Right", "Out3 Left + Right"},
558 {"Mono 2 Mux", "Inverted Mono 1", "MONO1"},
559 {"Mono 2 Mux", "Left", "Left Mixer"},
560 {"Mono 2 Mux", "Right", "Right Mixer"},
561 {"Mono Out 2", NULL, "Mono 2 Mux"},
562 {"MONO2", NULL, "Mono Out 2"},
563
564 /* out 3 */
565 {"Out3 Left + Right", NULL, "Left Mixer"},
566 {"Out3 Left + Right", NULL, "Right Mixer"},
567 {"Out3 Mux", "VREF", "VREF"},
568 {"Out3 Mux", "Left + Right", "Out3 Left + Right"},
569 {"Out3 Mux", "ROUT2", "ROUT2"},
570 {"Out 3", NULL, "Out3 Mux"},
571 {"OUT3", NULL, "Out 3"},
572
573 /* out 4 */
574 {"Out4 Mux", "VREF", "VREF"},
575 {"Out4 Mux", "Capture ST", "Capture ST Mixer"},
576 {"Out4 Mux", "LOUT2", "LOUT2"},
577 {"Out 4", NULL, "Out4 Mux"},
578 {"OUT4", NULL, "Out 4"},
579
580 /* record mixer */
581 {"Playback Mixer", "Left Capture Switch", "Left Mixer"},
582 {"Playback Mixer", "Voice Capture Switch", "Mono Mixer"},
583 {"Playback Mixer", "Right Capture Switch", "Right Mixer"},
584
585 /* Mic/SideTone Mux */
586 {"Mic Sidetone Mux", "Left PGA", "Left Capture Volume"},
587 {"Mic Sidetone Mux", "Right PGA", "Right Capture Volume"},
588 {"Mic Sidetone Mux", "Mic 1", "Mic 1 Volume"},
589 {"Mic Sidetone Mux", "Mic 2", "Mic 2 Volume"},
590
591 /* Capture Left Mux */
592 {"Capture Left Mux", "PGA", "Left Capture Volume"},
593 {"Capture Left Mux", "Line or RXP-RXN", "Line Left Mux"},
594 {"Capture Left Mux", "Line", "LINE1"},
595
596 /* Capture Right Mux */
597 {"Capture Right Mux", "PGA", "Right Capture Volume"},
598 {"Capture Right Mux", "Line or RXP-RXN", "Line Right Mux"},
599 {"Capture Right Mux", "Sidetone", "Capture ST Mixer"},
600
601 /* Mono Capture mixer-mux */
602 {"Capture Right Mixer", "Stereo", "Capture Right Mux"},
603 {"Capture Left Mixer", "Analogue Mix Left", "Capture Left Mux"},
604 {"Capture Left Mixer", "Analogue Mix Left", "Capture Right Mux"},
605 {"Capture Right Mixer", "Analogue Mix Right", "Capture Left Mux"},
606 {"Capture Right Mixer", "Analogue Mix Right", "Capture Right Mux"},
607 {"Capture Left Mixer", "Digital Mono Mix", "Capture Left Mux"},
608 {"Capture Left Mixer", "Digital Mono Mix", "Capture Right Mux"},
609 {"Capture Right Mixer", "Digital Mono Mix", "Capture Left Mux"},
610 {"Capture Right Mixer", "Digital Mono Mix", "Capture Right Mux"},
611
612 /* ADC */
613 {"Left ADC", NULL, "Capture Left Mixer"},
614 {"Right ADC", NULL, "Capture Right Mixer"},
615
616 /* Left Capture Volume */
617 {"Left Capture Volume", NULL, "ACIN"},
618
619 /* Right Capture Volume */
620 {"Right Capture Volume", NULL, "Mic 2 Volume"},
621
622 /* ALC Mixer */
623 {"ALC Mixer", "Line Capture Switch", "Line Mixer"},
624 {"ALC Mixer", "Mic2 Capture Switch", "Mic 2 Volume"},
625 {"ALC Mixer", "Mic1 Capture Switch", "Mic 1 Volume"},
626 {"ALC Mixer", "Rx Capture Switch", "Rx Mixer"},
627
628 /* Line Left Mux */
629 {"Line Left Mux", "Line 1", "LINE1"},
630 {"Line Left Mux", "Rx Mix", "Rx Mixer"},
631
632 /* Line Right Mux */
633 {"Line Right Mux", "Line 2", "LINE2"},
634 {"Line Right Mux", "Rx Mix", "Rx Mixer"},
635
636 /* Line Mono Mux */
637 {"Line Mono Mux", "Line Mix", "Line Mixer"},
638 {"Line Mono Mux", "Rx Mix", "Rx Mixer"},
639
640 /* Line Mixer/Mux */
641 {"Line Mixer", "Line 1 + 2", "LINE1"},
642 {"Line Mixer", "Line 1 - 2", "LINE1"},
643 {"Line Mixer", "Line 1 + 2", "LINE2"},
644 {"Line Mixer", "Line 1 - 2", "LINE2"},
645 {"Line Mixer", "Line 1", "LINE1"},
646 {"Line Mixer", "Line 2", "LINE2"},
647
648 /* Rx Mixer/Mux */
649 {"Rx Mixer", "RXP - RXN", "RXP"},
650 {"Rx Mixer", "RXP + RXN", "RXP"},
651 {"Rx Mixer", "RXP - RXN", "RXN"},
652 {"Rx Mixer", "RXP + RXN", "RXN"},
653 {"Rx Mixer", "RXP", "RXP"},
654 {"Rx Mixer", "RXN", "RXN"},
655
656 /* Mic 1 Volume */
657 {"Mic 1 Volume", NULL, "MIC1N"},
658 {"Mic 1 Volume", NULL, "Mic Selection Mux"},
659
660 /* Mic 2 Volume */
661 {"Mic 2 Volume", NULL, "MIC2N"},
662 {"Mic 2 Volume", NULL, "MIC2"},
663
664 /* Mic Selector Mux */
665 {"Mic Selection Mux", "Mic 1", "MIC1"},
666 {"Mic Selection Mux", "Mic 2", "MIC2N"},
667 {"Mic Selection Mux", "Mic 3", "MIC2"},
668
669 /* ACOP */
670 {"ACOP", NULL, "ALC Mixer"},
671
672 /* terminator */
673 {NULL, NULL, NULL},
674};
675
676static int wm8753_add_widgets(struct snd_soc_codec *codec)
677{
678 int i;
679
680 for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++)
681 snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
682
683 /* set up the WM8753 audio map */
684 for (i = 0; audio_map[i][0] != NULL; i++) {
685 snd_soc_dapm_connect_input(codec, audio_map[i][0],
686 audio_map[i][1], audio_map[i][2]);
687 }
688
689 snd_soc_dapm_new_widgets(codec);
690 return 0;
691}
692
693/* PLL divisors */
694struct _pll_div {
695 u32 div2:1;
696 u32 n:4;
697 u32 k:24;
698};
699
700/* The size in bits of the pll divide multiplied by 10
701 * to allow rounding later */
702#define FIXED_PLL_SIZE ((1 << 22) * 10)
703
704static void pll_factors(struct _pll_div *pll_div, unsigned int target,
705 unsigned int source)
706{
707 u64 Kpart;
708 unsigned int K, Ndiv, Nmod;
709
710 Ndiv = target / source;
711 if (Ndiv < 6) {
712 source >>= 1;
713 pll_div->div2 = 1;
714 Ndiv = target / source;
715 } else
716 pll_div->div2 = 0;
717
718 if ((Ndiv < 6) || (Ndiv > 12))
719 printk(KERN_WARNING
720 "WM8753 N value outwith recommended range! N = %d\n",Ndiv);
721
722 pll_div->n = Ndiv;
723 Nmod = target % source;
724 Kpart = FIXED_PLL_SIZE * (long long)Nmod;
725
726 do_div(Kpart, source);
727
728 K = Kpart & 0xFFFFFFFF;
729
730 /* Check if we need to round */
731 if ((K % 10) >= 5)
732 K += 5;
733
734 /* Move down to proper range now rounding is done */
735 K /= 10;
736
737 pll_div->k = K;
738}
739
740static int wm8753_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
741 int pll_id, unsigned int freq_in, unsigned int freq_out)
742{
743 u16 reg, enable;
744 int offset;
745 struct snd_soc_codec *codec = codec_dai->codec;
746
747 if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2)
748 return -ENODEV;
749
750 if (pll_id == WM8753_PLL1) {
751 offset = 0;
752 enable = 0x10;
753 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xffef;
754 } else {
755 offset = 4;
756 enable = 0x8;
757 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfff7;
758 }
759
760 if (!freq_in || !freq_out) {
761 /* disable PLL */
762 wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0026);
763 wm8753_write(codec, WM8753_CLOCK, reg);
764 return 0;
765 } else {
766 u16 value = 0;
767 struct _pll_div pll_div;
768
769 pll_factors(&pll_div, freq_out * 8, freq_in);
770
771 /* set up N and K PLL divisor ratios */
772 /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */
773 value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18);
774 wm8753_write(codec, WM8753_PLL1CTL2 + offset, value);
775
776 /* bits 8:0 = PLL_K[17:9] */
777 value = (pll_div.k & 0x03fe00) >> 9;
778 wm8753_write(codec, WM8753_PLL1CTL3 + offset, value);
779
780 /* bits 8:0 = PLL_K[8:0] */
781 value = pll_div.k & 0x0001ff;
782 wm8753_write(codec, WM8753_PLL1CTL4 + offset, value);
783
784 /* set PLL as input and enable */
785 wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 |
786 (pll_div.div2 << 3));
787 wm8753_write(codec, WM8753_CLOCK, reg | enable);
788 }
789 return 0;
790}
791
792struct _coeff_div {
793 u32 mclk;
794 u32 rate;
795 u8 sr:5;
796 u8 usb:1;
797};
798
799/* codec hifi mclk (after PLL) clock divider coefficients */
800static const struct _coeff_div coeff_div[] = {
801 /* 8k */
802 {12288000, 8000, 0x6, 0x0},
803 {11289600, 8000, 0x16, 0x0},
804 {18432000, 8000, 0x7, 0x0},
805 {16934400, 8000, 0x17, 0x0},
806 {12000000, 8000, 0x6, 0x1},
807
808 /* 11.025k */
809 {11289600, 11025, 0x18, 0x0},
810 {16934400, 11025, 0x19, 0x0},
811 {12000000, 11025, 0x19, 0x1},
812
813 /* 16k */
814 {12288000, 16000, 0xa, 0x0},
815 {18432000, 16000, 0xb, 0x0},
816 {12000000, 16000, 0xa, 0x1},
817
818 /* 22.05k */
819 {11289600, 22050, 0x1a, 0x0},
820 {16934400, 22050, 0x1b, 0x0},
821 {12000000, 22050, 0x1b, 0x1},
822
823 /* 32k */
824 {12288000, 32000, 0xc, 0x0},
825 {18432000, 32000, 0xd, 0x0},
826 {12000000, 32000, 0xa, 0x1},
827
828 /* 44.1k */
829 {11289600, 44100, 0x10, 0x0},
830 {16934400, 44100, 0x11, 0x0},
831 {12000000, 44100, 0x11, 0x1},
832
833 /* 48k */
834 {12288000, 48000, 0x0, 0x0},
835 {18432000, 48000, 0x1, 0x0},
836 {12000000, 48000, 0x0, 0x1},
837
838 /* 88.2k */
839 {11289600, 88200, 0x1e, 0x0},
840 {16934400, 88200, 0x1f, 0x0},
841 {12000000, 88200, 0x1f, 0x1},
842
843 /* 96k */
844 {12288000, 96000, 0xe, 0x0},
845 {18432000, 96000, 0xf, 0x0},
846 {12000000, 96000, 0xe, 0x1},
847};
848
849static int get_coeff(int mclk, int rate)
850{
851 int i;
852
853 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
854 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
855 return i;
856 }
857 return -EINVAL;
858}
859
860/*
861 * Clock after PLL and dividers
862 */
863static int wm8753_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
864 int clk_id, unsigned int freq, int dir)
865{
866 struct snd_soc_codec *codec = codec_dai->codec;
867 struct wm8753_priv *wm8753 = codec->private_data;
868
869 switch (freq) {
870 case 11289600:
871 case 12000000:
872 case 12288000:
873 case 16934400:
874 case 18432000:
875 if (clk_id == WM8753_MCLK) {
876 wm8753->sysclk = freq;
877 return 0;
878 } else if (clk_id == WM8753_PCMCLK) {
879 wm8753->pcmclk = freq;
880 return 0;
881 }
882 break;
883 }
884 return -EINVAL;
885}
886
887/*
888 * Set's ADC and Voice DAC format.
889 */
890static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
891 unsigned int fmt)
892{
893 struct snd_soc_codec *codec = codec_dai->codec;
894 u16 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x01ec;
895
896 /* interface format */
897 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
898 case SND_SOC_DAIFMT_I2S:
899 voice |= 0x0002;
900 break;
901 case SND_SOC_DAIFMT_RIGHT_J:
902 break;
903 case SND_SOC_DAIFMT_LEFT_J:
904 voice |= 0x0001;
905 break;
906 case SND_SOC_DAIFMT_DSP_A:
907 voice |= 0x0003;
908 break;
909 case SND_SOC_DAIFMT_DSP_B:
910 voice |= 0x0013;
911 break;
912 default:
913 return -EINVAL;
914 }
915
916 wm8753_write(codec, WM8753_PCM, voice);
917 return 0;
918}
919
920/*
921 * Set PCM DAI bit size and sample rate.
922 */
923static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
924 struct snd_pcm_hw_params *params)
925{
926 struct snd_soc_pcm_runtime *rtd = substream->private_data;
927 struct snd_soc_device *socdev = rtd->socdev;
928 struct snd_soc_codec *codec = socdev->codec;
929 struct wm8753_priv *wm8753 = codec->private_data;
930 u16 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x01f3;
931 u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x017f;
932
933 /* bit size */
934 switch (params_format(params)) {
935 case SNDRV_PCM_FORMAT_S16_LE:
936 break;
937 case SNDRV_PCM_FORMAT_S20_3LE:
938 voice |= 0x0004;
939 break;
940 case SNDRV_PCM_FORMAT_S24_LE:
941 voice |= 0x0008;
942 break;
943 case SNDRV_PCM_FORMAT_S32_LE:
944 voice |= 0x000c;
945 break;
946 }
947
948 /* sample rate */
949 if (params_rate(params) * 384 == wm8753->pcmclk)
950 srate |= 0x80;
951 wm8753_write(codec, WM8753_SRATE1, srate);
952
953 wm8753_write(codec, WM8753_PCM, voice);
954 return 0;
955}
956
957/*
958 * Set's PCM dai fmt and BCLK.
959 */
960static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
961 unsigned int fmt)
962{
963 struct snd_soc_codec *codec = codec_dai->codec;
964 u16 voice, ioctl;
965
966 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x011f;
967 ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x015d;
968
969 /* set master/slave audio interface */
970 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
971 case SND_SOC_DAIFMT_CBS_CFS:
972 break;
973 case SND_SOC_DAIFMT_CBM_CFM:
974 ioctl |= 0x2;
975 case SND_SOC_DAIFMT_CBM_CFS:
976 voice |= 0x0040;
977 break;
978 default:
979 return -EINVAL;
980 }
981
982 /* clock inversion */
983 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
984 case SND_SOC_DAIFMT_DSP_A:
985 case SND_SOC_DAIFMT_DSP_B:
986 /* frame inversion not valid for DSP modes */
987 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
988 case SND_SOC_DAIFMT_NB_NF:
989 break;
990 case SND_SOC_DAIFMT_IB_NF:
991 voice |= 0x0080;
992 break;
993 default:
994 return -EINVAL;
995 }
996 break;
997 case SND_SOC_DAIFMT_I2S:
998 case SND_SOC_DAIFMT_RIGHT_J:
999 case SND_SOC_DAIFMT_LEFT_J:
1000 voice &= ~0x0010;
1001 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1002 case SND_SOC_DAIFMT_NB_NF:
1003 break;
1004 case SND_SOC_DAIFMT_IB_IF:
1005 voice |= 0x0090;
1006 break;
1007 case SND_SOC_DAIFMT_IB_NF:
1008 voice |= 0x0080;
1009 break;
1010 case SND_SOC_DAIFMT_NB_IF:
1011 voice |= 0x0010;
1012 break;
1013 default:
1014 return -EINVAL;
1015 }
1016 break;
1017 default:
1018 return -EINVAL;
1019 }
1020
1021 wm8753_write(codec, WM8753_PCM, voice);
1022 wm8753_write(codec, WM8753_IOCTL, ioctl);
1023 return 0;
1024}
1025
1026static int wm8753_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
1027 int div_id, int div)
1028{
1029 struct snd_soc_codec *codec = codec_dai->codec;
1030 u16 reg;
1031
1032 switch (div_id) {
1033 case WM8753_PCMDIV:
1034 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0x003f;
1035 wm8753_write(codec, WM8753_CLOCK, reg | div);
1036 break;
1037 case WM8753_BCLKDIV:
1038 reg = wm8753_read_reg_cache(codec, WM8753_SRATE2) & 0x01c7;
1039 wm8753_write(codec, WM8753_SRATE2, reg | div);
1040 break;
1041 case WM8753_VXCLKDIV:
1042 reg = wm8753_read_reg_cache(codec, WM8753_SRATE2) & 0x003f;
1043 wm8753_write(codec, WM8753_SRATE2, reg | div);
1044 break;
1045 default:
1046 return -EINVAL;
1047 }
1048 return 0;
1049}
1050
1051/*
1052 * Set's HiFi DAC format.
1053 */
1054static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1055 unsigned int fmt)
1056{
1057 struct snd_soc_codec *codec = codec_dai->codec;
1058 u16 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x01e0;
1059
1060 /* interface format */
1061 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1062 case SND_SOC_DAIFMT_I2S:
1063 hifi |= 0x0002;
1064 break;
1065 case SND_SOC_DAIFMT_RIGHT_J:
1066 break;
1067 case SND_SOC_DAIFMT_LEFT_J:
1068 hifi |= 0x0001;
1069 break;
1070 case SND_SOC_DAIFMT_DSP_A:
1071 hifi |= 0x0003;
1072 break;
1073 case SND_SOC_DAIFMT_DSP_B:
1074 hifi |= 0x0013;
1075 break;
1076 default:
1077 return -EINVAL;
1078 }
1079
1080 wm8753_write(codec, WM8753_HIFI, hifi);
1081 return 0;
1082}
1083
1084/*
1085 * Set's I2S DAI format.
1086 */
1087static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1088 unsigned int fmt)
1089{
1090 struct snd_soc_codec *codec = codec_dai->codec;
1091 u16 ioctl, hifi;
1092
1093 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x011f;
1094 ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x00ae;
1095
1096 /* set master/slave audio interface */
1097 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
1098 case SND_SOC_DAIFMT_CBS_CFS:
1099 break;
1100 case SND_SOC_DAIFMT_CBM_CFM:
1101 ioctl |= 0x1;
1102 case SND_SOC_DAIFMT_CBM_CFS:
1103 hifi |= 0x0040;
1104 break;
1105 default:
1106 return -EINVAL;
1107 }
1108
1109 /* clock inversion */
1110 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1111 case SND_SOC_DAIFMT_DSP_A:
1112 case SND_SOC_DAIFMT_DSP_B:
1113 /* frame inversion not valid for DSP modes */
1114 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1115 case SND_SOC_DAIFMT_NB_NF:
1116 break;
1117 case SND_SOC_DAIFMT_IB_NF:
1118 hifi |= 0x0080;
1119 break;
1120 default:
1121 return -EINVAL;
1122 }
1123 break;
1124 case SND_SOC_DAIFMT_I2S:
1125 case SND_SOC_DAIFMT_RIGHT_J:
1126 case SND_SOC_DAIFMT_LEFT_J:
1127 hifi &= ~0x0010;
1128 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1129 case SND_SOC_DAIFMT_NB_NF:
1130 break;
1131 case SND_SOC_DAIFMT_IB_IF:
1132 hifi |= 0x0090;
1133 break;
1134 case SND_SOC_DAIFMT_IB_NF:
1135 hifi |= 0x0080;
1136 break;
1137 case SND_SOC_DAIFMT_NB_IF:
1138 hifi |= 0x0010;
1139 break;
1140 default:
1141 return -EINVAL;
1142 }
1143 break;
1144 default:
1145 return -EINVAL;
1146 }
1147
1148 wm8753_write(codec, WM8753_HIFI, hifi);
1149 wm8753_write(codec, WM8753_IOCTL, ioctl);
1150 return 0;
1151}
1152
1153/*
1154 * Set PCM DAI bit size and sample rate.
1155 */
1156static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1157 struct snd_pcm_hw_params *params)
1158{
1159 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1160 struct snd_soc_device *socdev = rtd->socdev;
1161 struct snd_soc_codec *codec = socdev->codec;
1162 struct wm8753_priv *wm8753 = codec->private_data;
1163 u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x01c0;
1164 u16 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x01f3;
1165 int coeff;
1166
1167 /* is digital filter coefficient valid ? */
1168 coeff = get_coeff(wm8753->sysclk, params_rate(params));
1169 if (coeff < 0) {
1170 printk(KERN_ERR "wm8753 invalid MCLK or rate\n");
1171 return coeff;
1172 }
1173 wm8753_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) |
1174 coeff_div[coeff].usb);
1175
1176 /* bit size */
1177 switch (params_format(params)) {
1178 case SNDRV_PCM_FORMAT_S16_LE:
1179 break;
1180 case SNDRV_PCM_FORMAT_S20_3LE:
1181 hifi |= 0x0004;
1182 break;
1183 case SNDRV_PCM_FORMAT_S24_LE:
1184 hifi |= 0x0008;
1185 break;
1186 case SNDRV_PCM_FORMAT_S32_LE:
1187 hifi |= 0x000c;
1188 break;
1189 }
1190
1191 wm8753_write(codec, WM8753_HIFI, hifi);
1192 return 0;
1193}
1194
1195static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1196 unsigned int fmt)
1197{
1198 struct snd_soc_codec *codec = codec_dai->codec;
1199 u16 clock;
1200
1201 /* set clk source as pcmclk */
1202 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1203 wm8753_write(codec, WM8753_CLOCK, clock);
1204
1205 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1206 return -EINVAL;
1207 return wm8753_pcm_set_dai_fmt(codec_dai, fmt);
1208}
1209
1210static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1211 unsigned int fmt)
1212{
1213 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0)
1214 return -EINVAL;
1215 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1216}
1217
1218static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1219 unsigned int fmt)
1220{
1221 struct snd_soc_codec *codec = codec_dai->codec;
1222 u16 clock;
1223
1224 /* set clk source as pcmclk */
1225 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1226 wm8753_write(codec, WM8753_CLOCK, clock);
1227
1228 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1229 return -EINVAL;
1230 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1231}
1232
1233static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1234 unsigned int fmt)
1235{
1236 struct snd_soc_codec *codec = codec_dai->codec;
1237 u16 clock;
1238
1239 /* set clk source as mclk */
1240 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1241 wm8753_write(codec, WM8753_CLOCK, clock | 0x4);
1242
1243 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0)
1244 return -EINVAL;
1245 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1246 return -EINVAL;
1247 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1248}
1249
1250static int wm8753_mute(struct snd_soc_codec_dai *dai, int mute)
1251{
1252 struct snd_soc_codec *codec = dai->codec;
1253 u16 mute_reg = wm8753_read_reg_cache(codec, WM8753_DAC) & 0xfff7;
1254
1255 /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
1256 * make sure we check if they are not both active when we mute */
1257 if (mute && dai->id == 1) {
1258 if (!wm8753_dai[WM8753_DAI_VOICE].playback.active ||
1259 !wm8753_dai[WM8753_DAI_HIFI].playback.active)
1260 wm8753_write(codec, WM8753_DAC, mute_reg | 0x8);
1261 } else {
1262 if (mute)
1263 wm8753_write(codec, WM8753_DAC, mute_reg | 0x8);
1264 else
1265 wm8753_write(codec, WM8753_DAC, mute_reg);
1266 }
1267
1268 return 0;
1269}
1270
1271static int wm8753_dapm_event(struct snd_soc_codec *codec, int event)
1272{
1273 u16 pwr_reg = wm8753_read_reg_cache(codec, WM8753_PWR1) & 0xfe3e;
1274
1275 switch (event) {
1276 case SNDRV_CTL_POWER_D0: /* full On */
1277 /* set vmid to 50k and unmute dac */
1278 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x00c0);
1279 break;
1280 case SNDRV_CTL_POWER_D1: /* partial On */
1281 case SNDRV_CTL_POWER_D2: /* partial On */
1282 /* set vmid to 5k for quick power up */
1283 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x01c1);
1284 break;
1285 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
1286 /* mute dac and set vmid to 500k, enable VREF */
1287 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x0141);
1288 break;
1289 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
1290 wm8753_write(codec, WM8753_PWR1, 0x0001);
1291 break;
1292 }
1293 codec->dapm_state = event;
1294 return 0;
1295}
1296
1297#define WM8753_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1298 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
1299 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
1300
1301#define WM8753_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1302 SNDRV_PCM_FMTBIT_S24_LE)
1303
1304/*
1305 * The WM8753 supports upto 4 different and mutually exclusive DAI
1306 * configurations. This gives 2 PCM's available for use, hifi and voice.
1307 * NOTE: The Voice PCM cannot play or capture audio to the CPU as it's DAI
1308 * is connected between the wm8753 and a BT codec or GSM modem.
1309 *
1310 * 1. Voice over PCM DAI - HIFI DAC over HIFI DAI
1311 * 2. Voice over HIFI DAI - HIFI disabled
1312 * 3. Voice disabled - HIFI over HIFI
1313 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture
1314 */
1315static const struct snd_soc_codec_dai wm8753_all_dai[] = {
1316/* DAI HiFi mode 1 */
1317{ .name = "WM8753 HiFi",
1318 .id = 1,
1319 .playback = {
1320 .stream_name = "HiFi Playback",
1321 .channels_min = 1,
1322 .channels_max = 2,
1323 .rates = WM8753_RATES,
1324 .formats = WM8753_FORMATS,},
1325 .capture = { /* dummy for fast DAI switching */
1326 .stream_name = "Capture",
1327 .channels_min = 1,
1328 .channels_max = 2,
1329 .rates = WM8753_RATES,
1330 .formats = WM8753_FORMATS,},
1331 .ops = {
1332 .hw_params = wm8753_i2s_hw_params,},
1333 .dai_ops = {
1334 .digital_mute = wm8753_mute,
1335 .set_fmt = wm8753_mode1h_set_dai_fmt,
1336 .set_clkdiv = wm8753_set_dai_clkdiv,
1337 .set_pll = wm8753_set_dai_pll,
1338 .set_sysclk = wm8753_set_dai_sysclk,
1339 },
1340},
1341/* DAI Voice mode 1 */
1342{ .name = "WM8753 Voice",
1343 .id = 1,
1344 .playback = {
1345 .stream_name = "Voice Playback",
1346 .channels_min = 1,
1347 .channels_max = 1,
1348 .rates = WM8753_RATES,
1349 .formats = WM8753_FORMATS,},
1350 .capture = {
1351 .stream_name = "Capture",
1352 .channels_min = 1,
1353 .channels_max = 2,
1354 .rates = WM8753_RATES,
1355 .formats = WM8753_FORMATS,},
1356 .ops = {
1357 .hw_params = wm8753_pcm_hw_params,},
1358 .dai_ops = {
1359 .digital_mute = wm8753_mute,
1360 .set_fmt = wm8753_mode1v_set_dai_fmt,
1361 .set_clkdiv = wm8753_set_dai_clkdiv,
1362 .set_pll = wm8753_set_dai_pll,
1363 .set_sysclk = wm8753_set_dai_sysclk,
1364 },
1365},
1366/* DAI HiFi mode 2 - dummy */
1367{ .name = "WM8753 HiFi",
1368 .id = 2,
1369},
1370/* DAI Voice mode 2 */
1371{ .name = "WM8753 Voice",
1372 .id = 2,
1373 .playback = {
1374 .stream_name = "Voice Playback",
1375 .channels_min = 1,
1376 .channels_max = 1,
1377 .rates = WM8753_RATES,
1378 .formats = WM8753_FORMATS,},
1379 .capture = {
1380 .stream_name = "Capture",
1381 .channels_min = 1,
1382 .channels_max = 2,
1383 .rates = WM8753_RATES,
1384 .formats = WM8753_FORMATS,},
1385 .ops = {
1386 .hw_params = wm8753_pcm_hw_params,},
1387 .dai_ops = {
1388 .digital_mute = wm8753_mute,
1389 .set_fmt = wm8753_mode2_set_dai_fmt,
1390 .set_clkdiv = wm8753_set_dai_clkdiv,
1391 .set_pll = wm8753_set_dai_pll,
1392 .set_sysclk = wm8753_set_dai_sysclk,
1393 },
1394},
1395/* DAI HiFi mode 3 */
1396{ .name = "WM8753 HiFi",
1397 .id = 3,
1398 .playback = {
1399 .stream_name = "HiFi Playback",
1400 .channels_min = 1,
1401 .channels_max = 2,
1402 .rates = WM8753_RATES,
1403 .formats = WM8753_FORMATS,},
1404 .capture = {
1405 .stream_name = "Capture",
1406 .channels_min = 1,
1407 .channels_max = 2,
1408 .rates = WM8753_RATES,
1409 .formats = WM8753_FORMATS,},
1410 .ops = {
1411 .hw_params = wm8753_i2s_hw_params,},
1412 .dai_ops = {
1413 .digital_mute = wm8753_mute,
1414 .set_fmt = wm8753_mode3_4_set_dai_fmt,
1415 .set_clkdiv = wm8753_set_dai_clkdiv,
1416 .set_pll = wm8753_set_dai_pll,
1417 .set_sysclk = wm8753_set_dai_sysclk,
1418 },
1419},
1420/* DAI Voice mode 3 - dummy */
1421{ .name = "WM8753 Voice",
1422 .id = 3,
1423},
1424/* DAI HiFi mode 4 */
1425{ .name = "WM8753 HiFi",
1426 .id = 4,
1427 .playback = {
1428 .stream_name = "HiFi Playback",
1429 .channels_min = 1,
1430 .channels_max = 2,
1431 .rates = WM8753_RATES,
1432 .formats = WM8753_FORMATS,},
1433 .capture = {
1434 .stream_name = "Capture",
1435 .channels_min = 1,
1436 .channels_max = 2,
1437 .rates = WM8753_RATES,
1438 .formats = WM8753_FORMATS,},
1439 .ops = {
1440 .hw_params = wm8753_i2s_hw_params,},
1441 .dai_ops = {
1442 .digital_mute = wm8753_mute,
1443 .set_fmt = wm8753_mode3_4_set_dai_fmt,
1444 .set_clkdiv = wm8753_set_dai_clkdiv,
1445 .set_pll = wm8753_set_dai_pll,
1446 .set_sysclk = wm8753_set_dai_sysclk,
1447 },
1448},
1449/* DAI Voice mode 4 - dummy */
1450{ .name = "WM8753 Voice",
1451 .id = 4,
1452},
1453};
1454
1455struct snd_soc_codec_dai wm8753_dai[2];
1456EXPORT_SYMBOL_GPL(wm8753_dai);
1457
1458static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode)
1459{
1460 if (mode < 4) {
1461 int playback_active, capture_active, codec_active, pop_wait;
1462 void *private_data;
1463
1464 playback_active = wm8753_dai[0].playback.active;
1465 capture_active = wm8753_dai[0].capture.active;
1466 codec_active = wm8753_dai[0].active;
1467 private_data = wm8753_dai[0].private_data;
1468 pop_wait = wm8753_dai[0].pop_wait;
1469 wm8753_dai[0] = wm8753_all_dai[mode << 1];
1470 wm8753_dai[0].playback.active = playback_active;
1471 wm8753_dai[0].capture.active = capture_active;
1472 wm8753_dai[0].active = codec_active;
1473 wm8753_dai[0].private_data = private_data;
1474 wm8753_dai[0].pop_wait = pop_wait;
1475
1476 playback_active = wm8753_dai[1].playback.active;
1477 capture_active = wm8753_dai[1].capture.active;
1478 codec_active = wm8753_dai[1].active;
1479 private_data = wm8753_dai[1].private_data;
1480 pop_wait = wm8753_dai[1].pop_wait;
1481 wm8753_dai[1] = wm8753_all_dai[(mode << 1) + 1];
1482 wm8753_dai[1].playback.active = playback_active;
1483 wm8753_dai[1].capture.active = capture_active;
1484 wm8753_dai[1].active = codec_active;
1485 wm8753_dai[1].private_data = private_data;
1486 wm8753_dai[1].pop_wait = pop_wait;
1487 }
1488 wm8753_dai[0].codec = codec;
1489 wm8753_dai[1].codec = codec;
1490}
1491
1492static void wm8753_work(struct work_struct *work)
1493{
1494 struct snd_soc_codec *codec =
1495 container_of(work, struct snd_soc_codec, delayed_work.work);
1496 wm8753_dapm_event(codec, codec->dapm_state);
1497}
1498
1499static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
1500{
1501 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1502 struct snd_soc_codec *codec = socdev->codec;
1503
1504 /* we only need to suspend if we are a valid card */
1505 if(!codec->card)
1506 return 0;
1507
1508 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1509 return 0;
1510}
1511
1512static int wm8753_resume(struct platform_device *pdev)
1513{
1514 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1515 struct snd_soc_codec *codec = socdev->codec;
1516 int i;
1517 u8 data[2];
1518 u16 *cache = codec->reg_cache;
1519
1520 /* we only need to resume if we are a valid card */
1521 if(!codec->card)
1522 return 0;
1523
1524 /* Sync reg_cache with the hardware */
1525 for (i = 0; i < ARRAY_SIZE(wm8753_reg); i++) {
1526 if (i + 1 == WM8753_RESET)
1527 continue;
1528 data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001);
1529 data[1] = cache[i] & 0x00ff;
1530 codec->hw_write(codec->control_data, data, 2);
1531 }
1532
1533 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1534
1535 /* charge wm8753 caps */
1536 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
1537 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2);
1538 codec->dapm_state = SNDRV_CTL_POWER_D0;
1539 schedule_delayed_work(&codec->delayed_work,
1540 msecs_to_jiffies(caps_charge));
1541 }
1542
1543 return 0;
1544}
1545
1546/*
1547 * initialise the WM8753 driver
1548 * register the mixer and dsp interfaces with the kernel
1549 */
1550static int wm8753_init(struct snd_soc_device *socdev)
1551{
1552 struct snd_soc_codec *codec = socdev->codec;
1553 int reg, ret = 0;
1554
1555 codec->name = "WM8753";
1556 codec->owner = THIS_MODULE;
1557 codec->read = wm8753_read_reg_cache;
1558 codec->write = wm8753_write;
1559 codec->dapm_event = wm8753_dapm_event;
1560 codec->dai = wm8753_dai;
1561 codec->num_dai = 2;
1562 codec->reg_cache_size = sizeof(wm8753_reg);
1563 codec->reg_cache = kmemdup(wm8753_reg, sizeof(wm8753_reg), GFP_KERNEL);
1564
1565 if (codec->reg_cache == NULL)
1566 return -ENOMEM;
1567
1568 wm8753_set_dai_mode(codec, 0);
1569
1570 wm8753_reset(codec);
1571
1572 /* register pcms */
1573 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1574 if (ret < 0) {
1575 printk(KERN_ERR "wm8753: failed to create pcms\n");
1576 goto pcm_err;
1577 }
1578
1579 /* charge output caps */
1580 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2);
1581 codec->dapm_state = SNDRV_CTL_POWER_D3hot;
1582 schedule_delayed_work(&codec->delayed_work,
1583 msecs_to_jiffies(caps_charge));
1584
1585 /* set the update bits */
1586 reg = wm8753_read_reg_cache(codec, WM8753_LDAC);
1587 wm8753_write(codec, WM8753_LDAC, reg | 0x0100);
1588 reg = wm8753_read_reg_cache(codec, WM8753_RDAC);
1589 wm8753_write(codec, WM8753_RDAC, reg | 0x0100);
1590 reg = wm8753_read_reg_cache(codec, WM8753_LADC);
1591 wm8753_write(codec, WM8753_LADC, reg | 0x0100);
1592 reg = wm8753_read_reg_cache(codec, WM8753_RADC);
1593 wm8753_write(codec, WM8753_RADC, reg | 0x0100);
1594 reg = wm8753_read_reg_cache(codec, WM8753_LOUT1V);
1595 wm8753_write(codec, WM8753_LOUT1V, reg | 0x0100);
1596 reg = wm8753_read_reg_cache(codec, WM8753_ROUT1V);
1597 wm8753_write(codec, WM8753_ROUT1V, reg | 0x0100);
1598 reg = wm8753_read_reg_cache(codec, WM8753_LOUT2V);
1599 wm8753_write(codec, WM8753_LOUT2V, reg | 0x0100);
1600 reg = wm8753_read_reg_cache(codec, WM8753_ROUT2V);
1601 wm8753_write(codec, WM8753_ROUT2V, reg | 0x0100);
1602 reg = wm8753_read_reg_cache(codec, WM8753_LINVOL);
1603 wm8753_write(codec, WM8753_LINVOL, reg | 0x0100);
1604 reg = wm8753_read_reg_cache(codec, WM8753_RINVOL);
1605 wm8753_write(codec, WM8753_RINVOL, reg | 0x0100);
1606
1607 wm8753_add_controls(codec);
1608 wm8753_add_widgets(codec);
1609 ret = snd_soc_register_card(socdev);
1610 if (ret < 0) {
1611 printk(KERN_ERR "wm8753: failed to register card\n");
1612 goto card_err;
1613 }
1614 return ret;
1615
1616card_err:
1617 snd_soc_free_pcms(socdev);
1618 snd_soc_dapm_free(socdev);
1619pcm_err:
1620 kfree(codec->reg_cache);
1621 return ret;
1622}
1623
1624/* If the i2c layer weren't so broken, we could pass this kind of data
1625 around */
1626static struct snd_soc_device *wm8753_socdev;
1627
1628#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1629
1630/*
1631 * WM8753 2 wire address is determined by GPIO5
1632 * state during powerup.
1633 * low = 0x1a
1634 * high = 0x1b
1635 */
1636static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
1637
1638/* Magic definition of all other variables and things */
1639I2C_CLIENT_INSMOD;
1640
1641static struct i2c_driver wm8753_i2c_driver;
1642static struct i2c_client client_template;
1643
1644static int wm8753_codec_probe(struct i2c_adapter *adap, int addr, int kind)
1645{
1646 struct snd_soc_device *socdev = wm8753_socdev;
1647 struct wm8753_setup_data *setup = socdev->codec_data;
1648 struct snd_soc_codec *codec = socdev->codec;
1649 struct i2c_client *i2c;
1650 int ret;
1651
1652 if (addr != setup->i2c_address)
1653 return -ENODEV;
1654
1655 client_template.adapter = adap;
1656 client_template.addr = addr;
1657
1658 i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
1659 if (i2c == NULL){
1660 kfree(codec);
1661 return -ENOMEM;
1662 }
1663 i2c_set_clientdata(i2c, codec);
1664 codec->control_data = i2c;
1665
1666 ret = i2c_attach_client(i2c);
1667 if (ret < 0) {
1668 err("failed to attach codec at addr %x\n", addr);
1669 goto err;
1670 }
1671
1672 ret = wm8753_init(socdev);
1673 if (ret < 0) {
1674 err("failed to initialise WM8753\n");
1675 goto err;
1676 }
1677
1678 return ret;
1679
1680err:
1681 kfree(codec);
1682 kfree(i2c);
1683 return ret;
1684}
1685
1686static int wm8753_i2c_detach(struct i2c_client *client)
1687{
1688 struct snd_soc_codec *codec = i2c_get_clientdata(client);
1689 i2c_detach_client(client);
1690 kfree(codec->reg_cache);
1691 kfree(client);
1692 return 0;
1693}
1694
1695static int wm8753_i2c_attach(struct i2c_adapter *adap)
1696{
1697 return i2c_probe(adap, &addr_data, wm8753_codec_probe);
1698}
1699
1700/* corgi i2c codec control layer */
1701static struct i2c_driver wm8753_i2c_driver = {
1702 .driver = {
1703 .name = "WM8753 I2C Codec",
1704 .owner = THIS_MODULE,
1705 },
1706 .id = I2C_DRIVERID_WM8753,
1707 .attach_adapter = wm8753_i2c_attach,
1708 .detach_client = wm8753_i2c_detach,
1709 .command = NULL,
1710};
1711
1712static struct i2c_client client_template = {
1713 .name = "WM8753",
1714 .driver = &wm8753_i2c_driver,
1715};
1716#endif
1717
1718static int wm8753_probe(struct platform_device *pdev)
1719{
1720 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1721 struct wm8753_setup_data *setup;
1722 struct snd_soc_codec *codec;
1723 struct wm8753_priv *wm8753;
1724 int ret = 0;
1725
1726 info("WM8753 Audio Codec %s", WM8753_VERSION);
1727
1728 setup = socdev->codec_data;
1729 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
1730 if (codec == NULL)
1731 return -ENOMEM;
1732
1733 wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
1734 if (wm8753 == NULL) {
1735 kfree(codec);
1736 return -ENOMEM;
1737 }
1738
1739 codec->private_data = wm8753;
1740 socdev->codec = codec;
1741 mutex_init(&codec->mutex);
1742 INIT_LIST_HEAD(&codec->dapm_widgets);
1743 INIT_LIST_HEAD(&codec->dapm_paths);
1744 wm8753_socdev = socdev;
1745 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
1746
1747#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1748 if (setup->i2c_address) {
1749 normal_i2c[0] = setup->i2c_address;
1750 codec->hw_write = (hw_write_t)i2c_master_send;
1751 ret = i2c_add_driver(&wm8753_i2c_driver);
1752 if (ret != 0)
1753 printk(KERN_ERR "can't add i2c driver");
1754 }
1755#else
1756 /* Add other interfaces here */
1757#endif
1758 return ret;
1759}
1760
1761/*
1762 * This function forces any delayed work to be queued and run.
1763 */
1764static int run_delayed_work(struct delayed_work *dwork)
1765{
1766 int ret;
1767
1768 /* cancel any work waiting to be queued. */
1769 ret = cancel_delayed_work(dwork);
1770
1771 /* if there was any work waiting then we run it now and
1772 * wait for it's completion */
1773 if (ret) {
1774 schedule_delayed_work(dwork, 0);
1775 flush_scheduled_work();
1776 }
1777 return ret;
1778}
1779
1780/* power down chip */
1781static int wm8753_remove(struct platform_device *pdev)
1782{
1783 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1784 struct snd_soc_codec *codec = socdev->codec;
1785
1786 if (codec->control_data)
1787 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1788 run_delayed_work(&codec->delayed_work);
1789 snd_soc_free_pcms(socdev);
1790 snd_soc_dapm_free(socdev);
1791#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1792 i2c_del_driver(&wm8753_i2c_driver);
1793#endif
1794 kfree(codec->private_data);
1795 kfree(codec);
1796
1797 return 0;
1798}
1799
1800struct snd_soc_codec_device soc_codec_dev_wm8753 = {
1801 .probe = wm8753_probe,
1802 .remove = wm8753_remove,
1803 .suspend = wm8753_suspend,
1804 .resume = wm8753_resume,
1805};
1806
1807EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753);
1808
1809MODULE_DESCRIPTION("ASoC WM8753 driver");
1810MODULE_AUTHOR("Liam Girdwood");
1811MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8753.h b/sound/soc/codecs/wm8753.h
new file mode 100644
index 00000000000..95e2a1f5316
--- /dev/null
+++ b/sound/soc/codecs/wm8753.h
@@ -0,0 +1,126 @@
1/*
2 * wm8753.h -- audio driver for WM8753
3 *
4 * Copyright 2003 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#ifndef _WM8753_H
16#define _WM8753_H
17
18/* WM8753 register space */
19
20#define WM8753_DAC 0x01
21#define WM8753_ADC 0x02
22#define WM8753_PCM 0x03
23#define WM8753_HIFI 0x04
24#define WM8753_IOCTL 0x05
25#define WM8753_SRATE1 0x06
26#define WM8753_SRATE2 0x07
27#define WM8753_LDAC 0x08
28#define WM8753_RDAC 0x09
29#define WM8753_BASS 0x0a
30#define WM8753_TREBLE 0x0b
31#define WM8753_ALC1 0x0c
32#define WM8753_ALC2 0x0d
33#define WM8753_ALC3 0x0e
34#define WM8753_NGATE 0x0f
35#define WM8753_LADC 0x10
36#define WM8753_RADC 0x11
37#define WM8753_ADCTL1 0x12
38#define WM8753_3D 0x13
39#define WM8753_PWR1 0x14
40#define WM8753_PWR2 0x15
41#define WM8753_PWR3 0x16
42#define WM8753_PWR4 0x17
43#define WM8753_ID 0x18
44#define WM8753_INTPOL 0x19
45#define WM8753_INTEN 0x1a
46#define WM8753_GPIO1 0x1b
47#define WM8753_GPIO2 0x1c
48#define WM8753_RESET 0x1f
49#define WM8753_RECMIX1 0x20
50#define WM8753_RECMIX2 0x21
51#define WM8753_LOUTM1 0x22
52#define WM8753_LOUTM2 0x23
53#define WM8753_ROUTM1 0x24
54#define WM8753_ROUTM2 0x25
55#define WM8753_MOUTM1 0x26
56#define WM8753_MOUTM2 0x27
57#define WM8753_LOUT1V 0x28
58#define WM8753_ROUT1V 0x29
59#define WM8753_LOUT2V 0x2a
60#define WM8753_ROUT2V 0x2b
61#define WM8753_MOUTV 0x2c
62#define WM8753_OUTCTL 0x2d
63#define WM8753_ADCIN 0x2e
64#define WM8753_INCTL1 0x2f
65#define WM8753_INCTL2 0x30
66#define WM8753_LINVOL 0x31
67#define WM8753_RINVOL 0x32
68#define WM8753_MICBIAS 0x33
69#define WM8753_CLOCK 0x34
70#define WM8753_PLL1CTL1 0x35
71#define WM8753_PLL1CTL2 0x36
72#define WM8753_PLL1CTL3 0x37
73#define WM8753_PLL1CTL4 0x38
74#define WM8753_PLL2CTL1 0x39
75#define WM8753_PLL2CTL2 0x3a
76#define WM8753_PLL2CTL3 0x3b
77#define WM8753_PLL2CTL4 0x3c
78#define WM8753_BIASCTL 0x3d
79#define WM8753_ADCTL2 0x3f
80
81struct wm8753_setup_data {
82 unsigned short i2c_address;
83};
84
85#define WM8753_PLL1 0
86#define WM8753_PLL2 1
87
88/* clock inputs */
89#define WM8753_MCLK 0
90#define WM8753_PCMCLK 1
91
92/* clock divider id's */
93#define WM8753_PCMDIV 0
94#define WM8753_BCLKDIV 1
95#define WM8753_VXCLKDIV 2
96
97/* PCM clock dividers */
98#define WM8753_PCM_DIV_1 (0 << 6)
99#define WM8753_PCM_DIV_3 (2 << 6)
100#define WM8753_PCM_DIV_5_5 (3 << 6)
101#define WM8753_PCM_DIV_2 (4 << 6)
102#define WM8753_PCM_DIV_4 (5 << 6)
103#define WM8753_PCM_DIV_6 (6 << 6)
104#define WM8753_PCM_DIV_8 (7 << 6)
105
106/* BCLK clock dividers */
107#define WM8753_BCLK_DIV_1 (0 << 3)
108#define WM8753_BCLK_DIV_2 (1 << 3)
109#define WM8753_BCLK_DIV_4 (2 << 3)
110#define WM8753_BCLK_DIV_8 (3 << 3)
111#define WM8753_BCLK_DIV_16 (4 << 3)
112
113/* VXCLK clock dividers */
114#define WM8753_VXCLK_DIV_1 (0 << 6)
115#define WM8753_VXCLK_DIV_2 (1 << 6)
116#define WM8753_VXCLK_DIV_4 (2 << 6)
117#define WM8753_VXCLK_DIV_8 (3 << 6)
118#define WM8753_VXCLK_DIV_16 (4 << 6)
119
120#define WM8753_DAI_HIFI 0
121#define WM8753_DAI_VOICE 1
122
123extern struct snd_soc_codec_dai wm8753_dai[2];
124extern struct snd_soc_codec_device soc_codec_dev_wm8753;
125
126#endif
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index ee7a691a9ba..986b5d59cef 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -544,6 +544,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream)
544struct snd_soc_codec_dai wm9712_dai[] = { 544struct snd_soc_codec_dai wm9712_dai[] = {
545{ 545{
546 .name = "AC97 HiFi", 546 .name = "AC97 HiFi",
547 .type = SND_SOC_DAI_AC97_BUS,
547 .playback = { 548 .playback = {
548 .stream_name = "HiFi Playback", 549 .stream_name = "HiFi Playback",
549 .channels_min = 1, 550 .channels_min = 1,
@@ -676,14 +677,13 @@ static int wm9712_soc_probe(struct platform_device *pdev)
676 codec = socdev->codec; 677 codec = socdev->codec;
677 mutex_init(&codec->mutex); 678 mutex_init(&codec->mutex);
678 679
679 codec->reg_cache = 680 codec->reg_cache = kmemdup(wm9712_reg, sizeof(wm9712_reg), GFP_KERNEL);
680 kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL); 681
681 if (codec->reg_cache == NULL) { 682 if (codec->reg_cache == NULL) {
682 ret = -ENOMEM; 683 ret = -ENOMEM;
683 goto cache_err; 684 goto cache_err;
684 } 685 }
685 memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg)); 686 codec->reg_cache_size = sizeof(wm9712_reg);
686 codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg);
687 codec->reg_cache_step = 2; 687 codec->reg_cache_step = 2;
688 688
689 codec->name = "WM9712"; 689 codec->name = "WM9712";
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index b9ab3b8e1d3..a83e22937c2 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -1,5 +1,3 @@
1menu "SoC Audio for the Intel PXA2xx"
2
3config SND_PXA2XX_SOC 1config SND_PXA2XX_SOC
4 tristate "SoC Audio for the Intel PXA2xx chip" 2 tristate "SoC Audio for the Intel PXA2xx chip"
5 depends on ARCH_PXA && SND_SOC 3 depends on ARCH_PXA && SND_SOC
@@ -55,5 +53,3 @@ config SND_PXA2XX_SOC_TOSA
55 help 53 help
56 Say Y if you want to add support for SoC audio on Sharp 54 Say Y if you want to add support for SoC audio on Sharp
57 Zaurus SL-C6000x models (Tosa). 55 Zaurus SL-C6000x models (Tosa).
58
59endmenu
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index b222755763e..129d851b315 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -300,7 +300,7 @@ static int pxa2xx_ac97_probe(struct platform_device *pdev)
300 return 0; 300 return 0;
301 301
302 err: 302 err:
303 if (CKEN & CKEN_AC97) { 303 if (CKEN & (1 << CKEN_AC97)) {
304 GCR |= GCR_ACLINK_OFF; 304 GCR |= GCR_ACLINK_OFF;
305 free_irq(IRQ_AC97, NULL); 305 free_irq(IRQ_AC97, NULL);
306 pxa_set_cken(CKEN_AC97, 0); 306 pxa_set_cken(CKEN_AC97, 0);
diff --git a/sound/soc/pxa/pxa2xx-ac97.h b/sound/soc/pxa/pxa2xx-ac97.h
index 4c4b882316a..b8ccfee095c 100644
--- a/sound/soc/pxa/pxa2xx-ac97.h
+++ b/sound/soc/pxa/pxa2xx-ac97.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/sound/arm/pxa2xx-ac97.h 2 * linux/sound/soc/pxa/pxa2xx-ac97.h
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
diff --git a/sound/soc/pxa/pxa2xx-i2s.h b/sound/soc/pxa/pxa2xx-i2s.h
index a2484f0881f..4435bd9f884 100644
--- a/sound/soc/pxa/pxa2xx-i2s.h
+++ b/sound/soc/pxa/pxa2xx-i2s.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/sound/arm/pxa2xx-i2s.h 2 * linux/sound/soc/pxa/pxa2xx-i2s.h
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
new file mode 100644
index 00000000000..e97c68306a9
--- /dev/null
+++ b/sound/soc/s3c24xx/Kconfig
@@ -0,0 +1,37 @@
1config SND_S3C24XX_SOC
2 tristate "SoC Audio for the Samsung S3C24XX chips"
3 depends on ARCH_S3C2410 && SND_SOC
4 select SND_PCM
5 help
6 Say Y or M if you want to add support for codecs attached to
7 the S3C24XX AC97, I2S or SSP interface. You will also need
8 to select the audio interfaces to support below.
9
10config SND_S3C24XX_SOC_I2S
11 tristate
12
13config SND_S3C2443_SOC_AC97
14 tristate
15 select AC97_BUS
16 select SND_AC97_CODEC
17 select SND_SOC_AC97_BUS
18
19config SND_S3C24XX_SOC_NEO1973_WM8753
20 tristate "SoC I2S Audio support for NEO1973 - WM8753"
21 depends on SND_S3C24XX_SOC && MACH_GTA01
22 select SND_S3C24XX_SOC_I2S
23 select SND_SOC_WM8753
24 help
25 Say Y if you want to add support for SoC audio on smdk2440
26 with the WM8753.
27
28config SND_S3C24XX_SOC_SMDK2443_WM9710
29 tristate "SoC AC97 Audio support for SMDK2443 - WM9710"
30 depends on SND_S3C24XX_SOC && MACH_SMDK2443
31 select SND_S3C2443_SOC_AC97
32 select SND_SOC_AC97_CODEC
33 help
34 Say Y if you want to add support for SoC audio on smdk2443
35 with the WM9710.
36
37
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
new file mode 100644
index 00000000000..13c92f0fa1e
--- /dev/null
+++ b/sound/soc/s3c24xx/Makefile
@@ -0,0 +1,15 @@
1# S3c24XX Platform Support
2snd-soc-s3c24xx-objs := s3c24xx-pcm.o
3snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o
4snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o
5
6obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o
7obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o
8obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o
9
10# S3C24XX Machine Support
11snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o
12snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o
13
14obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
15obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o
diff --git a/sound/soc/s3c24xx/lm4857.h b/sound/soc/s3c24xx/lm4857.h
new file mode 100644
index 00000000000..0cf5b7011d6
--- /dev/null
+++ b/sound/soc/s3c24xx/lm4857.h
@@ -0,0 +1,32 @@
1/*
2 * lm4857.h -- ALSA Soc Audio Layer
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 18th Jun 2007 Initial version.
15 */
16
17#ifndef LM4857_H_
18#define LM4857_H_
19
20/* The register offsets in the cache array */
21#define LM4857_MVOL 0
22#define LM4857_LVOL 1
23#define LM4857_RVOL 2
24#define LM4857_CTRL 3
25
26/* the shifts required to set these bits */
27#define LM4857_3D 5
28#define LM4857_WAKEUP 5
29#define LM4857_EPGAIN 4
30
31#endif /*LM4857_H_*/
32
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c
new file mode 100644
index 00000000000..d5a8fc2cf8d
--- /dev/null
+++ b/sound/soc/s3c24xx/neo1973_wm8753.c
@@ -0,0 +1,670 @@
1/*
2 * neo1973_wm8753.c -- SoC audio for Neo1973
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 20th Jan 2007 Initial version.
15 * 05th Feb 2007 Rename all to Neo1973
16 *
17 */
18
19#include <linux/module.h>
20#include <linux/moduleparam.h>
21#include <linux/timer.h>
22#include <linux/interrupt.h>
23#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <sound/driver.h>
26#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/soc.h>
29#include <sound/soc-dapm.h>
30
31#include <asm/mach-types.h>
32#include <asm/hardware/scoop.h>
33#include <asm/arch/regs-iis.h>
34#include <asm/arch/regs-clock.h>
35#include <asm/arch/regs-gpio.h>
36#include <asm/hardware.h>
37#include <asm/arch/audio.h>
38#include <asm/io.h>
39#include <asm/arch/spi-gpio.h>
40#include "../codecs/wm8753.h"
41#include "lm4857.h"
42#include "s3c24xx-pcm.h"
43#include "s3c24xx-i2s.h"
44
45/* define the scenarios */
46#define NEO_AUDIO_OFF 0
47#define NEO_GSM_CALL_AUDIO_HANDSET 1
48#define NEO_GSM_CALL_AUDIO_HEADSET 2
49#define NEO_GSM_CALL_AUDIO_BLUETOOTH 3
50#define NEO_STEREO_TO_SPEAKERS 4
51#define NEO_STEREO_TO_HEADPHONES 5
52#define NEO_CAPTURE_HANDSET 6
53#define NEO_CAPTURE_HEADSET 7
54#define NEO_CAPTURE_BLUETOOTH 8
55
56static struct snd_soc_machine neo1973;
57static struct i2c_client *i2c;
58
59static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream,
60 struct snd_pcm_hw_params *params)
61{
62 struct snd_soc_pcm_runtime *rtd = substream->private_data;
63 struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
64 struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
65 unsigned int pll_out = 0, bclk = 0;
66 int ret = 0;
67 unsigned long iis_clkrate;
68
69 iis_clkrate = s3c24xx_i2s_get_clockrate();
70
71 switch (params_rate(params)) {
72 case 8000:
73 case 16000:
74 pll_out = 12288000;
75 break;
76 case 48000:
77 bclk = WM8753_BCLK_DIV_4;
78 pll_out = 12288000;
79 break;
80 case 96000:
81 bclk = WM8753_BCLK_DIV_2;
82 pll_out = 12288000;
83 break;
84 case 11025:
85 bclk = WM8753_BCLK_DIV_16;
86 pll_out = 11289600;
87 break;
88 case 22050:
89 bclk = WM8753_BCLK_DIV_8;
90 pll_out = 11289600;
91 break;
92 case 44100:
93 bclk = WM8753_BCLK_DIV_4;
94 pll_out = 11289600;
95 break;
96 case 88200:
97 bclk = WM8753_BCLK_DIV_2;
98 pll_out = 11289600;
99 break;
100 }
101
102 /* set codec DAI configuration */
103 ret = codec_dai->dai_ops.set_fmt(codec_dai,
104 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
105 SND_SOC_DAIFMT_CBM_CFM);
106 if (ret < 0)
107 return ret;
108
109 /* set cpu DAI configuration */
110 ret = cpu_dai->dai_ops.set_fmt(cpu_dai,
111 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
112 SND_SOC_DAIFMT_CBM_CFM);
113 if (ret < 0)
114 return ret;
115
116 /* set the codec system clock for DAC and ADC */
117 ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_MCLK, pll_out,
118 SND_SOC_CLOCK_IN);
119 if (ret < 0)
120 return ret;
121
122 /* set MCLK division for sample rate */
123 ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
124 S3C2410_IISMOD_32FS );
125 if (ret < 0)
126 return ret;
127
128 /* set codec BCLK division for sample rate */
129 ret = codec_dai->dai_ops.set_clkdiv(codec_dai, WM8753_BCLKDIV, bclk);
130 if (ret < 0)
131 return ret;
132
133 /* set prescaler division for sample rate */
134 ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
135 S3C24XX_PRESCALE(4,4));
136 if (ret < 0)
137 return ret;
138
139 /* codec PLL input is PCLK/4 */
140 ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1,
141 iis_clkrate / 4, pll_out);
142 if (ret < 0)
143 return ret;
144
145 return 0;
146}
147
148static int neo1973_hifi_hw_free(struct snd_pcm_substream *substream)
149{
150 struct snd_soc_pcm_runtime *rtd = substream->private_data;
151 struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
152
153 /* disable the PLL */
154 return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1, 0, 0);
155}
156
157/*
158 * Neo1973 WM8753 HiFi DAI opserations.
159 */
160static struct snd_soc_ops neo1973_hifi_ops = {
161 .hw_params = neo1973_hifi_hw_params,
162 .hw_free = neo1973_hifi_hw_free,
163};
164
165static int neo1973_voice_hw_params(struct snd_pcm_substream *substream,
166 struct snd_pcm_hw_params *params)
167{
168 struct snd_soc_pcm_runtime *rtd = substream->private_data;
169 struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
170 unsigned int pcmdiv = 0;
171 int ret = 0;
172 unsigned long iis_clkrate;
173
174 iis_clkrate = s3c24xx_i2s_get_clockrate();
175
176 if (params_rate(params) != 8000)
177 return -EINVAL;
178 if (params_channels(params) != 1)
179 return -EINVAL;
180
181 pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */
182
183 /* todo: gg check mode (DSP_B) against CSR datasheet */
184 /* set codec DAI configuration */
185 ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B |
186 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
187 if (ret < 0)
188 return ret;
189
190 /* set the codec system clock for DAC and ADC */
191 ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_PCMCLK, 12288000,
192 SND_SOC_CLOCK_IN);
193 if (ret < 0)
194 return ret;
195
196 /* set codec PCM division for sample rate */
197 ret = codec_dai->dai_ops.set_clkdiv(codec_dai, WM8753_PCMDIV, pcmdiv);
198 if (ret < 0)
199 return ret;
200
201 /* configue and enable PLL for 12.288MHz output */
202 ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2,
203 iis_clkrate / 4, 12288000);
204 if (ret < 0)
205 return ret;
206
207 return 0;
208}
209
210static int neo1973_voice_hw_free(struct snd_pcm_substream *substream)
211{
212 struct snd_soc_pcm_runtime *rtd = substream->private_data;
213 struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
214
215 /* disable the PLL */
216 return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2, 0, 0);
217}
218
219static struct snd_soc_ops neo1973_voice_ops = {
220 .hw_params = neo1973_voice_hw_params,
221 .hw_free = neo1973_voice_hw_free,
222};
223
224static int neo1973_scenario = 0;
225
226static int neo1973_get_scenario(struct snd_kcontrol *kcontrol,
227 struct snd_ctl_elem_value *ucontrol)
228{
229 ucontrol->value.integer.value[0] = neo1973_scenario;
230 return 0;
231}
232
233static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario)
234{
235 switch(neo1973_scenario) {
236 case NEO_AUDIO_OFF:
237 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
238 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
239 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
240 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
241 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
242 break;
243 case NEO_GSM_CALL_AUDIO_HANDSET:
244 snd_soc_dapm_set_endpoint(codec, "Audio Out", 1);
245 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
246 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 1);
247 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
248 snd_soc_dapm_set_endpoint(codec, "Call Mic", 1);
249 break;
250 case NEO_GSM_CALL_AUDIO_HEADSET:
251 snd_soc_dapm_set_endpoint(codec, "Audio Out", 1);
252 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
253 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 1);
254 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 1);
255 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
256 break;
257 case NEO_GSM_CALL_AUDIO_BLUETOOTH:
258 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
259 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
260 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 1);
261 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
262 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
263 break;
264 case NEO_STEREO_TO_SPEAKERS:
265 snd_soc_dapm_set_endpoint(codec, "Audio Out", 1);
266 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
267 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
268 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
269 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
270 break;
271 case NEO_STEREO_TO_HEADPHONES:
272 snd_soc_dapm_set_endpoint(codec, "Audio Out", 1);
273 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
274 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
275 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
276 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
277 break;
278 case NEO_CAPTURE_HANDSET:
279 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
280 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
281 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
282 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
283 snd_soc_dapm_set_endpoint(codec, "Call Mic", 1);
284 break;
285 case NEO_CAPTURE_HEADSET:
286 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
287 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
288 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
289 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 1);
290 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
291 break;
292 case NEO_CAPTURE_BLUETOOTH:
293 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
294 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
295 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
296 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
297 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
298 break;
299 default:
300 snd_soc_dapm_set_endpoint(codec, "Audio Out", 0);
301 snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
302 snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
303 snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
304 snd_soc_dapm_set_endpoint(codec, "Call Mic", 0);
305 }
306
307 snd_soc_dapm_sync_endpoints(codec);
308
309 return 0;
310}
311
312static int neo1973_set_scenario(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_value *ucontrol)
314{
315 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
316
317 if (neo1973_scenario == ucontrol->value.integer.value[0])
318 return 0;
319
320 neo1973_scenario = ucontrol->value.integer.value[0];
321 set_scenario_endpoints(codec, neo1973_scenario);
322 return 1;
323}
324
325static u8 lm4857_regs[4] = {0x00, 0x40, 0x80, 0xC0};
326
327static void lm4857_write_regs(void)
328{
329 if (i2c_master_send(i2c, lm4857_regs, 4) != 4)
330 printk(KERN_ERR "lm4857: i2c write failed\n");
331}
332
333static int lm4857_get_reg(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_value *ucontrol)
335{
336 int reg=kcontrol->private_value & 0xFF;
337 int shift = (kcontrol->private_value >> 8) & 0x0F;
338 int mask = (kcontrol->private_value >> 16) & 0xFF;
339
340 ucontrol->value.integer.value[0] = (lm4857_regs[reg] >> shift) & mask;
341 return 0;
342}
343
344static int lm4857_set_reg(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_value *ucontrol)
346{
347 int reg = kcontrol->private_value & 0xFF;
348 int shift = (kcontrol->private_value >> 8) & 0x0F;
349 int mask = (kcontrol->private_value >> 16) & 0xFF;
350
351 if (((lm4857_regs[reg] >> shift ) & mask) ==
352 ucontrol->value.integer.value[0])
353 return 0;
354
355 lm4857_regs[reg] &= ~ (mask << shift);
356 lm4857_regs[reg] |= ucontrol->value.integer.value[0] << shift;
357 lm4857_write_regs();
358 return 1;
359}
360
361static int lm4857_get_mode(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_value *ucontrol)
363{
364 u8 value = lm4857_regs[LM4857_CTRL] & 0x0F;
365
366 if (value)
367 value -= 5;
368
369 ucontrol->value.integer.value[0] = value;
370 return 0;
371}
372
373static int lm4857_set_mode(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
375{
376 u8 value = ucontrol->value.integer.value[0];
377
378 if (value)
379 value += 5;
380
381 if ((lm4857_regs[LM4857_CTRL] & 0x0F) == value)
382 return 0;
383
384 lm4857_regs[LM4857_CTRL] &= 0xF0;
385 lm4857_regs[LM4857_CTRL] |= value;
386 lm4857_write_regs();
387 return 1;
388}
389
390static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
391 SND_SOC_DAPM_LINE("Audio Out", NULL),
392 SND_SOC_DAPM_LINE("GSM Line Out", NULL),
393 SND_SOC_DAPM_LINE("GSM Line In", NULL),
394 SND_SOC_DAPM_MIC("Headset Mic", NULL),
395 SND_SOC_DAPM_MIC("Call Mic", NULL),
396};
397
398
399/* example machine audio_mapnections */
400static const char* audio_map[][3] = {
401
402 /* Connections to the lm4857 amp */
403 {"Audio Out", NULL, "LOUT1"},
404 {"Audio Out", NULL, "ROUT1"},
405
406 /* Connections to the GSM Module */
407 {"GSM Line Out", NULL, "MONO1"},
408 {"GSM Line Out", NULL, "MONO2"},
409 {"RXP", NULL, "GSM Line In"},
410 {"RXN", NULL, "GSM Line In"},
411
412 /* Connections to Headset */
413 {"MIC1", NULL, "Mic Bias"},
414 {"Mic Bias", NULL, "Headset Mic"},
415
416 /* Call Mic */
417 {"MIC2", NULL, "Mic Bias"},
418 {"MIC2N", NULL, "Mic Bias"},
419 {"Mic Bias", NULL, "Call Mic"},
420
421 /* Connect the ALC pins */
422 {"ACIN", NULL, "ACOP"},
423
424 {NULL, NULL, NULL},
425};
426
427static const char *lm4857_mode[] = {
428 "Off",
429 "Call Speaker",
430 "Stereo Speakers",
431 "Stereo Speakers + Headphones",
432 "Headphones"
433};
434
435static const struct soc_enum lm4857_mode_enum[] = {
436 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lm4857_mode), lm4857_mode),
437};
438
439static const char *neo_scenarios[] = {
440 "Off",
441 "GSM Handset",
442 "GSM Headset",
443 "GSM Bluetooth",
444 "Speakers",
445 "Headphones",
446 "Capture Handset",
447 "Capture Headset",
448 "Capture Bluetooth"
449};
450
451static const struct soc_enum neo_scenario_enum[] = {
452 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(neo_scenarios),neo_scenarios),
453};
454
455static const struct snd_kcontrol_new wm8753_neo1973_controls[] = {
456 SOC_SINGLE_EXT("Amp Left Playback Volume", LM4857_LVOL, 0, 31, 0,
457 lm4857_get_reg, lm4857_set_reg),
458 SOC_SINGLE_EXT("Amp Right Playback Volume", LM4857_RVOL, 0, 31, 0,
459 lm4857_get_reg, lm4857_set_reg),
460 SOC_SINGLE_EXT("Amp Mono Playback Volume", LM4857_MVOL, 0, 31, 0,
461 lm4857_get_reg, lm4857_set_reg),
462 SOC_ENUM_EXT("Amp Mode", lm4857_mode_enum[0],
463 lm4857_get_mode, lm4857_set_mode),
464 SOC_ENUM_EXT("Neo Mode", neo_scenario_enum[0],
465 neo1973_get_scenario, neo1973_set_scenario),
466 SOC_SINGLE_EXT("Amp Spk 3D Playback Switch", LM4857_LVOL, 5, 1, 0,
467 lm4857_get_reg, lm4857_set_reg),
468 SOC_SINGLE_EXT("Amp HP 3d Playback Switch", LM4857_RVOL, 5, 1, 0,
469 lm4857_get_reg, lm4857_set_reg),
470 SOC_SINGLE_EXT("Amp Fast Wakeup Playback Switch", LM4857_CTRL, 5, 1, 0,
471 lm4857_get_reg, lm4857_set_reg),
472 SOC_SINGLE_EXT("Amp Earpiece 6dB Playback Switch", LM4857_CTRL, 4, 1, 0,
473 lm4857_get_reg, lm4857_set_reg),
474};
475
476/*
477 * This is an example machine initialisation for a wm8753 connected to a
478 * neo1973 II. It is missing logic to detect hp/mic insertions and logic
479 * to re-route the audio in such an event.
480 */
481static int neo1973_wm8753_init(struct snd_soc_codec *codec)
482{
483 int i, err;
484
485 /* set up NC codec pins */
486 snd_soc_dapm_set_endpoint(codec, "LOUT2", 0);
487 snd_soc_dapm_set_endpoint(codec, "ROUT2", 0);
488 snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
489 snd_soc_dapm_set_endpoint(codec, "OUT4", 0);
490 snd_soc_dapm_set_endpoint(codec, "LINE1", 0);
491 snd_soc_dapm_set_endpoint(codec, "LINE2", 0);
492
493
494 /* set endpoints to default mode */
495 set_scenario_endpoints(codec, NEO_AUDIO_OFF);
496
497 /* Add neo1973 specific widgets */
498 for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++)
499 snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
500
501 /* add neo1973 specific controls */
502 for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) {
503 err = snd_ctl_add(codec->card,
504 snd_soc_cnew(&wm8753_neo1973_controls[i],
505 codec, NULL));
506 if (err < 0)
507 return err;
508 }
509
510 /* set up neo1973 specific audio path audio_mapnects */
511 for (i = 0; audio_map[i][0] != NULL; i++) {
512 snd_soc_dapm_connect_input(codec, audio_map[i][0],
513 audio_map[i][1], audio_map[i][2]);
514 }
515
516 snd_soc_dapm_sync_endpoints(codec);
517 return 0;
518}
519
520/*
521 * BT Codec DAI
522 */
523static struct snd_soc_cpu_dai bt_dai =
524{ .name = "Bluetooth",
525 .id = 0,
526 .type = SND_SOC_DAI_PCM,
527 .playback = {
528 .channels_min = 1,
529 .channels_max = 1,
530 .rates = SNDRV_PCM_RATE_8000,
531 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
532 .capture = {
533 .channels_min = 1,
534 .channels_max = 1,
535 .rates = SNDRV_PCM_RATE_8000,
536 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
537};
538
539static struct snd_soc_dai_link neo1973_dai[] = {
540{ /* Hifi Playback - for similatious use with voice below */
541 .name = "WM8753",
542 .stream_name = "WM8753 HiFi",
543 .cpu_dai = &s3c24xx_i2s_dai,
544 .codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
545 .init = neo1973_wm8753_init,
546 .ops = &neo1973_hifi_ops,
547},
548{ /* Voice via BT */
549 .name = "Bluetooth",
550 .stream_name = "Voice",
551 .cpu_dai = &bt_dai,
552 .codec_dai = &wm8753_dai[WM8753_DAI_VOICE],
553 .ops = &neo1973_voice_ops,
554},
555};
556
557static struct snd_soc_machine neo1973 = {
558 .name = "neo1973",
559 .dai_link = neo1973_dai,
560 .num_links = ARRAY_SIZE(neo1973_dai),
561};
562
563static struct wm8753_setup_data neo1973_wm8753_setup = {
564 .i2c_address = 0x1a,
565};
566
567static struct snd_soc_device neo1973_snd_devdata = {
568 .machine = &neo1973,
569 .platform = &s3c24xx_soc_platform,
570 .codec_dev = &soc_codec_dev_wm8753,
571 .codec_data = &neo1973_wm8753_setup,
572};
573
574static struct i2c_client client_template;
575
576static unsigned short normal_i2c[] = { 0x7C, I2C_CLIENT_END };
577
578/* Magic definition of all other variables and things */
579I2C_CLIENT_INSMOD;
580
581static int lm4857_amp_probe(struct i2c_adapter *adap, int addr, int kind)
582{
583 int ret;
584
585 client_template.adapter = adap;
586 client_template.addr = addr;
587
588 i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
589 if (i2c == NULL)
590 return -ENOMEM;
591
592 ret = i2c_attach_client(i2c);
593 if (ret < 0) {
594 printk(KERN_ERR "LM4857 failed to attach at addr %x\n", addr);
595 goto exit_err;
596 }
597
598 lm4857_write_regs();
599 return ret;
600
601exit_err:
602 kfree(i2c);
603 return ret;
604}
605
606static int lm4857_i2c_detach(struct i2c_client *client)
607{
608 i2c_detach_client(client);
609 kfree(client);
610 return 0;
611}
612
613static int lm4857_i2c_attach(struct i2c_adapter *adap)
614{
615 return i2c_probe(adap, &addr_data, lm4857_amp_probe);
616}
617
618/* corgi i2c codec control layer */
619static struct i2c_driver lm4857_i2c_driver = {
620 .driver = {
621 .name = "LM4857 I2C Amp",
622 .owner = THIS_MODULE,
623 },
624 .id = I2C_DRIVERID_LM4857,
625 .attach_adapter = lm4857_i2c_attach,
626 .detach_client = lm4857_i2c_detach,
627 .command = NULL,
628};
629
630static struct i2c_client client_template = {
631 .name = "LM4857",
632 .driver = &lm4857_i2c_driver,
633};
634
635static struct platform_device *neo1973_snd_device;
636
637static int __init neo1973_init(void)
638{
639 int ret;
640
641 neo1973_snd_device = platform_device_alloc("soc-audio", -1);
642 if (!neo1973_snd_device)
643 return -ENOMEM;
644
645 platform_set_drvdata(neo1973_snd_device, &neo1973_snd_devdata);
646 neo1973_snd_devdata.dev = &neo1973_snd_device->dev;
647 ret = platform_device_add(neo1973_snd_device);
648
649 if (ret)
650 platform_device_put(neo1973_snd_device);
651
652 ret = i2c_add_driver(&lm4857_i2c_driver);
653 if (ret != 0)
654 printk(KERN_ERR "can't add i2c driver");
655
656 return ret;
657}
658
659static void __exit neo1973_exit(void)
660{
661 platform_device_unregister(neo1973_snd_device);
662}
663
664module_init(neo1973_init);
665module_exit(neo1973_exit);
666
667/* Module information */
668MODULE_AUTHOR("Graeme Gregory, graeme.gregory@wolfsonmicro.com, www.wolfsonmicro.com");
669MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973");
670MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c
new file mode 100644
index 00000000000..75acf7ef552
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c2443-ac97.c
@@ -0,0 +1,401 @@
1/*
2 * s3c2443-ac97.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2007 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 *
7 * Copyright (C) 2005, Sean Choi <sh428.choi@samsung.com>
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Revision history
15 * 21st Mar 2007 Initial Version
16 */
17
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/platform_device.h>
21#include <linux/interrupt.h>
22#include <linux/wait.h>
23#include <linux/delay.h>
24#include <linux/clk.h>
25
26#include <sound/driver.h>
27#include <sound/core.h>
28#include <sound/pcm.h>
29#include <sound/ac97_codec.h>
30#include <sound/initval.h>
31#include <sound/soc.h>
32
33#include <asm/hardware.h>
34#include <asm/io.h>
35#include <asm/arch/regs-ac97.h>
36#include <asm/arch/regs-gpio.h>
37#include <asm/arch/regs-clock.h>
38#include <asm/arch/audio.h>
39#include <asm/dma.h>
40#include <asm/arch/dma.h>
41
42#include "s3c24xx-pcm.h"
43#include "s3c24xx-ac97.h"
44
45struct s3c24xx_ac97_info {
46 void __iomem *regs;
47 struct clk *ac97_clk;
48};
49static struct s3c24xx_ac97_info s3c24xx_ac97;
50
51DECLARE_COMPLETION(ac97_completion);
52static u32 codec_ready;
53static DECLARE_MUTEX(ac97_mutex);
54
55static unsigned short s3c2443_ac97_read(struct snd_ac97 *ac97,
56 unsigned short reg)
57{
58 u32 ac_glbctrl;
59 u32 ac_codec_cmd;
60 u32 stat, addr, data;
61
62 down(&ac97_mutex);
63
64 codec_ready = S3C_AC97_GLBSTAT_CODECREADY;
65 ac_codec_cmd = readl(s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
66 ac_codec_cmd = S3C_AC97_CODEC_CMD_READ | AC_CMD_ADDR(reg);
67 writel(ac_codec_cmd, s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
68
69 udelay(50);
70
71 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
72 ac_glbctrl |= S3C_AC97_GLBCTRL_CODECREADYIE;
73 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
74
75 wait_for_completion(&ac97_completion);
76
77 stat = readl(s3c24xx_ac97.regs + S3C_AC97_STAT);
78 addr = (stat >> 16) & 0x7f;
79 data = (stat & 0xffff);
80
81 if (addr != reg)
82 printk(KERN_ERR "s3c24xx-ac97: req addr = %02x,"
83 " rep addr = %02x\n", reg, addr);
84
85 up(&ac97_mutex);
86
87 return (unsigned short)data;
88}
89
90static void s3c2443_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
91 unsigned short val)
92{
93 u32 ac_glbctrl;
94 u32 ac_codec_cmd;
95
96 down(&ac97_mutex);
97
98 codec_ready = S3C_AC97_GLBSTAT_CODECREADY;
99 ac_codec_cmd = readl(s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
100 ac_codec_cmd = AC_CMD_ADDR(reg) | AC_CMD_DATA(val);
101 writel(ac_codec_cmd, s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
102
103 udelay(50);
104
105 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
106 ac_glbctrl |= S3C_AC97_GLBCTRL_CODECREADYIE;
107 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
108
109 wait_for_completion(&ac97_completion);
110
111 ac_codec_cmd = readl(s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
112 ac_codec_cmd |= S3C_AC97_CODEC_CMD_READ;
113 writel(ac_codec_cmd, s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD);
114
115 up(&ac97_mutex);
116
117}
118
119static void s3c2443_ac97_warm_reset(struct snd_ac97 *ac97)
120{
121 u32 ac_glbctrl;
122
123 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
124 ac_glbctrl = S3C_AC97_GLBCTRL_WARMRESET;
125 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
126 msleep(1);
127
128 ac_glbctrl = 0;
129 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
130 msleep(1);
131}
132
133static void s3c2443_ac97_cold_reset(struct snd_ac97 *ac97)
134{
135 u32 ac_glbctrl;
136
137 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
138 ac_glbctrl = S3C_AC97_GLBCTRL_COLDRESET;
139 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
140 msleep(1);
141
142 ac_glbctrl = 0;
143 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
144 msleep(1);
145
146 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
147 ac_glbctrl = S3C_AC97_GLBCTRL_ACLINKON;
148 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
149 msleep(1);
150
151 ac_glbctrl |= S3C_AC97_GLBCTRL_TRANSFERDATAENABLE;
152 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
153 msleep(1);
154
155 ac_glbctrl |= S3C_AC97_GLBCTRL_PCMOUTTM_DMA |
156 S3C_AC97_GLBCTRL_PCMINTM_DMA | S3C_AC97_GLBCTRL_MICINTM_DMA;
157 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
158}
159
160static irqreturn_t s3c2443_ac97_irq(int irq, void *dev_id)
161{
162 int status;
163 u32 ac_glbctrl;
164
165 status = readl(s3c24xx_ac97.regs + S3C_AC97_GLBSTAT) & codec_ready;
166
167 if (status) {
168 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
169 ac_glbctrl &= ~S3C_AC97_GLBCTRL_CODECREADYIE;
170 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
171 complete(&ac97_completion);
172 }
173 return IRQ_HANDLED;
174}
175
176struct snd_ac97_bus_ops soc_ac97_ops = {
177 .read = s3c2443_ac97_read,
178 .write = s3c2443_ac97_write,
179 .warm_reset = s3c2443_ac97_warm_reset,
180 .reset = s3c2443_ac97_cold_reset,
181};
182
183static struct s3c2410_dma_client s3c2443_dma_client_out = {
184 .name = "AC97 PCM Stereo out"
185};
186
187static struct s3c2410_dma_client s3c2443_dma_client_in = {
188 .name = "AC97 PCM Stereo in"
189};
190
191static struct s3c2410_dma_client s3c2443_dma_client_micin = {
192 .name = "AC97 Mic Mono in"
193};
194
195static struct s3c24xx_pcm_dma_params s3c2443_ac97_pcm_stereo_out = {
196 .client = &s3c2443_dma_client_out,
197 .channel = DMACH_PCM_OUT,
198 .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA,
199 .dma_size = 4,
200};
201
202static struct s3c24xx_pcm_dma_params s3c2443_ac97_pcm_stereo_in = {
203 .client = &s3c2443_dma_client_in,
204 .channel = DMACH_PCM_IN,
205 .dma_addr = S3C2440_PA_AC97 + S3C_AC97_PCM_DATA,
206 .dma_size = 4,
207};
208
209static struct s3c24xx_pcm_dma_params s3c2443_ac97_mic_mono_in = {
210 .client = &s3c2443_dma_client_micin,
211 .channel = DMACH_MIC_IN,
212 .dma_addr = S3C2440_PA_AC97 + S3C_AC97_MIC_DATA,
213 .dma_size = 4,
214};
215
216static int s3c2443_ac97_probe(struct platform_device *pdev)
217{
218 int ret;
219 u32 ac_glbctrl;
220
221 s3c24xx_ac97.regs = ioremap(S3C2440_PA_AC97, 0x100);
222 if (s3c24xx_ac97.regs == NULL)
223 return -ENXIO;
224
225 s3c24xx_ac97.ac97_clk = clk_get(&pdev->dev, "ac97");
226 if (s3c24xx_ac97.ac97_clk == NULL) {
227 printk(KERN_ERR "s3c2443-ac97 failed to get ac97_clock\n");
228 iounmap(s3c24xx_ac97.regs);
229 return -ENODEV;
230 }
231 clk_enable(s3c24xx_ac97.ac97_clk);
232
233 s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2443_GPE0_AC_nRESET);
234 s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2443_GPE1_AC_SYNC);
235 s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2443_GPE2_AC_BITCLK);
236 s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2443_GPE3_AC_SDI);
237 s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2443_GPE4_AC_SDO);
238
239 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
240 ac_glbctrl = S3C_AC97_GLBCTRL_COLDRESET;
241 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
242 msleep(1);
243
244 ac_glbctrl = 0;
245 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
246 msleep(1);
247
248 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
249 ac_glbctrl = S3C_AC97_GLBCTRL_ACLINKON;
250 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
251 msleep(1);
252
253 ac_glbctrl |= S3C_AC97_GLBCTRL_TRANSFERDATAENABLE;
254 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
255
256 ret = request_irq(IRQ_S3C2443_AC97, s3c2443_ac97_irq,
257 IRQF_DISABLED, "AC97", NULL);
258 if (ret < 0) {
259 printk(KERN_ERR "s3c24xx-ac97: interrupt request failed.\n");
260 clk_disable(s3c24xx_ac97.ac97_clk);
261 clk_put(s3c24xx_ac97.ac97_clk);
262 iounmap(s3c24xx_ac97.regs);
263 }
264 return ret;
265}
266
267static void s3c2443_ac97_remove(struct platform_device *pdev)
268{
269 free_irq(IRQ_S3C2443_AC97, NULL);
270 clk_disable(s3c24xx_ac97.ac97_clk);
271 clk_put(s3c24xx_ac97.ac97_clk);
272 iounmap(s3c24xx_ac97.regs);
273}
274
275static int s3c2443_ac97_hw_params(struct snd_pcm_substream *substream,
276 struct snd_pcm_hw_params *params)
277{
278 struct snd_soc_pcm_runtime *rtd = substream->private_data;
279 struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
280
281 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
282 cpu_dai->dma_data = &s3c2443_ac97_pcm_stereo_out;
283 else
284 cpu_dai->dma_data = &s3c2443_ac97_pcm_stereo_in;
285
286 return 0;
287}
288
289static int s3c2443_ac97_trigger(struct snd_pcm_substream *substream, int cmd)
290{
291 u32 ac_glbctrl;
292
293 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
294 switch(cmd) {
295 case SNDRV_PCM_TRIGGER_START:
296 case SNDRV_PCM_TRIGGER_RESUME:
297 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
298 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
299 ac_glbctrl |= S3C_AC97_GLBCTRL_PCMINTM_DMA;
300 else
301 ac_glbctrl |= S3C_AC97_GLBCTRL_PCMOUTTM_DMA;
302 break;
303 case SNDRV_PCM_TRIGGER_STOP:
304 case SNDRV_PCM_TRIGGER_SUSPEND:
305 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
306 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
307 ac_glbctrl &= ~S3C_AC97_GLBCTRL_PCMINTM_MASK;
308 else
309 ac_glbctrl &= ~S3C_AC97_GLBCTRL_PCMOUTTM_MASK;
310 break;
311 }
312 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
313
314 return 0;
315}
316
317static int s3c2443_ac97_hw_mic_params(struct snd_pcm_substream *substream,
318 struct snd_pcm_hw_params *params)
319{
320 struct snd_soc_pcm_runtime *rtd = substream->private_data;
321 struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
322
323 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
324 return -ENODEV;
325 else
326 cpu_dai->dma_data = &s3c2443_ac97_mic_mono_in;
327
328 return 0;
329}
330
331static int s3c2443_ac97_mic_trigger(struct snd_pcm_substream *substream,
332 int cmd)
333{
334 u32 ac_glbctrl;
335
336 ac_glbctrl = readl(s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
337 switch(cmd) {
338 case SNDRV_PCM_TRIGGER_START:
339 case SNDRV_PCM_TRIGGER_RESUME:
340 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
341 ac_glbctrl |= S3C_AC97_GLBCTRL_PCMINTM_DMA;
342 break;
343 case SNDRV_PCM_TRIGGER_STOP:
344 case SNDRV_PCM_TRIGGER_SUSPEND:
345 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
346 ac_glbctrl &= ~S3C_AC97_GLBCTRL_PCMINTM_MASK;
347 }
348 writel(ac_glbctrl, s3c24xx_ac97.regs + S3C_AC97_GLBCTRL);
349
350 return 0;
351}
352
353#define s3c2443_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
354 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
355 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
356
357struct snd_soc_cpu_dai s3c2443_ac97_dai[] = {
358{
359 .name = "s3c2443-ac97",
360 .id = 0,
361 .type = SND_SOC_DAI_AC97,
362 .probe = s3c2443_ac97_probe,
363 .remove = s3c2443_ac97_remove,
364 .playback = {
365 .stream_name = "AC97 Playback",
366 .channels_min = 2,
367 .channels_max = 2,
368 .rates = s3c2443_AC97_RATES,
369 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
370 .capture = {
371 .stream_name = "AC97 Capture",
372 .channels_min = 2,
373 .channels_max = 2,
374 .rates = s3c2443_AC97_RATES,
375 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
376 .ops = {
377 .hw_params = s3c2443_ac97_hw_params,
378 .trigger = s3c2443_ac97_trigger},
379},
380{
381 .name = "pxa2xx-ac97-mic",
382 .id = 1,
383 .type = SND_SOC_DAI_AC97,
384 .capture = {
385 .stream_name = "AC97 Mic Capture",
386 .channels_min = 1,
387 .channels_max = 1,
388 .rates = s3c2443_AC97_RATES,
389 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
390 .ops = {
391 .hw_params = s3c2443_ac97_hw_mic_params,
392 .trigger = s3c2443_ac97_mic_trigger,},
393},
394};
395
396EXPORT_SYMBOL_GPL(s3c2443_ac97_dai);
397EXPORT_SYMBOL_GPL(soc_ac97_ops);
398
399MODULE_AUTHOR("Graeme Gregory");
400MODULE_DESCRIPTION("AC97 driver for the Samsung s3c2443 chip");
401MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c24xx-ac97.h b/sound/soc/s3c24xx/s3c24xx-ac97.h
new file mode 100644
index 00000000000..2b835e8260f
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-ac97.h
@@ -0,0 +1,25 @@
1/*
2 * s3c24xx-ac97.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2007 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 10th Nov 2006 Initial version.
15 */
16
17#ifndef S3C24XXAC97_H_
18#define S3C24XXAC97_H_
19
20#define AC_CMD_ADDR(x) (x << 16)
21#define AC_CMD_DATA(x) (x & 0xffff)
22
23extern struct snd_soc_cpu_dai s3c2443_ac97_dai[];
24
25#endif /*S3C24XXAC97_H_*/
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
new file mode 100644
index 00000000000..39f02462e07
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -0,0 +1,441 @@
1/*
2 * s3c24xx-i2s.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 *
7 * (c) 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 *
17 * Revision history
18 * 11th Dec 2006 Merged with Simtec driver
19 * 10th Nov 2006 Initial version.
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/device.h>
25#include <linux/delay.h>
26#include <linux/clk.h>
27#include <sound/driver.h>
28#include <sound/core.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31#include <sound/initval.h>
32#include <sound/soc.h>
33
34#include <asm/hardware.h>
35#include <asm/io.h>
36#include <asm/arch/regs-iis.h>
37#include <asm/arch/regs-gpio.h>
38#include <asm/arch/regs-clock.h>
39#include <asm/arch/audio.h>
40#include <asm/dma.h>
41#include <asm/arch/dma.h>
42
43#include "s3c24xx-pcm.h"
44#include "s3c24xx-i2s.h"
45
46#define S3C24XX_I2S_DEBUG 0
47#if S3C24XX_I2S_DEBUG
48#define DBG(x...) printk(KERN_DEBUG x)
49#else
50#define DBG(x...)
51#endif
52
53static struct s3c2410_dma_client s3c24xx_dma_client_out = {
54 .name = "I2S PCM Stereo out"
55};
56
57static struct s3c2410_dma_client s3c24xx_dma_client_in = {
58 .name = "I2S PCM Stereo in"
59};
60
61static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_out = {
62 .client = &s3c24xx_dma_client_out,
63 .channel = DMACH_I2S_OUT,
64 .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
65 .dma_size = 2,
66};
67
68static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_in = {
69 .client = &s3c24xx_dma_client_in,
70 .channel = DMACH_I2S_IN,
71 .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
72 .dma_size = 2,
73};
74
75struct s3c24xx_i2s_info {
76 void __iomem *regs;
77 struct clk *iis_clk;
78};
79static struct s3c24xx_i2s_info s3c24xx_i2s;
80
81static void s3c24xx_snd_txctrl(int on)
82{
83 u32 iisfcon;
84 u32 iiscon;
85 u32 iismod;
86
87 DBG("Entered %s\n", __FUNCTION__);
88
89 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
90 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
91 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
92
93 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
94
95 if (on) {
96 iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE;
97 iiscon |= S3C2410_IISCON_TXDMAEN | S3C2410_IISCON_IISEN;
98 iiscon &= ~S3C2410_IISCON_TXIDLE;
99 iismod |= S3C2410_IISMOD_TXMODE;
100
101 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
102 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
103 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
104 } else {
105 /* note, we have to disable the FIFOs otherwise bad things
106 * seem to happen when the DMA stops. According to the
107 * Samsung supplied kernel, this should allow the DMA
108 * engine and FIFOs to reset. If this isn't allowed, the
109 * DMA engine will simply freeze randomly.
110 */
111
112 iisfcon &= ~S3C2410_IISFCON_TXENABLE;
113 iisfcon &= ~S3C2410_IISFCON_TXDMA;
114 iiscon |= S3C2410_IISCON_TXIDLE;
115 iiscon &= ~S3C2410_IISCON_TXDMAEN;
116 iismod &= ~S3C2410_IISMOD_TXMODE;
117
118 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
119 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
120 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
121 }
122
123 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
124}
125
126static void s3c24xx_snd_rxctrl(int on)
127{
128 u32 iisfcon;
129 u32 iiscon;
130 u32 iismod;
131
132 DBG("Entered %s\n", __FUNCTION__);
133
134 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
135 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
136 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
137
138 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
139
140 if (on) {
141 iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE;
142 iiscon |= S3C2410_IISCON_RXDMAEN | S3C2410_IISCON_IISEN;
143 iiscon &= ~S3C2410_IISCON_RXIDLE;
144 iismod |= S3C2410_IISMOD_RXMODE;
145
146 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
147 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
148 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
149 } else {
150 /* note, we have to disable the FIFOs otherwise bad things
151 * seem to happen when the DMA stops. According to the
152 * Samsung supplied kernel, this should allow the DMA
153 * engine and FIFOs to reset. If this isn't allowed, the
154 * DMA engine will simply freeze randomly.
155 */
156
157 iisfcon &= ~S3C2410_IISFCON_RXENABLE;
158 iisfcon &= ~S3C2410_IISFCON_RXDMA;
159 iiscon |= S3C2410_IISCON_RXIDLE;
160 iiscon &= ~S3C2410_IISCON_RXDMAEN;
161 iismod &= ~S3C2410_IISMOD_RXMODE;
162
163 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
164 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
165 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
166 }
167
168 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
169}
170
171/*
172 * Wait for the LR signal to allow synchronisation to the L/R clock
173 * from the codec. May only be needed for slave mode.
174 */
175static int s3c24xx_snd_lrsync(void)
176{
177 u32 iiscon;
178 unsigned long timeout = jiffies + msecs_to_jiffies(5);
179
180 DBG("Entered %s\n", __FUNCTION__);
181
182 while (1) {
183 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
184 if (iiscon & S3C2410_IISCON_LRINDEX)
185 break;
186
187 if (timeout < jiffies)
188 return -ETIMEDOUT;
189 }
190
191 return 0;
192}
193
194/*
195 * Check whether CPU is the master or slave
196 */
197static inline int s3c24xx_snd_is_clkmaster(void)
198{
199 DBG("Entered %s\n", __FUNCTION__);
200
201 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1;
202}
203
204/*
205 * Set S3C24xx I2S DAI format
206 */
207static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai,
208 unsigned int fmt)
209{
210 u32 iismod;
211
212 DBG("Entered %s\n", __FUNCTION__);
213
214 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
215 DBG("hw_params r: IISMOD: %lx \n", iismod);
216
217 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
218 case SND_SOC_DAIFMT_CBM_CFM:
219 iismod |= S3C2410_IISMOD_SLAVE;
220 break;
221 case SND_SOC_DAIFMT_CBS_CFS:
222 break;
223 default:
224 return -EINVAL;
225 }
226
227 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
228 case SND_SOC_DAIFMT_LEFT_J:
229 iismod |= S3C2410_IISMOD_MSB;
230 break;
231 case SND_SOC_DAIFMT_I2S:
232 break;
233 default:
234 return -EINVAL;
235 }
236
237 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
238 DBG("hw_params w: IISMOD: %lx \n", iismod);
239 return 0;
240}
241
242static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
243 struct snd_pcm_hw_params *params)
244{
245 struct snd_soc_pcm_runtime *rtd = substream->private_data;
246 u32 iismod;
247
248 DBG("Entered %s\n", __FUNCTION__);
249
250 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
251 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out;
252 else
253 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in;
254
255 /* Working copies of register */
256 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
257 DBG("hw_params r: IISMOD: %lx\n", iismod);
258
259 switch (params_format(params)) {
260 case SNDRV_PCM_FORMAT_S8:
261 break;
262 case SNDRV_PCM_FORMAT_S16_LE:
263 iismod |= S3C2410_IISMOD_16BIT;
264 break;
265 }
266
267 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
268 DBG("hw_params w: IISMOD: %lx\n", iismod);
269 return 0;
270}
271
272static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd)
273{
274 int ret = 0;
275
276 DBG("Entered %s\n", __FUNCTION__);
277
278 switch (cmd) {
279 case SNDRV_PCM_TRIGGER_START:
280 case SNDRV_PCM_TRIGGER_RESUME:
281 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
282 if (!s3c24xx_snd_is_clkmaster()) {
283 ret = s3c24xx_snd_lrsync();
284 if (ret)
285 goto exit_err;
286 }
287
288 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
289 s3c24xx_snd_rxctrl(1);
290 else
291 s3c24xx_snd_txctrl(1);
292 break;
293 case SNDRV_PCM_TRIGGER_STOP:
294 case SNDRV_PCM_TRIGGER_SUSPEND:
295 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
296 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
297 s3c24xx_snd_rxctrl(0);
298 else
299 s3c24xx_snd_txctrl(0);
300 break;
301 default:
302 ret = -EINVAL;
303 break;
304 }
305
306exit_err:
307 return ret;
308}
309
310/*
311 * Set S3C24xx Clock source
312 */
313static int s3c24xx_i2s_set_sysclk(struct snd_soc_cpu_dai *cpu_dai,
314 int clk_id, unsigned int freq, int dir)
315{
316 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
317
318 DBG("Entered %s\n", __FUNCTION__);
319
320 iismod &= ~S3C2440_IISMOD_MPLL;
321
322 switch (clk_id) {
323 case S3C24XX_CLKSRC_PCLK:
324 break;
325 case S3C24XX_CLKSRC_MPLL:
326 iismod |= S3C2440_IISMOD_MPLL;
327 break;
328 default:
329 return -EINVAL;
330 }
331
332 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
333 return 0;
334}
335
336/*
337 * Set S3C24xx Clock dividers
338 */
339static int s3c24xx_i2s_set_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
340 int div_id, int div)
341{
342 u32 reg;
343
344 DBG("Entered %s\n", __FUNCTION__);
345
346 switch (div_id) {
347 case S3C24XX_DIV_BCLK:
348 reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~S3C2410_IISMOD_FS_MASK;
349 writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD);
350 break;
351 case S3C24XX_DIV_MCLK:
352 reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~(S3C2410_IISMOD_384FS);
353 writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD);
354 break;
355 case S3C24XX_DIV_PRESCALER:
356 writel(div, s3c24xx_i2s.regs + S3C2410_IISPSR);
357 reg = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
358 writel(reg | S3C2410_IISCON_PSCEN, s3c24xx_i2s.regs + S3C2410_IISCON);
359 break;
360 default:
361 return -EINVAL;
362 }
363
364 return 0;
365}
366
367/*
368 * To avoid duplicating clock code, allow machine driver to
369 * get the clockrate from here.
370 */
371u32 s3c24xx_i2s_get_clockrate(void)
372{
373 return clk_get_rate(s3c24xx_i2s.iis_clk);
374}
375EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate);
376
377static int s3c24xx_i2s_probe(struct platform_device *pdev)
378{
379 DBG("Entered %s\n", __FUNCTION__);
380
381 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100);
382 if (s3c24xx_i2s.regs == NULL)
383 return -ENXIO;
384
385 s3c24xx_i2s.iis_clk=clk_get(&pdev->dev, "iis");
386 if (s3c24xx_i2s.iis_clk == NULL) {
387 DBG("failed to get iis_clock\n");
388 return -ENODEV;
389 }
390 clk_enable(s3c24xx_i2s.iis_clk);
391
392 /* Configure the I2S pins in correct mode */
393 s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK);
394 s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK);
395 s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK);
396 s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI);
397 s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO);
398
399 writel(S3C2410_IISCON_IISEN, s3c24xx_i2s.regs + S3C2410_IISCON);
400
401 s3c24xx_snd_txctrl(0);
402 s3c24xx_snd_rxctrl(0);
403
404 return 0;
405}
406
407#define S3C24XX_I2S_RATES \
408 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
409 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
410 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
411
412struct snd_soc_cpu_dai s3c24xx_i2s_dai = {
413 .name = "s3c24xx-i2s",
414 .id = 0,
415 .type = SND_SOC_DAI_I2S,
416 .probe = s3c24xx_i2s_probe,
417 .playback = {
418 .channels_min = 2,
419 .channels_max = 2,
420 .rates = S3C24XX_I2S_RATES,
421 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,},
422 .capture = {
423 .channels_min = 2,
424 .channels_max = 2,
425 .rates = S3C24XX_I2S_RATES,
426 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,},
427 .ops = {
428 .trigger = s3c24xx_i2s_trigger,
429 .hw_params = s3c24xx_i2s_hw_params,},
430 .dai_ops = {
431 .set_fmt = s3c24xx_i2s_set_fmt,
432 .set_clkdiv = s3c24xx_i2s_set_clkdiv,
433 .set_sysclk = s3c24xx_i2s_set_sysclk,
434 },
435};
436EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai);
437
438/* Module information */
439MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
440MODULE_DESCRIPTION("s3c24xx I2S SoC Interface");
441MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.h b/sound/soc/s3c24xx/s3c24xx-i2s.h
new file mode 100644
index 00000000000..537b4ecce8a
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.h
@@ -0,0 +1,37 @@
1/*
2 * s3c24xx-i2s.c -- ALSA Soc Audio Layer
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 10th Nov 2006 Initial version.
15 */
16
17#ifndef S3C24XXI2S_H_
18#define S3C24XXI2S_H_
19
20/* clock sources */
21#define S3C24XX_CLKSRC_PCLK 0
22#define S3C24XX_CLKSRC_MPLL 1
23
24/* Clock dividers */
25#define S3C24XX_DIV_MCLK 0
26#define S3C24XX_DIV_BCLK 1
27#define S3C24XX_DIV_PRESCALER 2
28
29/* prescaler */
30#define S3C24XX_PRESCALE(a,b) \
31 (((a - 1) << S3C2410_IISPSR_INTSHIFT) | ((b - 1) << S3C2410_IISPSR_EXTSHFIT))
32
33u32 s3c24xx_i2s_get_clockrate(void);
34
35extern struct snd_soc_cpu_dai s3c24xx_i2s_dai;
36
37#endif /*S3C24XXI2S_H_*/
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
new file mode 100644
index 00000000000..bfbdc3cbd43
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -0,0 +1,470 @@
1/*
2 * s3c24xx-pcm.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 *
7 * (c) 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * Revision history
17 * 11th Dec 2006 Merged with Simtec driver
18 * 10th Nov 2006 Initial version.
19 */
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/slab.h>
25#include <linux/dma-mapping.h>
26
27#include <sound/driver.h>
28#include <sound/core.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31#include <sound/soc.h>
32
33#include <asm/dma.h>
34#include <asm/io.h>
35#include <asm/hardware.h>
36#include <asm/arch/dma.h>
37#include <asm/arch/audio.h>
38
39#include "s3c24xx-pcm.h"
40
41#define S3C24XX_PCM_DEBUG 0
42#if S3C24XX_PCM_DEBUG
43#define DBG(x...) printk(KERN_DEBUG x)
44#else
45#define DBG(x...)
46#endif
47
48static const struct snd_pcm_hardware s3c24xx_pcm_hardware = {
49 .info = SNDRV_PCM_INFO_INTERLEAVED |
50 SNDRV_PCM_INFO_BLOCK_TRANSFER |
51 SNDRV_PCM_INFO_MMAP |
52 SNDRV_PCM_INFO_MMAP_VALID,
53 .formats = SNDRV_PCM_FMTBIT_S16_LE |
54 SNDRV_PCM_FMTBIT_U16_LE |
55 SNDRV_PCM_FMTBIT_U8 |
56 SNDRV_PCM_FMTBIT_S8,
57 .channels_min = 2,
58 .channels_max = 2,
59 .buffer_bytes_max = 128*1024,
60 .period_bytes_min = PAGE_SIZE,
61 .period_bytes_max = PAGE_SIZE*2,
62 .periods_min = 2,
63 .periods_max = 128,
64 .fifo_size = 32,
65};
66
67struct s3c24xx_runtime_data {
68 spinlock_t lock;
69 int state;
70 unsigned int dma_loaded;
71 unsigned int dma_limit;
72 unsigned int dma_period;
73 dma_addr_t dma_start;
74 dma_addr_t dma_pos;
75 dma_addr_t dma_end;
76 struct s3c24xx_pcm_dma_params *params;
77};
78
79/* s3c24xx_pcm_enqueue
80 *
81 * place a dma buffer onto the queue for the dma system
82 * to handle.
83*/
84static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
85{
86 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
87 dma_addr_t pos = prtd->dma_pos;
88 int ret;
89
90 DBG("Entered %s\n", __FUNCTION__);
91
92 while (prtd->dma_loaded < prtd->dma_limit) {
93 unsigned long len = prtd->dma_period;
94
95 DBG("dma_loaded: %d\n",prtd->dma_loaded);
96
97 if ((pos + len) > prtd->dma_end) {
98 len = prtd->dma_end - pos;
99 DBG(KERN_DEBUG "%s: corrected dma len %ld\n",
100 __FUNCTION__, len);
101 }
102
103 ret = s3c2410_dma_enqueue(prtd->params->channel,
104 substream, pos, len);
105
106 if (ret == 0) {
107 prtd->dma_loaded++;
108 pos += prtd->dma_period;
109 if (pos >= prtd->dma_end)
110 pos = prtd->dma_start;
111 } else
112 break;
113 }
114
115 prtd->dma_pos = pos;
116}
117
118static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
119 void *dev_id, int size,
120 enum s3c2410_dma_buffresult result)
121{
122 struct snd_pcm_substream *substream = dev_id;
123 struct s3c24xx_runtime_data *prtd;
124
125 DBG("Entered %s\n", __FUNCTION__);
126
127 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
128 return;
129
130 prtd = substream->runtime->private_data;
131
132 if (substream)
133 snd_pcm_period_elapsed(substream);
134
135 spin_lock(&prtd->lock);
136 if (prtd->state & ST_RUNNING) {
137 prtd->dma_loaded--;
138 s3c24xx_pcm_enqueue(substream);
139 }
140
141 spin_unlock(&prtd->lock);
142}
143
144static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
145 struct snd_pcm_hw_params *params)
146{
147 struct snd_pcm_runtime *runtime = substream->runtime;
148 struct s3c24xx_runtime_data *prtd = runtime->private_data;
149 struct snd_soc_pcm_runtime *rtd = substream->private_data;
150 struct s3c24xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data;
151 unsigned long totbytes = params_buffer_bytes(params);
152 int ret=0;
153
154 DBG("Entered %s\n", __FUNCTION__);
155
156 /* return if this is a bufferless transfer e.g.
157 * codec <--> BT codec or GSM modem -- lg FIXME */
158 if (!dma)
159 return 0;
160
161 /* prepare DMA */
162 prtd->params = dma;
163
164 DBG("params %p, client %p, channel %d\n", prtd->params,
165 prtd->params->client, prtd->params->channel);
166
167 ret = s3c2410_dma_request(prtd->params->channel,
168 prtd->params->client, NULL);
169
170 if (ret) {
171 DBG(KERN_ERR "failed to get dma channel\n");
172 return ret;
173 }
174
175 /* channel needs configuring for mem=>device, increment memory addr,
176 * sync to pclk, half-word transfers to the IIS-FIFO. */
177 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
178 s3c2410_dma_devconfig(prtd->params->channel,
179 S3C2410_DMASRC_MEM, S3C2410_DISRCC_INC |
180 S3C2410_DISRCC_APB, prtd->params->dma_addr);
181
182 s3c2410_dma_config(prtd->params->channel,
183 prtd->params->dma_size,
184 S3C2410_DCON_SYNC_PCLK |
185 S3C2410_DCON_HANDSHAKE);
186 } else {
187 s3c2410_dma_config(prtd->params->channel,
188 prtd->params->dma_size,
189 S3C2410_DCON_HANDSHAKE |
190 S3C2410_DCON_SYNC_PCLK);
191
192 s3c2410_dma_devconfig(prtd->params->channel,
193 S3C2410_DMASRC_HW, 0x3,
194 prtd->params->dma_addr);
195 }
196
197 s3c2410_dma_set_buffdone_fn(prtd->params->channel,
198 s3c24xx_audio_buffdone);
199
200 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
201
202 runtime->dma_bytes = totbytes;
203
204 spin_lock_irq(&prtd->lock);
205 prtd->dma_loaded = 0;
206 prtd->dma_limit = runtime->hw.periods_min;
207 prtd->dma_period = params_period_bytes(params);
208 prtd->dma_start = runtime->dma_addr;
209 prtd->dma_pos = prtd->dma_start;
210 prtd->dma_end = prtd->dma_start + totbytes;
211 spin_unlock_irq(&prtd->lock);
212
213 return 0;
214}
215
216static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
217{
218 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
219
220 DBG("Entered %s\n", __FUNCTION__);
221
222 /* TODO - do we need to ensure DMA flushed */
223 snd_pcm_set_runtime_buffer(substream, NULL);
224
225 if (prtd->params) {
226 s3c2410_dma_free(prtd->params->channel, prtd->params->client);
227 prtd->params = NULL;
228 }
229
230 return 0;
231}
232
233static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
234{
235 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
236 int ret = 0;
237
238 DBG("Entered %s\n", __FUNCTION__);
239
240 /* return if this is a bufferless transfer e.g.
241 * codec <--> BT codec or GSM modem -- lg FIXME */
242 if (!prtd->params)
243 return 0;
244
245 /* flush the DMA channel */
246 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_FLUSH);
247 prtd->dma_loaded = 0;
248 prtd->dma_pos = prtd->dma_start;
249
250 /* enqueue dma buffers */
251 s3c24xx_pcm_enqueue(substream);
252
253 return ret;
254}
255
256static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
257{
258 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
259 int ret = 0;
260
261 DBG("Entered %s\n", __FUNCTION__);
262
263 spin_lock(&prtd->lock);
264
265 switch (cmd) {
266 case SNDRV_PCM_TRIGGER_START:
267 case SNDRV_PCM_TRIGGER_RESUME:
268 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
269 prtd->state |= ST_RUNNING;
270 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_START);
271 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STARTED);
272 break;
273
274 case SNDRV_PCM_TRIGGER_STOP:
275 case SNDRV_PCM_TRIGGER_SUSPEND:
276 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
277 prtd->state &= ~ST_RUNNING;
278 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STOP);
279 break;
280
281 default:
282 ret = -EINVAL;
283 break;
284 }
285
286 spin_unlock(&prtd->lock);
287
288 return ret;
289}
290
291static snd_pcm_uframes_t
292 s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
293{
294 struct snd_pcm_runtime *runtime = substream->runtime;
295 struct s3c24xx_runtime_data *prtd = runtime->private_data;
296 unsigned long res;
297 dma_addr_t src, dst;
298
299 DBG("Entered %s\n", __FUNCTION__);
300
301 spin_lock(&prtd->lock);
302 s3c2410_dma_getposition(prtd->params->channel, &src, &dst);
303
304 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
305 res = dst - prtd->dma_start;
306 else
307 res = src - prtd->dma_start;
308
309 spin_unlock(&prtd->lock);
310
311 DBG("Pointer %x %x\n",src,dst);
312
313 /* we seem to be getting the odd error from the pcm library due
314 * to out-of-bounds pointers. this is maybe due to the dma engine
315 * not having loaded the new values for the channel before being
316 * callled... (todo - fix )
317 */
318
319 if (res >= snd_pcm_lib_buffer_bytes(substream)) {
320 if (res == snd_pcm_lib_buffer_bytes(substream))
321 res = 0;
322 }
323
324 return bytes_to_frames(substream->runtime, res);
325}
326
327static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
328{
329 struct snd_pcm_runtime *runtime = substream->runtime;
330 struct s3c24xx_runtime_data *prtd;
331
332 DBG("Entered %s\n", __FUNCTION__);
333
334 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
335
336 prtd = kzalloc(sizeof(struct s3c24xx_runtime_data), GFP_KERNEL);
337 if (prtd == NULL)
338 return -ENOMEM;
339
340 spin_lock_init(&prtd->lock);
341
342 runtime->private_data = prtd;
343 return 0;
344}
345
346static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
347{
348 struct snd_pcm_runtime *runtime = substream->runtime;
349 struct s3c24xx_runtime_data *prtd = runtime->private_data;
350
351 DBG("Entered %s\n", __FUNCTION__);
352
353 if (prtd)
354 kfree(prtd);
355 else
356 DBG("s3c24xx_pcm_close called with prtd == NULL\n");
357
358 return 0;
359}
360
361static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream,
362 struct vm_area_struct *vma)
363{
364 struct snd_pcm_runtime *runtime = substream->runtime;
365
366 DBG("Entered %s\n", __FUNCTION__);
367
368 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
369 runtime->dma_area,
370 runtime->dma_addr,
371 runtime->dma_bytes);
372}
373
374static struct snd_pcm_ops s3c24xx_pcm_ops = {
375 .open = s3c24xx_pcm_open,
376 .close = s3c24xx_pcm_close,
377 .ioctl = snd_pcm_lib_ioctl,
378 .hw_params = s3c24xx_pcm_hw_params,
379 .hw_free = s3c24xx_pcm_hw_free,
380 .prepare = s3c24xx_pcm_prepare,
381 .trigger = s3c24xx_pcm_trigger,
382 .pointer = s3c24xx_pcm_pointer,
383 .mmap = s3c24xx_pcm_mmap,
384};
385
386static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
387{
388 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
389 struct snd_dma_buffer *buf = &substream->dma_buffer;
390 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max;
391
392 DBG("Entered %s\n", __FUNCTION__);
393
394 buf->dev.type = SNDRV_DMA_TYPE_DEV;
395 buf->dev.dev = pcm->card->dev;
396 buf->private_data = NULL;
397 buf->area = dma_alloc_writecombine(pcm->card->dev, size,
398 &buf->addr, GFP_KERNEL);
399 if (!buf->area)
400 return -ENOMEM;
401 buf->bytes = size;
402 return 0;
403}
404
405static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
406{
407 struct snd_pcm_substream *substream;
408 struct snd_dma_buffer *buf;
409 int stream;
410
411 DBG("Entered %s\n", __FUNCTION__);
412
413 for (stream = 0; stream < 2; stream++) {
414 substream = pcm->streams[stream].substream;
415 if (!substream)
416 continue;
417
418 buf = &substream->dma_buffer;
419 if (!buf->area)
420 continue;
421
422 dma_free_writecombine(pcm->card->dev, buf->bytes,
423 buf->area, buf->addr);
424 buf->area = NULL;
425 }
426}
427
428static u64 s3c24xx_pcm_dmamask = DMA_32BIT_MASK;
429
430static int s3c24xx_pcm_new(struct snd_card *card,
431 struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
432{
433 int ret = 0;
434
435 DBG("Entered %s\n", __FUNCTION__);
436
437 if (!card->dev->dma_mask)
438 card->dev->dma_mask = &s3c24xx_pcm_dmamask;
439 if (!card->dev->coherent_dma_mask)
440 card->dev->coherent_dma_mask = 0xffffffff;
441
442 if (dai->playback.channels_min) {
443 ret = s3c24xx_pcm_preallocate_dma_buffer(pcm,
444 SNDRV_PCM_STREAM_PLAYBACK);
445 if (ret)
446 goto out;
447 }
448
449 if (dai->capture.channels_min) {
450 ret = s3c24xx_pcm_preallocate_dma_buffer(pcm,
451 SNDRV_PCM_STREAM_CAPTURE);
452 if (ret)
453 goto out;
454 }
455 out:
456 return ret;
457}
458
459struct snd_soc_platform s3c24xx_soc_platform = {
460 .name = "s3c24xx-audio",
461 .pcm_ops = &s3c24xx_pcm_ops,
462 .pcm_new = s3c24xx_pcm_new,
463 .pcm_free = s3c24xx_pcm_free_dma_buffers,
464};
465
466EXPORT_SYMBOL_GPL(s3c24xx_soc_platform);
467
468MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
469MODULE_DESCRIPTION("Samsung S3C24XX PCM DMA module");
470MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.h b/sound/soc/s3c24xx/s3c24xx-pcm.h
new file mode 100644
index 00000000000..0088c79822e
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.h
@@ -0,0 +1,31 @@
1/*
2 * s3c24xx-pcm.h --
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * ALSA PCM interface for the Samsung S3C24xx CPU
10 */
11
12#ifndef _S3C24XX_PCM_H
13#define _S3C24XX_PCM_H
14
15#define ST_RUNNING (1<<0)
16#define ST_OPENED (1<<1)
17
18struct s3c24xx_pcm_dma_params {
19 struct s3c2410_dma_client *client; /* stream identifier */
20 int channel; /* Channel ID */
21 dma_addr_t dma_addr;
22 int dma_size; /* Size of the DMA transfer */
23};
24
25#define S3C24XX_DAI_I2S 0
26
27/* platform data */
28extern struct snd_soc_platform s3c24xx_soc_platform;
29extern struct snd_ac97_bus_ops s3c24xx_ac97_ops;
30
31#endif
diff --git a/sound/soc/s3c24xx/smdk2443_wm9710.c b/sound/soc/s3c24xx/smdk2443_wm9710.c
new file mode 100644
index 00000000000..d46cd811ceb
--- /dev/null
+++ b/sound/soc/s3c24xx/smdk2443_wm9710.c
@@ -0,0 +1,85 @@
1/*
2 * smdk2443_wm9710.c -- SoC audio for smdk2443
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 8th Mar 2007 Initial version.
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/device.h>
20#include <sound/driver.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/soc.h>
24#include <sound/soc-dapm.h>
25
26#include "../codecs/ac97.h"
27#include "s3c24xx-pcm.h"
28#include "s3c24xx-ac97.h"
29
30static struct snd_soc_machine smdk2443;
31
32static struct snd_soc_dai_link smdk2443_dai[] = {
33{
34 .name = "AC97",
35 .stream_name = "AC97 HiFi",
36 .cpu_dai = &s3c2443_ac97_dai[0],
37 .codec_dai = &ac97_dai,
38},
39};
40
41static struct snd_soc_machine smdk2443 = {
42 .name = "SMDK2443",
43 .dai_link = smdk2443_dai,
44 .num_links = ARRAY_SIZE(smdk2443_dai),
45};
46
47static struct snd_soc_device smdk2443_snd_ac97_devdata = {
48 .machine = &smdk2443,
49 .platform = &s3c24xx_soc_platform,
50 .codec_dev = &soc_codec_dev_ac97,
51};
52
53static struct platform_device *smdk2443_snd_ac97_device;
54
55static int __init smdk2443_init(void)
56{
57 int ret;
58
59 smdk2443_snd_ac97_device = platform_device_alloc("soc-audio", -1);
60 if (!smdk2443_snd_ac97_device)
61 return -ENOMEM;
62
63 platform_set_drvdata(smdk2443_snd_ac97_device,
64 &smdk2443_snd_ac97_devdata);
65 smdk2443_snd_ac97_devdata.dev = &smdk2443_snd_ac97_device->dev;
66 ret = platform_device_add(smdk2443_snd_ac97_device);
67
68 if (ret)
69 platform_device_put(smdk2443_snd_ac97_device);
70
71 return ret;
72}
73
74static void __exit smdk2443_exit(void)
75{
76 platform_device_unregister(smdk2443_snd_ac97_device);
77}
78
79module_init(smdk2443_init);
80module_exit(smdk2443_exit);
81
82/* Module information */
83MODULE_AUTHOR("Graeme Gregory, graeme.gregory@wolfsonmicro.com, www.wolfsonmicro.com");
84MODULE_DESCRIPTION("ALSA SoC WM9710 SMDK2443");
85MODULE_LICENSE("GPL");
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig
new file mode 100644
index 00000000000..f03220d23e7
--- /dev/null
+++ b/sound/soc/sh/Kconfig
@@ -0,0 +1,38 @@
1menu "SoC Audio support for SuperH"
2
3config SND_SOC_PCM_SH7760
4 tristate "SoC Audio support for Renesas SH7760"
5 depends on CPU_SUBTYPE_SH7760 && SND_SOC && SH_DMABRG
6 help
7 Enable this option for SH7760 AC97/I2S audio support.
8
9
10##
11## Audio unit modules
12##
13
14config SND_SOC_SH4_HAC
15 select AC97_BUS
16 select SND_SOC_AC97_BUS
17 select SND_AC97_CODEC
18 tristate
19
20config SND_SOC_SH4_SSI
21 tristate
22
23
24
25##
26## Boards
27##
28
29config SND_SH7760_AC97
30 tristate "SH7760 AC97 sound support"
31 depends on CPU_SUBTYPE_SH7760 && SND_SOC_PCM_SH7760
32 select SND_SOC_SH4_HAC
33 select SND_SOC_AC97_CODEC
34 help
35 This option enables generic sound support for the first
36 AC97 unit of the SH7760.
37
38endmenu
diff --git a/sound/soc/sh/Makefile b/sound/soc/sh/Makefile
new file mode 100644
index 00000000000..a8e8ab81cc6
--- /dev/null
+++ b/sound/soc/sh/Makefile
@@ -0,0 +1,14 @@
1## DMA engines
2snd-soc-dma-sh7760-objs := dma-sh7760.o
3obj-$(CONFIG_SND_SOC_PCM_SH7760) += snd-soc-dma-sh7760.o
4
5## audio units found on some SH-4
6snd-soc-hac-objs := hac.o
7snd-soc-ssi-objs := ssi.o
8obj-$(CONFIG_SND_SOC_SH4_HAC) += snd-soc-hac.o
9obj-$(CONFIG_SND_SOC_SH4_SSI) += snd-soc-ssi.o
10
11## boards
12snd-soc-sh7760-ac97-objs := sh7760-ac97.o
13
14obj-$(CONFIG_SND_SH7760_AC97) += snd-soc-sh7760-ac97.o
diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
new file mode 100644
index 00000000000..cdee374b843
--- /dev/null
+++ b/sound/soc/sh/dma-sh7760.c
@@ -0,0 +1,354 @@
1/*
2 * SH7760 ("camelot") DMABRG audio DMA unit support
3 *
4 * Copyright (C) 2007 Manuel Lauss <mano@roarinelk.homelinux.net>
5 * licensed under the terms outlined in the file COPYING at the root
6 * of the linux kernel sources.
7 *
8 * The SH7760 DMABRG provides 4 dma channels (2x rec, 2x play), which
9 * trigger an interrupt when one half of the programmed transfer size
10 * has been xmitted.
11 *
12 * FIXME: little-endian only for now
13 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h>
19#include <sound/driver.h>
20#include <sound/core.h>
21#include <sound/pcm.h>
22#include <sound/pcm_params.h>
23#include <sound/soc.h>
24#include <asm/dmabrg.h>
25
26
27/* registers and bits */
28#define BRGATXSAR 0x00
29#define BRGARXDAR 0x04
30#define BRGATXTCR 0x08
31#define BRGARXTCR 0x0C
32#define BRGACR 0x10
33#define BRGATXTCNT 0x14
34#define BRGARXTCNT 0x18
35
36#define ACR_RAR (1 << 18)
37#define ACR_RDS (1 << 17)
38#define ACR_RDE (1 << 16)
39#define ACR_TAR (1 << 2)
40#define ACR_TDS (1 << 1)
41#define ACR_TDE (1 << 0)
42
43/* receiver/transmitter data alignment */
44#define ACR_RAM_NONE (0 << 24)
45#define ACR_RAM_4BYTE (1 << 24)
46#define ACR_RAM_2WORD (2 << 24)
47#define ACR_TAM_NONE (0 << 8)
48#define ACR_TAM_4BYTE (1 << 8)
49#define ACR_TAM_2WORD (2 << 8)
50
51
52struct camelot_pcm {
53 unsigned long mmio; /* DMABRG audio channel control reg MMIO */
54 unsigned int txid; /* ID of first DMABRG IRQ for this unit */
55
56 struct snd_pcm_substream *tx_ss;
57 unsigned long tx_period_size;
58 unsigned int tx_period;
59
60 struct snd_pcm_substream *rx_ss;
61 unsigned long rx_period_size;
62 unsigned int rx_period;
63
64} cam_pcm_data[2] = {
65 {
66 .mmio = 0xFE3C0040,
67 .txid = DMABRGIRQ_A0TXF,
68 },
69 {
70 .mmio = 0xFE3C0060,
71 .txid = DMABRGIRQ_A1TXF,
72 },
73};
74
75#define BRGREG(x) (*(unsigned long *)(cam->mmio + (x)))
76
77/*
78 * set a minimum of 16kb per period, to avoid interrupt-"storm" and
79 * resulting skipping. In general, the bigger the minimum size, the
80 * better for overall system performance. (The SH7760 is a puny CPU
81 * with a slow SDRAM interface and poor internal bus bandwidth,
82 * *especially* when the LCDC is active). The minimum for the DMAC
83 * is 8 bytes; 16kbytes are enough to get skip-free playback of a
84 * 44kHz/16bit/stereo MP3 on a lightly loaded system, and maintain
85 * reasonable responsiveness in MPlayer.
86 */
87#define DMABRG_PERIOD_MIN 16 * 1024
88#define DMABRG_PERIOD_MAX 0x03fffffc
89#define DMABRG_PREALLOC_BUFFER 32 * 1024
90#define DMABRG_PREALLOC_BUFFER_MAX 32 * 1024
91
92/* support everything the SSI supports */
93#define DMABRG_RATES \
94 SNDRV_PCM_RATE_8000_192000
95
96#define DMABRG_FMTS \
97 (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \
98 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \
99 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE | \
100 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3LE | \
101 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE)
102
103static struct snd_pcm_hardware camelot_pcm_hardware = {
104 .info = (SNDRV_PCM_INFO_MMAP |
105 SNDRV_PCM_INFO_INTERLEAVED |
106 SNDRV_PCM_INFO_BLOCK_TRANSFER |
107 SNDRV_PCM_INFO_MMAP_VALID),
108 .formats = DMABRG_FMTS,
109 .rates = DMABRG_RATES,
110 .rate_min = 8000,
111 .rate_max = 192000,
112 .channels_min = 2,
113 .channels_max = 8, /* max of the SSI */
114 .buffer_bytes_max = DMABRG_PERIOD_MAX,
115 .period_bytes_min = DMABRG_PERIOD_MIN,
116 .period_bytes_max = DMABRG_PERIOD_MAX / 2,
117 .periods_min = 2,
118 .periods_max = 2,
119 .fifo_size = 128,
120};
121
122static void camelot_txdma(void *data)
123{
124 struct camelot_pcm *cam = data;
125 cam->tx_period ^= 1;
126 snd_pcm_period_elapsed(cam->tx_ss);
127}
128
129static void camelot_rxdma(void *data)
130{
131 struct camelot_pcm *cam = data;
132 cam->rx_period ^= 1;
133 snd_pcm_period_elapsed(cam->rx_ss);
134}
135
136static int camelot_pcm_open(struct snd_pcm_substream *substream)
137{
138 struct snd_soc_pcm_runtime *rtd = substream->private_data;
139 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
140 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
141 int ret, dmairq;
142
143 snd_soc_set_runtime_hwparams(substream, &camelot_pcm_hardware);
144
145 /* DMABRG buffer half/full events */
146 dmairq = (recv) ? cam->txid + 2 : cam->txid;
147 if (recv) {
148 cam->rx_ss = substream;
149 ret = dmabrg_request_irq(dmairq, camelot_rxdma, cam);
150 if (unlikely(ret)) {
151 pr_debug("audio unit %d irqs already taken!\n",
152 rtd->dai->cpu_dai->id);
153 return -EBUSY;
154 }
155 (void)dmabrg_request_irq(dmairq + 1,camelot_rxdma, cam);
156 } else {
157 cam->tx_ss = substream;
158 ret = dmabrg_request_irq(dmairq, camelot_txdma, cam);
159 if (unlikely(ret)) {
160 pr_debug("audio unit %d irqs already taken!\n",
161 rtd->dai->cpu_dai->id);
162 return -EBUSY;
163 }
164 (void)dmabrg_request_irq(dmairq + 1, camelot_txdma, cam);
165 }
166 return 0;
167}
168
169static int camelot_pcm_close(struct snd_pcm_substream *substream)
170{
171 struct snd_soc_pcm_runtime *rtd = substream->private_data;
172 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
173 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
174 int dmairq;
175
176 dmairq = (recv) ? cam->txid + 2 : cam->txid;
177
178 if (recv)
179 cam->rx_ss = NULL;
180 else
181 cam->tx_ss = NULL;
182
183 dmabrg_free_irq(dmairq + 1);
184 dmabrg_free_irq(dmairq);
185
186 return 0;
187}
188
189static int camelot_hw_params(struct snd_pcm_substream *substream,
190 struct snd_pcm_hw_params *hw_params)
191{
192 struct snd_soc_pcm_runtime *rtd = substream->private_data;
193 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
194 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
195 int ret;
196
197 ret = snd_pcm_lib_malloc_pages(substream,
198 params_buffer_bytes(hw_params));
199 if (ret < 0)
200 return ret;
201
202 if (recv) {
203 cam->rx_period_size = params_period_bytes(hw_params);
204 cam->rx_period = 0;
205 } else {
206 cam->tx_period_size = params_period_bytes(hw_params);
207 cam->tx_period = 0;
208 }
209 return 0;
210}
211
212static int camelot_hw_free(struct snd_pcm_substream *substream)
213{
214 return snd_pcm_lib_free_pages(substream);
215}
216
217static int camelot_prepare(struct snd_pcm_substream *substream)
218{
219 struct snd_pcm_runtime *runtime = substream->runtime;
220 struct snd_soc_pcm_runtime *rtd = substream->private_data;
221 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
222
223 pr_debug("PCM data: addr 0x%08ulx len %d\n",
224 (u32)runtime->dma_addr, runtime->dma_bytes);
225
226 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
227 BRGREG(BRGATXSAR) = (unsigned long)runtime->dma_area;
228 BRGREG(BRGATXTCR) = runtime->dma_bytes;
229 } else {
230 BRGREG(BRGARXDAR) = (unsigned long)runtime->dma_area;
231 BRGREG(BRGARXTCR) = runtime->dma_bytes;
232 }
233
234 return 0;
235}
236
237static inline void dmabrg_play_dma_start(struct camelot_pcm *cam)
238{
239 unsigned long acr = BRGREG(BRGACR) & ~(ACR_TDS | ACR_RDS);
240 /* start DMABRG engine: XFER start, auto-addr-reload */
241 BRGREG(BRGACR) = acr | ACR_TDE | ACR_TAR | ACR_TAM_2WORD;
242}
243
244static inline void dmabrg_play_dma_stop(struct camelot_pcm *cam)
245{
246 unsigned long acr = BRGREG(BRGACR) & ~(ACR_TDS | ACR_RDS);
247 /* forcibly terminate data transmission */
248 BRGREG(BRGACR) = acr | ACR_TDS;
249}
250
251static inline void dmabrg_rec_dma_start(struct camelot_pcm *cam)
252{
253 unsigned long acr = BRGREG(BRGACR) & ~(ACR_TDS | ACR_RDS);
254 /* start DMABRG engine: recv start, auto-reload */
255 BRGREG(BRGACR) = acr | ACR_RDE | ACR_RAR | ACR_RAM_2WORD;
256}
257
258static inline void dmabrg_rec_dma_stop(struct camelot_pcm *cam)
259{
260 unsigned long acr = BRGREG(BRGACR) & ~(ACR_TDS | ACR_RDS);
261 /* forcibly terminate data receiver */
262 BRGREG(BRGACR) = acr | ACR_RDS;
263}
264
265static int camelot_trigger(struct snd_pcm_substream *substream, int cmd)
266{
267 struct snd_soc_pcm_runtime *rtd = substream->private_data;
268 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
269 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
270
271 switch (cmd) {
272 case SNDRV_PCM_TRIGGER_START:
273 if (recv)
274 dmabrg_rec_dma_start(cam);
275 else
276 dmabrg_play_dma_start(cam);
277 break;
278 case SNDRV_PCM_TRIGGER_STOP:
279 if (recv)
280 dmabrg_rec_dma_stop(cam);
281 else
282 dmabrg_play_dma_stop(cam);
283 break;
284 default:
285 return -EINVAL;
286 }
287
288 return 0;
289}
290
291static snd_pcm_uframes_t camelot_pos(struct snd_pcm_substream *substream)
292{
293 struct snd_pcm_runtime *runtime = substream->runtime;
294 struct snd_soc_pcm_runtime *rtd = substream->private_data;
295 struct camelot_pcm *cam = &cam_pcm_data[rtd->dai->cpu_dai->id];
296 int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
297 unsigned long pos;
298
299 /* cannot use the DMABRG pointer register: under load, by the
300 * time ALSA comes around to read the register, it is already
301 * far ahead (or worse, already done with the fragment) of the
302 * position at the time the IRQ was triggered, which results in
303 * fast-playback sound in my test application (ScummVM)
304 */
305 if (recv)
306 pos = cam->rx_period ? cam->rx_period_size : 0;
307 else
308 pos = cam->tx_period ? cam->tx_period_size : 0;
309
310 return bytes_to_frames(runtime, pos);
311}
312
313static struct snd_pcm_ops camelot_pcm_ops = {
314 .open = camelot_pcm_open,
315 .close = camelot_pcm_close,
316 .ioctl = snd_pcm_lib_ioctl,
317 .hw_params = camelot_hw_params,
318 .hw_free = camelot_hw_free,
319 .prepare = camelot_prepare,
320 .trigger = camelot_trigger,
321 .pointer = camelot_pos,
322};
323
324static void camelot_pcm_free(struct snd_pcm *pcm)
325{
326 snd_pcm_lib_preallocate_free_for_all(pcm);
327}
328
329static int camelot_pcm_new(struct snd_card *card,
330 struct snd_soc_codec_dai *dai,
331 struct snd_pcm *pcm)
332{
333 /* dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel
334 * in MMAP mode (i.e. aplay -M)
335 */
336 snd_pcm_lib_preallocate_pages_for_all(pcm,
337 SNDRV_DMA_TYPE_CONTINUOUS,
338 snd_dma_continuous_data(GFP_KERNEL),
339 DMABRG_PREALLOC_BUFFER, DMABRG_PREALLOC_BUFFER_MAX);
340
341 return 0;
342}
343
344struct snd_soc_platform sh7760_soc_platform = {
345 .name = "sh7760-pcm",
346 .pcm_ops = &camelot_pcm_ops,
347 .pcm_new = camelot_pcm_new,
348 .pcm_free = camelot_pcm_free,
349};
350EXPORT_SYMBOL_GPL(sh7760_soc_platform);
351
352MODULE_LICENSE("GPL");
353MODULE_DESCRIPTION("SH7760 Audio DMA (DMABRG) driver");
354MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
diff --git a/sound/soc/sh/hac.c b/sound/soc/sh/hac.c
new file mode 100644
index 00000000000..8e3f03908cd
--- /dev/null
+++ b/sound/soc/sh/hac.c
@@ -0,0 +1,322 @@
1/*
2 * Hitachi Audio Controller (AC97) support for SH7760/SH7780
3 *
4 * Copyright (c) 2007 Manuel Lauss <mano@roarinelk.homelinux.net>
5 * licensed under the terms outlined in the file COPYING at the root
6 * of the linux kernel sources.
7 *
8 * dont forget to set IPSEL/OMSEL register bits (in your board code) to
9 * enable HAC output pins!
10 */
11
12/* BIG FAT FIXME: although the SH7760 has 2 independent AC97 units, only
13 * the FIRST can be used since ASoC does not pass any information to the
14 * ac97_read/write() functions regarding WHICH unit to use. You'll have
15 * to edit the code a bit to use the other AC97 unit. --mlau
16 */
17
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/platform_device.h>
21#include <linux/interrupt.h>
22#include <linux/wait.h>
23#include <linux/delay.h>
24#include <sound/driver.h>
25#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/ac97_codec.h>
28#include <sound/initval.h>
29#include <sound/soc.h>
30
31/* regs and bits */
32#define HACCR 0x08
33#define HACCSAR 0x20
34#define HACCSDR 0x24
35#define HACPCML 0x28
36#define HACPCMR 0x2C
37#define HACTIER 0x50
38#define HACTSR 0x54
39#define HACRIER 0x58
40#define HACRSR 0x5C
41#define HACACR 0x60
42
43#define CR_CR (1 << 15) /* "codec-ready" indicator */
44#define CR_CDRT (1 << 11) /* cold reset */
45#define CR_WMRT (1 << 10) /* warm reset */
46#define CR_B9 (1 << 9) /* the mysterious "bit 9" */
47#define CR_ST (1 << 5) /* AC97 link start bit */
48
49#define CSAR_RD (1 << 19) /* AC97 data read bit */
50#define CSAR_WR (0)
51
52#define TSR_CMDAMT (1 << 31)
53#define TSR_CMDDMT (1 << 30)
54
55#define RSR_STARY (1 << 22)
56#define RSR_STDRY (1 << 21)
57
58#define ACR_DMARX16 (1 << 30)
59#define ACR_DMATX16 (1 << 29)
60#define ACR_TX12ATOM (1 << 26)
61#define ACR_DMARX20 ((1 << 24) | (1 << 22))
62#define ACR_DMATX20 ((1 << 23) | (1 << 21))
63
64#define CSDR_SHIFT 4
65#define CSDR_MASK (0xffff << CSDR_SHIFT)
66#define CSAR_SHIFT 12
67#define CSAR_MASK (0x7f << CSAR_SHIFT)
68
69#define AC97_WRITE_RETRY 1
70#define AC97_READ_RETRY 5
71
72/* manual-suggested AC97 codec access timeouts (us) */
73#define TMO_E1 500 /* 21 < E1 < 1000 */
74#define TMO_E2 13 /* 13 < E2 */
75#define TMO_E3 21 /* 21 < E3 */
76#define TMO_E4 500 /* 21 < E4 < 1000 */
77
78struct hac_priv {
79 unsigned long mmio; /* HAC base address */
80} hac_cpu_data[] = {
81#if defined(CONFIG_CPU_SUBTYPE_SH7760)
82 {
83 .mmio = 0xFE240000,
84 },
85 {
86 .mmio = 0xFE250000,
87 },
88#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
89 {
90 .mmio = 0xFFE40000,
91 },
92#else
93#error "Unsupported SuperH SoC"
94#endif
95};
96
97#define HACREG(reg) (*(unsigned long *)(hac->mmio + (reg)))
98
99/*
100 * AC97 read/write flow as outlined in the SH7760 manual (pages 903-906)
101 */
102static int hac_get_codec_data(struct hac_priv *hac, unsigned short r,
103 unsigned short *v)
104{
105 unsigned int to1, to2, i;
106 unsigned short adr;
107
108 for (i = 0; i < AC97_READ_RETRY; ++i) {
109 *v = 0;
110 /* wait for HAC to receive something from the codec */
111 for (to1 = TMO_E4;
112 to1 && !(HACREG(HACRSR) & RSR_STARY);
113 --to1)
114 udelay(1);
115 for (to2 = TMO_E4;
116 to2 && !(HACREG(HACRSR) & RSR_STDRY);
117 --to2)
118 udelay(1);
119
120 if (!to1 && !to2)
121 return 0; /* codec comm is down */
122
123 adr = ((HACREG(HACCSAR) & CSAR_MASK) >> CSAR_SHIFT);
124 *v = ((HACREG(HACCSDR) & CSDR_MASK) >> CSDR_SHIFT);
125
126 HACREG(HACRSR) &= ~(RSR_STDRY | RSR_STARY);
127
128 if (r == adr)
129 break;
130
131 /* manual says: wait at least 21 usec before retrying */
132 udelay(21);
133 }
134 HACREG(HACRSR) &= ~(RSR_STDRY | RSR_STARY);
135 return (i < AC97_READ_RETRY);
136}
137
138static unsigned short hac_read_codec_aux(struct hac_priv *hac,
139 unsigned short reg)
140{
141 unsigned short val;
142 unsigned int i, to;
143
144 for (i = 0; i < AC97_READ_RETRY; i++) {
145 /* send_read_request */
146 local_irq_disable();
147 HACREG(HACTSR) &= ~(TSR_CMDAMT);
148 HACREG(HACCSAR) = (reg << CSAR_SHIFT) | CSAR_RD;
149 local_irq_enable();
150
151 for (to = TMO_E3;
152 to && !(HACREG(HACTSR) & TSR_CMDAMT);
153 --to)
154 udelay(1);
155
156 HACREG(HACTSR) &= ~TSR_CMDAMT;
157 val = 0;
158 if (hac_get_codec_data(hac, reg, &val) != 0)
159 break;
160 }
161
162 if (i == AC97_READ_RETRY)
163 return ~0;
164
165 return val;
166}
167
168static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
169 unsigned short val)
170{
171 int unit_id = 0 /* ac97->private_data */;
172 struct hac_priv *hac = &hac_cpu_data[unit_id];
173 unsigned int i, to;
174 /* write_codec_aux */
175 for (i = 0; i < AC97_WRITE_RETRY; i++) {
176 /* send_write_request */
177 local_irq_disable();
178 HACREG(HACTSR) &= ~(TSR_CMDDMT | TSR_CMDAMT);
179 HACREG(HACCSDR) = (val << CSDR_SHIFT);
180 HACREG(HACCSAR) = (reg << CSAR_SHIFT) & (~CSAR_RD);
181 local_irq_enable();
182
183 /* poll-wait for CMDAMT and CMDDMT */
184 for (to = TMO_E1;
185 to && !(HACREG(HACTSR) & (TSR_CMDAMT|TSR_CMDDMT));
186 --to)
187 udelay(1);
188
189 HACREG(HACTSR) &= ~(TSR_CMDAMT | TSR_CMDDMT);
190 if (to)
191 break;
192 /* timeout, try again */
193 }
194}
195
196static unsigned short hac_ac97_read(struct snd_ac97 *ac97,
197 unsigned short reg)
198{
199 int unit_id = 0 /* ac97->private_data */;
200 struct hac_priv *hac = &hac_cpu_data[unit_id];
201 return hac_read_codec_aux(hac, reg);
202}
203
204static void hac_ac97_warmrst(struct snd_ac97 *ac97)
205{
206 int unit_id = 0 /* ac97->private_data */;
207 struct hac_priv *hac = &hac_cpu_data[unit_id];
208 unsigned int tmo;
209
210 HACREG(HACCR) = CR_WMRT | CR_ST | CR_B9;
211 msleep(10);
212 HACREG(HACCR) = CR_ST | CR_B9;
213 for (tmo = 1000; (tmo > 0) && !(HACREG(HACCR) & CR_CR); tmo--)
214 udelay(1);
215
216 if (!tmo)
217 printk(KERN_INFO "hac: reset: AC97 link down!\n");
218 /* settings this bit lets us have a conversation with codec */
219 HACREG(HACACR) |= ACR_TX12ATOM;
220}
221
222static void hac_ac97_coldrst(struct snd_ac97 *ac97)
223{
224 int unit_id = 0 /* ac97->private_data */;
225 struct hac_priv *hac;
226 hac = &hac_cpu_data[unit_id];
227
228 HACREG(HACCR) = 0;
229 HACREG(HACCR) = CR_CDRT | CR_ST | CR_B9;
230 msleep(10);
231 hac_ac97_warmrst(ac97);
232}
233
234struct snd_ac97_bus_ops soc_ac97_ops = {
235 .read = hac_ac97_read,
236 .write = hac_ac97_write,
237 .reset = hac_ac97_coldrst,
238 .warm_reset = hac_ac97_warmrst,
239};
240EXPORT_SYMBOL_GPL(soc_ac97_ops);
241
242static int hac_hw_params(struct snd_pcm_substream *substream,
243 struct snd_pcm_hw_params *params)
244{
245 struct snd_soc_pcm_runtime *rtd = substream->private_data;
246 struct hac_priv *hac = &hac_cpu_data[rtd->dai->cpu_dai->id];
247 int d = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
248
249 switch (params->msbits) {
250 case 16:
251 HACREG(HACACR) |= d ? ACR_DMARX16 : ACR_DMATX16;
252 HACREG(HACACR) &= d ? ~ACR_DMARX20 : ~ACR_DMATX20;
253 break;
254 case 20:
255 HACREG(HACACR) &= d ? ~ACR_DMARX16 : ~ACR_DMATX16;
256 HACREG(HACACR) |= d ? ACR_DMARX20 : ACR_DMATX20;
257 break;
258 default:
259 pr_debug("hac: invalid depth %d bit\n", params->msbits);
260 return -EINVAL;
261 break;
262 }
263
264 return 0;
265}
266
267#define AC97_RATES \
268 SNDRV_PCM_RATE_8000_192000
269
270#define AC97_FMTS \
271 SNDRV_PCM_FMTBIT_S16_LE
272
273struct snd_soc_cpu_dai sh4_hac_dai[] = {
274{
275 .name = "HAC0",
276 .id = 0,
277 .type = SND_SOC_DAI_AC97,
278 .playback = {
279 .rates = AC97_RATES,
280 .formats = AC97_FMTS,
281 .channels_min = 2,
282 .channels_max = 2,
283 },
284 .capture = {
285 .rates = AC97_RATES,
286 .formats = AC97_FMTS,
287 .channels_min = 2,
288 .channels_max = 2,
289 },
290 .ops = {
291 .hw_params = hac_hw_params,
292 },
293},
294#ifdef CONFIG_CPU_SUBTYPE_SH7760
295{
296 .name = "HAC1",
297 .id = 1,
298 .type = SND_SOC_DAI_AC97,
299 .playback = {
300 .rates = AC97_RATES,
301 .formats = AC97_FMTS,
302 .channels_min = 2,
303 .channels_max = 2,
304 },
305 .capture = {
306 .rates = AC97_RATES,
307 .formats = AC97_FMTS,
308 .channels_min = 2,
309 .channels_max = 2,
310 },
311 .ops = {
312 .hw_params = hac_hw_params,
313 },
314
315},
316#endif
317};
318EXPORT_SYMBOL_GPL(sh4_hac_dai);
319
320MODULE_LICENSE("GPL");
321MODULE_DESCRIPTION("SuperH onchip HAC (AC97) audio driver");
322MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
diff --git a/sound/soc/sh/sh7760-ac97.c b/sound/soc/sh/sh7760-ac97.c
new file mode 100644
index 00000000000..5563f14511f
--- /dev/null
+++ b/sound/soc/sh/sh7760-ac97.c
@@ -0,0 +1,92 @@
1/*
2 * Generic AC97 sound support for SH7760
3 *
4 * (c) 2007 Manuel Lauss
5 *
6 * Licensed under the GPLv2.
7 */
8
9#include <linux/module.h>
10#include <linux/moduleparam.h>
11#include <linux/platform_device.h>
12#include <sound/driver.h>
13#include <sound/core.h>
14#include <sound/pcm.h>
15#include <sound/soc.h>
16#include <sound/soc-dapm.h>
17#include <asm/io.h>
18
19#include "../codecs/ac97.h"
20
21#define IPSEL 0xFE400034
22
23/* platform specific structs can be declared here */
24extern struct snd_soc_cpu_dai sh4_hac_dai[2];
25extern struct snd_soc_platform sh7760_soc_platform;
26
27static int machine_init(struct snd_soc_codec *codec)
28{
29 snd_soc_dapm_sync_endpoints(codec);
30 return 0;
31}
32
33static struct snd_soc_dai_link sh7760_ac97_dai = {
34 .name = "AC97",
35 .stream_name = "AC97 HiFi",
36 .cpu_dai = &sh4_hac_dai[0], /* HAC0 */
37 .codec_dai = &ac97_dai,
38 .init = machine_init,
39 .ops = NULL,
40};
41
42static struct snd_soc_machine sh7760_ac97_soc_machine = {
43 .name = "SH7760 AC97",
44 .dai_link = &sh7760_ac97_dai,
45 .num_links = 1,
46};
47
48static struct snd_soc_device sh7760_ac97_snd_devdata = {
49 .machine = &sh7760_ac97_soc_machine,
50 .platform = &sh7760_soc_platform,
51 .codec_dev = &soc_codec_dev_ac97,
52};
53
54static struct platform_device *sh7760_ac97_snd_device;
55
56static int __init sh7760_ac97_init(void)
57{
58 int ret;
59 unsigned short ipsel;
60
61 /* enable both AC97 controllers in pinmux reg */
62 ipsel = ctrl_inw(IPSEL);
63 ctrl_outw(ipsel | (3 << 10), IPSEL);
64
65 ret = -ENOMEM;
66 sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
67 if (!sh7760_ac97_snd_device)
68 goto out;
69
70 platform_set_drvdata(sh7760_ac97_snd_device,
71 &sh7760_ac97_snd_devdata);
72 sh7760_ac97_snd_devdata.dev = &sh7760_ac97_snd_device->dev;
73 ret = platform_device_add(sh7760_ac97_snd_device);
74
75 if (ret)
76 platform_device_put(sh7760_ac97_snd_device);
77
78out:
79 return ret;
80}
81
82static void __exit sh7760_ac97_exit(void)
83{
84 platform_device_unregister(sh7760_ac97_snd_device);
85}
86
87module_init(sh7760_ac97_init);
88module_exit(sh7760_ac97_exit);
89
90MODULE_LICENSE("GPL");
91MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
92MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
diff --git a/sound/soc/sh/ssi.c b/sound/soc/sh/ssi.c
new file mode 100644
index 00000000000..b72bc316cb8
--- /dev/null
+++ b/sound/soc/sh/ssi.c
@@ -0,0 +1,400 @@
1/*
2 * Serial Sound Interface (I2S) support for SH7760/SH7780
3 *
4 * Copyright (c) 2007 Manuel Lauss <mano@roarinelk.homelinux.net>
5 *
6 * licensed under the terms outlined in the file COPYING at the root
7 * of the linux kernel sources.
8 *
9 * dont forget to set IPSEL/OMSEL register bits (in your board code) to
10 * enable SSI output pins!
11 */
12
13/*
14 * LIMITATIONS:
15 * The SSI unit has only one physical data line, so full duplex is
16 * impossible. This can be remedied on the SH7760 by using the
17 * other SSI unit for recording; however the SH7780 has only 1 SSI
18 * unit, and its pins are shared with the AC97 unit, among others.
19 *
20 * FEATURES:
21 * The SSI features "compressed mode": in this mode it continuously
22 * streams PCM data over the I2S lines and uses LRCK as a handshake
23 * signal. Can be used to send compressed data (AC3/DTS) to a DSP.
24 * The number of bits sent over the wire in a frame can be adjusted
25 * and can be independent from the actual sample bit depth. This is
26 * useful to support TDM mode codecs like the AD1939 which have a
27 * fixed TDM slot size, regardless of sample resolution.
28 */
29
30#include <linux/init.h>
31#include <linux/module.h>
32#include <linux/platform_device.h>
33#include <sound/driver.h>
34#include <sound/core.h>
35#include <sound/pcm.h>
36#include <sound/initval.h>
37#include <sound/soc.h>
38#include <asm/io.h>
39
40#define SSICR 0x00
41#define SSISR 0x04
42
43#define CR_DMAEN (1 << 28)
44#define CR_CHNL_SHIFT 22
45#define CR_CHNL_MASK (3 << CR_CHNL_SHIFT)
46#define CR_DWL_SHIFT 19
47#define CR_DWL_MASK (7 << CR_DWL_SHIFT)
48#define CR_SWL_SHIFT 16
49#define CR_SWL_MASK (7 << CR_SWL_SHIFT)
50#define CR_SCK_MASTER (1 << 15) /* bitclock master bit */
51#define CR_SWS_MASTER (1 << 14) /* wordselect master bit */
52#define CR_SCKP (1 << 13) /* I2Sclock polarity */
53#define CR_SWSP (1 << 12) /* LRCK polarity */
54#define CR_SPDP (1 << 11)
55#define CR_SDTA (1 << 10) /* i2s alignment (msb/lsb) */
56#define CR_PDTA (1 << 9) /* fifo data alignment */
57#define CR_DEL (1 << 8) /* delay data by 1 i2sclk */
58#define CR_BREN (1 << 7) /* clock gating in burst mode */
59#define CR_CKDIV_SHIFT 4
60#define CR_CKDIV_MASK (7 << CR_CKDIV_SHIFT) /* bitclock divider */
61#define CR_MUTE (1 << 3) /* SSI mute */
62#define CR_CPEN (1 << 2) /* compressed mode */
63#define CR_TRMD (1 << 1) /* transmit/receive select */
64#define CR_EN (1 << 0) /* enable SSI */
65
66#define SSIREG(reg) (*(unsigned long *)(ssi->mmio + (reg)))
67
68struct ssi_priv {
69 unsigned long mmio;
70 unsigned long sysclk;
71 int inuse;
72} ssi_cpu_data[] = {
73#if defined(CONFIG_CPU_SUBTYPE_SH7760)
74 {
75 .mmio = 0xFE680000,
76 },
77 {
78 .mmio = 0xFE690000,
79 },
80#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
81 {
82 .mmio = 0xFFE70000,
83 },
84#else
85#error "Unsupported SuperH SoC"
86#endif
87};
88
89/*
90 * track usage of the SSI; it is simplex-only so prevent attempts of
91 * concurrent playback + capture. FIXME: any locking required?
92 */
93static int ssi_startup(struct snd_pcm_substream *substream)
94{
95 struct snd_soc_pcm_runtime *rtd = substream->private_data;
96 struct ssi_priv *ssi = &ssi_cpu_data[rtd->dai->cpu_dai->id];
97 if (ssi->inuse) {
98 pr_debug("ssi: already in use!\n");
99 return -EBUSY;
100 } else
101 ssi->inuse = 1;
102 return 0;
103}
104
105static void ssi_shutdown(struct snd_pcm_substream *substream)
106{
107 struct snd_soc_pcm_runtime *rtd = substream->private_data;
108 struct ssi_priv *ssi = &ssi_cpu_data[rtd->dai->cpu_dai->id];
109
110 ssi->inuse = 0;
111}
112
113static int ssi_trigger(struct snd_pcm_substream *substream, int cmd)
114{
115 struct snd_soc_pcm_runtime *rtd = substream->private_data;
116 struct ssi_priv *ssi = &ssi_cpu_data[rtd->dai->cpu_dai->id];
117
118 switch (cmd) {
119 case SNDRV_PCM_TRIGGER_START:
120 SSIREG(SSICR) |= CR_DMAEN | CR_EN;
121 break;
122 case SNDRV_PCM_TRIGGER_STOP:
123 SSIREG(SSICR) &= ~(CR_DMAEN | CR_EN);
124 break;
125 default:
126 return -EINVAL;
127 }
128
129 return 0;
130}
131
132static int ssi_hw_params(struct snd_pcm_substream *substream,
133 struct snd_pcm_hw_params *params)
134{
135 struct snd_soc_pcm_runtime *rtd = substream->private_data;
136 struct ssi_priv *ssi = &ssi_cpu_data[rtd->dai->cpu_dai->id];
137 unsigned long ssicr = SSIREG(SSICR);
138 unsigned int bits, channels, swl, recv, i;
139
140 channels = params_channels(params);
141 bits = params->msbits;
142 recv = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1;
143
144 pr_debug("ssi_hw_params() enter\nssicr was %08lx\n", ssicr);
145 pr_debug("bits: %d channels: %d\n", bits, channels);
146
147 ssicr &= ~(CR_TRMD | CR_CHNL_MASK | CR_DWL_MASK | CR_PDTA |
148 CR_SWL_MASK);
149
150 /* direction (send/receive) */
151 if (!recv)
152 ssicr |= CR_TRMD; /* transmit */
153
154 /* channels */
155 if ((channels < 2) || (channels > 8) || (channels & 1)) {
156 pr_debug("ssi: invalid number of channels\n");
157 return -EINVAL;
158 }
159 ssicr |= ((channels >> 1) - 1) << CR_CHNL_SHIFT;
160
161 /* DATA WORD LENGTH (DWL): databits in audio sample */
162 i = 0;
163 switch (bits) {
164 case 32: ++i;
165 case 24: ++i;
166 case 22: ++i;
167 case 20: ++i;
168 case 18: ++i;
169 case 16: ++i;
170 ssicr |= i << CR_DWL_SHIFT;
171 case 8: break;
172 default:
173 pr_debug("ssi: invalid sample width\n");
174 return -EINVAL;
175 }
176
177 /*
178 * SYSTEM WORD LENGTH: size in bits of half a frame over the I2S
179 * wires. This is usually bits_per_sample x channels/2; i.e. in
180 * Stereo mode the SWL equals DWL. SWL can be bigger than the
181 * product of (channels_per_slot x samplebits), e.g. for codecs
182 * like the AD1939 which only accept 32bit wide TDM slots. For
183 * "standard" I2S operation we set SWL = chans / 2 * DWL here.
184 * Waiting for ASoC to get TDM support ;-)
185 */
186 if ((bits > 16) && (bits <= 24)) {
187 bits = 24; /* these are padded by the SSI */
188 /*ssicr |= CR_PDTA;*/ /* cpu/data endianness ? */
189 }
190 i = 0;
191 swl = (bits * channels) / 2;
192 switch (swl) {
193 case 256: ++i;
194 case 128: ++i;
195 case 64: ++i;
196 case 48: ++i;
197 case 32: ++i;
198 case 16: ++i;
199 ssicr |= i << CR_SWL_SHIFT;
200 case 8: break;
201 default:
202 pr_debug("ssi: invalid system word length computed\n");
203 return -EINVAL;
204 }
205
206 SSIREG(SSICR) = ssicr;
207
208 pr_debug("ssi_hw_params() leave\nssicr is now %08lx\n", ssicr);
209 return 0;
210}
211
212static int ssi_set_sysclk(struct snd_soc_cpu_dai *cpu_dai, int clk_id,
213 unsigned int freq, int dir)
214{
215 struct ssi_priv *ssi = &ssi_cpu_data[cpu_dai->id];
216
217 ssi->sysclk = freq;
218
219 return 0;
220}
221
222/*
223 * This divider is used to generate the SSI_SCK (I2S bitclock) from the
224 * clock at the HAC_BIT_CLK ("oversampling clock") pin.
225 */
226static int ssi_set_clkdiv(struct snd_soc_cpu_dai *dai, int did, int div)
227{
228 struct ssi_priv *ssi = &ssi_cpu_data[dai->id];
229 unsigned long ssicr;
230 int i;
231
232 i = 0;
233 ssicr = SSIREG(SSICR) & ~CR_CKDIV_MASK;
234 switch (div) {
235 case 16: ++i;
236 case 8: ++i;
237 case 4: ++i;
238 case 2: ++i;
239 SSIREG(SSICR) = ssicr | (i << CR_CKDIV_SHIFT);
240 case 1: break;
241 default:
242 pr_debug("ssi: invalid sck divider %d\n", div);
243 return -EINVAL;
244 }
245
246 return 0;
247}
248
249static int ssi_set_fmt(struct snd_soc_cpu_dai *dai, unsigned int fmt)
250{
251 struct ssi_priv *ssi = &ssi_cpu_data[dai->id];
252 unsigned long ssicr = SSIREG(SSICR);
253
254 pr_debug("ssi_set_fmt()\nssicr was 0x%08lx\n", ssicr);
255
256 ssicr &= ~(CR_DEL | CR_PDTA | CR_BREN | CR_SWSP | CR_SCKP |
257 CR_SWS_MASTER | CR_SCK_MASTER);
258
259 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
260 case SND_SOC_DAIFMT_I2S:
261 break;
262 case SND_SOC_DAIFMT_RIGHT_J:
263 ssicr |= CR_DEL | CR_PDTA;
264 break;
265 case SND_SOC_DAIFMT_LEFT_J:
266 ssicr |= CR_DEL;
267 break;
268 default:
269 pr_debug("ssi: unsupported format\n");
270 return -EINVAL;
271 }
272
273 switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) {
274 case SND_SOC_DAIFMT_CONT:
275 break;
276 case SND_SOC_DAIFMT_GATED:
277 ssicr |= CR_BREN;
278 break;
279 }
280
281 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
282 case SND_SOC_DAIFMT_NB_NF:
283 ssicr |= CR_SCKP; /* sample data at low clkedge */
284 break;
285 case SND_SOC_DAIFMT_NB_IF:
286 ssicr |= CR_SCKP | CR_SWSP;
287 break;
288 case SND_SOC_DAIFMT_IB_NF:
289 break;
290 case SND_SOC_DAIFMT_IB_IF:
291 ssicr |= CR_SWSP; /* word select starts low */
292 break;
293 default:
294 pr_debug("ssi: invalid inversion\n");
295 return -EINVAL;
296 }
297
298 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
299 case SND_SOC_DAIFMT_CBM_CFM:
300 break;
301 case SND_SOC_DAIFMT_CBS_CFM:
302 ssicr |= CR_SCK_MASTER;
303 break;
304 case SND_SOC_DAIFMT_CBM_CFS:
305 ssicr |= CR_SWS_MASTER;
306 break;
307 case SND_SOC_DAIFMT_CBS_CFS:
308 ssicr |= CR_SWS_MASTER | CR_SCK_MASTER;
309 break;
310 default:
311 pr_debug("ssi: invalid master/slave configuration\n");
312 return -EINVAL;
313 }
314
315 SSIREG(SSICR) = ssicr;
316 pr_debug("ssi_set_fmt() leave\nssicr is now 0x%08lx\n", ssicr);
317
318 return 0;
319}
320
321/* the SSI depends on an external clocksource (at HAC_BIT_CLK) even in
322 * Master mode, so really this is board specific; the SSI can do any
323 * rate with the right bitclk and divider settings.
324 */
325#define SSI_RATES \
326 SNDRV_PCM_RATE_8000_192000
327
328/* the SSI can do 8-32 bit samples, with 8 possible channels */
329#define SSI_FMTS \
330 (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \
331 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \
332 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE | \
333 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3LE | \
334 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE)
335
336struct snd_soc_cpu_dai sh4_ssi_dai[] = {
337{
338 .name = "SSI0",
339 .id = 0,
340 .type = SND_SOC_DAI_I2S,
341 .playback = {
342 .rates = SSI_RATES,
343 .formats = SSI_FMTS,
344 .channels_min = 2,
345 .channels_max = 8,
346 },
347 .capture = {
348 .rates = SSI_RATES,
349 .formats = SSI_FMTS,
350 .channels_min = 2,
351 .channels_max = 8,
352 },
353 .ops = {
354 .startup = ssi_startup,
355 .shutdown = ssi_shutdown,
356 .trigger = ssi_trigger,
357 .hw_params = ssi_hw_params,
358 },
359 .dai_ops = {
360 .set_sysclk = ssi_set_sysclk,
361 .set_clkdiv = ssi_set_clkdiv,
362 .set_fmt = ssi_set_fmt,
363 },
364},
365#ifdef CONFIG_CPU_SUBTYPE_SH7760
366{
367 .name = "SSI1",
368 .id = 1,
369 .type = SND_SOC_DAI_I2S,
370 .playback = {
371 .rates = SSI_RATES,
372 .formats = SSI_FMTS,
373 .channels_min = 2,
374 .channels_max = 8,
375 },
376 .capture = {
377 .rates = SSI_RATES,
378 .formats = SSI_FMTS,
379 .channels_min = 2,
380 .channels_max = 8,
381 },
382 .ops = {
383 .startup = ssi_startup,
384 .shutdown = ssi_shutdown,
385 .trigger = ssi_trigger,
386 .hw_params = ssi_hw_params,
387 },
388 .dai_ops = {
389 .set_sysclk = ssi_set_sysclk,
390 .set_clkdiv = ssi_set_clkdiv,
391 .set_fmt = ssi_set_fmt,
392 },
393},
394#endif
395};
396EXPORT_SYMBOL_GPL(sh4_ssi_dai);
397
398MODULE_LICENSE("GPL");
399MODULE_DESCRIPTION("SuperH onchip SSI (I2S) audio driver");
400MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 36519aef55d..92d5d917b73 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -116,6 +116,7 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
116static inline const char* get_dai_name(int type) 116static inline const char* get_dai_name(int type)
117{ 117{
118 switch(type) { 118 switch(type) {
119 case SND_SOC_DAI_AC97_BUS:
119 case SND_SOC_DAI_AC97: 120 case SND_SOC_DAI_AC97:
120 return "AC97"; 121 return "AC97";
121 case SND_SOC_DAI_I2S: 122 case SND_SOC_DAI_I2S:
@@ -1099,7 +1100,8 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
1099 continue; 1100 continue;
1100 } 1101 }
1101 } 1102 }
1102 if (socdev->machine->dai_link[i].cpu_dai->type == SND_SOC_DAI_AC97) 1103 if (socdev->machine->dai_link[i].codec_dai->type ==
1104 SND_SOC_DAI_AC97_BUS)
1103 ac97 = 1; 1105 ac97 = 1;
1104 } 1106 }
1105 snprintf(codec->card->shortname, sizeof(codec->card->shortname), 1107 snprintf(codec->card->shortname, sizeof(codec->card->shortname),
@@ -1148,11 +1150,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
1148void snd_soc_free_pcms(struct snd_soc_device *socdev) 1150void snd_soc_free_pcms(struct snd_soc_device *socdev)
1149{ 1151{
1150 struct snd_soc_codec *codec = socdev->codec; 1152 struct snd_soc_codec *codec = socdev->codec;
1153#ifdef CONFIG_SND_SOC_AC97_BUS
1154 struct snd_soc_codec_dai *codec_dai;
1155 int i;
1156#endif
1151 1157
1152 mutex_lock(&codec->mutex); 1158 mutex_lock(&codec->mutex);
1153#ifdef CONFIG_SND_SOC_AC97_BUS 1159#ifdef CONFIG_SND_SOC_AC97_BUS
1154 if (codec->ac97) 1160 for(i = 0; i < codec->num_dai; i++) {
1155 soc_ac97_dev_unregister(codec); 1161 codec_dai = &codec->dai[i];
1162 if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) {
1163 soc_ac97_dev_unregister(codec);
1164 goto free_card;
1165 }
1166 }
1167free_card:
1156#endif 1168#endif
1157 1169
1158 if (codec->card) 1170 if (codec->card)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7caf8c7b0ac..96bce55572a 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -882,13 +882,15 @@ int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
882 if (wsink->id == snd_soc_dapm_input) { 882 if (wsink->id == snd_soc_dapm_input) {
883 if (wsource->id == snd_soc_dapm_micbias || 883 if (wsource->id == snd_soc_dapm_micbias ||
884 wsource->id == snd_soc_dapm_mic || 884 wsource->id == snd_soc_dapm_mic ||
885 wsink->id == snd_soc_dapm_line) 885 wsink->id == snd_soc_dapm_line ||
886 wsink->id == snd_soc_dapm_output)
886 wsink->ext = 1; 887 wsink->ext = 1;
887 } 888 }
888 if (wsource->id == snd_soc_dapm_output) { 889 if (wsource->id == snd_soc_dapm_output) {
889 if (wsink->id == snd_soc_dapm_spk || 890 if (wsink->id == snd_soc_dapm_spk ||
890 wsink->id == snd_soc_dapm_hp || 891 wsink->id == snd_soc_dapm_hp ||
891 wsink->id == snd_soc_dapm_line) 892 wsink->id == snd_soc_dapm_line ||
893 wsink->id == snd_soc_dapm_input)
892 wsource->ext = 1; 894 wsource->ext = 1;
893 } 895 }
894 896
diff --git a/sound/sound_firmware.c b/sound/sound_firmware.c
index 3304344713a..96deaefaa89 100644
--- a/sound/sound_firmware.c
+++ b/sound/sound_firmware.c
@@ -3,6 +3,7 @@
3#include <linux/fs.h> 3#include <linux/fs.h>
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/slab.h> 5#include <linux/slab.h>
6#include <linux/sched.h>
6#include <asm/uaccess.h> 7#include <asm/uaccess.h>
7#include "oss/sound_firmware.h" 8#include "oss/sound_firmware.h"
8 9
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 900a00de35f..dca0344cc1b 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -661,11 +661,9 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd)
661 { 661 {
662 unsigned int what = 0; 662 unsigned int what = 0;
663 struct snd_pcm_substream *s; 663 struct snd_pcm_substream *s;
664 struct list_head *pos;
665 unsigned long flags; 664 unsigned long flags;
666 665
667 snd_pcm_group_for_each(pos, substream) { 666 snd_pcm_group_for_each_entry(s, substream) {
668 s = snd_pcm_group_substream_entry(pos);
669 if (s == chip->playback_substream) { 667 if (s == chip->playback_substream) {
670 what |= CS4231_PLAYBACK_ENABLE; 668 what |= CS4231_PLAYBACK_ENABLE;
671 snd_pcm_trigger_done(s, substream); 669 snd_pcm_trigger_done(s, substream);
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 25a2a733300..e07085a7cfc 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -673,7 +673,7 @@ static s32 *dbri_cmdlock(struct snd_dbri * dbri, int len)
673} 673}
674 674
675/* 675/*
676 * Send prepared cmd string. It works by writting a JUMP cmd into 676 * Send prepared cmd string. It works by writing a JUMP cmd into
677 * the last WAIT cmd and force DBRI to reread the cmd. 677 * the last WAIT cmd and force DBRI to reread the cmd.
678 * The JUMP cmd points to the new cmd string. 678 * The JUMP cmd points to the new cmd string.
679 * It also releases the cmdlock spinlock. 679 * It also releases the cmdlock spinlock.
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index f05d02f5b69..315360f3127 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -29,5 +29,33 @@ config SND_USB_USX2Y
29 To compile this driver as a module, choose M here: the module 29 To compile this driver as a module, choose M here: the module
30 will be called snd-usb-usx2y. 30 will be called snd-usb-usx2y.
31 31
32config SND_USB_CAIAQ
33 tristate "Native Instruments USB audio devices"
34 depends on SND && USB
35 select SND_HWDEP
36 select SND_RAWMIDI
37 select SND_PCM
38 help
39 Say Y here to include support for caiaq USB audio interfaces,
40 namely:
41
42 * Native Instruments RigKontrol2
43 * Native Instruments Kore Controller
44 * Native Instruments Audio Kontrol 1
45 * Native Instruments Audio 8 DJ
46
47 To compile this driver as a module, choose M here: the module
48 will be called snd-usb-caiaq.
49
50config SND_USB_CAIAQ_INPUT
51 bool "enable input device for controllers"
52 depends on SND_USB_CAIAQ
53 help
54 Say Y here to support input controllers like buttons, knobs,
55 alpha dials and analog pedals on the following products:
56
57 * Native Instruments RigKontrol2
58 * Native Instruments Audio Kontrol 1
59
32endmenu 60endmenu
33 61
diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2c1dc11a72e..aa252ef2ebf 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -9,4 +9,4 @@ snd-usb-lib-objs := usbmidi.o
9obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o 9obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o
10obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o 10obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o
11 11
12obj-$(CONFIG_SND) += usx2y/ 12obj-$(CONFIG_SND) += usx2y/ caiaq/
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile
new file mode 100644
index 00000000000..455c8c58a1b
--- /dev/null
+++ b/sound/usb/caiaq/Makefile
@@ -0,0 +1,3 @@
1snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o
2
3obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
new file mode 100644
index 00000000000..0414d766ba0
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -0,0 +1,707 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack, Karsten Wiese
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#include <sound/driver.h>
20#include <linux/init.h>
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/interrupt.h>
24#include <linux/usb.h>
25#include <linux/spinlock.h>
26#include <sound/core.h>
27#include <sound/initval.h>
28#include <sound/pcm.h>
29#include <sound/rawmidi.h>
30#ifdef CONFIG_SND_USB_CAIAQ_INPUT
31#include <linux/input.h>
32#endif
33
34#include "caiaq-device.h"
35#include "caiaq-audio.h"
36
37#define N_URBS 32
38#define CLOCK_DRIFT_TOLERANCE 5
39#define FRAMES_PER_URB 8
40#define BYTES_PER_FRAME 512
41#define CHANNELS_PER_STREAM 2
42#define BYTES_PER_SAMPLE 3
43#define BYTES_PER_SAMPLE_USB 4
44#define MAX_BUFFER_SIZE (128*1024)
45
46#define ENDPOINT_CAPTURE 2
47#define ENDPOINT_PLAYBACK 6
48
49#define MAKE_CHECKBYTE(dev,stream,i) \
50 (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)
51
52static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
53 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
54 SNDRV_PCM_INFO_BLOCK_TRANSFER),
55 .formats = SNDRV_PCM_FMTBIT_S24_3BE,
56 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
57 SNDRV_PCM_RATE_96000),
58 .rate_min = 44100,
59 .rate_max = 0, /* will overwrite later */
60 .channels_min = CHANNELS_PER_STREAM,
61 .channels_max = CHANNELS_PER_STREAM,
62 .buffer_bytes_max = MAX_BUFFER_SIZE,
63 .period_bytes_min = 4096,
64 .period_bytes_max = MAX_BUFFER_SIZE,
65 .periods_min = 1,
66 .periods_max = 1024,
67};
68
69static void
70activate_substream(struct snd_usb_caiaqdev *dev,
71 struct snd_pcm_substream *sub)
72{
73 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
74 dev->sub_playback[sub->number] = sub;
75 else
76 dev->sub_capture[sub->number] = sub;
77}
78
79static void
80deactivate_substream(struct snd_usb_caiaqdev *dev,
81 struct snd_pcm_substream *sub)
82{
83 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
84 dev->sub_playback[sub->number] = NULL;
85 else
86 dev->sub_capture[sub->number] = NULL;
87}
88
89static int
90all_substreams_zero(struct snd_pcm_substream **subs)
91{
92 int i;
93 for (i = 0; i < MAX_STREAMS; i++)
94 if (subs[i] != NULL)
95 return 0;
96 return 1;
97}
98
99static int stream_start(struct snd_usb_caiaqdev *dev)
100{
101 int i, ret;
102
103 debug("stream_start(%p)\n", dev);
104 spin_lock_irq(&dev->spinlock);
105 if (dev->streaming) {
106 spin_unlock_irq(&dev->spinlock);
107 return -EINVAL;
108 }
109
110 dev->input_panic = 0;
111 dev->output_panic = 0;
112 dev->first_packet = 1;
113 dev->streaming = 1;
114
115 for (i = 0; i < N_URBS; i++) {
116 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
117 if (ret) {
118 log("unable to trigger initial read #%d! (ret = %d)\n",
119 i, ret);
120 dev->streaming = 0;
121 spin_unlock_irq(&dev->spinlock);
122 return -EPIPE;
123 }
124 }
125
126 spin_unlock_irq(&dev->spinlock);
127 return 0;
128}
129
130static void stream_stop(struct snd_usb_caiaqdev *dev)
131{
132 int i;
133
134 debug("stream_stop(%p)\n", dev);
135 if (!dev->streaming)
136 return;
137
138 dev->streaming = 0;
139 for (i = 0; i < N_URBS; i++) {
140 usb_unlink_urb(dev->data_urbs_in[i]);
141 usb_unlink_urb(dev->data_urbs_out[i]);
142 }
143}
144
145static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
146{
147 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
148 debug("snd_usb_caiaq_substream_open(%p)\n", substream);
149 substream->runtime->hw = dev->pcm_info;
150 snd_pcm_limit_hw_rates(substream->runtime);
151 return 0;
152}
153
154static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
155{
156 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
157
158 debug("snd_usb_caiaq_substream_close(%p)\n", substream);
159 if (all_substreams_zero(dev->sub_playback) &&
160 all_substreams_zero(dev->sub_capture)) {
161 /* when the last client has stopped streaming,
162 * all sample rates are allowed again */
163 stream_stop(dev);
164 dev->pcm_info.rates = dev->samplerates;
165 }
166
167 return 0;
168}
169
170static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
171 struct snd_pcm_hw_params *hw_params)
172{
173 debug("snd_usb_caiaq_pcm_hw_params(%p)\n", sub);
174 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params));
175}
176
177static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
178{
179 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
180 debug("snd_usb_caiaq_pcm_hw_free(%p)\n", sub);
181 spin_lock_irq(&dev->spinlock);
182 deactivate_substream(dev, sub);
183 spin_unlock_irq(&dev->spinlock);
184 return snd_pcm_lib_free_pages(sub);
185}
186
187/* this should probably go upstream */
188#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
189#error "Change this table"
190#endif
191
192static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
193 48000, 64000, 88200, 96000, 176400, 192000 };
194
195static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
196{
197 int bytes_per_sample, bpp, ret, i;
198 int index = substream->number;
199 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
200 struct snd_pcm_runtime *runtime = substream->runtime;
201
202 debug("snd_usb_caiaq_pcm_prepare(%p)\n", substream);
203
204 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
205 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1;
206 else
207 dev->audio_in_buf_pos[index] = 0;
208
209 if (dev->streaming)
210 return 0;
211
212 /* the first client that opens a stream defines the sample rate
213 * setting for all subsequent calls, until the last client closed. */
214 for (i=0; i < ARRAY_SIZE(rates); i++)
215 if (runtime->rate == rates[i])
216 dev->pcm_info.rates = 1 << i;
217
218 snd_pcm_limit_hw_rates(runtime);
219
220 bytes_per_sample = BYTES_PER_SAMPLE;
221 if (dev->spec.data_alignment == 2)
222 bytes_per_sample++;
223
224 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE)
225 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams;
226
227 ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate,
228 runtime->sample_bits, bpp);
229 if (ret)
230 return ret;
231
232 ret = stream_start(dev);
233 if (ret)
234 return ret;
235
236 dev->output_running = 0;
237 wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ);
238 if (!dev->output_running) {
239 stream_stop(dev);
240 return -EPIPE;
241 }
242
243 return 0;
244}
245
246static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
247{
248 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
249
250 switch (cmd) {
251 case SNDRV_PCM_TRIGGER_START:
252 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
253 spin_lock(&dev->spinlock);
254 activate_substream(dev, sub);
255 spin_unlock(&dev->spinlock);
256 break;
257 case SNDRV_PCM_TRIGGER_STOP:
258 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
259 spin_lock(&dev->spinlock);
260 deactivate_substream(dev, sub);
261 spin_unlock(&dev->spinlock);
262 break;
263 default:
264 return -EINVAL;
265 }
266
267 return 0;
268}
269
270static snd_pcm_uframes_t
271snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
272{
273 int index = sub->number;
274 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
275
276 if (dev->input_panic || dev->output_panic)
277 return SNDRV_PCM_POS_XRUN;
278
279 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
280 return bytes_to_frames(sub->runtime,
281 dev->audio_out_buf_pos[index]);
282 else
283 return bytes_to_frames(sub->runtime,
284 dev->audio_in_buf_pos[index]);
285}
286
287/* operators for both playback and capture */
288static struct snd_pcm_ops snd_usb_caiaq_ops = {
289 .open = snd_usb_caiaq_substream_open,
290 .close = snd_usb_caiaq_substream_close,
291 .ioctl = snd_pcm_lib_ioctl,
292 .hw_params = snd_usb_caiaq_pcm_hw_params,
293 .hw_free = snd_usb_caiaq_pcm_hw_free,
294 .prepare = snd_usb_caiaq_pcm_prepare,
295 .trigger = snd_usb_caiaq_pcm_trigger,
296 .pointer = snd_usb_caiaq_pcm_pointer
297};
298
299static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev,
300 struct snd_pcm_substream **subs)
301{
302 int stream, pb, *cnt;
303 struct snd_pcm_substream *sub;
304
305 for (stream = 0; stream < dev->n_streams; stream++) {
306 sub = subs[stream];
307 if (!sub)
308 continue;
309
310 pb = frames_to_bytes(sub->runtime,
311 sub->runtime->period_size);
312 cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
313 &dev->period_out_count[stream] :
314 &dev->period_in_count[stream];
315
316 if (*cnt >= pb) {
317 snd_pcm_period_elapsed(sub);
318 *cnt %= pb;
319 }
320 }
321}
322
323static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
324 const struct urb *urb,
325 const struct usb_iso_packet_descriptor *iso)
326{
327 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
328 struct snd_pcm_substream *sub;
329 int stream, i;
330
331 if (all_substreams_zero(dev->sub_capture))
332 return;
333
334 spin_lock(&dev->spinlock);
335
336 for (i = 0; i < iso->actual_length;) {
337 for (stream = 0; stream < dev->n_streams; stream++, i++) {
338 sub = dev->sub_capture[stream];
339 if (sub) {
340 struct snd_pcm_runtime *rt = sub->runtime;
341 char *audio_buf = rt->dma_area;
342 int sz = frames_to_bytes(rt, rt->buffer_size);
343 audio_buf[dev->audio_in_buf_pos[stream]++]
344 = usb_buf[i];
345 dev->period_in_count[stream]++;
346 if (dev->audio_in_buf_pos[stream] == sz)
347 dev->audio_in_buf_pos[stream] = 0;
348 }
349 }
350 }
351
352 spin_unlock(&dev->spinlock);
353}
354
355static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
356 const struct urb *urb,
357 const struct usb_iso_packet_descriptor *iso)
358{
359 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
360 unsigned char check_byte;
361 struct snd_pcm_substream *sub;
362 int stream, i;
363
364 spin_lock(&dev->spinlock);
365
366 for (i = 0; i < iso->actual_length;) {
367 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) {
368 for (stream = 0;
369 stream < dev->n_streams;
370 stream++, i++) {
371 if (dev->first_packet)
372 continue;
373
374 check_byte = MAKE_CHECKBYTE(dev, stream, i);
375
376 if ((usb_buf[i] & 0x3f) != check_byte)
377 dev->input_panic = 1;
378
379 if (usb_buf[i] & 0x80)
380 dev->output_panic = 1;
381 }
382 }
383 dev->first_packet = 0;
384
385 for (stream = 0; stream < dev->n_streams; stream++, i++) {
386 sub = dev->sub_capture[stream];
387 if (sub) {
388 struct snd_pcm_runtime *rt = sub->runtime;
389 char *audio_buf = rt->dma_area;
390 int sz = frames_to_bytes(rt, rt->buffer_size);
391 audio_buf[dev->audio_in_buf_pos[stream]++] =
392 usb_buf[i];
393 dev->period_in_count[stream]++;
394 if (dev->audio_in_buf_pos[stream] == sz)
395 dev->audio_in_buf_pos[stream] = 0;
396 }
397 }
398 }
399
400 spin_unlock(&dev->spinlock);
401}
402
403static void read_in_urb(struct snd_usb_caiaqdev *dev,
404 const struct urb *urb,
405 const struct usb_iso_packet_descriptor *iso)
406{
407 if (!dev->streaming)
408 return;
409
410 switch (dev->spec.data_alignment) {
411 case 0:
412 read_in_urb_mode0(dev, urb, iso);
413 break;
414 case 2:
415 read_in_urb_mode2(dev, urb, iso);
416 break;
417 }
418
419 if (dev->input_panic || dev->output_panic) {
420 debug("streaming error detected %s %s\n",
421 dev->input_panic ? "(input)" : "",
422 dev->output_panic ? "(output)" : "");
423 }
424
425 check_for_elapsed_periods(dev, dev->sub_capture);
426}
427
428static void fill_out_urb(struct snd_usb_caiaqdev *dev,
429 struct urb *urb,
430 const struct usb_iso_packet_descriptor *iso)
431{
432 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
433 struct snd_pcm_substream *sub;
434 int stream, i;
435
436 spin_lock(&dev->spinlock);
437
438 for (i = 0; i < iso->length;) {
439 for (stream = 0; stream < dev->n_streams; stream++, i++) {
440 sub = dev->sub_playback[stream];
441 if (sub) {
442 struct snd_pcm_runtime *rt = sub->runtime;
443 char *audio_buf = rt->dma_area;
444 int sz = frames_to_bytes(rt, rt->buffer_size);
445 usb_buf[i] =
446 audio_buf[dev->audio_out_buf_pos[stream]];
447 dev->period_out_count[stream]++;
448 dev->audio_out_buf_pos[stream]++;
449 if (dev->audio_out_buf_pos[stream] == sz)
450 dev->audio_out_buf_pos[stream] = 0;
451 } else
452 usb_buf[i] = 0;
453 }
454
455 /* fill in the check bytes */
456 if (dev->spec.data_alignment == 2 &&
457 i % (dev->n_streams * BYTES_PER_SAMPLE_USB) ==
458 (dev->n_streams * CHANNELS_PER_STREAM))
459 for (stream = 0; stream < dev->n_streams; stream++, i++)
460 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i);
461 }
462
463 spin_unlock(&dev->spinlock);
464 check_for_elapsed_periods(dev, dev->sub_playback);
465}
466
467static void read_completed(struct urb *urb)
468{
469 struct snd_usb_caiaq_cb_info *info = urb->context;
470 struct snd_usb_caiaqdev *dev;
471 struct urb *out;
472 int frame, len, send_it = 0, outframe = 0;
473
474 if (urb->status || !info)
475 return;
476
477 dev = info->dev;
478 if (!dev->streaming)
479 return;
480
481 out = dev->data_urbs_out[info->index];
482
483 /* read the recently received packet and send back one which has
484 * the same layout */
485 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
486 if (urb->iso_frame_desc[frame].status)
487 continue;
488
489 len = urb->iso_frame_desc[outframe].actual_length;
490 out->iso_frame_desc[outframe].length = len;
491 out->iso_frame_desc[outframe].actual_length = 0;
492 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame;
493
494 if (len > 0) {
495 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]);
496 read_in_urb(dev, urb, &urb->iso_frame_desc[frame]);
497 send_it = 1;
498 }
499
500 outframe++;
501 }
502
503 if (send_it) {
504 out->number_of_packets = FRAMES_PER_URB;
505 out->transfer_flags = URB_ISO_ASAP;
506 usb_submit_urb(out, GFP_ATOMIC);
507 }
508
509 /* re-submit inbound urb */
510 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
511 urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame;
512 urb->iso_frame_desc[frame].length = BYTES_PER_FRAME;
513 urb->iso_frame_desc[frame].actual_length = 0;
514 }
515
516 urb->number_of_packets = FRAMES_PER_URB;
517 urb->transfer_flags = URB_ISO_ASAP;
518 usb_submit_urb(urb, GFP_ATOMIC);
519}
520
521static void write_completed(struct urb *urb)
522{
523 struct snd_usb_caiaq_cb_info *info = urb->context;
524 struct snd_usb_caiaqdev *dev = info->dev;
525
526 if (!dev->output_running) {
527 dev->output_running = 1;
528 wake_up(&dev->prepare_wait_queue);
529 }
530}
531
532static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
533{
534 int i, frame;
535 struct urb **urbs;
536 struct usb_device *usb_dev = dev->chip.dev;
537 unsigned int pipe;
538
539 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
540 usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
541 usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
542
543 urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
544 if (!urbs) {
545 log("unable to kmalloc() urbs, OOM!?\n");
546 *ret = -ENOMEM;
547 return NULL;
548 }
549
550 for (i = 0; i < N_URBS; i++) {
551 urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
552 if (!urbs[i]) {
553 log("unable to usb_alloc_urb(), OOM!?\n");
554 *ret = -ENOMEM;
555 return urbs;
556 }
557
558 urbs[i]->transfer_buffer =
559 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
560 if (!urbs[i]->transfer_buffer) {
561 log("unable to kmalloc() transfer buffer, OOM!?\n");
562 *ret = -ENOMEM;
563 return urbs;
564 }
565
566 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
567 struct usb_iso_packet_descriptor *iso =
568 &urbs[i]->iso_frame_desc[frame];
569
570 iso->offset = BYTES_PER_FRAME * frame;
571 iso->length = BYTES_PER_FRAME;
572 }
573
574 urbs[i]->dev = usb_dev;
575 urbs[i]->pipe = pipe;
576 urbs[i]->transfer_buffer_length = FRAMES_PER_URB
577 * BYTES_PER_FRAME;
578 urbs[i]->context = &dev->data_cb_info[i];
579 urbs[i]->interval = 1;
580 urbs[i]->transfer_flags = URB_ISO_ASAP;
581 urbs[i]->number_of_packets = FRAMES_PER_URB;
582 urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
583 read_completed : write_completed;
584 }
585
586 *ret = 0;
587 return urbs;
588}
589
590static void free_urbs(struct urb **urbs)
591{
592 int i;
593
594 if (!urbs)
595 return;
596
597 for (i = 0; i < N_URBS; i++) {
598 if (!urbs[i])
599 continue;
600
601 usb_kill_urb(urbs[i]);
602 kfree(urbs[i]->transfer_buffer);
603 usb_free_urb(urbs[i]);
604 }
605
606 kfree(urbs);
607}
608
609int __devinit snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
610{
611 int i, ret;
612
613 dev->n_audio_in = max(dev->spec.num_analog_audio_in,
614 dev->spec.num_digital_audio_in) /
615 CHANNELS_PER_STREAM;
616 dev->n_audio_out = max(dev->spec.num_analog_audio_out,
617 dev->spec.num_digital_audio_out) /
618 CHANNELS_PER_STREAM;
619 dev->n_streams = max(dev->n_audio_in, dev->n_audio_out);
620
621 debug("dev->n_audio_in = %d\n", dev->n_audio_in);
622 debug("dev->n_audio_out = %d\n", dev->n_audio_out);
623 debug("dev->n_streams = %d\n", dev->n_streams);
624
625 if (dev->n_streams > MAX_STREAMS) {
626 log("unable to initialize device, too many streams.\n");
627 return -EINVAL;
628 }
629
630 ret = snd_pcm_new(dev->chip.card, dev->product_name, 0,
631 dev->n_audio_out, dev->n_audio_in, &dev->pcm);
632
633 if (ret < 0) {
634 log("snd_pcm_new() returned %d\n", ret);
635 return ret;
636 }
637
638 dev->pcm->private_data = dev;
639 strcpy(dev->pcm->name, dev->product_name);
640
641 memset(dev->sub_playback, 0, sizeof(dev->sub_playback));
642 memset(dev->sub_capture, 0, sizeof(dev->sub_capture));
643
644 memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware,
645 sizeof(snd_usb_caiaq_pcm_hardware));
646
647 /* setup samplerates */
648 dev->samplerates = dev->pcm_info.rates;
649 switch (dev->chip.usb_id) {
650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
651 dev->samplerates |= SNDRV_PCM_RATE_88200;
652 dev->samplerates |= SNDRV_PCM_RATE_192000;
653 break;
654 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
655 dev->samplerates |= SNDRV_PCM_RATE_88200;
656 break;
657 }
658
659 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK,
660 &snd_usb_caiaq_ops);
661 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE,
662 &snd_usb_caiaq_ops);
663
664 snd_pcm_lib_preallocate_pages_for_all(dev->pcm,
665 SNDRV_DMA_TYPE_CONTINUOUS,
666 snd_dma_continuous_data(GFP_KERNEL),
667 MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
668
669 dev->data_cb_info =
670 kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
671 GFP_KERNEL);
672
673 if (!dev->data_cb_info)
674 return -ENOMEM;
675
676 for (i = 0; i < N_URBS; i++) {
677 dev->data_cb_info[i].dev = dev;
678 dev->data_cb_info[i].index = i;
679 }
680
681 dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret);
682 if (ret < 0) {
683 kfree(dev->data_cb_info);
684 free_urbs(dev->data_urbs_in);
685 return ret;
686 }
687
688 dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret);
689 if (ret < 0) {
690 kfree(dev->data_cb_info);
691 free_urbs(dev->data_urbs_in);
692 free_urbs(dev->data_urbs_out);
693 return ret;
694 }
695
696 return 0;
697}
698
699void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev)
700{
701 debug("snd_usb_caiaq_audio_free (%p)\n", dev);
702 stream_stop(dev);
703 free_urbs(dev->data_urbs_in);
704 free_urbs(dev->data_urbs_out);
705 kfree(dev->data_cb_info);
706}
707
diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/caiaq-audio.h
new file mode 100644
index 00000000000..8ab1f8d9529
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-audio.h
@@ -0,0 +1,7 @@
1#ifndef CAIAQ_AUDIO_H
2#define CAIAQ_AUDIO_H
3
4int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev);
5void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev);
6
7#endif /* CAIAQ_AUDIO_H */
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
new file mode 100644
index 00000000000..4709347326f
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -0,0 +1,436 @@
1/*
2 * caiaq.c: ALSA driver for caiaq/NativeInstruments devices
3 *
4 * Copyright (c) 2007 Daniel Mack <daniel@caiaq.de>
5 * Karsten Wiese <fzu@wemgehoertderstaat.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/interrupt.h>
26#include <linux/usb.h>
27#include <linux/input.h>
28#include <linux/spinlock.h>
29#include <sound/driver.h>
30#include <sound/core.h>
31#include <sound/initval.h>
32#include <sound/pcm.h>
33#include <sound/rawmidi.h>
34
35#include "caiaq-device.h"
36#include "caiaq-audio.h"
37#include "caiaq-midi.h"
38
39#ifdef CONFIG_SND_USB_CAIAQ_INPUT
40#include "caiaq-input.h"
41#endif
42
43MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
44MODULE_DESCRIPTION("caiaq USB audio, version 1.1.0");
45MODULE_LICENSE("GPL");
46MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
47 "{Native Instruments, Kore Controller},"
48 "{Native Instruments, Audio Kontrol 1}"
49 "{Native Instruments, Audio 8 DJ}}");
50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
52static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
54static int snd_card_used[SNDRV_CARDS];
55
56module_param_array(index, int, NULL, 0444);
57MODULE_PARM_DESC(index, "Index value for the caiaq sound device");
58module_param_array(id, charp, NULL, 0444);
59MODULE_PARM_DESC(id, "ID string for the caiaq soundcard.");
60module_param_array(enable, bool, NULL, 0444);
61MODULE_PARM_DESC(enable, "Enable the caiaq soundcard.");
62
63enum {
64 SAMPLERATE_44100 = 0,
65 SAMPLERATE_48000 = 1,
66 SAMPLERATE_96000 = 2,
67 SAMPLERATE_192000 = 3,
68 SAMPLERATE_88200 = 4,
69 SAMPLERATE_INVALID = 0xff
70};
71
72enum {
73 DEPTH_NONE = 0,
74 DEPTH_16 = 1,
75 DEPTH_24 = 2,
76 DEPTH_32 = 3
77};
78
79static struct usb_device_id snd_usb_id_table[] = {
80 {
81 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
82 .idVendor = USB_VID_NATIVEINSTRUMENTS,
83 .idProduct = USB_PID_RIGKONTROL2
84 },
85 {
86 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
87 .idVendor = USB_VID_NATIVEINSTRUMENTS,
88 .idProduct = USB_PID_KORECONTROLLER
89 },
90 {
91 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
92 .idVendor = USB_VID_NATIVEINSTRUMENTS,
93 .idProduct = USB_PID_AK1
94 },
95 {
96 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
97 .idVendor = USB_VID_NATIVEINSTRUMENTS,
98 .idProduct = USB_PID_AUDIO8DJ
99 },
100 { /* terminator */ }
101};
102
103static void usb_ep1_command_reply_dispatch (struct urb* urb)
104{
105 int ret;
106 struct snd_usb_caiaqdev *dev = urb->context;
107 unsigned char *buf = urb->transfer_buffer;
108
109 if (urb->status || !dev) {
110 log("received EP1 urb->status = %i\n", urb->status);
111 return;
112 }
113
114 switch(buf[0]) {
115 case EP1_CMD_GET_DEVICE_INFO:
116 memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec));
117 dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version);
118 debug("device spec (firmware %d): audio: %d in, %d out, "
119 "MIDI: %d in, %d out, data alignment %d\n",
120 dev->spec.fw_version,
121 dev->spec.num_analog_audio_in,
122 dev->spec.num_analog_audio_out,
123 dev->spec.num_midi_in,
124 dev->spec.num_midi_out,
125 dev->spec.data_alignment);
126
127 dev->spec_received++;
128 wake_up(&dev->ep1_wait_queue);
129 break;
130 case EP1_CMD_AUDIO_PARAMS:
131 dev->audio_parm_answer = buf[1];
132 wake_up(&dev->ep1_wait_queue);
133 break;
134 case EP1_CMD_MIDI_READ:
135 snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]);
136 break;
137
138#ifdef CONFIG_SND_USB_CAIAQ_INPUT
139 case EP1_CMD_READ_ERP:
140 case EP1_CMD_READ_ANALOG:
141 case EP1_CMD_READ_IO:
142 snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length);
143 break;
144#endif
145 }
146
147 dev->ep1_in_urb.actual_length = 0;
148 ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC);
149 if (ret < 0)
150 log("unable to submit urb. OOM!?\n");
151}
152
153static int send_command (struct snd_usb_caiaqdev *dev,
154 unsigned char command,
155 const unsigned char *buffer,
156 int len)
157{
158 int actual_len;
159 struct usb_device *usb_dev = dev->chip.dev;
160
161 if (!usb_dev)
162 return -EIO;
163
164 if (len > EP1_BUFSIZE - 1)
165 len = EP1_BUFSIZE - 1;
166
167 if (buffer && len > 0)
168 memcpy(dev->ep1_out_buf+1, buffer, len);
169
170 dev->ep1_out_buf[0] = command;
171 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
172 dev->ep1_out_buf, len+1, &actual_len, 200);
173}
174
175int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
176 int rate, int depth, int bpp)
177{
178 int ret;
179 char tmp[5];
180
181 switch (rate) {
182 case 44100: tmp[0] = SAMPLERATE_44100; break;
183 case 48000: tmp[0] = SAMPLERATE_48000; break;
184 case 88200: tmp[0] = SAMPLERATE_88200; break;
185 case 96000: tmp[0] = SAMPLERATE_96000; break;
186 case 192000: tmp[0] = SAMPLERATE_192000; break;
187 default: return -EINVAL;
188 }
189
190 switch (depth) {
191 case 16: tmp[1] = DEPTH_16; break;
192 case 24: tmp[1] = DEPTH_24; break;
193 default: return -EINVAL;
194 }
195
196 tmp[2] = bpp & 0xff;
197 tmp[3] = bpp >> 8;
198 tmp[4] = 1; /* packets per microframe */
199
200 debug("setting audio params: %d Hz, %d bits, %d bpp\n",
201 rate, depth, bpp);
202
203 dev->audio_parm_answer = -1;
204 ret = send_command(dev, EP1_CMD_AUDIO_PARAMS, tmp, sizeof(tmp));
205
206 if (ret)
207 return ret;
208
209 if (!wait_event_timeout(dev->ep1_wait_queue,
210 dev->audio_parm_answer >= 0, HZ))
211 return -EPIPE;
212
213 if (dev->audio_parm_answer != 1)
214 debug("unable to set the device's audio params\n");
215
216 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
217}
218
219int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev,
220 int digital, int analog, int erp)
221{
222 char tmp[3] = { digital, analog, erp };
223 return send_command(dev, EP1_CMD_AUTO_MSG, tmp, sizeof(tmp));
224}
225
226static void setup_card(struct snd_usb_caiaqdev *dev)
227{
228 int ret;
229 char val[3];
230
231 /* device-specific startup specials */
232 switch (dev->chip.usb_id) {
233 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
234 /* RigKontrol2 - display centered dash ('-') */
235 val[0] = 0x00;
236 val[1] = 0x00;
237 val[2] = 0x01;
238 send_command(dev, EP1_CMD_WRITE_IO, val, 3);
239 break;
240 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
241 /* Audio Kontrol 1 - make USB-LED stop blinking */
242 val[0] = 0x00;
243 send_command(dev, EP1_CMD_WRITE_IO, val, 1);
244 break;
245 }
246
247 ret = snd_usb_caiaq_audio_init(dev);
248 if (ret < 0)
249 log("Unable to set up audio system (ret=%d)\n", ret);
250
251 ret = snd_usb_caiaq_midi_init(dev);
252 if (ret < 0)
253 log("Unable to set up MIDI system (ret=%d)\n", ret);
254
255#ifdef CONFIG_SND_USB_CAIAQ_INPUT
256 ret = snd_usb_caiaq_input_init(dev);
257 if (ret < 0)
258 log("Unable to set up input system (ret=%d)\n", ret);
259#endif
260
261 /* finally, register the card and all its sub-instances */
262 ret = snd_card_register(dev->chip.card);
263 if (ret < 0) {
264 log("snd_card_register() returned %d\n", ret);
265 snd_card_free(dev->chip.card);
266 }
267}
268
269static struct snd_card* create_card(struct usb_device* usb_dev)
270{
271 int devnum;
272 struct snd_card *card;
273 struct snd_usb_caiaqdev *dev;
274
275 for (devnum = 0; devnum < SNDRV_CARDS; devnum++)
276 if (enable[devnum] && !snd_card_used[devnum])
277 break;
278
279 if (devnum >= SNDRV_CARDS)
280 return NULL;
281
282 card = snd_card_new(index[devnum], id[devnum], THIS_MODULE,
283 sizeof(struct snd_usb_caiaqdev));
284 if (!card)
285 return NULL;
286
287 dev = caiaqdev(card);
288 dev->chip.dev = usb_dev;
289 dev->chip.card = card;
290 dev->chip.usb_id = USB_ID(usb_dev->descriptor.idVendor,
291 usb_dev->descriptor.idProduct);
292 spin_lock_init(&dev->spinlock);
293 snd_card_set_dev(card, &usb_dev->dev);
294
295 return card;
296}
297
298static int init_card(struct snd_usb_caiaqdev *dev)
299{
300 char *c;
301 struct usb_device *usb_dev = dev->chip.dev;
302 struct snd_card *card = dev->chip.card;
303 int err, len;
304
305 if (usb_set_interface(usb_dev, 0, 1) != 0) {
306 log("can't set alt interface.\n");
307 return -EIO;
308 }
309
310 usb_init_urb(&dev->ep1_in_urb);
311 usb_init_urb(&dev->midi_out_urb);
312
313 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev,
314 usb_rcvbulkpipe(usb_dev, 0x1),
315 dev->ep1_in_buf, EP1_BUFSIZE,
316 usb_ep1_command_reply_dispatch, dev);
317
318 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev,
319 usb_sndbulkpipe(usb_dev, 0x1),
320 dev->midi_out_buf, EP1_BUFSIZE,
321 snd_usb_caiaq_midi_output_done, dev);
322
323 init_waitqueue_head(&dev->ep1_wait_queue);
324 init_waitqueue_head(&dev->prepare_wait_queue);
325
326 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)
327 return -EIO;
328
329 err = send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
330 if (err)
331 return err;
332
333 if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ))
334 return -ENODEV;
335
336 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
337 dev->vendor_name, CAIAQ_USB_STR_LEN);
338
339 usb_string(usb_dev, usb_dev->descriptor.iProduct,
340 dev->product_name, CAIAQ_USB_STR_LEN);
341
342 usb_string(usb_dev, usb_dev->descriptor.iSerialNumber,
343 dev->serial, CAIAQ_USB_STR_LEN);
344
345 /* terminate serial string at first white space occurence */
346 c = strchr(dev->serial, ' ');
347 if (c)
348 *c = '\0';
349
350 strcpy(card->driver, MODNAME);
351 strcpy(card->shortname, dev->product_name);
352
353 len = snprintf(card->longname, sizeof(card->longname),
354 "%s %s (serial %s, ",
355 dev->vendor_name, dev->product_name, dev->serial);
356
357 if (len < sizeof(card->longname) - 2)
358 len += usb_make_path(usb_dev, card->longname + len,
359 sizeof(card->longname) - len);
360
361 card->longname[len++] = ')';
362 card->longname[len] = '\0';
363 setup_card(dev);
364 return 0;
365}
366
367static int snd_probe(struct usb_interface *intf,
368 const struct usb_device_id *id)
369{
370 int ret;
371 struct snd_card *card;
372 struct usb_device *device = interface_to_usbdev(intf);
373
374 card = create_card(device);
375
376 if (!card)
377 return -ENOMEM;
378
379 dev_set_drvdata(&intf->dev, card);
380 ret = init_card(caiaqdev(card));
381 if (ret < 0) {
382 log("unable to init card! (ret=%d)\n", ret);
383 snd_card_free(card);
384 return ret;
385 }
386
387 return 0;
388}
389
390static void snd_disconnect(struct usb_interface *intf)
391{
392 struct snd_usb_caiaqdev *dev;
393 struct snd_card *card = dev_get_drvdata(&intf->dev);
394
395 debug("snd_disconnect(%p)\n", intf);
396
397 if (!card)
398 return;
399
400 dev = caiaqdev(card);
401 snd_card_disconnect(card);
402
403#ifdef CONFIG_SND_USB_CAIAQ_INPUT
404 snd_usb_caiaq_input_free(dev);
405#endif
406 snd_usb_caiaq_audio_free(dev);
407
408 usb_kill_urb(&dev->ep1_in_urb);
409 usb_kill_urb(&dev->midi_out_urb);
410
411 snd_card_free(card);
412 usb_reset_device(interface_to_usbdev(intf));
413}
414
415
416MODULE_DEVICE_TABLE(usb, snd_usb_id_table);
417static struct usb_driver snd_usb_driver = {
418 .name = MODNAME,
419 .probe = snd_probe,
420 .disconnect = snd_disconnect,
421 .id_table = snd_usb_id_table,
422};
423
424static int __init snd_module_init(void)
425{
426 return usb_register(&snd_usb_driver);
427}
428
429static void __exit snd_module_exit(void)
430{
431 usb_deregister(&snd_usb_driver);
432}
433
434module_init(snd_module_init)
435module_exit(snd_module_exit)
436
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
new file mode 100644
index 00000000000..088d5ec241f
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -0,0 +1,116 @@
1#ifndef CAIAQ_DEVICE_H
2#define CAIAQ_DEVICE_H
3
4#include "../usbaudio.h"
5
6#define USB_VID_NATIVEINSTRUMENTS 0x17cc
7
8#define USB_PID_RIGKONTROL2 0x1969
9#define USB_PID_KORECONTROLLER 0x4711
10#define USB_PID_AK1 0x0815
11#define USB_PID_AUDIO8DJ 0x1978
12
13#define EP1_BUFSIZE 64
14#define CAIAQ_USB_STR_LEN 0xff
15#define MAX_STREAMS 32
16
17//#define SND_USB_CAIAQ_DEBUG
18
19#define MODNAME "snd-usb-caiaq"
20#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
21
22#ifdef SND_USB_CAIAQ_DEBUG
23#define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
24#else
25#define debug(x...) do { } while(0)
26#endif
27
28#define EP1_CMD_GET_DEVICE_INFO 0x1
29#define EP1_CMD_READ_ERP 0x2
30#define EP1_CMD_READ_ANALOG 0x3
31#define EP1_CMD_READ_IO 0x4
32#define EP1_CMD_WRITE_IO 0x5
33#define EP1_CMD_MIDI_READ 0x6
34#define EP1_CMD_MIDI_WRITE 0x7
35#define EP1_CMD_AUDIO_PARAMS 0x9
36#define EP1_CMD_AUTO_MSG 0xb
37
38struct caiaq_device_spec {
39 unsigned short fw_version;
40 unsigned char hw_subtype;
41 unsigned char num_erp;
42 unsigned char num_analog_in;
43 unsigned char num_digital_in;
44 unsigned char num_digital_out;
45 unsigned char num_analog_audio_out;
46 unsigned char num_analog_audio_in;
47 unsigned char num_digital_audio_out;
48 unsigned char num_digital_audio_in;
49 unsigned char num_midi_out;
50 unsigned char num_midi_in;
51 unsigned char data_alignment;
52} __attribute__ ((packed));
53
54struct snd_usb_caiaq_cb_info;
55
56struct snd_usb_caiaqdev {
57 struct snd_usb_audio chip;
58
59 struct urb ep1_in_urb;
60 struct urb midi_out_urb;
61 struct urb **data_urbs_in;
62 struct urb **data_urbs_out;
63 struct snd_usb_caiaq_cb_info *data_cb_info;
64
65 unsigned char ep1_in_buf[EP1_BUFSIZE];
66 unsigned char ep1_out_buf[EP1_BUFSIZE];
67 unsigned char midi_out_buf[EP1_BUFSIZE];
68
69 struct caiaq_device_spec spec;
70 spinlock_t spinlock;
71 wait_queue_head_t ep1_wait_queue;
72 wait_queue_head_t prepare_wait_queue;
73 int spec_received, audio_parm_answer;
74
75 char vendor_name[CAIAQ_USB_STR_LEN];
76 char product_name[CAIAQ_USB_STR_LEN];
77 char serial[CAIAQ_USB_STR_LEN];
78
79 int n_streams, n_audio_in, n_audio_out;
80 int streaming, first_packet, output_running;
81 int audio_in_buf_pos[MAX_STREAMS];
82 int audio_out_buf_pos[MAX_STREAMS];
83 int period_in_count[MAX_STREAMS];
84 int period_out_count[MAX_STREAMS];
85 int input_panic, output_panic;
86 char *audio_in_buf, *audio_out_buf;
87 unsigned int samplerates;
88
89 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
90 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
91
92 /* Linux input */
93#ifdef CONFIG_SND_USB_CAIAQ_INPUT
94 struct input_dev *input_dev;
95#endif
96
97 /* ALSA */
98 struct snd_pcm *pcm;
99 struct snd_pcm_hardware pcm_info;
100 struct snd_rawmidi *rmidi;
101 struct snd_rawmidi_substream *midi_receive_substream;
102 struct snd_rawmidi_substream *midi_out_substream;
103};
104
105struct snd_usb_caiaq_cb_info {
106 struct snd_usb_caiaqdev *dev;
107 int index;
108};
109
110#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
111
112int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
113int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
114
115
116#endif /* CAIAQ_DEVICE_H */
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/caiaq-input.c
new file mode 100644
index 00000000000..3acd12db695
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-input.c
@@ -0,0 +1,246 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack, Tim Ruetz
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#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/input.h>
23#include <linux/usb.h>
24#include <linux/spinlock.h>
25#include <sound/driver.h>
26#include <sound/core.h>
27#include <sound/rawmidi.h>
28#include <sound/pcm.h>
29#include "caiaq-device.h"
30#include "caiaq-input.h"
31
32#ifdef CONFIG_SND_USB_CAIAQ_INPUT
33
34static unsigned char keycode_ak1[] = { KEY_C, KEY_B, KEY_A };
35static unsigned char keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4,
36 KEY_5, KEY_6, KEY_7 };
37
38#define DEG90 (range/2)
39#define DEG180 (range)
40#define DEG270 (DEG90 + DEG180)
41#define DEG360 (DEG180 * 2)
42#define HIGH_PEAK (268)
43#define LOW_PEAK (-7)
44
45/* some of these devices have endless rotation potentiometers
46 * built in which use two tapers, 90 degrees phase shifted.
47 * this algorithm decodes them to one single value, ranging
48 * from 0 to 999 */
49static unsigned int decode_erp(unsigned char a, unsigned char b)
50{
51 int weight_a, weight_b;
52 int pos_a, pos_b;
53 int ret;
54 int range = HIGH_PEAK - LOW_PEAK;
55 int mid_value = (HIGH_PEAK + LOW_PEAK) / 2;
56
57 weight_b = abs(mid_value-a) - (range/2 - 100)/2;
58
59 if (weight_b < 0)
60 weight_b = 0;
61
62 if (weight_b > 100)
63 weight_b = 100;
64
65 weight_a = 100 - weight_b;
66
67 if (a < mid_value) {
68 /* 0..90 and 270..360 degrees */
69 pos_b = b - LOW_PEAK + DEG270;
70 if (pos_b >= DEG360)
71 pos_b -= DEG360;
72 } else
73 /* 90..270 degrees */
74 pos_b = HIGH_PEAK - b + DEG90;
75
76
77 if (b > mid_value)
78 /* 0..180 degrees */
79 pos_a = a - LOW_PEAK;
80 else
81 /* 180..360 degrees */
82 pos_a = HIGH_PEAK - a + DEG180;
83
84 /* interpolate both slider values, depending on weight factors */
85 /* 0..99 x DEG360 */
86 ret = pos_a * weight_a + pos_b * weight_b;
87
88 /* normalize to 0..999 */
89 ret *= 10;
90 ret /= DEG360;
91
92 if (ret < 0)
93 ret += 1000;
94
95 if (ret >= 1000)
96 ret -= 1000;
97
98 return ret;
99}
100
101#undef DEG90
102#undef DEG180
103#undef DEG270
104#undef DEG360
105#undef HIGH_PEAK
106#undef LOW_PEAK
107
108
109static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev,
110 const char *buf, unsigned int len)
111{
112 switch(dev->input_dev->id.product) {
113 case USB_PID_RIGKONTROL2:
114 input_report_abs(dev->input_dev, ABS_X, (buf[4] << 8) |buf[5]);
115 input_report_abs(dev->input_dev, ABS_Y, (buf[0] << 8) |buf[1]);
116 input_report_abs(dev->input_dev, ABS_Z, (buf[2] << 8) |buf[3]);
117 input_sync(dev->input_dev);
118 break;
119 }
120}
121
122static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev,
123 const char *buf, unsigned int len)
124{
125 int i;
126
127 switch(dev->input_dev->id.product) {
128 case USB_PID_AK1:
129 i = decode_erp(buf[0], buf[1]);
130 input_report_abs(dev->input_dev, ABS_X, i);
131 input_sync(dev->input_dev);
132 break;
133 }
134}
135
136static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
137 char *buf, unsigned int len)
138{
139 int i;
140 unsigned char *keycode = dev->input_dev->keycode;
141
142 if (!keycode)
143 return;
144
145 if (dev->input_dev->id.product == USB_PID_RIGKONTROL2)
146 for (i=0; i<len; i++)
147 buf[i] = ~buf[i];
148
149 for (i=0; (i<dev->input_dev->keycodemax) && (i < len); i++)
150 input_report_key(dev->input_dev, keycode[i],
151 buf[i/8] & (1 << (i%8)));
152
153 input_sync(dev->input_dev);
154}
155
156void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev,
157 char *buf,
158 unsigned int len)
159{
160 if (!dev->input_dev || (len < 1))
161 return;
162
163 switch (buf[0]) {
164 case EP1_CMD_READ_ANALOG:
165 snd_caiaq_input_read_analog(dev, buf+1, len-1);
166 break;
167 case EP1_CMD_READ_ERP:
168 snd_caiaq_input_read_erp(dev, buf+1, len-1);
169 break;
170 case EP1_CMD_READ_IO:
171 snd_caiaq_input_read_io(dev, buf+1, len-1);
172 break;
173 }
174}
175
176int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
177{
178 struct usb_device *usb_dev = dev->chip.dev;
179 struct input_dev *input;
180 int i, ret;
181
182 input = input_allocate_device();
183 if (!input)
184 return -ENOMEM;
185
186 input->name = dev->product_name;
187 input->id.bustype = BUS_USB;
188 input->id.vendor = usb_dev->descriptor.idVendor;
189 input->id.product = usb_dev->descriptor.idProduct;
190 input->id.version = usb_dev->descriptor.bcdDevice;
191
192 switch (dev->chip.usb_id) {
193 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
194 input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
195 input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_Z);
196 input->keycode = keycode_rk2;
197 input->keycodesize = sizeof(char);
198 input->keycodemax = ARRAY_SIZE(keycode_rk2);
199 for (i=0; i<ARRAY_SIZE(keycode_rk2); i++)
200 set_bit(keycode_rk2[i], input->keybit);
201
202 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
203 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
204 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
205 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);
206 break;
207 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
208 input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
209 input->absbit[0] = BIT(ABS_X);
210 input->keycode = keycode_ak1;
211 input->keycodesize = sizeof(char);
212 input->keycodemax = ARRAY_SIZE(keycode_ak1);
213 for (i=0; i<ARRAY_SIZE(keycode_ak1); i++)
214 set_bit(keycode_ak1[i], input->keybit);
215
216 input_set_abs_params(input, ABS_X, 0, 999, 0, 10);
217 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5);
218 break;
219 default:
220 /* no input methods supported on this device */
221 input_free_device(input);
222 return 0;
223 }
224
225 ret = input_register_device(input);
226 if (ret < 0) {
227 input_free_device(input);
228 return ret;
229 }
230
231 dev->input_dev = input;
232 return 0;
233}
234
235void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev)
236{
237 if (!dev || !dev->input_dev)
238 return;
239
240 input_unregister_device(dev->input_dev);
241 input_free_device(dev->input_dev);
242 dev->input_dev = NULL;
243}
244
245#endif /* CONFIG_SND_USB_CAIAQ_INPUT */
246
diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/caiaq-input.h
new file mode 100644
index 00000000000..ced53557786
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-input.h
@@ -0,0 +1,8 @@
1#ifndef CAIAQ_INPUT_H
2#define CAIAQ_INPUT_H
3
4void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, char *buf, unsigned int len);
5int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev);
6void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev);
7
8#endif
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/caiaq-midi.c
new file mode 100644
index 00000000000..793ca20ce34
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-midi.c
@@ -0,0 +1,177 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack
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#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/interrupt.h>
23#include <linux/usb.h>
24#include <linux/input.h>
25#include <linux/spinlock.h>
26#include <sound/driver.h>
27#include <sound/core.h>
28#include <sound/rawmidi.h>
29#include <sound/pcm.h>
30
31#include "caiaq-device.h"
32#include "caiaq-midi.h"
33
34
35static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream)
36{
37 return 0;
38}
39
40static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substream)
41{
42 return 0;
43}
44
45static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
46{
47 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
48
49 if (!dev)
50 return;
51
52 dev->midi_receive_substream = up ? substream : NULL;
53}
54
55
56static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substream)
57{
58 return 0;
59}
60
61static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
62{
63 return 0;
64}
65
66static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
67 struct snd_rawmidi_substream *substream)
68{
69 int len, ret;
70
71 dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
72 dev->midi_out_buf[1] = 0; /* port */
73 len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
74
75 if (len <= 0)
76 return;
77
78 dev->midi_out_buf[2] = len;
79 dev->midi_out_urb.transfer_buffer_length = len+3;
80
81 ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
82 if (ret < 0)
83 log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
84 substream, ret);
85}
86
87static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
88{
89 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
90
91 if (dev->midi_out_substream != NULL)
92 return;
93
94 if (!up) {
95 dev->midi_out_substream = NULL;
96 return;
97 }
98
99 dev->midi_out_substream = substream;
100 snd_usb_caiaq_midi_send(dev, substream);
101}
102
103
104static struct snd_rawmidi_ops snd_usb_caiaq_midi_output =
105{
106 .open = snd_usb_caiaq_midi_output_open,
107 .close = snd_usb_caiaq_midi_output_close,
108 .trigger = snd_usb_caiaq_midi_output_trigger,
109};
110
111static struct snd_rawmidi_ops snd_usb_caiaq_midi_input =
112{
113 .open = snd_usb_caiaq_midi_input_open,
114 .close = snd_usb_caiaq_midi_input_close,
115 .trigger = snd_usb_caiaq_midi_input_trigger,
116};
117
118void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev,
119 int port, const char *buf, int len)
120{
121 if (!dev->midi_receive_substream)
122 return;
123
124 snd_rawmidi_receive(dev->midi_receive_substream, buf, len);
125}
126
127int __devinit snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
128{
129 int ret;
130 struct snd_rawmidi *rmidi;
131
132 ret = snd_rawmidi_new(device->chip.card, device->product_name, 0,
133 device->spec.num_midi_out,
134 device->spec.num_midi_in,
135 &rmidi);
136
137 if (ret < 0)
138 return ret;
139
140 strcpy(rmidi->name, device->product_name);
141
142 rmidi->info_flags = SNDRV_RAWMIDI_INFO_DUPLEX;
143 rmidi->private_data = device;
144
145 if (device->spec.num_midi_out > 0) {
146 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
147 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
148 &snd_usb_caiaq_midi_output);
149 }
150
151 if (device->spec.num_midi_in > 0) {
152 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
153 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
154 &snd_usb_caiaq_midi_input);
155 }
156
157 device->rmidi = rmidi;
158
159 return 0;
160}
161
162void snd_usb_caiaq_midi_output_done(struct urb* urb)
163{
164 struct snd_usb_caiaqdev *dev = urb->context;
165 char *buf = urb->transfer_buffer;
166
167 if (urb->status != 0)
168 return;
169
170 if (!dev->midi_out_substream)
171 return;
172
173 snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
174 dev->midi_out_substream = NULL;
175 snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
176}
177
diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/caiaq-midi.h
new file mode 100644
index 00000000000..9d16db027fc
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-midi.h
@@ -0,0 +1,8 @@
1#ifndef CAIAQ_MIDI_H
2#define CAIAQ_MIDI_H
3
4int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev);
5void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len);
6void snd_usb_caiaq_midi_output_done(struct urb* urb);
7
8#endif /* CAIAQ_MIDI_H */
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index b6d886373bb..7bd5852fcc0 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1878,6 +1878,9 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1878 } 1878 }
1879 1879
1880 /* set the period time minimum 1ms */ 1880 /* set the period time minimum 1ms */
1881 /* FIXME: high-speed mode allows 125us minimum period, but many parts
1882 * in the current code assume the 1ms period.
1883 */
1881 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1884 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1882 1000 * MIN_PACKS_URB, 1885 1000 * MIN_PACKS_URB,
1883 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1886 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);
@@ -2347,7 +2350,9 @@ static int is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *
2347 return 1; 2350 return 1;
2348 break; 2351 break;
2349 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ 2352 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
2350 return 1; 2353 if (device_setup[chip->index] == 0x00 ||
2354 fp->altsetting==1 || fp->altsetting==2 || fp->altsetting==3)
2355 return 1;
2351 } 2356 }
2352 return 0; 2357 return 0;
2353} 2358}
@@ -2527,7 +2532,18 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *
2527 * but we give normal PCM format to get the existing 2532 * but we give normal PCM format to get the existing
2528 * apps working... 2533 * apps working...
2529 */ 2534 */
2530 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 2535 switch (chip->usb_id) {
2536
2537 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
2538 if (device_setup[chip->index] == 0x00 &&
2539 fp->altsetting == 6)
2540 pcm_format = SNDRV_PCM_FORMAT_S16_BE;
2541 else
2542 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
2543 break;
2544 default:
2545 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
2546 }
2531 } else { 2547 } else {
2532 pcm_format = parse_audio_format_i_type(chip, fp, format, fmt); 2548 pcm_format = parse_audio_format_i_type(chip, fp, format, fmt);
2533 if (pcm_format < 0) 2549 if (pcm_format < 0)
@@ -3248,6 +3264,11 @@ static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
3248static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 3264static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
3249 int iface, int altno) 3265 int iface, int altno)
3250{ 3266{
3267 /* Reset ALL ifaces to 0 altsetting.
3268 * Call it for every possible altsetting of every interface.
3269 */
3270 usb_set_interface(chip->dev, iface, 0);
3271
3251 if (device_setup[chip->index] & AUDIOPHILE_SET) { 3272 if (device_setup[chip->index] & AUDIOPHILE_SET) {
3252 if ((device_setup[chip->index] & AUDIOPHILE_SET_DTS) 3273 if ((device_setup[chip->index] & AUDIOPHILE_SET_DTS)
3253 && altno != 6) 3274 && altno != 6)
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 24f5a26c5f0..99295f9b769 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * usbmidi.c - ALSA USB MIDI driver 2 * usbmidi.c - ALSA USB MIDI driver
3 * 3 *
4 * Copyright (c) 2002-2005 Clemens Ladisch 4 * Copyright (c) 2002-2007 Clemens Ladisch
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on the OSS usb-midi driver by NAGANO Daisuke, 7 * Based on the OSS usb-midi driver by NAGANO Daisuke,
@@ -145,6 +145,7 @@ struct snd_usb_midi_in_endpoint {
145 struct urb* urb; 145 struct urb* urb;
146 struct usbmidi_in_port { 146 struct usbmidi_in_port {
147 struct snd_rawmidi_substream *substream; 147 struct snd_rawmidi_substream *substream;
148 u8 running_status_length;
148 } ports[0x10]; 149 } ports[0x10];
149 u8 seen_f5; 150 u8 seen_f5;
150 u8 error_resubmit; 151 u8 error_resubmit;
@@ -366,6 +367,46 @@ static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep,
366} 367}
367 368
368/* 369/*
370 * Buggy M-Audio device: running status on input results in a packet that has
371 * the data bytes but not the status byte and that is marked with CIN 4.
372 */
373static void snd_usbmidi_maudio_broken_running_status_input(
374 struct snd_usb_midi_in_endpoint* ep,
375 uint8_t* buffer, int buffer_length)
376{
377 int i;
378
379 for (i = 0; i + 3 < buffer_length; i += 4)
380 if (buffer[i] != 0) {
381 int cable = buffer[i] >> 4;
382 u8 cin = buffer[i] & 0x0f;
383 struct usbmidi_in_port *port = &ep->ports[cable];
384 int length;
385
386 length = snd_usbmidi_cin_length[cin];
387 if (cin == 0xf && buffer[i + 1] >= 0xf8)
388 ; /* realtime msg: no running status change */
389 else if (cin >= 0x8 && cin <= 0xe)
390 /* channel msg */
391 port->running_status_length = length - 1;
392 else if (cin == 0x4 &&
393 port->running_status_length != 0 &&
394 buffer[i + 1] < 0x80)
395 /* CIN 4 that is not a SysEx */
396 length = port->running_status_length;
397 else
398 /*
399 * All other msgs cannot begin running status.
400 * (A channel msg sent as two or three CIN 0xF
401 * packets could in theory, but this device
402 * doesn't use this format.)
403 */
404 port->running_status_length = 0;
405 snd_usbmidi_input_data(ep, cable, &buffer[i + 1], length);
406 }
407}
408
409/*
369 * Adds one USB MIDI packet to the output buffer. 410 * Adds one USB MIDI packet to the output buffer.
370 */ 411 */
371static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0, 412static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0,
@@ -525,6 +566,12 @@ static struct usb_protocol_ops snd_usbmidi_midiman_ops = {
525 .output_packet = snd_usbmidi_output_midiman_packet, 566 .output_packet = snd_usbmidi_output_midiman_packet,
526}; 567};
527 568
569static struct usb_protocol_ops snd_usbmidi_maudio_broken_running_status_ops = {
570 .input = snd_usbmidi_maudio_broken_running_status_input,
571 .output = snd_usbmidi_standard_output,
572 .output_packet = snd_usbmidi_output_standard_packet,
573};
574
528/* 575/*
529 * Novation USB MIDI protocol: number of data bytes is in the first byte 576 * Novation USB MIDI protocol: number of data bytes is in the first byte
530 * (when receiving) (+1!) or in the second byte (when sending); data begins 577 * (when receiving) (+1!) or in the second byte (when sending); data begins
@@ -918,7 +965,11 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
918 } 965 }
919 /* we never use interrupt output pipes */ 966 /* we never use interrupt output pipes */
920 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); 967 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep);
921 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); 968 if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */
969 /* FIXME: we need more URBs to get reasonable bandwidth here: */
970 ep->max_transfer = 4;
971 else
972 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1);
922 buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer, 973 buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer,
923 GFP_KERNEL, &ep->urb->transfer_dma); 974 GFP_KERNEL, &ep->urb->transfer_dma);
924 if (!buffer) { 975 if (!buffer) {
@@ -1606,6 +1657,9 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1606 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) { 1657 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) {
1607 case QUIRK_MIDI_STANDARD_INTERFACE: 1658 case QUIRK_MIDI_STANDARD_INTERFACE:
1608 err = snd_usbmidi_get_ms_info(umidi, endpoints); 1659 err = snd_usbmidi_get_ms_info(umidi, endpoints);
1660 if (chip->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */
1661 umidi->usb_protocol_ops =
1662 &snd_usbmidi_maudio_broken_running_status_ops;
1609 break; 1663 break;
1610 case QUIRK_MIDI_FIXED_ENDPOINT: 1664 case QUIRK_MIDI_FIXED_ENDPOINT:
1611 memcpy(&endpoints[0], quirk->data, 1665 memcpy(&endpoints[0], quirk->data,
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 7b3bf3545a3..325d4b6b54a 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -360,7 +360,7 @@ static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali
360 request, 360 request,
361 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 361 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
362 validx, cval->mixer->ctrlif | (cval->id << 8), 362 validx, cval->mixer->ctrlif | (cval->id << 8),
363 buf, val_len, 100) >= 0) { 363 buf, val_len, 100) >= val_len) {
364 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); 364 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
365 return 0; 365 return 0;
366 } 366 }
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 858262068f4..5a2f518c662 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -40,6 +40,56 @@
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* 42/*
43 * Logitech QuickCam: bDeviceClass is vendor-specific, so generic interface
44 * class matches do not take effect without an explicit ID match.
45 */
46{
47 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
48 USB_DEVICE_ID_MATCH_INT_CLASS |
49 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
50 .idVendor = 0x046d,
51 .idProduct = 0x0850,
52 .bInterfaceClass = USB_CLASS_AUDIO,
53 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
54},
55{
56 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
57 USB_DEVICE_ID_MATCH_INT_CLASS |
58 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
59 .idVendor = 0x046d,
60 .idProduct = 0x08ae,
61 .bInterfaceClass = USB_CLASS_AUDIO,
62 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
63},
64{
65 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
66 USB_DEVICE_ID_MATCH_INT_CLASS |
67 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
68 .idVendor = 0x046d,
69 .idProduct = 0x08c6,
70 .bInterfaceClass = USB_CLASS_AUDIO,
71 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
72},
73{
74 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
75 USB_DEVICE_ID_MATCH_INT_CLASS |
76 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
77 .idVendor = 0x046d,
78 .idProduct = 0x08f0,
79 .bInterfaceClass = USB_CLASS_AUDIO,
80 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
81},
82{
83 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
84 USB_DEVICE_ID_MATCH_INT_CLASS |
85 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
86 .idVendor = 0x046d,
87 .idProduct = 0x08f6,
88 .bInterfaceClass = USB_CLASS_AUDIO,
89 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
90},
91
92/*
43 * Yamaha devices 93 * Yamaha devices
44 */ 94 */
45 95
@@ -1019,7 +1069,15 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1019 .type = QUIRK_MIDI_STANDARD_INTERFACE 1069 .type = QUIRK_MIDI_STANDARD_INTERFACE
1020 } 1070 }
1021}, 1071},
1022 /* TODO: add Roland EXR support */ 1072{
1073 USB_DEVICE(0x0582, 0x0060),
1074 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1075 .vendor_name = "Roland",
1076 .product_name = "EXR Series",
1077 .ifnum = 0,
1078 .type = QUIRK_MIDI_STANDARD_INTERFACE
1079 }
1080},
1023{ 1081{
1024 /* has ID 0x0067 when not in "Advanced Driver" mode */ 1082 /* has ID 0x0067 when not in "Advanced Driver" mode */
1025 USB_DEVICE(0x0582, 0x0065), 1083 USB_DEVICE(0x0582, 0x0065),
@@ -1062,6 +1120,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1062 } 1120 }
1063 } 1121 }
1064}, 1122},
1123{
1124 USB_DEVICE(0x582, 0x00a6),
1125 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1126 .vendor_name = "Roland",
1127 .product_name = "Juno-G",
1128 .ifnum = 0,
1129 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1130 .data = & (const struct snd_usb_midi_endpoint_info) {
1131 .out_cables = 0x0001,
1132 .in_cables = 0x0001
1133 }
1134 }
1135},
1065{ /* 1136{ /*
1066 * This quirk is for the "Advanced" modes of the Edirol UA-25. 1137 * This quirk is for the "Advanced" modes of the Edirol UA-25.
1067 * If the switch is not in an advanced setting, the UA-25 has 1138 * If the switch is not in an advanced setting, the UA-25 has
@@ -1198,6 +1269,37 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1198 } 1269 }
1199}, 1270},
1200 /* TODO: add Edirol MD-P1 support */ 1271 /* TODO: add Edirol MD-P1 support */
1272{
1273 /* Roland SH-201 */
1274 USB_DEVICE(0x0582, 0x00ad),
1275 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1276 .vendor_name = "Roland",
1277 .product_name = "SH-201",
1278 .ifnum = QUIRK_ANY_INTERFACE,
1279 .type = QUIRK_COMPOSITE,
1280 .data = (const struct snd_usb_audio_quirk[]) {
1281 {
1282 .ifnum = 0,
1283 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1284 },
1285 {
1286 .ifnum = 1,
1287 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1288 },
1289 {
1290 .ifnum = 2,
1291 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1292 .data = & (const struct snd_usb_midi_endpoint_info) {
1293 .out_cables = 0x0001,
1294 .in_cables = 0x0001
1295 }
1296 },
1297 {
1298 .ifnum = -1
1299 }
1300 }
1301 }
1302},
1201 1303
1202/* Guillemot devices */ 1304/* Guillemot devices */
1203{ 1305{
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 0a352e46862..48e9aa3f18c 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -935,10 +935,9 @@ static struct snd_pcm_ops snd_usX2Y_pcm_ops =
935 */ 935 */
936static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream) 936static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream)
937{ 937{
938 if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { 938 kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
939 kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); 939 usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
940 usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL; 940
941 }
942 kfree(usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]); 941 kfree(usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]);
943 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; 942 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL;
944} 943}