GIT 3edcb88c312bc8d8a19f846a3a70bc0227dbda44 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/perex/alsa.git#mm commit Author: Randy Cushman Date: Fri Dec 22 12:44:25 2006 +0100 [ALSA] ac97 - fix various issues with AD1986/AD1986A support Previously, ac97_codec.c was coded to support AD1986 and AD1986A CODECs using code written for the AD1985 CODEC. This allowed the LINE_OUT and HEADPHONE jacks to function properly, however register differences between the CODECs prevented line and microphone inputs from functioning. Specifically, this patch fixes issues with the following mixer controls: 'V_REFOUT', 'Spread Front to Surround and Center/LFE', 'Exchange Front/Surround', 'Surround Jack Mode', and 'Channel Mode'. This patch removes the undocumented AD1888 control 'High Pass Filter Enable' and adds the new control 'Exchange Mic/Line In'. Signed-off-by: Randy Cushman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 43764937466a04844984bc7231b4cc8fad5831bd Author: Randy Cushman Date: Thu Dec 21 19:17:29 2006 +0100 [ALSA] ac97 - fix malfunctioning mixer controls for AD1985 This patch replaces the 'V_REFOUT Enable' mixer switch control with a listbox control for the AD1985 CODEC. Previous patch 'AD1888 mixer controls for DC mode' added controls that were propogated to multiple codecs. For the AD1985 codec, the bits VREFH and VREFD function differently, preventing the 'V_REFOUT Enable' control from setting V_REFOUT to Hi-Z. This patch also corrects an issue in which register bits relating to mixer controls 'Surround Jack Mode' and 'Channel Mode'. The register bits controlled by these controls were being set at boot time to states inconsistent with the stored values of these controls. Signed-off-by: Randy Cushman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f05edfe43a12a6faa23b8e397535537756053c95 Author: Takashi Iwai Date: Thu Dec 21 11:02:06 2006 +0100 [ALSA] soc - Fix delayed_work related changes on 2.6.20 kernel Fix the changes realted to delayed_work in soc/codecs/wm8750.c. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c969c31243f4fab957f581cad33f868fe765203f Author: Timofei V. Bondarenko Date: Wed Dec 20 19:20:07 2006 +0100 [ALSA] _snd_cmipci_uswitch_put doesn't set zero flags Playing with spdif output on cmipci i've noticed the SPDO5V option does not change appropriate bits the register. The _snd_cmipci_uswitch_put checks the change in flags in wrong way. If 'active' state of an option corresponds to a _zero_ bits in a hw register then function fails. The SPDO5V is the sample. In the most cases 'active' state of option is set through an non-zerio bits in a register. This case works fine. The fix attached. Unfortunately i was unable to change spdif output voltage anyway. Although the register changes right at least. From: Timofei V. Bondarenko Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ea4179d98c2dfd2de7250025b56e228aa35b78bc Author: Randy Cushman Date: Tue Dec 19 18:42:16 2006 +0100 [ALSA] ac97 - fix microphone and line_in selection logic This patch fixes the Microphone and LINE_IN select logic for Analog Devices surround codecs with shared jacks. The existing code can never utilize the shared jacks for Microphone and LINE_IN due to the reversed jack selection logic. The patched code correctly selects the shared jack for input if the 'Channel Mode' selector does not specify that the jack is to be used for output. Specifically, in '2ch' mode the Center/LFE jack is used for microphone input and the Surround jack is used for LINE_IN, in '4ch' mode the Center/LFE jack is used for microphone input and the Surround jack is used for output, and in '6ch' mode both jacks are used for output. Signed-off-by: Randy Cushman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f7c2ae32a2478989432a2df754c5c07ab168a0e0 Author: Takashi Iwai Date: Tue Dec 19 17:16:14 2006 +0100 [ALSA] soc - Use global workqueue Use global workqueue for simplicity instead of own workqueue in SoC core and wm8750 codes. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ffa1764d3696fa6941676459c65af2939f05a0f6 Author: Takashi Iwai Date: Tue Dec 19 17:13:16 2006 +0100 [ALSA] ak4114 - Use global workqueue Use global workqueue for simplicity instead of own workqueue. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 53186214173409f1c82580545a26a43b57a740aa Author: Takashi Iwai Date: Tue Dec 19 17:08:52 2006 +0100 [ALSA] hda-codec - Use global workqueue Use global workqueue for simplicity. The unsolicited event frequency isn't so high to have own queue. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ddbc16f3781cae83997bef3f4af2e9196533194a Author: Robert P. J. Day Date: Tue Dec 19 14:44:15 2006 +0100 [ALSA] sound: Change final two instances of kcalloc(1,...) to kzalloc() Change the two remaining instances in the tree of kcalloc(1,...) to the corresponding kzalloc() call. Signed-off-by: Robert P. J. Day Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit e0c3f3d9e84afbc41e34d6998bffee7557fcf815 Author: James C Georgas Date: Tue Dec 19 11:09:41 2006 +0100 [ALSA] Remove AC97 POP control for STAC9708/11 The STAC9708/11 AC97 codecs implement the PCM Out Path & Mute bit in the General Purpose register (0x20:F), even though they don't implement the actual function in the mixer. Since the alsa tests for the function by toggling the bit and reading it back to see if it changed, it mistakenly creates a useless control. This patch explicitly removes the control when the codec is an STAC9708/11. I put the check in patch_sigmatel_stac9708_specific(), because I have an SBLive with this chip on it. I don't know if the STAC9758 or other codecs also behave this way. If they do, then this check could maybe go in patch_sigmatel_stac97xx_specific(), or some other more general function. Signed-off-by: James C Georgas Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ed408c336dd4926b63578d398af59274e9107397 Author: Takashi Iwai Date: Mon Dec 18 16:16:04 2006 +0100 [ALSA] hda-codec - Fix NULL dereference in generic hda code Fix NULL dereference in hda_generic.c. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 9f915c703fd391cbaef25c5339dd3dca8585c0f2 Author: Krzysztof Helt Date: Mon Dec 18 14:41:03 2006 +0100 [ALSA] sparc dbri comment fix This is a comment fix to avoid misleading about locking in the dbri_cmdsend. Signed-off-by: Krzysztof Helt Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f022a82cfe4416ceebda2be98eecf1a7cafe629a Author: Liam Girdwood Date: Mon Dec 18 14:39:02 2006 +0100 [ALSA] Additional credits to soc-core This patch adds copyright and credit for my good friend Richard Purdie from OpenedHand for his help and code contribution throughout the development of the core code. Many thanks Richard (I guess we overlooked this in trying to get everything working well). It also adds some extra comments wrt to DAI clock matching. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit a814fc039d509e77a7c0f6477345c33a4f0f0cc1 Author: Liam Girdwood Date: Mon Dec 18 14:38:37 2006 +0100 [ALSA] Remove trailing white space from wm9712.c This patch removes some trailing white space from the WM9712 ASoC codec driver. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 383ea3d6bf5e89442f17e741ea7e6ce2f0322666 Author: Tobin Davis Date: Mon Dec 18 13:24:37 2006 +0100 [ALSA] hda-codec - Add quirk for Turbo-X Coeus G610P This patch adds the Turbo-X Coeus G610P to the alc880 config table, based on user provided information. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 2bf4ac909144ceb1aa7b72342759fb9a8d4df1b5 Author: Johannes Berg Date: Mon Dec 18 13:20:06 2006 +0100 [ALSA] snd-aoa: fix onyx resume When the machine resumes the onyx codec might be in a weird state. Hence, simply fully reset it once (and keep the code to take it out of suspend in case the suspend of the codec chip survives a reset). Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit cbbf4757d3f8cd8f5f4915807026202e16c2b629 Author: Matt Porter Date: Mon Dec 18 13:17:28 2006 +0100 [ALSA] hda: add sigmatel 9205 eapd support Adds support for handling EAPD on 9205 codecs Signed-off-by: Matt Porter Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit d26d23ef85cdb7a6fd48e49f3d0eb82513c24f87 Author: Toshimune Konno Date: Mon Dec 18 13:12:18 2006 +0100 [ALSA] ice1724 - Add support for Prodigy 7.1 XT This patch supports Audiotrack 7.1 XT. 7.1XT is almost same hardware as 7.1LT. so using 7.1 LT's code. Signed-off-by: Toshimune Konno Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 90ebc182e186937e06d8cf84b3e6356c9e02055b Author: Takashi Iwai Date: Mon Dec 18 13:07:35 2006 +0100 [ALSA] Fix AC97_BUS in soc/pxa/Kconfig Fixed the renamed AC97_BUS in soc/pxa/Kconfig file. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5948a846a254e71cb771024b4d7fb7653a624da5 Author: Tobin Davis Date: Fri Dec 15 10:02:12 2006 +0100 [ALSA] hda-codec (realtek): add support for MacPro series workstations This patch adds limited support for Intel-based MacPro workstations. Currently, the front headphone jack is not functioning, but line out and line in are working. S/PDIF not tested. Signed-off-by: Tobin Davis Signed-off-by: Jaroslav Kysela commit bd453b95edde3a02a552def592e56a206d832fe2 Author: Andrew Morton Date: Fri Dec 15 09:30:07 2006 +0100 [ALSA] Fix the soc code after dhowells workqueue changes. From: Andrew Morton I converted the workqueues to per-device while I was there. It seems strange to create a new kernel thread (on each CPU!) and to then only have a single global work to ever be queued upon it. Plus without this, I'd have to use the _NAR stuff, gawd help me. Does that workqueue really need to be per-cpu? Does that workqueue really need to exist? Why not use keventd? Cc: Takashi Iwai Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit b09fbc59f366ed826797f17b5b05631b808a258a Author: Andrew Morton Date: Fri Dec 15 09:26:20 2006 +0100 [ALSA] ucb1400_ts.c compilation fix (struct snd_ac97) From: Andrew Morton Cc: Takashi Iwai Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit e26a6190e35352f13bb1d66dec3a90b4cf689f5d Author: James Courtier-Dutton Date: Wed Dec 13 11:21:55 2006 +0000 [ALSA] emu10k1: Update registers defines for the Audigy 2/emu10k2.5 Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 5be11f4cb6b6e3f4d552ce5333fe24f4b07363f3 Author: James Courtier-Dutton Date: Sun Dec 10 00:00:38 2006 +0000 [ALSA] ca0106: Fix sound capture on Audigy LS via AC97. Fixes ALSA bug#2286 Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 0aa66097ea801bcc5488b7ec5250369b7d65f1eb Author: Andrew Morton Date: Thu Dec 7 08:26:27 2006 +0100 [ALSA] arm header fix Cc: Takashi Iwai Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit fa154ecb31e136818ca281589eac873fe55bb9fd Author: Olaf Hering Date: Thu Dec 7 08:25:01 2006 +0100 [ALSA] create driver symlink in snd-aoa /sys/bus/aoa-soundbus/devices/*/ create sysfs driver symlink for snd-aoa in /sys/bus/aoa-soundbus/devices/*/ Acked-by: Johannes Berg Signed-off-by: Olaf Hering Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit 7978b5ce19144dccb430c7ffba457955ed7e8745 Author: Olaf Hering Date: Thu Dec 7 08:24:12 2006 +0100 [ALSA] create device symlink in snd-aoa create sysfs device symlinks for snd-aoa in /sys/class/sound/controlC0 This allows hald to recognize the device as sound device. Furthermore it allows the desktop user to actually access the sound device nodes. hald and related packages will modify the acl attributes. Fixes https://bugzilla.novell.com/show_bug.cgi?id=106294 Acked-by: Johannes Berg Signed-off-by: Olaf Hering Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit 4a5d83efd4b70ee480e53983a72705ab15b98037 Author: Randy Dunlap Date: Thu Dec 7 08:22:50 2006 +0100 [ALSA] add struct snd_pcm_substream forward declaration fixes: include/sound/pcm.h:62: warning: 'struct snd_pcm_substream' declared inside parameter list Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Jaroslav Kysela commit acb6583a31c21f7bacaf768cf7bec2498201d14b Author: James Courtier-Dutton Date: Wed Dec 6 20:38:45 2006 +0000 [ALSA] emu10k1: Rename the digital optical capture control for the Audigy 2 ZS Notebook. Digital playback and capture now works, but it is not bit accurate because it passes through a resampler. Bit accurate playback and capture will be implemented later via the p17v. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 5bddea6955512c2a72c9afc8d49a9bb50c8a7493 Author: James Courtier-Dutton Date: Wed Dec 6 15:58:02 2006 +0000 [ALSA] emu10k1: Add Audio capture support for Audigy 2 ZS Notebook. Implement functionallity in order to fixe ALSA bug#2058. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit a5200e941f0009a3fb56bfbb846aa02ec20ea70a Author: Teru KAMOGASHIRA Date: Mon Dec 4 18:03:53 2006 +0100 [ALSA] Current driver does not utilize 44.1kHz high quality sampling rate converter. Following patch will make the driver to use the 44.1kHz SRC automatically if the pcm source is 44.1kHz signed 16bit stereo. The SRC is available in YMF754 only. Signed-off-by: Teru KAMOGASHIRA Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 035c933e5e3976debd5f2f5e4a2c46666a66f4fa Author: Joseph Chan Date: Wed Nov 29 15:29:40 2006 +0100 [ALSA] hda-codec - Add support for VIA VT1708(A) HD audio codec This patch is VIA first release for HD audio codec, VT1708(A) and it provides geneneral HD audio driver features. Signed-off-by: Joseph Chan Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 18205093e37ff0c167abb81278eb7790933a0a8b Author: Takashi Iwai Date: Tue Nov 28 17:18:25 2006 +0100 [ALSA] Add description about spdif_aclink option for snd-intel8x0 Added a description about spdif_aclink option for snd-intel8x0 driver in ALSA-Configuration.txt. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit d89afa4aa457909db3ccc557a4052a89101254cc Author: Adrian Bunk Date: Tue Nov 28 12:10:09 2006 +0100 [ALSA] sound/soc/soc-dapm.c: make 4 functions static Make the following needlessly global functions static: - dapm_power_widgets() - dapm_mux_update_power() - dapm_mixer_update_power() - dapm_free_widgets() Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 107fc5647f9e4115cd2e28570f5d1536f6555755 Author: Jonathan Woithe Date: Tue Nov 28 11:35:52 2006 +0100 [ALSA] hda-codec - Make internal speaker work on Acer C20x tablets The following patch creates a new 'Mono speaker' control in alsamixer when the Realtek 'acer' model is used with hda_intel. This is needed so the internal mono speaker (when present) can be controlled. This new control won't do anything in Acer laptops which are not fitted with a mono speaker. Acer models which are known to have a mono speaker are the C20x tablet series but there may be others. I guess we could define a new model specifically for Acers with mono speakers but this seems a bit silly given that such a model will be identical to the normal 'acer' model except for this added control. This patch also adds the C20x tablets to the list of PCI ids associated with the 'acer' model. This means that owners of C20x machines will no longer have to supply 'model=acer' when loading hda_intel. Signed-off-by: Jonathan Woithe Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit cebc82fcd5eeb042c1f5aed302fa063891604df2 Author: Takashi Iwai Date: Tue Nov 28 11:33:10 2006 +0100 [ALSA] hda-codec - Fix compile warnings without CONFIG_SND_DEBUG Fix compile warnings (unused variables) in patch_conexant.c without CONFIG_SND_DEBUG. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 2a1193d536d91ac9766167399f62cbf8cad4ced2 Author: Philipp Zabel Date: Mon Nov 27 12:05:04 2006 +0100 [ALSA] ASoC - Bit clock matching error This patch by Philipp Zabel fixes a bug whereby the BCLK matching fails when the Codec BCLK is constant and the CPU BCLK is based upon a divider. Signed-off-by: Philipp Zabel Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 36dc6a18aab33be360fd2ae0fd6be21ad4ef5fd1 Author: Takashi Iwai Date: Fri Nov 24 17:07:44 2006 +0100 [ALSA] hda-codec - Use snd_pci_quirk_lookup() for board config lookup Use snd_pci_quirk_lookup() for looking up a board config table. The config table is sorted in numerical order of PCI SSIDs. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit edfdfe998fc80f8ec93cb3ab0ea7edf69e0c96b2 Author: Takashi Iwai Date: Fri Nov 24 16:13:57 2006 +0100 [ALSA] Clean up serial-u16500.c Remove uesless typedefs and clean up the code a bit to follow the standard coding style. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 9840ca87844bb56d66efd2aaee155de039ce587f Author: Takashi Iwai Date: Fri Nov 24 16:12:50 2006 +0100 [ALSA] Fix documentation of ASoC Fixed obsolete *_t typedefs in ASoC documentation. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3b0edcd46846c012a2fa20c09c32c0dd9ed2e944 Author: Frank Mandarino Date: Fri Nov 24 15:49:39 2006 +0100 [ALSA] Update AT91 ASoC driver for 2.6.19 kernel. Changes were required to support latest AT91 header files. Also updated to remove AT91RM9200-specific code in the ASoC platform drivers to support the AT91SAM9260 and AT91SAM9261 chips, but no testing was performed on these chips. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit dee363674c69cd967a1266afe40990f120e02826 Author: Takashi Iwai Date: Fri Nov 24 15:42:07 2006 +0100 [ALSA] intel8x0 - Add spdif_aclink option Added spdif_aclink module option to specify whether the board has SPDIF over AC-link or a direct connection from the controller chip. NForce and ICH4 (or newer) boards may be equipped with SPDIF through AC97 codec. In such a case, SPDIF should be handled as if the old ICH style (the same slot for analog and digital). A quirk list is added to detect this automatically for known hardwares. Corresponds to ALSA bug#2637. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3938ef5c4280c48bf5decc5fd096b77f857fa531 Author: Takashi Iwai Date: Fri Nov 24 15:38:18 2006 +0100 [ALSA] ens1371 - Clean up quirks Clean up quirks in snd-ens1371 driver using snd_pci_quirk_lookup(). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 0d029b1bf9a51b96b53e4cc8eff948ffb173c65c Author: Takashi Iwai Date: Fri Nov 24 15:37:18 2006 +0100 [ALSA] via82xx - Use quirk list helper function Clean up dxs_support quirk list using snd_pci_quirk_lookup(). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5538f4e2312e2d61691508a9051c8d0247199be3 Author: Takashi Iwai Date: Fri Nov 24 15:36:46 2006 +0100 [ALSA] maestro3 - Use quirk list helper function Clean up maestro3 amp and GPIO quirks using snd_pci_quirk_lookup(). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 38d1774425c9e4145a0d5e7c06d209c7cca5e342 Author: Takashi Iwai Date: Fri Nov 24 15:36:13 2006 +0100 [ALSA] nm256 - Use quirk list helper function Clean up nm256-quirk lookup using snd_pci_quirk_lookup(). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3bc695e61eb6e6b1937c2022e2d5fbbc52e5facb Author: Takashi Iwai Date: Fri Nov 24 15:35:18 2006 +0100 [ALSA] atiixp - Use quirk list helper function Clean up ac97_codec quirk using snd_pci_quirk_lookup(). Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 28b8336f30d5b4ebce1b608e9c03950c77a01923 Author: Takashi Iwai Date: Fri Nov 24 15:34:06 2006 +0100 [ALSA] Add PCI quirk list helper function Added a helper function snd_pci_quirk_lookup() to look up PCI SSID quirk list. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 9dafff7d4b34da44e94045c4a91985aea9d5ab90 Author: Giuliano Pochini Date: Fri Nov 24 13:03:58 2006 +0100 [ALSA] echoaudio, add TLV support This patch adds TLV support to the echoaudio driver. All gains are in the range -127dB to +6dB with steps of 1dB, and -128 is mute. VU-meters levels go from -128 to 0dB. The input gain of the Layla20 ranges from -25dB to +25dB in steps of 0.5dB. Signed-off-by: Giuliano Pochini Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 17f23bb3d312615681b50907fccdcfe999d083aa Author: Takashi Iwai Date: Thu Nov 23 19:27:12 2006 +0100 [ALSA] Fix obsolete *_t typedefs Fixed obsolete *_t typedefs. Now completely removed. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 26877587475bf39e7a37b9ed41d3aeebb49841f5 Author: Takashi Iwai Date: Thu Nov 23 18:37:00 2006 +0100 [ALSA] Remove obsolete typedefs.h Removed obsolete typedefs.h. It existes only for backward compatibility, and now all codes should be free from such typedefs. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit cf2e8293bca235bcba81c1a153370a1ac25e2bcb Author: Jason Gaston Date: Wed Nov 22 11:53:52 2006 +0100 [ALSA] hda_intel: ALSA HD Audio patch for Intel ICH9 This patch adds the Intel ICH9 HD Audio controller DID's for ALSA. Signed-off-by: Jason Gaston Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 07a0d5dd353f0c7e5669f6b6127e52df6c6b79a5 Author: Takashi Iwai Date: Wed Nov 22 11:52:52 2006 +0100 [ALSA] hda-codec - Add asus-laptop model for ALC861 (ALC660) Added a new model 'asus-laptop' for ASUS F2*/F3* laptops with ALC861 (equivalent with ALC660) codec chip. Also fixed the model for PCI SSID 1043:1338. Corresponding to ALSA bug#2480. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit b4d9eacecddfd51af8b5805ec2498f8887fdb876 Author: Randy Dunlap Date: Tue Nov 21 19:01:51 2006 +0100 [ALSA] korg1212: fix printk format warning sound/pci/korg1212/korg1212.c:2359: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3ecc74f61ffb3f4423323fd8740a64e9ca49fad6 Author: Takashi Iwai Date: Tue Nov 21 12:10:55 2006 +0100 [ALSA] hda-intel - Disable INTX when MSI is used Call pci_intx() to disable/enable INTX when MSI is used/unused. Nvidia and AMD boards seem to have problems with MSI when INTX isn't disabled. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit af743190579147773bcc35247eb9db5695b4015a Author: Adrian Bunk Date: Mon Nov 20 17:50:17 2006 +0100 [ALSA] make sound/core/control.c:snd_ctl_new() static Now that everyone uses snd_ctl_new1() and noone is using snd_ctl_new() anymore, we can make it static. Signed-off-by: Adrian Bunk Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ab87a15f881d7f854ff43833d7ac2b50b86c5693 Author: Tobin Davis Date: Mon Nov 20 17:42:09 2006 +0100 [ALSA] hda-codec - Add missing array to conexant driver This patch adds a missing array to the conexant driver. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 90f4e5f260ba053027790b44811698bf5dcf3b8d Author: Dan Carpenter Date: Mon Nov 20 16:35:18 2006 +0100 [ALSA] atiixp - Add a parameter ac97_quirk Add an option to specify the AC'97 codec instead of probing. This is a fix for bugzilla #7467. Signed-off-by: Dan Carpenter Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 06d274ab66248b983ea635e96a9ddf05c8ec8869 Author: Clemens Ladisch Date: Mon Nov 20 14:14:39 2006 +0100 [ALSA] usb-audio: work around wrong frequency in CM6501 descriptors The C-Media CM6501 chip's descriptors say that altsetting 5 supports 48 kHz, but it actually plays at 96 kHz. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 4cb582a28a5648d4aa57ee17757e41cfef8d95c8 Author: Adrian Bunk Date: Mon Nov 20 12:03:44 2006 +0100 [ALSA] make sound/pci/hda/patch_sigmatel.c:stac92xx_dmic_labels[] static This patch makes the needlessly global stac92xx_dmic_labels[] static. Signed-off-by: Adrian Bunk Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 1be516c92235c9ff5ae124d39cfd2018f04a5000 Author: Tobin Davis Date: Mon Nov 20 12:02:56 2006 +0100 [ALSA] hda-codec - Add support for Evesham Voyager C530RD laptops This patch adds support for the Evesham Voyager C530RD series laptops. So far, only playback has been tested, but microphone should also work. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 0546b4073643f6feed4205fe8d31dc7106286c40 Author: Takashi Iwai Date: Thu Nov 16 17:24:20 2006 +0100 [ALSA] hda-codec - Add model for ASUS W3j laptop Added a proper model entry (model=laptop-eapd) for ASUS W3j laptop with AD1986A codec. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5320cf60c1a1f2ab714d0b98c648facffa4db44e Author: Takashi Iwai Date: Thu Nov 16 17:12:49 2006 +0100 [ALSA] hda-codec - Fix ALC861 connection of front-output Fix the wrongly set SET_CONNECTION verb for NID 0x0f of ALC861. The widget has only a single connection although the init verb sets to 0x01. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ab48c6acf7b2d3a13b1fef44f6066c8e4eff3b6d Author: Tobin Davis Date: Thu Nov 16 16:24:35 2006 +0100 [ALSA] hda-codec - Change Gigabyte K8N51 from 6stack to 6stack-digout This patch moves the entry for the Gigabyte K8N51 from the 6stack grouping to the 6stack-digout grouping, allowing for S/PDIF output functionality. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 990625953820bac6ff13cfc309b604900a199aa9 Author: Takashi Iwai Date: Tue Nov 14 12:30:52 2006 +0100 [ALSA] hda-codec - Add support for Sony UX-90s Added the model entry (model=hippo) for Sony UX-90s with ALC262 codec. Although the device has no SPDIF output, the hippo model adds a PCM output, but it must be harmless. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 52d593d739fd52034594e1d33867feba9e695eb1 Author: Tobin Davis Date: Tue Nov 14 12:13:39 2006 +0100 [ALSA] Add Conexant audio support to the HD Audio driver This driver adds limited support for the Conexant 5045 and 5047 HD Audio codecs. Some issues still need to be resolved. The code is based primarily on code from the Analog Devices AD1981 support and the Realtek ALC260 support. Some code came from the original code developed by Alex Pototskiy (see alsa bugtracker 2485). Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 597757709aa04566fc7b32f64cb461c325f050d8 Author: James Courtier-Dutton Date: Sat Nov 11 10:52:06 2006 +0000 [ALSA] snd-ca0106: Updated Enum control names. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 58ce9b48f4413cc504d0265b30824957e59178c3 Author: James Courtier-Dutton Date: Sat Nov 11 10:48:58 2006 +0000 [ALSA] snd-emu10k1: Update Enum naming. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 2c7034e4c47f0ad5d261a9cd53c84ccc27886a5c Author: Takashi Iwai Date: Thu Nov 9 16:47:26 2006 +0100 [ALSA] ice1724 - Add support of M-Audio Audiophile 192 Added the (experimental) support of M-Audio Audiophile 192 board. Currently, the analog and the digital playbacks seem working fine. The inputs seem not working as far as I've tested yet. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 11eccf982b26edfc05f9c86c6586d69e9e266f3a Author: Liam Girdwood Date: Thu Nov 9 16:35:01 2006 +0100 [ALSA] ASoC - mixer name changes for older OSS app support This patch suggested by Richard Purdie changes the names of some WM8731 and WM8750 mixers so that they will be recognised by some older OSS mixer apps. Changes:- o WM8731 Playback changed to Master Playback o WM8750 Out1 changed to Headphone o WM8750 Out2 changed to Speaker Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 12a512377626a3dc8a6c55fcd0a2f7c21a4bef50 Author: Andrew L. Neporada Date: Tue Nov 7 11:37:08 2006 +0100 [ALSA] hda-codec - Clevo M540JE, M550JE laptops (Nvidia MCP51 chipset, ALC883 codec) We need to enable External Amplifier on this laptops. This patch basicly adds laptop-eapd model to ALC883 codec. Signed-off-by: Andrew L. Neporada Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit e04efd7058a0a71efcbbee1d6f9ec4a8705997d4 Author: Takashi Iwai Date: Mon Nov 6 15:38:55 2006 +0100 [ALSA] hdspm - Fix printk warnings sound/pci/rme9652/hdspm.c: In function 'snd_hdspm_hw_params': sound/pci/rme9652/hdspm.c:3681: warning: format '%08X' expects type 'unsigned int', but argument 4 has type 'unsigned char *' sound/pci/rme9652/hdspm.c:3692: warning: format '%08X' expects type 'unsigned int', but argument 4 has type 'unsigned char *' Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit d635e475c5679fbd0c2b41700c09c177ab28c18f Author: Takashi Iwai Date: Mon Nov 6 14:45:42 2006 +0100 [ALSA] hda-codec - Fix model for ASUS M2N-MX Add a proper model (3stack) for ASUS M2N-MX with AD1986A codec. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 749124b552083024a14d6cdd8129286a7ceb2ae1 Author: Giuliano Pochini Date: Mon Nov 6 11:42:00 2006 +0100 [ALSA] Fix potential NULL pointer dereference in echoaudio midi Fix races between the timer handler and the close function. Signed-off-by: Giuliano Pochini Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit a44049b012c1be7395d6e69f3a76eaa35251d4cf Author: Clemens Ladisch Date: Mon Nov 6 09:26:41 2006 +0100 [ALSA] maestro3: add request_firmware() Load the ASSP codes using request_firmware(), if possible, instead of using the built-in blobs. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 09992d92000561575903d725b328e8f6791c89b4 Author: Clemens Ladisch Date: Mon Nov 6 09:24:29 2006 +0100 [ALSA] korg1212: add request_firmware() Load the DSP code using request_firmware(), if possible, instead of using the built-in blob. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit e357bf06a5a0eeef4e699fa5e522ae0085a57cc8 Author: Clemens Ladisch Date: Mon Nov 6 09:21:58 2006 +0100 [ALSA] wavefront: add request_firmware() Load the YSS225 register initialization data using request_firmware(), if possible, instead of using the built-in data blob. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 7749dece3aab5bc4f1aff5fcd7720296dc25174f Author: Clemens Ladisch Date: Mon Nov 6 09:20:04 2006 +0100 [ALSA] wavefront: simplify YSS225 register initialization Instead of using a somewhat algorithmic approach of initializing the YSS225's registers, just use a simple series of port/value pairs. This makes it easier to later replace or entirely remove the register data blob. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 70a5b0b1634973231b3b51402c1784ea80031486 Author: Clemens Ladisch Date: Mon Nov 6 09:18:34 2006 +0100 [ALSA] sb16: add request_firmware() Load the CSP programs using request_firmware(), if possible, instead of using the built-in firmware blobs. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 9fb16c27caf420d3029d8345a70c517a738d5e41 Author: Peer Chen Date: Tue Oct 31 15:33:42 2006 +0100 [ALSA] Audio: Add nvidia HD Audio controllers of MCP67 support to hda_intel.c Add the support for HD audio controllers of MCP51,MCP55,MCP61,MCP65 & MCP67. Signed-off-by: Peer Chen Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7d217d457795c4c8e9dc4f0fdc2cf57a92e2a833 Author: Hubert Kahlert Date: Tue Oct 31 15:31:27 2006 +0100 [ALSA] Fix mask to stop AT91 SSC clock on shutdown This patch by Frank Mandarino and Hubert Kahlert fixes a bug in the AT91 SSC (i2s) shutdown code that would erroneously disable other AT91 peripheral clocks. Signed-off-by: Hubert Kahlert Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 563570baae0c24afe271c67daca576ecdaa90a6b Author: Matt Porter Date: Thu Oct 26 17:12:59 2006 +0200 [ALSA] hda: add dig mic support for sigmatel codecs Adds support for digital microphone pin widgets on SigmaTel codecs. Enables support only on the 9205 codecs for now. Signed-off-by: Matt Porter Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3c857ee39afb470e93a3573a813d341769d52a76 Author: Takashi Iwai Date: Tue Oct 24 19:49:39 2006 +0200 [ALSA] hda-codec - Fix model for Lenovo A60 desktop Add a proper model entry (3stack) for Lenovo A60 desktop with AD1986a codec to fix noise problems. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit da5bb0e8abe21c679a0115171934a633689e4a48 Author: Takashi Iwai Date: Tue Oct 24 18:25:29 2006 +0200 [ALSA] ac97 - Suppress power-saving mode on non-supporting drivers Don't enable power-saving mode on drivers that don't support it. The supporting drivers set AC97_SCAP_POWER_SAVE to scaps at creation of ac97 instance. Currently enable on the following drivers: intel8x0, intel8x0m, atiixp, atiixp-modem, via82xx and via82xx-modem. Also, a bit clean up of power-saving stuff: - Don't create an own workq - Remove superfluous ifdefs Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 6d0f9e546937ba5ba608b7a1c44b10f8e3f8be97 Author: Mariusz Domanski Date: Mon Oct 23 13:42:56 2006 +0200 [ALSA] hda-codec - Add asus model to ALC861 codec This patch adds support for Asus laptops (for example: Asus A6Rp-AP002). Signed-off-by: Mariusz Domanski Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c6e2aca795807545d030a4dacb5503dde5071e02 Author: Liam Girdwood Date: Thu Oct 19 20:35:56 2006 +0200 [ALSA] ASoC: Add support for BCLK based on (Rate * Chn * Word Size) This patch adds support for the DAI BCLK to be generated by multiplying Rate * Channels * Word Size (RCW). This now gives 3 options for BCLK clocking and synchronisation :- 1. BCLK = Rate * x 2. BCLK = MCLK / x 3. BCLK = Rate * Chn * Word Size. (New) Changes:- o Add support for RCW generation of BCLK o Update Documentation to include RCW. o Update DAI documentation for label = value DAI modes. o Add RCW support to wm8731, wm8750 and pxa2xx-i2s drivers. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 2d209a00da88dfac4ed6aa79d74c7540f68e13ca Author: Frank Mandarino Date: Thu Oct 19 18:22:53 2006 +0200 [ALSA] ASoC AT91 DAI modes update This patch by Frank Mandarino updates the AT91RM9200 I2S DAI audio modes as follows:- o fixes a typo in the 16k mode o removes experimental 24k mode o adds a 32k mode. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5da081552e97dbc55a595bf634a2bddf6fd46095 Author: Remy Bruno Date: Tue Oct 17 12:41:56 2006 +0200 [ALSA] hdsp - Add DDS register support for RME9632 rev >= 152 Add DDS register support for RME9632 rev >= 152. This register sets the sample rate for these cards and is required in addition to the standard control register. It corresponds to a quartz divisor. Signed-off-by: Remy Bruno Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 3ccbc60f550eb530fd0eab7f5f370a878145c67b Author: Kailang Yang Date: Tue Oct 17 12:32:26 2006 +0200 [ALSA] hda-codec - Add new modesl for Realtek codecs Changes from Realtek driver: - New models hippo and hippo_1 for ALC262 - New models tagra-dig and tagra-2ch-dig for ALC883 - New id for ALC660 codec chip Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit dc3f053d927ff7230ea3d6179d1506ab09b59fb8 Author: Tobin Davis Date: Tue Oct 17 12:00:28 2006 +0200 [ALSA] hda-codec - Add toshiba model to ALC861 codec This patch adds support for Toshiba laptops. Code is from RealTek's alsa-driver-1.0.12-4.05b tree. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 413b9b88956d53a59bd017c6f7eaf96d1c9dc15e Author: Liam Girdwood Date: Mon Oct 16 21:19:48 2006 +0200 [ALSA] ASoC - Fix build warnings in soc-core.c This patch fixes some build warnings in soc-core.c Changes:- o Check the return value of soc_ac97_dev_register() o Check return value of calls to device_create_file() Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit e8c1a072d56683d531c3587535af451fcd46808c Author: Jerome Demange Date: Mon Oct 16 21:08:57 2006 +0200 [ALSA] ac97 - enables sound output through speakers on MSI S250 laptop Signed-off-by: Jerome Demange Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit bcb359ef6d6de0c2e585a1aab4319e83943be053 Author: Remy Bruno Date: Mon Oct 16 12:46:32 2006 +0200 [ALSA] hdspm: Add support for AES32 Add support for AES32. Difference between MADI and AES32 is done through revision. Master support is not finished for now (RME so-called DDS feature is not supported yet) Signed-off-by: Remy Bruno Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 2acb92d7be655358bdc746b98432637ec4fc4739 Author: Takashi Iwai Date: Fri Oct 13 20:09:59 2006 +0200 [ALSA] Remove trailing whitespaces from soc/* files Remove trailing whitespaces from soc/* files added by the conversion to C99-style initialization. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ae8fbeddd0e3708d5f250f1cda92c2100455411c Author: Liam Girdwood Date: Fri Oct 13 19:13:41 2006 +0200 [ALSA] ASoC debug output build breakage This patch fixes a build failure when ASoC debug is enabled. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7a18a6436c3a17a52d533a7c3b41ab55b26b70b1 Author: Takashi Iwai Date: Fri Oct 13 12:46:10 2006 +0200 [ALSA] hda-codec - Add missing comma Added a missing comma in the medion patch. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 15175f00c92ea7738a5103567698704555a06b82 Author: Liam Girdwood Date: Fri Oct 13 12:33:56 2006 +0200 [ALSA] ASoC DAI capabilities labelling This patch suggested by Takashi changes the DAI capabilities definitions in pxa-i2s.c, at91rm9200-i2s.c, wm8731.c, wm8750.c and wm9712.c to use a label = value style. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f85395cfd229dc00ab89bf38c8c31d5a04210dca Author: Tobin Davis Date: Fri Oct 13 12:32:16 2006 +0200 [ALSA] hda-codec - Add support for Medion laptops This patch adds audio support for Medion's line of laptops, based on code shipped with the laptops. Microphone support is still being explored. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 05d4bb1133bab25b2d7fdc31fafee1ea278d1d81 Author: Liam Girdwood Date: Thu Oct 12 14:34:32 2006 +0200 [ALSA] ASoC pxa2xx build support This patch builds ASoC pxa2xx support for Corgi, Spitz, Tosa and Poodle Zaurus machines. From: Liam Girdwood Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit e2430b7a13d74dcc0607f285820e3c18cf1bd8de Author: Liam Girdwood Date: Thu Oct 12 14:33:45 2006 +0200 [ALSA] ASoC pxa2xx Poodle machine support This patch adds Alsa audio support to the Sharp Zaurus SL-C5600 (Poodle) machine. From: Liam Girdwood Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5f719b6ecb2354630b803029ed376216f68b4442 Author: Liam Girdwood Date: Thu Oct 12 14:33:09 2006 +0200 [ALSA] ASoC pxa2xx Tosa machine support This patch adds Alsa audio support to the Sharp Zaurus SL-C6000 (Tosa) machine. From: Liam Girdwood Signed-off-by: Dirk Opfer Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ab7c6281294ea5c365091a4390e015370f96d9c0 Author: Liam Girdwood Date: Thu Oct 12 14:32:13 2006 +0200 [ALSA] ASoC pxa2xx Spitz machine support This patch adds Alsa audio support to the Sharp Zaurus SL-C1000/SL-C3x00 (Akita/Spitz) machines. From: Liam Girdwood Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 0b51f00ec6b7a1be845a03cd849a01bf525779c6 Author: Liam Girdwood Date: Thu Oct 12 14:31:16 2006 +0200 [ALSA] ASoC pxa2xx Corgi machine support This patch adds Alsa audio support to the Sharp Zaurus SL-C7x0/C860 (Corgi) machines. From: Liam Girdwood Signed-off-by: Graeme Gregory Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 0a0ebd229ab09aed8f7364af5cbd594bc2e113de Author: Liam Girdwood Date: Thu Oct 12 14:29:03 2006 +0200 [ALSA] ASoC pxa2xx AC97 support This patch adds pxa2xx AC97 ASoC audio support. It's based on sound/arm/pxa-ac97 by Nicolas Pitre with the following differences. o Modified driver structure to use ASoC core PCM callbacks. o Removed AC97 configuration function (all handled in ASoC core) o Added and exported ASoC DAI configuration table. o Added DMA support for AUX DAC and Mic ADC o Separated out AC97 reset into cold and warm reset functions. From: Liam Girdwood Signed-off-by: Nicolas Pitre Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 47af71ac0ac01da7c5757d6f32696403d2eef02d Author: Liam Girdwood Date: Thu Oct 12 14:28:10 2006 +0200 [ALSA] ASoC pxa2xx I2S support This patch adds pxa2xx I2S ASoC audio support. Features:- o Supports playback/capture o 16 bit PCM o 8k - 96k sample rates o Supports master and slave mode. From: Liam Girdwood Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c91d7624c237b663ef0db3be50e2d7d4428471fb Author: Liam Girdwood Date: Thu Oct 12 14:26:55 2006 +0200 [ALSA] ASoC pxa2xx DMA support This patch adds pxa2xx ASoC DMA audio support. It's based on sound/arm/pxa-pcm.c by Nicolas Pitre with the following differences. o Modified driver structure to use ASoC core PCM callbacks and data structures. o Registration with ASoC core. From: Liam Girdwood Signed-off-by: Nicolas Pitre Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 8102e7f0a7e02fab89685e95ff0cd1b685946d30 Author: Clemens Ladisch Date: Wed Oct 11 12:05:59 2006 +0200 [ALSA] ymfpci: add request_firmware() Load the DSP and controller microcode using request_firmware(), if possible, instead of using the built-in firmware. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit c159620bbde207ea6db48079bbb72434df040ce7 Author: James Courtier-Dutton Date: Tue Oct 10 18:44:29 2006 +0100 [ALSA] snd-emu10k1: emu1010: replace long udelay with msleep. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 4daae7867d84535bf34a8dc7d4a5400f77886890 Author: James Courtier-Dutton Date: Tue Oct 10 18:08:45 2006 +0100 [ALSA] snd-emu10k1: Add emu1010 internal clock rate control for 44100 or 48000. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit 63731ca6b3d7526c762d93e62b7dbea44bfae920 Author: Takashi Iwai Date: Tue Oct 10 15:59:46 2006 +0200 [ALSA] Fix irq handler in soc/at91/at91rm9200-i2s.c Fixed the irq handler in soc/at91-at91rm9200-i2s.c to follow the new style without pt_regs. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c6a60df160958d931d6b5a4d93467150b70c2d54 Author: James Courtier-Dutton Date: Mon Oct 9 23:08:00 2006 +0100 [ALSA] snd_emu10k1: Added support for 14dB Attenuation PADS on DACs and ADCs. Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela commit f9b7986c079a6a94780f50fe153e0c95d6cdd76f Author: Remy Bruno Date: Mon Oct 9 15:52:01 2006 +0200 [ALSA] hdsp: support for mixer matrix of RME9632 rev 152 Added the support for mixer matrix of RME9632 rev 152. Signed-off-by: Remy Bruno Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 755d9cff48db38b876475e77673e131d0ab14bdf Author: Clemens Ladisch Date: Mon Oct 9 08:18:26 2006 +0200 [ALSA] emu10k1: select FW_LOADER Let the emu10k1 driver select FW_LOADER because the new Emu1010 support requires it. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit eb4d59d8c782896b644cdc3081796b2684fdf840 Author: Clemens Ladisch Date: Mon Oct 9 08:17:48 2006 +0200 [ALSA] pci: select FW_LOADER instead of depending on it Let the AudioScience, Echoaudio and Riptide drivers select FW_LOADER instead of depending on it so that they can be configured without having to enable FW_LOADER manually. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 65b16ed24fb4005b1c588f4674bb43cf1defa08e Author: Clemens Ladisch Date: Mon Oct 9 08:14:58 2006 +0200 [ALSA] soc-core: fix multi-line string literal Properly quote a string that had an embedded newline. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit ee9bc3335684e6e25da0fc3db7a907dd676933ef Author: Frank Mandarino Date: Fri Oct 6 18:41:42 2006 +0200 [ALSA] ASoC AT91RM92000 build This patch adds a Makefile and Kconfig to build the ASoC AT91RM9200 support. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c6db3cedcc0261c683d2de0fdd0d35bbaae9a421 Author: Frank Mandarino Date: Fri Oct 6 18:41:10 2006 +0200 [ALSA] ASoC AT91RM92000 eti_b1 machine support This patch adds support for the Endrelia ETI_B1 machine using the WM8731 codec and the AT91RM9200 platform. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 9cb36dbf6c9a38bd5f4d325a6e50d138168cf5a8 Author: Frank Mandarino Date: Fri Oct 6 18:40:25 2006 +0200 [ALSA] ASoC AT91RM92000 I2S support This patch adds I2S support to the Atmel AT91RM9200 CPU. Features:- o Playback/Capture supported. o 16 Bit data size. o 8k - 48k sample rates. o ssc0, ssc1 and ssc2 supported as I2S ports. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 40a3e5fc617710edfcf3a781fa28f599f7157458 Author: Frank Mandarino Date: Fri Oct 6 18:39:29 2006 +0200 [ALSA] ASoC AT91RM92000 audio DMA This patch adds ASoC audio DMA support to the Atmel AT91RM9200 CPU. Features:- o Playback/Capture supported. o 16 Bit data size. Signed-off-by: Frank Mandarino Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f66cb5b05a487d2e734f379bcbf5cf5278ffc28c Author: Richard Purdie Date: Fri Oct 6 18:38:37 2006 +0200 [ALSA] ASoC codecs: build files This patch adds an ASoC Makefile and Kconfig for the WM8731, WM8750 and WM9712 codecs. Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f079fea0a127a5604254b266ee0aac6d1cdb1b02 Author: Richard Purdie Date: Fri Oct 6 18:38:03 2006 +0200 [ALSA] ASoC codecs: generic AC97 support This patch allows the std Alsa AC97 codec driver to use any AsoC AC97 controller driver. Currently, only HiFi playback and Capture are supported atm. Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5fefc943eb1bf7f632332b6672c291968a6dbb92 Author: Richard Purdie Date: Fri Oct 6 18:37:32 2006 +0200 [ALSA] ASoC codecs: WM9712 support This patch adds ASoC support for the WM9712 codec. Supported features:- o Capture/Playback/Sidetone/Bypass. o Aux DAC. o 8k - 48k sample rates. o DAPM. Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 11eead65926ecafc3e6062c9f9b79959d8f2f624 Author: Richard Purdie Date: Fri Oct 6 18:36:39 2006 +0200 [ALSA] ASoC codecs: WM8750 support This patch adds ASoC support for the WM8750 codec. Supported features:- o Capture/Playback/Sidetone/Bypass. o 16 & 24 bit audio. o 8k - 96k sample rates. o DAPM. Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 1e76e0c2318e514a9887d32d624c01327a435784 Author: Richard Purdie Date: Fri Oct 6 18:36:07 2006 +0200 [ALSA] ASoC codecs: WM8731 support This patch adds ASoC support for the WM8731 codec. Supported features:- o Capture/Playback/Sidetone/Bypass. o 16 & 24 bit audio. o 8k - 96k sample rates. o DAPM. Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 6fb7520a5536ce3df5fb4d6615861cd212aba404 Author: Liam Girdwood Date: Fri Oct 6 18:34:51 2006 +0200 [ALSA] ASoC: documentation & maintainer This patch adds documentation describing the ASoC architecture and a maintainer entry for ASoC. The documentation includes the following files:- codec.txt: Codec driver internals. DAI.txt: Description of Digital Audio Interface standards and how to configure a DAI within your codec and CPU DAI drivers. dapm.txt: Dynamic Audio Power Management. platform.txt: Platform audio DMA and DAI. machine.txt: Machine driver internals. pop_clicks.txt: How to minimise audio artifacts. clocking.txt: ASoC clocking for best power performance. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c33ae80e44df57accf05f2fdc9592a068ca0a3fb Author: Liam Girdwood Date: Fri Oct 6 18:33:55 2006 +0200 [ALSA] ASoC: Build files This patch adds support for building the ASoC core and the dynamic audio power management support. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 4a3e5c63b6605caf19fa64b246515f9998cb72b1 Author: Richard Purdie Date: Fri Oct 6 18:32:18 2006 +0200 [ALSA] ASoC: dynamic audio power management (DAPM) This patch adds Dynamic Audio Power Management (DAPM) to ASoC. Dynamic Audio Power Management (DAPM) is designed to allow portable and handheld Linux devices to use the minimum amount of power within the audio subsystem at all times. It is independent of other kernel PM and as such, can easily co-exist with the other PM systems. DAPM is also completely transparent to all user space applications as all power switching is done within the ASoC core. No code changes or recompiling are required for user space applications. DAPM makes power switching decisions based upon any audio stream (capture/playback) activity and audio mixer settings within the device. DAPM spans the whole machine. It covers power control within the entire audio subsystem, this includes internal codec power blocks and machine level power systems. There are 4 power domains within DAPM:- 1. Codec domain - VREF, VMID (core codec and audio power) Usually controlled at codec probe/remove and suspend/resume, although can be set at stream time if power is not needed for sidetone, etc. 2. Platform/Machine domain - physically connected inputs and outputs Is platform/machine and user action specific, is configured by the machine driver and responds to asynchronous events e.g when HP are inserted 3. Path domain - audio subsystem signal paths Automatically set when mixer and mux settings are changed by the user. e.g. alsamixer, amixer. 4. Stream domain - DAC's and ADC's. Enabled and disabled when stream playback/capture is started and stopped respectively. e.g. aplay, arecord. All DAPM power switching decisions are made automatically by consulting an audio routing map of the whole machine. This map is specific to each machine and consists of the interconnections between every audio component (including internal codec components). Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 1e553835735f0ecdfaf3e440e6dfd04b445c7dcf Author: Frank Mandarino Date: Fri Oct 6 18:31:09 2006 +0200 [ALSA] ASoC: core code This patch is the core of ASoC functionality. The ASoC core is designed to provide the following features :- o Codec independence. Allows reuse of codec drivers on other platforms and machines. o Platform driver code reuse. Reuse of platform specific audio DMA and DAI drivers on different machines. o Easy I2S/PCM digital audio interface configuration between codec and SoC. Each SoC interface and codec registers their audio interface capabilities with the core at initialisation. The capabilities are subsequently matched and configured at run time for best power and performance when the application hw params are known. o Machine specific controls/operations: Allow machines to add controls and operations to the audio subsystem. e.g. volume control for speaker amp. To achieve all this, ASoC splits an embedded audio system into 3 components :- 1. Codec driver: The codec driver is platform independent and contains audio controls, audio interface capabilities, codec dapm and codec IO functions. 2. Platform driver: The platform driver contains the audio dma engine and audio interface drivers (e.g. I2S, AC97, PCM) for that platform. 3. Machine driver: The machine driver handles any machine specific controls and audio events. i.e. turning on an amp at start of playback. Signed-off-by: Frank Mandarino Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit e2e7518e563c868b8aab3c27926d6f5a74b84e7f Author: Richard Purdie Date: Fri Oct 6 18:20:14 2006 +0200 [ALSA] ASoC: core and dapm headers This patch adds the ASoC and DAPM headers. Features:- o Defines Digital Audio Interface (DAI) API o Defines Codec, Platform and Machine API o Defines Dynamic Audio Power Management API Signed-off-by: Richard Purdie Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7d75a0a97a0a498147015ff1ad96ce2d663229bb Author: Takashi Iwai Date: Fri Oct 6 17:06:39 2006 +0200 [ALSA] intel8x0 - Use pci_iomap Use pci_iomap and ioread*/iowrite*() functions for accessing hardwares. pci_iomap is suitable for hardwares like ICH and compatible that have both PIO and MMIO. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f5ec545ac26cd427b62f77e582635c2154573da1 Author: Jaroslav Kysela Date: Fri Oct 6 15:12:29 2006 +0200 [ALSA] pcm core: add prealloc_max file to substream directory to show maximum DMA size Users ask us many times about the maximum DMA size for PCM devices. This file gives them a hint in KB. Signed-off-by: Jaroslav Kysela commit e8e2a259ca941605ed4fb3c43b272152a03429ef Author: Jaroslav Kysela Date: Fri Oct 6 09:34:20 2006 +0200 [ALSA] hda_intel: increase maximum DMA buffer size to 1024MB See ALSA bug#2481 . Signed-off-by: Jaroslav Kysela commit 1d1ecad12c297f8577e046b01727a6ca3a3439bb Author: Takashi Iwai Date: Thu Oct 5 16:21:19 2006 +0200 [ALSA] emu10k1 - Fix compile warning Fixed a compile warning regarding print format for size_t. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit bea960aa518ee7a1c63ac939921a2690effcdeec Author: Johannes Berg Date: Thu Oct 5 16:02:22 2006 +0200 [ALSA] alsa core: convert to list_for_each_entry* This patch converts most uses of list_for_each to list_for_each_entry all across alsa. In some place apparently an item can be on a list with different pointers so of course that isn't compatible with list_for_each, I therefore didn't touch those places. Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit accb859cf11ecd7ff7e62083ddc38aafd96601e9 Author: Johannes Berg Date: Thu Oct 5 15:08:23 2006 +0200 [ALSA] aoa: fix up i2sbus_attach_codec This patch changes i2sbus_attach_codec to implement a proper error handling strategy using labels to jump to the right part. Since it has an elaborate set-up sequence it also needs that tear-down, which I had hard-coded inbetween all the checks. This increases readability and should reduce .text size as well. Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ec0a2f0cbecab2c9e9bbd6b54fd5ebc3f956f1e7 Author: Johannes Berg Date: Thu Oct 5 15:07:23 2006 +0200 [ALSA] aoa: set device pointer in pcms This patch makes a few whitespace cleanups and makes i2sbus assign the new struct device pointer in struct snd_pcm so that the proper device symlink shows up in sysfs. Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 6cea3b2f18e33347673b0dce70e3a90d438f8bb0 Author: Johannes Berg Date: Thu Oct 5 15:06:34 2006 +0200 [ALSA] alsa core: add struct device pointer to struct snd_pcm This patch adds a struct device pointer to struct snd_pcm in order to be able to give it a different device than the card. It defaults to the card's device, however, so it should behave identically for drivers not touching the field. Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 81a68155a64dd89f4d1bf572e5f09e3139c71866 Author: Johannes Berg Date: Thu Oct 5 15:05:34 2006 +0200 [ALSA] allow registering an alsa device with struct device pointer This patch adds snd_register_device_for_dev taking a struct device pointer to link the new device to and makes snd_register_device a simple static inline wrapper around it. Signed-off-by: Johannes Berg Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 781a6ec3f1e066322e2f8656c7644ce465ea3d40 Author: Jochen Voss Date: Wed Oct 4 18:08:43 2006 +0200 [ALSA] Enable the analog loopback of the Revolution 5.1 Enable the analog loopback of the Revolution 5.1 card. This patch adds support for the PT2258 volume controller and modifies the Revolution 5.1 driver to make use of this facility. This allows to control the analog loopback of the card. Signed-off-by: Jochen Voss Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit cc3ba867c245b24d1357c048c3d6578e45339607 Author: Jochen Voss Date: Wed Oct 4 18:04:10 2006 +0200 [ALSA] Enable capture from line-in and CD on Revolution 5.1 Enable capture from line-in and CD on the Revolution 5.1 card. This patch adds support for switching between the 5 input channels of the AK5365 ADC and modifies the Revolution 5.1 driver to make use of this facility. Previously the capture channel was fixed to channel 0 (microphone on the Revolution 5.1 card). Signed-off-by: Jochen Voss Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c9e025d2b78fd660c9c9012abb41ff9bb55c36e6 Author: Clemens Ladisch Date: Wed Oct 4 13:42:57 2006 +0200 [ALSA] usb-audio: allow pausing Add pause capabilities for both USB playback and capture streams. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit f77376c922889f9bb3ec0b2c0b64489b302069df Author: Clemens Ladisch Date: Wed Oct 4 13:41:25 2006 +0200 [ALSA] usb-audio: merge playback/capture hardware information structs The hardware information structures for playback and capture streams, respectively, are the same, so we can use just one structure for both streams. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela commit 9a5ba392517dccdc88662bfa55d098e564b9ce73 Author: James Courtier-Dutton Date: Sun Oct 1 10:48:04 2006 +0100 [ALSA] snd-emu10k1: Added support for emu1010, including E-Mu 1212m and E-Mu 1820m Signed-off-by: James Courtier-Dutton Signed-off-by: Jaroslav Kysela Documentation/sound/alsa/ALSA-Configuration.txt | 35 .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 10 Documentation/sound/alsa/hda_codec.txt | 10 Documentation/sound/alsa/soc/DAI.txt | 546 ++++ Documentation/sound/alsa/soc/clocking.txt | 314 ++ Documentation/sound/alsa/soc/codec.txt | 232 ++ Documentation/sound/alsa/soc/dapm.txt | 297 ++ Documentation/sound/alsa/soc/machine.txt | 114 + Documentation/sound/alsa/soc/overview.txt | 83 + Documentation/sound/alsa/soc/platform.txt | 58 Documentation/sound/alsa/soc/pops_clicks.txt | 52 MAINTAINERS | 6 drivers/input/touchscreen/ucb1400_ts.c | 2 include/linux/i2c-id.h | 2 include/sound/ac97_codec.h | 4 include/sound/ak4114.h | 1 include/sound/ak4xxx-adda.h | 2 include/sound/control.h | 1 include/sound/core.h | 62 include/sound/emu10k1.h | 397 +++ include/sound/pcm.h | 4 include/sound/pt2258.h | 37 include/sound/sb16_csp.h | 14 include/sound/snd_wavefront.h | 2 include/sound/soc-dapm.h | 286 ++ include/sound/soc.h | 488 ++++ include/sound/typedefs.h | 173 - include/sound/ymfpci.h | 6 sound/Kconfig | 2 sound/Makefile | 2 sound/aoa/aoa.h | 2 sound/aoa/codecs/snd-aoa-codec-onyx.c | 11 sound/aoa/core/snd-aoa-alsa.c | 5 sound/aoa/core/snd-aoa-alsa.h | 2 sound/aoa/core/snd-aoa-core.c | 4 sound/aoa/fabrics/snd-aoa-fabric-layout.c | 5 sound/aoa/soundbus/i2sbus/i2sbus-pcm.c | 79 - sound/arm/aaci.h | 2 sound/core/control.c | 42 sound/core/control_compat.c | 5 sound/core/device.c | 24 sound/core/hwdep.c | 10 sound/core/memalloc.c | 10 sound/core/misc.c | 28 sound/core/pcm.c | 50 sound/core/pcm_memory.c | 23 sound/core/rawmidi.c | 29 sound/core/seq/seq_clientmgr.c | 14 sound/core/seq/seq_device.c | 25 sound/core/seq/seq_ports.c | 49 sound/core/seq/seq_virmidi.c | 4 sound/core/sound.c | 17 sound/core/timer.c | 77 - sound/drivers/serial-u16550.c | 221 +- sound/i2c/Makefile | 1 sound/i2c/other/Makefile | 4 sound/i2c/other/ak4114.c | 17 sound/i2c/other/ak4xxx-adda.c | 85 + sound/i2c/other/pt2258.c | 233 ++ sound/isa/Kconfig | 2 sound/isa/sb/sb16_csp.c | 61 sound/isa/wavefront/wavefront.c | 1 sound/isa/wavefront/wavefront_fx.c | 812 ------ sound/isa/wavefront/yss225.c | 2739 ++++++++++++++++++++ sound/pci/Kconfig | 30 sound/pci/ac97/ac97_codec.c | 43 sound/pci/ac97/ac97_patch.c | 542 ++++ sound/pci/ac97/ac97_patch.h | 1 sound/pci/als300.c | 6 sound/pci/atiixp.c | 31 sound/pci/atiixp_modem.c | 2 sound/pci/ca0106/ca0106_main.c | 19 sound/pci/ca0106/ca0106_mixer.c | 46 sound/pci/cmipci.c | 3 sound/pci/echoaudio/darla20.c | 1 sound/pci/echoaudio/darla24.c | 1 sound/pci/echoaudio/echo3g.c | 1 sound/pci/echoaudio/echoaudio.c | 18 sound/pci/echoaudio/gina20.c | 1 sound/pci/echoaudio/gina24.c | 1 sound/pci/echoaudio/indigo.c | 1 sound/pci/echoaudio/indigodj.c | 1 sound/pci/echoaudio/indigoio.c | 1 sound/pci/echoaudio/layla20.c | 1 sound/pci/echoaudio/layla24.c | 1 sound/pci/echoaudio/mia.c | 1 sound/pci/echoaudio/midi.c | 6 sound/pci/echoaudio/mona.c | 1 sound/pci/emu10k1/emu10k1_main.c | 616 ++++ sound/pci/emu10k1/emu10k1x.c | 6 sound/pci/emu10k1/emufx.c | 102 + sound/pci/emu10k1/emumixer.c | 744 +++++ sound/pci/emu10k1/emupcm.c | 147 + sound/pci/emu10k1/emuproc.c | 34 sound/pci/emu10k1/io.c | 104 + sound/pci/emu10k1/p16v.c | 12 sound/pci/emu10k1/p17v.h | 47 sound/pci/emu10k1/voice.c | 2 sound/pci/ens1370.c | 154 + sound/pci/hda/Makefile | 11 sound/pci/hda/hda_codec.c | 68 sound/pci/hda/hda_generic.c | 5 sound/pci/hda/hda_intel.c | 17 sound/pci/hda/hda_local.h | 12 sound/pci/hda/hda_patch.h | 6 sound/pci/hda/patch_analog.c | 139 + sound/pci/hda/patch_cmedia.c | 24 sound/pci/hda/patch_conexant.c | 1311 ++++++++++ sound/pci/hda/patch_realtek.c | 1456 +++++++++-- sound/pci/hda/patch_sigmatel.c | 550 ++-- sound/pci/hda/patch_via.c | 1396 ++++++++++ sound/pci/ice1712/aureon.c | 52 sound/pci/ice1712/aureon.h | 4 sound/pci/ice1712/ice1712.h | 14 sound/pci/ice1712/revo.c | 346 ++- sound/pci/ice1712/revo.h | 11 sound/pci/intel8x0.c | 208 +- sound/pci/intel8x0m.c | 120 - sound/pci/korg1212/korg1212.c | 45 sound/pci/maestro3.c | 373 +-- sound/pci/nm256/nm256.c | 56 sound/pci/rme9652/hdsp.c | 38 sound/pci/rme9652/hdspm.c | 1242 ++++++++- sound/pci/via82xx.c | 132 - sound/pci/via82xx_modem.c | 2 sound/pci/ymfpci/ymfpci_image.h | 6 sound/pci/ymfpci/ymfpci_main.c | 169 + sound/soc/Kconfig | 32 sound/soc/Makefile | 4 sound/soc/at91/Kconfig | 24 sound/soc/at91/Makefile | 11 sound/soc/at91/at91-i2s.c | 673 +++++ sound/soc/at91/at91-pcm.c | 427 +++ sound/soc/at91/at91-pcm.h | 71 + sound/soc/at91/eti_b1_wm8731.c | 268 ++ sound/soc/codecs/Kconfig | 15 sound/soc/codecs/Makefile | 9 sound/soc/codecs/ac97.c | 167 + sound/soc/codecs/ac97.h | 18 sound/soc/codecs/wm8731.c | 886 ++++++ sound/soc/codecs/wm8731.h | 41 sound/soc/codecs/wm8750.c | 1273 +++++++++ sound/soc/codecs/wm8750.h | 66 sound/soc/codecs/wm9712.c | 781 ++++++ sound/soc/codecs/wm9712.h | 14 sound/soc/pxa/Kconfig | 60 sound/soc/pxa/Makefile | 20 sound/soc/pxa/corgi.c | 361 +++ sound/soc/pxa/poodle.c | 329 ++ sound/soc/pxa/pxa2xx-ac97.c | 437 +++ sound/soc/pxa/pxa2xx-i2s.c | 354 +++ sound/soc/pxa/pxa2xx-pcm.c | 363 +++ sound/soc/pxa/pxa2xx-pcm.h | 48 sound/soc/pxa/spitz.c | 374 +++ sound/soc/pxa/tosa.c | 287 ++ sound/soc/soc-core.c | 2051 +++++++++++++++ sound/soc/soc-dapm.c | 1327 ++++++++++ sound/sparc/dbri.c | 2 sound/usb/usbaudio.c | 73 - 159 files changed, 26207 insertions(+), 3134 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 9fef210..89b612f 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -242,6 +242,12 @@ Prior to version 0.9.0rc4 options had a ac97_clock - AC'97 clock (default = 48000) ac97_quirk - AC'97 workaround for strange hardware See "AC97 Quirk Option" section below. + ac97_codec - Workaround to specify which AC'97 codec + instead of probing. If this works for you + file a bug with your `lspci -vn` output. + -2 -- Force probing. + -1 -- Default behavior. + 0-2 -- Use the specified codec. spdif_aclink - S/PDIF transfer over AC-link (default = 1) This module supports one card and autoprobe. @@ -801,6 +807,8 @@ Prior to version 0.9.0rc4 options had a fujitsu Fujitsu Laptop hp-bpc HP xw4400/6400/8400/9400 laptops benq Benq ED8 + hippo Hippo (ATI) with jack detection, Sony UX-90s + hippo_1 Hippo (Benq) with jack detection basic fixed pin assignment w/o SPDIF auto auto-config reading BIOS (default) @@ -817,6 +825,10 @@ Prior to version 0.9.0rc4 options had a 3stack-6ch-dig 3-jack 6-channel with SPDIF I/O 6stack-dig-demo 6-jack digital for Intel demo board acer Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc) + medion Medion Laptops + targa-dig Targa/MSI + targa-2ch-dig Targs/MSI with 2-channel + laptop-eapd 3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE) auto auto-config reading BIOS (default) ALC861/660 @@ -825,6 +837,9 @@ Prior to version 0.9.0rc4 options had a 6stack-dig 6-jack with SPDIF I/O 3stack-660 3-jack (for ALC660) uniwill-m31 Uniwill M31 laptop + toshiba Toshiba laptop support + asus Asus laptop support + asus-laptop ASUS F2/F3 laptops auto auto-config reading BIOS (default) CMI9880 @@ -854,6 +869,20 @@ Prior to version 0.9.0rc4 options had a laptop 3-jack with hp-jack automute laptop-dig ditto with SPDIF auto auto-config reading BIOS (default) + + Conexant 5045 + laptop Laptop config + test for testing/debugging purpose, almost all controls + can be adjusted. Appearing only when compiled with + $CONFIG_SND_DEBUG=y + + Conexant 5047 + laptop Basic Laptop config + laptop-hp Laptop config for some HP models (subdevice 30A5) + laptop-eapd Laptop config with EAPD support + test for testing/debugging purpose, almost all controls + can be adjusted. Appearing only when compiled with + $CONFIG_SND_DEBUG=y STAC9200/9205/9220/9221/9254 ref Reference board @@ -974,6 +1003,7 @@ Prior to version 0.9.0rc4 options had a Module for Envy24HT (VT/ICE1724), Envy24PT (VT1720) based PCI sound cards. * MidiMan M Audio Revolution 5.1 * MidiMan M Audio Revolution 7.1 + * MidiMan M Audio Audiophile 192 * AMP Ltd AUDIO2000 * TerraTec Aureon 5.1 Sky * TerraTec Aureon 7.1 Space @@ -993,7 +1023,7 @@ Prior to version 0.9.0rc4 options had a model - Use the given board model, one of the following: revo51, revo71, amp2000, prodigy71, prodigy71lt, - prodigy192, aureon51, aureon71, universe, + prodigy192, aureon51, aureon71, universe, ap192, k8x800, phase22, phase28, ms300, av710 This module supports multiple cards and autoprobe. @@ -1049,6 +1079,9 @@ Prior to version 0.9.0rc4 options had a buggy_semaphore - Enable workaround for hardwares with buggy semaphores (e.g. on some ASUS laptops) (default off) + spdif_aclink - Use S/PDIF over AC-link instead of direct connection + from the controller chip + (0 = off, 1 = on, -1 = default) This module supports one chip and autoprobe. diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index ccd0a95..a319905 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -3691,16 +3691,6 @@ #endif - Here, the chip instance is retrieved via - snd_kcontrol_chip() macro. This macro - just accesses to kcontrol->private_data. The - kcontrol->private_data field is - given as the argument of snd_ctl_new() - (see the later subsection - Constructor). - - - The value field is depending on the type of control as well as on info callback. For example, the sb driver uses this field to store the register offset, diff --git a/Documentation/sound/alsa/hda_codec.txt b/Documentation/sound/alsa/hda_codec.txt index 0be57ed..4eaae2a 100644 --- a/Documentation/sound/alsa/hda_codec.txt +++ b/Documentation/sound/alsa/hda_codec.txt @@ -277,11 +277,11 @@ Helper Functions snd_hda_get_codec_name() stores the codec name on the given string. snd_hda_check_board_config() can be used to obtain the configuration -information matching with the device. Define the table with struct -hda_board_config entries (zero-terminated), and pass it to the -function. The function checks the modelname given as a module -parameter, and PCI subsystem IDs. If the matching entry is found, it -returns the config field value. +information matching with the device. Define the model string table +and the table with struct snd_pci_quirk entries (zero-terminated), +and pass it to the function. The function checks the modelname given +as a module parameter, and PCI subsystem IDs. If the matching entry +is found, it returns the config field value. snd_hda_add_new_ctls() can be used to create and add control entries. Pass the zero-terminated array of struct snd_kcontrol_new. The same array diff --git a/Documentation/sound/alsa/soc/DAI.txt b/Documentation/sound/alsa/soc/DAI.txt new file mode 100644 index 0000000..251545a --- /dev/null +++ b/Documentation/sound/alsa/soc/DAI.txt @@ -0,0 +1,546 @@ +ASoC currently supports the three main Digital Audio Interfaces (DAI) found on +SoC controllers and portable audio CODECS today, namely AC97, I2S and PCM. + + +AC97 +==== + + AC97 is a five wire interface commonly found on many PC sound cards. It is +now also popular in many portable devices. This DAI has a reset line and time +multiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines. +The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and the +frame (FRAME) (usually 48kHz) is always driven by the controller. Each AC97 +frame is 21uS long and is divided into 13 time slots. + +The AC97 specification can be found at :- +http://www.intel.com/design/chipsets/audio/ac97_r23.pdf + + +I2S +=== + + I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and +Rx lines are used for audio transmision, whilst the bit clock (BCLK) and +left/right clock (LRC) synchronise the link. I2S is flexible in that either the +controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock +usually varies depending on the sample rate and the master system clock +(SYSCLK). LRCLK is the same as the sample rate. A few devices support separate +ADC and DAC LRCLK's, this allows for similtanious capture and playback at +different sample rates. + +I2S has several different operating modes:- + + o I2S - MSB is transmitted on the falling edge of the first BCLK after LRC + transition. + + o Left Justified - MSB is transmitted on transition of LRC. + + o Right Justified - MSB is transmitted sample size BCLK's before LRC + transition. + +PCM +=== + +PCM is another 4 wire interface, very similar to I2S, that can support a more +flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used +to synchronise the link whilst the Tx and Rx lines are used to transmit and +receive the audio data. Bit clock usually varies depending on sample rate +whilst sync runs at the sample rate. PCM also supports Time Division +Multiplexing (TDM) in that several devices can use the bus similtaniuosly (This +is sometimes referred to as network mode). + +Common PCM operating modes:- + + o Mode A - MSB is transmitted on falling edge of first BCLK after FRAME/SYNC. + + o Mode B - MSB is transmitted on rising edge of FRAME/SYNC. + + +ASoC DAI Configuration +====================== + +Every CODEC DAI and SoC DAI must have their capabilities defined in order to +be configured together at runtime when the audio and clocking parameters are +known. This is achieved by creating an array of struct snd_soc_hw_mode in the +the CODEC and SoC interface drivers. Each element in the array describes a DAI +mode and each mode is usually based upon the DAI system clock to sample rate +ratio (FS). + +i.e. 48k sample rate @ 256 FS = sytem clock of 12.288 MHz + 48000 * 256 = 12288000 + +The CPU and Codec DAI modes are then ANDed together at runtime to determine the +rutime DAI configuration for both the Codec and CPU. + +When creating a new codec or SoC DAI it's probably best to start of with a few +sample rates first and then test your interface. + +struct snd_soc_dai_mode is defined (in soc.h) as:- + +/* SoC DAI mode */ +struct snd_soc_dai_mode { + u16 fmt; /* SND_SOC_DAIFMT_* */ + u16 tdm; /* SND_SOC_HWTDM_* */ + u64 pcmfmt; /* SNDRV_PCM_FMTBIT_* */ + u16 pcmrate; /* SND_SOC_HWRATE_* */ + u16 pcmdir:2; /* SND_SOC_HWDIR_* */ + u16 flags:8; /* hw flags */ + u16 fs; /* mclk to rate divider */ + u64 bfs; /* mclk to bclk dividers */ + unsigned long priv; /* private mode data */ +}; + +fmt: +---- +This field defines the DAI mode hardware format (e.g. I2S settings) and +supports the following settings:- + + 1) hardware DAI formats + +#define SND_SOC_DAIFMT_I2S (1 << 0) /* I2S mode */ +#define SND_SOC_DAIFMT_RIGHT_J (1 << 1) /* Right justified mode */ +#define SND_SOC_DAIFMT_LEFT_J (1 << 2) /* Left Justified mode */ +#define SND_SOC_DAIFMT_DSP_A (1 << 3) /* L data msb after FRM */ +#define SND_SOC_DAIFMT_DSP_B (1 << 4) /* L data msb during FRM */ +#define SND_SOC_DAIFMT_AC97 (1 << 5) /* AC97 */ + + 2) hw DAI signal inversions + +#define SND_SOC_DAIFMT_NB_NF (1 << 8) /* normal bit clock + frame */ +#define SND_SOC_DAIFMT_NB_IF (1 << 9) /* normal bclk + inv frm */ +#define SND_SOC_DAIFMT_IB_NF (1 << 10) /* invert bclk + nor frm */ +#define SND_SOC_DAIFMT_IB_IF (1 << 11) /* invert bclk + frm */ + + 3) hw clock masters + This is wrt the codec, the inverse is true for the interface + i.e. if the codec is clk and frm master then the interface is + clk and frame slave. + +#define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & frm master */ +#define SND_SOC_DAIFMT_CBS_CFM (1 << 13) /* codec clk slave & frm master */ +#define SND_SOC_DAIFMT_CBM_CFS (1 << 14) /* codec clk master & frame slave */ +#define SND_SOC_DAIFMT_CBS_CFS (1 << 15) /* codec clk & frm slave */ + +At least one option from each section must be selected. Multiple selections are +also supported e.g. + + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_RIGHT_J | \ + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_IB_NF | \ + SND_SOC_DAIFMT_IB_IF + + +tdm: +------ +This field defines the Time Division Multiplexing left and right word +positions for the DAI mode if applicable. Set to SND_SOC_DAITDM_LRDW(0,0) for +no TDM. + + +pcmfmt: +--------- +The hardware PCM format. This describes the PCM formats supported by the DAI +mode e.g. + + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \ + SNDRV_PCM_FORMAT_S24_3LE + +pcmrate: +---------- +The PCM sample rates supported by the DAI mode. e.g. + + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 + + +pcmdir: +--------- +The stream directions supported by this mode. e.g. playback and capture + + +flags: +-------- +The DAI hardware flags supported by the mode. + +/* use bfs mclk divider mode (BCLK = MCLK / x) */ +#define SND_SOC_DAI_BFS_DIV 0x1 +/* use bfs rate mulitplier (BCLK = RATE * x)*/ +#define SND_SOC_DAI_BFS_RATE 0x2 +/* use bfs rcw multiplier (BCLK = RATE * CHN * WORD SIZE) */ +#define SND_SOC_DAI_BFS_RCW 0x4 +/* capture and playback can use different clocks */ +#define SND_SOC_DAI_ASYNC 0x8 + +NOTE: Bitclock division and mulitiplication modes can be safely matched by the +core logic. + + +fs: +----- +The FS supported by this DAI mode FS is the ratio between the system clock and +the sample rate. See above + +bfs: +------ +BFS is the ratio of BCLK to MCLK or the ratio of BCLK to sample rate (this +depends on the codec or CPU DAI). + +The BFS supported by the DAI mode. This can either be the ratio between the +bitclock (BCLK) and the sample rate OR the ratio between the system clock and +the sample rate. Depends on the flags above. + +priv: +----- +private codec mode data. + + + +Examples +======== + +Note that Codec DAI and CPU DAI examples are interchangeable in these examples +as long as the bus master is reversed. i.e. + + SND_SOC_DAIFMT_CBM_CFM would become SND_SOC_DAIFMT_CBS_CFS + and vice versa. + +This applies to all SND_SOC_DAIFMT_CB*_CF*. + +Example 1 +--------- + +Simple codec that only runs at 8k & 48k @ 256FS in master mode, can generate a +BCLK of either MCLK/2 or MCLK/4. + + /* codec master */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(2) | SND_SOC_FSBD(4), + } + + +Example 2 +--------- +Simple codec that only runs at 8k & 48k @ 256FS in master mode, can generate a +BCLK of either Rate * 32 or Rate * 64. + + /* codec master */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 256, + .bfs = 32, + }, + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 256, + .bfs = 64, + }, + + +Example 3 +--------- +Codec that runs at 8k & 48k @ 256FS in master mode, can generate a BCLK that +is a multiple of Rate * channels * word size. (RCW) i.e. + + BCLK = 8000 * 2 * 16 (8k, stereo, 16bit) + = 256kHz + +This codecs supports a RCW multiple of 1,2 + + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RCW, + .fs = 256, + .bfs = SND_SOC_FSBW(1) | SND_SOC_FSBW(2), + } + + +Example 4 +--------- +Codec that only runs at 8k & 48k @ 256FS in master mode, can generate a +BCLK of either Rate * 32 or Rate * 64. Codec can also run in slave mode as long +as BCLK is rate * 32 or rate * 64. + + /* codec master */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 256, + .bfs = 32, + }, + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 256, + .bfs = 64, + }, + + /* codec slave */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmdir = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = SND_SOC_FS_ALL, + .bfs = 32, + }, + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmdir = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = SND_SOC_FS_ALL, + .bfs = 64, + }, + + +Example 5 +--------- +Codec that only runs at 8k, 16k, 32k, 48k, 96k @ 128FS, 192FS & 256FS in master +mode and can generate a BCLK of MCLK / (1,2,4,8,16). Codec can also run in slave +mode as and does not care about FS or BCLK (as long as there is enough bandwidth). + + #define CODEC_FSB \ + (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \ + SND_SOC_FSBD(8) | SND_SOC_FSBD(16)) + + #define CODEC_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 |\ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000) + + /* codec master @ 128, 192 & 256 FS */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = CODEC_RATES, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 128, + .bfs = CODEC_FSB, + }, + + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = CODEC_RATES, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 192, + .bfs = CODEC_FSB + }, + + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = CODEC_RATES, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = CODEC_FSB, + }, + + /* codec slave */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = CODEC_RATES, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .fs = SND_SOC_FS_ALL, + .bfs = SND_SOC_FSB_ALL, + }, + + +Example 6 +--------- +Codec that only runs at 8k, 44.1k, 48k @ different FS in master mode (for use +with a fixed MCLK) and can generate a BCLK of MCLK / (1,2,4,8,16). +Codec can also run in slave mode as and does not care about FS or BCLK (as long +as there is enough bandwidth). Codec can support 16, 24 and 32 bit PCM sample +sizes. + + #define CODEC_FSB \ + (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \ + SND_SOC_FSBD(8) | SND_SOC_FSBD(16)) + + #define CODEC_PCM_FORMATS \ + (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \ + SNDRV_PCM_FORMAT_S24_3LE | SNDRV_PCM_FORMAT_S24_LE | SNDRV_PCM_FORMAT_S32_LE) + + /* codec master */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1536, + .bfs = CODEC_FSB, + }, + + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_44100, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 272, + .bfs = CODEC_FSB, + }, + + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = CODEC_FSB, + }, + + /* codec slave */ + { + .fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FORMAT_S16_LE, + .pcmrate = CODEC_RATES, + .pcmdir = SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE, + .fs = SND_SOC_FS_ALL, + .bfs = SND_SOC_FSB_ALL, + }, + + +Example 7 +--------- +AC97 Codec that does not support VRA (i.e only runs at 48k). + + #define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + + #define AC97_PCM_FORMATS \ + (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S18_3LE | \ + SNDRV_PCM_FORMAT_S20_3LE) + + /* AC97 with no VRA */ + { + .pcmfmt = AC97_PCM_FORMATS, + .pcmrate = SNDRV_PCM_RATE_48000, + } + + +Example 8 +--------- + +CPU DAI that supports 8k - 48k @ 256FS and BCLK = MCLK / 4 in master mode. +Slave mode (CPU DAI is FRAME master) supports 8k - 96k at any FS as long as +BCLK = 64 * rate. (Intel XScale I2S controller). + + #define PXA_I2S_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF) + + #define PXA_I2S_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + + #define PXA_I2S_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + + /* priv is divider */ + static struct snd_soc_dai_mode pxa2xx_i2s_modes[] = { + /* pxa2xx I2S frame and clock master modes */ + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x48, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_11025, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x34, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x24, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_22050, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x1a, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_44100, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0xd, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0xc, + }, + + /* pxa2xx I2S frame master and clock slave mode */ + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBM_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = PXA_I2S_RATES, + .pcmdir = PXA_I2S_DIR, + .fs = SND_SOC_FS_ALL, + .flags = SND_SOC_DAI_BFS_RATE, + .bfs = 64, + .priv = 0x48, + }, +}; diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt new file mode 100644 index 0000000..1f55fd8 --- /dev/null +++ b/Documentation/sound/alsa/soc/clocking.txt @@ -0,0 +1,314 @@ +Audio Clocking +============== + +This text describes the audio clocking terms in ASoC and digital audio in +general. Note: Audio clocking can be complex ! + + +Master Clock +------------ + +Every audio subsystem is driven by a master clock (sometimes refered to as MCLK +or SYSCLK). This audio master clock can be derived from a number of sources +(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct +audio playback and capture sample rates. + +Some master clocks (e.g. PLL's and CPU based clocks) are configuarble in that +their speed can be altered by software (depending on the system use and to save +power). Other master clocks are fixed at at set frequency (i.e. crystals). + + +DAI Clocks +---------- +The Digital Audio Interface is usually driven by a Bit Clock (often referred to +as BCLK). This clock is used to drive the digital audio data across the link +between the codec and CPU. + +The DAI also has a frame clock to signal the start of each audio frame. This +clock is sometimes referred to as LRC (left right clock) or FRAME. This clock +runs at exactly the sample rate (LRC = Rate). + +Bit Clock can be generated as follows:- + +BCLK = MCLK / x + + or + +BCLK = LRC * x + + or + +BCLK = LRC * Channels * Word Size + +This relationship depends on the codec or SoC CPU in particular. ASoC can quite +easily match BCLK generated by division (SND_SOC_DAI_BFS_DIV) with BCLK by +multiplication (SND_SOC_DAI_BFS_RATE) or BCLK generated by +Rate * Channels * Word size (RCW or SND_SOC_DAI_BFS_RCW). + + +ASoC Clocking +------------- + +The ASoC core determines the clocking for each particular configuration at +runtime. This is to allow for dynamic audio clocking wereby the audio clock is +variable and depends on the system state or device usage scenario. i.e. a voice +call requires slower clocks (and hence less power) than MP3 playback. + +ASoC will call the config_sysclock() function for the target machine during the +audio parameters configuration. The function is responsible for then clocking +the machine audio subsytem and returning the audio clock speed to the core. +This function should also call the codec and cpu DAI clock_config() functions +to configure their respective internal clocking if required. + + +ASoC Clocking Control Flow +-------------------------- + +The ASoC core will call the machine drivers config_sysclock() when most of the +DAI capabilities are known. The machine driver is then responsible for calling +the codec and/or CPU DAI drivers with the selected capabilities and the current +MCLK. Note that the machine driver is also resonsible for setting the MCLK (and +enabling it). + + (1) Match Codec and CPU DAI capabilities. At this point we have + matched the majority of the DAI fields and now need to make sure this + mode is currently clockable. + + (2) machine->config_sysclk() is now called with the matched DAI FS, sample + rate and BCLK master. This function then gets/sets the current audio + clock (depening on usage) and calls the codec and CPUI DAI drivers with + the FS, rate, BCLK master and MCLK. + + (3) Codec/CPU DAI config_sysclock(). This function checks that the FS, rate, + BCLK master and MCLK are acceptable for the codec or CPU DAI. It also + sets the DAI internal state to work with said clocks. + +The config_sysclk() functions for CPU, codec and machine should return the MCLK +on success and 0 on failure. + + +Examples (b = BCLK, l = LRC) +============================ + +Example 1 +--------- + +Simple codec that only runs at 48k @ 256FS in master mode. + +CPU only runs as slave DAI, however it generates a variable MCLK. + + -------- --------- + | | <----mclk--- | | + | Codec |b -----------> | CPU | + | |l -----------> | | + | | | | + -------- --------- + +The codec driver has the following config_sysclock() + + static unsigned int config_sysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) + { + /* make sure clock is 256 * rate */ + if(info->rate << 8 == clk) { + dai->mclk = clk; + return clk; + } + + return 0; + } + +The CPU I2S DAI driver has the following config_sysclk() + + static unsigned int config_sysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) + { + /* can we support this clk */ + if(set_audio_clk(clk) < 0) + return -EINVAL; + + dai->mclk = clk; + return dai->clk; + } + +The machine driver config_sysclk() in this example is as follows:- + + unsigned int machine_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) + { + int clk = info->rate * info->fs; + + /* check that CPU can deliver clock */ + if(rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, clk) < 0) + return -EINVAL; + + /* can codec work with this clock */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, clk); + } + + +Example 2 +--------- + +Codec that can master at 8k and 48k at various FS (and hence supports a fixed +set of input MCLK's) and can also be slave at various FS . + +The CPU can master at 8k and 48k @256 FS and can be slave at any FS. + +MCLK is a 12.288MHz crystal on this machine. + + -------- --------- + | | <---xtal---> | | + | Codec |b <----------> | CPU | + | |l <----------> | | + | | | | + -------- --------- + + +The codec driver has the following config_sysclock() + + /* supported input clocks */ + const static int hifi_clks[] = {11289600, 12000000, 12288000, + 16934400, 18432000}; + + static unsigned int config_hsysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) + { + int i; + + /* is clk supported */ + for(i = 0; i < ARRAY_SIZE(hifi_clks); i++) { + if(clk == hifi_clks[i]) { + dai->mclk = clk; + return clk; + } + } + + /* this clk is not supported */ + return 0; + } + +The CPU I2S DAI driver has the following config_sysclk() + + static unsigned int config_sysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) + { + /* are we master or slave */ + if (info->bclk_master & + (SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_CBM_CFS)) { + + /* we can only master @ 256FS */ + if(info->rate << 8 == clk) { + dai->mclk = clk; + return dai->mclk; + } + } else { + /* slave we can run at any FS */ + dai->mclk = clk; + return dai->mclk; + } + + /* not supported */ + return dai->clk; + } + +The machine driver config_sysclk() in this example is as follows:- + + unsigned int machine_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) + { + int clk = 12288000; /* 12.288MHz */ + + /* who's driving the link */ + if (info->bclk_master & + (SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_CBM_CFS)) { + /* codec master */ + + /* check that CPU can work with clock */ + if(rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, clk) < 0) + return -EINVAL; + + /* can codec work with this clock */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, clk); + } else { + /* cpu master */ + + /* check that codec can work with clock */ + if(rtd->codec_dai->config_sysclk(rtd->codec_dai, info, clk) < 0) + return -EINVAL; + + /* can CPU work with this clock */ + return rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, clk); + } + } + + + +Example 3 +--------- + +Codec that masters at 8k ... 48k @256 FS. Codec can also be slave and +doesn't care about FS. The codec has an internal PLL and dividers to generate +the necessary internal clocks (for 256FS). + +CPU can only be slave and doesn't care about FS. + +MCLK is a non controllable 13MHz clock from the CPU. + + + -------- --------- + | | <----mclk--- | | + | Codec |b <----------> | CPU | + | |l <----------> | | + | | | | + -------- --------- + +The codec driver has the following config_sysclock() + + /* valid PCM clock dividers * 2 */ + static int pcm_divs[] = {2, 6, 11, 4, 8, 12, 16}; + + static unsigned int config_vsysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) + { + int i, j, best_clk = info->fs * info->rate; + + /* can we run at this clk without the PLL ? */ + for (i = 0; i < ARRAY_SIZE(pcm_divs); i++) { + if ((best_clk >> 1) * pcm_divs[i] == clk) { + dai->pll_in = 0; + dai->clk_div = pcm_divs[i]; + dai->mclk = best_clk; + return dai->mclk; + } + } + + /* now check for PLL support */ + for (i = 0; i < ARRAY_SIZE(pll_div); i++) { + if (pll_div[i].pll_in == clk) { + for (j = 0; j < ARRAY_SIZE(pcm_divs); j++) { + if (pll_div[i].pll_out == pcm_divs[j] * (best_clk >> 1)) { + dai->pll_in = clk; + dai->pll_out = pll_div[i].pll_out; + dai->clk_div = pcm_divs[j]; + dai->mclk = best_clk; + return dai->mclk; + } + } + } + } + + /* this clk is not supported */ + return 0; + } + + +The CPU I2S DAI driver has the does not need a config_sysclk() as it can slave +at any FS. + + unsigned int config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) + { + /* codec has pll that generates mclk from 13MHz xtal */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, 13000000); + } diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt new file mode 100644 index 0000000..274657a --- /dev/null +++ b/Documentation/sound/alsa/soc/codec.txt @@ -0,0 +1,232 @@ +ASoC Codec Driver +================= + +The codec driver is generic and hardware independent code that configures the +codec to provide audio capture and playback. It should contain no code that is +specific to the target platform or machine. All platform and machine specific +code should be added to the platform and machine drivers respectively. + +Each codec driver must provide the following features:- + + 1) Digital audio interface (DAI) description + 2) Digital audio interface configuration + 3) PCM's description + 4) Codec control IO - using I2C, 3 Wire(SPI) or both API's + 5) Mixers and audio controls + 6) Sysclk configuration + 7) Codec audio operations + +Optionally, codec drivers can also provide:- + + 8) DAPM description. + 9) DAPM event handler. +10) DAC Digital mute control. + +It's probably best to use this guide in conjuction with the existing codec +driver code in sound/soc/codecs/ + +ASoC Codec driver breakdown +=========================== + +1 - Digital Audio Interface (DAI) description +--------------------------------------------- +The DAI is a digital audio data transfer link between the codec and host SoC +CPU. It typically has data transfer capabilities in both directions +(playback and capture) and can run at a variety of different speeds. +Supported interfaces currently include AC97, I2S and generic PCM style links. +Please read DAI.txt for implementation information. + + +2 - Digital Audio Interface (DAI) configuration +----------------------------------------------- +DAI configuration is handled by the codec_pcm_prepare function and is +responsible for configuring and starting the DAI on the codec. This can be +called multiple times and is atomic. It can access the runtime parameters. + +This usually consists of a large function with numerous switch statements to +set up each configuration option. These options are set by the core at runtime. + + +3 - Codec PCM's +--------------- +Each codec must have it's PCM's defined. This defines the number of channels, +stream names, callbacks and codec name. It is also used to register the DAI +with the ASoC core. The PCM structure also associates the DAI capabilities with +the ALSA PCM. + +e.g. + +static struct snd_soc_pcm_codec wm8731_pcm_client = { + .name = "WM8731", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + }, + .config_sysclk = wm8731_config_sysclk, + .ops = { + .prepare = wm8731_pcm_prepare, + }, + .caps = { + .num_modes = ARRAY_SIZE(wm8731_hwfmt), + .modes = &wm8731_hwfmt[0], + }, +}; + + +4 - Codec control IO +-------------------- +The codec can ususally be controlled via an I2C or SPI style interface (AC97 +combines control with data in the DAI). The codec drivers will have to provide +functions to read and write the codec registers along with supplying a register +cache:- + + /* IO control data and register cache */ + void *control_data; /* codec control (i2c/3wire) data */ + void *reg_cache; + +Codec read/write should do any data formatting and call the hardware read write +below to perform the IO. These functions are called by the core and alsa when +performing DAPM or changing the mixer:- + + unsigned int (*read)(struct snd_soc_codec *, unsigned int); + int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); + +Codec hardware IO functions - usually points to either the I2C, SPI or AC97 +read/write:- + + hw_write_t hw_write; + hw_read_t hw_read; + + +5 - Mixers and audio controls +----------------------------- +All the codec mixers and audio controls can be defined using the convenience +macros defined in soc.h. + + #define SOC_SINGLE(xname, reg, shift, mask, invert) + +Defines a single control as follows:- + + xname = Control name e.g. "Playback Volume" + reg = codec register + shift = control bit(s) offset in register + mask = control bit size(s) e.g. mask of 7 = 3 bits + invert = the control is inverted + +Other macros include:- + + #define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) + +A stereo control + + #define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert) + +A stereo control spanning 2 registers + + #define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) + +Defines an single enumerated control as follows:- + + xreg = register + xshift = control bit(s) offset in register + xmask = control bit(s) size + xtexts = pointer to array of strings that describe each setting + + #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) + +Defines a stereo enumerated control + + +6 - System clock configuration. +------------------------------- +The system clock that drives the audio subsystem can change depending on sample +rate and the system power state. i.e. + +o Higher sample rates sometimes need a higher system clock. +o Low system power states can sometimes limit the available clocks. + +This function is a callback that the machine driver can call to set and +determine if the clock and sample rate combination is supported by the codec at +the present time (and system state). + +NOTE: If the codec has a PLL then it has a lot more flexability wrt clock and +sample rate combinations. + +Your config_sysclock function should return the MCLK if it's a valid +combination for your codec else 0; + +Please read clocking.txt now. + + +7 - Codec Audio Operations +-------------------------- +The codec driver also supports the following alsa operations:- + +/* SoC audio ops */ +struct snd_soc_ops { + int (*startup)(struct snd_pcm_substream *); + void (*shutdown)(struct snd_pcm_substream *); + int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); + int (*hw_free)(struct snd_pcm_substream *); + int (*prepare)(struct snd_pcm_substream *); +}; + +Please refer to the alsa driver PCM documentation for details. +http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm + + +8 - DAPM description. +--------------------- +The Dynamic Audio Power Management description describes the codec's power +components, their relationships and registers to the ASoC core. Please read +dapm.txt for details of building the description. + +Please also see the examples in other codec drivers. + + +9 - DAPM event handler +---------------------- +This function is a callback that handles codec domain PM calls and system +domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep +when not in use. + +Power states:- + + SNDRV_CTL_POWER_D0: /* full On */ + /* vref/mid, clk and osc on, active */ + + SNDRV_CTL_POWER_D1: /* partial On */ + SNDRV_CTL_POWER_D2: /* partial On */ + + SNDRV_CTL_POWER_D3hot: /* Off, with power */ + /* everything off except vref/vmid, inactive */ + + SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */ + + +10 - Codec DAC digital mute control. +------------------------------------ +Most codecs have a digital mute before the DAC's that can be used to minimise +any system noise. The mute stops any digital data from entering the DAC. + +A callback can be created that is called by the core for each codec DAI when the +mute is applied or freed. + +i.e. + +static int wm8974_mute(struct snd_soc_codec *codec, + struct snd_soc_codec_dai *dai, int mute) +{ + u16 mute_reg = wm8974_read_reg_cache(codec, WM8974_DAC) & 0xffbf; + if(mute) + wm8974_write(codec, WM8974_DAC, mute_reg | 0x40); + else + wm8974_write(codec, WM8974_DAC, mute_reg); + return 0; +} diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt new file mode 100644 index 0000000..c11877f --- /dev/null +++ b/Documentation/sound/alsa/soc/dapm.txt @@ -0,0 +1,297 @@ +Dynamic Audio Power Management for Portable Devices +=================================================== + +1. Description +============== + +Dynamic Audio Power Management (DAPM) is designed to allow portable Linux devices +to use the minimum amount of power within the audio subsystem at all times. It +is independent of other kernel PM and as such, can easily co-exist with the +other PM systems. + +DAPM is also completely transparent to all user space applications as all power +switching is done within the ASoC core. No code changes or recompiling are +required for user space applications. DAPM makes power switching descisions based +upon any audio stream (capture/playback) activity and audio mixer settings +within the device. + +DAPM spans the whole machine. It covers power control within the entire audio +subsystem, this includes internal codec power blocks and machine level power +systems. + +There are 4 power domains within DAPM + + 1. Codec domain - VREF, VMID (core codec and audio power) + Usually controlled at codec probe/remove and suspend/resume, although + can be set at stream time if power is not needed for sidetone, etc. + + 2. Platform/Machine domain - physically connected inputs and outputs + Is platform/machine and user action specific, is configured by the + machine driver and responds to asynchronous events e.g when HP + are inserted + + 3. Path domain - audio susbsystem signal paths + Automatically set when mixer and mux settings are changed by the user. + e.g. alsamixer, amixer. + + 4. Stream domain - DAC's and ADC's. + Enabled and disabled when stream playback/capture is started and + stopped respectively. e.g. aplay, arecord. + +All DAPM power switching descisons are made automatically by consulting an audio +routing map of the whole machine. This map is specific to each machine and +consists of the interconnections between every audio component (including +internal codec components). All audio components that effect power are called +widgets hereafter. + + +2. DAPM Widgets +=============== + +Audio DAPM widgets fall into a number of types:- + + o Mixer - Mixes several analog signals into a single analog signal. + o Mux - An analog switch that outputs only 1 of it's inputs. + o PGA - A programmable gain amplifier or attenuation widget. + o ADC - Analog to Digital Converter + o DAC - Digital to Analog Converter + o Switch - An analog switch + o Input - A codec input pin + o Output - A codec output pin + o Headphone - Headphone (and optional Jack) + o Mic - Mic (and optional Jack) + o Line - Line Input/Output (and optional Jack) + o Speaker - Speaker + o Pre - Special PRE widget (exec before all others) + o Post - Special POST widget (exec after all others) + +(Widgets are defined in include/sound/soc-dapm.h) + +Widgets are usually added in the codec driver and the machine driver. There are +convience macros defined in soc-dapm.h that can be used to quickly build a +list of widgets of the codecs and machines DAPM widgets. + +Most widgets have a name, register, shift and invert. Some widgets have extra +parameters for stream name and kcontrols. + + +2.1 Stream Domain Widgets +------------------------- + +Stream Widgets relate to the stream power domain and only consist of ADC's +(analog to digital converters) and DAC's (digital to analog converters). + +Stream widgets have the following format:- + +SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), + +NOTE: the stream name must match the corresponding stream name in your codecs +snd_soc_codec_dai. + +e.g. stream widgets for HiFi playback and capture + +SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), +SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), + + +2.2 Path Domain Widgets +----------------------- + +Path domain widgets have a ability to control or effect the audio signal or +audio paths within the audio subsystem. They have the following form:- + +SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls) + +Any widget kcontrols can be set using the controls and num_controls members. + +e.g. Mixer widget (the kcontrols are declared first) + +/* Output Mixer */ +static const snd_kcontrol_new_t wm8731_output_mixer_controls[] = { +SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0), +SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA, 5, 1, 0), +SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0), +}; + +SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls, + ARRAY_SIZE(wm8731_output_mixer_controls)), + + +2.3 Platform/Machine domain Widgets +----------------------------------- + +Machine widgets are different from codec widgets in that they don't have a +codec register bit associated with them. A machine widget is assigned to each +machine audio component (non codec) that can be independently powered. e.g. + + o Speaker Amp + o Microphone Bias + o Jack connectors + +A machine widget can have an optional call back. + +e.g. Jack connector widget for an external Mic that enables Mic Bias +when the Mic is inserted:- + +static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event) +{ + if(SND_SOC_DAPM_EVENT_ON(event)) + set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS); + else + reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS); + + return 0; +} + +SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), + + +2.4 Codec Domain +---------------- + +The Codec power domain has no widgets and is handled by the codecs DAPM event +handler. This handler is called when the codec powerstate is changed wrt to any +stream event or by kernel PM events. + + +2.5 Virtual Widgets +------------------- + +Sometimes widgets exist in the codec or machine audio map that don't have any +corresponding register bit for power control. In this case it's necessary to +create a virtual widget - a widget with no control bits e.g. + +SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0), + +This can be used to merge to signal paths together in software. + +After all the widgets have been defined, they can then be added to the DAPM +subsystem individually with a call to snd_soc_dapm_new_control(). + + +3. Codec Widget Interconnections +================================ + +Widgets are connected to each other within the codec and machine by audio +paths (called interconnections). Each interconnection must be defined in order +to create a map of all audio paths between widgets. +This is easiest with a diagram of the codec (and schematic of the machine audio +system), as it requires joining widgets together via their audio signal paths. + +i.e. from the WM8731 codec's output mixer (wm8731.c) + +The WM8731 output mixer has 3 inputs (sources) + + 1. Line Bypass Input + 2. DAC (HiFi playback) + 3. Mic Sidetone Input + +Each input in this example has a kcontrol associated with it (defined in example +above) and is connected to the output mixer via it's kcontrol name. We can now +connect the destination widget (wrt audio signal) with it's source widgets. + + /* output mixer */ + {"Output Mixer", "Line Bypass Switch", "Line Input"}, + {"Output Mixer", "HiFi Playback Switch", "DAC"}, + {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"}, + +So we have :- + + Destination Widget <=== Path Name <=== Source Widget + +Or:- + + Sink, Path, Source + +Or :- + + "Output Mixer" is connected to the "DAC" via the "HiFi Playback Switch". + +When there is no path name connecting widgets (e.g. a direct connection) we +pass NULL for the path name. + +Interconnections are created with a call to:- + +snd_soc_dapm_connect_input(codec, sink, path, source); + +Finally, snd_soc_dapm_new_widgets(codec) must be called after all widgets and +interconnections have been registered with the core. This causes the core to +scan the codec and machine so that the internal DAPM state matches the +physical state of the machine. + + +3.1 Machine Widget Interconnections +----------------------------------- +Machine widget interconnections are created in the same way as codec ones and +directly connect the codec pins to machine level widgets. + +e.g. connects the speaker out codec pins to the internal speaker. + + /* ext speaker connected to codec pins LOUT2, ROUT2 */ + {"Ext Spk", NULL , "ROUT2"}, + {"Ext Spk", NULL , "LOUT2"}, + +This allows the DAPM to power on and off pins that are connected (and in use) +and pins that are NC respectively. + + +4 Endpoint Widgets +=================== +An endpoint is a start or end point (widget) of an audio signal within the +machine and includes the codec. e.g. + + o Headphone Jack + o Internal Speaker + o Internal Mic + o Mic Jack + o Codec Pins + +When a codec pin is NC it can be marked as not used with a call to + +snd_soc_dapm_set_endpoint(codec, "Widget Name", 0); + +The last argument is 0 for inactive and 1 for active. This way the pin and its +input widget will never be powered up and consume power. + +This also applies to machine widgets. e.g. if a headphone is connected to a +jack then the jack can be marked active. If the headphone is removed, then +the headphone jack can be marked inactive. + + +5 DAPM Widget Events +==================== + +Some widgets can register their interest with the DAPM core in PM events. +e.g. A Speaker with an amplifier registers a widget so the amplifier can be +powered only when the spk is in use. + +/* turn speaker amplifier on/off depending on use */ +static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event) +{ + if (SND_SOC_DAPM_EVENT_ON(event)) + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); + else + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); + + return 0; +} + +/* corgi machine dapm widgets */ +static const struct snd_soc_dapm_widget wm8731_dapm_widgets = + SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event); + +Please see soc-dapm.h for all other widgets that support events. + + +5.1 Event types +--------------- + +The following event types are supported by event widgets. + +/* dapm event types */ +#define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ +#define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ +#define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ +#define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ +#define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ +#define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt new file mode 100644 index 0000000..3014795 --- /dev/null +++ b/Documentation/sound/alsa/soc/machine.txt @@ -0,0 +1,114 @@ +ASoC Machine Driver +=================== + +The ASoC machine (or board) driver is the code that glues together the platform +and codec drivers. + +The machine driver can contain codec and platform specific code. It registers +the audio subsystem with the kernel as a platform device and is represented by +the following struct:- + +/* SoC machine */ +struct snd_soc_machine { + char *name; + + int (*probe)(struct platform_device *pdev); + int (*remove)(struct platform_device *pdev); + + /* the pre and post PM functions are used to do any PM work before and + * after the codec and DAI's do any PM work. */ + int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); + int (*suspend_post)(struct platform_device *pdev, pm_message_t state); + int (*resume_pre)(struct platform_device *pdev); + int (*resume_post)(struct platform_device *pdev); + + /* machine stream operations */ + struct snd_soc_ops *ops; + + /* CPU <--> Codec DAI links */ + struct snd_soc_dai_link *dai_link; + int num_links; +}; + +probe()/remove() +---------------- +probe/remove are optional. Do any machine specific probe here. + + +suspend()/resume() +------------------ +The machine driver has pre and post versions of suspend and resume to take care +of any machine audio tasks that have to be done before or after the codec, DAI's +and DMA is suspended and resumed. Optional. + + +Machine operations +------------------ +The machine specific audio operations can be set here. Again this is optional. + + +Machine DAI Configuration +------------------------- +The machine DAI configuration glues all the codec and CPU DAI's together. It can +also be used to set up the DAI system clock and for any machine related DAI +initialisation e.g. the machine audio map can be connected to the codec audio +map, unconnnected codec pins can be set as such. Please see corgi.c, spitz.c +for examples. + +struct snd_soc_dai_link is used to set up each DAI in your machine. e.g. + +/* corgi digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link corgi_dai = { + .name = "WM8731", + .stream_name = "WM8731", + .cpu_dai = &pxa_i2s_dai, + .codec_dai = &wm8731_dai, + .init = corgi_wm8731_init, + .config_sysclk = corgi_config_sysclk, +}; + +struct snd_soc_machine then sets up the machine with it's DAI's. e.g. + +/* corgi audio machine driver */ +static struct snd_soc_machine snd_soc_machine_corgi = { + .name = "Corgi", + .dai_link = &corgi_dai, + .num_links = 1, + .ops = &corgi_ops, +}; + + +Machine Audio Subsystem +----------------------- + +The machine soc device glues the platform, machine and codec driver together. +Private data can also be set here. e.g. + +/* corgi audio private data */ +static struct wm8731_setup_data corgi_wm8731_setup = { + .i2c_address = 0x1b, +}; + +/* corgi audio subsystem */ +static struct snd_soc_device corgi_snd_devdata = { + .machine = &snd_soc_machine_corgi, + .platform = &pxa2xx_soc_platform, + .codec_dev = &soc_codec_dev_wm8731, + .codec_data = &corgi_wm8731_setup, +}; + + +Machine Power Map +----------------- + +The machine driver can optionally extend the codec power map and to become an +audio power map of the audio subsystem. This allows for automatic power up/down +of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack +sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for +details. + + +Machine Controls +---------------- + +Machine specific audio mixer controls can be added in the dai init function. \ No newline at end of file diff --git a/Documentation/sound/alsa/soc/overview.txt b/Documentation/sound/alsa/soc/overview.txt new file mode 100644 index 0000000..753c5cc --- /dev/null +++ b/Documentation/sound/alsa/soc/overview.txt @@ -0,0 +1,83 @@ +ALSA SoC Layer +============== + +The overall project goal of the ALSA System on Chip (ASoC) layer is to provide +better ALSA support for embedded system on chip procesors (e.g. pxa2xx, au1x00, +iMX, etc) and portable audio codecs. Currently there is some support in the +kernel for SoC audio, however it has some limitations:- + + * Currently, codec drivers are often tightly coupled to the underlying SoC + cpu. This is not ideal and leads to code duplication i.e. Linux now has 4 + different wm8731 drivers for 4 different SoC platforms. + + * There is no standard method to signal user initiated audio events. + e.g. Headphone/Mic insertion, Headphone/Mic detection after an insertion + event. These are quite common events on portable devices and ofter require + machine specific code to re route audio, enable amps etc after such an event. + + * Current drivers tend to power up the entire codec when playing + (or recording) audio. This is fine for a PC, but tends to waste a lot of + power on portable devices. There is also no support for saving power via + changing codec oversampling rates, bias currents, etc. + + +ASoC Design +=========== + +The ASoC layer is designed to address these issues and provide the following +features :- + + * Codec independence. Allows reuse of codec drivers on other platforms + and machines. + + * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC interface + and codec registers it's audio interface capabilities with the core and are + subsequently matched and configured when the application hw params are known. + + * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to + it's minimum power state at all times. This includes powering up/down + internal power blocks depending on the internal codec audio routing and any + active streams. + + * Pop and click reduction. Pops and clicks can be reduced by powering the + codec up/down in the correct sequence (including using digital mute). ASoC + signals the codec when to change power states. + + * Machine specific controls: Allow machines to add controls to the sound card + e.g. volume control for speaker amp. + +To achieve all this, ASoC basically splits an embedded audio system into 3 +components :- + + * Codec driver: The codec driver is platform independent and contains audio + controls, audio interface capabilities, codec dapm definition and codec IO + functions. + + * Platform driver: The platform driver contains the audio dma engine and audio + interface drivers (e.g. I2S, AC97, PCM) for that platform. + + * Machine driver: The machine driver handles any machine specific controls and + audio events. i.e. turing on an amp at start of playback. + + +Documentation +============= + +The documentation is spilt into the following sections:- + +overview.txt: This file. + +codec.txt: Codec driver internals. + +DAI.txt: Description of Digital Audio Interface standards and how to configure +a DAI within your codec and CPU DAI drivers. + +dapm.txt: Dynamic Audio Power Management + +platform.txt: Platform audio DMA and DAI. + +machine.txt: Machine driver internals. + +pop_clicks.txt: How to minimise audio artifacts. + +clocking.txt: ASoC clocking for best power performance. \ No newline at end of file diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt new file mode 100644 index 0000000..e95b16d --- /dev/null +++ b/Documentation/sound/alsa/soc/platform.txt @@ -0,0 +1,58 @@ +ASoC Platform Driver +==================== + +An ASoC platform driver can be divided into audio DMA and SoC DAI configuration +and control. The platform drivers only target the SoC CPU and must have no board +specific code. + +Audio DMA +========= + +The platform DMA driver optionally supports the following alsa operations:- + +/* SoC audio ops */ +struct snd_soc_ops { + int (*startup)(struct snd_pcm_substream *); + void (*shutdown)(struct snd_pcm_substream *); + int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); + int (*hw_free)(struct snd_pcm_substream *); + int (*prepare)(struct snd_pcm_substream *); + int (*trigger)(struct snd_pcm_substream *, int); +}; + +The platform driver exports it's DMA functionailty via struct snd_soc_platform:- + +struct snd_soc_platform { + char *name; + + int (*probe)(struct platform_device *pdev); + int (*remove)(struct platform_device *pdev); + int (*suspend)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai); + int (*resume)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai); + + /* pcm creation and destruction */ + int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, struct snd_pcm *); + void (*pcm_free)(struct snd_pcm *); + + /* platform stream ops */ + struct snd_pcm_ops *pcm_ops; +}; + +Please refer to the alsa driver documentation for details of audio DMA. +http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm + +An example DMA driver is soc/pxa/pxa2xx-pcm.c + + +SoC DAI Drivers +=============== + +Each SoC DAI driver must provide the following features:- + + 1) Digital audio interface (DAI) description + 2) Digital audio interface configuration + 3) PCM's description + 4) Sysclk configuration + 5) Suspend and resume (optional) + +Please see codec.txt for a description of items 1 - 4. diff --git a/Documentation/sound/alsa/soc/pops_clicks.txt b/Documentation/sound/alsa/soc/pops_clicks.txt new file mode 100644 index 0000000..f4f8de5 --- /dev/null +++ b/Documentation/sound/alsa/soc/pops_clicks.txt @@ -0,0 +1,52 @@ +Audio Pops and Clicks +===================== + +Pops and clicks are unwanted audio artifacts caused by the powering up and down +of components within the audio subsystem. This is noticable on PC's when an audio +module is either loaded or unloaded (at module load time the sound card is +powered up and causes a popping noise on the speakers). + +Pops and clicks can be more frequent on portable systems with DAPM. This is because +the components within the subsystem are being dynamically powered depending on +the audio usage and this can subsequently cause a small pop or click every time a +component power state is changed. + + +Minimising Playback Pops and Clicks +=================================== + +Playback pops in portable audio subsystems cannot be completely eliminated atm, +however future audio codec hardware will have better pop and click supression. +Pops can be reduced within playback by powering the audio components in a +specific order. This order is different for startup and shutdown and follows +some basic rules:- + + Startup Order :- DAC --> Mixers --> Output PGA --> Digital Unmute + + Shutdown Order :- Digital Mute --> Output PGA --> Mixers --> DAC + +This assumes that the codec PCM output path from the DAC is via a mixer and then +a PGA (programmable gain amplifier) before being output to the speakers. + + +Minimising Capture Pops and Clicks +================================== + +Capture artifacts are somewhat easier to get rid as we can delay activating the +ADC until all the pops have occured. This follows similar power rules to +playback in that components are powered in a sequence depending upon stream +startup or shutdown. + + Startup Order - Input PGA --> Mixers --> ADC + + Shutdown Order - ADC --> Mixers --> Input PGA + + +Zipper Noise +============ +An unwanted zipper noise can occur within the audio playback or capture stream +when a volume control is changed near its maximum gain value. The zipper noise +is heard when the gain increase or decrease changes the mean audio signal +amplitude too quickly. It can be minimised by enabling the zero cross setting +for each volume control. The ZC forces the gain change to occur when the signal +crosses the zero amplitude line. diff --git a/MAINTAINERS b/MAINTAINERS index db09036..9e46c2c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2841,6 +2841,12 @@ M: perex@suse.cz L: alsa-devel@alsa-project.org S: Maintained +SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT +P: Liam Girdwood +M: liam.girdwood@wolfsonmicro.com +L: alsa-devel@alsa-project.org +S: Supported + SPI SUBSYSTEM P: David Brownell M: dbrownell@users.sourceforge.net diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index 4358a0a..c7db403 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c @@ -83,7 +83,7 @@ #define UCB_ID_1400 0x4304 struct ucb1400 { - ac97_t *ac97; + struct snd_ac97 *ac97; struct input_dev *ts_idev; int irq; diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index d38778f..6e7ec4c 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -115,6 +115,8 @@ #define I2C_DRIVERID_BT866 85 /* Conexan #define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */ #define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */ #define I2C_DRIVERID_ISL1208 88 /* Intersil ISL1208 RTC */ +#define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */ +#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */ #define I2C_DRIVERID_I2CDEV 900 #define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */ diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index 3372039..246ac23 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -375,6 +375,7 @@ #define AC97_SCAP_INV_EAPD (1<<7) /* inv #define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */ #define AC97_SCAP_NO_SPDIF (1<<9) /* don't build SPDIF controls */ #define AC97_SCAP_EAPD_LED (1<<10) /* EAPD as mute LED */ +#define AC97_SCAP_POWER_SAVE (1<<11) /* capable for aggresive power-saving */ /* ac97->flags */ #define AC97_HAS_PC_BEEP (1<<0) /* force PC Speaker usage */ @@ -425,6 +426,7 @@ #endif struct snd_ac97_bus_ops { void (*reset) (struct snd_ac97 *ac97); + void (*warm_reset)(struct snd_ac97 *ac97); void (*write) (struct snd_ac97 *ac97, unsigned short reg, unsigned short val); unsigned short (*read) (struct snd_ac97 *ac97, unsigned short reg); void (*wait) (struct snd_ac97 *ac97); @@ -501,6 +503,7 @@ struct snd_ac97 { unsigned short id[3]; // codec IDs (lower 16-bit word) unsigned short pcmreg[3]; // PCM registers unsigned short codec_cfg[3]; // CODEC_CFG bits + unsigned char swap_mic_linein; // AD1986/AD1986A only } ad18xx; unsigned int dev_flags; /* device specific */ } spec; @@ -510,7 +513,6 @@ struct snd_ac97 { #ifdef CONFIG_SND_AC97_POWER_SAVE unsigned int power_up; /* power states */ - struct workqueue_struct *power_workq; struct delayed_work power_work; #endif struct device dev; diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h index 2ee0616..85f49d4 100644 --- a/include/sound/ak4114.h +++ b/include/sound/ak4114.h @@ -181,7 +181,6 @@ struct ak4114 { unsigned long ccrc_errors; unsigned char rcs0; unsigned char rcs1; - struct workqueue_struct *workqueue; struct delayed_work work; void *change_callback_private; void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h index d0deca6..d01d535 100644 --- a/include/sound/ak4xxx-adda.h +++ b/include/sound/ak4xxx-adda.h @@ -50,6 +50,8 @@ struct snd_akm4xxx_adc_channel { char *name; /* capture gain volume label */ char *switch_name; /* capture switch */ unsigned int num_channels; + char *selector_name; /* capture source select label */ + const char **input_names; /* capture source names (NULL terminated) */ }; struct snd_akm4xxx { diff --git a/include/sound/control.h b/include/sound/control.h index 1de148b..f1361d6 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -108,7 +108,6 @@ typedef int (*snd_kctl_ioctl_func_t) (st void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id); -struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol * kcontrol, unsigned int access); struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data); void snd_ctl_free_one(struct snd_kcontrol * kcontrol); int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); diff --git a/include/sound/core.h b/include/sound/core.h index a994bea..7230a3f 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -199,9 +199,40 @@ extern struct class *sound_class; void snd_request_card(int card); -int snd_register_device(int type, struct snd_card *card, int dev, - const struct file_operations *f_ops, void *private_data, - const char *name); +int snd_register_device_for_dev(int type, struct snd_card *card, + int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name, + struct device *device); + +/** + * snd_register_device - Register the ALSA device file for the card + * @type: the device type, SNDRV_DEVICE_TYPE_XXX + * @card: the card instance + * @dev: the device index + * @f_ops: the file operations + * @private_data: user pointer for f_ops->open() + * @name: the device file name + * + * Registers an ALSA device file for the given card. + * The operators have to be set in reg parameter. + * + * This function uses the card's device pointer to link to the + * correct &struct device. + * + * Returns zero if successful, or a negative error code on failure. + */ +static inline int snd_register_device(int type, struct snd_card *card, int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name) +{ + return snd_register_device_for_dev(type, card, dev, f_ops, + private_data, name, + card ? card->dev : NULL); +} + int snd_unregister_device(int type, struct snd_card *card, int dev); void *snd_lookup_minor_data(unsigned int minor, int type); int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, @@ -384,6 +415,29 @@ #define gameport_get_port_data(gp) (gp)- #endif #endif -#include "typedefs.h" +/* PCI quirk list helper */ +struct snd_pci_quirk { + unsigned short subvendor; /* PCI subvendor ID */ + unsigned short subdevice; /* PCI subdevice ID */ + int value; /* value */ +#ifdef CONFIG_SND_DEBUG_DETECT + const char *name; /* name of the device (optional) */ +#endif +}; + +#define _SND_PCI_QUIRK_ID(vend,dev) \ + .subvendor = (vend), .subdevice = (dev) +#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} +#ifdef CONFIG_SND_DEBUG_DETECT +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} +#else +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} +#endif + +const struct snd_pci_quirk * +snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); + #endif /* __SOUND_CORE_H */ diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 3d3c151..adca71b 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -188,7 +188,35 @@ #define HCFG_LEGACYWORD 0x00400000 /* 1 #define HCFG_LEGACYINT 0x00200000 /* 1 = legacy event captured. Write 1 to clear. */ /* NOTE: The rest of the bits in this register */ /* _are_ relevant under Linux. */ -#define HCFG_CODECFORMAT_MASK 0x00070000 /* CODEC format */ +#define HCFG_PUSH_BUTTON_ENABLE 0x00100000 /* Enables Volume Inc/Dec and Mute functions */ +#define HCFG_BAUD_RATE 0x00080000 /* 0 = 48kHz, 1 = 44.1kHz */ +#define HCFG_EXPANDED_MEM 0x00040000 /* 1 = any 16M of 4G addr, 0 = 32M of 2G addr */ +#define HCFG_CODECFORMAT_MASK 0x00030000 /* CODEC format */ + +/* Specific to Alice2, CA0102 */ +#define HCFG_CODECFORMAT_AC97_1 0x00000000 /* AC97 CODEC format -- Ver 1.03 */ +#define HCFG_CODECFORMAT_AC97_2 0x00010000 /* AC97 CODEC format -- Ver 2.1 */ +#define HCFG_AUTOMUTE_ASYNC 0x00008000 /* When set, the async sample rate convertors */ + /* will automatically mute their output when */ + /* they are not rate-locked to the external */ + /* async audio source */ +#define HCFG_AUTOMUTE_SPDIF 0x00004000 /* When set, the async sample rate convertors */ + /* will automatically mute their output when */ + /* the SPDIF V-bit indicates invalid audio */ +#define HCFG_EMU32_SLAVE 0x00002000 /* 0 = Master, 1 = Slave. Slave for EMU1010 */ +#define HCFG_SLOW_RAMP 0x00001000 /* Increases Send Smoothing time constant */ +/* 0x00000800 not used on Alice2 */ +#define HCFG_PHASE_TRACK_MASK 0x00000700 /* When set, forces corresponding input to */ + /* phase track the previous input. */ + /* I2S0 can phase track the last S/PDIF input */ +#define HCFG_I2S_ASRC_ENABLE 0x00000070 /* When set, enables asynchronous sample rate */ + /* conversion for the corresponding */ + /* I2S format input */ +/* Rest of HCFG 0x0000000f same as below. LOCKSOUNDCACHE etc. */ + + + +/* Older chips */ #define HCFG_CODECFORMAT_AC97 0x00000000 /* AC97 CODEC format -- Primary Output */ #define HCFG_CODECFORMAT_I2S 0x00010000 /* I2S CODEC format -- Secondary (Rear) Output */ #define HCFG_GPINPUT0 0x00004000 /* External pin112 */ @@ -432,6 +460,7 @@ #define FXRT_CHANNELB 0x00f00000 /* Eff #define FXRT_CHANNELC 0x0f000000 /* Effects send bus number for channel's effects send C */ #define FXRT_CHANNELD 0xf0000000 /* Effects send bus number for channel's effects send D */ +#define A_HR 0x0b /* High Resolution. 24bit playback from host to DSP. */ #define MAPA 0x0c /* Cache map A */ #define MAPB 0x0d /* Cache map B */ @@ -439,6 +468,8 @@ #define MAPB 0x0d /* Cache map B #define MAP_PTE_MASK 0xffffe000 /* The 19 MSBs of the PTE indexed by the PTI */ #define MAP_PTI_MASK 0x00001fff /* The 13 bit index to one of the 8192 PTE dwords */ +/* 0x0e, 0x0f: Not used */ + #define ENVVOL 0x10 /* Volume envelope register */ #define ENVVOL_MASK 0x0000ffff /* Current value of volume envelope state variable */ /* 0x8000-n == 666*n usec delay */ @@ -527,7 +558,7 @@ #define TEMPENV_MASK 0x0000ffff /* 16-b /* NOTE: All channels contain internal variables; do */ /* not write to these locations. */ -/* 1f something */ +/* 0x1f: not used */ #define CD0 0x20 /* Cache data 0 register */ #define CD1 0x21 /* Cache data 1 register */ @@ -597,6 +628,8 @@ #define FXWC_ZOOMRIGHT (1<<21) #define FXWC_SPDIFLEFT (1<<22) /* 0x00400000 */ #define FXWC_SPDIFRIGHT (1<<23) /* 0x00800000 */ +#define A_TBLSZ ` 0x43 /* Effects Tank Internal Table Size. Only low byte or register used */ + #define TCBS 0x44 /* Tank cache buffer size register */ #define TCBS_MASK 0x00000007 /* Tank cache buffer size field */ #define TCBS_BUFFSIZE_16K 0x00000000 @@ -617,7 +650,7 @@ #define ADCBA_MASK 0xfffff000 /* 20 bit #define FXBA 0x47 /* FX Buffer Address */ #define FXBA_MASK 0xfffff000 /* 20 bit base address */ -/* 0x48 something - word access, defaults to 3f */ +#define A_HWM 0x48 /* High PCI Water Mark - word access, defaults to 3f */ #define MICBS 0x49 /* Microphone buffer size register */ @@ -661,6 +694,18 @@ #define ADCBS_BUFSIZE_49152 0x0000001d #define ADCBS_BUFSIZE_57344 0x0000001e #define ADCBS_BUFSIZE_65536 0x0000001f +/* Current Send B, A Amounts */ +#define A_CSBA 0x4c + +/* Current Send D, C Amounts */ +#define A_CSDC 0x4d + +/* Current Send F, E Amounts */ +#define A_CSFE 0x4e + +/* Current Send H, G Amounts */ +#define A_CSHG 0x4f + #define CDCS 0x50 /* CD-ROM digital channel status register */ @@ -668,6 +713,9 @@ #define GPSCS 0x51 /* General Purpose #define DBG 0x52 /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */ +/* S/PDIF Input C Channel Status */ +#define A_SPSC 0x52 + #define REG53 0x53 /* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP */ #define A_DBG 0x53 @@ -708,6 +756,8 @@ #define SPCS_COPYRIGHT 0x00000004 /* Co #define SPCS_NOTAUDIODATA 0x00000002 /* 0 = Digital audio, 1 = not audio */ #define SPCS_PROFESSIONAL 0x00000001 /* 0 = Consumer (IEC-958), 1 = pro (AES3-1992) */ +/* 0x57: Not used */ + /* The 32-bit CLIx and SOLx registers all have one bit per channel control/status */ #define CLIEL 0x58 /* Channel loop interrupt enable low register */ @@ -733,6 +783,9 @@ #define AC97SLOT_REAR_LEFT 0x02 /* Rear #define AC97SLOT_CNTR 0x10 /* Center enable */ #define AC97SLOT_LFE 0x20 /* LFE enable */ +/* PCB Revision */ +#define A_PCB 0x5f + // NOTE: 0x60,61,62: 64-bit #define CDSRCS 0x60 /* CD-ROM Sample Rate Converter status register */ @@ -780,9 +833,18 @@ #define HLIPL 0x68 /* Channel half lo #define HLIPH 0x69 /* Channel half loop interrupt pending high register */ -// 0x6a,6b,6c used for some recording -// 0x6d unused -// 0x6e,6f - tanktable base / offset +/* S/PDIF Host Record Index (bypasses SRC) */ +#define A_SPRI 0x6a +/* S/PDIF Host Record Address */ +#define A_SPRA 0x6b +/* S/PDIF Host Record Control */ +#define A_SPRC 0x6c +/* Delayed Interrupt Counter & Enable */ +#define A_DICE 0x6d +/* Tank Table Base */ +#define A_TTB 0x6e +/* Tank Delay Offset */ +#define A_TDOF 0x6f /* This is the MPU port on the card (via the game port) */ #define A_MUDATA1 0x70 @@ -800,6 +862,7 @@ #define A_MUSTAT2 A_MUCMD2 #define A_FXWC1 0x74 /* Selects 0x7f-0x60 for FX recording */ #define A_FXWC2 0x75 /* Selects 0x9f-0x80 for FX recording */ +/* Extended Hardware Control */ #define A_SPDIF_SAMPLERATE 0x76 /* Set the sample rate of SPDIF output */ #define A_SAMPLE_RATE 0x76 /* Various sample rate settings. */ #define A_SAMPLE_RATE_NOT_USED 0x0ffc111e /* Bits that are not used and cannot be set. */ @@ -822,8 +885,20 @@ #define A_PCM_192000 0x00002000 #define A_PCM_96000 0x00004000 #define A_PCM_44100 0x00008000 -/* 0x77,0x78,0x79 "something i2s-related" - default to 0x01080000 on my audigy 2 ZS --rlrevell */ -/* 0x7a, 0x7b - lookup tables */ +/* I2S0 Sample Rate Tracker Status */ +#define A_SRT3 0x77 + +/* I2S1 Sample Rate Tracker Status */ +#define A_SRT4 0x78 + +/* I2S2 Sample Rate Tracker Status */ +#define A_SRT5 0x79 +/* - default to 0x01080000 on my audigy 2 ZS --rlrevell */ + +/* Tank Table DMA Address */ +#define A_TTDA 0x7a +/* Tank Table DMA Data */ +#define A_TTDD 0x7b #define A_FXRT2 0x7c #define A_FXRT_CHANNELE 0x0000003f /* Effects send bus number for channel's effects send E */ @@ -845,7 +920,7 @@ #define A_FXRT_CHANNELB 0x00003f00 #define A_FXRT_CHANNELC 0x003f0000 #define A_FXRT_CHANNELD 0x3f000000 - +/* 0x7f: Not used */ /* Each FX general purpose register is 32 bits in length, all bits are used */ #define FXGPREGBASE 0x100 /* FX general purpose registers base */ #define A_FXGPREGBASE 0x400 /* Audigy GPRs, 0x400 to 0x5ff */ @@ -886,6 +961,293 @@ #define A_HIWORD_OPCODE_MASK 0x0f000000 #define A_HIWORD_RESULT_MASK 0x007ff000 #define A_HIWORD_OPA_MASK 0x000007ff +/************************************************************************************************/ +/* EMU1010m HANA FPGA registers */ +/************************************************************************************************/ +#define EMU_HANA_DESTHI 0x00 /* 0000xxx 3 bits Link Destination */ +#define EMU_HANA_DESTLO 0x01 /* 00xxxxx 5 bits */ +#define EMU_HANA_SRCHI 0x02 /* 0000xxx 3 bits Link Source */ +#define EMU_HANA_SRCLO 0x03 /* 00xxxxx 5 bits */ +#define EMU_HANA_DOCK_PWR 0x04 /* 000000x 1 bits Audio Dock power */ +#define EMU_HANA_DOCK_PWR_ON 0x01 /* Audio Dock power on */ +#define EMU_HANA_WCLOCK 0x05 /* 0000xxx 3 bits Word Clock source select */ + /* Must be written after power on to reset DLL */ + /* One is unable to detect the Audio dock without this */ +#define EMU_HANA_WCLOCK_SRC_MASK 0x07 +#define EMU_HANA_WCLOCK_INT_48K 0x00 +#define EMU_HANA_WCLOCK_INT_44_1K 0x01 +#define EMU_HANA_WCLOCK_HANA_SPDIF_IN 0x02 +#define EMU_HANA_WCLOCK_HANA_ADAT_IN 0x03 +#define EMU_HANA_WCLOCK_SYNC_BNCN 0x04 +#define EMU_HANA_WCLOCK_2ND_HANA 0x05 +#define EMU_HANA_WCLOCK_SRC_RESERVED 0x06 +#define EMU_HANA_WCLOCK_OFF 0x07 /* For testing, forces fallback to DEFCLOCK */ +#define EMU_HANA_WCLOCK_MULT_MASK 0x18 +#define EMU_HANA_WCLOCK_1X 0x00 +#define EMU_HANA_WCLOCK_2X 0x08 +#define EMU_HANA_WCLOCK_4X 0x10 +#define EMU_HANA_WCLOCK_MULT_RESERVED 0x18 + +#define EMU_HANA_DEFCLOCK 0x06 /* 000000x 1 bits Default Word Clock */ +#define EMU_HANA_DEFCLOCK_48K 0x00 +#define EMU_HANA_DEFCLOCK_44_1K 0x01 + +#define EMU_HANA_UNMUTE 0x07 /* 000000x 1 bits Mute all audio outputs */ +#define EMU_MUTE 0x00 +#define EMU_UNMUTE 0x01 + +#define EMU_HANA_FPGA_CONFIG 0x08 /* 00000xx 2 bits Config control of FPGAs */ +#define EMU_HANA_FPGA_CONFIG_AUDIODOCK 0x01 /* Set in order to program FPGA on Audio Dock */ +#define EMU_HANA_FPGA_CONFIG_HANA 0x02 /* Set in order to program FPGA on Hana */ + +#define EMU_HANA_IRQ_ENABLE 0x09 /* 000xxxx 4 bits IRQ Enable */ +#define EMU_HANA_IRQ_WCLK_CHANGED 0x01 +#define EMU_HANA_IRQ_ADAT 0x02 +#define EMU_HANA_IRQ_DOCK 0x04 +#define EMU_HANA_IRQ_DOCK_LOST 0x08 + +#define EMU_HANA_SPDIF_MODE 0x0a /* 00xxxxx 5 bits SPDIF MODE */ +#define EMU_HANA_SPDIF_MODE_TX_COMSUMER 0x00 +#define EMU_HANA_SPDIF_MODE_TX_PRO 0x01 +#define EMU_HANA_SPDIF_MODE_TX_NOCOPY 0x02 +#define EMU_HANA_SPDIF_MODE_RX_COMSUMER 0x00 +#define EMU_HANA_SPDIF_MODE_RX_PRO 0x04 +#define EMU_HANA_SPDIF_MODE_RX_NOCOPY 0x08 +#define EMU_HANA_SPDIF_MODE_RX_INVALID 0x10 + +#define EMU_HANA_OPTICAL_TYPE 0x0b /* 00000xx 2 bits ADAT or SPDIF in/out */ +#define EMU_HANA_OPTICAL_IN_SPDIF 0x00 +#define EMU_HANA_OPTICAL_IN_ADAT 0x01 +#define EMU_HANA_OPTICAL_OUT_SPDIF 0x00 +#define EMU_HANA_OPTICAL_OUT_ADAT 0x02 + +#define EMU_HANA_MIDI_IN 0x0c /* 000000x 1 bit Control MIDI */ +#define EMU_HANA_MIDI_IN_FROM_HAMOA 0x00 /* HAMOA MIDI in to Alice 2 MIDI B */ +#define EMU_HANA_MIDI_IN_FROM_DOCK 0x01 /* Audio Dock MIDI in to Alice 2 MIDI B */ + +#define EMU_HANA_DOCK_LEDS_1 0x0d /* 000xxxx 4 bit Audio Dock LEDs */ +#define EMU_HANA_DOCK_LEDS_1_MIDI1 0x01 /* MIDI 1 LED on */ +#define EMU_HANA_DOCK_LEDS_1_MIDI2 0x02 /* MIDI 2 LED on */ +#define EMU_HANA_DOCK_LEDS_1_SMPTE_IN 0x04 /* SMPTE IN LED on */ +#define EMU_HANA_DOCK_LEDS_1_SMPTE_OUT 0x08 /* SMPTE OUT LED on */ + +#define EMU_HANA_DOCK_LEDS_2 0x0e /* 0xxxxxx 6 bit Audio Dock LEDs */ +#define EMU_HANA_DOCK_LEDS_2_44K 0x01 /* 44.1 kHz LED on */ +#define EMU_HANA_DOCK_LEDS_2_48K 0x02 /* 48 kHz LED on */ +#define EMU_HANA_DOCK_LEDS_2_96K 0x04 /* 96 kHz LED on */ +#define EMU_HANA_DOCK_LEDS_2_192K 0x08 /* 192 kHz LED on */ +#define EMU_HANA_DOCK_LEDS_2_LOCK 0x10 /* LOCK LED on */ +#define EMU_HANA_DOCK_LEDS_2_EXT 0x20 /* EXT LED on */ + +#define EMU_HANA_DOCK_LEDS_3 0x0f /* 0xxxxxx 6 bit Audio Dock LEDs */ +#define EMU_HANA_DOCK_LEDS_3_CLIP_A 0x01 /* Mic A Clip LED on */ +#define EMU_HANA_DOCK_LEDS_3_CLIP_B 0x02 /* Mic B Clip LED on */ +#define EMU_HANA_DOCK_LEDS_3_SIGNAL_A 0x04 /* Signal A Clip LED on */ +#define EMU_HANA_DOCK_LEDS_3_SIGNAL_B 0x08 /* Signal B Clip LED on */ +#define EMU_HANA_DOCK_LEDS_3_MANUAL_CLIP 0x10 /* Manual Clip detection */ +#define EMU_HANA_DOCK_LEDS_3_MANUAL_SIGNAL 0x20 /* Manual Signal detection */ + +#define EMU_HANA_ADC_PADS 0x10 /* 0000xxx 3 bit Audio Dock ADC 14dB pads */ +#define EMU_HANA_DOCK_ADC_PAD1 0x01 /* 14dB Attenuation on Audio Dock ADC 1 */ +#define EMU_HANA_DOCK_ADC_PAD2 0x02 /* 14dB Attenuation on Audio Dock ADC 2 */ +#define EMU_HANA_DOCK_ADC_PAD3 0x04 /* 14dB Attenuation on Audio Dock ADC 3 */ +#define EMU_HANA_0202_ADC_PAD1 0x08 /* 14dB Attenuation on 0202 ADC 1 */ + +#define EMU_HANA_DOCK_MISC 0x11 /* 0xxxxxx 6 bit Audio Dock misc bits */ +#define EMU_HANA_DOCK_DAC1_MUTE 0x01 /* DAC 1 Mute */ +#define EMU_HANA_DOCK_DAC2_MUTE 0x02 /* DAC 2 Mute */ +#define EMU_HANA_DOCK_DAC3_MUTE 0x04 /* DAC 3 Mute */ +#define EMU_HANA_DOCK_DAC4_MUTE 0x08 /* DAC 4 Mute */ +#define EMU_HANA_DOCK_PHONES_192_DAC1 0x00 /* DAC 1 Headphones source at 192kHz */ +#define EMU_HANA_DOCK_PHONES_192_DAC2 0x10 /* DAC 2 Headphones source at 192kHz */ +#define EMU_HANA_DOCK_PHONES_192_DAC3 0x20 /* DAC 3 Headphones source at 192kHz */ +#define EMU_HANA_DOCK_PHONES_192_DAC4 0x30 /* DAC 4 Headphones source at 192kHz */ + +#define EMU_HANA_MIDI_OUT 0x12 /* 00xxxxx 5 bit Source for each MIDI out port */ +#define EMU_HANA_MIDI_OUT_0202 0x01 /* 0202 MIDI from Alice 2. 0 = A, 1 = B */ +#define EMU_HANA_MIDI_OUT_DOCK1 0x02 /* Audio Dock MIDI1 front, from Alice 2. 0 = A, 1 = B */ +#define EMU_HANA_MIDI_OUT_DOCK2 0x04 /* Audio Dock MIDI2 rear, from Alice 2. 0 = A, 1 = B */ +#define EMU_HANA_MIDI_OUT_SYNC2 0x08 /* Sync card. Not the actual MIDI out jack. 0 = A, 1 = B */ +#define EMU_HANA_MIDI_OUT_LOOP 0x10 /* 0 = bits (3:0) normal. 1 = MIDI loopback enabled. */ + +#define EMU_HANA_DAC_PADS 0x13 /* 00xxxxx 5 bit DAC 14dB attenuation pads */ +#define EMU_HANA_DOCK_DAC_PAD1 0x01 /* 14dB Attenuation on AudioDock DAC 1. Left and Right */ +#define EMU_HANA_DOCK_DAC_PAD2 0x02 /* 14dB Attenuation on AudioDock DAC 2. Left and Right */ +#define EMU_HANA_DOCK_DAC_PAD3 0x04 /* 14dB Attenuation on AudioDock DAC 3. Left and Right */ +#define EMU_HANA_DOCK_DAC_PAD4 0x08 /* 14dB Attenuation on AudioDock DAC 4. Left and Right */ +#define EMU_HANA_0202_DAC_PAD1 0x10 /* 14dB Attenuation on 0202 DAC 1. Left and Right */ + +/* 0x14 - 0x1f Unused R/W registers */ +#define EMU_HANA_IRQ_STATUS 0x20 /* 000xxxx 4 bits IRQ Status */ +#if 0 /* Already defined for reg 0x09 IRQ_ENABLE */ +#define EMU_HANA_IRQ_WCLK_CHANGED 0x01 +#define EMU_HANA_IRQ_ADAT 0x02 +#define EMU_HANA_IRQ_DOCK 0x04 +#define EMU_HANA_IRQ_DOCK_LOST 0x08 +#endif + +#define EMU_HANA_OPTION_CARDS 0x21 /* 000xxxx 4 bits Presence of option cards */ +#define EMU_HANA_OPTION_HAMOA 0x01 /* HAMOA card present */ +#define EMU_HANA_OPTION_SYNC 0x02 /* Sync card present */ +#define EMU_HANA_OPTION_DOCK_ONLINE 0x04 /* Audio Dock online and FPGA configured */ +#define EMU_HANA_OPTION_DOCK_OFFLINE 0x08 /* Audio Dock online and FPGA not configured */ + +#define EMU_HANA_ID 0x22 /* 1010101 7 bits ID byte & 0x7f = 0x55 */ + +#define EMU_HANA_MAJOR_REV 0x23 /* 0000xxx 3 bit Hana FPGA Major rev */ +#define EMU_HANA_MINOR_REV 0x24 /* 0000xxx 3 bit Hana FPGA Minor rev */ + +#define EMU_DOCK_MAJOR_REV 0x25 /* 0000xxx 3 bit Audio Dock FPGA Major rev */ +#define EMU_DOCK_MINOR_REV 0x26 /* 0000xxx 3 bit Audio Dock FPGA Minor rev */ + +#define EMU_DOCK_BOARD_ID 0x27 /* 00000xx 2 bits Audio Dock ID pins */ +#define EMU_DOCK_BOARD_ID0 0x00 /* ID bit 0 */ +#define EMU_DOCK_BOARD_ID1 0x03 /* ID bit 1 */ + +#define EMU_HANA_WC_SPDIF_HI 0x28 /* 0xxxxxx 6 bit SPDIF IN Word clock, upper 6 bits */ +#define EMU_HANA_WC_SPDIF_LO 0x29 /* 0xxxxxx 6 bit SPDIF IN Word clock, lower 6 bits */ + +#define EMU_HANA_WC_ADAT_HI 0x2a /* 0xxxxxx 6 bit ADAT IN Word clock, upper 6 bits */ +#define EMU_HANA_WC_ADAT_LO 0x2b /* 0xxxxxx 6 bit ADAT IN Word clock, lower 6 bits */ + +#define EMU_HANA_WC_BNC_LO 0x2c /* 0xxxxxx 6 bit BNC IN Word clock, lower 6 bits */ +#define EMU_HANA_WC_BNC_HI 0x2d /* 0xxxxxx 6 bit BNC IN Word clock, upper 6 bits */ + +#define EMU_HANA2_WC_SPDIF_HI 0x2e /* 0xxxxxx 6 bit HANA2 SPDIF IN Word clock, upper 6 bits */ +#define EMU_HANA2_WC_SPDIF_LO 0x2f /* 0xxxxxx 6 bit HANA2 SPDIF IN Word clock, lower 6 bits */ +/* 0x30 - 0x3f Unused Read only registers */ + +/************************************************************************************************/ +/* EMU1010m HANA Destinations */ +/************************************************************************************************/ +#define EMU_DST_ALICE2_EMU32_0 0x000f /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_1 0x0000 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_2 0x0001 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_3 0x0002 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_4 0x0003 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_5 0x0004 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_6 0x0005 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_7 0x0006 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_8 0x0007 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_9 0x0008 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_A 0x0009 /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_B 0x000a /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_C 0x000b /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_D 0x000c /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_E 0x000d /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_ALICE2_EMU32_F 0x000e /* 16 EMU32 channels to Alice2 +0 to +0xf */ +#define EMU_DST_DOCK_DAC1_LEFT1 0x0100 /* Audio Dock DAC1 Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC1_LEFT2 0x0101 /* Audio Dock DAC1 Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC1_LEFT3 0x0102 /* Audio Dock DAC1 Left, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC1_LEFT4 0x0103 /* Audio Dock DAC1 Left, 4th or 192kHz */ +#define EMU_DST_DOCK_DAC1_RIGHT1 0x0104 /* Audio Dock DAC1 Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC1_RIGHT2 0x0105 /* Audio Dock DAC1 Right, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC1_RIGHT3 0x0106 /* Audio Dock DAC1 Right, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC1_RIGHT4 0x0107 /* Audio Dock DAC1 Right, 4th or 192kHz */ +#define EMU_DST_DOCK_DAC2_LEFT1 0x0108 /* Audio Dock DAC2 Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC2_LEFT2 0x0109 /* Audio Dock DAC2 Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC2_LEFT3 0x010a /* Audio Dock DAC2 Left, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC2_LEFT4 0x010b /* Audio Dock DAC2 Left, 4th or 192kHz */ +#define EMU_DST_DOCK_DAC2_RIGHT1 0x010c /* Audio Dock DAC2 Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC2_RIGHT2 0x010d /* Audio Dock DAC2 Right, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC2_RIGHT3 0x010e /* Audio Dock DAC2 Right, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC2_RIGHT4 0x010f /* Audio Dock DAC2 Right, 4th or 192kHz */ +#define EMU_DST_DOCK_DAC3_LEFT1 0x0110 /* Audio Dock DAC1 Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC3_LEFT2 0x0111 /* Audio Dock DAC1 Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC3_LEFT3 0x0112 /* Audio Dock DAC1 Left, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC3_LEFT4 0x0113 /* Audio Dock DAC1 Left, 4th or 192kHz */ +#define EMU_DST_DOCK_PHONES_LEFT1 0x0112 /* Audio Dock PHONES Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_PHONES_LEFT2 0x0113 /* Audio Dock PHONES Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC3_RIGHT1 0x0114 /* Audio Dock DAC1 Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC3_RIGHT2 0x0115 /* Audio Dock DAC1 Right, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC3_RIGHT3 0x0116 /* Audio Dock DAC1 Right, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC3_RIGHT4 0x0117 /* Audio Dock DAC1 Right, 4th or 192kHz */ +#define EMU_DST_DOCK_PHONES_RIGHT1 0x0116 /* Audio Dock PHONES Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_PHONES_RIGHT2 0x0117 /* Audio Dock PHONES Right, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC4_LEFT1 0x0118 /* Audio Dock DAC2 Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC4_LEFT2 0x0119 /* Audio Dock DAC2 Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC4_LEFT3 0x011a /* Audio Dock DAC2 Left, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC4_LEFT4 0x011b /* Audio Dock DAC2 Left, 4th or 192kHz */ +#define EMU_DST_DOCK_SPDIF_LEFT1 0x011a /* Audio Dock SPDIF Left, 1st or 48kHz only */ +#define EMU_DST_DOCK_SPDIF_LEFT2 0x011b /* Audio Dock SPDIF Left, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC4_RIGHT1 0x011c /* Audio Dock DAC2 Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_DAC4_RIGHT2 0x011d /* Audio Dock DAC2 Right, 2nd or 96kHz */ +#define EMU_DST_DOCK_DAC4_RIGHT3 0x011e /* Audio Dock DAC2 Right, 3rd or 192kHz */ +#define EMU_DST_DOCK_DAC4_RIGHT4 0x011f /* Audio Dock DAC2 Right, 4th or 192kHz */ +#define EMU_DST_DOCK_SPDIF_RIGHT1 0x011e /* Audio Dock SPDIF Right, 1st or 48kHz only */ +#define EMU_DST_DOCK_SPDIF_RIGHT2 0x011f /* Audio Dock SPDIF Right, 2nd or 96kHz */ +#define EMU_DST_HANA_SPDIF_LEFT1 0x0200 /* Hana SPDIF Left, 1st or 48kHz only */ +#define EMU_DST_HANA_SPDIF_LEFT2 0x0202 /* Hana SPDIF Left, 2nd or 96kHz */ +#define EMU_DST_HANA_SPDIF_RIGHT1 0x0201 /* Hana SPDIF Right, 1st or 48kHz only */ +#define EMU_DST_HANA_SPDIF_RIGHT2 0x0203 /* Hana SPDIF Right, 2nd or 96kHz */ +#define EMU_DST_HAMOA_DAC_LEFT1 0x0300 /* Hamoa DAC Left, 1st or 48kHz only */ +#define EMU_DST_HAMOA_DAC_LEFT2 0x0302 /* Hamoa DAC Left, 2nd or 96kHz */ +#define EMU_DST_HAMOA_DAC_LEFT3 0x0304 /* Hamoa DAC Left, 3rd or 192kHz */ +#define EMU_DST_HAMOA_DAC_LEFT4 0x0306 /* Hamoa DAC Left, 4th or 192kHz */ +#define EMU_DST_HAMOA_DAC_RIGHT1 0x0301 /* Hamoa DAC Right, 1st or 48kHz only */ +#define EMU_DST_HAMOA_DAC_RIGHT2 0x0303 /* Hamoa DAC Right, 2nd or 96kHz */ +#define EMU_DST_HAMOA_DAC_RIGHT3 0x0305 /* Hamoa DAC Right, 3rd or 192kHz */ +#define EMU_DST_HAMOA_DAC_RIGHT4 0x0307 /* Hamoa DAC Right, 4th or 192kHz */ +#define EMU_DST_HANA_ADAT 0x0400 /* Hana ADAT 8 channel out +0 to +7 */ +#define EMU_DST_ALICE_I2S0_LEFT 0x0500 /* Alice2 I2S0 Left */ +#define EMU_DST_ALICE_I2S0_RIGHT 0x0501 /* Alice2 I2S0 Right */ +#define EMU_DST_ALICE_I2S1_LEFT 0x0600 /* Alice2 I2S1 Left */ +#define EMU_DST_ALICE_I2S1_RIGHT 0x0601 /* Alice2 I2S1 Right */ +#define EMU_DST_ALICE_I2S2_LEFT 0x0700 /* Alice2 I2S2 Left */ +#define EMU_DST_ALICE_I2S2_RIGHT 0x0701 /* Alice2 I2S2 Right */ + +/************************************************************************************************/ +/* EMU1010m HANA Sources */ +/************************************************************************************************/ +#define EMU_SRC_SILENCE 0x0000 /* Silence */ +#define EMU_SRC_DOCK_MIC_A1 0x0100 /* Audio Dock Mic A, 1st or 48kHz only */ +#define EMU_SRC_DOCK_MIC_A2 0x0101 /* Audio Dock Mic A, 2nd or 96kHz */ +#define EMU_SRC_DOCK_MIC_A3 0x0102 /* Audio Dock Mic A, 3rd or 192kHz */ +#define EMU_SRC_DOCK_MIC_A4 0x0103 /* Audio Dock Mic A, 4th or 192kHz */ +#define EMU_SRC_DOCK_MIC_B1 0x0104 /* Audio Dock Mic B, 1st or 48kHz only */ +#define EMU_SRC_DOCK_MIC_B2 0x0105 /* Audio Dock Mic B, 2nd or 96kHz */ +#define EMU_SRC_DOCK_MIC_B3 0x0106 /* Audio Dock Mic B, 3rd or 192kHz */ +#define EMU_SRC_DOCK_MIC_B4 0x0107 /* Audio Dock Mic B, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC1_LEFT1 0x0108 /* Audio Dock ADC1 Left, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC1_LEFT2 0x0109 /* Audio Dock ADC1 Left, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC1_LEFT3 0x010a /* Audio Dock ADC1 Left, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC1_LEFT4 0x010b /* Audio Dock ADC1 Left, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC1_RIGHT1 0x010c /* Audio Dock ADC1 Right, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC1_RIGHT2 0x010d /* Audio Dock ADC1 Right, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC1_RIGHT3 0x010e /* Audio Dock ADC1 Right, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC1_RIGHT4 0x010f /* Audio Dock ADC1 Right, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC2_LEFT1 0x0110 /* Audio Dock ADC2 Left, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC2_LEFT2 0x0111 /* Audio Dock ADC2 Left, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC2_LEFT3 0x0112 /* Audio Dock ADC2 Left, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC2_LEFT4 0x0113 /* Audio Dock ADC2 Left, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC2_RIGHT1 0x0114 /* Audio Dock ADC2 Right, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC2_RIGHT2 0x0115 /* Audio Dock ADC2 Right, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC2_RIGHT3 0x0116 /* Audio Dock ADC2 Right, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC2_RIGHT4 0x0117 /* Audio Dock ADC2 Right, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC3_LEFT1 0x0118 /* Audio Dock ADC3 Left, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC3_LEFT2 0x0119 /* Audio Dock ADC3 Left, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC3_LEFT3 0x011a /* Audio Dock ADC3 Left, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC3_LEFT4 0x011b /* Audio Dock ADC3 Left, 4th or 192kHz */ +#define EMU_SRC_DOCK_ADC3_RIGHT1 0x011c /* Audio Dock ADC3 Right, 1st or 48kHz only */ +#define EMU_SRC_DOCK_ADC3_RIGHT2 0x011d /* Audio Dock ADC3 Right, 2nd or 96kHz */ +#define EMU_SRC_DOCK_ADC3_RIGHT3 0x011e /* Audio Dock ADC3 Right, 3rd or 192kHz */ +#define EMU_SRC_DOCK_ADC3_RIGHT4 0x011f /* Audio Dock ADC3 Right, 4th or 192kHz */ +#define EMU_SRC_HAMOA_ADC_LEFT1 0x0200 /* Hamoa ADC Left, 1st or 48kHz only */ +#define EMU_SRC_HAMOA_ADC_LEFT2 0x0202 /* Hamoa ADC Left, 2nd or 96kHz */ +#define EMU_SRC_HAMOA_ADC_LEFT3 0x0204 /* Hamoa ADC Left, 3rd or 192kHz */ +#define EMU_SRC_HAMOA_ADC_LEFT4 0x0206 /* Hamoa ADC Left, 4th or 192kHz */ +#define EMU_SRC_HAMOA_ADC_RIGHT1 0x0201 /* Hamoa ADC Right, 1st or 48kHz only */ +#define EMU_SRC_HAMOA_ADC_RIGHT2 0x0203 /* Hamoa ADC Right, 2nd or 96kHz */ +#define EMU_SRC_HAMOA_ADC_RIGHT3 0x0205 /* Hamoa ADC Right, 3rd or 192kHz */ +#define EMU_SRC_HAMOA_ADC_RIGHT4 0x0207 /* Hamoa ADC Right, 4th or 192kHz */ +#define EMU_SRC_ALICE_EMU32A 0x0300 /* Alice2 EMU32a 16 outputs. +0 to +0xf */ +#define EMU_SRC_ALICE_EMU32B 0x0310 /* Alice2 EMU32b 16 outputs. +0 to +0xf */ +#define EMU_SRC_HANA_ADAT 0x0400 /* Hana ADAT 8 channel in +0 to +7 */ +#define EMU_SRC_HANA_SPDIF_LEFT1 0x0500 /* Hana SPDIF Left, 1st or 48kHz only */ +#define EMU_SRC_HANA_SPDIF_LEFT2 0x0502 /* Hana SPDIF Left, 2nd or 96kHz */ +#define EMU_SRC_HANA_SPDIF_RIGHT1 0x0501 /* Hana SPDIF Right, 1st or 48kHz only */ +#define EMU_SRC_HANA_SPDIF_RIGHT2 0x0503 /* Hana SPDIF Right, 2nd or 96kHz */ +/* 0x600 and 0x700 no used */ /* ------------------- STRUCTURES -------------------- */ @@ -1063,7 +1425,7 @@ struct snd_emu_chip_details { unsigned char spdif_bug; /* Has Spdif phasing bug */ unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ unsigned char ecard; /* APS EEPROM */ - unsigned char emu1212m; /* EMU 1212m card */ + unsigned char emu1010; /* EMU 1010m card */ unsigned char spi_dac; /* SPI interface for DAC */ unsigned char i2c_adc; /* I2C interface for ADC */ unsigned char adc_1361t; /* Use Philips 1361T ADC */ @@ -1072,6 +1434,14 @@ struct snd_emu_chip_details { const char *id; /* for backward compatibility - can be NULL if not needed */ }; +struct snd_emu1010 { + unsigned int output_source[64]; + unsigned int input_source[64]; + unsigned int adc_pads; /* bit mask */ + unsigned int dac_pads; /* bit mask */ + unsigned int internal_clock; /* 44100 or 48000 */ +}; + struct snd_emu10k1 { int irq; @@ -1104,6 +1474,8 @@ struct snd_emu10k1 { spinlock_t memblk_lock; unsigned int spdif_bits[3]; /* s/pdif out setup */ + unsigned int i2c_capture_source; + u8 i2c_capture_volume[4][2]; struct snd_emu10k1_fx8010 fx8010; /* FX8010 info */ int gpr_base; @@ -1132,6 +1504,7 @@ struct snd_emu10k1 { int p16v_device_offset; u32 p16v_capture_source; u32 p16v_capture_channel; + struct snd_emu1010 emu1010; struct snd_emu10k1_pcm_mixer pcm_mixer[32]; struct snd_emu10k1_pcm_mixer efx_pcm_mixer[NUM_EFX_PLAYBACK]; struct snd_kcontrol *ctl_send_routing; @@ -1208,6 +1581,10 @@ void snd_emu10k1_ptr_write(struct snd_em unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data); +int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value); +int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value); +int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value); +int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src); unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 2f645df..ee6bc2d 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -56,6 +56,8 @@ struct snd_pcm_hardware { size_t fifo_size; /* fifo size in bytes */ }; +struct snd_pcm_substream; + struct snd_pcm_ops { int (*open)(struct snd_pcm_substream *substream); int (*close)(struct snd_pcm_substream *substream); @@ -384,6 +386,7 @@ #ifdef CONFIG_SND_VERBOSE_PROCFS struct snd_info_entry *proc_sw_params_entry; struct snd_info_entry *proc_status_entry; struct snd_info_entry *proc_prealloc_entry; + struct snd_info_entry *proc_prealloc_max_entry; #endif /* misc flags */ unsigned int hw_opened: 1; @@ -427,6 +430,7 @@ struct snd_pcm { wait_queue_head_t open_wait; void *private_data; void (*private_free) (struct snd_pcm *pcm); + struct device *dev; /* actual hw device this belongs to */ #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) struct snd_pcm_oss oss; #endif diff --git a/include/sound/pt2258.h b/include/sound/pt2258.h new file mode 100644 index 0000000..160f812 --- /dev/null +++ b/include/sound/pt2258.h @@ -0,0 +1,37 @@ +/* + * ALSA Driver for the PT2258 volume controller. + * + * Copyright (c) 2006 Jochen Voss + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __SOUND_PT2258_H +#define __SOUND_PT2258_H + +struct snd_pt2258 { + struct snd_card *card; + struct snd_i2c_bus *i2c_bus; + struct snd_i2c_device *i2c_dev; + + unsigned char volume[6]; + int mute; +}; + +extern int snd_pt2258_reset(struct snd_pt2258 *pt); +extern int snd_pt2258_build_controls(struct snd_pt2258 *pt); + +#endif /* __SOUND_PT2258_H */ diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h index caf6fe2..736eac7 100644 --- a/include/sound/sb16_csp.h +++ b/include/sound/sb16_csp.h @@ -114,9 +114,21 @@ #define SNDRV_SB_CSP_IOCTL_RESTART _IO(' #ifdef __KERNEL__ #include "sb.h" #include "hwdep.h" +#include struct snd_sb_csp; +/* indices for the known CSP programs */ +enum { + CSP_PROGRAM_MULAW, + CSP_PROGRAM_ALAW, + CSP_PROGRAM_ADPCM_INIT, + CSP_PROGRAM_ADPCM_PLAYBACK, + CSP_PROGRAM_ADPCM_CAPTURE, + + CSP_PROGRAM_COUNT +}; + /* * CSP operators */ @@ -159,6 +171,8 @@ struct snd_sb_csp { struct snd_kcontrol *qsound_space; struct mutex access_mutex; /* locking */ + + const struct firmware *csp_programs[CSP_PROGRAM_COUNT]; }; int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep); diff --git a/include/sound/snd_wavefront.h b/include/sound/snd_wavefront.h index 0b9e5de..9688d4b 100644 --- a/include/sound/snd_wavefront.h +++ b/include/sound/snd_wavefront.h @@ -85,6 +85,7 @@ #define fx_mod_data base + 0xf char hw_version[2]; /* major = [0], minor = [1] */ char israw; /* needs Motorola microcode */ char has_fx; /* has FX processor (Tropez+) */ + char fx_initialized; /* FX's register pages initialized */ char prog_status[WF_MAX_PROGRAM]; /* WF_SLOT_* */ char patch_status[WF_MAX_PATCH]; /* WF_SLOT_* */ char sample_status[WF_MAX_SAMPLE]; /* WF_ST_* | WF_SLOT_* */ @@ -94,6 +95,7 @@ #define fx_mod_data base + 0xf spinlock_t irq_lock; wait_queue_head_t interrupt_sleeper; snd_wavefront_midi_t midi; /* ICS2115 MIDI interface */ + struct snd_card *card; }; struct _snd_wavefront_card { diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h new file mode 100644 index 0000000..2b1ae8e --- /dev/null +++ b/include/sound/soc-dapm.h @@ -0,0 +1,286 @@ +/* + * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management + * + * Author: Liam Girdwood + * Created: Aug 11th 2005 + * Copyright: Wolfson Microelectronics. PLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __LINUX_SND_SOC_DAPM_H +#define __LINUX_SND_SOC_DAPM_H + +#include +#include +#include +#include + +/* widget has no PM register bit */ +#define SND_SOC_NOPM -1 + +/* + * SoC dynamic audio power managment + * + * We can have upto 4 power domains + * 1. Codec domain - VREF, VMID + * Usually controlled at codec probe/remove, although can be set + * at stream time if power is not needed for sidetone, etc. + * 2. Platform/Machine domain - physically connected inputs and outputs + * Is platform/machine and user action specific, is set in the machine + * driver and by userspace e.g when HP are inserted + * 3. Path domain - Internal codec path mixers + * Are automatically set when mixer and mux settings are + * changed by the user. + * 4. Stream domain - DAC's and ADC's. + * Enabled when stream playback/capture is started. + */ + +/* codec domain */ +#define SND_SOC_DAPM_VMID(wname) \ +{ .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0} + +/* platform domain */ +#define SND_SOC_DAPM_INPUT(wname) \ +{ .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0} +#define SND_SOC_DAPM_OUTPUT(wname) \ +{ .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0} +#define SND_SOC_DAPM_MIC(wname, wevent) \ +{ .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} +#define SND_SOC_DAPM_HP(wname, wevent) \ +{ .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} +#define SND_SOC_DAPM_SPK(wname, wevent) \ +{ .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} +#define SND_SOC_DAPM_LINE(wname, wevent) \ +{ .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} + +/* path domain */ +#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\ + wcontrols, wncontrols) \ +{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} +#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \ + wcontrols, wncontrols)\ +{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} +#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ +{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} +#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \ +{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} +#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ +{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} + +/* path domain with event - event handler must return 0 for success */ +#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ + wncontrols, wevent, wflags) \ +{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ + .event = wevent, .event_flags = wflags} +#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \ + wncontrols, wevent, wflags) \ +{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ + .event = wevent, .event_flags = wflags} +#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ +{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ + .event = wevent, .event_flags = wflags} +#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \ + wevent, wflags) \ +{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1 \ + .event = wevent, .event_flags = wflags} +#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ + wevent, wflags) \ +{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ + .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ + .event = wevent, .event_flags = wflags} + +/* events that are pre and post DAPM */ +#define SND_SOC_DAPM_PRE(wname, wevent) \ +{ .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD} +#define SND_SOC_DAPM_POST(wname, wevent) \ +{ .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \ + .num_kcontrols = 0, .event = wevent, \ + .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD} + +/* stream domain */ +#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ +{ .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ + .shift = wshift, .invert = winvert} +#define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \ +{ .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ + .shift = wshift, .invert = winvert} + +/* dapm kcontrol types */ +#define SOC_DAPM_SINGLE(xname, reg, shift, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_volsw, \ + .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ + .private_value = SOC_SINGLE_VALUE(reg, shift, mask, invert) } +#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, mask, invert, \ + power) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ + .info = snd_soc_info_volsw, \ + .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ + .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ + ((mask) << 16) | ((invert) << 24) } +#define SOC_DAPM_ENUM(xname, xenum) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_enum_double, \ + .get = snd_soc_dapm_get_enum_double, \ + .put = snd_soc_dapm_put_enum_double, \ + .private_value = (unsigned long)&xenum } + +/* dapm stream operations */ +#define SND_SOC_DAPM_STREAM_NOP 0x0 +#define SND_SOC_DAPM_STREAM_START 0x1 +#define SND_SOC_DAPM_STREAM_STOP 0x2 +#define SND_SOC_DAPM_STREAM_SUSPEND 0x4 +#define SND_SOC_DAPM_STREAM_RESUME 0x8 +#define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 +#define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20 + +/* dapm event types */ +#define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ +#define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ +#define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ +#define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ +#define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ +#define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ + +/* convenience event type detection */ +#define SND_SOC_DAPM_EVENT_ON(e) \ + (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) +#define SND_SOC_DAPM_EVENT_OFF(e) \ + (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)) + +struct snd_soc_dapm_widget; +enum snd_soc_dapm_type; +struct snd_soc_dapm_path; +struct snd_soc_dapm_pin; + +/* dapm controls */ +int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_new_control(struct snd_soc_codec *codec, + const struct snd_soc_dapm_widget *widget); + +/* dapm path setup */ +int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, + const char *sink_name, const char *control_name, const char *src_name); +int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); +void snd_soc_dapm_free(struct snd_soc_device *socdev); + +/* dapm events */ +int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, + int event); + +/* dapm sys fs - used by the core */ +int snd_soc_dapm_sys_add(struct device *dev); + +/* dapm audio endpoint control */ +int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec, + char *pin, int status); +int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec); + +/* dapm widget types */ +enum snd_soc_dapm_type { + snd_soc_dapm_input = 0, /* input pin */ + snd_soc_dapm_output, /* output pin */ + snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ + snd_soc_dapm_mixer, /* mixes several analog signals together */ + snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ + snd_soc_dapm_adc, /* analog to digital converter */ + snd_soc_dapm_dac, /* digital to analog converter */ + snd_soc_dapm_micbias, /* microphone bias (power) */ + snd_soc_dapm_mic, /* microphone */ + snd_soc_dapm_hp, /* headphones */ + snd_soc_dapm_spk, /* speaker */ + snd_soc_dapm_line, /* line input/output */ + snd_soc_dapm_switch, /* analog switch */ + snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ + snd_soc_dapm_pre, /* machine specific pre widget - exec first */ + snd_soc_dapm_post, /* machine specific post widget - exec last */ +}; + +/* dapm audio path between two widgets */ +struct snd_soc_dapm_path { + char *name; + char *long_name; + + /* source (input) and sink (output) widgets */ + struct snd_soc_dapm_widget *source; + struct snd_soc_dapm_widget *sink; + struct snd_kcontrol *kcontrol; + + /* status */ + u32 connect:1; /* source and sink widgets are connected */ + u32 walked:1; /* path has been walked */ + + struct list_head list_source; + struct list_head list_sink; + struct list_head list; +}; + +/* dapm widget */ +struct snd_soc_dapm_widget { + enum snd_soc_dapm_type id; + char *name; /* widget name */ + char *sname; /* stream name */ + struct snd_soc_codec *codec; + struct list_head list; + + /* dapm control */ + short reg; /* negative reg = no direct dapm */ + unsigned char shift; /* bits to shift */ + unsigned int saved_value; /* widget saved value */ + unsigned int value; /* widget current value */ + unsigned char power:1; /* block power status */ + unsigned char invert:1; /* invert the power bit */ + unsigned char active:1; /* active stream on DAC, ADC's */ + unsigned char connected:1; /* connected codec pin */ + unsigned char new:1; /* cnew complete */ + unsigned char ext:1; /* has external widgets */ + unsigned char muted:1; /* muted for pop reduction */ + unsigned char suspend:1; /* was active before suspend */ + unsigned char pmdown:1; /* waiting for timeout */ + + /* external events */ + unsigned short event_flags; /* flags to specify event types */ + int (*event)(struct snd_soc_dapm_widget*, int); + + /* kcontrols that relate to this widget */ + int num_kcontrols; + const struct snd_kcontrol_new *kcontrols; + + /* widget input and outputs */ + struct list_head sources; + struct list_head sinks; +}; + +#endif diff --git a/include/sound/soc.h b/include/sound/soc.h new file mode 100644 index 0000000..ea836d8 --- /dev/null +++ b/include/sound/soc.h @@ -0,0 +1,488 @@ +/* + * linux/sound/soc.h -- ALSA SoC Layer + * + * Author: Liam Girdwood + * Created: Aug 11th 2005 + * Copyright: Wolfson Microelectronics. PLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __LINUX_SND_SOC_H +#define __LINUX_SND_SOC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SND_SOC_VERSION "0.12" + +/* + * Convenience kcontrol builders + */ +#define SOC_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) |\ + ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) +#define SOC_SINGLE_VALUE_EXT(reg,mask,invert) ((reg) | ((mask) << 16) |\ + ((invert) << 31)) +#define SOC_SINGLE(xname, reg, shift, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ + .put = snd_soc_put_volsw, \ + .private_value = SOC_SINGLE_VALUE(reg, shift, mask, invert) } +#define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ + .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ + .put = snd_soc_put_volsw, \ + .private_value = (reg) | ((shift_left) << 8) | \ + ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } +#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ + .info = snd_soc_info_volsw_2r, \ + .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ + .private_value = (reg_left) | ((shift) << 8) | \ + ((mask) << 12) | ((invert) << 20) | ((reg_right) << 24) } +#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ +{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ + .mask = xmask, .texts = xtexts } +#define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \ + SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts) +#define SOC_ENUM_SINGLE_EXT(xmask, xtexts) \ +{ .mask = xmask, .texts = xtexts } +#define SOC_ENUM(xname, xenum) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ + .info = snd_soc_info_enum_double, \ + .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ + .private_value = (unsigned long)&xenum } +#define SOC_SINGLE_EXT(xname, xreg, xmask, xinvert,\ + xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_volsw_ext, \ + .get = xhandler_get, .put = xhandler_put, \ + .private_value = SOC_SINGLE_VALUE_EXT(xreg, xmask, xinvert) } +#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_bool_ext, \ + .get = xhandler_get, .put = xhandler_put, \ + .private_value = xdata } +#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_enum_ext, \ + .get = xhandler_get, .put = xhandler_put, \ + .private_value = (unsigned long)&xenum } + +/* + * Digital Audio Interface (DAI) types + */ +#define SND_SOC_DAI_AC97 0x1 +#define SND_SOC_DAI_I2S 0x2 +#define SND_SOC_DAI_PCM 0x4 + +/* + * DAI hardware audio formats + */ +#define SND_SOC_DAIFMT_I2S (1 << 0) /* I2S mode */ +#define SND_SOC_DAIFMT_RIGHT_J (1 << 1) /* Right justified mode */ +#define SND_SOC_DAIFMT_LEFT_J (1 << 2) /* Left Justified mode */ +#define SND_SOC_DAIFMT_DSP_A (1 << 3) /* L data msb after FRM or LRC */ +#define SND_SOC_DAIFMT_DSP_B (1 << 4) /* L data msb during FRM or LRC */ +#define SND_SOC_DAIFMT_AC97 (1 << 5) /* AC97 */ + +/* + * DAI hardware signal inversions + */ +#define SND_SOC_DAIFMT_NB_NF (1 << 8) /* normal bit clock + frame */ +#define SND_SOC_DAIFMT_NB_IF (1 << 9) /* normal bclk + inv frm */ +#define SND_SOC_DAIFMT_IB_NF (1 << 10) /* invert bclk + nor frm */ +#define SND_SOC_DAIFMT_IB_IF (1 << 11) /* invert bclk + frm */ + +/* + * DAI hardware clock masters + * This is wrt the codec, the inverse is true for the interface + * i.e. if the codec is clk and frm master then the interface is + * clk and frame slave. + */ +#define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & frm master */ +#define SND_SOC_DAIFMT_CBS_CFM (1 << 13) /* codec clk slave & frm master */ +#define SND_SOC_DAIFMT_CBM_CFS (1 << 14) /* codec clk master & frame slave */ +#define SND_SOC_DAIFMT_CBS_CFS (1 << 15) /* codec clk & frm slave */ + +#define SND_SOC_DAIFMT_FORMAT_MASK 0x00ff +#define SND_SOC_DAIFMT_INV_MASK 0x0f00 +#define SND_SOC_DAIFMT_CLOCK_MASK 0xf000 + +/* + * DAI hardware audio direction + */ +#define SND_SOC_DAIDIR_PLAYBACK 0x1 +#define SND_SOC_DAIDIR_CAPTURE 0x2 + +/* + * DAI hardware Time Division Multiplexing (TDM) Slots + * Left and Right data word positions + * This is measured in words (sample size) and not bits. + */ +#define SND_SOC_DAITDM_LRDW(l,r) ((l << 8) | r) + +/* + * DAI hardware clock ratios + * bit clock can either be a generated by dividing mclk or + * by multiplying sample rate, hence there are 2 definitions below + * depending on codec type. + */ +/* ratio of sample rate to mclk/sysclk */ +#define SND_SOC_FS_ALL 0xffff /* all mclk supported */ + +/* bit clock dividers */ +#define SND_SOC_FSBD(x) (1 << (x - 1)) /* ratio mclk:bclk */ +#define SND_SOC_FSBD_REAL(x) (ffs(x)) + +/* bit clock ratio to (sample rate * channels * word size) */ +#define SND_SOC_FSBW(x) (1 << (x - 1)) +#define SND_SOC_FSBW_REAL(x) (ffs(x)) +/* all bclk ratios supported */ +#define SND_SOC_FSB_ALL ~0ULL + +/* + * DAI hardware flags + */ +/* use bfs mclk divider mode (BCLK = MCLK / x) */ +#define SND_SOC_DAI_BFS_DIV 0x1 +/* use bfs rate mulitplier (BCLK = RATE * x)*/ +#define SND_SOC_DAI_BFS_RATE 0x2 +/* use bfs rcw multiplier (BCLK = RATE * CHN * WORD SIZE) */ +#define SND_SOC_DAI_BFS_RCW 0x4 +/* capture and playback can use different clocks */ +#define SND_SOC_DAI_ASYNC 0x8 + +/* + * AC97 codec ID's bitmask + */ +#define SND_SOC_DAI_AC97_ID0 (1 << 0) +#define SND_SOC_DAI_AC97_ID1 (1 << 1) +#define SND_SOC_DAI_AC97_ID2 (1 << 2) +#define SND_SOC_DAI_AC97_ID3 (1 << 3) + +struct snd_soc_device; +struct snd_soc_pcm_stream; +struct snd_soc_ops; +struct snd_soc_dai_mode; +struct snd_soc_pcm_runtime; +struct snd_soc_codec_dai; +struct snd_soc_cpu_dai; +struct snd_soc_codec; +struct snd_soc_machine_config; +struct soc_enum; +struct snd_soc_ac97_ops; +struct snd_soc_clock_info; + +typedef int (*hw_write_t)(void *,const char* ,int); +typedef int (*hw_read_t)(void *,char* ,int); + +extern struct snd_ac97_bus_ops soc_ac97_ops; + +/* pcm <-> DAI connect */ +void snd_soc_free_pcms(struct snd_soc_device *socdev); +int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); +int snd_soc_register_card(struct snd_soc_device *socdev); + +/* set runtime hw params */ +int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, + const struct snd_pcm_hardware *hw); +int snd_soc_get_rate(int rate); + +/* codec IO */ +#define snd_soc_read(codec, reg) codec->read(codec, reg) +#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value) + +/* codec register bit access */ +int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned short mask, unsigned short value); +int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned short mask, unsigned short value); + +int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, + struct snd_ac97_bus_ops *ops, int num); +void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); + +/* + *Controls + */ +struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, + void *data, char *long_name); +int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_info_bool_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); + +/* SoC PCM stream information */ +struct snd_soc_pcm_stream { + char *stream_name; + unsigned int rate_min; /* min rate */ + unsigned int rate_max; /* max rate */ + unsigned int channels_min; /* min channels */ + unsigned int channels_max; /* max channels */ + unsigned int active:1; /* stream is in use */ +}; + +/* SoC audio ops */ +struct snd_soc_ops { + int (*startup)(struct snd_pcm_substream *); + void (*shutdown)(struct snd_pcm_substream *); + int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); + int (*hw_free)(struct snd_pcm_substream *); + int (*prepare)(struct snd_pcm_substream *); + int (*trigger)(struct snd_pcm_substream *, int); +}; + +/* SoC DAI hardware mode */ +struct snd_soc_dai_mode { + u16 fmt; /* SND_SOC_DAIFMT_* */ + u16 tdm; /* SND_SOC_HWTDM_* */ + u64 pcmfmt; /* SNDRV_PCM_FMTBIT_* */ + u16 pcmrate; /* SND_SOC_HWRATE_* */ + u16 pcmdir:2; /* SND_SOC_HWDIR_* */ + u16 flags:8; /* hw flags */ + u16 fs; /* mclk to rate divider */ + u64 bfs; /* mclk to bclk dividers */ + unsigned long priv; /* private mode data */ +}; + +/* DAI capabilities */ +struct snd_soc_dai_cap { + int num_modes; /* number of DAI modes */ + struct snd_soc_dai_mode *mode; /* array of supported DAI modes */ +}; + +/* SoC Codec DAI */ +struct snd_soc_codec_dai { + char *name; + int id; + + /* DAI capabilities */ + struct snd_soc_pcm_stream playback; + struct snd_soc_pcm_stream capture; + struct snd_soc_dai_cap caps; + + /* DAI runtime info */ + struct snd_soc_dai_mode dai_runtime; + struct snd_soc_ops ops; + unsigned int (*config_sysclk)(struct snd_soc_codec_dai*, + struct snd_soc_clock_info *info, unsigned int clk); + int (*digital_mute)(struct snd_soc_codec *, + struct snd_soc_codec_dai*, int); + unsigned int mclk; /* the audio master clock */ + unsigned int pll_in; /* the PLL input clock */ + unsigned int pll_out; /* the PLL output clock */ + unsigned int clk_div; /* internal clock divider << 1 (for fractions) */ + unsigned int active; + unsigned char pop_wait:1; + + /* DAI private data */ + void *private_data; +}; + +/* SoC CPU DAI */ +struct snd_soc_cpu_dai { + + /* DAI description */ + char *name; + unsigned int id; + unsigned char type; + + /* DAI callbacks */ + int (*probe)(struct platform_device *pdev); + void (*remove)(struct platform_device *pdev); + int (*suspend)(struct platform_device *pdev, + struct snd_soc_cpu_dai *cpu_dai); + int (*resume)(struct platform_device *pdev, + struct snd_soc_cpu_dai *cpu_dai); + unsigned int (*config_sysclk)(struct snd_soc_cpu_dai *cpu_dai, + struct snd_soc_clock_info *info, unsigned int clk); + + /* DAI capabilities */ + struct snd_soc_pcm_stream capture; + struct snd_soc_pcm_stream playback; + struct snd_soc_dai_cap caps; + + /* DAI runtime info */ + struct snd_soc_dai_mode dai_runtime; + struct snd_soc_ops ops; + struct snd_pcm_runtime *runtime; + unsigned char active:1; + unsigned int mclk; + void *dma_data; + + /* DAI private data */ + void *private_data; +}; + +/* SoC Audio Codec */ +struct snd_soc_codec { + char *name; + struct module *owner; + struct mutex mutex; + + /* callbacks */ + int (*dapm_event)(struct snd_soc_codec *codec, int event); + + /* runtime */ + struct snd_card *card; + struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ + unsigned int active; + unsigned int pcm_devs; + void *private_data; + + /* codec IO */ + void *control_data; /* codec control (i2c/3wire) data */ + unsigned int (*read)(struct snd_soc_codec *, unsigned int); + int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); + hw_write_t hw_write; + hw_read_t hw_read; + void *reg_cache; + short reg_cache_size; + short reg_cache_step; + + /* dapm */ + struct list_head dapm_widgets; + struct list_head dapm_paths; + unsigned int dapm_state; + unsigned int suspend_dapm_state; + struct delayed_work delayed_work; + + /* codec DAI's */ + struct snd_soc_codec_dai *dai; + unsigned int num_dai; +}; + +/* codec device */ +struct snd_soc_codec_device { + int (*probe)(struct platform_device *pdev); + int (*remove)(struct platform_device *pdev); + int (*suspend)(struct platform_device *pdev, pm_message_t state); + int (*resume)(struct platform_device *pdev); +}; + +/* SoC platform interface */ +struct snd_soc_platform { + char *name; + + int (*probe)(struct platform_device *pdev); + int (*remove)(struct platform_device *pdev); + int (*suspend)(struct platform_device *pdev, + struct snd_soc_cpu_dai *cpu_dai); + int (*resume)(struct platform_device *pdev, + struct snd_soc_cpu_dai *cpu_dai); + + /* pcm creation and destruction */ + int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, + struct snd_pcm *); + void (*pcm_free)(struct snd_pcm *); + + /* platform stream ops */ + struct snd_pcm_ops *pcm_ops; +}; + +/* SoC machine DAI configuration, glues a codec and cpu DAI together */ +struct snd_soc_dai_link { + char *name; /* Codec name */ + char *stream_name; /* Stream name */ + + /* DAI */ + struct snd_soc_codec_dai *codec_dai; + struct snd_soc_cpu_dai *cpu_dai; + u32 flags; /* DAI config preference flags */ + + /* codec/machine specific init - e.g. add machine controls */ + int (*init)(struct snd_soc_codec *codec); + + /* audio sysclock configuration */ + unsigned int (*config_sysclk)(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info); +}; + +/* SoC machine */ +struct snd_soc_machine { + char *name; + + int (*probe)(struct platform_device *pdev); + int (*remove)(struct platform_device *pdev); + + /* the pre and post PM functions are used to do any PM work before and + * after the codec and DAI's do any PM work. */ + int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); + int (*suspend_post)(struct platform_device *pdev, pm_message_t state); + int (*resume_pre)(struct platform_device *pdev); + int (*resume_post)(struct platform_device *pdev); + + /* machine stream operations */ + struct snd_soc_ops *ops; + + /* CPU <--> Codec DAI links */ + struct snd_soc_dai_link *dai_link; + int num_links; +}; + +/* SoC Device - the audio subsystem */ +struct snd_soc_device { + struct device *dev; + struct snd_soc_machine *machine; + struct snd_soc_platform *platform; + struct snd_soc_codec *codec; + struct snd_soc_codec_device *codec_dev; + struct delayed_work delayed_work; + void *codec_data; +}; + +/* runtime channel data */ +struct snd_soc_pcm_runtime { + struct snd_soc_codec_dai *codec_dai; + struct snd_soc_cpu_dai *cpu_dai; + struct snd_soc_device *socdev; +}; + +/* enumerated kcontrol */ +struct soc_enum { + unsigned short reg; + unsigned short reg2; + unsigned char shift_l; + unsigned char shift_r; + unsigned int mask; + const char **texts; + void *dapm; +}; + +/* clocking configuration data */ +struct snd_soc_clock_info { + unsigned int rate; + unsigned int fs; + unsigned int bclk_master; +}; + +#endif diff --git a/include/sound/typedefs.h b/include/sound/typedefs.h deleted file mode 100644 index f454b02..0000000 --- a/include/sound/typedefs.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Typedef's for backward compatibility (for out-of-kernel drivers) - * - * This file will be removed soon in future - */ - -/* core stuff */ -typedef struct snd_card snd_card_t; -typedef struct snd_device snd_device_t; -typedef struct snd_device_ops snd_device_ops_t; -typedef enum snd_card_type snd_card_type_t; -typedef struct snd_minor snd_minor_t; - -/* info */ -typedef struct snd_info_entry snd_info_entry_t; -typedef struct snd_info_buffer snd_info_buffer_t; - -/* control */ -typedef struct snd_ctl_file snd_ctl_file_t; -typedef struct snd_kcontrol snd_kcontrol_t; -typedef struct snd_kcontrol_new snd_kcontrol_new_t; -typedef struct snd_kcontrol_volatile snd_kcontrol_volatile_t; -typedef struct snd_kctl_event snd_kctl_event_t; -typedef struct snd_aes_iec958 snd_aes_iec958_t; -typedef struct snd_ctl_card_info snd_ctl_card_info_t; -typedef struct snd_ctl_elem_id snd_ctl_elem_id_t; -typedef struct snd_ctl_elem_list snd_ctl_elem_list_t; -typedef struct snd_ctl_elem_info snd_ctl_elem_info_t; -typedef struct snd_ctl_elem_value snd_ctl_elem_value_t; -typedef struct snd_ctl_event snd_ctl_event_t; -#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) -typedef struct snd_mixer_oss snd_mixer_oss_t; -#endif - -/* timer */ -typedef struct snd_timer snd_timer_t; -typedef struct snd_timer_instance snd_timer_instance_t; -typedef struct snd_timer_id snd_timer_id_t; -typedef struct snd_timer_ginfo snd_timer_ginfo_t; -typedef struct snd_timer_gparams snd_timer_gparams_t; -typedef struct snd_timer_gstatus snd_timer_gstatus_t; -typedef struct snd_timer_select snd_timer_select_t; -typedef struct snd_timer_info snd_timer_info_t; -typedef struct snd_timer_params snd_timer_params_t; -typedef struct snd_timer_status snd_timer_status_t; -typedef struct snd_timer_read snd_timer_read_t; -typedef struct snd_timer_tread snd_timer_tread_t; - -/* PCM */ -typedef struct snd_pcm snd_pcm_t; -typedef struct snd_pcm_str snd_pcm_str_t; -typedef struct snd_pcm_substream snd_pcm_substream_t; -typedef struct snd_pcm_info snd_pcm_info_t; -typedef struct snd_pcm_hw_params snd_pcm_hw_params_t; -typedef struct snd_pcm_sw_params snd_pcm_sw_params_t; -typedef struct snd_pcm_channel_info snd_pcm_channel_info_t; -typedef struct snd_pcm_status snd_pcm_status_t; -typedef struct snd_pcm_mmap_status snd_pcm_mmap_status_t; -typedef struct snd_pcm_mmap_control snd_pcm_mmap_control_t; -typedef struct snd_mask snd_mask_t; -typedef struct snd_sg_buf snd_pcm_sgbuf_t; - -typedef struct snd_interval snd_interval_t; -typedef struct snd_xferi snd_xferi_t; -typedef struct snd_xfern snd_xfern_t; -typedef struct snd_xferv snd_xferv_t; - -typedef struct snd_pcm_file snd_pcm_file_t; -typedef struct snd_pcm_runtime snd_pcm_runtime_t; -typedef struct snd_pcm_hardware snd_pcm_hardware_t; -typedef struct snd_pcm_ops snd_pcm_ops_t; -typedef struct snd_pcm_hw_rule snd_pcm_hw_rule_t; -typedef struct snd_pcm_hw_constraints snd_pcm_hw_constraints_t; -typedef struct snd_ratnum ratnum_t; -typedef struct snd_ratden ratden_t; -typedef struct snd_pcm_hw_constraint_ratnums snd_pcm_hw_constraint_ratnums_t; -typedef struct snd_pcm_hw_constraint_ratdens snd_pcm_hw_constraint_ratdens_t; -typedef struct snd_pcm_hw_constraint_list snd_pcm_hw_constraint_list_t; -typedef struct snd_pcm_group snd_pcm_group_t; -typedef struct snd_pcm_notify snd_pcm_notify_t; - -/* rawmidi */ -typedef struct snd_rawmidi snd_rawmidi_t; -typedef struct snd_rawmidi_info snd_rawmidi_info_t; -typedef struct snd_rawmidi_params snd_rawmidi_params_t; -typedef struct snd_rawmidi_status snd_rawmidi_status_t; -typedef struct snd_rawmidi_runtime snd_rawmidi_runtime_t; -typedef struct snd_rawmidi_substream snd_rawmidi_substream_t; -typedef struct snd_rawmidi_str snd_rawmidi_str_t; -typedef struct snd_rawmidi_ops snd_rawmidi_ops_t; -typedef struct snd_rawmidi_global_ops snd_rawmidi_global_ops_t; -typedef struct snd_rawmidi_file snd_rawmidi_file_t; - -/* hwdep */ -typedef struct snd_hwdep snd_hwdep_t; -typedef struct snd_hwdep_info snd_hwdep_info_t; -typedef struct snd_hwdep_dsp_status snd_hwdep_dsp_status_t; -typedef struct snd_hwdep_dsp_image snd_hwdep_dsp_image_t; -typedef struct snd_hwdep_ops snd_hwdep_ops_t; - -/* sequencer */ -typedef struct snd_seq_port_info snd_seq_port_info_t; -typedef struct snd_seq_port_subscribe snd_seq_port_subscribe_t; -typedef struct snd_seq_event snd_seq_event_t; -typedef struct snd_seq_addr snd_seq_addr_t; -typedef struct snd_seq_ev_volume snd_seq_ev_volume_t; -typedef struct snd_seq_ev_loop snd_seq_ev_loop_t; -typedef struct snd_seq_remove_events snd_seq_remove_events_t; -typedef struct snd_seq_query_subs snd_seq_query_subs_t; -typedef struct snd_seq_system_info snd_seq_system_info_t; -typedef struct snd_seq_client_info snd_seq_client_info_t; -typedef struct snd_seq_queue_info snd_seq_queue_info_t; -typedef struct snd_seq_queue_status snd_seq_queue_status_t; -typedef struct snd_seq_queue_tempo snd_seq_queue_tempo_t; -typedef struct snd_seq_queue_owner snd_seq_queue_owner_t; -typedef struct snd_seq_queue_timer snd_seq_queue_timer_t; -typedef struct snd_seq_queue_client snd_seq_queue_client_t; -typedef struct snd_seq_client_pool snd_seq_client_pool_t; -typedef struct snd_seq_instr snd_seq_instr_t; -typedef struct snd_seq_instr_data snd_seq_instr_data_t; -typedef struct snd_seq_instr_header snd_seq_instr_header_t; - -typedef struct snd_seq_user_client user_client_t; -typedef struct snd_seq_kernel_client kernel_client_t; -typedef struct snd_seq_client client_t; -typedef struct snd_seq_queue queue_t; - -/* seq_device */ -typedef struct snd_seq_device snd_seq_device_t; -typedef struct snd_seq_dev_ops snd_seq_dev_ops_t; - -/* seq_midi */ -typedef struct snd_midi_event snd_midi_event_t; - -/* seq_midi_emul */ -typedef struct snd_midi_channel snd_midi_channel_t; -typedef struct snd_midi_channel_set snd_midi_channel_set_t; -typedef struct snd_midi_op snd_midi_op_t; - -/* seq_oss */ -typedef struct snd_seq_oss_arg snd_seq_oss_arg_t; -typedef struct snd_seq_oss_callback snd_seq_oss_callback_t; -typedef struct snd_seq_oss_reg snd_seq_oss_reg_t; - -/* virmidi */ -typedef struct snd_virmidi_dev snd_virmidi_dev_t; -typedef struct snd_virmidi snd_virmidi_t; - -/* seq_instr */ -typedef struct snd_seq_kcluster snd_seq_kcluster_t; -typedef struct snd_seq_kinstr_ops snd_seq_kinstr_ops_t; -typedef struct snd_seq_kinstr snd_seq_kinstr_t; -typedef struct snd_seq_kinstr_list snd_seq_kinstr_list_t; - -/* ac97 */ -typedef struct snd_ac97_bus ac97_bus_t; -typedef struct snd_ac97_bus_ops ac97_bus_ops_t; -typedef struct snd_ac97_template ac97_template_t; -typedef struct snd_ac97 ac97_t; - -/* opl3/4 */ -typedef struct snd_opl3 opl3_t; -typedef struct snd_opl4 opl4_t; - -/* mpu401 */ -typedef struct snd_mpu401 mpu401_t; - -/* i2c */ -typedef struct snd_i2c_device snd_i2c_device_t; -typedef struct snd_i2c_bus snd_i2c_bus_t; - -typedef struct snd_ak4531 ak4531_t; - diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h index f3514ee..203d2b4 100644 --- a/include/sound/ymfpci.h +++ b/include/sound/ymfpci.h @@ -270,6 +270,7 @@ struct snd_ymfpci_pcm { struct snd_pcm_substream *substream; struct snd_ymfpci_voice *voices[2]; /* playback only */ unsigned int running: 1, + use_441_slot: 1, output_front: 1, output_rear: 1, swap_rear: 1; @@ -324,6 +325,7 @@ #endif u32 active_bank; struct snd_ymfpci_voice voices[64]; + int src441_used; struct snd_ac97_bus *ac97_bus; struct snd_ac97 *ac97; @@ -346,7 +348,7 @@ #endif int mode_dup4ch; int rear_opened; int spdif_opened; - struct { + struct snd_ymfpci_pcm_mixer { u16 left; u16 right; struct snd_kcontrol *ctl; @@ -357,6 +359,8 @@ #endif wait_queue_head_t interrupt_sleep; atomic_t interrupt_sleep_count; struct snd_info_entry *proc_entry; + const struct firmware *dsp_microcode; + const struct firmware *controller_microcode; #ifdef CONFIG_PM u32 *saved_regs; diff --git a/sound/Kconfig b/sound/Kconfig index 9d77300..97532bb 100644 --- a/sound/Kconfig +++ b/sound/Kconfig @@ -76,6 +76,8 @@ source "sound/sparc/Kconfig" source "sound/parisc/Kconfig" +source "sound/soc/Kconfig" + endmenu menu "Open Sound System" diff --git a/sound/Makefile b/sound/Makefile index 9aee54c..b7c7fb7 100644 --- a/sound/Makefile +++ b/sound/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_SOUND) += soundcore.o obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o obj-$(CONFIG_SOUND_PRIME) += oss/ obj-$(CONFIG_DMASOUND) += oss/ -obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ +obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/ obj-$(CONFIG_SND_AOA) += aoa/ # This one must be compilable even if sound is configured out diff --git a/sound/aoa/aoa.h b/sound/aoa/aoa.h index 378ef1e..541b908 100644 --- a/sound/aoa/aoa.h +++ b/sound/aoa/aoa.h @@ -99,7 +99,7 @@ struct aoa_fabric { * that are not assigned yet are passed to the fabric * again for reconsideration. */ extern int -aoa_fabric_register(struct aoa_fabric *fabric); +aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev); /* it is vital to call this when the fabric exits! * When calling, the remove_codec will be called diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c b/sound/aoa/codecs/snd-aoa-codec-onyx.c index 0b76507..b00fc48 100644 --- a/sound/aoa/codecs/snd-aoa-codec-onyx.c +++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c @@ -825,7 +825,16 @@ static int onyx_resume(struct codec_info int err = -ENXIO; mutex_lock(&onyx->mutex); - /* take codec out of suspend */ + + /* reset codec */ + onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0); + msleep(1); + onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1); + msleep(1); + onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0); + msleep(1); + + /* take codec out of suspend (if it still is after reset) */ if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v)) goto out_unlock; onyx_write_register(onyx, ONYX_REG_CONTROL, v & ~(ONYX_ADPSV | ONYX_DAPSV)); diff --git a/sound/aoa/core/snd-aoa-alsa.c b/sound/aoa/core/snd-aoa-alsa.c index b42fdea..17fe689 100644 --- a/sound/aoa/core/snd-aoa-alsa.c +++ b/sound/aoa/core/snd-aoa-alsa.c @@ -14,7 +14,7 @@ MODULE_PARM_DESC(index, "index for AOA s static struct aoa_card *aoa_card; -int aoa_alsa_init(char *name, struct module *mod) +int aoa_alsa_init(char *name, struct module *mod, struct device *dev) { struct snd_card *alsa_card; int err; @@ -28,6 +28,7 @@ int aoa_alsa_init(char *name, struct mod return -ENOMEM; aoa_card = alsa_card->private_data; aoa_card->alsa_card = alsa_card; + alsa_card->dev = dev; strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver)); strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname)); strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname)); @@ -59,7 +60,7 @@ void aoa_alsa_cleanup(void) } int aoa_snd_device_new(snd_device_type_t type, - void * device_data, struct snd_device_ops * ops) + void * device_data, struct snd_device_ops * ops) { struct snd_card *card = aoa_get_card(); int err; diff --git a/sound/aoa/core/snd-aoa-alsa.h b/sound/aoa/core/snd-aoa-alsa.h index 660d2f1..9669e44 100644 --- a/sound/aoa/core/snd-aoa-alsa.h +++ b/sound/aoa/core/snd-aoa-alsa.h @@ -10,7 +10,7 @@ #ifndef __SND_AOA_ALSA_H #define __SND_AOA_ALSA_H #include "../aoa.h" -extern int aoa_alsa_init(char *name, struct module *mod); +extern int aoa_alsa_init(char *name, struct module *mod, struct device *dev); extern void aoa_alsa_cleanup(void); #endif /* __SND_AOA_ALSA_H */ diff --git a/sound/aoa/core/snd-aoa-core.c b/sound/aoa/core/snd-aoa-core.c index ecd2d82..19fdae4 100644 --- a/sound/aoa/core/snd-aoa-core.c +++ b/sound/aoa/core/snd-aoa-core.c @@ -82,7 +82,7 @@ void aoa_codec_unregister(struct aoa_cod } EXPORT_SYMBOL_GPL(aoa_codec_unregister); -int aoa_fabric_register(struct aoa_fabric *new_fabric) +int aoa_fabric_register(struct aoa_fabric *new_fabric, struct device *dev) { struct aoa_codec *c; int err; @@ -98,7 +98,7 @@ int aoa_fabric_register(struct aoa_fabri if (!new_fabric) return -EINVAL; - err = aoa_alsa_init(new_fabric->name, new_fabric->owner); + err = aoa_alsa_init(new_fabric->name, new_fabric->owner, dev); if (err) return err; diff --git a/sound/aoa/fabrics/snd-aoa-fabric-layout.c b/sound/aoa/fabrics/snd-aoa-fabric-layout.c index 172eb95..4098096 100644 --- a/sound/aoa/fabrics/snd-aoa-fabric-layout.c +++ b/sound/aoa/fabrics/snd-aoa-fabric-layout.c @@ -1014,7 +1014,7 @@ static int aoa_fabric_layout_probe(struc ldev->gpio.methods->init(&ldev->gpio); - err = aoa_fabric_register(&layout_fabric); + err = aoa_fabric_register(&layout_fabric, &sdev->ofdev.dev); if (err && err != -EALREADY) { printk(KERN_INFO "snd-aoa-fabric-layout: can't use," " another fabric is active!\n"); @@ -1107,6 +1107,9 @@ #ifdef CONFIG_PM .suspend = aoa_fabric_layout_suspend, .resume = aoa_fabric_layout_resume, #endif + .driver = { + .owner = THIS_MODULE, + } }; static int __init aoa_fabric_layout_init(void) diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c b/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c index 5eff30b..7c81db7 100644 --- a/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c +++ b/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c @@ -812,7 +812,6 @@ static void i2sbus_private_free(struct s module_put(THIS_MODULE); } -/* FIXME: this function needs an error handling strategy with labels */ int i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, struct codec_info *ci, void *data) @@ -880,41 +879,31 @@ i2sbus_attach_codec(struct soundbus_dev if (!cii->sdev) { printk(KERN_DEBUG "i2sbus: failed to get soundbus dev reference\n"); - kfree(cii); - return -ENODEV; + err = -ENODEV; + goto out_free_cii; } if (!try_module_get(THIS_MODULE)) { printk(KERN_DEBUG "i2sbus: failed to get module reference!\n"); - soundbus_dev_put(dev); - kfree(cii); - return -EBUSY; + err = -EBUSY; + goto out_put_sdev; } if (!try_module_get(ci->owner)) { printk(KERN_DEBUG "i2sbus: failed to get module reference to codec owner!\n"); - module_put(THIS_MODULE); - soundbus_dev_put(dev); - kfree(cii); - return -EBUSY; + err = -EBUSY; + goto out_put_this_module; } if (!dev->pcm) { - err = snd_pcm_new(card, - dev->pcmname, - dev->pcmid, - 0, - 0, + err = snd_pcm_new(card, dev->pcmname, dev->pcmid, 0, 0, &dev->pcm); if (err) { printk(KERN_DEBUG "i2sbus: failed to create pcm\n"); - kfree(cii); - module_put(ci->owner); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return err; + goto out_put_ci_module; } + dev->pcm->dev = &dev->ofdev.dev; } /* ALSA yet again sucks. @@ -926,20 +915,12 @@ i2sbus_attach_codec(struct soundbus_dev /* eh? */ printk(KERN_ERR "Can't attach same bus to different cards!\n"); - module_put(ci->owner); - kfree(cii); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return -EINVAL; - } - if ((err = - snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, 1))) { - module_put(ci->owner); - kfree(cii); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return err; + err = -EINVAL; + goto out_put_ci_module; } + err = snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, 1); + if (err) + goto out_put_ci_module; snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, &i2sbus_playback_ops); i2sdev->out.created = 1; @@ -949,20 +930,11 @@ i2sbus_attach_codec(struct soundbus_dev if (dev->pcm->card != card) { printk(KERN_ERR "Can't attach same bus to different cards!\n"); - module_put(ci->owner); - kfree(cii); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return -EINVAL; - } - if ((err = - snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, 1))) { - module_put(ci->owner); - kfree(cii); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return err; + goto out_put_ci_module; } + err = snd_pcm_new_stream(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, 1); + if (err) + goto out_put_ci_module; snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, &i2sbus_record_ops); i2sdev->in.created = 1; @@ -977,11 +949,7 @@ i2sbus_attach_codec(struct soundbus_dev err = snd_device_register(card, dev->pcm); if (err) { printk(KERN_ERR "i2sbus: error registering new pcm\n"); - module_put(ci->owner); - kfree(cii); - soundbus_dev_put(dev); - module_put(THIS_MODULE); - return err; + goto out_put_ci_module; } /* no errors any more, so let's add this to our list */ list_add(&cii->list, &dev->codec_list); @@ -996,6 +964,15 @@ i2sbus_attach_codec(struct soundbus_dev 64 * 1024, 64 * 1024); return 0; + out_put_ci_module: + module_put(ci->owner); + out_put_this_module: + module_put(THIS_MODULE); + out_put_sdev: + soundbus_dev_put(dev); + out_free_cii: + kfree(cii); + return err; } void i2sbus_detach_codec(struct soundbus_dev *dev, void *data) diff --git a/sound/arm/aaci.h b/sound/arm/aaci.h index 0629519..9175ff9 100644 --- a/sound/arm/aaci.h +++ b/sound/arm/aaci.h @@ -228,7 +228,7 @@ struct aaci { /* AC'97 */ struct mutex ac97_sem; - ac97_bus_t *ac97_bus; + struct snd_ac97_bus *ac97_bus; u32 maincr; spinlock_t lock; diff --git a/sound/core/control.c b/sound/core/control.c index 0c7bcd6..42bcf27 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -108,7 +108,6 @@ static void snd_ctl_empty_read_queue(str static int snd_ctl_release(struct inode *inode, struct file *file) { unsigned long flags; - struct list_head *list; struct snd_card *card; struct snd_ctl_file *ctl; struct snd_kcontrol *control; @@ -122,12 +121,10 @@ static int snd_ctl_release(struct inode list_del(&ctl->list); write_unlock_irqrestore(&card->ctl_files_rwlock, flags); down_write(&card->controls_rwsem); - list_for_each(list, &card->controls) { - control = snd_kcontrol(list); + list_for_each_entry(control, &card->controls, list) for (idx = 0; idx < control->count; idx++) if (control->vd[idx].owner == ctl) control->vd[idx].owner = NULL; - } up_write(&card->controls_rwsem); snd_ctl_empty_read_queue(ctl); kfree(ctl); @@ -140,7 +137,6 @@ void snd_ctl_notify(struct snd_card *car struct snd_ctl_elem_id *id) { unsigned long flags; - struct list_head *flist; struct snd_ctl_file *ctl; struct snd_kctl_event *ev; @@ -149,14 +145,11 @@ void snd_ctl_notify(struct snd_card *car #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) card->mixer_oss_change_count++; #endif - list_for_each(flist, &card->ctl_files) { - struct list_head *elist; - ctl = snd_ctl_file(flist); + list_for_each_entry(ctl, &card->ctl_files, list) { if (!ctl->subscribed) continue; spin_lock_irqsave(&ctl->read_lock, flags); - list_for_each(elist, &ctl->events) { - ev = snd_kctl_event(elist); + list_for_each_entry(ev, &ctl->events, list) { if (ev->id.numid == id->numid) { ev->mask |= mask; goto _found; @@ -190,7 +183,8 @@ EXPORT_SYMBOL(snd_ctl_notify); * * Returns the pointer of the new instance, or NULL on failure. */ -struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int access) +static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, + unsigned int access) { struct snd_kcontrol *kctl; unsigned int idx; @@ -208,8 +202,6 @@ struct snd_kcontrol *snd_ctl_new(struct return kctl; } -EXPORT_SYMBOL(snd_ctl_new); - /** * snd_ctl_new1 - create a control instance from the template * @ncontrol: the initialization record @@ -277,11 +269,9 @@ EXPORT_SYMBOL(snd_ctl_free_one); static unsigned int snd_ctl_hole_check(struct snd_card *card, unsigned int count) { - struct list_head *list; struct snd_kcontrol *kctl; - list_for_each(list, &card->controls) { - kctl = snd_kcontrol(list); + list_for_each_entry(kctl, &card->controls, list) { if ((kctl->id.numid <= card->last_numid && kctl->id.numid + kctl->count > card->last_numid) || (kctl->id.numid <= card->last_numid + count - 1 && @@ -498,12 +488,10 @@ EXPORT_SYMBOL(snd_ctl_rename_id); */ struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) { - struct list_head *list; struct snd_kcontrol *kctl; snd_assert(card != NULL && numid != 0, return NULL); - list_for_each(list, &card->controls) { - kctl = snd_kcontrol(list); + list_for_each_entry(kctl, &card->controls, list) { if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) return kctl; } @@ -527,14 +515,12 @@ EXPORT_SYMBOL(snd_ctl_find_numid); struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, struct snd_ctl_elem_id *id) { - struct list_head *list; struct snd_kcontrol *kctl; snd_assert(card != NULL && id != NULL, return NULL); if (id->numid != 0) return snd_ctl_find_numid(card, id->numid); - list_for_each(list, &card->controls) { - kctl = snd_kcontrol(list); + list_for_each_entry(kctl, &card->controls, list) { if (kctl->id.iface != id->iface) continue; if (kctl->id.device != id->device) @@ -1182,7 +1168,6 @@ static long snd_ctl_ioctl(struct file *f { struct snd_ctl_file *ctl; struct snd_card *card; - struct list_head *list; struct snd_kctl_ioctl *p; void __user *argp = (void __user *)arg; int __user *ip = argp; @@ -1232,8 +1217,7 @@ #else #endif } down_read(&snd_ioctl_rwsem); - list_for_each(list, &snd_control_ioctls) { - p = list_entry(list, struct snd_kctl_ioctl, list); + list_for_each_entry(p, &snd_control_ioctls, list) { err = p->fioctl(card, ctl, cmd, arg); if (err != -ENOIOCTLCMD) { up_read(&snd_ioctl_rwsem); @@ -1357,13 +1341,11 @@ #endif static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *lists) { - struct list_head *list; struct snd_kctl_ioctl *p; snd_assert(fcn != NULL, return -EINVAL); down_write(&snd_ioctl_rwsem); - list_for_each(list, lists) { - p = list_entry(list, struct snd_kctl_ioctl, list); + list_for_each_entry(p, lists, list) { if (p->fioctl == fcn) { list_del(&p->list); up_write(&snd_ioctl_rwsem); @@ -1453,7 +1435,6 @@ static int snd_ctl_dev_register(struct s static int snd_ctl_dev_disconnect(struct snd_device *device) { struct snd_card *card = device->device_data; - struct list_head *flist; struct snd_ctl_file *ctl; int err, cardnum; @@ -1462,8 +1443,7 @@ static int snd_ctl_dev_disconnect(struct snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); down_read(&card->controls_rwsem); - list_for_each(flist, &card->ctl_files) { - ctl = snd_ctl_file(flist); + list_for_each_entry(ctl, &card->ctl_files, list) { wake_up(&ctl->change_sleep); kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); } diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index ab48962..9311ca3 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -392,7 +392,7 @@ enum { static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { struct snd_ctl_file *ctl; - struct list_head *list; + struct snd_kctl_ioctl *p; void __user *argp = compat_ptr(arg); int err; @@ -427,8 +427,7 @@ static inline long snd_ctl_ioctl_compat( } down_read(&snd_ioctl_rwsem); - list_for_each(list, &snd_control_compat_ioctls) { - struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list); + list_for_each_entry(p, &snd_control_compat_ioctls, list) { if (p->fioctl) { err = p->fioctl(ctl->card, ctl, cmd, arg); if (err != -ENOIOCTLCMD) { diff --git a/sound/core/device.c b/sound/core/device.c index ccb2581..5858b02 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -79,13 +79,11 @@ EXPORT_SYMBOL(snd_device_new); */ int snd_device_free(struct snd_card *card, void *device_data) { - struct list_head *list; struct snd_device *dev; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (dev->device_data != device_data) continue; /* unlink */ @@ -124,13 +122,11 @@ EXPORT_SYMBOL(snd_device_free); */ int snd_device_disconnect(struct snd_card *card, void *device_data) { - struct list_head *list; struct snd_device *dev; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (dev->device_data != device_data) continue; if (dev->state == SNDRV_DEV_REGISTERED && @@ -161,14 +157,12 @@ int snd_device_disconnect(struct snd_car */ int snd_device_register(struct snd_card *card, void *device_data) { - struct list_head *list; struct snd_device *dev; int err; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (dev->device_data != device_data) continue; if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { @@ -192,13 +186,11 @@ EXPORT_SYMBOL(snd_device_register); */ int snd_device_register_all(struct snd_card *card) { - struct list_head *list; struct snd_device *dev; int err; snd_assert(card != NULL, return -ENXIO); - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { if ((err = dev->ops->dev_register(dev)) < 0) return err; @@ -215,12 +207,10 @@ int snd_device_register_all(struct snd_c int snd_device_disconnect_all(struct snd_card *card) { struct snd_device *dev; - struct list_head *list; int err = 0; snd_assert(card != NULL, return -ENXIO); - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (snd_device_disconnect(card, dev->device_data) < 0) err = -ENXIO; } @@ -234,7 +224,6 @@ int snd_device_disconnect_all(struct snd int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) { struct snd_device *dev; - struct list_head *list; int err; unsigned int range_low, range_high; @@ -242,8 +231,7 @@ int snd_device_free_all(struct snd_card range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; __again: - list_for_each(list, &card->devices) { - dev = snd_device(list); + list_for_each_entry(dev, &card->devices, list) { if (dev->type >= range_low && dev->type <= range_high) { if ((err = snd_device_free(card, dev->device_data)) < 0) return err; diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 46b4768..a6a6ad0 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -47,14 +47,11 @@ static int snd_hwdep_dev_disconnect(stru static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device) { - struct list_head *p; struct snd_hwdep *hwdep; - list_for_each(p, &snd_hwdep_devices) { - hwdep = list_entry(p, struct snd_hwdep, list); + list_for_each_entry(hwdep, &snd_hwdep_devices, list) if (hwdep->card == card && hwdep->device == device) return hwdep; - } return NULL; } @@ -468,15 +465,12 @@ #ifdef CONFIG_PROC_FS static void snd_hwdep_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct list_head *p; struct snd_hwdep *hwdep; mutex_lock(®ister_mutex); - list_for_each(p, &snd_hwdep_devices) { - hwdep = list_entry(p, struct snd_hwdep, list); + list_for_each_entry(hwdep, &snd_hwdep_devices, list) snd_iprintf(buffer, "%02i-%02i: %s\n", hwdep->card->number, hwdep->device, hwdep->name); - } mutex_unlock(®ister_mutex); } diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index bc0bd09..f057430 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -406,19 +406,17 @@ #endif */ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) { - struct list_head *p; struct snd_mem_list *mem; snd_assert(dmab, return 0); mutex_lock(&list_mutex); - list_for_each(p, &mem_list_head) { - mem = list_entry(p, struct snd_mem_list, list); + list_for_each_entry(mem, &mem_list_head, list) { if (mem->id == id && (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL || ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) { struct device *dev = dmab->dev.dev; - list_del(p); + list_del(&mem->list); *dmab = mem->buffer; if (dmab->dev.dev == NULL) dmab->dev.dev = dev; @@ -488,7 +486,6 @@ static int snd_mem_proc_read(char *page, { int len = 0; long pages = snd_allocated_pages >> (PAGE_SHIFT-12); - struct list_head *p; struct snd_mem_list *mem; int devno; static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; @@ -498,8 +495,7 @@ static int snd_mem_proc_read(char *page, "pages : %li bytes (%li pages per %likB)\n", pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); devno = 0; - list_for_each(p, &mem_list_head) { - mem = list_entry(p, struct snd_mem_list, list); + list_for_each_entry(mem, &mem_list_head, list) { devno++; len += snprintf(page + len, count - len, "buffer %d : ID %08x : type %s\n", diff --git a/sound/core/misc.c b/sound/core/misc.c index 03fc711..6db86a7 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -78,3 +78,31 @@ void snd_verbose_printd(const char *file EXPORT_SYMBOL(snd_verbose_printd); #endif + +#ifdef CONFIG_PCI +#include +/** + * snd_pci_quirk_lookup - look up a PCI SSID quirk list + * @pci: pci_dev handle + * @list: quirk list, terminated by a null entry + * + * Look through the given quirk list and finds a matching entry + * with the same PCI SSID. When subdevice is 0, all subdevice + * values may match. + * + * Returns the matched entry pointer, or NULL if nothing matched. + */ +const struct snd_pci_quirk * +snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) +{ + const struct snd_pci_quirk *q; + + for (q = list; q->subvendor; q++) + if (q->subvendor == pci->subsystem_vendor && + (!q->subdevice || q->subdevice == pci->subsystem_device)) + return q; + return NULL; +} + +EXPORT_SYMBOL(snd_pci_quirk_lookup); +#endif diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 8e01898..76fcc52 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -45,11 +45,9 @@ static int snd_pcm_dev_disconnect(struct static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) { - struct list_head *p; struct snd_pcm *pcm; - list_for_each(p, &snd_pcm_devices) { - pcm = list_entry(p, struct snd_pcm, list); + list_for_each_entry(pcm, &snd_pcm_devices, list) { if (pcm->card == card && pcm->device == device) return pcm; } @@ -782,7 +780,6 @@ int snd_pcm_attach_substream(struct snd_ struct snd_pcm_runtime *runtime; struct snd_ctl_file *kctl; struct snd_card *card; - struct list_head *list; int prefer_subdevice = -1; size_t size; @@ -795,8 +792,7 @@ int snd_pcm_attach_substream(struct snd_ card = pcm->card; down_read(&card->controls_rwsem); - list_for_each(list, &card->ctl_files) { - kctl = snd_ctl_file(list); + list_for_each_entry(kctl, &card->ctl_files, list) { if (kctl->pid == current->pid) { prefer_subdevice = kctl->prefer_pcm_subdevice; if (prefer_subdevice != -1) @@ -941,9 +937,10 @@ static int snd_pcm_dev_register(struct s { int cidx, err; struct snd_pcm_substream *substream; - struct list_head *list; + struct snd_pcm_notify *notify; char str[16]; struct snd_pcm *pcm = device->device_data; + struct device *dev; snd_assert(pcm != NULL && device != NULL, return -ENXIO); mutex_lock(®ister_mutex); @@ -966,11 +963,18 @@ static int snd_pcm_dev_register(struct s devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } - if ((err = snd_register_device(devtype, pcm->card, - pcm->device, - &snd_pcm_f_ops[cidx], - pcm, str)) < 0) - { + /* device pointer to use, pcm->dev takes precedence if + * it is assigned, otherwise fall back to card's device + * if possible */ + dev = pcm->dev; + if (!dev) + dev = pcm->card ? pcm->card->dev : NULL; + /* register pcm */ + err = snd_register_device_for_dev(devtype, pcm->card, + pcm->device, + &snd_pcm_f_ops[cidx], + pcm, str, dev); + if (err < 0) { list_del(&pcm->list); mutex_unlock(®ister_mutex); return err; @@ -980,11 +984,10 @@ static int snd_pcm_dev_register(struct s for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) snd_pcm_timer_init(substream); } - list_for_each(list, &snd_pcm_notify_list) { - struct snd_pcm_notify *notify; - notify = list_entry(list, struct snd_pcm_notify, list); + + list_for_each_entry(notify, &snd_pcm_notify_list, list) notify->n_register(pcm); - } + mutex_unlock(®ister_mutex); return 0; } @@ -1027,7 +1030,7 @@ static int snd_pcm_dev_disconnect(struct int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) { - struct list_head *p; + struct snd_pcm *pcm; snd_assert(notify != NULL && notify->n_register != NULL && @@ -1036,13 +1039,12 @@ int snd_pcm_notify(struct snd_pcm_notify mutex_lock(®ister_mutex); if (nfree) { list_del(¬ify->list); - list_for_each(p, &snd_pcm_devices) - notify->n_unregister(list_entry(p, - struct snd_pcm, list)); + list_for_each_entry(pcm, &snd_pcm_devices, list) + notify->n_unregister(pcm); } else { list_add_tail(¬ify->list, &snd_pcm_notify_list); - list_for_each(p, &snd_pcm_devices) - notify->n_register(list_entry(p, struct snd_pcm, list)); + list_for_each_entry(pcm, &snd_pcm_devices, list) + notify->n_register(pcm); } mutex_unlock(®ister_mutex); return 0; @@ -1058,12 +1060,10 @@ #ifdef CONFIG_PROC_FS static void snd_pcm_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct list_head *p; struct snd_pcm *pcm; mutex_lock(®ister_mutex); - list_for_each(p, &snd_pcm_devices) { - pcm = list_entry(p, struct snd_pcm, list); + list_for_each_entry(pcm, &snd_pcm_devices, list) { snd_iprintf(buffer, "%02i-%02i: %s : %s", pcm->card->number, pcm->device, pcm->id, pcm->name); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index be030cb..95b1b2f 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -101,6 +101,8 @@ int snd_pcm_lib_preallocate_free(struct { snd_pcm_lib_preallocate_dma_free(substream); #ifdef CONFIG_SND_VERBOSE_PROCFS + snd_info_free_entry(substream->proc_prealloc_max_entry); + substream->proc_prealloc_max_entry = NULL; snd_info_free_entry(substream->proc_prealloc_entry); substream->proc_prealloc_entry = NULL; #endif @@ -142,6 +144,18 @@ static void snd_pcm_lib_preallocate_proc } /* + * read callback for prealloc_max proc file + * + * prints the maximum allowed size in kB. + */ +static void snd_pcm_lib_preallocate_max_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct snd_pcm_substream *substream = entry->private_data; + snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024); +} + +/* * write callback for prealloc proc file * * accepts the preallocation size in kB. @@ -203,6 +217,15 @@ static inline void preallocate_info_init } } substream->proc_prealloc_entry = entry; + if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", substream->proc_root)) != NULL) { + entry->c.text.read = snd_pcm_lib_preallocate_max_proc_read; + entry->private_data = substream; + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + entry = NULL; + } + } + substream->proc_prealloc_max_entry = entry; } #else /* !CONFIG_SND_VERBOSE_PROCFS */ diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 0f055bf..7e6ceec 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -61,14 +61,11 @@ static DEFINE_MUTEX(register_mutex); static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) { - struct list_head *p; struct snd_rawmidi *rawmidi; - list_for_each(p, &snd_rawmidi_devices) { - rawmidi = list_entry(p, struct snd_rawmidi, list); + list_for_each_entry(rawmidi, &snd_rawmidi_devices, list) if (rawmidi->card == card && rawmidi->device == device) return rawmidi; - } return NULL; } @@ -389,7 +386,6 @@ static int snd_rawmidi_open(struct inode struct snd_rawmidi *rmidi; struct snd_rawmidi_file *rawmidi_file; wait_queue_t wait; - struct list_head *list; struct snd_ctl_file *kctl; if (maj == snd_major) { @@ -426,8 +422,7 @@ #endif while (1) { subdevice = -1; down_read(&card->controls_rwsem); - list_for_each(list, &card->ctl_files) { - kctl = snd_ctl_file(list); + list_for_each_entry(kctl, &card->ctl_files, list) { if (kctl->pid == current->pid) { subdevice = kctl->prefer_rawmidi_subdevice; if (subdevice != -1) @@ -575,7 +570,6 @@ int snd_rawmidi_info_select(struct snd_c struct snd_rawmidi *rmidi; struct snd_rawmidi_str *pstr; struct snd_rawmidi_substream *substream; - struct list_head *list; mutex_lock(®ister_mutex); rmidi = snd_rawmidi_search(card, info->device); @@ -589,8 +583,7 @@ int snd_rawmidi_info_select(struct snd_c return -ENOENT; if (info->subdevice >= pstr->substream_count) return -ENXIO; - list_for_each(list, &pstr->substreams) { - substream = list_entry(list, struct snd_rawmidi_substream, list); + list_for_each_entry(substream, &pstr->substreams, list) { if ((unsigned int)substream->number == info->subdevice) return snd_rawmidi_info(substream, info); } @@ -1313,14 +1306,14 @@ static void snd_rawmidi_proc_info_read(s struct snd_rawmidi *rmidi; struct snd_rawmidi_substream *substream; struct snd_rawmidi_runtime *runtime; - struct list_head *list; rmidi = entry->private_data; snd_iprintf(buffer, "%s\n\n", rmidi->name); mutex_lock(&rmidi->open_mutex); if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { - list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, struct snd_rawmidi_substream, list); + list_for_each_entry(substream, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams, + list) { snd_iprintf(buffer, "Output %d\n" " Tx bytes : %lu\n", @@ -1339,8 +1332,9 @@ static void snd_rawmidi_proc_info_read(s } } if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) { - list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { - substream = list_entry(list, struct snd_rawmidi_substream, list); + list_for_each_entry(substream, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams, + list) { snd_iprintf(buffer, "Input %d\n" " Rx bytes : %lu\n", @@ -1625,13 +1619,10 @@ #endif /* CONFIG_SND_OSSEMUL */ void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, struct snd_rawmidi_ops *ops) { - struct list_head *list; struct snd_rawmidi_substream *substream; - list_for_each(list, &rmidi->streams[stream].substreams) { - substream = list_entry(list, struct snd_rawmidi_substream, list); + list_for_each_entry(substream, &rmidi->streams[stream].substreams, list) substream->ops = ops; - } } /* diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 532a660..bb9dd9f 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -659,7 +659,6 @@ static int deliver_to_subscribers(struct int err = 0, num_ev = 0; struct snd_seq_event event_saved; struct snd_seq_client_port *src_port; - struct list_head *p; struct snd_seq_port_subs_info *grp; src_port = snd_seq_port_use_ptr(client, event->source.port); @@ -674,8 +673,7 @@ static int deliver_to_subscribers(struct read_lock(&grp->list_lock); else down_read(&grp->list_mutex); - list_for_each(p, &grp->list_head) { - subs = list_entry(p, struct snd_seq_subscribers, src_list); + list_for_each_entry(subs, &grp->list_head, src_list) { event->dest = subs->info.dest; if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP) /* convert time according to flag with subscription */ @@ -709,15 +707,14 @@ static int port_broadcast_event(struct s { int num_ev = 0, err = 0; struct snd_seq_client *dest_client; - struct list_head *p; + struct snd_seq_client_port *port; dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST); if (dest_client == NULL) return 0; /* no matching destination */ read_lock(&dest_client->ports_lock); - list_for_each(p, &dest_client->ports_list_head) { - struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); + list_for_each_entry(port, &dest_client->ports_list_head, list) { event->dest.port = port->addr.port; /* pass NULL as source client to avoid error bounce */ err = snd_seq_deliver_single_event(NULL, event, @@ -2473,11 +2470,10 @@ #define FLAG_PERM_DUPLEX(perm) ((perm) & static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, struct snd_seq_client *client) { - struct list_head *l; + struct snd_seq_client_port *p; mutex_lock(&client->ports_mutex); - list_for_each(l, &client->ports_list_head) { - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); + list_for_each_entry(p, &client->ports_list_head, list) { snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", p->addr.port, p->name, FLAG_PERM_RD(p->capability), diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index b79d011..37852cd 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -106,11 +106,10 @@ #ifdef CONFIG_PROC_FS static void snd_seq_device_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct list_head *head; + struct ops_list *ops; mutex_lock(&ops_mutex); - list_for_each(head, &opslist) { - struct ops_list *ops = list_entry(head, struct ops_list, list); + list_for_each_entry(ops, &opslist, list) { snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", ops->id, ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""), @@ -143,7 +142,7 @@ #endif void snd_seq_device_load_drivers(void) { #ifdef CONFIG_KMOD - struct list_head *head; + struct ops_list *ops; /* Calling request_module during module_init() * may cause blocking. @@ -155,8 +154,7 @@ #ifdef CONFIG_KMOD return; mutex_lock(&ops_mutex); - list_for_each(head, &opslist) { - struct ops_list *ops = list_entry(head, struct ops_list, list); + list_for_each_entry(ops, &opslist, list) { if (! (ops->driver & DRIVER_LOADED) && ! (ops->driver & DRIVER_REQUESTED)) { ops->used++; @@ -314,8 +312,8 @@ static int snd_seq_device_dev_disconnect int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize) { - struct list_head *head; struct ops_list *ops; + struct snd_seq_device *dev; if (id == NULL || entry == NULL || entry->init_device == NULL || entry->free_device == NULL) @@ -341,8 +339,7 @@ int snd_seq_device_register_driver(char ops->argsize = argsize; /* initialize existing devices if necessary */ - list_for_each(head, &ops->dev_list) { - struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); + list_for_each_entry(dev, &ops->dev_list, list) { init_device(dev, ops); } mutex_unlock(&ops->reg_mutex); @@ -394,8 +391,8 @@ static struct ops_list * create_driver(c */ int snd_seq_device_unregister_driver(char *id) { - struct list_head *head; struct ops_list *ops; + struct snd_seq_device *dev; ops = find_driver(id, 0); if (ops == NULL) @@ -411,8 +408,7 @@ int snd_seq_device_unregister_driver(cha /* close and release all devices associated with this driver */ mutex_lock(&ops->reg_mutex); ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ - list_for_each(head, &ops->dev_list) { - struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); + list_for_each_entry(dev, &ops->dev_list, list) { free_device(dev, ops); } @@ -512,11 +508,10 @@ static int free_device(struct snd_seq_de */ static struct ops_list * find_driver(char *id, int create_if_empty) { - struct list_head *head; + struct ops_list *ops; mutex_lock(&ops_mutex); - list_for_each(head, &opslist) { - struct ops_list *ops = list_entry(head, struct ops_list, list); + list_for_each_entry(ops, &opslist, list) { if (strcmp(ops->id, id) == 0) { ops->used++; mutex_unlock(&ops_mutex); diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 8c64b58..d881534 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -59,14 +59,12 @@ much elements are in array. struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, int num) { - struct list_head *p; struct snd_seq_client_port *port; if (client == NULL) return NULL; read_lock(&client->ports_lock); - list_for_each(p, &client->ports_list_head) { - port = list_entry(p, struct snd_seq_client_port, list); + list_for_each_entry(port, &client->ports_list_head, list) { if (port->addr.port == num) { if (port->closing) break; /* deleting now */ @@ -85,14 +83,12 @@ struct snd_seq_client_port *snd_seq_port struct snd_seq_port_info *pinfo) { int num; - struct list_head *p; struct snd_seq_client_port *port, *found; num = pinfo->addr.port; found = NULL; read_lock(&client->ports_lock); - list_for_each(p, &client->ports_list_head) { - port = list_entry(p, struct snd_seq_client_port, list); + list_for_each_entry(port, &client->ports_list_head, list) { if (port->addr.port < num) continue; if (port->addr.port == num) { @@ -131,8 +127,7 @@ struct snd_seq_client_port *snd_seq_crea int port) { unsigned long flags; - struct snd_seq_client_port *new_port; - struct list_head *l; + struct snd_seq_client_port *new_port, *p; int num = -1; /* sanity check */ @@ -161,15 +156,14 @@ struct snd_seq_client_port *snd_seq_crea num = port >= 0 ? port : 0; mutex_lock(&client->ports_mutex); write_lock_irqsave(&client->ports_lock, flags); - list_for_each(l, &client->ports_list_head) { - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); + list_for_each_entry(p, &client->ports_list_head, list) { if (p->addr.port > num) break; if (port < 0) /* auto-probe mode */ num = p->addr.port + 1; } /* insert the new port */ - list_add_tail(&new_port->list, l); + list_add_tail(&new_port->list, &p->list); client->num_ports++; new_port->addr.port = num; /* store the port number in the port */ write_unlock_irqrestore(&client->ports_lock, flags); @@ -287,16 +281,14 @@ static int port_delete(struct snd_seq_cl int snd_seq_delete_port(struct snd_seq_client *client, int port) { unsigned long flags; - struct list_head *l; - struct snd_seq_client_port *found = NULL; + struct snd_seq_client_port *found = NULL, *p; mutex_lock(&client->ports_mutex); write_lock_irqsave(&client->ports_lock, flags); - list_for_each(l, &client->ports_list_head) { - struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); + list_for_each_entry(p, &client->ports_list_head, list) { if (p->addr.port == port) { /* ok found. delete from the list at first */ - list_del(l); + list_del(&p->list); client->num_ports--; found = p; break; @@ -314,7 +306,8 @@ int snd_seq_delete_port(struct snd_seq_c int snd_seq_delete_all_ports(struct snd_seq_client *client) { unsigned long flags; - struct list_head deleted_list, *p, *n; + struct list_head deleted_list; + struct snd_seq_client_port *port, *tmp; /* move the port list to deleted_list, and * clear the port list in the client data. @@ -331,9 +324,8 @@ int snd_seq_delete_all_ports(struct snd_ write_unlock_irqrestore(&client->ports_lock, flags); /* remove each port in deleted_list */ - list_for_each_safe(p, n, &deleted_list) { - struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); - list_del(p); + list_for_each_entry_safe(port, tmp, &deleted_list, list) { + list_del(&port->list); snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); port_delete(client, port); } @@ -500,8 +492,7 @@ int snd_seq_port_connect(struct snd_seq_ { struct snd_seq_port_subs_info *src = &src_port->c_src; struct snd_seq_port_subs_info *dest = &dest_port->c_dest; - struct snd_seq_subscribers *subs; - struct list_head *p; + struct snd_seq_subscribers *subs, *s; int err, src_called = 0; unsigned long flags; int exclusive; @@ -525,13 +516,11 @@ int snd_seq_port_connect(struct snd_seq_ if (src->exclusive || dest->exclusive) goto __error; /* check whether already exists */ - list_for_each(p, &src->list_head) { - struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list); + list_for_each_entry(s, &src->list_head, src_list) { if (match_subs_info(info, &s->info)) goto __error; } - list_for_each(p, &dest->list_head) { - struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list); + list_for_each_entry(s, &dest->list_head, dest_list) { if (match_subs_info(info, &s->info)) goto __error; } @@ -582,7 +571,6 @@ int snd_seq_port_disconnect(struct snd_s struct snd_seq_port_subs_info *src = &src_port->c_src; struct snd_seq_port_subs_info *dest = &dest_port->c_dest; struct snd_seq_subscribers *subs; - struct list_head *p; int err = -ENOENT; unsigned long flags; @@ -590,8 +578,7 @@ int snd_seq_port_disconnect(struct snd_s down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING); /* look for the connection */ - list_for_each(p, &src->list_head) { - subs = list_entry(p, struct snd_seq_subscribers, src_list); + list_for_each_entry(subs, &src->list_head, src_list) { if (match_subs_info(info, &subs->info)) { write_lock_irqsave(&src->list_lock, flags); // write_lock(&dest->list_lock); // no lock yet @@ -620,12 +607,10 @@ int snd_seq_port_disconnect(struct snd_s struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, struct snd_seq_addr *dest_addr) { - struct list_head *p; struct snd_seq_subscribers *s, *found = NULL; down_read(&src_grp->list_mutex); - list_for_each(p, &src_grp->list_head) { - s = list_entry(p, struct snd_seq_subscribers, src_list); + list_for_each_entry(s, &src_grp->list_head, src_list) { if (addr_match(dest_addr, &s->info.dest)) { found = s; break; diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 0cfa06c..972f934 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -81,13 +81,11 @@ static int snd_virmidi_dev_receive_event struct snd_seq_event *ev) { struct snd_virmidi *vmidi; - struct list_head *list; unsigned char msg[4]; int len; read_lock(&rdev->filelist_lock); - list_for_each(list, &rdev->filelist) { - vmidi = list_entry(list, struct snd_virmidi, list); + list_for_each_entry(vmidi, &rdev->filelist, list) { if (!vmidi->trigger) continue; if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { diff --git a/sound/core/sound.c b/sound/core/sound.c index 2827420..4084de0 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -219,26 +219,27 @@ static int snd_kernel_minor(int type, st #endif /** - * snd_register_device - Register the ALSA device file for the card + * snd_register_device_for_dev - Register the ALSA device file for the card * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index * @f_ops: the file operations * @private_data: user pointer for f_ops->open() * @name: the device file name + * @device: the &struct device to link this new device to * * Registers an ALSA device file for the given card. * The operators have to be set in reg parameter. * - * Retrurns zero if successful, or a negative error code on failure. + * Returns zero if successful, or a negative error code on failure. */ -int snd_register_device(int type, struct snd_card *card, int dev, - const struct file_operations *f_ops, void *private_data, - const char *name) +int snd_register_device_for_dev(int type, struct snd_card *card, int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name, struct device *device) { int minor; struct snd_minor *preg; - struct device *device = NULL; snd_assert(name, return -EINVAL); preg = kmalloc(sizeof *preg, GFP_KERNEL); @@ -263,8 +264,6 @@ #endif return minor; } snd_minors[minor] = preg; - if (card) - device = card->dev; preg->dev = device_create(sound_class, device, MKDEV(major, minor), "%s", name); if (preg->dev) @@ -274,7 +273,7 @@ #endif return 0; } -EXPORT_SYMBOL(snd_register_device); +EXPORT_SYMBOL(snd_register_device_for_dev); /* find the matching minor record * return the index of snd_minor, or -1 if not found diff --git a/sound/core/timer.c b/sound/core/timer.c index 10a79ae..4e79f9c 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -130,11 +130,8 @@ static struct snd_timer_instance *snd_ti static struct snd_timer *snd_timer_find(struct snd_timer_id *tid) { struct snd_timer *timer = NULL; - struct list_head *p; - - list_for_each(p, &snd_timer_list) { - timer = list_entry(p, struct snd_timer, device_list); + list_for_each_entry(timer, &snd_timer_list, device_list) { if (timer->tmr_class != tid->dev_class) continue; if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD || @@ -184,13 +181,10 @@ static void snd_timer_check_slave(struct { struct snd_timer *timer; struct snd_timer_instance *master; - struct list_head *p, *q; /* FIXME: it's really dumb to look up all entries.. */ - list_for_each(p, &snd_timer_list) { - timer = list_entry(p, struct snd_timer, device_list); - list_for_each(q, &timer->open_list_head) { - master = list_entry(q, struct snd_timer_instance, open_list); + list_for_each_entry(timer, &snd_timer_list, device_list) { + list_for_each_entry(master, &timer->open_list_head, open_list) { if (slave->slave_class == master->slave_class && slave->slave_id == master->slave_id) { list_del(&slave->open_list); @@ -214,16 +208,13 @@ static void snd_timer_check_slave(struct */ static void snd_timer_check_master(struct snd_timer_instance *master) { - struct snd_timer_instance *slave; - struct list_head *p, *n; + struct snd_timer_instance *slave, *tmp; /* check all pending slaves */ - list_for_each_safe(p, n, &snd_timer_slave_list) { - slave = list_entry(p, struct snd_timer_instance, open_list); + list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) { if (slave->slave_class == master->slave_class && slave->slave_id == master->slave_id) { - list_del(p); - list_add_tail(p, &master->slave_list_head); + list_move_tail(&slave->open_list, &master->slave_list_head); spin_lock_irq(&slave_active_lock); slave->master = master; slave->timer = master->timer; @@ -317,8 +308,7 @@ static int _snd_timer_stop(struct snd_ti int snd_timer_close(struct snd_timer_instance *timeri) { struct snd_timer *timer = NULL; - struct list_head *p, *n; - struct snd_timer_instance *slave; + struct snd_timer_instance *slave, *tmp; snd_assert(timeri != NULL, return -ENXIO); @@ -353,12 +343,11 @@ int snd_timer_close(struct snd_timer_ins timer->hw.close) timer->hw.close(timer); /* remove slave links */ - list_for_each_safe(p, n, &timeri->slave_list_head) { - slave = list_entry(p, struct snd_timer_instance, open_list); + list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head, + open_list) { spin_lock_irq(&slave_active_lock); _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION); - list_del(p); - list_add_tail(p, &snd_timer_slave_list); + list_move_tail(&slave->open_list, &snd_timer_slave_list); slave->master = NULL; slave->timer = NULL; spin_unlock_irq(&slave_active_lock); @@ -394,7 +383,6 @@ static void snd_timer_notify1(struct snd unsigned long flags; unsigned long resolution = 0; struct snd_timer_instance *ts; - struct list_head *n; struct timespec tstamp; getnstimeofday(&tstamp); @@ -413,11 +401,9 @@ static void snd_timer_notify1(struct snd if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) return; spin_lock_irqsave(&timer->lock, flags); - list_for_each(n, &ti->slave_active_head) { - ts = list_entry(n, struct snd_timer_instance, active_list); + list_for_each_entry(ts, &ti->slave_active_head, active_list) if (ts->ccallback) ts->ccallback(ti, event + 100, &tstamp, resolution); - } spin_unlock_irqrestore(&timer->lock, flags); } @@ -593,10 +579,8 @@ static void snd_timer_reschedule(struct { struct snd_timer_instance *ti; unsigned long ticks = ~0UL; - struct list_head *p; - list_for_each(p, &timer->active_list_head) { - ti = list_entry(p, struct snd_timer_instance, active_list); + list_for_each_entry(ti, &timer->active_list_head, active_list) { if (ti->flags & SNDRV_TIMER_IFLG_START) { ti->flags &= ~SNDRV_TIMER_IFLG_START; ti->flags |= SNDRV_TIMER_IFLG_RUNNING; @@ -661,9 +645,9 @@ static void snd_timer_tasklet(unsigned l */ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) { - struct snd_timer_instance *ti, *ts; + struct snd_timer_instance *ti, *ts, *tmp; unsigned long resolution, ticks; - struct list_head *p, *q, *n, *ack_list_head; + struct list_head *p, *ack_list_head; unsigned long flags; int use_tasklet = 0; @@ -679,12 +663,12 @@ void snd_timer_interrupt(struct snd_time resolution = timer->hw.resolution; /* loop for all active instances - * Here we cannot use list_for_each because the active_list of a + * Here we cannot use list_for_each_entry because the active_list of a * processed instance is relinked to done_list_head before the callback * is called. */ - list_for_each_safe(p, n, &timer->active_list_head) { - ti = list_entry(p, struct snd_timer_instance, active_list); + list_for_each_entry_safe(ti, tmp, &timer->active_list_head, + active_list) { if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING)) continue; ti->pticks += ticks_left; @@ -700,7 +684,7 @@ void snd_timer_interrupt(struct snd_time } else { ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING; if (--timer->running) - list_del(p); + list_del(&ti->active_list); } if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) || (ti->flags & SNDRV_TIMER_IFLG_FAST)) @@ -709,8 +693,7 @@ void snd_timer_interrupt(struct snd_time ack_list_head = &timer->sack_list_head; if (list_empty(&ti->ack_list)) list_add_tail(&ti->ack_list, ack_list_head); - list_for_each(q, &ti->slave_active_head) { - ts = list_entry(q, struct snd_timer_instance, active_list); + list_for_each_entry(ts, &ti->slave_active_head, active_list) { ts->pticks = ti->pticks; ts->resolution = resolution; if (list_empty(&ts->ack_list)) @@ -844,7 +827,6 @@ static int snd_timer_dev_register(struct { struct snd_timer *timer = dev->device_data; struct snd_timer *timer1; - struct list_head *p; snd_assert(timer != NULL && timer->hw.start != NULL && timer->hw.stop != NULL, return -ENXIO); @@ -853,8 +835,7 @@ static int snd_timer_dev_register(struct return -EINVAL; mutex_lock(®ister_mutex); - list_for_each(p, &snd_timer_list) { - timer1 = list_entry(p, struct snd_timer, device_list); + list_for_each_entry(timer1, &snd_timer_list, device_list) { if (timer1->tmr_class > timer->tmr_class) break; if (timer1->tmr_class < timer->tmr_class) @@ -877,7 +858,7 @@ static int snd_timer_dev_register(struct mutex_unlock(®ister_mutex); return -EBUSY; } - list_add_tail(&timer->device_list, p); + list_add_tail(&timer->device_list, &timer1->device_list); mutex_unlock(®ister_mutex); return 0; } @@ -896,7 +877,6 @@ void snd_timer_notify(struct snd_timer * unsigned long flags; unsigned long resolution = 0; struct snd_timer_instance *ti, *ts; - struct list_head *p, *n; if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) return; @@ -911,15 +891,12 @@ void snd_timer_notify(struct snd_timer * else resolution = timer->hw.resolution; } - list_for_each(p, &timer->active_list_head) { - ti = list_entry(p, struct snd_timer_instance, active_list); + list_for_each_entry(ti, &timer->active_list_head, active_list) { if (ti->ccallback) ti->ccallback(ti, event, tstamp, resolution); - list_for_each(n, &ti->slave_active_head) { - ts = list_entry(n, struct snd_timer_instance, active_list); + list_for_each_entry(ts, &ti->slave_active_head, active_list) if (ts->ccallback) ts->ccallback(ts, event, tstamp, resolution); - } } spin_unlock_irqrestore(&timer->lock, flags); } @@ -1057,11 +1034,9 @@ static void snd_timer_proc_read(struct s { struct snd_timer *timer; struct snd_timer_instance *ti; - struct list_head *p, *q; mutex_lock(®ister_mutex); - list_for_each(p, &snd_timer_list) { - timer = list_entry(p, struct snd_timer, device_list); + list_for_each_entry(timer, &snd_timer_list, device_list) { switch (timer->tmr_class) { case SNDRV_TIMER_CLASS_GLOBAL: snd_iprintf(buffer, "G%i: ", timer->tmr_device); @@ -1088,14 +1063,12 @@ static void snd_timer_proc_read(struct s if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) snd_iprintf(buffer, " SLAVE"); snd_iprintf(buffer, "\n"); - list_for_each(q, &timer->open_list_head) { - ti = list_entry(q, struct snd_timer_instance, open_list); + list_for_each_entry(ti, &timer->open_list_head, open_list) snd_iprintf(buffer, " Client %s : %s\n", ti->owner ? ti->owner : "unknown", ti->flags & (SNDRV_TIMER_IFLG_START | SNDRV_TIMER_IFLG_RUNNING) ? "running" : "stopped"); - } } mutex_unlock(®ister_mutex); } diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 74028b2..3a86a58 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -117,13 +117,13 @@ #define SERIAL_MODE_OUTPUT_OPEN (1 << 1 #define SERIAL_MODE_INPUT_TRIGGERED (1 << 2) #define SERIAL_MODE_OUTPUT_TRIGGERED (1 << 3) -typedef struct _snd_uart16550 { +struct snd_uart16550 { struct snd_card *card; struct snd_rawmidi *rmidi; struct snd_rawmidi_substream *midi_output[SNDRV_SERIAL_MAX_OUTS]; struct snd_rawmidi_substream *midi_input[SNDRV_SERIAL_MAX_INS]; - int filemode; //open status of file + int filemode; /* open status of file */ spinlock_t open_lock; @@ -140,39 +140,39 @@ typedef struct _snd_uart16550 { unsigned char old_divisor_msb; unsigned char old_line_ctrl_reg; - // parameter for using of write loop - short int fifo_limit; //used in uart16550 - short int fifo_count; //used in uart16550 + /* parameter for using of write loop */ + short int fifo_limit; /* used in uart16550 */ + short int fifo_count; /* used in uart16550 */ - // type of adaptor + /* type of adaptor */ int adaptor; - // inputs + /* inputs */ int prev_in; unsigned char rstatus; - // outputs + /* outputs */ int prev_out; unsigned char prev_status[SNDRV_SERIAL_MAX_OUTS]; - // write buffer and its writing/reading position + /* write buffer and its writing/reading position */ unsigned char tx_buff[TX_BUFF_SIZE]; int buff_in_count; int buff_in; int buff_out; int drop_on_full; - // wait timer + /* wait timer */ unsigned int timer_running:1; struct timer_list buffer_timer; -} snd_uart16550_t; +}; static struct platform_device *devices[SNDRV_CARDS]; -static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) +static inline void snd_uart16550_add_timer(struct snd_uart16550 *uart) { - if (! uart->timer_running) { + if (!uart->timer_running) { /* timer 38600bps * 10bit * 16byte */ uart->buffer_timer.expires = jiffies + (HZ+255)/256; uart->timer_running = 1; @@ -180,7 +180,7 @@ static inline void snd_uart16550_add_tim } } -static inline void snd_uart16550_del_timer(snd_uart16550_t *uart) +static inline void snd_uart16550_del_timer(struct snd_uart16550 *uart) { if (uart->timer_running) { del_timer(&uart->buffer_timer); @@ -189,10 +189,10 @@ static inline void snd_uart16550_del_tim } /* This macro is only used in snd_uart16550_io_loop */ -static inline void snd_uart16550_buffer_output(snd_uart16550_t *uart) +static inline void snd_uart16550_buffer_output(struct snd_uart16550 *uart) { unsigned short buff_out = uart->buff_out; - if( uart->buff_in_count > 0 ) { + if (uart->buff_in_count > 0) { outb(uart->tx_buff[buff_out], uart->base + UART_TX); uart->fifo_count++; buff_out++; @@ -206,7 +206,7 @@ static inline void snd_uart16550_buffer_ * We don't want to interrupt this, * as we're already handling an interrupt */ -static void snd_uart16550_io_loop(snd_uart16550_t * uart) +static void snd_uart16550_io_loop(struct snd_uart16550 * uart) { unsigned char c, status; int substream; @@ -220,9 +220,8 @@ static void snd_uart16550_io_loop(snd_ua c = inb(uart->base + UART_RX); /* keep track of last status byte */ - if (c & 0x80) { + if (c & 0x80) uart->rstatus = c; - } /* handle stream switch */ if (uart->adaptor == SNDRV_SERIAL_GENERIC) { @@ -230,14 +229,16 @@ static void snd_uart16550_io_loop(snd_ua if (c <= SNDRV_SERIAL_MAX_INS && c > 0) substream = c - 1; if (c != 0xf5) - uart->rstatus = 0; /* prevent future bytes from being interpreted as streams */ - } - else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) && (uart->midi_input[substream] != NULL)) { - snd_rawmidi_receive(uart->midi_input[substream], &c, 1); - } - } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) && (uart->midi_input[substream] != NULL)) { + /* prevent future bytes from being + interpreted as streams */ + uart->rstatus = 0; + } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) + && uart->midi_input[substream]) + snd_rawmidi_receive(uart->midi_input[substream], + &c, 1); + } else if ((uart->filemode & SERIAL_MODE_INPUT_OPEN) && + uart->midi_input[substream]) snd_rawmidi_receive(uart->midi_input[substream], &c, 1); - } if (status & UART_LSR_OE) snd_printk("%s: Overrun on device at 0x%lx\n", @@ -250,21 +251,20 @@ static void snd_uart16550_io_loop(snd_ua /* no need of check SERIAL_MODE_OUTPUT_OPEN because if not, buffer is never filled. */ /* Check write status */ - if (status & UART_LSR_THRE) { + if (status & UART_LSR_THRE) uart->fifo_count = 0; - } if (uart->adaptor == SNDRV_SERIAL_MS124W_SA || uart->adaptor == SNDRV_SERIAL_GENERIC) { /* Can't use FIFO, must send only when CTS is true */ status = inb(uart->base + UART_MSR); - while( (uart->fifo_count == 0) && (status & UART_MSR_CTS) && - (uart->buff_in_count > 0) ) { + while (uart->fifo_count == 0 && (status & UART_MSR_CTS) && + uart->buff_in_count > 0) { snd_uart16550_buffer_output(uart); - status = inb( uart->base + UART_MSR ); + status = inb(uart->base + UART_MSR); } } else { /* Write loop */ - while (uart->fifo_count < uart->fifo_limit /* Can we write ? */ + while (uart->fifo_count < uart->fifo_limit /* Can we write ? */ && uart->buff_in_count > 0) /* Do we want to? */ snd_uart16550_buffer_output(uart); } @@ -294,15 +294,16 @@ static void snd_uart16550_io_loop(snd_ua */ static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id) { - snd_uart16550_t *uart; + struct snd_uart16550 *uart; - uart = (snd_uart16550_t *) dev_id; + uart = dev_id; spin_lock(&uart->open_lock); if (uart->filemode == SERIAL_MODE_NOT_OPENED) { spin_unlock(&uart->open_lock); return IRQ_NONE; } - inb(uart->base + UART_IIR); /* indicate to the UART that the interrupt has been serviced */ + /* indicate to the UART that the interrupt has been serviced */ + inb(uart->base + UART_IIR); snd_uart16550_io_loop(uart); spin_unlock(&uart->open_lock); return IRQ_HANDLED; @@ -312,9 +313,9 @@ static irqreturn_t snd_uart16550_interru static void snd_uart16550_buffer_timer(unsigned long data) { unsigned long flags; - snd_uart16550_t *uart; + struct snd_uart16550 *uart; - uart = (snd_uart16550_t *)data; + uart = (struct snd_uart16550 *)data; spin_lock_irqsave(&uart->open_lock, flags); snd_uart16550_del_timer(uart); snd_uart16550_io_loop(uart); @@ -326,7 +327,7 @@ static void snd_uart16550_buffer_timer(u * return 0 if found * return negative error if not found */ -static int __init snd_uart16550_detect(snd_uart16550_t *uart) +static int __init snd_uart16550_detect(struct snd_uart16550 *uart) { unsigned long io_base = uart->base; int ok; @@ -343,7 +344,8 @@ static int __init snd_uart16550_detect(s return -EBUSY; } - ok = 1; /* uart detected unless one of the following tests should fail */ + /* uart detected unless one of the following tests should fail */ + ok = 1; /* 8 data-bits, 1 stop-bit, parity off, DLAB = 0 */ outb(UART_LCR_WLEN8, io_base + UART_LCR); /* Line Control Register */ c = inb(io_base + UART_IER); @@ -368,7 +370,7 @@ static int __init snd_uart16550_detect(s return ok; } -static void snd_uart16550_do_open(snd_uart16550_t * uart) +static void snd_uart16550_do_open(struct snd_uart16550 * uart) { char byte; @@ -460,7 +462,7 @@ static void snd_uart16550_do_open(snd_ua inb(uart->base + UART_RX); /* Clear any pre-existing receive interrupt */ } -static void snd_uart16550_do_close(snd_uart16550_t * uart) +static void snd_uart16550_do_close(struct snd_uart16550 * uart) { if (uart->irq < 0) snd_uart16550_del_timer(uart); @@ -514,7 +516,7 @@ static void snd_uart16550_do_close(snd_u static int snd_uart16550_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); if (uart->filemode == SERIAL_MODE_NOT_OPENED) @@ -528,7 +530,7 @@ static int snd_uart16550_input_open(stru static int snd_uart16550_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); uart->filemode &= ~SERIAL_MODE_INPUT_OPEN; @@ -539,24 +541,24 @@ static int snd_uart16550_input_close(str return 0; } -static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream, int up) +static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream, + int up) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); - if (up) { + if (up) uart->filemode |= SERIAL_MODE_INPUT_TRIGGERED; - } else { + else uart->filemode &= ~SERIAL_MODE_INPUT_TRIGGERED; - } spin_unlock_irqrestore(&uart->open_lock, flags); } static int snd_uart16550_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); if (uart->filemode == SERIAL_MODE_NOT_OPENED) @@ -570,7 +572,7 @@ static int snd_uart16550_output_open(str static int snd_uart16550_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); uart->filemode &= ~SERIAL_MODE_OUTPUT_OPEN; @@ -581,18 +583,20 @@ static int snd_uart16550_output_close(st return 0; }; -static inline int snd_uart16550_buffer_can_write( snd_uart16550_t *uart, int Num ) +static inline int snd_uart16550_buffer_can_write(struct snd_uart16550 *uart, + int Num) { - if( uart->buff_in_count + Num < TX_BUFF_SIZE ) + if (uart->buff_in_count + Num < TX_BUFF_SIZE) return 1; else return 0; } -static inline int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned char byte) +static inline int snd_uart16550_write_buffer(struct snd_uart16550 *uart, + unsigned char byte) { unsigned short buff_in = uart->buff_in; - if( uart->buff_in_count < TX_BUFF_SIZE ) { + if (uart->buff_in_count < TX_BUFF_SIZE) { uart->tx_buff[buff_in] = byte; buff_in++; buff_in &= TX_BUFF_MASK; @@ -605,12 +609,14 @@ static inline int snd_uart16550_write_bu return 0; } -static int snd_uart16550_output_byte(snd_uart16550_t *uart, struct snd_rawmidi_substream *substream, unsigned char midi_byte) +static int snd_uart16550_output_byte(struct snd_uart16550 *uart, + struct snd_rawmidi_substream *substream, + unsigned char midi_byte) { - if (uart->buff_in_count == 0 /* Buffer empty? */ + if (uart->buff_in_count == 0 /* Buffer empty? */ && ((uart->adaptor != SNDRV_SERIAL_MS124W_SA && uart->adaptor != SNDRV_SERIAL_GENERIC) || - (uart->fifo_count == 0 /* FIFO empty? */ + (uart->fifo_count == 0 /* FIFO empty? */ && (inb(uart->base + UART_MSR) & UART_MSR_CTS)))) { /* CTS? */ /* Tx Buffer Empty - try to write immediately */ @@ -623,12 +629,13 @@ static int snd_uart16550_output_byte(snd uart->fifo_count++; outb(midi_byte, uart->base + UART_TX); } else { - /* Cannot write (buffer empty) - put char in buffer */ + /* Cannot write (buffer empty) - + * put char in buffer */ snd_uart16550_write_buffer(uart, midi_byte); } } } else { - if( !snd_uart16550_write_buffer(uart, midi_byte) ) { + if (!snd_uart16550_write_buffer(uart, midi_byte)) { snd_printk("%s: Buffer overrun on device at 0x%lx\n", uart->rmidi->name, uart->base); return 0; @@ -642,9 +649,9 @@ static void snd_uart16550_output_write(s { unsigned long flags; unsigned char midi_byte, addr_byte; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; char first; - static unsigned long lasttime=0; + static unsigned long lasttime = 0; /* Interupts are disabled during the updating of the tx_buff, * since it is 'bad' to have two processes updating the same @@ -653,7 +660,7 @@ static void snd_uart16550_output_write(s spin_lock_irqsave(&uart->open_lock, flags); - if (uart->irq < 0) //polling + if (uart->irq < 0) /* polling */ snd_uart16550_io_loop(uart); if (uart->adaptor == SNDRV_SERIAL_MS124W_MB) { @@ -671,7 +678,8 @@ #else /* select any combination of the four ports */ addr_byte = (substream->number << 4) | 0x08; /* ...except none */ - if (addr_byte == 0x08) addr_byte = 0xf8; + if (addr_byte == 0x08) + addr_byte = 0xf8; #endif snd_uart16550_output_byte(uart, substream, addr_byte); /* send midi byte */ @@ -679,31 +687,42 @@ #endif } } else { first = 0; - while( 1 == snd_rawmidi_transmit_peek(substream, &midi_byte, 1) ) { - /* Also send F5 after 3 seconds with no data to handle device disconnect */ - if (first == 0 && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS || - uart->adaptor == SNDRV_SERIAL_GENERIC) && - (uart->prev_out != substream->number || jiffies-lasttime > 3*HZ)) { - - if( snd_uart16550_buffer_can_write( uart, 3 ) ) { + while (snd_rawmidi_transmit_peek(substream, &midi_byte, 1) == 1) { + /* Also send F5 after 3 seconds with no data + * to handle device disconnect */ + if (first == 0 && + (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS || + uart->adaptor == SNDRV_SERIAL_GENERIC) && + (uart->prev_out != substream->number || + jiffies-lasttime > 3*HZ)) { + + if (snd_uart16550_buffer_can_write(uart, 3)) { /* Roland Soundcanvas part selection */ - /* If this substream of the data is different previous - substream in this uart, send the change part event */ + /* If this substream of the data is + * different previous substream + * in this uart, send the change part + * event + */ uart->prev_out = substream->number; /* change part */ - snd_uart16550_output_byte(uart, substream, 0xf5); + snd_uart16550_output_byte(uart, substream, + 0xf5); /* data */ - snd_uart16550_output_byte(uart, substream, uart->prev_out + 1); - /* If midi_byte is a data byte, send the previous status byte */ - if ((midi_byte < 0x80) && (uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS)) + snd_uart16550_output_byte(uart, substream, + uart->prev_out + 1); + /* If midi_byte is a data byte, + * send the previous status byte */ + if (midi_byte < 0x80 && + uart->adaptor == SNDRV_SERIAL_SOUNDCANVAS) snd_uart16550_output_byte(uart, substream, uart->prev_status[uart->prev_out]); - } else if( !uart->drop_on_full ) + } else if (!uart->drop_on_full) break; } /* send midi byte */ - if( !snd_uart16550_output_byte(uart, substream, midi_byte) && !uart->drop_on_full ) + if (!snd_uart16550_output_byte(uart, substream, midi_byte) && + !uart->drop_on_full ) break; if (midi_byte >= 0x80 && midi_byte < 0xf0) @@ -717,17 +736,17 @@ #endif spin_unlock_irqrestore(&uart->open_lock, flags); } -static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream, int up) +static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream, + int up) { unsigned long flags; - snd_uart16550_t *uart = substream->rmidi->private_data; + struct snd_uart16550 *uart = substream->rmidi->private_data; spin_lock_irqsave(&uart->open_lock, flags); - if (up) { + if (up) uart->filemode |= SERIAL_MODE_OUTPUT_TRIGGERED; - } else { + else uart->filemode &= ~SERIAL_MODE_OUTPUT_TRIGGERED; - } spin_unlock_irqrestore(&uart->open_lock, flags); if (up) snd_uart16550_output_write(substream); @@ -747,10 +766,10 @@ static struct snd_rawmidi_ops snd_uart16 .trigger = snd_uart16550_input_trigger, }; -static int snd_uart16550_free(snd_uart16550_t *uart) +static int snd_uart16550_free(struct snd_uart16550 *uart) { if (uart->irq >= 0) - free_irq(uart->irq, (void *)uart); + free_irq(uart->irq, uart); release_and_free_resource(uart->res_base); kfree(uart); return 0; @@ -758,7 +777,7 @@ static int snd_uart16550_free(snd_uart16 static int snd_uart16550_dev_free(struct snd_device *device) { - snd_uart16550_t *uart = device->device_data; + struct snd_uart16550 *uart = device->device_data; return snd_uart16550_free(uart); } @@ -769,12 +788,12 @@ static int __init snd_uart16550_create(s unsigned int base, int adaptor, int droponfull, - snd_uart16550_t **ruart) + struct snd_uart16550 **ruart) { static struct snd_device_ops ops = { .dev_free = snd_uart16550_dev_free, }; - snd_uart16550_t *uart; + struct snd_uart16550 *uart; int err; @@ -795,7 +814,7 @@ static int __init snd_uart16550_create(s if (irq >= 0 && irq != SNDRV_AUTO_IRQ) { if (request_irq(irq, snd_uart16550_interrupt, - IRQF_DISABLED, "Serial MIDI", (void *) uart)) { + IRQF_DISABLED, "Serial MIDI", uart)) { snd_printk("irq %d busy. Using Polling.\n", irq); } else { uart->irq = irq; @@ -843,23 +862,28 @@ static int __init snd_uart16550_create(s static void __init snd_uart16550_substreams(struct snd_rawmidi_str *stream) { - struct list_head *list; + struct snd_rawmidi_substream *substream; - list_for_each(list, &stream->substreams) { - struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list); + list_for_each_entry(substream, &stream->substreams, list) { sprintf(substream->name, "Serial MIDI %d", substream->number + 1); } } -static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int outs, int ins, struct snd_rawmidi **rmidi) +static int __init snd_uart16550_rmidi(struct snd_uart16550 *uart, int device, + int outs, int ins, + struct snd_rawmidi **rmidi) { struct snd_rawmidi *rrawmidi; int err; - if ((err = snd_rawmidi_new(uart->card, "UART Serial MIDI", device, outs, ins, &rrawmidi)) < 0) + err = snd_rawmidi_new(uart->card, "UART Serial MIDI", device, + outs, ins, &rrawmidi); + if (err < 0) return err; - snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_uart16550_input); - snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_uart16550_output); + snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_INPUT, + &snd_uart16550_input); + snd_rawmidi_set_ops(rrawmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, + &snd_uart16550_output); strcpy(rrawmidi->name, "Serial MIDI"); snd_uart16550_substreams(&rrawmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]); snd_uart16550_substreams(&rrawmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); @@ -875,7 +899,7 @@ static int __init snd_uart16550_rmidi(sn static int __init snd_serial_probe(struct platform_device *devptr) { struct snd_card *card; - snd_uart16550_t *uart; + struct snd_uart16550 *uart; int err; int dev = devptr->id; @@ -929,7 +953,8 @@ static int __init snd_serial_probe(struc &uart)) < 0) goto _err; - if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0) + err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi); + if (err < 0) goto _err; sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d", diff --git a/sound/i2c/Makefile b/sound/i2c/Makefile index 816a2e7..45902d4 100644 --- a/sound/i2c/Makefile +++ b/sound/i2c/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_SND) += other/ # Toplevel Module Dependency obj-$(CONFIG_SND_INTERWAVE_STB) += snd-tea6330t.o snd-i2c.o obj-$(CONFIG_SND_ICE1712) += snd-cs8427.o snd-i2c.o +obj-$(CONFIG_SND_ICE1724) += snd-i2c.o diff --git a/sound/i2c/other/Makefile b/sound/i2c/other/Makefile index 2fe023e..77a8a7c 100644 --- a/sound/i2c/other/Makefile +++ b/sound/i2c/other/Makefile @@ -6,11 +6,11 @@ # snd-ak4114-objs := ak4114.o snd-ak4117-objs := ak4117.o snd-ak4xxx-adda-objs := ak4xxx-adda.o +snd-pt2258-objs := pt2258.o snd-tea575x-tuner-objs := tea575x-tuner.o # Module Dependency obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o -obj-$(CONFIG_SND_ICE1724) += snd-ak4xxx-adda.o -obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o +obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4xxx-adda.o snd-pt2258.o obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index d2f2c50..69dcaf8 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -66,10 +66,7 @@ static void snd_ak4114_free(struct ak411 { chip->init = 1; /* don't schedule new work */ mb(); - if (chip->workqueue != NULL) { - flush_workqueue(chip->workqueue); - destroy_workqueue(chip->workqueue); - } + flush_scheduled_work(); kfree(chip); } @@ -106,12 +103,6 @@ int snd_ak4114_create(struct snd_card *c for (reg = 0; reg < 5; reg++) chip->txcsb[reg] = txcsb[reg]; - chip->workqueue = create_workqueue("snd-ak4114"); - if (chip->workqueue == NULL) { - kfree(chip); - return -ENOMEM; - } - snd_ak4114_reinit(chip); chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT); @@ -143,7 +134,7 @@ void snd_ak4114_reinit(struct ak4114 *ch chip->init = 1; mb(); - flush_workqueue(chip->workqueue); + flush_scheduled_work(); /* bring the chip to reset state and powerdown state */ reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN)); udelay(200); @@ -159,7 +150,7 @@ void snd_ak4114_reinit(struct ak4114 *ch /* bring up statistics / event queing */ chip->init = 0; INIT_DELAYED_WORK(&chip->work, ak4114_stats); - queue_delayed_work(chip->workqueue, &chip->work, HZ / 10); + schedule_delayed_work(&chip->work, HZ / 10); } static unsigned int external_rate(unsigned char rcs1) @@ -568,7 +559,7 @@ static void ak4114_stats(struct work_str if (chip->init) return; snd_ak4114_check_rate_and_errors(chip, 0); - queue_delayed_work(chip->workqueue, &chip->work, HZ / 10); + schedule_delayed_work(&chip->work, HZ / 10); } EXPORT_SYMBOL(snd_ak4114_create); diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index 5da49e2..fe61b92 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -513,6 +513,66 @@ static int ak4xxx_switch_put(struct snd_ return change; } +#define AK5365_NUM_INPUTS 5 + +static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); + int mixer_ch = AK_GET_SHIFT(kcontrol->private_value); + const char **input_names; + int num_names, idx; + + input_names = ak->adc_info[mixer_ch].input_names; + + num_names = 0; + while (num_names < AK5365_NUM_INPUTS && input_names[num_names]) + ++num_names; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = num_names; + idx = uinfo->value.enumerated.item; + if (idx >= num_names) + return -EINVAL; + strncpy(uinfo->value.enumerated.name, input_names[idx], + sizeof(uinfo->value.enumerated.name)); + return 0; +} + +static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); + int chip = AK_GET_CHIP(kcontrol->private_value); + int addr = AK_GET_ADDR(kcontrol->private_value); + int mask = AK_GET_MASK(kcontrol->private_value); + unsigned char val; + + val = snd_akm4xxx_get(ak, chip, addr) & mask; + ucontrol->value.enumerated.item[0] = val; + return 0; +} + +static int ak4xxx_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); + int chip = AK_GET_CHIP(kcontrol->private_value); + int addr = AK_GET_ADDR(kcontrol->private_value); + int mask = AK_GET_MASK(kcontrol->private_value); + unsigned char oval, val; + + oval = snd_akm4xxx_get(ak, chip, addr); + val = oval & ~mask; + val |= ucontrol->value.enumerated.item[0] & mask; + if (val != oval) { + snd_akm4xxx_write(ak, chip, addr, val); + return 1; + } + return 0; +} + /* * build AK4xxx controls */ @@ -647,9 +707,10 @@ static int build_adc_controls(struct snd if (ak->type == SND_AK5365 && (idx % 2) == 0) { if (! ak->adc_info || - ! ak->adc_info[mixer_ch].switch_name) + ! ak->adc_info[mixer_ch].switch_name) { knew.name = "Capture Switch"; - else + knew.index = mixer_ch + ak->idx_offset * 2; + } else knew.name = ak->adc_info[mixer_ch].switch_name; knew.info = ak4xxx_switch_info; knew.get = ak4xxx_switch_get; @@ -662,6 +723,26 @@ static int build_adc_controls(struct snd err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak)); if (err < 0) return err; + + memset(&knew, 0, sizeof(knew)); + knew.name = ak->adc_info[mixer_ch].selector_name; + if (!knew.name) { + knew.name = "Capture Channel"; + knew.index = mixer_ch + ak->idx_offset * 2; + } + + knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew.info = ak4xxx_capture_source_info; + knew.get = ak4xxx_capture_source_get; + knew.put = ak4xxx_capture_source_put; + knew.access = 0; + /* input selector control: reg. 1, bits 0-2. + * mis-use 'shift' to pass mixer_ch */ + knew.private_value + = AK_COMPOSE(idx/2, 1, mixer_ch, 0x07); + err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak)); + if (err < 0) + return err; } idx += num_stereo; diff --git a/sound/i2c/other/pt2258.c b/sound/i2c/other/pt2258.c new file mode 100644 index 0000000..50df1df --- /dev/null +++ b/sound/i2c/other/pt2258.c @@ -0,0 +1,233 @@ +/* + * ALSA Driver for the PT2258 volume controller. + * + * Copyright (c) 2006 Jochen Voss + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Jochen Voss "); +MODULE_DESCRIPTION("PT2258 volume controller (Princeton Technology Corp.)"); +MODULE_LICENSE("GPL"); + +#define PT2258_CMD_RESET 0xc0 +#define PT2258_CMD_UNMUTE 0xf8 +#define PT2258_CMD_MUTE 0xf9 + +static const unsigned char pt2258_channel_code[12] = { + 0x80, 0x90, /* channel 1: -10dB, -1dB */ + 0x40, 0x50, /* channel 2: -10dB, -1dB */ + 0x00, 0x10, /* channel 3: -10dB, -1dB */ + 0x20, 0x30, /* channel 4: -10dB, -1dB */ + 0x60, 0x70, /* channel 5: -10dB, -1dB */ + 0xa0, 0xb0 /* channel 6: -10dB, -1dB */ +}; + +int snd_pt2258_reset(struct snd_pt2258 *pt) +{ + unsigned char bytes[2]; + int i; + + /* reset chip */ + bytes[0] = PT2258_CMD_RESET; + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + /* mute all channels */ + pt->mute = 1; + bytes[0] = PT2258_CMD_MUTE; + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + /* set all channels to 0dB */ + for (i = 0; i < 6; ++i) + pt->volume[i] = 0; + bytes[0] = 0xd0; + bytes[1] = 0xe0; + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + return 0; + + __error: + snd_i2c_unlock(pt->i2c_bus); + snd_printk(KERN_ERR "PT2258 reset failed\n"); + return -EIO; +} + +static int pt2258_stereo_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 79; + return 0; +} + +static int pt2258_stereo_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pt2258 *pt = kcontrol->private_data; + int base = kcontrol->private_value; + + /* chip does not support register reads */ + ucontrol->value.integer.value[0] = 79 - pt->volume[base]; + ucontrol->value.integer.value[1] = 79 - pt->volume[base + 1]; + return 0; +} + +static int pt2258_stereo_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pt2258 *pt = kcontrol->private_data; + int base = kcontrol->private_value; + unsigned char bytes[2]; + int val0, val1; + + val0 = 79 - ucontrol->value.integer.value[0]; + val1 = 79 - ucontrol->value.integer.value[1]; + if (val0 == pt->volume[base] && val1 == pt->volume[base + 1]) + return 0; + + pt->volume[base] = val0; + bytes[0] = pt2258_channel_code[2 * base] | (val0 / 10); + bytes[1] = pt2258_channel_code[2 * base + 1] | (val0 % 10); + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + pt->volume[base + 1] = val1; + bytes[0] = pt2258_channel_code[2 * base + 2] | (val1 / 10); + bytes[1] = pt2258_channel_code[2 * base + 3] | (val1 % 10); + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 2) != 2) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + return 1; + + __error: + snd_i2c_unlock(pt->i2c_bus); + snd_printk(KERN_ERR "PT2258 access failed\n"); + return -EIO; +} + +static int pt2258_switch_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int pt2258_switch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pt2258 *pt = kcontrol->private_data; + + ucontrol->value.integer.value[0] = !pt->mute; + return 0; +} + +static int pt2258_switch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pt2258 *pt = kcontrol->private_data; + unsigned char bytes[2]; + int val; + + val = !ucontrol->value.integer.value[0]; + if (pt->mute == val) + return 0; + + pt->mute = val; + bytes[0] = val ? PT2258_CMD_MUTE : PT2258_CMD_UNMUTE; + snd_i2c_lock(pt->i2c_bus); + if (snd_i2c_sendbytes(pt->i2c_dev, bytes, 1) != 1) + goto __error; + snd_i2c_unlock(pt->i2c_bus); + + return 1; + + __error: + snd_i2c_unlock(pt->i2c_bus); + snd_printk(KERN_ERR "PT2258 access failed 2\n"); + return -EIO; +} + +static DECLARE_TLV_DB_SCALE(pt2258_db_scale, -7900, 100, 0); + +int snd_pt2258_build_controls(struct snd_pt2258 *pt) +{ + struct snd_kcontrol_new knew; + char *names[3] = { + "Mic Loopback Playback Volume", + "Line Loopback Playback Volume", + "CD Loopback Playback Volume" + }; + int i, err; + + for (i = 0; i < 3; ++i) { + memset(&knew, 0, sizeof(knew)); + knew.name = names[i]; + knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew.count = 1; + knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ; + knew.private_value = 2 * i; + knew.info = pt2258_stereo_volume_info; + knew.get = pt2258_stereo_volume_get; + knew.put = pt2258_stereo_volume_put; + knew.tlv.p = pt2258_db_scale; + + err = snd_ctl_add(pt->card, snd_ctl_new1(&knew, pt)); + if (err < 0) + return err; + } + + memset(&knew, 0, sizeof(knew)); + knew.name = "Loopback Switch"; + knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew.info = pt2258_switch_info; + knew.get = pt2258_switch_get; + knew.put = pt2258_switch_put; + knew.access = 0; + err = snd_ctl_add(pt->card, snd_ctl_new1(&knew, pt)); + if (err < 0) + return err; + + return 0; +} + +EXPORT_SYMBOL(snd_pt2258_reset); +EXPORT_SYMBOL(snd_pt2258_build_controls); diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 57371f1..4e3a972 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -358,6 +358,7 @@ config SND_SBAWE config SND_SB16_CSP bool "Sound Blaster 16/AWE CSP support" depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC) + select FW_LOADER help Say Y here to include support for the CSP core. This special coprocessor can do variable tasks like various compression and @@ -390,6 +391,7 @@ config SND_SSCAPE config SND_WAVEFRONT tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" depends on SND + select FW_LOADER select SND_OPL3_LIB select SND_MPU401_UART select SND_CS4231_LIB diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index fcd6380..3d9d7e0 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -161,10 +161,13 @@ int snd_sb_csp_new(struct snd_sb *chip, */ static void snd_sb_csp_free(struct snd_hwdep *hwdep) { + int i; struct snd_sb_csp *p = hwdep->private_data; if (p) { if (p->running & SNDRV_SB_CSP_ST_RUNNING) snd_sb_csp_stop(p); + for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i) + release_firmware(p->csp_programs[i]); kfree(p); } } @@ -687,8 +690,50 @@ static int snd_sb_csp_load_user(struct s return err; } +#define FIRMWARE_IN_THE_KERNEL + +#ifdef FIRMWARE_IN_THE_KERNEL #include "sb16_csp_codecs.h" +static const struct firmware snd_sb_csp_static_programs[] = { + { .data = mulaw_main, .size = sizeof mulaw_main }, + { .data = alaw_main, .size = sizeof alaw_main }, + { .data = ima_adpcm_init, .size = sizeof ima_adpcm_init }, + { .data = ima_adpcm_playback, .size = sizeof ima_adpcm_playback }, + { .data = ima_adpcm_capture, .size = sizeof ima_adpcm_capture }, +}; +#endif + +static int snd_sb_csp_firmware_load(struct snd_sb_csp *p, int index, int flags) +{ + static const char *const names[] = { + "sb16/mulaw_main.csp", + "sb16/alaw_main.csp", + "sb16/ima_adpcm_init.csp", + "sb16/ima_adpcm_playback.csp", + "sb16/ima_adpcm_capture.csp", + }; + const struct firmware *program; + int err; + + BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT); + program = p->csp_programs[index]; + if (!program) { + err = request_firmware(&program, names[index], + p->chip->card->dev); + if (err >= 0) + p->csp_programs[index] = program; + else { +#ifdef FIRMWARE_IN_THE_KERNEL + program = &snd_sb_csp_static_programs[index]; +#else + return err; +#endif + } + } + return snd_sb_csp_load(p, program->data, program->size, flags); +} + /* * autoload hardware codec if necessary * return 0 if CSP is loaded and ready to run (p->running != 0) @@ -708,27 +753,27 @@ static int snd_sb_csp_autoload(struct sn } else { switch (pcm_sfmt) { case SNDRV_PCM_FORMAT_MU_LAW: - err = snd_sb_csp_load(p, &mulaw_main[0], sizeof(mulaw_main), 0); + err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_MULAW, 0); p->acc_format = SNDRV_PCM_FMTBIT_MU_LAW; p->mode = SNDRV_SB_CSP_MODE_DSP_READ | SNDRV_SB_CSP_MODE_DSP_WRITE; break; case SNDRV_PCM_FORMAT_A_LAW: - err = snd_sb_csp_load(p, &alaw_main[0], sizeof(alaw_main), 0); + err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_ALAW, 0); p->acc_format = SNDRV_PCM_FMTBIT_A_LAW; p->mode = SNDRV_SB_CSP_MODE_DSP_READ | SNDRV_SB_CSP_MODE_DSP_WRITE; break; case SNDRV_PCM_FORMAT_IMA_ADPCM: - err = snd_sb_csp_load(p, &ima_adpcm_init[0], sizeof(ima_adpcm_init), - SNDRV_SB_CSP_LOAD_INITBLOCK); + err = snd_sb_csp_firmware_load(p, CSP_PROGRAM_ADPCM_INIT, + SNDRV_SB_CSP_LOAD_INITBLOCK); if (err) break; if (play_rec_mode == SNDRV_SB_CSP_MODE_DSP_WRITE) { - err = snd_sb_csp_load(p, &ima_adpcm_playback[0], - sizeof(ima_adpcm_playback), 0); + err = snd_sb_csp_firmware_load + (p, CSP_PROGRAM_ADPCM_PLAYBACK, 0); p->mode = SNDRV_SB_CSP_MODE_DSP_WRITE; } else { - err = snd_sb_csp_load(p, &ima_adpcm_capture[0], - sizeof(ima_adpcm_capture), 0); + err = snd_sb_csp_firmware_load + (p, CSP_PROGRAM_ADPCM_CAPTURE, 0); p->mode = SNDRV_SB_CSP_MODE_DSP_READ; } p->acc_format = SNDRV_PCM_FMTBIT_IMA_ADPCM; diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 85db535..e2fdd5f 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -402,6 +402,7 @@ static struct snd_card *snd_wavefront_ca init_waitqueue_head(&acard->wavefront.interrupt_sleeper); spin_lock_init(&acard->wavefront.midi.open); spin_lock_init(&acard->wavefront.midi.virtual); + acard->wavefront.card = card; card->private_free = snd_wavefront_free; return card; diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 4f0846f..15331ed 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -21,6 +21,7 @@ #include #include #include #include +#include #include #include #include @@ -32,325 +33,17 @@ #define FX_LSB_TRANSFER 0x01 /* trans #define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */ #define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */ -/* weird stuff, derived from port I/O tracing with dosemu */ - -static unsigned char page_zero[] __devinitdata = { -0x01, 0x7c, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0x00, -0x11, 0x00, 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x13, 0x00, 0x00, -0x00, 0x14, 0x02, 0x76, 0x00, 0x60, 0x00, 0x80, 0x02, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x19, -0x01, 0x1a, 0x01, 0x20, 0x01, 0x40, 0x01, 0x17, 0x00, 0x00, 0x01, -0x80, 0x01, 0x20, 0x00, 0x10, 0x01, 0xa0, 0x03, 0xd1, 0x00, 0x00, -0x01, 0xf2, 0x02, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf4, 0x02, -0xe0, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, -0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x00, 0x00, 0x00, -0x40, 0x00, 0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, -0x00, 0x92, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xb3, 0x02, -0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x40, -0x00, 0x80, 0x00, 0xf5, 0x00, 0x20, 0x00, 0x70, 0x00, 0xa0, 0x02, -0x11, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, -0x02, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x17, 0x00, 0x1b, 0x00, -0x1d, 0x02, 0xdf -}; - -static unsigned char page_one[] __devinitdata = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x19, 0x00, -0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xd8, 0x00, 0x00, -0x02, 0x20, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, -0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x60, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x80, 0x00, -0x00, 0x02, 0xfb, 0x02, 0xa0, 0x00, 0x00, 0x00, 0x1b, 0x02, 0xd7, -0x00, 0x00, 0x02, 0xf7, 0x03, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, -0x1c, 0x03, 0x3c, 0x00, 0x00, 0x03, 0x3f, 0x00, 0x00, 0x03, 0xc0, -0x00, 0x00, 0x03, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x03, 0x5d, 0x00, -0x00, 0x03, 0xc0, 0x00, 0x00, 0x03, 0x7d, 0x00, 0x00, 0x03, 0xc0, -0x00, 0x00, 0x03, 0x9e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x03, -0xbe, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, -0xdb, 0x00, 0x00, 0x02, 0xdb, 0x00, 0x00, 0x02, 0xe0, 0x00, 0x00, -0x02, 0xfb, 0x00, 0x00, 0x02, 0xc0, 0x02, 0x40, 0x02, 0xfb, 0x02, -0x60, 0x00, 0x1b -}; - -static unsigned char page_two[] __devinitdata = { -0xc4, 0x00, 0x44, 0x07, 0x44, 0x00, 0x40, 0x25, 0x01, 0x06, 0xc4, -0x07, 0x40, 0x25, 0x01, 0x00, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x07, -0x05, 0x05, 0x05, 0x04, 0x07, 0x05, 0x04, 0x07, 0x05, 0x44, 0x46, -0x44, 0x46, 0x46, 0x07, 0x05, 0x44, 0x46, 0x05, 0x46, 0x05, 0x46, -0x05, 0x46, 0x05, 0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07, -0x44, 0x46, 0x05, 0x07, 0x44, 0x46, 0x05, 0x07, 0x44, 0x05, 0x05, -0x05, 0x44, 0x05, 0x05, 0x05, 0x46, 0x05, 0x46, 0x05, 0x46, 0x05, -0x46, 0x05, 0x46, 0x07, 0x46, 0x07, 0x44 -}; - -static unsigned char page_three[] __devinitdata = { -0x07, 0x40, 0x00, 0x00, 0x00, 0x47, 0x00, 0x40, 0x00, 0x40, 0x06, -0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, -0xc0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, -0x60, 0x00, 0x70, 0x00, 0x40, 0x00, 0x40, 0x00, 0x42, 0x00, 0x40, -0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, -0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, -0x00, 0x42, 0x00, 0x40, 0x00, 0x42, 0x00, 0x02, 0x00, 0x02, 0x00, -0x02, 0x00, 0x42, 0x00, 0xc0, 0x00, 0x40 -}; - -static unsigned char page_four[] __devinitdata = { -0x63, 0x03, 0x26, 0x02, 0x2c, 0x00, 0x24, 0x00, 0x2e, 0x02, 0x02, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, -0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x60, 0x00, -0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, -0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, 0x60, 0x00, 0x20, 0x00, -0x20, 0x00, 0x22, 0x02, 0x22, 0x02, 0x20, 0x00, 0x60, 0x00, 0x22, -0x02, 0x62, 0x02, 0x20, 0x01, 0x21, 0x01 -}; - -static unsigned char page_six[] __devinitdata = { -0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00, -0x00, 0x08, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x0e, -0x00, 0x00, 0x10, 0x00, 0x00, 0x12, 0x00, 0x00, 0x14, 0x00, 0x00, -0x16, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x1c, 0x00, -0x00, 0x1e, 0x00, 0x00, 0x20, 0x00, 0x00, 0x22, 0x00, 0x00, 0x24, -0x00, 0x00, 0x26, 0x00, 0x00, 0x28, 0x00, 0x00, 0x2a, 0x00, 0x00, -0x2c, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x30, 0x00, 0x00, 0x32, 0x00, -0x00, 0x34, 0x00, 0x00, 0x36, 0x00, 0x00, 0x38, 0x00, 0x00, 0x3a, -0x00, 0x00, 0x3c, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x40, 0x00, 0x00, -0x42, 0x03, 0x00, 0x44, 0x01, 0x00, 0x46, 0x0a, 0x21, 0x48, 0x0d, -0x23, 0x4a, 0x23, 0x1b, 0x4c, 0x37, 0x8f, 0x4e, 0x45, 0x77, 0x50, -0x52, 0xe2, 0x52, 0x1c, 0x92, 0x54, 0x1c, 0x52, 0x56, 0x07, 0x00, -0x58, 0x2f, 0xc6, 0x5a, 0x0b, 0x00, 0x5c, 0x30, 0x06, 0x5e, 0x17, -0x00, 0x60, 0x3d, 0xda, 0x62, 0x29, 0x00, 0x64, 0x3e, 0x41, 0x66, -0x39, 0x00, 0x68, 0x4c, 0x48, 0x6a, 0x49, 0x00, 0x6c, 0x4c, 0x6c, -0x6e, 0x11, 0xd2, 0x70, 0x16, 0x0c, 0x72, 0x00, 0x00, 0x74, 0x00, -0x80, 0x76, 0x0f, 0x00, 0x78, 0x00, 0x80, 0x7a, 0x13, 0x00, 0x7c, -0x80, 0x00, 0x7e, 0x80, 0x80 -}; - -static unsigned char page_seven[] __devinitdata = { -0x0f, 0xff, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, -0x08, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, -0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x0f, 0xff, -0x0f, 0xff, 0x0f, 0xff, 0x02, 0xe9, 0x06, 0x8c, 0x06, 0x8c, 0x0f, -0xff, 0x1a, 0x75, 0x0d, 0x8b, 0x04, 0xe9, 0x0b, 0x16, 0x1a, 0x38, -0x0d, 0xc8, 0x04, 0x6f, 0x0b, 0x91, 0x0f, 0xff, 0x06, 0x40, 0x06, -0x40, 0x02, 0x8f, 0x0f, 0xff, 0x06, 0x62, 0x06, 0x62, 0x02, 0x7b, -0x0f, 0xff, 0x06, 0x97, 0x06, 0x97, 0x02, 0x52, 0x0f, 0xff, 0x06, -0xf6, 0x06, 0xf6, 0x02, 0x19, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, -0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x05, 0x55, 0x14, -0xda, 0x0d, 0x93, 0x04, 0xda, 0x05, 0x93, 0x14, 0xda, 0x0d, 0x93, -0x04, 0xda, 0x05, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x00 -}; - -static unsigned char page_zero_v2[] __devinitdata = { -0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static unsigned char page_one_v2[] __devinitdata = { -0x01, 0xc0, 0x01, 0xfa, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -static unsigned char page_two_v2[] __devinitdata = { -0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00 -}; -static unsigned char page_three_v2[] __devinitdata = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00 -}; -static unsigned char page_four_v2[] __devinitdata = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00 -}; +#define WAIT_IDLE 0xff -static unsigned char page_seven_v2[] __devinitdata = { -0x0f, 0xff, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +#define FIRMWARE_IN_THE_KERNEL -static unsigned char mod_v2[] __devinitdata = { -0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, -0x00, 0x01, 0x03, 0x02, 0x00, 0x01, 0x04, 0x02, 0x00, 0x01, 0x05, -0x02, 0x00, 0x01, 0x06, 0x02, 0x00, 0x01, 0x07, 0x02, 0x00, 0xb0, -0x20, 0xb1, 0x20, 0xb2, 0x20, 0xb3, 0x20, 0xb4, 0x20, 0xb5, 0x20, -0xb6, 0x20, 0xb7, 0x20, 0xf0, 0x20, 0xf1, 0x20, 0xf2, 0x20, 0xf3, -0x20, 0xf4, 0x20, 0xf5, 0x20, 0xf6, 0x20, 0xf7, 0x20, 0x10, 0xff, -0x11, 0xff, 0x12, 0xff, 0x13, 0xff, 0x14, 0xff, 0x15, 0xff, 0x16, -0xff, 0x17, 0xff, 0x20, 0xff, 0x21, 0xff, 0x22, 0xff, 0x23, 0xff, -0x24, 0xff, 0x25, 0xff, 0x26, 0xff, 0x27, 0xff, 0x30, 0x00, 0x31, -0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, -0x37, 0x00, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, -0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00, 0x50, 0x00, 0x51, 0x00, -0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, -0x00, 0x60, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, -0x65, 0x00, 0x66, 0x00, 0x67, 0x00, 0x70, 0xc0, 0x71, 0xc0, 0x72, -0xc0, 0x73, 0xc0, 0x74, 0xc0, 0x75, 0xc0, 0x76, 0xc0, 0x77, 0xc0, -0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, 0x00, 0x85, -0x00, 0x86, 0x00, 0x87, 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, -0x93, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00, 0xa0, -0x00, 0xa1, 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, -0xa6, 0x00, 0xa7, 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, -0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xd0, 0x00, -0xd1, 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, -0x00, 0xd7, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, 0x00, -0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0x01, 0x00, 0x02, -0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x03, -0x02, 0x01, 0x01, 0x04, 0x02, 0x01, 0x01, 0x05, 0x02, 0x01, 0x01, -0x06, 0x02, 0x01, 0x01, 0x07, 0x02, 0x01 -}; -static unsigned char coefficients[] __devinitdata = { -0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x00, 0x4b, 0x03, -0x11, 0x00, 0x4d, 0x01, 0x32, 0x07, 0x46, 0x00, 0x00, 0x07, 0x49, -0x00, 0x00, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x01, -0x40, 0x02, 0x40, 0x01, 0x41, 0x02, 0x60, 0x07, 0x40, 0x00, 0x00, -0x07, 0x41, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00, 0x07, 0x4a, 0x00, -0x00, 0x00, 0x47, 0x01, 0x00, 0x00, 0x4a, 0x01, 0x20, 0x07, 0x47, -0x00, 0x00, 0x07, 0x4a, 0x00, 0x00, 0x07, 0x7c, 0x00, 0x00, 0x07, -0x7e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x07, 0x7c, 0x00, 0x00, -0x07, 0x7e, 0x00, 0x00, 0x07, 0x44, 0x00, 0x00, 0x00, 0x44, 0x01, -0x00, 0x07, 0x44, 0x00, 0x00, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43, -0x00, 0x00, 0x00, 0x42, 0x01, 0x1a, 0x00, 0x43, 0x01, 0x20, 0x07, -0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07, 0x40, 0x00, 0x00, -0x07, 0x41, 0x00, 0x00, 0x01, 0x40, 0x02, 0x40, 0x01, 0x41, 0x02, -0x60, 0x07, 0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x44, -0x0f, 0xff, 0x07, 0x42, 0x00, 0x00, 0x07, 0x43, 0x00, 0x00, 0x07, -0x40, 0x00, 0x00, 0x07, 0x41, 0x00, 0x00, 0x07, 0x51, 0x06, 0x40, -0x07, 0x50, 0x06, 0x40, 0x07, 0x4f, 0x03, 0x81, 0x07, 0x53, 0x1a, -0x76, 0x07, 0x54, 0x0d, 0x8b, 0x07, 0x55, 0x04, 0xe9, 0x07, 0x56, -0x0b, 0x17, 0x07, 0x57, 0x1a, 0x38, 0x07, 0x58, 0x0d, 0xc9, 0x07, -0x59, 0x04, 0x6f, 0x07, 0x5a, 0x0b, 0x91, 0x07, 0x73, 0x14, 0xda, -0x07, 0x74, 0x0d, 0x93, 0x07, 0x75, 0x04, 0xd9, 0x07, 0x76, 0x05, -0x93, 0x07, 0x77, 0x14, 0xda, 0x07, 0x78, 0x0d, 0x93, 0x07, 0x79, -0x04, 0xd9, 0x07, 0x7a, 0x05, 0x93, 0x07, 0x5e, 0x03, 0x68, 0x07, -0x5c, 0x04, 0x31, 0x07, 0x5d, 0x04, 0x31, 0x07, 0x62, 0x03, 0x52, -0x07, 0x60, 0x04, 0x76, 0x07, 0x61, 0x04, 0x76, 0x07, 0x66, 0x03, -0x2e, 0x07, 0x64, 0x04, 0xda, 0x07, 0x65, 0x04, 0xda, 0x07, 0x6a, -0x02, 0xf6, 0x07, 0x68, 0x05, 0x62, 0x07, 0x69, 0x05, 0x62, 0x06, -0x46, 0x0a, 0x22, 0x06, 0x48, 0x0d, 0x24, 0x06, 0x6e, 0x11, 0xd3, -0x06, 0x70, 0x15, 0xcb, 0x06, 0x52, 0x20, 0x93, 0x06, 0x54, 0x20, -0x54, 0x06, 0x4a, 0x27, 0x1d, 0x06, 0x58, 0x2f, 0xc8, 0x06, 0x5c, -0x30, 0x07, 0x06, 0x4c, 0x37, 0x90, 0x06, 0x60, 0x3d, 0xdb, 0x06, -0x64, 0x3e, 0x42, 0x06, 0x4e, 0x45, 0x78, 0x06, 0x68, 0x4c, 0x48, -0x06, 0x6c, 0x4c, 0x6c, 0x06, 0x50, 0x52, 0xe2, 0x06, 0x42, 0x02, -0xba -}; -static unsigned char coefficients2[] __devinitdata = { -0x07, 0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x45, 0x0f, -0xff, 0x07, 0x48, 0x0f, 0xff, 0x07, 0x7b, 0x04, 0xcc, 0x07, 0x7d, -0x04, 0xcc, 0x07, 0x7c, 0x00, 0x00, 0x07, 0x7e, 0x00, 0x00, 0x07, -0x46, 0x00, 0x00, 0x07, 0x49, 0x00, 0x00, 0x07, 0x47, 0x00, 0x00, -0x07, 0x4a, 0x00, 0x00, 0x07, 0x4c, 0x00, 0x00, 0x07, 0x4e, 0x00, 0x00 -}; -static unsigned char coefficients3[] __devinitdata = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x00, 0x51, 0x00, -0x51, 0x00, 0x7a, 0x00, 0x7a, 0x00, 0xa3, 0x00, 0xa3, 0x00, 0xcc, -0x00, 0xcc, 0x00, 0xf5, 0x00, 0xf5, 0x01, 0x1e, 0x01, 0x1e, 0x01, -0x47, 0x01, 0x47, 0x01, 0x70, 0x01, 0x70, 0x01, 0x99, 0x01, 0x99, -0x01, 0xc2, 0x01, 0xc2, 0x01, 0xeb, 0x01, 0xeb, 0x02, 0x14, 0x02, -0x14, 0x02, 0x3d, 0x02, 0x3d, 0x02, 0x66, 0x02, 0x66, 0x02, 0x8f, -0x02, 0x8f, 0x02, 0xb8, 0x02, 0xb8, 0x02, 0xe1, 0x02, 0xe1, 0x03, -0x0a, 0x03, 0x0a, 0x03, 0x33, 0x03, 0x33, 0x03, 0x5c, 0x03, 0x5c, -0x03, 0x85, 0x03, 0x85, 0x03, 0xae, 0x03, 0xae, 0x03, 0xd7, 0x03, -0xd7, 0x04, 0x00, 0x04, 0x00, 0x04, 0x28, 0x04, 0x28, 0x04, 0x51, -0x04, 0x51, 0x04, 0x7a, 0x04, 0x7a, 0x04, 0xa3, 0x04, 0xa3, 0x04, -0xcc, 0x04, 0xcc, 0x04, 0xf5, 0x04, 0xf5, 0x05, 0x1e, 0x05, 0x1e, -0x05, 0x47, 0x05, 0x47, 0x05, 0x70, 0x05, 0x70, 0x05, 0x99, 0x05, -0x99, 0x05, 0xc2, 0x05, 0xc2, 0x05, 0xeb, 0x05, 0xeb, 0x06, 0x14, -0x06, 0x14, 0x06, 0x3d, 0x06, 0x3d, 0x06, 0x66, 0x06, 0x66, 0x06, -0x8f, 0x06, 0x8f, 0x06, 0xb8, 0x06, 0xb8, 0x06, 0xe1, 0x06, 0xe1, -0x07, 0x0a, 0x07, 0x0a, 0x07, 0x33, 0x07, 0x33, 0x07, 0x5c, 0x07, -0x5c, 0x07, 0x85, 0x07, 0x85, 0x07, 0xae, 0x07, 0xae, 0x07, 0xd7, -0x07, 0xd7, 0x08, 0x00, 0x08, 0x00, 0x08, 0x28, 0x08, 0x28, 0x08, -0x51, 0x08, 0x51, 0x08, 0x7a, 0x08, 0x7a, 0x08, 0xa3, 0x08, 0xa3, -0x08, 0xcc, 0x08, 0xcc, 0x08, 0xf5, 0x08, 0xf5, 0x09, 0x1e, 0x09, -0x1e, 0x09, 0x47, 0x09, 0x47, 0x09, 0x70, 0x09, 0x70, 0x09, 0x99, -0x09, 0x99, 0x09, 0xc2, 0x09, 0xc2, 0x09, 0xeb, 0x09, 0xeb, 0x0a, -0x14, 0x0a, 0x14, 0x0a, 0x3d, 0x0a, 0x3d, 0x0a, 0x66, 0x0a, 0x66, -0x0a, 0x8f, 0x0a, 0x8f, 0x0a, 0xb8, 0x0a, 0xb8, 0x0a, 0xe1, 0x0a, -0xe1, 0x0b, 0x0a, 0x0b, 0x0a, 0x0b, 0x33, 0x0b, 0x33, 0x0b, 0x5c, -0x0b, 0x5c, 0x0b, 0x85, 0x0b, 0x85, 0x0b, 0xae, 0x0b, 0xae, 0x0b, -0xd7, 0x0b, 0xd7, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x28, 0x0c, 0x28, -0x0c, 0x51, 0x0c, 0x51, 0x0c, 0x7a, 0x0c, 0x7a, 0x0c, 0xa3, 0x0c, -0xa3, 0x0c, 0xcc, 0x0c, 0xcc, 0x0c, 0xf5, 0x0c, 0xf5, 0x0d, 0x1e, -0x0d, 0x1e, 0x0d, 0x47, 0x0d, 0x47, 0x0d, 0x70, 0x0d, 0x70, 0x0d, -0x99, 0x0d, 0x99, 0x0d, 0xc2, 0x0d, 0xc2, 0x0d, 0xeb, 0x0d, 0xeb, -0x0e, 0x14, 0x0e, 0x14, 0x0e, 0x3d, 0x0e, 0x3d, 0x0e, 0x66, 0x0e, -0x66, 0x0e, 0x8f, 0x0e, 0x8f, 0x0e, 0xb8, 0x0e, 0xb8, 0x0e, 0xe1, -0x0e, 0xe1, 0x0f, 0x0a, 0x0f, 0x0a, 0x0f, 0x33, 0x0f, 0x33, 0x0f, -0x5c, 0x0f, 0x5c, 0x0f, 0x85, 0x0f, 0x85, 0x0f, 0xae, 0x0f, 0xae, -0x0f, 0xd7, 0x0f, 0xd7, 0x0f, 0xff, 0x0f, 0xff +#ifdef FIRMWARE_IN_THE_KERNEL +#include "yss225.c" +static const struct firmware yss225_registers_firmware = { + .data = (u8 *)yss225_registers, + .size = sizeof yss225_registers }; +#endif static int wavefront_fx_idle (snd_wavefront_t *dev) @@ -555,465 +248,56 @@ snd_wavefront_fx_ioctl (struct snd_hwdep of the port I/O done, using the Yamaha faxback document as a guide to add more logic to the code. Its really pretty weird. - There was an alternative approach of just dumping the whole I/O + This is the approach of just dumping the whole I/O sequence as a series of port/value pairs and a simple loop - that output it. However, I hope that eventually I'll get more - control over what this code does, and so I tried to stick with - a somewhat "algorithmic" approach. + that outputs it. */ - int __devinit snd_wavefront_fx_start (snd_wavefront_t *dev) - { - unsigned int i, j; + unsigned int i; + int err; + const struct firmware *firmware; - /* Set all bits for all channels on the MOD unit to zero */ - /* XXX But why do this twice ? */ + if (dev->fx_initialized) + return 0; - for (j = 0; j < 2; j++) { - for (i = 0x10; i <= 0xff; i++) { - - if (!wavefront_fx_idle (dev)) { - return (-1); + err = request_firmware(&firmware, "yamaha/yss225_registers.bin", + dev->card->dev); + if (err < 0) { +#ifdef FIRMWARE_IN_THE_KERNEL + firmware = &yss225_registers_firmware; +#else + err = -1; + goto out; +#endif + } + + for (i = 0; i + 1 < firmware->size; i += 2) { + if (firmware->data[i] >= 8 && firmware->data[i] < 16) { + outb(firmware->data[i + 1], + dev->base + firmware->data[i]); + } else if (firmware->data[i] == WAIT_IDLE) { + if (!wavefront_fx_idle(dev)) { + err = -1; + goto out; } - - outb (i, dev->fx_mod_addr); - outb (0x0, dev->fx_mod_data); - } - } - - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x02, dev->fx_op); /* mute on */ - - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x44, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x42, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x43, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x7c, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x7e, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x46, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x49, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x47, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x4a, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - - /* either because of stupidity by TB's programmers, or because it - actually does something, rezero the MOD page. - */ - for (i = 0x10; i <= 0xff; i++) { - - if (!wavefront_fx_idle (dev)) { - return (-1); + } else { + snd_printk(KERN_ERR "invalid address" + " in register data\n"); + err = -1; + goto out; } - - outb (i, dev->fx_mod_addr); - outb (0x0, dev->fx_mod_data); - } - /* load page zero */ - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x00, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_zero); i += 2) { - outb (page_zero[i], dev->fx_dsp_msb); - outb (page_zero[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - /* Now load page one */ - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x01, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_one); i += 2) { - outb (page_one[i], dev->fx_dsp_msb); - outb (page_one[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x02, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_two); i++) { - outb (page_two[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x03, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_three); i++) { - outb (page_three[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x04, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_four); i++) { - outb (page_four[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - /* Load memory area (page six) */ - - outb (FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x06, dev->fx_dsp_page); - - for (i = 0; i < sizeof (page_six); i += 3) { - outb (page_six[i], dev->fx_dsp_addr); - outb (page_six[i+1], dev->fx_dsp_msb); - outb (page_six[i+2], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x07, dev->fx_dsp_page); - outb (0x00, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_seven); i += 2) { - outb (page_seven[i], dev->fx_dsp_msb); - outb (page_seven[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - /* Now setup the MOD area. We do this algorithmically in order to - save a little data space. It could be done in the same fashion - as the "pages". - */ - - for (i = 0x00; i <= 0x0f; i++) { - outb (0x01, dev->fx_mod_addr); - outb (i, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x02, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0xb0; i <= 0xbf; i++) { - outb (i, dev->fx_mod_addr); - outb (0x20, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); } - for (i = 0xf0; i <= 0xff; i++) { - outb (i, dev->fx_mod_addr); - outb (0x20, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0x10; i <= 0x1d; i++) { - outb (i, dev->fx_mod_addr); - outb (0xff, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x1e, dev->fx_mod_addr); - outb (0x40, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - for (i = 0x1f; i <= 0x2d; i++) { - outb (i, dev->fx_mod_addr); - outb (0xff, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x2e, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - for (i = 0x2f; i <= 0x3e; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x3f, dev->fx_mod_addr); - outb (0x20, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - for (i = 0x40; i <= 0x4d; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x4e, dev->fx_mod_addr); - outb (0x0e, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x4f, dev->fx_mod_addr); - outb (0x0e, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - - for (i = 0x50; i <= 0x6b; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x6c, dev->fx_mod_addr); - outb (0x40, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - outb (0x6d, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - outb (0x6e, dev->fx_mod_addr); - outb (0x40, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - outb (0x6f, dev->fx_mod_addr); - outb (0x40, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - for (i = 0x70; i <= 0x7f; i++) { - outb (i, dev->fx_mod_addr); - outb (0xc0, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0x80; i <= 0xaf; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0xc0; i <= 0xdd; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0xde, dev->fx_mod_addr); - outb (0x10, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0xdf, dev->fx_mod_addr); - outb (0x10, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - - for (i = 0xe0; i <= 0xef; i++) { - outb (i, dev->fx_mod_addr); - outb (0x00, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0x00; i <= 0x0f; i++) { - outb (0x01, dev->fx_mod_addr); - outb (i, dev->fx_mod_data); - outb (0x02, dev->fx_mod_addr); - outb (0x01, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (0x02, dev->fx_op); /* mute on */ - - /* Now set the coefficients and so forth for the programs above */ - - for (i = 0; i < sizeof (coefficients); i += 4) { - outb (coefficients[i], dev->fx_dsp_page); - outb (coefficients[i+1], dev->fx_dsp_addr); - outb (coefficients[i+2], dev->fx_dsp_msb); - outb (coefficients[i+3], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - /* Some settings (?) that are too small to bundle into loops */ - - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x1e, dev->fx_mod_addr); - outb (0x14, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0xde, dev->fx_mod_addr); - outb (0x20, dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0xdf, dev->fx_mod_addr); - outb (0x20, dev->fx_mod_data); - - /* some more coefficients */ - - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x06, dev->fx_dsp_page); - outb (0x78, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x40, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x03, dev->fx_dsp_addr); - outb (0x0f, dev->fx_dsp_msb); - outb (0xff, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x0b, dev->fx_dsp_addr); - outb (0x0f, dev->fx_dsp_msb); - outb (0xff, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x02, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x0a, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x46, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - outb (0x07, dev->fx_dsp_page); - outb (0x49, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - - /* Now, for some strange reason, lets reload every page - and all the coefficients over again. I have *NO* idea - why this is done. I do know that no sound is produced - is this phase is omitted. - */ - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x00, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_zero_v2); i += 2) { - outb (page_zero_v2[i], dev->fx_dsp_msb); - outb (page_zero_v2[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x01, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_one_v2); i += 2) { - outb (page_one_v2[i], dev->fx_dsp_msb); - outb (page_one_v2[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - if (!wavefront_fx_idle (dev)) return (-1); - if (!wavefront_fx_idle (dev)) return (-1); - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x02, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_two_v2); i++) { - outb (page_two_v2[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x03, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_three_v2); i++) { - outb (page_three_v2[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x04, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_four_v2); i++) { - outb (page_four_v2[i], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x06, dev->fx_dsp_page); - - /* Page six v.2 is algorithmic */ - - for (i = 0x10; i <= 0x3e; i += 2) { - outb (i, dev->fx_dsp_addr); - outb (0x00, dev->fx_dsp_msb); - outb (0x00, dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - outb (FX_AUTO_INCR|FX_LSB_TRANSFER, dev->fx_lcr); - outb (0x07, dev->fx_dsp_page); - outb (0x10, dev->fx_dsp_addr); - - for (i = 0; i < sizeof (page_seven_v2); i += 2) { - outb (page_seven_v2[i], dev->fx_dsp_msb); - outb (page_seven_v2[i+1], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0x00; i < sizeof(mod_v2); i += 2) { - outb (mod_v2[i], dev->fx_mod_addr); - outb (mod_v2[i+1], dev->fx_mod_data); - if (!wavefront_fx_idle (dev)) return (-1); - } + dev->fx_initialized = 1; + err = 0; - for (i = 0; i < sizeof (coefficients2); i += 4) { - outb (coefficients2[i], dev->fx_dsp_page); - outb (coefficients2[i+1], dev->fx_dsp_addr); - outb (coefficients2[i+2], dev->fx_dsp_msb); - outb (coefficients2[i+3], dev->fx_dsp_lsb); - if (!wavefront_fx_idle (dev)) return (-1); - } - - for (i = 0; i < sizeof (coefficients3); i += 2) { - int x; - - outb (0x07, dev->fx_dsp_page); - x = (i % 4) ? 0x4e : 0x4c; - outb (x, dev->fx_dsp_addr); - outb (coefficients3[i], dev->fx_dsp_msb); - outb (coefficients3[i+1], dev->fx_dsp_lsb); - } - - outb (0x00, dev->fx_op); /* mute off */ - if (!wavefront_fx_idle (dev)) return (-1); - - return (0); +out: +#ifdef FIRMWARE_IN_THE_KERNEL + if (firmware != &yss225_registers_firmware) +#endif + release_firmware(firmware); + return err; } diff --git a/sound/isa/wavefront/yss225.c b/sound/isa/wavefront/yss225.c new file mode 100644 index 0000000..9f6be3f --- /dev/null +++ b/sound/isa/wavefront/yss225.c @@ -0,0 +1,2739 @@ +/* + * Copyright (c) 1998-2002 by Paul Davis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* weird stuff, derived from port I/O tracing with dosemu */ + +static const struct { + unsigned char addr; + unsigned char data; +} yss225_registers[] __devinitdata = { +/* Set all bits for all channels on the MOD unit to zero */ +{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 }, + +/* XXX But why do this twice? */ +{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 }, + +/* mute on */ +{ WAIT_IDLE }, { 0x8, 0x02 }, + +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, + +/* either because of stupidity by TB's programmers, or because it + actually does something, rezero the MOD page. */ +{ WAIT_IDLE }, { 0xe, 0x10 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x11 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x12 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x13 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x14 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x15 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x16 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x17 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x18 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x19 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x1f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x20 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x21 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x22 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x23 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x24 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x25 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x26 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x27 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x28 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x29 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x2f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x30 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x31 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x32 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x33 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x34 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x35 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x36 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x37 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x38 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x39 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x3f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x40 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x41 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x42 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x43 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x44 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x45 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x46 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x47 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x48 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x49 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x4f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x50 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x51 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x52 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x53 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x54 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x55 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x56 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x57 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x58 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x59 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x5f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x60 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x61 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x62 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x63 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x64 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x65 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x66 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x67 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x68 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x69 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x6f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x70 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x71 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x72 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x73 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x74 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x75 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x76 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x77 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x78 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x79 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x7f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x80 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x81 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x82 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x83 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x84 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x85 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x86 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x87 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x88 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x89 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x8f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x90 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x91 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x92 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x93 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x94 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x95 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x96 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x97 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x98 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x99 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9a }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9b }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9c }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9d }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9e }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0x9f }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xa9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xab }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xac }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xad }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xae }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xaf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xb9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xba }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xbf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xc9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xca }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xce }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xcf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xd9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xda }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xe9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xea }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xeb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xec }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xed }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xee }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xef }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf0 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf1 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf2 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf3 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf4 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf5 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf6 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf7 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf8 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xf9 }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfa }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfb }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfc }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfd }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xfe }, { 0xf, 0x00 }, +{ WAIT_IDLE }, { 0xe, 0xff }, { 0xf, 0x00 }, + +/* load page zero */ +{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x00 }, + +{ 0xd, 0x01 }, { 0xc, 0x7c }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1e }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x11 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x32 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x14 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x76 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x17 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0xa0 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xd1 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0xf2 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x13 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xf4 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x15 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x50 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x71 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x92 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xb3 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xd4 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xf5 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x70 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0xa0 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x11 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x16 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x10 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x17 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1d }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xdf }, { WAIT_IDLE }, + +/* Now load page one */ +{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x00 }, + +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1f }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xd8 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x19 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x18 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xa0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xd7 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xf7 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1c }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x3c }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x3f }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xdf }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x5d }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x7d }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0x9e }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xbe }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x03 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xdb }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xe0 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xfb }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1b }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x00 }, + +{ 0xc, 0xc4 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x25 }, { WAIT_IDLE }, +{ 0xc, 0x01 }, { WAIT_IDLE }, +{ 0xc, 0x06 }, { WAIT_IDLE }, +{ 0xc, 0xc4 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x25 }, { WAIT_IDLE }, +{ 0xc, 0x01 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x04 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x04 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x05 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x44 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x00 }, + +{ 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x47 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x06 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x70 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x42 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x42 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x42 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x42 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x40 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x00 }, + +{ 0xc, 0x63 }, { WAIT_IDLE }, +{ 0xc, 0x03 }, { WAIT_IDLE }, +{ 0xc, 0x26 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x2c }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x24 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x2e }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x01 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x22 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x22 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x22 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x62 }, { WAIT_IDLE }, +{ 0xc, 0x02 }, { WAIT_IDLE }, +{ 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xc, 0x01 }, { WAIT_IDLE }, +{ 0xc, 0x21 }, { WAIT_IDLE }, +{ 0xc, 0x01 }, { WAIT_IDLE }, + +/* Load memory area (page six) */ +{ 0x9, 0x01 }, { 0xb, 0x06 }, + +{ 0xa, 0x00 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x04 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x06 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x08 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x0c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x0e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x42 }, { 0xd, 0x03 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x21 }, { WAIT_IDLE }, +{ 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x23 }, { WAIT_IDLE }, +{ 0xa, 0x4a }, { 0xd, 0x23 }, { 0xc, 0x1b }, { WAIT_IDLE }, +{ 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x8f }, { WAIT_IDLE }, +{ 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x77 }, { WAIT_IDLE }, +{ 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE }, +{ 0xa, 0x52 }, { 0xd, 0x1c }, { 0xc, 0x92 }, { WAIT_IDLE }, +{ 0xa, 0x54 }, { 0xd, 0x1c }, { 0xc, 0x52 }, { WAIT_IDLE }, +{ 0xa, 0x56 }, { 0xd, 0x07 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc6 }, { WAIT_IDLE }, +{ 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x06 }, { WAIT_IDLE }, +{ 0xa, 0x5e }, { 0xd, 0x17 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xa, 0x62 }, { 0xd, 0x29 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x41 }, { WAIT_IDLE }, +{ 0xa, 0x66 }, { 0xd, 0x39 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE }, +{ 0xa, 0x6a }, { 0xd, 0x49 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE }, +{ 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd2 }, { WAIT_IDLE }, +{ 0xa, 0x70 }, { 0xd, 0x16 }, { 0xc, 0x0c }, { WAIT_IDLE }, +{ 0xa, 0x72 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x74 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xa, 0x76 }, { 0xd, 0x0f }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x80 }, { WAIT_IDLE }, +{ 0xa, 0x7a }, { 0xd, 0x13 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x7c }, { 0xd, 0x80 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x7e }, { 0xd, 0x80 }, { 0xc, 0x80 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x00 }, + +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x08 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0xe9 }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x8c }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x1a }, { 0xc, 0x75 }, { WAIT_IDLE }, +{ 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE }, +{ 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE }, +{ 0xd, 0x0b }, { 0xc, 0x16 }, { WAIT_IDLE }, +{ 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE }, +{ 0xd, 0x0d }, { 0xc, 0xc8 }, { WAIT_IDLE }, +{ 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE }, +{ 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x8f }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x62 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x7b }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0x97 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x52 }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE }, +{ 0xd, 0x06 }, { 0xc, 0xf6 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x19 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x55 }, { WAIT_IDLE }, +{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +/* Now setup the MOD area. */ +{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x08 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x09 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0a }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0b }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0c }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0d }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0e }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0f }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, + +{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb8 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb9 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xba }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xbb }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xbc }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xbd }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xbe }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xbf }, { 0xf, 0x20 }, { WAIT_IDLE }, + +{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf8 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf9 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xfa }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xfb }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xfc }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xfd }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xfe }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xff }, { 0xf, 0x20 }, { WAIT_IDLE }, + +{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x18 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x19 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x1a }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x1b }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x1c }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x1d }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x1e }, { 0xf, 0x40 }, { WAIT_IDLE }, +{ 0xe, 0x1f }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x28 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x29 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x2a }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x2b }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x2c }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x2d }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x2e }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x2f }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x38 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x39 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3c }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3e }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x3f }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x48 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x49 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x4a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x4b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x4c }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x4d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x4e }, { 0xf, 0x0e }, { WAIT_IDLE }, +{ 0xe, 0x4f }, { 0xf, 0x0e }, { WAIT_IDLE }, +{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x58 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x59 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5c }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5e }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x5f }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x68 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x69 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x6a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x6b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x6c }, { 0xf, 0x40 }, { WAIT_IDLE }, +{ 0xe, 0x6d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x6e }, { 0xf, 0x40 }, { WAIT_IDLE }, +{ 0xe, 0x6f }, { 0xf, 0x40 }, { WAIT_IDLE }, +{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x78 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x79 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7a }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7b }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7c }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7d }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7e }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x7f }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x88 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x89 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8c }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8e }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x8f }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x98 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x99 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9a }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9b }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9c }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9d }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9e }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x9f }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa8 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa9 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xaa }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xab }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xac }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xad }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xae }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xaf }, { 0xf, 0x00 }, { WAIT_IDLE }, + +{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc8 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc9 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xca }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xcb }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xcc }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xcd }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xce }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xcf }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd8 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd9 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xda }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xdb }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xdc }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xdd }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xde }, { 0xf, 0x10 }, { WAIT_IDLE }, +{ 0xe, 0xdf }, { 0xf, 0x10 }, { WAIT_IDLE }, +{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe8 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe9 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xea }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xeb }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xec }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xed }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xee }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xef }, { 0xf, 0x00 }, { WAIT_IDLE }, + +{ 0xe, 0x01 }, { 0xf, 0x00 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x01 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x02 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x03 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x04 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x05 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x06 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x07 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x08 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x09 }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0a }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0b }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0c }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0d }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0e }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x0f }, { 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, + +/* mute on */ +{ 0x8, 0x02 }, + +/* Now set the coefficients and so forth for the programs above */ +{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x4b }, { 0xd, 0x03 }, { 0xc, 0x11 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x4d }, { 0xd, 0x01 }, { 0xc, 0x32 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x47 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x4a }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x00 }, { 0xd, 0x01 }, { 0xc, 0x1c }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x44 }, { 0xd, 0x01 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x42 }, { 0xd, 0x01 }, { 0xc, 0x1a }, { WAIT_IDLE }, +{ 0xb, 0x00 }, { 0xa, 0x43 }, { 0xd, 0x01 }, { 0xc, 0x20 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x01 }, { 0xa, 0x40 }, { 0xd, 0x02 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xb, 0x01 }, { 0xa, 0x41 }, { 0xd, 0x02 }, { 0xc, 0x60 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x44 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x42 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x43 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x40 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x41 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x51 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x50 }, { 0xd, 0x06 }, { 0xc, 0x40 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4f }, { 0xd, 0x03 }, { 0xc, 0x81 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x53 }, { 0xd, 0x1a }, { 0xc, 0x76 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x54 }, { 0xd, 0x0d }, { 0xc, 0x8b }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x55 }, { 0xd, 0x04 }, { 0xc, 0xe9 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x56 }, { 0xd, 0x0b }, { 0xc, 0x17 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x57 }, { 0xd, 0x1a }, { 0xc, 0x38 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x58 }, { 0xd, 0x0d }, { 0xc, 0xc9 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x59 }, { 0xd, 0x04 }, { 0xc, 0x6f }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x5a }, { 0xd, 0x0b }, { 0xc, 0x91 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x73 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x74 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x75 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x76 }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x77 }, { 0xd, 0x14 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x78 }, { 0xd, 0x0d }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x79 }, { 0xd, 0x04 }, { 0xc, 0xd9 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7a }, { 0xd, 0x05 }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x5e }, { 0xd, 0x03 }, { 0xc, 0x68 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x5c }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x5d }, { 0xd, 0x04 }, { 0xc, 0x31 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x62 }, { 0xd, 0x03 }, { 0xc, 0x52 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x60 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x61 }, { 0xd, 0x04 }, { 0xc, 0x76 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x66 }, { 0xd, 0x03 }, { 0xc, 0x2e }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x64 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x65 }, { 0xd, 0x04 }, { 0xc, 0xda }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x6a }, { 0xd, 0x02 }, { 0xc, 0xf6 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x68 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x69 }, { 0xd, 0x05 }, { 0xc, 0x62 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x46 }, { 0xd, 0x0a }, { 0xc, 0x22 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x48 }, { 0xd, 0x0d }, { 0xc, 0x24 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x6e }, { 0xd, 0x11 }, { 0xc, 0xd3 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x70 }, { 0xd, 0x15 }, { 0xc, 0xcb }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x52 }, { 0xd, 0x20 }, { 0xc, 0x93 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x54 }, { 0xd, 0x20 }, { 0xc, 0x54 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x4a }, { 0xd, 0x27 }, { 0xc, 0x1d }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x58 }, { 0xd, 0x2f }, { 0xc, 0xc8 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x5c }, { 0xd, 0x30 }, { 0xc, 0x07 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x4c }, { 0xd, 0x37 }, { 0xc, 0x90 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x60 }, { 0xd, 0x3d }, { 0xc, 0xdb }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x64 }, { 0xd, 0x3e }, { 0xc, 0x42 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x4e }, { 0xd, 0x45 }, { 0xc, 0x78 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x68 }, { 0xd, 0x4c }, { 0xc, 0x48 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x6c }, { 0xd, 0x4c }, { 0xc, 0x6c }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x50 }, { 0xd, 0x52 }, { 0xc, 0xe2 }, { WAIT_IDLE }, +{ 0xb, 0x06 }, { 0xa, 0x42 }, { 0xd, 0x02 }, { 0xc, 0xba }, { WAIT_IDLE }, + +/* Some settings (?) */ +{ WAIT_IDLE }, { 0xe, 0x1e }, { 0xf, 0x14 }, +{ WAIT_IDLE }, { 0xe, 0xde }, { 0xf, 0x20 }, +{ WAIT_IDLE }, { 0xe, 0xdf }, { 0xf, 0x20 }, + +/* some more coefficients */ +{ WAIT_IDLE }, { 0xb, 0x06 }, { 0xa, 0x78 }, { 0xd, 0x00 }, { 0xc, 0x40 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x03 }, { 0xd, 0x0f }, { 0xc, 0xff }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0b }, { 0xd, 0x0f }, { 0xc, 0xff }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x02 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x0a }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ WAIT_IDLE }, { 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, + +/* Now, for some strange reason, lets reload every page + and all the coefficients over again. I have *NO* idea + why this is done. I do know that no sound is produced + is this phase is omitted. */ +{ 0x9, 0x05 }, { 0xb, 0x00 }, { 0xa, 0x10 }, + +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x02 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x01 }, { 0xa, 0x10 }, + +{ 0xd, 0x01 }, { 0xc, 0xc0 }, { WAIT_IDLE }, +{ 0xd, 0x01 }, { 0xc, 0xfa }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x1a }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +{ WAIT_IDLE }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x02 }, { 0xa, 0x10 }, + +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x46 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x03 }, { 0xa, 0x10 }, + +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x04 }, { 0xa, 0x10 }, + +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xc, 0x00 }, { WAIT_IDLE }, + +/* Page six v.2 */ +{ 0x9, 0x01 }, { 0xb, 0x06 }, + +{ 0xa, 0x10 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x12 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x14 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x16 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x18 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x1e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x20 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x22 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x24 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x26 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x28 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x2e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x30 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x32 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x34 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x36 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x38 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xa, 0x3e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0x9, 0x05 }, { 0xb, 0x07 }, { 0xa, 0x10 }, + +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xb0 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb1 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb2 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb3 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb4 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb5 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb6 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xb7 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf0 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf1 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf2 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf3 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf4 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf5 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf6 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0xf7 }, { 0xf, 0x20 }, { WAIT_IDLE }, +{ 0xe, 0x10 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x11 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x12 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x13 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x14 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x15 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x16 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x17 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x20 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x21 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x22 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x23 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x24 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x25 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x26 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x27 }, { 0xf, 0xff }, { WAIT_IDLE }, +{ 0xe, 0x30 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x31 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x32 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x33 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x34 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x35 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x36 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x37 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x40 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x41 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x42 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x43 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x44 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x45 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x46 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x47 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x50 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x51 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x52 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x53 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x54 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x55 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x56 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x57 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x60 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x61 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x62 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x63 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x64 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x65 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x66 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x67 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x70 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x71 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x72 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x73 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x74 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x75 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x76 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x77 }, { 0xf, 0xc0 }, { WAIT_IDLE }, +{ 0xe, 0x80 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x81 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x82 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x83 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x84 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x85 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x86 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x87 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x90 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x91 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x92 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x93 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x94 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x95 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x96 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x97 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xa7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xc7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xd7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe0 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe1 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe2 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe3 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe4 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe5 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe6 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0xe7 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x00 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x02 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x03 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x04 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x05 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x06 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, +{ 0xe, 0x01 }, { 0xf, 0x07 }, { WAIT_IDLE }, +{ 0xe, 0x02 }, { 0xf, 0x01 }, { WAIT_IDLE }, + +{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x45 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x48 }, { 0xd, 0x0f }, { 0xc, 0xff }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7b }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7d }, { 0xd, 0x04 }, { 0xc, 0xcc }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x7e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x46 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x49 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x47 }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4a }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 }, { WAIT_IDLE }, + +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x00 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x00 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x01 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x01 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x02 }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x02 }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x03 }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x03 }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x04 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x04 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x05 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x05 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x06 }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x06 }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x07 }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x07 }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x08 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x08 }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x09 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x09 }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0a }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0a }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0b }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0b }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x00 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x28 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x51 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0x7a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xa3 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xcc }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0c }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0c }, { 0xc, 0xf5 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x1e }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x47 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x70 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0x99 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xc2 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0d }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0d }, { 0xc, 0xeb }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x14 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x3d }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x66 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0x8f }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xb8 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0e }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0e }, { 0xc, 0xe1 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x0a }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x33 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x5c }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0x85 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xae }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xd7 }, +{ 0xb, 0x07 }, { 0xa, 0x4c }, { 0xd, 0x0f }, { 0xc, 0xff }, +{ 0xb, 0x07 }, { 0xa, 0x4e }, { 0xd, 0x0f }, { 0xc, 0xff }, + +/* mute off */ +{ 0x8, 0x00 }, { WAIT_IDLE } +}; diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 8a6b180..1bcfb3a 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -236,7 +236,7 @@ config SND_CS5535AUDIO config SND_DARLA20 tristate "(Echoaudio) Darla20" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Darla. @@ -247,7 +247,7 @@ config SND_DARLA20 config SND_GINA20 tristate "(Echoaudio) Gina20" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Gina. @@ -258,7 +258,7 @@ config SND_GINA20 config SND_LAYLA20 tristate "(Echoaudio) Layla20" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_RAWMIDI select SND_PCM help @@ -270,7 +270,7 @@ config SND_LAYLA20 config SND_DARLA24 tristate "(Echoaudio) Darla24" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Darla24. @@ -281,7 +281,7 @@ config SND_DARLA24 config SND_GINA24 tristate "(Echoaudio) Gina24" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Gina24. @@ -292,7 +292,7 @@ config SND_GINA24 config SND_LAYLA24 tristate "(Echoaudio) Layla24" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_RAWMIDI select SND_PCM help @@ -304,7 +304,7 @@ config SND_LAYLA24 config SND_MONA tristate "(Echoaudio) Mona" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_RAWMIDI select SND_PCM help @@ -316,7 +316,7 @@ config SND_MONA config SND_MIA tristate "(Echoaudio) Mia" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_RAWMIDI select SND_PCM help @@ -328,7 +328,7 @@ config SND_MIA config SND_ECHO3G tristate "(Echoaudio) 3G cards" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_RAWMIDI select SND_PCM help @@ -340,7 +340,7 @@ config SND_ECHO3G config SND_INDIGO tristate "(Echoaudio) Indigo" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Indigo. @@ -351,7 +351,7 @@ config SND_INDIGO config SND_INDIGOIO tristate "(Echoaudio) Indigo IO" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Indigo IO. @@ -362,7 +362,7 @@ config SND_INDIGOIO config SND_INDIGODJ tristate "(Echoaudio) Indigo DJ" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_PCM help Say 'Y' or 'M' to include support for Echoaudio Indigo DJ. @@ -373,6 +373,7 @@ config SND_INDIGODJ config SND_EMU10K1 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)" depends on SND + select FW_LOADER select SND_HWDEP select SND_RAWMIDI select SND_AC97_CODEC @@ -575,6 +576,7 @@ config SND_INTEL8X0M config SND_KORG1212 tristate "Korg 1212 IO" depends on SND + select FW_LOADER select SND_PCM help Say Y here to include support for Korg 1212IO soundcards. @@ -585,6 +587,7 @@ config SND_KORG1212 config SND_MAESTRO3 tristate "ESS Allegro/Maestro3" depends on SND + select FW_LOADER select SND_AC97_CODEC help Say Y here to include support for soundcards based on ESS Maestro 3 @@ -629,7 +632,7 @@ config SND_PCXHR config SND_RIPTIDE tristate "Conexant Riptide" depends on SND - depends on FW_LOADER + select FW_LOADER select SND_OPL3_LIB select SND_MPU401_UART select SND_AC97_CODEC @@ -734,6 +737,7 @@ config SND_VX222 config SND_YMFPCI tristate "Yamaha YMF724/740/744/754" depends on SND + select FW_LOADER select SND_OPL3_LIB select SND_MPU401_UART select SND_AC97_CODEC diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index d2994cb..bd8cfdc 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -111,7 +111,7 @@ static const struct ac97_codec_id snd_ac { 0x41445372, 0xffffffff, "AD1981A", patch_ad1981a, NULL }, { 0x41445374, 0xffffffff, "AD1981B", patch_ad1981b, NULL }, { 0x41445375, 0xffffffff, "AD1985", patch_ad1985, NULL }, -{ 0x41445378, 0xffffffff, "AD1986", patch_ad1985, NULL }, +{ 0x41445378, 0xffffffff, "AD1986", patch_ad1986, NULL }, { 0x414c4300, 0xffffff00, "ALC100,100P", NULL, NULL }, { 0x414c4710, 0xfffffff0, "ALC200,200P", NULL, NULL }, { 0x414c4721, 0xffffffff, "ALC650D", NULL, NULL }, /* already patched */ @@ -194,6 +194,13 @@ static const struct ac97_codec_id snd_ac static void update_power_regs(struct snd_ac97 *ac97); +#ifdef CONFIG_SND_AC97_POWER_SAVE +#define ac97_is_power_save_mode(ac97) \ + ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save) +#else +#define ac97_is_power_save_mode(ac97) 0 +#endif + /* * I/O routines @@ -982,8 +989,7 @@ static int snd_ac97_free(struct snd_ac97 { if (ac97) { #ifdef CONFIG_SND_AC97_POWER_SAVE - if (ac97->power_workq) - destroy_workqueue(ac97->power_workq); + cancel_delayed_work(&ac97->power_work); #endif snd_ac97_proc_done(ac97); if (ac97->bus) @@ -1989,7 +1995,6 @@ int snd_ac97_mixer(struct snd_ac97_bus * mutex_init(&ac97->reg_mutex); mutex_init(&ac97->page_mutex); #ifdef CONFIG_SND_AC97_POWER_SAVE - ac97->power_workq = create_workqueue("ac97"); INIT_DELAYED_WORK(&ac97->power_work, do_update_power); #endif @@ -2275,15 +2280,13 @@ static void snd_ac97_powerdown(struct sn udelay(100); power |= AC97_PD_PR2 | AC97_PD_PR3; /* Analog Mixer powerdown */ snd_ac97_write(ac97, AC97_POWERDOWN, power); -#ifdef CONFIG_SND_AC97_POWER_SAVE - if (power_save) { + if (ac97_is_power_save_mode(ac97)) { udelay(100); /* AC-link powerdown, internal Clk disable */ /* FIXME: this may cause click noises on some boards */ power |= AC97_PD_PR4 | AC97_PD_PR5; snd_ac97_write(ac97, AC97_POWERDOWN, power); } -#endif } @@ -2337,14 +2340,16 @@ int snd_ac97_update_power(struct snd_ac9 } } - if (power_save && !powerup && ac97->power_workq) + if (ac97_is_power_save_mode(ac97) && !powerup) /* adjust power-down bits after two seconds delay * (for avoiding loud click noises for many (OSS) apps * that open/close frequently) */ - queue_delayed_work(ac97->power_workq, &ac97->power_work, HZ*2); - else + schedule_delayed_work(&ac97->power_work, HZ*2); + else { + cancel_delayed_work(&ac97->power_work); update_power_regs(ac97); + } return 0; } @@ -2357,19 +2362,15 @@ static void update_power_regs(struct snd unsigned int power_up, bits; int i; + power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC); + power_up |= (1 << PWIDX_MIC); + if (ac97->scaps & AC97_SCAP_SURROUND_DAC) + power_up |= (1 << PWIDX_SURR); + if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) + power_up |= (1 << PWIDX_CLFE); #ifdef CONFIG_SND_AC97_POWER_SAVE - if (power_save) + if (ac97_is_power_save_mode(ac97)) power_up = ac97->power_up; - else { -#endif - power_up = (1 << PWIDX_FRONT) | (1 << PWIDX_ADC); - power_up |= (1 << PWIDX_MIC); - if (ac97->scaps & AC97_SCAP_SURROUND_DAC) - power_up |= (1 << PWIDX_SURR); - if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) - power_up |= (1 << PWIDX_CLFE); -#ifdef CONFIG_SND_AC97_POWER_SAVE - } #endif if (power_up) { if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) { diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index e813968..f5b4b44 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -190,14 +190,28 @@ static inline int is_clfe_on(struct snd_ return ac97->channel_mode >= 2; } +/* system has shared jacks with surround out enabled */ +static inline int is_shared_surrout(struct snd_ac97 *ac97) +{ + return !ac97->indep_surround && is_surround_on(ac97); +} + +/* system has shared jacks with center/lfe out enabled */ +static inline int is_shared_clfeout(struct snd_ac97 *ac97) +{ + return !ac97->indep_surround && is_clfe_on(ac97); +} + +/* system has shared jacks with line in enabled */ static inline int is_shared_linein(struct snd_ac97 *ac97) { - return ! ac97->indep_surround && is_surround_on(ac97); + return !ac97->indep_surround && !is_surround_on(ac97); } +/* system has shared jacks with mic in enabled */ static inline int is_shared_micin(struct snd_ac97 *ac97) { - return ! ac97->indep_surround && is_clfe_on(ac97); + return !ac97->indep_surround && !is_clfe_on(ac97); } @@ -941,6 +955,9 @@ static int patch_sigmatel_stac9708_speci { int err; + /* the register bit is writable, but the function is not implemented: */ + snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL); + snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback"); if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0) return err; @@ -1609,19 +1626,22 @@ int patch_ad1886(struct snd_ac97 * ac97) return 0; } -/* MISC bits */ +/* MISC bits (AD1888/AD1980/AD1985 register 0x76) */ #define AC97_AD198X_MBC 0x0003 /* mic boost */ #define AC97_AD198X_MBC_20 0x0000 /* +20dB */ #define AC97_AD198X_MBC_10 0x0001 /* +10dB */ #define AC97_AD198X_MBC_30 0x0002 /* +30dB */ #define AC97_AD198X_VREFD 0x0004 /* VREF high-Z */ -#define AC97_AD198X_VREFH 0x0008 /* 2.25V, 3.7V */ -#define AC97_AD198X_VREF_0 0x000c /* 0V */ +#define AC97_AD198X_VREFH 0x0008 /* 0=2.25V, 1=3.7V */ +#define AC97_AD198X_VREF_0 0x000c /* 0V (AD1985 only) */ +#define AC97_AD198X_VREF_MASK (AC97_AD198X_VREFH | AC97_AD198X_VREFD) +#define AC97_AD198X_VREF_SHIFT 2 #define AC97_AD198X_SRU 0x0010 /* sample rate unlock */ #define AC97_AD198X_LOSEL 0x0020 /* LINE_OUT amplifiers input select */ #define AC97_AD198X_2MIC 0x0040 /* 2-channel mic select */ #define AC97_AD198X_SPRD 0x0080 /* SPREAD enable */ -#define AC97_AD198X_DMIX0 0x0100 /* downmix mode: 0 = 6-to-4, 1 = 6-to-2 downmix */ +#define AC97_AD198X_DMIX0 0x0100 /* downmix mode: */ + /* 0 = 6-to-4, 1 = 6-to-2 downmix */ #define AC97_AD198X_DMIX1 0x0200 /* downmix mode: 1 = enabled */ #define AC97_AD198X_HPSEL 0x0400 /* headphone amplifier input select */ #define AC97_AD198X_CLDIS 0x0800 /* center/lfe disable */ @@ -1630,6 +1650,83 @@ #define AC97_AD198X_MSPLT 0x2000 /* mute #define AC97_AD198X_AC97NC 0x4000 /* AC97 no compatible mode */ #define AC97_AD198X_DACZ 0x8000 /* DAC zero-fill mode */ +/* MISC 1 bits (AD1986 register 0x76) */ +#define AC97_AD1986_MBC 0x0003 /* mic boost */ +#define AC97_AD1986_MBC_20 0x0000 /* +20dB */ +#define AC97_AD1986_MBC_10 0x0001 /* +10dB */ +#define AC97_AD1986_MBC_30 0x0002 /* +30dB */ +#define AC97_AD1986_LISEL0 0x0004 /* LINE_IN select bit 0 */ +#define AC97_AD1986_LISEL1 0x0008 /* LINE_IN select bit 1 */ +#define AC97_AD1986_LISEL_MASK (AC97_AD1986_LISEL1 | AC97_AD1986_LISEL0) +#define AC97_AD1986_LISEL_LI 0x0000 /* LINE_IN pins as LINE_IN source */ +#define AC97_AD1986_LISEL_SURR 0x0004 /* SURROUND pins as LINE_IN source */ +#define AC97_AD1986_LISEL_MIC 0x0008 /* MIC_1/2 pins as LINE_IN source */ +#define AC97_AD1986_SRU 0x0010 /* sample rate unlock */ +#define AC97_AD1986_SOSEL 0x0020 /* SURROUND_OUT amplifiers input sel */ +#define AC97_AD1986_2MIC 0x0040 /* 2-channel mic select */ +#define AC97_AD1986_SPRD 0x0080 /* SPREAD enable */ +#define AC97_AD1986_DMIX0 0x0100 /* downmix mode: */ + /* 0 = 6-to-4, 1 = 6-to-2 downmix */ +#define AC97_AD1986_DMIX1 0x0200 /* downmix mode: 1 = enabled */ +#define AC97_AD1986_CLDIS 0x0800 /* center/lfe disable */ +#define AC97_AD1986_SODIS 0x1000 /* SURROUND_OUT disable */ +#define AC97_AD1986_MSPLT 0x2000 /* mute split (read only 1) */ +#define AC97_AD1986_AC97NC 0x4000 /* AC97 no compatible mode (r/o 1) */ +#define AC97_AD1986_DACZ 0x8000 /* DAC zero-fill mode */ + +/* MISC 2 bits (AD1986 register 0x70) */ +#define AC97_AD_MISC2 0x70 /* Misc Control Bits 2 (AD1986) */ + +#define AC97_AD1986_CVREF0 0x0004 /* C/LFE VREF_OUT 2.25V */ +#define AC97_AD1986_CVREF1 0x0008 /* C/LFE VREF_OUT 0V */ +#define AC97_AD1986_CVREF2 0x0010 /* C/LFE VREF_OUT 3.7V */ +#define AC97_AD1986_CVREF_MASK \ + (AC97_AD1986_CVREF2 | AC97_AD1986_CVREF1 | AC97_AD1986_CVREF0) +#define AC97_AD1986_JSMAP 0x0020 /* Jack Sense Mapping 1 = alternate */ +#define AC97_AD1986_MMDIS 0x0080 /* Mono Mute Disable */ +#define AC97_AD1986_MVREF0 0x0400 /* MIC VREF_OUT 2.25V */ +#define AC97_AD1986_MVREF1 0x0800 /* MIC VREF_OUT 0V */ +#define AC97_AD1986_MVREF2 0x1000 /* MIC VREF_OUT 3.7V */ +#define AC97_AD1986_MVREF_MASK \ + (AC97_AD1986_MVREF2 | AC97_AD1986_MVREF1 | AC97_AD1986_MVREF0) + +/* MISC 3 bits (AD1986 register 0x7a) */ +#define AC97_AD_MISC3 0x7a /* Misc Control Bits 3 (AD1986) */ + +#define AC97_AD1986_MMIX 0x0004 /* Mic Mix, left/right */ +#define AC97_AD1986_GPO 0x0008 /* General Purpose Out */ +#define AC97_AD1986_LOHPEN 0x0010 /* LINE_OUT headphone drive */ +#define AC97_AD1986_LVREF0 0x0100 /* LINE_OUT VREF_OUT 2.25V */ +#define AC97_AD1986_LVREF1 0x0200 /* LINE_OUT VREF_OUT 0V */ +#define AC97_AD1986_LVREF2 0x0400 /* LINE_OUT VREF_OUT 3.7V */ +#define AC97_AD1986_LVREF_MASK \ + (AC97_AD1986_LVREF2 | AC97_AD1986_LVREF1 | AC97_AD1986_LVREF0) +#define AC97_AD1986_JSINVA 0x0800 /* Jack Sense Invert SENSE_A */ +#define AC97_AD1986_LOSEL 0x1000 /* LINE_OUT amplifiers input select */ +#define AC97_AD1986_HPSEL0 0x2000 /* Headphone amplifiers */ + /* input select Surround DACs */ +#define AC97_AD1986_HPSEL1 0x4000 /* Headphone amplifiers input */ + /* select C/LFE DACs */ +#define AC97_AD1986_JSINVB 0x8000 /* Jack Sense Invert SENSE_B */ + +/* Serial Config bits (AD1986 register 0x74) (incomplete) */ +#define AC97_AD1986_OMS0 0x0100 /* Optional Mic Selector bit 0 */ +#define AC97_AD1986_OMS1 0x0200 /* Optional Mic Selector bit 1 */ +#define AC97_AD1986_OMS2 0x0400 /* Optional Mic Selector bit 2 */ +#define AC97_AD1986_OMS_MASK \ + (AC97_AD1986_OMS2 | AC97_AD1986_OMS1 | AC97_AD1986_OMS0) +#define AC97_AD1986_OMS_M 0x0000 /* MIC_1/2 pins are MIC sources */ +#define AC97_AD1986_OMS_L 0x0100 /* LINE_IN pins are MIC sources */ +#define AC97_AD1986_OMS_C 0x0200 /* Center/LFE pins are MCI sources */ +#define AC97_AD1986_OMS_MC 0x0400 /* Mix of MIC and C/LFE pins */ + /* are MIC sources */ +#define AC97_AD1986_OMS_ML 0x0500 /* MIX of MIC and LINE_IN pins */ + /* are MIC sources */ +#define AC97_AD1986_OMS_LC 0x0600 /* MIX of LINE_IN and C/LFE pins */ + /* are MIC sources */ +#define AC97_AD1986_OMS_MLC 0x0700 /* MIX of MIC, LINE_IN, C/LFE pins */ + /* are MIC sources */ + static int snd_ac97_ad198x_spdif_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -1952,8 +2049,80 @@ int patch_ad1980(struct snd_ac97 * ac97) return 0; } +static int snd_ac97_ad1985_vrefout_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[4] = {"High-Z", "3.7 V", "2.25 V", "0 V"}; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 4; + if (uinfo->value.enumerated.item > 3) + uinfo->value.enumerated.item = 3; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + return 0; +} + +static int snd_ac97_ad1985_vrefout_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + static const int reg2ctrl[4] = {2, 0, 1, 3}; + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short val; + val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK) + >> AC97_AD198X_VREF_SHIFT; + ucontrol->value.enumerated.item[0] = reg2ctrl[val]; + return 0; +} + +static int snd_ac97_ad1985_vrefout_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + static const int ctrl2reg[4] = {1, 2, 0, 3}; + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short val; + + if (ucontrol->value.enumerated.item[0] > 3 + || ucontrol->value.enumerated.item[0] < 0) + return -EINVAL; + val = ctrl2reg[ucontrol->value.enumerated.item[0]] + << AC97_AD198X_VREF_SHIFT; + return snd_ac97_update_bits(ac97, AC97_AD_MISC, + AC97_AD198X_VREF_MASK, val); +} + static const struct snd_kcontrol_new snd_ac97_ad1985_controls[] = { - AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0) + AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Exchange Front/Surround", + .info = snd_ac97_ad1888_lohpsel_info, + .get = snd_ac97_ad1888_lohpsel_get, + .put = snd_ac97_ad1888_lohpsel_put + }, + AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1), + AC97_SINGLE("Spread Front to Surround and Center/LFE", + AC97_AD_MISC, 7, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Downmix", + .info = snd_ac97_ad1888_downmix_info, + .get = snd_ac97_ad1888_downmix_get, + .put = snd_ac97_ad1888_downmix_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "V_REFOUT", + .info = snd_ac97_ad1985_vrefout_info, + .get = snd_ac97_ad1985_vrefout_get, + .put = snd_ac97_ad1985_vrefout_put + }, + AC97_SURROUND_JACK_MODE_CTL, + AC97_CHANNEL_MODE_CTL, + + AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0), + AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0), }; static void ad1985_update_jacks(struct snd_ac97 *ac97) @@ -1967,9 +2136,16 @@ static int patch_ad1985_specific(struct { int err; - if ((err = patch_ad1980_specific(ac97)) < 0) + /* rename 0x04 as "Master" and 0x02 as "Master Surround" */ + snd_ac97_rename_vol_ctl(ac97, "Master Playback", + "Master Surround Playback"); + snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); + + if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) return err; - return patch_build_controls(ac97, snd_ac97_ad1985_controls, ARRAY_SIZE(snd_ac97_ad1985_controls)); + + return patch_build_controls(ac97, snd_ac97_ad1985_controls, + ARRAY_SIZE(snd_ac97_ad1985_controls)); } static struct snd_ac97_build_ops patch_ad1985_build_ops = { @@ -1989,24 +2165,311 @@ int patch_ad1985(struct snd_ac97 * ac97) ac97->build_ops = &patch_ad1985_build_ops; misc = snd_ac97_read(ac97, AC97_AD_MISC); /* switch front/surround line-out/hp-out */ - /* center/LFE, mic in 3.75V mode */ /* AD-compatible mode */ /* Stereo mutes enabled */ - /* in accordance with ADI driver: misc | 0x5c28 */ snd_ac97_write_cache(ac97, AC97_AD_MISC, misc | - AC97_AD198X_VREFH | AC97_AD198X_LOSEL | AC97_AD198X_HPSEL | - AC97_AD198X_CLDIS | - AC97_AD198X_LODIS | AC97_AD198X_MSPLT | AC97_AD198X_AC97NC); ac97->flags |= AC97_STEREO_MUTES; + + /* update current jack configuration */ + ad1985_update_jacks(ac97); + /* on AD1985 rev. 3, AC'97 revision bits are zero */ ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23; return 0; } +static int snd_ac97_ad1986_bool_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_ac97_ad1986_lososel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short val; + + val = ac97->regs[AC97_AD_MISC3]; + ucontrol->value.integer.value[0] = (val & AC97_AD1986_LOSEL) != 0; + return 0; +} + +static int snd_ac97_ad1986_lososel_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + int ret0; + int ret1; + int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0; + + ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL, + ucontrol->value.integer.value[0] != 0 + ? AC97_AD1986_LOSEL : 0); + if (ret0 < 0) + return ret0; + + /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */ + ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL, + (ucontrol->value.integer.value[0] != 0 + || sprd) + ? AC97_AD1986_SOSEL : 0); + if (ret1 < 0) + return ret1; + + return (ret0 > 0 || ret1 > 0) ? 1 : 0; +} + +static int snd_ac97_ad1986_spread_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short val; + + val = ac97->regs[AC97_AD_MISC]; + ucontrol->value.integer.value[0] = (val & AC97_AD1986_SPRD) != 0; + return 0; +} + +static int snd_ac97_ad1986_spread_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + int ret0; + int ret1; + int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0; + + ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD, + ucontrol->value.integer.value[0] != 0 + ? AC97_AD1986_SPRD : 0); + if (ret0 < 0) + return ret0; + + /* SOSEL is set to values of "Spread" or "Exchange F/S" controls */ + ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL, + (ucontrol->value.integer.value[0] != 0 + || sprd) + ? AC97_AD1986_SOSEL : 0); + if (ret1 < 0) + return ret1; + + return (ret0 > 0 || ret1 > 0) ? 1 : 0; +} + +static int snd_ac97_ad1986_miclisel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein; + return 0; +} + +static int snd_ac97_ad1986_miclisel_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned char swap = ucontrol->value.integer.value[0] != 0; + + if (swap != ac97->spec.ad18xx.swap_mic_linein) { + ac97->spec.ad18xx.swap_mic_linein = swap; + if (ac97->build_ops->update_jacks) + ac97->build_ops->update_jacks(ac97); + return 1; + } + return 0; +} + +static int snd_ac97_ad1986_vrefout_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + /* Use MIC_1/2 V_REFOUT as the "get" value */ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short val; + unsigned short reg = ac97->regs[AC97_AD_MISC2]; + if ((reg & AC97_AD1986_MVREF0) != 0) + val = 2; + else if ((reg & AC97_AD1986_MVREF1) != 0) + val = 3; + else if ((reg & AC97_AD1986_MVREF2) != 0) + val = 1; + else + val = 0; + ucontrol->value.enumerated.item[0] = val; + return 0; +} + +static int snd_ac97_ad1986_vrefout_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + unsigned short cval; + unsigned short lval; + unsigned short mval; + int cret; + int lret; + int mret; + + switch (ucontrol->value.enumerated.item[0]) + { + case 0: /* High-Z */ + cval = 0; + lval = 0; + mval = 0; + break; + case 1: /* 3.7 V */ + cval = AC97_AD1986_CVREF2; + lval = AC97_AD1986_LVREF2; + mval = AC97_AD1986_MVREF2; + break; + case 2: /* 2.25 V */ + cval = AC97_AD1986_CVREF0; + lval = AC97_AD1986_LVREF0; + mval = AC97_AD1986_MVREF0; + break; + case 3: /* 0 V */ + cval = AC97_AD1986_CVREF1; + lval = AC97_AD1986_LVREF1; + mval = AC97_AD1986_MVREF1; + break; + default: + return -EINVAL; + } + + cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2, + AC97_AD1986_CVREF_MASK, cval); + if (cret < 0) + return cret; + lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3, + AC97_AD1986_LVREF_MASK, lval); + if (lret < 0) + return lret; + mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2, + AC97_AD1986_MVREF_MASK, mval); + if (mret < 0) + return mret; + + return (cret > 0 || lret > 0 || mret > 0) ? 1 : 0; +} + +static const struct snd_kcontrol_new snd_ac97_ad1986_controls[] = { + AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Exchange Front/Surround", + .info = snd_ac97_ad1986_bool_info, + .get = snd_ac97_ad1986_lososel_get, + .put = snd_ac97_ad1986_lososel_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Exchange Mic/Line In", + .info = snd_ac97_ad1986_bool_info, + .get = snd_ac97_ad1986_miclisel_get, + .put = snd_ac97_ad1986_miclisel_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Spread Front to Surround and Center/LFE", + .info = snd_ac97_ad1986_bool_info, + .get = snd_ac97_ad1986_spread_get, + .put = snd_ac97_ad1986_spread_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Downmix", + .info = snd_ac97_ad1888_downmix_info, + .get = snd_ac97_ad1888_downmix_get, + .put = snd_ac97_ad1888_downmix_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "V_REFOUT", + .info = snd_ac97_ad1985_vrefout_info, + .get = snd_ac97_ad1986_vrefout_get, + .put = snd_ac97_ad1986_vrefout_put + }, + AC97_SURROUND_JACK_MODE_CTL, + AC97_CHANNEL_MODE_CTL, + + AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0), + AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0) +}; + +static void ad1986_update_jacks(struct snd_ac97 *ac97) +{ + unsigned short misc_val = 0; + unsigned short ser_val; + + /* disable SURROUND and CENTER/LFE if not surround mode */ + if (! is_surround_on(ac97)) + misc_val |= AC97_AD1986_SODIS; + if (! is_clfe_on(ac97)) + misc_val |= AC97_AD1986_CLDIS; + + /* select line input (default=LINE_IN, SURROUND or MIC_1/2) */ + if (is_shared_linein(ac97)) + misc_val |= AC97_AD1986_LISEL_SURR; + else if (ac97->spec.ad18xx.swap_mic_linein != 0) + misc_val |= AC97_AD1986_LISEL_MIC; + snd_ac97_update_bits(ac97, AC97_AD_MISC, + AC97_AD1986_SODIS | AC97_AD1986_CLDIS | + AC97_AD1986_LISEL_MASK, + misc_val); + + /* select microphone input (MIC_1/2, Center/LFE or LINE_IN) */ + if (is_shared_micin(ac97)) + ser_val = AC97_AD1986_OMS_C; + else if (ac97->spec.ad18xx.swap_mic_linein != 0) + ser_val = AC97_AD1986_OMS_L; + else + ser_val = AC97_AD1986_OMS_M; + snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, + AC97_AD1986_OMS_MASK, + ser_val); +} + +static int patch_ad1986_specific(struct snd_ac97 *ac97) +{ + int err; + + if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) + return err; + + return patch_build_controls(ac97, snd_ac97_ad1986_controls, + ARRAY_SIZE(snd_ac97_ad1985_controls)); +} + +static struct snd_ac97_build_ops patch_ad1986_build_ops = { + .build_post_spdif = patch_ad198x_post_spdif, + .build_specific = patch_ad1986_specific, +#ifdef CONFIG_PM + .resume = ad18xx_resume, +#endif + .update_jacks = ad1986_update_jacks, +}; + +int patch_ad1986(struct snd_ac97 * ac97) +{ + patch_ad1881(ac97); + ac97->build_ops = &patch_ad1986_build_ops; + ac97->flags |= AC97_STEREO_MUTES; + + /* update current jack configuration */ + ad1986_update_jacks(ac97); + + return 0; +} + + /* * realtek ALC65x/850 codecs */ @@ -2014,12 +2477,12 @@ static void alc650_update_jacks(struct s { int shared; - /* shared Line-In */ - shared = is_shared_linein(ac97); + /* shared Line-In / Surround Out */ + shared = is_shared_surrout(ac97); snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9, shared ? (1 << 9) : 0); - /* update shared Mic */ - shared = is_shared_micin(ac97); + /* update shared Mic In / Center/LFE Out */ + shared = is_shared_clfeout(ac97); /* disable/enable vref */ snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, shared ? (1 << 12) : 0); @@ -2149,12 +2612,12 @@ static void alc655_update_jacks(struct s { int shared; - /* shared Line-In */ - shared = is_shared_linein(ac97); + /* shared Line-In / Surround Out */ + shared = is_shared_surrout(ac97); ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9, shared ? (1 << 9) : 0, 0); - /* update shared mic */ - shared = is_shared_micin(ac97); + /* update shared Mic In / Center/LFE Out */ + shared = is_shared_clfeout(ac97); /* misc control; vrefout disable */ snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, shared ? (1 << 12) : 0); @@ -2264,7 +2727,8 @@ int patch_alc655(struct snd_ac97 * ac97) if (ac97->subsystem_vendor == 0x1462 && (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */ ac97->subsystem_device == 0x0161 || /* LG K1 Express */ - ac97->subsystem_device == 0x0351)) /* MSI L725 laptop */ + ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */ + ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */ val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ else val |= (1 << 1); /* Pin 47 is spdif input pin */ @@ -2297,16 +2761,16 @@ static void alc850_update_jacks(struct s { int shared; - /* shared Line-In */ - shared = is_shared_linein(ac97); + /* shared Line-In / Surround Out */ + shared = is_shared_surrout(ac97); /* SURR 1kOhm (bit4), Amp (bit5) */ snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5), shared ? (1<<5) : (1<<4)); /* LINE-IN = 0, SURROUND = 2 */ snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12, shared ? (2<<12) : (0<<12)); - /* update shared mic */ - shared = is_shared_micin(ac97); + /* update shared Mic In / Center/LFE Out */ + shared = is_shared_clfeout(ac97); /* Vref disable (bit12), 1kOhm (bit13) */ snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13), shared ? (1<<12) : (1<<13)); @@ -2379,9 +2843,9 @@ int patch_alc850(struct snd_ac97 *ac97) */ static void cm9738_update_jacks(struct snd_ac97 *ac97) { - /* shared Line-In */ + /* shared Line-In / Surround Out */ snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10, - is_shared_linein(ac97) ? (1 << 10) : 0); + is_shared_surrout(ac97) ? (1 << 10) : 0); } static const struct snd_kcontrol_new snd_ac97_cm9738_controls[] = { @@ -2463,12 +2927,12 @@ static const struct snd_kcontrol_new snd static void cm9739_update_jacks(struct snd_ac97 *ac97) { - /* shared Line-In */ + /* shared Line-In / Surround Out */ snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10, - is_shared_linein(ac97) ? (1 << 10) : 0); - /* shared Mic */ + is_shared_surrout(ac97) ? (1 << 10) : 0); + /* shared Mic In / Center/LFE Out **/ snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000, - is_shared_micin(ac97) ? 0x1000 : 0x2000); + is_shared_clfeout(ac97) ? 0x1000 : 0x2000); } static const struct snd_kcontrol_new snd_ac97_cm9739_controls[] = { @@ -2580,8 +3044,8 @@ static void cm9761_update_jacks(struct s val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)]; val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)]; - val |= surr_shared[ac97->spec.dev_flags][is_shared_linein(ac97)]; - val |= clfe_shared[ac97->spec.dev_flags][is_shared_micin(ac97)]; + val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)]; + val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)]; snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val); } @@ -2828,12 +3292,12 @@ int patch_vt1617a(struct snd_ac97 * ac97 */ static void it2646_update_jacks(struct snd_ac97 *ac97) { - /* shared Line-In */ + /* shared Line-In / Surround Out */ snd_ac97_update_bits(ac97, 0x76, 1 << 9, - is_shared_linein(ac97) ? (1<<9) : 0); - /* shared Mic */ + is_shared_surrout(ac97) ? (1<<9) : 0); + /* shared Mic / Center/LFE Out */ snd_ac97_update_bits(ac97, 0x76, 1 << 10, - is_shared_micin(ac97) ? (1<<10) : 0); + is_shared_clfeout(ac97) ? (1<<10) : 0); } static const struct snd_kcontrol_new snd_ac97_controls_it2646[] = { diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h index 7419792..94340da 100644 --- a/sound/pci/ac97/ac97_patch.h +++ b/sound/pci/ac97/ac97_patch.h @@ -48,6 +48,7 @@ int patch_ad1980(struct snd_ac97 * ac97) int patch_ad1981a(struct snd_ac97 * ac97); int patch_ad1981b(struct snd_ac97 * ac97); int patch_ad1985(struct snd_ac97 * ac97); +int patch_ad1986(struct snd_ac97 * ac97); int patch_alc650(struct snd_ac97 * ac97); int patch_alc655(struct snd_ac97 * ac97); int patch_alc850(struct snd_ac97 * ac97); diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 9f406fb..8afcb98 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -444,7 +444,7 @@ static int snd_als300_capture_close(stru } static int snd_als300_pcm_hw_params(struct snd_pcm_substream *substream, - snd_pcm_hw_params_t * hw_params) + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); @@ -673,7 +673,7 @@ static void snd_als300_init(struct snd_a snd_als300_dbgcallleave(); } -static int __devinit snd_als300_create(snd_card_t *card, +static int __devinit snd_als300_create(struct snd_card *card, struct pci_dev *pci, int chip_type, struct snd_als300 **rchip) { @@ -681,7 +681,7 @@ static int __devinit snd_als300_create(s void *irq_handler; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_als300_dev_free, }; *rchip = NULL; diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 476c343..7d8053b 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -45,6 +45,7 @@ static char *id = SNDRV_DEFAULT_STR1; /* static int ac97_clock = 48000; static char *ac97_quirk; static int spdif_aclink = 1; +static int ac97_codec = -1; module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for ATI IXP controller."); @@ -54,6 +55,8 @@ module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); +module_param(ac97_codec, int, 0444); +MODULE_PARM_DESC(ac97_codec, "Specify codec instead of probing."); module_param(spdif_aclink, bool, 0444); MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); @@ -293,6 +296,10 @@ static struct pci_device_id snd_atiixp_i MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); +static struct snd_pci_quirk atiixp_quirks[] __devinitdata = { + SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0), + { } /* terminator */ +}; /* * lowlevel functions @@ -553,11 +560,33 @@ #define ALL_CODEC_NOT_READY \ ATI_REG_ISR_CODEC2_NOT_READY) #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) +static int ac97_probing_bugs(struct pci_dev *pci) +{ + const struct snd_pci_quirk *q; + + q = snd_pci_quirk_lookup(pci, atiixp_quirks); + if (q) { + snd_printdd(KERN_INFO "Atiixp quirk for %s. " + "Forcing codec %d\n", q->name, q->value); + return q->value; + } + /* this hardware doesn't need workarounds. Probe for codec */ + return -1; +} + static int snd_atiixp_codec_detect(struct atiixp *chip) { int timeout; chip->codec_not_ready_bits = 0; + if (ac97_codec == -1) + ac97_codec = ac97_probing_bugs(chip->pci); + if (ac97_codec >= 0) { + chip->codec_not_ready_bits |= + CODEC_CHECK_BITS ^ (1 << (ac97_codec + 10)); + return 0; + } + atiixp_write(chip, IER, CODEC_CHECK_BITS); /* wait for the interrupts */ timeout = 50; @@ -1396,7 +1425,7 @@ static int __devinit snd_atiixp_mixer_ne ac97.private_data = chip; ac97.pci = chip->pci; ac97.num = i; - ac97.scaps = AC97_SCAP_SKIP_MODEM; + ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; if (! chip->spdif_over_aclink) ac97.scaps |= AC97_SCAP_NO_SPDIF; if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index cc2e6b9..904023f 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1090,7 +1090,7 @@ static int __devinit snd_atiixp_mixer_ne ac97.private_data = chip; ac97.pci = chip->pci; ac97.num = i; - ac97.scaps = AC97_SCAP_SKIP_AUDIO; + ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { chip->ac97[i] = NULL; /* to be sure */ snd_printdd("atiixp-modem: codec %d not available for modem\n", i); diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index f61f052..6f781b8 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1382,7 +1382,6 @@ #endif snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */ chip->spdif_enable = 0; /* Set digital SPDIF output off */ - chip->capture_source = 3; /* Set CAPTURE_SOURCE */ //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ //snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00); /* Digital out */ @@ -1402,8 +1401,22 @@ #endif snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */ snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); /* Mute */ } - snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ - chip->capture_source = 3; /* Set CAPTURE_SOURCE */ + if (chip->details->i2c_adc == 1) { + /* Select MIC, Line in, TAD in, AUX in */ + snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); + /* Default to CAPTURE_SOURCE to i2s in */ + chip->capture_source = 3; + } else if (chip->details->ac97 == 1) { + /* Default to AC97 in */ + snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4); + /* Default to CAPTURE_SOURCE to AC97 in */ + chip->capture_source = 4; + } else { + /* Select MIC, Line in, TAD in, AUX in */ + snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); + /* Default to Set CAPTURE_SOURCE to i2s in */ + chip->capture_source = 3; + } if (chip->details->gpio_type == 2) { /* The SB0438 use GPIO differently. */ /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 9855f52..289f78a 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -482,19 +482,6 @@ #define CA_VOLUME(xname,chid,reg) \ .private_value = ((chid) << 8) | (reg) \ } -#define I2C_VOLUME(xname,chid) \ -{ \ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ - SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ - .info = snd_ca0106_i2c_volume_info, \ - .get = snd_ca0106_i2c_volume_get, \ - .put = snd_ca0106_i2c_volume_put, \ - .tlv = { .p = snd_ca0106_db_scale2 }, \ - .private_value = chid \ -} - - static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { CA_VOLUME("Analog Front Playback Volume", CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), @@ -517,11 +504,6 @@ static struct snd_kcontrol_new snd_ca010 CA_VOLUME("CAPTURE feedback Playback Volume", 1, CAPTURE_CONTROL), - I2C_VOLUME("Phone Capture Volume", 0), - I2C_VOLUME("Mic Capture Volume", 1), - I2C_VOLUME("Line in Capture Volume", 2), - I2C_VOLUME("Aux Capture Volume", 3), - { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -539,14 +521,14 @@ static struct snd_kcontrol_new snd_ca010 }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Digital Capture Source", + .name = "Digital Source Capture Enum", .info = snd_ca0106_capture_source_info, .get = snd_ca0106_capture_source_get, .put = snd_ca0106_capture_source_put }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Capture Source", + .name = "Analog Source Capture Enum", .info = snd_ca0106_i2c_capture_source_info, .get = snd_ca0106_i2c_capture_source_get, .put = snd_ca0106_i2c_capture_source_put @@ -561,6 +543,25 @@ static struct snd_kcontrol_new snd_ca010 }, }; +#define I2C_VOLUME(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ + SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ + .info = snd_ca0106_i2c_volume_info, \ + .get = snd_ca0106_i2c_volume_get, \ + .put = snd_ca0106_i2c_volume_put, \ + .tlv = { .p = snd_ca0106_db_scale2 }, \ + .private_value = chid \ +} + +static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata = { + I2C_VOLUME("Phone Capture Volume", 0), + I2C_VOLUME("Mic Capture Volume", 1), + I2C_VOLUME("Line in Capture Volume", 2), + I2C_VOLUME("Aux Capture Volume", 3), +}; + static int __devinit remove_ctl(struct snd_card *card, const char *name) { struct snd_ctl_elem_id id; @@ -645,6 +646,11 @@ #endif return err; } if (emu->details->i2c_adc == 1) { + for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_i2c_adc_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_i2c_adc_ctls[i], emu)); + if (err < 0) + return err; + } if (emu->details->gpio_type == 1) err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)); else /* gpio_type == 2 */ diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 71c58df..70face7 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2198,7 +2198,8 @@ static int _snd_cmipci_uswitch_put(struc val = inb(cm->iobase + args->reg); else val = snd_cmipci_read(cm, args->reg); - change = (val & args->mask) != (ucontrol->value.integer.value[0] ? args->mask : 0); + change = (val & args->mask) != (ucontrol->value.integer.value[0] ? + args->mask_on : (args->mask & ~args->mask_on)); if (change) { val &= ~args->mask; if (ucontrol->value.integer.value[0]) diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c index b7108e2..8e7fe03 100644 --- a/sound/pci/echoaudio/darla20.c +++ b/sound/pci/echoaudio/darla20.c @@ -47,6 +47,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c index e59a982..a13c623 100644 --- a/sound/pci/echoaudio/darla24.c +++ b/sound/pci/echoaudio/darla24.c @@ -51,6 +51,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c index 12099fe..8fb1582 100644 --- a/sound/pci/echoaudio/echo3g.c +++ b/sound/pci/echoaudio/echo3g.c @@ -58,6 +58,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 047e0b5..3410bd4 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -34,6 +34,7 @@ module_param_array(enable, bool, NULL, 0 MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard."); static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; +static DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1); static int get_firmware(const struct firmware **fw_entry, const struct firmware *frm, struct echoaudio *chip) @@ -1011,17 +1012,21 @@ #ifdef ECHOCARD_HAS_VMIXER static struct snd_kcontrol_new snd_echo_line_output_gain __devinitdata = { .name = "Line Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_output_gain_info, .get = snd_echo_output_gain_get, .put = snd_echo_output_gain_put, + .tlv = {.p = db_scale_output_gain}, }; #else static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = { .name = "PCM Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_output_gain_info, .get = snd_echo_output_gain_get, .put = snd_echo_output_gain_put, + .tlv = {.p = db_scale_output_gain}, }; #endif @@ -1080,12 +1085,16 @@ static int snd_echo_input_gain_put(struc return changed; } +static DECLARE_TLV_DB_SCALE(db_scale_input_gain, -2500, 50, 0); + static struct snd_kcontrol_new snd_echo_line_input_gain __devinitdata = { .name = "Line Capture Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_input_gain_info, .get = snd_echo_input_gain_get, .put = snd_echo_input_gain_put, + .tlv = {.p = db_scale_input_gain}, }; #endif /* ECHOCARD_HAS_INPUT_GAIN */ @@ -1277,9 +1286,11 @@ static int snd_echo_mixer_put(struct snd static struct snd_kcontrol_new snd_echo_monitor_mixer __devinitdata = { .name = "Monitor Mixer Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_mixer_info, .get = snd_echo_mixer_get, .put = snd_echo_mixer_put, + .tlv = {.p = db_scale_output_gain}, }; #endif /* ECHOCARD_HAS_MONITOR */ @@ -1343,9 +1354,11 @@ static int snd_echo_vmixer_put(struct sn static struct snd_kcontrol_new snd_echo_vmixer __devinitdata = { .name = "VMixer Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_vmixer_info, .get = snd_echo_vmixer_get, .put = snd_echo_vmixer_put, + .tlv = {.p = db_scale_output_gain}, }; #endif /* ECHOCARD_HAS_VMIXER */ @@ -1753,9 +1766,12 @@ static int snd_echo_vumeters_get(struct static struct snd_kcontrol_new snd_echo_vumeters __devinitdata = { .name = "VU-meters", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, + .access = SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ, .info = snd_echo_vumeters_info, .get = snd_echo_vumeters_get, + .tlv = {.p = db_scale_output_gain}, }; diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c index 29d6d12..af4d320 100644 --- a/sound/pci/echoaudio/gina20.c +++ b/sound/pci/echoaudio/gina20.c @@ -51,6 +51,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c index e464d72..9ff454a 100644 --- a/sound/pci/echoaudio/gina24.c +++ b/sound/pci/echoaudio/gina24.c @@ -57,6 +57,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c index bfd2467..37eb726 100644 --- a/sound/pci/echoaudio/indigo.c +++ b/sound/pci/echoaudio/indigo.c @@ -49,6 +49,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c index 8ed7ff1..dc8b918 100644 --- a/sound/pci/echoaudio/indigodj.c +++ b/sound/pci/echoaudio/indigodj.c @@ -49,6 +49,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c index a8788e9..eadf326 100644 --- a/sound/pci/echoaudio/indigoio.c +++ b/sound/pci/echoaudio/indigoio.c @@ -50,6 +50,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c index e503d74..6cede49 100644 --- a/sound/pci/echoaudio/layla20.c +++ b/sound/pci/echoaudio/layla20.c @@ -56,6 +56,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c index d4581fd..44f7354 100644 --- a/sound/pci/echoaudio/layla24.c +++ b/sound/pci/echoaudio/layla24.c @@ -58,6 +58,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c index be40c64..dc172d0 100644 --- a/sound/pci/echoaudio/mia.c +++ b/sound/pci/echoaudio/mia.c @@ -56,6 +56,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c index e31f0f1..91f5bff 100644 --- a/sound/pci/echoaudio/midi.c +++ b/sound/pci/echoaudio/midi.c @@ -213,7 +213,7 @@ static void snd_echo_midi_output_write(u sent = bytes = 0; spin_lock_irqsave(&chip->lock, flags); chip->midi_full = 0; - if (chip->midi_out && !snd_rawmidi_transmit_empty(chip->midi_out)) { + if (!snd_rawmidi_transmit_empty(chip->midi_out)) { bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf, MIDI_OUT_BUFFER_SIZE - 1); DE_MID(("Try to send %d bytes...\n", bytes)); @@ -264,9 +264,11 @@ static void snd_echo_midi_output_trigger } } else { if (chip->tinuse) { - del_timer(&chip->timer); chip->tinuse = 0; + spin_unlock_irq(&chip->lock); + del_timer_sync(&chip->timer); DE_MID(("Timer removed\n")); + return; } } spin_unlock_irq(&chip->lock); diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c index 5dc512a..c856ed5 100644 --- a/sound/pci/echoaudio/mona.c +++ b/sound/pci/echoaudio/mona.c @@ -55,6 +55,7 @@ #include #include #include #include +#include #include #include #include diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 972ec40..80aa585 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -3,8 +3,10 @@ * Creative Labs, Inc. * Routines for control of EMU10K1 chips * - * Copyright (c) by James Courtier-Dutton + * Copyright (c) by James Courtier-Dutton * Added support for Audigy 2 Value. + * Added EMU 1010 support. + * General bug fixes and enhancements. * * * BUGS: @@ -41,8 +43,10 @@ #include #include #include +#include #include "p16v.h" #include "tina2.h" +#include "p17v.h" /************************************************************************* @@ -117,11 +121,28 @@ static unsigned int spi_dac_init[] = { 0x0622, 0x1400, }; + +static unsigned int i2c_adc_init[][2] = { + { 0x17, 0x00 }, /* Reset */ + { 0x07, 0x00 }, /* Timeout */ + { 0x0b, 0x22 }, /* Interface control */ + { 0x0c, 0x22 }, /* Master mode control */ + { 0x0d, 0x08 }, /* Powerdown control */ + { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */ + { 0x0f, 0xcf }, /* Attenuation Right 0.5dB steps */ + { 0x10, 0x7b }, /* ALC Control 1 */ + { 0x11, 0x00 }, /* ALC Control 2 */ + { 0x12, 0x32 }, /* ALC Control 3 */ + { 0x13, 0x00 }, /* Noise gate control */ + { 0x14, 0xa6 }, /* Limiter control */ + { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for Audigy 2 ZS Notebook */ +}; static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) { unsigned int silent_page; int ch; + u32 tmp; /* disable audio and lock cache */ outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, @@ -160,8 +181,6 @@ static int snd_emu10k1_init(struct snd_e if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ /* Hacks for Alice3 to work independent of haP16V driver */ - u32 tmp; - //Setup SRCMulti_I2S SamplingRate tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); tmp &= 0xfffff1ff; @@ -181,8 +200,6 @@ static int snd_emu10k1_init(struct snd_e } if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ /* Hacks for Alice3 to work independent of haP16V driver */ - u32 tmp; - snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); //Setup SRCMulti_I2S SamplingRate tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); @@ -211,7 +228,7 @@ static int snd_emu10k1_init(struct snd_e int size, n; size = ARRAY_SIZE(spi_dac_init); - for (n=0; n < size; n++) + for (n = 0; n < size; n++) snd_emu10k1_spi_write(emu, spi_dac_init[n]); snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); @@ -228,6 +245,23 @@ static int snd_emu10k1_init(struct snd_e outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */ } + if (emu->card_capabilities->i2c_adc) { /* Audigy 2 ZS Notebook with ADC Wolfson WM8775 */ + int size, n; + + snd_emu10k1_ptr20_write(emu, P17V_I2S_SRC_SEL, 0, 0x2020205f); + tmp = inl(emu->port + A_IOCFG); + outl(tmp | 0x4, emu->port + A_IOCFG); /* Set bit 2 for mic input */ + tmp = inl(emu->port + A_IOCFG); + size = ARRAY_SIZE(i2c_adc_init); + for (n = 0; n < size; n++) + snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]); + for (n=0; n < 4; n++) { + emu->i2c_capture_volume[n][0]= 0xcf; + emu->i2c_capture_volume[n][1]= 0xcf; + } + + } + snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ @@ -239,6 +273,10 @@ static int snd_emu10k1_init(struct snd_e snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page); } + if (emu->card_capabilities->emu1010) { + outl(HCFG_AUTOMUTE_ASYNC | + HCFG_EMU32_SLAVE | + HCFG_AUDIOENABLE, emu->port + HCFG); /* * Hokay, setup HCFG * Mute Disable Audio = 0 @@ -246,7 +284,7 @@ static int snd_emu10k1_init(struct snd_e * Lock Sound Memory = 0 * Auto Mute = 1 */ - if (emu->audigy) { + } else if (emu->audigy) { if (emu->revision == 4) /* audigy2 */ outl(HCFG_AUDIOENABLE | HCFG_AC3ENABLE_CDSPDIF | @@ -265,8 +303,10 @@ static int snd_emu10k1_init(struct snd_e outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); if (enable_ir) { /* enable IR for SB Live */ - if ( emu->card_capabilities->emu1212m) { - ; /* Disable all access to A_IOCFG for the emu1212m */ + if (emu->card_capabilities->emu1010) { + ; /* Disable all access to A_IOCFG for the emu1010 */ + } else if (emu->card_capabilities->i2c_adc) { + ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ } else if (emu->audigy) { unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); @@ -284,8 +324,10 @@ static int snd_emu10k1_init(struct snd_e } } - if ( emu->card_capabilities->emu1212m) { - ; /* Disable all access to A_IOCFG for the emu1212m */ + if (emu->card_capabilities->emu1010) { + ; /* Disable all access to A_IOCFG for the emu1010 */ + } else if (emu->card_capabilities->i2c_adc) { + ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ } else if (emu->audigy) { /* enable analog output */ unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); @@ -302,8 +344,10 @@ static void snd_emu10k1_audio_enable(str outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG); /* Enable analog/digital outs on audigy */ - if ( emu->card_capabilities->emu1212m) { - ; /* Disable all access to A_IOCFG for the emu1212m */ + if (emu->card_capabilities->emu1010) { + ; /* Disable all access to A_IOCFG for the emu1010 */ + } else if (emu->card_capabilities->i2c_adc) { + ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ } else if (emu->audigy) { outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); @@ -596,133 +640,423 @@ static int snd_emu10k1_cardbus_init(stru return 0; } -static int snd_emu1212m_fpga_write(struct snd_emu10k1 * emu, int reg, int value) +static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) { - if (reg<0 || reg>0x3f) - return 1; - reg+=0x40; /* 0x40 upwards are registers. */ - if (value<0 || value>0x3f) /* 0 to 0x3f are values */ - return 1; - outl(reg, emu->port + A_IOCFG); - outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ - outl(value, emu->port + A_IOCFG); - outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ - - return 0; -} - -static int snd_emu1212m_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) -{ - if (reg<0 || reg>0x3f) - return 1; - reg+=0x40; /* 0x40 upwards are registers. */ - outl(reg, emu->port + A_IOCFG); - outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ - *value = inl(emu->port + A_IOCFG); - - return 0; -} + int err; + int n, i; + int reg; + int value; + const struct firmware *fw_entry; + + if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) { + snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err); + return err; + } + snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); + if (fw_entry->size != 0x133a4) { + snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename); + return -EINVAL; + } -static int snd_emu1212m_fpga_netlist_write(struct snd_emu10k1 * emu, int reg, int value) -{ - snd_emu1212m_fpga_write(emu, 0x00, ((reg >> 8) & 0x3f) ); - snd_emu1212m_fpga_write(emu, 0x01, (reg & 0x3f) ); - snd_emu1212m_fpga_write(emu, 0x02, ((value >> 8) & 0x3f) ); - snd_emu1212m_fpga_write(emu, 0x03, (value & 0x3f) ); + /* The FPGA is a Xilinx Spartan IIE XC2S50E */ + /* GPIO7 -> FPGA PGMN + * GPIO6 -> FPGA CCLK + * GPIO5 -> FPGA DIN + * FPGA CONFIG OFF -> FPGA PGMN + */ + outl(0x00, emu->port + A_IOCFG); /* Set PGMN low for 1uS. */ + udelay(1); + outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */ + udelay(100); /* Allow FPGA memory to clean */ + for(n = 0; n < fw_entry->size; n++) { + value=fw_entry->data[n]; + for(i = 0; i < 8; i++) { + reg = 0x80; + if (value & 0x1) + reg = reg | 0x20; + value = value >> 1; + outl(reg, emu->port + A_IOCFG); + outl(reg | 0x40, emu->port + A_IOCFG); + } + } + /* After programming, set GPIO bit 4 high again. */ + outl(0x10, emu->port + A_IOCFG); + + release_firmware(fw_entry); return 0; } -static int snd_emu10k1_emu1212m_init(struct snd_emu10k1 * emu) +static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) { unsigned int i; - int tmp; - - snd_printk(KERN_ERR "emu1212m: Special config.\n"); + int tmp,tmp2; + int reg; + int err; + const char *hana_filename = "emu/hana.fw"; + const char *dock_filename = "emu/audio_dock.fw"; + + snd_printk(KERN_INFO "emu1010: Special config.\n"); + /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, + * Lock Sound Memory Cache, Lock Tank Memory Cache, + * Mute all codecs. + */ outl(0x0005a00c, emu->port + HCFG); - outl(0x0005a004, emu->port + HCFG); + /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, + * Lock Tank Memory Cache, + * Mute all codecs. + */ + outl(0x0005a004, emu->port + HCFG); + /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, + * Mute all codecs. + */ outl(0x0005a000, emu->port + HCFG); + /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, + * Mute all codecs. + */ outl(0x0005a000, emu->port + HCFG); - snd_emu1212m_fpga_read(emu, 0x22, &tmp ); - snd_emu1212m_fpga_read(emu, 0x23, &tmp ); - snd_emu1212m_fpga_read(emu, 0x24, &tmp ); - snd_emu1212m_fpga_write(emu, 0x04, 0x01 ); - snd_emu1212m_fpga_read(emu, 0x0b, &tmp ); - snd_emu1212m_fpga_write(emu, 0x0b, 0x01 ); - snd_emu1212m_fpga_read(emu, 0x10, &tmp ); - snd_emu1212m_fpga_write(emu, 0x10, 0x00 ); - snd_emu1212m_fpga_read(emu, 0x11, &tmp ); - snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); - snd_emu1212m_fpga_read(emu, 0x13, &tmp ); - snd_emu1212m_fpga_write(emu, 0x13, 0x0f ); - snd_emu1212m_fpga_read(emu, 0x11, &tmp ); - snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); - snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); - snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); - snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); - snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); - snd_emu1212m_fpga_write(emu, 0x09, 0x0f ); - snd_emu1212m_fpga_write(emu, 0x06, 0x00 ); - snd_emu1212m_fpga_write(emu, 0x05, 0x00 ); - snd_emu1212m_fpga_write(emu, 0x0e, 0x12 ); - snd_emu1212m_fpga_netlist_write(emu, 0x0000, 0x0200); - snd_emu1212m_fpga_netlist_write(emu, 0x0001, 0x0201); - snd_emu1212m_fpga_netlist_write(emu, 0x0002, 0x0500); - snd_emu1212m_fpga_netlist_write(emu, 0x0003, 0x0501); - snd_emu1212m_fpga_netlist_write(emu, 0x0004, 0x0400); - snd_emu1212m_fpga_netlist_write(emu, 0x0005, 0x0401); - snd_emu1212m_fpga_netlist_write(emu, 0x0006, 0x0402); - snd_emu1212m_fpga_netlist_write(emu, 0x0007, 0x0403); - snd_emu1212m_fpga_netlist_write(emu, 0x0008, 0x0404); - snd_emu1212m_fpga_netlist_write(emu, 0x0009, 0x0405); - snd_emu1212m_fpga_netlist_write(emu, 0x000a, 0x0406); - snd_emu1212m_fpga_netlist_write(emu, 0x000b, 0x0407); - snd_emu1212m_fpga_netlist_write(emu, 0x000c, 0x0100); - snd_emu1212m_fpga_netlist_write(emu, 0x000d, 0x0104); - snd_emu1212m_fpga_netlist_write(emu, 0x000e, 0x0200); - snd_emu1212m_fpga_netlist_write(emu, 0x000f, 0x0201); - for (i=0;i < 0x20;i++) { - snd_emu1212m_fpga_netlist_write(emu, 0x0100+i, 0x0000); + /* Disable 48Volt power to Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); + + /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ + snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); + snd_printdd("reg1=0x%x\n",reg); + if (reg == 0x55) { + /* FPGA netlist already present so clear it */ + /* Return to programming mode */ + + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 ); } - for (i=0;i < 4;i++) { - snd_emu1212m_fpga_netlist_write(emu, 0x0200+i, 0x0000); + snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); + snd_printdd("reg2=0x%x\n",reg); + if (reg == 0x55) { + /* FPGA failed to return to programming mode */ + return -ENODEV; } - for (i=0;i < 7;i++) { - snd_emu1212m_fpga_netlist_write(emu, 0x0300+i, 0x0000); + snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); + if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { + snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); + return err; } - for (i=0;i < 7;i++) { - snd_emu1212m_fpga_netlist_write(emu, 0x0400+i, 0x0000); + + /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ + snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); + if (reg != 0x55) { + /* FPGA failed to be programmed */ + snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); + return -ENODEV; } - snd_emu1212m_fpga_netlist_write(emu, 0x0500, 0x0108); - snd_emu1212m_fpga_netlist_write(emu, 0x0501, 0x010c); - snd_emu1212m_fpga_netlist_write(emu, 0x0600, 0x0110); - snd_emu1212m_fpga_netlist_write(emu, 0x0601, 0x0114); - snd_emu1212m_fpga_netlist_write(emu, 0x0700, 0x0118); - snd_emu1212m_fpga_netlist_write(emu, 0x0701, 0x011c); - snd_emu1212m_fpga_write(emu, 0x07, 0x01 ); - snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); + snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp ); + snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 ); + snd_printk("Hana ver:%d.%d\n",tmp ,tmp2); + /* Enable 48Volt power to Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON ); + + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); + snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); + snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); + snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); + /* ADAT input. */ + snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 ); + snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); + /* Set no attenuation on Audio Dock pads. */ + snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); + emu->emu1010.adc_pads = 0x00; + snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); + /* Unmute Audio dock DACs, Headphone source DAC-4. */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); + snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp ); + /* DAC PADs. */ + snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f ); + emu->emu1010.dac_pads = 0x0f; + snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); + snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); + /* SPDIF Format. Set Consumer mode, 24bit, copy enable */ + snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); + /* MIDI routing */ + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); + /* Unknown. */ + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); + /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */ + /* IRQ Enable: All off */ + snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 ); + + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); + snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg); + /* Default WCLK set to 48kHz. */ + snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 ); + /* Word Clock source, Internal 48kHz x1 */ + snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); + //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); + /* Audio Dock LEDs. */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); - outl(0x0000a000, emu->port + HCFG); +#if 0 + /* For 96kHz */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2); +#endif +#if 0 + /* For 192kHz */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4); +#endif +#if 1 + /* For 48kHz */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1); +#endif +#if 0 + /* Original */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2); +#endif + for (i = 0;i < 0x20; i++ ) { + /* AudioDock Elink <- Silence */ + snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE); + } + for (i = 0;i < 4; i++) { + /* Hana SPDIF Out <- Silence */ + snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE); + } + for (i = 0;i < 7; i++) { + /* Hamoa DAC <- Silence */ + snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE); + } + for (i = 0;i < 7; i++) { + /* Hana ADAT Out <- Silence */ + snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE); + } + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1); + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1); + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all + + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); + + /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, + * Lock Sound Memory Cache, Lock Tank Memory Cache, + * Mute all codecs. + */ + outl(0x0000a000, emu->port + HCFG); + /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, + * Lock Sound Memory Cache, Lock Tank Memory Cache, + * Un-Mute all codecs. + */ outl(0x0000a001, emu->port + HCFG); + /* Initial boot complete. Now patches */ - snd_emu1212m_fpga_read(emu, 0x21, &tmp ); - snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); - snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); - snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); - snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); - snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); - snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); - - snd_emu1212m_fpga_read(emu, 0x20, &tmp ); - snd_emu1212m_fpga_read(emu, 0x21, &tmp ); - - snd_emu1212m_fpga_netlist_write(emu, 0x0300, 0x0312); - snd_emu1212m_fpga_netlist_write(emu, 0x0301, 0x0313); - snd_emu1212m_fpga_netlist_write(emu, 0x0200, 0x0302); - snd_emu1212m_fpga_netlist_write(emu, 0x0201, 0x0303); + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ + snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ + snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); + snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ + + /* Delay to allow Audio Dock to settle */ + msleep(100); + snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ + snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); /* OPTIONS: Which cards are attached to the EMU */ + /* FIXME: The loading of this should be able to happen any time, + * as the user can plug/unplug it at any time + */ + if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) { + /* Audio Dock attached */ + /* Return to Audio Dock programming mode */ + snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); + if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) { + return err; + } + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); + snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ® ); + snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); + /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ + snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); + snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); + if (reg != 0x55) { + /* FPGA failed to be programmed */ + snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); + return 0; + return -ENODEV; + } + snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); + snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); + snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); + snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); + } +#if 0 + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3); /* ALICE2 bus 0xa3 */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2); /* ALICE2 bus 0xb2 */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); /* ALICE2 bus 0xb3 */ +#endif + /* Default outputs */ + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[0] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[1] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2); + emu->emu1010.output_source[2] = 23; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); + emu->emu1010.output_source[3] = 24; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4); + emu->emu1010.output_source[4] = 25; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5); + emu->emu1010.output_source[5] = 26; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6); + emu->emu1010.output_source[6] = 27; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7); + emu->emu1010.output_source[7] = 28; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[8] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[9] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[10] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[11] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[12] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[13] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[14] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[15] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ + emu->emu1010.output_source[16] = 21; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1); + emu->emu1010.output_source[17] = 22; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2); + emu->emu1010.output_source[18] = 23; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3); + emu->emu1010.output_source[19] = 24; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4); + emu->emu1010.output_source[20] = 25; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5); + emu->emu1010.output_source[21] = 26; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6); + emu->emu1010.output_source[22] = 27; + snd_emu1010_fpga_link_dst_src_write(emu, + EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7); + emu->emu1010.output_source[23] = 28; + + /* TEMP: Select SPDIF in/out */ + snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ + + /* TEMP: Select 48kHz SPDIF out */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */ + /* Word Clock source, Internal 48kHz x1 */ + snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); + //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); + emu->emu1010.internal_clock = 1; /* 48000 */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */ + //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */ + //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */ + //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */ return 0; } @@ -747,6 +1081,10 @@ static int snd_emu10k1_free(struct snd_e } snd_emu10k1_free_efx(emu); } + if (emu->card_capabilities->emu1010) { + /* Disable 48Volt power to Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); + } if (emu->memhdr) snd_util_memhdr_free(emu->memhdr); if (emu->silent_page.area) @@ -838,10 +1176,11 @@ static struct snd_emu_chip_details emu_c .adc_1361t = 1, /* 24 bit capture instead of 16bit */ .ac97_chip = 1} , /* Audigy 2 ZS Notebook Cardbus card.*/ - /* Tested by James@superbug.co.uk 22th December 2005 */ + /* Tested by James@superbug.co.uk 6th November 2006 */ /* Audio output 7.1/Headphones working. * Digital output working. (AC3 not checked, only PCM) - * Audio inputs not tested. + * Audio Mic/Line inputs working. + * Digital input not tested. */ /* DSP: Tina2 * DAC: Wolfson WM8768/WM8568 @@ -849,6 +1188,25 @@ static struct snd_emu_chip_details emu_c * AC97: None * CA0151: None */ + /* Tested by James@superbug.co.uk 4th April 2006 */ + /* A_IOCFG bits + * Output + * 0: Not Used + * 1: 0 = Mute all the 7.1 channel out. 1 = unmute. + * 2: Analog input 0 = line in, 1 = mic in + * 3: Not Used + * 4: Digital output 0 = off, 1 = on. + * 5: Not Used + * 6: Not Used + * 7: Not Used + * Input + * All bits 1 (0x3fxx) means nothing plugged in. + * 8-9: 0 = Line in/Mic, 2 = Optical in, 3 = Nothing. + * A-B: 0 = Headphones, 2 = Optical out, 3 = Nothing. + * C-D: 2 = Front/Rear/etc, 3 = nothing. + * E-F: Always 0 + * + */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", .id = "Audigy2", @@ -856,6 +1214,7 @@ static struct snd_emu_chip_details emu_c .ca0108_chip = 1, .ca_cardbus_chip = 1, .spi_dac = 1, + .i2c_adc = 1, .spk71 = 1} , {.vendor = 0x1102, .device = 0x0008, .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", @@ -865,11 +1224,12 @@ static struct snd_emu_chip_details emu_c .ac97_chip = 1} , /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, - .driver = "Audigy2", .name = "E-mu 1212m [4001]", - .id = "EMU1212m", + .driver = "Audigy2", .name = "E-mu 1010 [4001]", + .id = "EMU1010", .emu10k2_chip = 1, .ca0102_chip = 1, - .emu1212m = 1} , + .spk71 = 1, + .emu1010 = 1} , /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", @@ -1297,8 +1657,8 @@ int __devinit snd_emu10k1_create(struct } else if (emu->card_capabilities->ca_cardbus_chip) { if ((err = snd_emu10k1_cardbus_init(emu)) < 0) goto error; - } else if (emu->card_capabilities->emu1212m) { - if ((err = snd_emu10k1_emu1212m_init(emu)) < 0) { + } else if (emu->card_capabilities->emu1010) { + if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { snd_emu10k1_free(emu); return err; } @@ -1446,8 +1806,8 @@ void snd_emu10k1_resume_init(struct snd_ snd_emu10k1_ecard_init(emu); else if (emu->card_capabilities->ca_cardbus_chip) snd_emu10k1_cardbus_init(emu); - else if (emu->card_capabilities->emu1212m) - snd_emu10k1_emu1212m_init(emu); + else if (emu->card_capabilities->emu1010) + snd_emu10k1_emu1010_init(emu); else snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); snd_emu10k1_init(emu, emu->enable_ir, 1); diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 2199b42..bb0fec7 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -460,7 +460,7 @@ static int snd_emu10k1x_pcm_prepare(stru u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); int i; - for(i=0; i < runtime->periods; i++) { + for(i = 0; i < runtime->periods; i++) { *table_base++=runtime->dma_addr+(i*period_size_bytes); *table_base++=period_size_bytes<<16; } @@ -1042,8 +1042,8 @@ static void snd_emu10k1x_proc_reg_write( if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) continue; - if ((reg < 0x49) && (reg >=0) && (val <= 0xffffffff) - && (channel_id >=0) && (channel_id <= 2) ) + if ((reg < 0x49) && (reg >= 0) && (val <= 0xffffffff) + && (channel_id >= 0) && (channel_id <= 2) ) snd_emu10k1x_ptr_write(emu, reg, channel_id, val); } } diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 13cd6ce..d8e8db8 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -3,6 +3,9 @@ * Creative Labs, Inc. * Routines for effect processor FX8010 * + * Copyright (c) by James Courtier-Dutton + * Added EMU 1010 support. + * * BUGS: * -- * @@ -1069,6 +1072,21 @@ snd_emu10k1_init_stereo_onoff_control(st ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; } +static int snd_emu10k1_audigy_dsp_convert_32_to_2x16( + struct snd_emu10k1_fx8010_code *icode, + u32 *ptr, int tmp, int bit_shifter16, + int reg_in, int reg_out) +{ + A_OP(icode, ptr, iACC3, A_GPR(tmp + 1), reg_in, A_C_00000000, A_C_00000000); + A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp + 1), A_GPR(bit_shifter16 - 1), A_C_00000000); + A_OP(icode, ptr, iTSTNEG, A_GPR(tmp + 2), A_GPR(tmp), A_C_80000000, A_GPR(bit_shifter16 - 2)); + A_OP(icode, ptr, iANDXOR, A_GPR(tmp + 2), A_GPR(tmp + 2), A_C_80000000, A_C_00000000); + A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp), A_GPR(bit_shifter16 - 3), A_C_00000000); + A_OP(icode, ptr, iMACINT0, A_GPR(tmp), A_C_00000000, A_GPR(tmp), A_C_00010000); + A_OP(icode, ptr, iANDXOR, reg_out, A_GPR(tmp), A_C_ffffffff, A_GPR(tmp + 2)); + A_OP(icode, ptr, iACC3, reg_out + 1, A_GPR(tmp + 1), A_C_00000000, A_C_00000000); + return 1; +} /* * initial DSP configuration for Audigy @@ -1077,6 +1095,7 @@ snd_emu10k1_init_stereo_onoff_control(st static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) { int err, i, z, gpr, nctl; + int bit_shifter16; const int playback = 10; const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */ const int stereo_mix = capture + 2; @@ -1114,17 +1133,14 @@ static int __devinit _snd_emu10k1_audigy ptr = 0; nctl = 0; gpr = stereo_mix + 10; + gpr_map[gpr++] = 0x00007fff; + gpr_map[gpr++] = 0x00008000; + gpr_map[gpr++] = 0x0000ffff; + bit_shifter16 = gpr; /* stop FX processor */ snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); -#if 0 - /* FIX: jcd test */ - for (z = 0; z < 80; z=z+2) { - A_OP(icode, &ptr, iACC3, A_EXTOUT(z), A_FXBUS(FXBUS_PCM_LEFT_FRONT), A_C_00000000, A_C_00000000); /* left */ - A_OP(icode, &ptr, iACC3, A_EXTOUT(z+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT), A_C_00000000, A_C_00000000); /* right */ - } -#endif /* jcd test */ #if 1 /* PCM front Playback Volume (independent from stereo mix) */ A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); @@ -1182,13 +1198,20 @@ #if 1 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT)); snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0); gpr += 2; - + /* * inputs */ #define A_ADD_VOLUME_IN(var,vol,input) \ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) + /* emu1212 DSP 0 and DSP 1 Capture */ + if (emu->card_capabilities->emu1010) { + A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0)); + A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_P16VIN(0x1)); + snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0); + gpr += 2; + } /* AC'97 Playback Volume - used only for mic (renamed later) */ A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AC97_L); A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AC97_R); @@ -1429,6 +1452,13 @@ #undef TREBLE_GPR /* digital outputs */ /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ + if (emu->card_capabilities->emu1010) { + /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ + snd_printk("EMU outputs on\n"); + for (z = 0; z < 8; z++) { + A_OP(icode, &ptr, iACC3, A_EMU32OUTL(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000); + } + } /* IEC958 Optical Raw Playback Switch */ gpr_map[gpr++] = 0; @@ -1466,9 +1496,57 @@ #else A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_R, capture+1); #endif - /* EFX capture - capture the 16 EXTINs */ - for (z = 0; z < 16; z++) { - A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); + if (emu->card_capabilities->emu1010) { + snd_printk("EMU inputs on\n"); + /* Capture 8 channels of S32_LE sound */ + + /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */ + /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ + /* A_P16VIN(0) is delayed by one sample, + * so all other A_P16VIN channels will need to also be delayed + */ + /* Left ADC in. 1 of 2 */ + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) ); + /* Right ADC in 1 of 2 */ + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000); + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(4) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000); + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(6) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000); + /* For 96kHz mode */ + /* Left ADC in. 2 of 2 */ + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0x8) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000); + /* Right ADC in 2 of 2 */ + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xa) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000); + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xc) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000); + gpr_map[gpr++] = 0x00000000; + snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) ); + A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000); + +#if 0 + for (z = 4; z < 8; z++) { + A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000); + } + for (z = 0xc; z < 0x10; z++) { + A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000); + } +#endif + } else { + /* EFX capture - capture the 16 EXTINs */ + /* Capture 16 channels of S16_LE sound */ + for (z = 0; z < 16; z++) { + A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); + } } #endif /* JCD test */ @@ -2138,7 +2216,7 @@ void snd_emu10k1_free_efx(struct snd_emu snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg = EMU10K1_DBG_SINGLE_STEP); } -#if 0 // FIXME: who use them? +#if 0 /* FIXME: who use them? */ int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output) { if (output < 0 || output >= 6) diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index c31f3d0..0469546 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -5,6 +5,9 @@ * Routines for control of EMU10K1 chips / mixer routines * Multichannel PCM support Copyright (c) Lee Revell * + * Copyright (c) by James Courtier-Dutton + * Added EMU 1010 support. + * * BUGS: * -- * @@ -32,9 +35,15 @@ #include #include #include #include +#include +#include + +#include "p17v.h" #define AC97_ID_STAC9758 0x83847658 +static DECLARE_TLV_DB_SCALE(snd_audigy_db_scale2, -10350, 50, 1); /* WM8775 gain scale */ + static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; @@ -68,6 +77,669 @@ static int snd_emu10k1_spdif_get_mask(st return 0; } +static char *emu1010_src_texts[] = { + "Silence", + "Dock Mic A", + "Dock Mic B", + "Dock ADC1 Left", + "Dock ADC1 Right", + "Dock ADC2 Left", + "Dock ADC2 Right", + "Dock ADC3 Left", + "Dock ADC3 Right", + "0202 ADC Left", + "0202 ADC Right", + "0202 SPDIF Left", + "0202 SPDIF Right", + "ADAT 0", + "ADAT 1", + "ADAT 2", + "ADAT 3", + "ADAT 4", + "ADAT 5", + "ADAT 6", + "ADAT 7", + "DSP 0", + "DSP 1", + "DSP 2", + "DSP 3", + "DSP 4", + "DSP 5", + "DSP 6", + "DSP 7", + "DSP 8", + "DSP 9", + "DSP 10", + "DSP 11", + "DSP 12", + "DSP 13", + "DSP 14", + "DSP 15", + "DSP 16", + "DSP 17", + "DSP 18", + "DSP 19", + "DSP 20", + "DSP 21", + "DSP 22", + "DSP 23", + "DSP 24", + "DSP 25", + "DSP 26", + "DSP 27", + "DSP 28", + "DSP 29", + "DSP 30", + "DSP 31", +}; + +static unsigned int emu1010_src_regs[] = { + EMU_SRC_SILENCE,/* 0 */ + EMU_SRC_DOCK_MIC_A1, /* 1 */ + EMU_SRC_DOCK_MIC_B1, /* 2 */ + EMU_SRC_DOCK_ADC1_LEFT1, /* 3 */ + EMU_SRC_DOCK_ADC1_RIGHT1, /* 4 */ + EMU_SRC_DOCK_ADC2_LEFT1, /* 5 */ + EMU_SRC_DOCK_ADC2_RIGHT1, /* 6 */ + EMU_SRC_DOCK_ADC3_LEFT1, /* 7 */ + EMU_SRC_DOCK_ADC3_RIGHT1, /* 8 */ + EMU_SRC_HAMOA_ADC_LEFT1, /* 9 */ + EMU_SRC_HAMOA_ADC_RIGHT1, /* 10 */ + EMU_SRC_HANA_SPDIF_LEFT1, /* 11 */ + EMU_SRC_HANA_SPDIF_RIGHT1, /* 12 */ + EMU_SRC_HANA_ADAT, /* 13 */ + EMU_SRC_HANA_ADAT+1, /* 14 */ + EMU_SRC_HANA_ADAT+2, /* 15 */ + EMU_SRC_HANA_ADAT+3, /* 16 */ + EMU_SRC_HANA_ADAT+4, /* 17 */ + EMU_SRC_HANA_ADAT+5, /* 18 */ + EMU_SRC_HANA_ADAT+6, /* 19 */ + EMU_SRC_HANA_ADAT+7, /* 20 */ + EMU_SRC_ALICE_EMU32A, /* 21 */ + EMU_SRC_ALICE_EMU32A+1, /* 22 */ + EMU_SRC_ALICE_EMU32A+2, /* 23 */ + EMU_SRC_ALICE_EMU32A+3, /* 24 */ + EMU_SRC_ALICE_EMU32A+4, /* 25 */ + EMU_SRC_ALICE_EMU32A+5, /* 26 */ + EMU_SRC_ALICE_EMU32A+6, /* 27 */ + EMU_SRC_ALICE_EMU32A+7, /* 28 */ + EMU_SRC_ALICE_EMU32A+8, /* 29 */ + EMU_SRC_ALICE_EMU32A+9, /* 30 */ + EMU_SRC_ALICE_EMU32A+0xa, /* 31 */ + EMU_SRC_ALICE_EMU32A+0xb, /* 32 */ + EMU_SRC_ALICE_EMU32A+0xc, /* 33 */ + EMU_SRC_ALICE_EMU32A+0xd, /* 34 */ + EMU_SRC_ALICE_EMU32A+0xe, /* 35 */ + EMU_SRC_ALICE_EMU32A+0xf, /* 36 */ + EMU_SRC_ALICE_EMU32B, /* 37 */ + EMU_SRC_ALICE_EMU32B+1, /* 38 */ + EMU_SRC_ALICE_EMU32B+2, /* 39 */ + EMU_SRC_ALICE_EMU32B+3, /* 40 */ + EMU_SRC_ALICE_EMU32B+4, /* 41 */ + EMU_SRC_ALICE_EMU32B+5, /* 42 */ + EMU_SRC_ALICE_EMU32B+6, /* 43 */ + EMU_SRC_ALICE_EMU32B+7, /* 44 */ + EMU_SRC_ALICE_EMU32B+8, /* 45 */ + EMU_SRC_ALICE_EMU32B+9, /* 46 */ + EMU_SRC_ALICE_EMU32B+0xa, /* 47 */ + EMU_SRC_ALICE_EMU32B+0xb, /* 48 */ + EMU_SRC_ALICE_EMU32B+0xc, /* 49 */ + EMU_SRC_ALICE_EMU32B+0xd, /* 50 */ + EMU_SRC_ALICE_EMU32B+0xe, /* 51 */ + EMU_SRC_ALICE_EMU32B+0xf, /* 52 */ +}; + +static unsigned int emu1010_output_dst[] = { + EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ + EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ + EMU_DST_DOCK_DAC2_LEFT1, /* 2 */ + EMU_DST_DOCK_DAC2_RIGHT1, /* 3 */ + EMU_DST_DOCK_DAC3_LEFT1, /* 4 */ + EMU_DST_DOCK_DAC3_RIGHT1, /* 5 */ + EMU_DST_DOCK_DAC4_LEFT1, /* 6 */ + EMU_DST_DOCK_DAC4_RIGHT1, /* 7 */ + EMU_DST_DOCK_PHONES_LEFT1, /* 8 */ + EMU_DST_DOCK_PHONES_RIGHT1, /* 9 */ + EMU_DST_DOCK_SPDIF_LEFT1, /* 10 */ + EMU_DST_DOCK_SPDIF_RIGHT1, /* 11 */ + EMU_DST_HANA_SPDIF_LEFT1, /* 12 */ + EMU_DST_HANA_SPDIF_RIGHT1, /* 13 */ + EMU_DST_HAMOA_DAC_LEFT1, /* 14 */ + EMU_DST_HAMOA_DAC_RIGHT1, /* 15 */ + EMU_DST_HANA_ADAT, /* 16 */ + EMU_DST_HANA_ADAT+1, /* 17 */ + EMU_DST_HANA_ADAT+2, /* 18 */ + EMU_DST_HANA_ADAT+3, /* 19 */ + EMU_DST_HANA_ADAT+4, /* 20 */ + EMU_DST_HANA_ADAT+5, /* 21 */ + EMU_DST_HANA_ADAT+6, /* 22 */ + EMU_DST_HANA_ADAT+7, /* 23 */ +}; + +static unsigned int emu1010_input_dst[] = { + EMU_DST_ALICE2_EMU32_0, + EMU_DST_ALICE2_EMU32_1, + EMU_DST_ALICE2_EMU32_2, + EMU_DST_ALICE2_EMU32_3, + EMU_DST_ALICE2_EMU32_4, + EMU_DST_ALICE2_EMU32_5, + EMU_DST_ALICE2_EMU32_6, + EMU_DST_ALICE2_EMU32_7, + EMU_DST_ALICE2_EMU32_8, + EMU_DST_ALICE2_EMU32_9, + EMU_DST_ALICE2_EMU32_A, + EMU_DST_ALICE2_EMU32_B, + EMU_DST_ALICE2_EMU32_C, + EMU_DST_ALICE2_EMU32_D, + EMU_DST_ALICE2_EMU32_E, + EMU_DST_ALICE2_EMU32_F, + EMU_DST_ALICE_I2S0_LEFT, + EMU_DST_ALICE_I2S0_RIGHT, + EMU_DST_ALICE_I2S1_LEFT, + EMU_DST_ALICE_I2S1_RIGHT, + EMU_DST_ALICE_I2S2_LEFT, + EMU_DST_ALICE_I2S2_RIGHT, +}; + +static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 53; + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, emu1010_src_texts[uinfo->value.enumerated.item]); + return 0; +} + +static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int channel; + + channel = (kcontrol->private_value) & 0xff; + ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel]; + return 0; +} + +static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int change = 0; + unsigned int val; + int channel; + + channel = (kcontrol->private_value) & 0xff; + if (emu->emu1010.output_source[channel] != ucontrol->value.enumerated.item[0]) { + val = emu->emu1010.output_source[channel] = ucontrol->value.enumerated.item[0]; + change = 1; + snd_emu1010_fpga_link_dst_src_write(emu, + emu1010_output_dst[channel], emu1010_src_regs[val]); + } + return change; +} + +static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int channel; + + channel = (kcontrol->private_value) & 0xff; + ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel]; + return 0; +} + +static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int change = 0; + unsigned int val; + int channel; + + channel = (kcontrol->private_value) & 0xff; + if (emu->emu1010.input_source[channel] != ucontrol->value.enumerated.item[0]) { + val = emu->emu1010.input_source[channel] = ucontrol->value.enumerated.item[0]; + change = 1; + snd_emu1010_fpga_link_dst_src_write(emu, + emu1010_input_dst[channel], emu1010_src_regs[val]); + } + return change; +} + +#define EMU1010_SOURCE_OUTPUT(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .info = snd_emu1010_input_output_source_info, \ + .get = snd_emu1010_output_source_get, \ + .put = snd_emu1010_output_source_put, \ + .private_value = chid \ +} + +static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] __devinitdata = { + EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0), + EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1), + EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Enum", 2), + EMU1010_SOURCE_OUTPUT("Dock DAC2 Right Playback Enum", 3), + EMU1010_SOURCE_OUTPUT("Dock DAC3 Left Playback Enum", 4), + EMU1010_SOURCE_OUTPUT("Dock DAC3 Right Playback Enum", 5), + EMU1010_SOURCE_OUTPUT("Dock DAC4 Left Playback Enum", 6), + EMU1010_SOURCE_OUTPUT("Dock DAC4 Right Playback Enum", 7), + EMU1010_SOURCE_OUTPUT("Dock Phones Left Playback Enum", 8), + EMU1010_SOURCE_OUTPUT("Dock Phones Right Playback Enum", 9), + EMU1010_SOURCE_OUTPUT("Dock SPDIF Left Playback Enum", 0xa), + EMU1010_SOURCE_OUTPUT("Dock SPDIF Right Playback Enum", 0xb), + EMU1010_SOURCE_OUTPUT("1010 SPDIF Left Playback Enum", 0xc), + EMU1010_SOURCE_OUTPUT("1010 SPDIF Right Playback Enum", 0xd), + EMU1010_SOURCE_OUTPUT("0202 DAC Left Playback Enum", 0xe), + EMU1010_SOURCE_OUTPUT("0202 DAC Right Playback Enum", 0xf), + EMU1010_SOURCE_OUTPUT("1010 ADAT 0 Playback Enum", 0x10), + EMU1010_SOURCE_OUTPUT("1010 ADAT 1 Playback Enum", 0x11), + EMU1010_SOURCE_OUTPUT("1010 ADAT 2 Playback Enum", 0x12), + EMU1010_SOURCE_OUTPUT("1010 ADAT 3 Playback Enum", 0x13), + EMU1010_SOURCE_OUTPUT("1010 ADAT 4 Playback Enum", 0x14), + EMU1010_SOURCE_OUTPUT("1010 ADAT 5 Playback Enum", 0x15), + EMU1010_SOURCE_OUTPUT("1010 ADAT 6 Playback Enum", 0x16), + EMU1010_SOURCE_OUTPUT("1010 ADAT 7 Playback Enum", 0x17), +}; + +#define EMU1010_SOURCE_INPUT(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .info = snd_emu1010_input_output_source_info, \ + .get = snd_emu1010_input_source_get, \ + .put = snd_emu1010_input_source_put, \ + .private_value = chid \ +} + +static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] __devinitdata = { + EMU1010_SOURCE_INPUT("DSP 0 Capture Enum", 0), + EMU1010_SOURCE_INPUT("DSP 1 Capture Enum", 1), + EMU1010_SOURCE_INPUT("DSP 2 Capture Enum", 2), + EMU1010_SOURCE_INPUT("DSP 3 Capture Enum", 3), + EMU1010_SOURCE_INPUT("DSP 4 Capture Enum", 4), + EMU1010_SOURCE_INPUT("DSP 5 Capture Enum", 5), + EMU1010_SOURCE_INPUT("DSP 6 Capture Enum", 6), + EMU1010_SOURCE_INPUT("DSP 7 Capture Enum", 7), + EMU1010_SOURCE_INPUT("DSP 8 Capture Enum", 8), + EMU1010_SOURCE_INPUT("DSP 9 Capture Enum", 9), + EMU1010_SOURCE_INPUT("DSP A Capture Enum", 0xa), + EMU1010_SOURCE_INPUT("DSP B Capture Enum", 0xb), + EMU1010_SOURCE_INPUT("DSP C Capture Enum", 0xc), + EMU1010_SOURCE_INPUT("DSP D Capture Enum", 0xd), + EMU1010_SOURCE_INPUT("DSP E Capture Enum", 0xe), + EMU1010_SOURCE_INPUT("DSP F Capture Enum", 0xf), + EMU1010_SOURCE_INPUT("DSP 10 Capture Enum", 0x10), + EMU1010_SOURCE_INPUT("DSP 11 Capture Enum", 0x11), + EMU1010_SOURCE_INPUT("DSP 12 Capture Enum", 0x12), + EMU1010_SOURCE_INPUT("DSP 13 Capture Enum", 0x13), + EMU1010_SOURCE_INPUT("DSP 14 Capture Enum", 0x14), + EMU1010_SOURCE_INPUT("DSP 15 Capture Enum", 0x15), +}; + + + + +static int snd_emu1010_adc_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_emu1010_adc_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int mask = kcontrol->private_value & 0xff; + ucontrol->value.integer.value[0] = (emu->emu1010.adc_pads & mask) ? 1 : 0; + return 0; +} + +static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int mask = kcontrol->private_value & 0xff; + unsigned int val, cache; + val = ucontrol->value.integer.value[0]; + cache = emu->emu1010.adc_pads; + if (val == 1) + cache = cache | mask; + else + cache = cache & ~mask; + if (cache != emu->emu1010.adc_pads) { + snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, cache ); + emu->emu1010.adc_pads = cache; + } + + return 0; +} + + + +#define EMU1010_ADC_PADS(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .info = snd_emu1010_adc_pads_info, \ + .get = snd_emu1010_adc_pads_get, \ + .put = snd_emu1010_adc_pads_put, \ + .private_value = chid \ +} + +static struct snd_kcontrol_new snd_emu1010_adc_pads[] __devinitdata = { + EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1), + EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2), + EMU1010_ADC_PADS("ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3), + EMU1010_ADC_PADS("ADC1 14dB PAD 0202 Capture Switch", EMU_HANA_0202_ADC_PAD1), +}; + +static int snd_emu1010_dac_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_emu1010_dac_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int mask = kcontrol->private_value & 0xff; + ucontrol->value.integer.value[0] = (emu->emu1010.dac_pads & mask) ? 1 : 0; + return 0; +} + +static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int mask = kcontrol->private_value & 0xff; + unsigned int val, cache; + val = ucontrol->value.integer.value[0]; + cache = emu->emu1010.dac_pads; + if (val == 1) + cache = cache | mask; + else + cache = cache & ~mask; + if (cache != emu->emu1010.dac_pads) { + snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, cache ); + emu->emu1010.dac_pads = cache; + } + + return 0; +} + + + +#define EMU1010_DAC_PADS(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .info = snd_emu1010_dac_pads_info, \ + .get = snd_emu1010_dac_pads_get, \ + .put = snd_emu1010_dac_pads_put, \ + .private_value = chid \ +} + +static struct snd_kcontrol_new snd_emu1010_dac_pads[] __devinitdata = { + EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1), + EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2), + EMU1010_DAC_PADS("DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3), + EMU1010_DAC_PADS("DAC4 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD4), + EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1), +}; + + +static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[2] = { + "44100", "48000" + }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 2; + if (uinfo->value.enumerated.item > 1) + uinfo->value.enumerated.item = 1; + strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); + return 0; +} + +static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + + ucontrol->value.enumerated.item[0] = emu->emu1010.internal_clock; + return 0; +} + +static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int val; + int change = 0; + + val = ucontrol->value.enumerated.item[0] ; + change = (emu->emu1010.internal_clock != val); + if (change) { + emu->emu1010.internal_clock = val; + switch (val) { + case 0: + /* 44100 */ + /* Mute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); + /* Default fallback clock 48kHz */ + snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K ); + /* Word Clock source, Internal 44.1kHz x1 */ + snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, + EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X ); + /* Set LEDs on Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, + EMU_HANA_DOCK_LEDS_2_44K | EMU_HANA_DOCK_LEDS_2_LOCK ); + /* Allow DLL to settle */ + msleep(10); + /* Unmute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); + break; + case 1: + /* 48000 */ + /* Mute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); + /* Default fallback clock 48kHz */ + snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K ); + /* Word Clock source, Internal 48kHz x1 */ + snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, + EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X ); + /* Set LEDs on Audio Dock */ + snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, + EMU_HANA_DOCK_LEDS_2_48K | EMU_HANA_DOCK_LEDS_2_LOCK ); + /* Allow DLL to settle */ + msleep(10); + /* Unmute all */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); + break; + } + } + return change; +} + +static struct snd_kcontrol_new snd_emu1010_internal_clock = +{ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Clock Internal Rate", + .count = 1, + .info = snd_emu1010_internal_clock_info, + .get = snd_emu1010_internal_clock_get, + .put = snd_emu1010_internal_clock_put +}; + +static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ +#if 0 + static char *texts[4] = { + "Unknown1", "Unknown2", "Mic", "Line" + }; +#endif + static char *texts[2] = { + "Mic", "Line" + }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 2; + if (uinfo->value.enumerated.item > 1) + uinfo->value.enumerated.item = 1; + strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); + return 0; +} + +static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + + ucontrol->value.enumerated.item[0] = emu->i2c_capture_source; + return 0; +} + +static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int source_id; + unsigned int ngain, ogain; + u32 gpio; + int change = 0; + unsigned long flags; + u32 source; + /* If the capture source has changed, + * update the capture volume from the cached value + * for the particular source. + */ + source_id = ucontrol->value.enumerated.item[0]; /* Use 2 and 3 */ + change = (emu->i2c_capture_source != source_id); + if (change) { + snd_emu10k1_i2c_write(emu, ADC_MUX, 0); /* Mute input */ + spin_lock_irqsave(&emu->emu_lock, flags); + gpio = inl(emu->port + A_IOCFG); + if (source_id==0) + outl(gpio | 0x4, emu->port + A_IOCFG); + else + outl(gpio & ~0x4, emu->port + A_IOCFG); + spin_unlock_irqrestore(&emu->emu_lock, flags); + + ngain = emu->i2c_capture_volume[source_id][0]; /* Left */ + ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */ + if (ngain != ogain) + snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff)); + ngain = emu->i2c_capture_volume[source_id][1]; /* Right */ + ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Right */ + if (ngain != ogain) + snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff)); + + source = 1 << (source_id + 2); + snd_emu10k1_i2c_write(emu, ADC_MUX, source); /* Set source */ + emu->i2c_capture_source = source_id; + } + return change; +} + +static struct snd_kcontrol_new snd_audigy_i2c_capture_source = +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = snd_audigy_i2c_capture_source_info, + .get = snd_audigy_i2c_capture_source_get, + .put = snd_audigy_i2c_capture_source_put +}; + +static int snd_audigy_i2c_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 255; + return 0; +} + +static int snd_audigy_i2c_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + int source_id; + + source_id = kcontrol->private_value; + + ucontrol->value.integer.value[0] = emu->i2c_capture_volume[source_id][0]; + ucontrol->value.integer.value[1] = emu->i2c_capture_volume[source_id][1]; + return 0; +} + +static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + unsigned int ogain; + unsigned int ngain; + int source_id; + int change = 0; + + source_id = kcontrol->private_value; + ogain = emu->i2c_capture_volume[source_id][0]; /* Left */ + ngain = ucontrol->value.integer.value[0]; + if (ngain > 0xff) + return 0; + if (ogain != ngain) { + if (emu->i2c_capture_source == source_id) + snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff) ); + emu->i2c_capture_volume[source_id][0] = ucontrol->value.integer.value[0]; + change = 1; + } + ogain = emu->i2c_capture_volume[source_id][1]; /* Right */ + ngain = ucontrol->value.integer.value[1]; + if (ngain > 0xff) + return 0; + if (ogain != ngain) { + if (emu->i2c_capture_source == source_id) + snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff)); + emu->i2c_capture_volume[source_id][1] = ucontrol->value.integer.value[1]; + change = 1; + } + + return change; +} + +#define I2C_VOLUME(xname,chid) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ + SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ + .info = snd_audigy_i2c_volume_info, \ + .get = snd_audigy_i2c_volume_get, \ + .put = snd_audigy_i2c_volume_put, \ + .tlv = { .p = snd_audigy_db_scale2 }, \ + .private_value = chid \ +} + + +static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] __devinitdata = { + I2C_VOLUME("Mic Capture Volume", 0), + I2C_VOLUME("Line Capture Volume", 0) +}; + #if 0 static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -668,7 +1340,9 @@ static int snd_emu10k1_shared_spdif_put( int change = 0; spin_lock_irqsave(&emu->reg_lock, flags); - if (emu->audigy) { + if ( emu->card_capabilities->i2c_adc) { + /* Do nothing for Audigy 2 ZS Notebook */ + } else if (emu->audigy) { reg = inl(emu->port + A_IOCFG); val = ucontrol->value.integer.value[0] ? A_IOCFG_GPOUT0 : 0; change = (reg & A_IOCFG_GPOUT0) != val; @@ -806,6 +1480,24 @@ int __devinit snd_emu10k1_mixer(struct s "AMic Playback Volume", "Mic Playback Volume", NULL }; + static char *audigy_rename_ctls_i2c_adc[] = { + //"Analog Mix Capture Volume","OLD Analog Mix Capture Volume", + "Line Capture Volume", "Analog Mix Capture Volume", + "Wave Playback Volume", "OLD PCM Playback Volume", + "Wave Master Playback Volume", "Master Playback Volume", + "AMic Playback Volume", "Old Mic Playback Volume", + "CD Capture Volume", "IEC958 Optical Capture Volume", + NULL + }; + static char *audigy_remove_ctls_i2c_adc[] = { + /* On the Audigy2 ZS Notebook + * Capture via WM8775 */ + "Mic Capture Volume", + "Analog Mix Capture Volume", + "Aux Capture Volume", + "IEC958 Optical Capture Volume", + NULL + }; static char *audigy_remove_ctls_1361t_adc[] = { /* On the Audigy2 the AC97 playback is piped into * the Philips ADC for 24bit capture */ @@ -898,6 +1590,10 @@ int __devinit snd_emu10k1_mixer(struct s } for (; *c; c++) remove_ctl(card, *c); + } else if (emu->card_capabilities->i2c_adc) { + c = audigy_remove_ctls_i2c_adc; + for (; *c; c++) + remove_ctl(card, *c); } else { no_ac97: if (emu->card_capabilities->ecard) @@ -911,6 +1607,8 @@ int __devinit snd_emu10k1_mixer(struct s if (emu->audigy) if (emu->card_capabilities->adc_1361t) c = audigy_rename_ctls_1361t_adc; + else if (emu->card_capabilities->i2c_adc) + c = audigy_rename_ctls_i2c_adc; else c = audigy_rename_ctls; else @@ -1021,7 +1719,7 @@ int __devinit snd_emu10k1_mixer(struct s return err; } - if ( emu->card_capabilities->emu1212m) { + if ( emu->card_capabilities->emu1010) { ; /* Disable the snd_audigy_spdif_shared_spdif */ } else if (emu->audigy) { if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL) @@ -1045,6 +1743,48 @@ #endif if ((err = snd_p16v_mixer(emu))) return err; } + + if ( emu->card_capabilities->emu1010) { + int i; + + for (i = 0; i < ARRAY_SIZE(snd_emu1010_output_enum_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_output_enum_ctls[i], emu)); + if (err < 0) + return err; + } + for (i = 0; i < ARRAY_SIZE(snd_emu1010_input_enum_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_input_enum_ctls[i], emu)); + if (err < 0) + return err; + } + for (i = 0; i < ARRAY_SIZE(snd_emu1010_adc_pads); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_adc_pads[i], emu)); + if (err < 0) + return err; + } + for (i = 0; i < ARRAY_SIZE(snd_emu1010_dac_pads); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_dac_pads[i], emu)); + if (err < 0) + return err; + } + err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_internal_clock, emu)); + if (err < 0) + return err; + } + + if ( emu->card_capabilities->i2c_adc) { + int i; + + err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_i2c_capture_source, emu)); + if (err < 0) + return err; + + for (i = 0; i < ARRAY_SIZE(snd_audigy_i2c_volume_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_i2c_volume_ctls[i], emu)); + if (err < 0) + return err; + } + } return 0; } diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 717e92e..ab4f5df 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -147,7 +147,7 @@ static int snd_emu10k1_pcm_channel_alloc 1, &epcm->extra); if (err < 0) { - // printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); + /* printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); */ for (i = 0; i < voices; i++) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); epcm->voices[i] = NULL; @@ -339,7 +339,7 @@ static void snd_emu10k1_pcm_init_voice(s } } - // setup routing + /* setup routing */ if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXRT1, voice, snd_emu10k1_compose_audigy_fxrt1(send_routing)); @@ -353,12 +353,15 @@ static void snd_emu10k1_pcm_init_voice(s } else snd_emu10k1_ptr_write(emu, FXRT, voice, snd_emu10k1_compose_send_routing(send_routing)); - // Stop CA - // Assumption that PT is already 0 so no harm overwriting + /* Stop CA */ + /* Assumption that PT is already 0 so no harm overwriting */ snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]); snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24)); snd_emu10k1_ptr_write(emu, PSST, voice, start_addr | (send_amount[2] << 24)); - pitch_target = emu10k1_calc_pitch_target(runtime->rate); + if (emu->card_capabilities->emu1010) + pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ + else + pitch_target = emu10k1_calc_pitch_target(runtime->rate); if (extra) snd_emu10k1_ptr_write(emu, CCCA, voice, start_addr | emu10k1_select_interprom(pitch_target) | @@ -367,14 +370,14 @@ static void snd_emu10k1_pcm_init_voice(s snd_emu10k1_ptr_write(emu, CCCA, voice, (start_addr + ccis) | emu10k1_select_interprom(pitch_target) | (w_16 ? 0 : CCCA_8BITSELECT)); - // Clear filter delay memory + /* Clear filter delay memory */ snd_emu10k1_ptr_write(emu, Z1, voice, 0); snd_emu10k1_ptr_write(emu, Z2, voice, 0); - // invalidate maps + /* invalidate maps */ silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK; snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page); snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page); - // modulation envelope + /* modulation envelope */ snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); snd_emu10k1_ptr_write(emu, ATKHLDM, voice, 0); @@ -385,12 +388,12 @@ static void snd_emu10k1_pcm_init_voice(s snd_emu10k1_ptr_write(emu, TREMFRQ, voice, 0); snd_emu10k1_ptr_write(emu, FM2FRQ2, voice, 0); snd_emu10k1_ptr_write(emu, ENVVAL, voice, 0x8000); - // volume envelope + /* volume envelope */ snd_emu10k1_ptr_write(emu, ATKHLDV, voice, 0x7f7f); snd_emu10k1_ptr_write(emu, ENVVOL, voice, 0x0000); - // filter envelope + /* filter envelope */ snd_emu10k1_ptr_write(emu, PEFE_FILTERAMOUNT, voice, 0x7f); - // pitch envelope + /* pitch envelope */ snd_emu10k1_ptr_write(emu, PEFE_PITCHAMOUNT, voice, 0); spin_unlock_irqrestore(&emu->reg_lock, flags); @@ -468,7 +471,7 @@ static int snd_emu10k1_efx_playback_hw_f snd_emu10k1_voice_free(epcm->emu, epcm->extra); epcm->extra = NULL; } - for (i=0; i < NUM_EFX_PLAYBACK; i++) { + for (i = 0; i < NUM_EFX_PLAYBACK; i++) { if (epcm->voices[i]) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); epcm->voices[i] = NULL; @@ -637,7 +640,7 @@ static void snd_emu10k1_playback_invalid stereo = (!extra && runtime->channels == 2); sample = snd_pcm_format_width(runtime->format) == 16 ? 0 : 0x80808080; ccis = emu10k1_ccis(stereo, sample == 0); - // set cs to 2 * number of cache registers beside the invalidated + /* set cs to 2 * number of cache registers beside the invalidated */ cs = (sample == 0) ? (32-ccis) : (64-ccis+1) >> 1; if (cs > 16) cs = 16; for (i = 0; i < cs; i++) { @@ -646,14 +649,14 @@ static void snd_emu10k1_playback_invalid snd_emu10k1_ptr_write(emu, CD0 + i, voice + 1, sample); } } - // reset cache + /* reset cache */ snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, 0); snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice, cra); if (stereo) { snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice + 1, 0); snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice + 1, cra); } - // fill cache + /* fill cache */ snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, ccis); if (stereo) { snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice+1, ccis); @@ -698,7 +701,10 @@ static void snd_emu10k1_playback_trigger voice = evoice->number; pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8; - pitch_target = emu10k1_calc_pitch_target(runtime->rate); + if (emu->card_capabilities->emu1010) + pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ + else + pitch_target = emu10k1_calc_pitch_target(runtime->rate); snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target); if (master || evoice->epcm->type == PLAYBACK_EFX) snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target); @@ -732,7 +738,7 @@ static int snd_emu10k1_playback_trigger( struct snd_emu10k1_pcm_mixer *mix; int result = 0; - // printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); + /* printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); */ spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -778,10 +784,10 @@ static int snd_emu10k1_capture_trigger(s switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: - // hmm this should cause full and half full interrupt to be raised? + /* hmm this should cause full and half full interrupt to be raised? */ outl(epcm->capture_ipr, emu->port + IPR); snd_emu10k1_intr_enable(emu, epcm->capture_inte); - // printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); + /* printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */ switch (epcm->type) { case CAPTURE_AC97ADC: snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); @@ -790,6 +796,7 @@ static int snd_emu10k1_capture_trigger(s if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); + snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2); } else snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); break; @@ -851,7 +858,7 @@ #else /* EMU10K1 Open Source code from C ptr -= runtime->buffer_size; } #endif - // printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); + /* printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); */ return ptr; } @@ -868,7 +875,7 @@ static int snd_emu10k1_efx_playback_trig spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: - // prepare voices + /* prepare voices */ for (i = 0; i < NUM_EFX_PLAYBACK; i++) { snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]); } @@ -917,7 +924,7 @@ static snd_pcm_uframes_t snd_emu10k1_cap if (!epcm->running) return 0; if (epcm->first_ptr) { - udelay(50); // hack, it takes awhile until capture is started + udelay(50); /* hack, it takes awhile until capture is started */ epcm->first_ptr = 0; } ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff; @@ -972,6 +979,28 @@ static struct snd_pcm_hardware snd_emu10 .fifo_size = 0, }; +static struct snd_pcm_hardware snd_emu10k1_capture_efx = +{ + .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_MMAP_VALID), + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, + .rate_min = 44100, + .rate_max = 192000, + .channels_min = 8, + .channels_max = 8, + .buffer_bytes_max = (64*1024), + .period_bytes_min = 384, + .period_bytes_max = (64*1024), + .periods_min = 2, + .periods_max = 2, + .fifo_size = 0, +}; + /* * */ @@ -1016,7 +1045,7 @@ static int snd_emu10k1_efx_playback_clos struct snd_emu10k1_pcm_mixer *mix; int i; - for (i=0; i < NUM_EFX_PLAYBACK; i++) { + for (i = 0; i < NUM_EFX_PLAYBACK; i++) { mix = &emu->efx_pcm_mixer[i]; mix->epcm = NULL; snd_emu10k1_pcm_efx_mixer_notify(emu, i, 0); @@ -1045,7 +1074,7 @@ static int snd_emu10k1_efx_playback_open runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_efx_playback; - for (i=0; i < NUM_EFX_PLAYBACK; i++) { + for (i = 0; i < NUM_EFX_PLAYBACK; i++) { mix = &emu->efx_pcm_mixer[i]; mix->send_routing[0][0] = i; memset(&mix->send_volume, 0, sizeof(mix->send_volume)); @@ -1199,15 +1228,69 @@ static int snd_emu10k1_capture_efx_open( epcm->capture_idx_reg = FXIDX; substream->runtime->private_data = epcm; substream->runtime->private_free = snd_emu10k1_pcm_free_substream; - runtime->hw = snd_emu10k1_capture; + runtime->hw = snd_emu10k1_capture_efx; runtime->hw.rates = SNDRV_PCM_RATE_48000; runtime->hw.rate_min = runtime->hw.rate_max = 48000; spin_lock_irq(&emu->reg_lock); - runtime->hw.channels_min = runtime->hw.channels_max = 0; - for (idx = 0; idx < nefx; idx++) { - if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { - runtime->hw.channels_min++; - runtime->hw.channels_max++; + if (emu->card_capabilities->emu1010) { + /* TODO + * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE + * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 + * rate_min = 44100, + * rate_max = 192000, + * channels_min = 8, + * channels_max = 8, + * Need to add mixer control to fix sample rate + * + * There are 16 mono channels of 16bits each. + * 24bit Audio uses 2x channels over 16bit + * 96kHz uses 2x channels over 48kHz + * 192kHz uses 4x channels over 48kHz + * So, for 48kHz 24bit, one has 8 channels + * for 96kHz 24bit, one has 4 channels + * for 192kHz 24bit, one has 2 channels + */ +#if 1 + switch (emu->emu1010.internal_clock) { + case 0: + /* For 44.1kHz */ + runtime->hw.rates = SNDRV_PCM_RATE_44100; + runtime->hw.rate_min = runtime->hw.rate_max = 44100; + runtime->hw.channels_min = runtime->hw.channels_max = 8; + break; + case 1: + /* For 48kHz */ + runtime->hw.rates = SNDRV_PCM_RATE_48000; + runtime->hw.rate_min = runtime->hw.rate_max = 48000; + runtime->hw.channels_min = runtime->hw.channels_max = 8; + break; + }; +#endif +#if 0 + /* For 96kHz */ + runtime->hw.rates = SNDRV_PCM_RATE_96000; + runtime->hw.rate_min = runtime->hw.rate_max = 96000; + runtime->hw.channels_min = runtime->hw.channels_max = 4; +#endif +#if 0 + /* For 192kHz */ + runtime->hw.rates = SNDRV_PCM_RATE_192000; + runtime->hw.rate_min = runtime->hw.rate_max = 192000; + runtime->hw.channels_min = runtime->hw.channels_max = 2; +#endif + runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; + /* efx_voices_mask[0] is expected to be zero + * efx_voices_mask[1] is expected to have 16bits set + */ + } else { + runtime->hw.channels_min = runtime->hw.channels_max = 0; + for (idx = 0; idx < nefx; idx++) { + if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { + runtime->hw.channels_min++; + runtime->hw.channels_max++; + } } } epcm->capture_cr_val = emu->efx_voices_mask[0]; @@ -1460,7 +1543,7 @@ static void snd_emu10k1_fx8010_playback_ unsigned int count, unsigned int tram_shift) { - // printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); + /* printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */ if ((tram_shift & 1) == 0) { while (count--) { *dst_left-- = *src++; @@ -1537,7 +1620,7 @@ static int snd_emu10k1_fx8010_playback_p struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; - // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); + /* printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */ memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index b939e03..2c15859 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -3,6 +3,9 @@ * Creative Labs, Inc. * Routines for control of EMU10K1 chips / proc interface routines * + * Copyright (c) by James Courtier-Dutton + * Added EMU 1010 support. + * * BUGS: * -- * @@ -255,7 +258,7 @@ static void snd_emu10k1_proc_rates_read( unsigned int val, tmp, n; val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); tmp = (val >> 16) & 0x8; - for (n=0;n<4;n++) { + for (n = 0; n < 4; n++) { tmp = val >> (16 + (n*4)); if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]); else snd_iprintf(buffer, "Channel %d: No input\n", n); @@ -372,6 +375,27 @@ static void snd_emu10k1_proc_voices_read } #ifdef CONFIG_SND_DEBUG +static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct snd_emu10k1 *emu = entry->private_data; + unsigned long value; + unsigned long flags; + unsigned long regs; + int i; + snd_iprintf(buffer, "EMU1010 Registers:\n\n"); + + for(i = 0; i < 0x30; i+=1) { + spin_lock_irqsave(&emu->emu_lock, flags); + regs=i+0x40; /* 0x40 upwards are registers. */ + outl(regs, emu->port + A_IOCFG); + outl(regs | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + value = inl(emu->port + A_IOCFG); + spin_unlock_irqrestore(&emu->emu_lock, flags); + snd_iprintf(buffer, "%02X: %08lX, %02lX\n", i, value, (value >> 8) & 0x7f); + } +} + static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { @@ -398,7 +422,7 @@ static void snd_emu_proc_io_reg_write(st while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%x %x", ®, &val) != 2) continue; - if ((reg < 0x40) && (reg >=0) && (val <= 0xffffffff) ) { + if ((reg < 0x40) && (reg >= 0) && (val <= 0xffffffff) ) { spin_lock_irqsave(&emu->emu_lock, flags); outl(val, emu->port + (reg & 0xfffffffc)); spin_unlock_irqrestore(&emu->emu_lock, flags); @@ -474,7 +498,7 @@ static void snd_emu_proc_ptr_reg_write(s while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) continue; - if ((reg < 0xa0) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) + if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) ) snd_ptr_write(emu, iobase, reg, channel_id, val); } } @@ -531,6 +555,10 @@ int __devinit snd_emu10k1_proc_init(stru { struct snd_info_entry *entry; #ifdef CONFIG_SND_DEBUG + if ((emu->card_capabilities->emu1010) && + snd_card_proc_new(emu->card, "emu1010_regs", &entry)) { + snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read); + } if (! snd_card_proc_new(emu->card, "io_regs", &entry)) { snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read); entry->c.text.write = snd_emu_proc_io_reg_write; diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 029e785..116e1c8 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -30,6 +30,7 @@ #include #include #include #include +#include "p17v.h" unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { @@ -167,6 +168,109 @@ int snd_emu10k1_spi_write(struct snd_emu return 0; } +/* The ADC does not support i2c read, so only write is implemented */ +int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, + u32 reg, + u32 value) +{ + u32 tmp; + int timeout = 0; + int status; + int retry; + if ((reg > 0x7f) || (value > 0x1ff)) { + snd_printk(KERN_ERR "i2c_write: invalid values.\n"); + return -EINVAL; + } + + tmp = reg << 25 | value << 16; + // snd_printk("I2C-write:reg=0x%x, value=0x%x\n", reg, value); + /* Not sure what this I2C channel controls. */ + /* snd_emu10k1_ptr_write(emu, P17V_I2C_0, 0, tmp); */ + + /* This controls the I2C connected to the WM8775 ADC Codec */ + snd_emu10k1_ptr20_write(emu, P17V_I2C_1, 0, tmp); + tmp = snd_emu10k1_ptr20_read(emu, P17V_I2C_1, 0); /* write post */ + + for (retry = 0; retry < 10; retry++) { + /* Send the data to i2c */ + //tmp = snd_emu10k1_ptr_read(emu, P17V_I2C_ADDR, 0); + //tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); + tmp = 0; + tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); + snd_emu10k1_ptr20_write(emu, P17V_I2C_ADDR, 0, tmp); + + /* Wait till the transaction ends */ + while (1) { + udelay(10); + status = snd_emu10k1_ptr20_read(emu, P17V_I2C_ADDR, 0); + // snd_printk("I2C:status=0x%x\n", status); + timeout++; + if ((status & I2C_A_ADC_START) == 0) + break; + + if (timeout > 1000) { + snd_printk("emu10k1:I2C:timeout status=0x%x\n", status); + break; + } + } + //Read back and see if the transaction is successful + if ((status & I2C_A_ADC_ABORT) == 0) + break; + } + + if (retry == 10) { + snd_printk(KERN_ERR "Writing to ADC failed!\n"); + return -EINVAL; + } + + return 0; +} + +int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value) +{ + if (reg < 0 || reg > 0x3f) + return 1; + reg += 0x40; /* 0x40 upwards are registers. */ + if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */ + return 1; + outl(reg, emu->port + A_IOCFG); + udelay(10); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + udelay(10); + outl(value, emu->port + A_IOCFG); + udelay(10); + outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + + return 0; +} + +int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) +{ + if (reg < 0 || reg > 0x3f) + return 1; + reg += 0x40; /* 0x40 upwards are registers. */ + outl(reg, emu->port + A_IOCFG); + udelay(10); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + udelay(10); + *value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f); + + return 0; +} + +/* Each Destination has one and only one Source, + * but one Source can feed any number of Destinations simultaneously. + */ +int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src) +{ + snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) ); + snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) ); + snd_emu1010_fpga_write(emu, 0x02, ((src >> 8) & 0x3f) ); + snd_emu1010_fpga_write(emu, 0x03, (src & 0x3f) ); + + return 0; +} + void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 4e0f954..5da637c 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -253,7 +253,7 @@ static int snd_p16v_pcm_close_playback(s struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); //struct snd_pcm_runtime *runtime = substream->runtime; //struct snd_emu10k1_pcm *epcm = runtime->private_data; - emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; + emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use = 0; /* FIXME: maybe zero others */ return 0; } @@ -264,7 +264,7 @@ static int snd_p16v_pcm_close_capture(st struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); //struct snd_pcm_runtime *runtime = substream->runtime; //struct snd_emu10k1_pcm *epcm = runtime->private_data; - emu->p16v_capture_voice.use=0; + emu->p16v_capture_voice.use = 0; /* FIXME: maybe zero others */ return 0; } @@ -349,7 +349,7 @@ static int snd_p16v_pcm_prepare_playback break; } /* FIXME: Check emu->buffer.size before actually writing to it. */ - for(i=0; i < runtime->periods; i++) { + for(i = 0; i < runtime->periods; i++) { table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); table_base[(i*2)+1]=period_size_bytes<<16; } @@ -394,7 +394,7 @@ static int snd_p16v_pcm_prepare_capture( /* FIXME: Check emu->buffer.size before actually writing to it. */ snd_emu10k1_ptr20_write(emu, 0x13, channel, 0); snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); - snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes + snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size) << 16); // buffer size in bytes snd_emu10k1_ptr20_write(emu, CAPTURE_POINTER, channel, 0); //snd_emu10k1_ptr20_write(emu, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC or Line in */ //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<voices[(first_voice + i) % NUM_G]; // printk("voice alloc - %i, %i of %i\n", voice->number, idx-first_voice+1, number); voice->use = 1; diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index a84f6b2..425b167 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -413,8 +413,6 @@ #endif } u; struct pci_dev *pci; - unsigned short subsystem_vendor_id; - unsigned short subsystem_device_id; struct snd_card *card; struct snd_pcm *pcm1; /* DAC1/ADC PCM */ struct snd_pcm *pcm2; /* DAC2 PCM */ @@ -1607,11 +1605,26 @@ static void snd_ensoniq_mixer_free_ac97( ensoniq->u.es1371.ac97 = NULL; } -static struct { +struct es1371_quirk { unsigned short vid; /* vendor ID */ unsigned short did; /* device ID */ unsigned char rev; /* revision */ -} es1371_spdif_present[] __devinitdata = { +}; + +static int __devinit es1371_quirk_lookup(struct ensoniq *ensoniq, + struct es1371_quirk *list) +{ + while (list->vid != (unsigned short)PCI_ANY_ID) { + if (ensoniq->pci->vendor == list->vid && + ensoniq->pci->device == list->did && + ensoniq->rev == list->rev) + return 1; + list++; + } + return 0; +} + +static struct es1371_quirk es1371_spdif_present[] __devinitdata = { { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, @@ -1620,12 +1633,19 @@ static struct { { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } }; -static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int has_line) +static struct snd_pci_quirk ens1373_line_quirk[] __devinitdata = { + SND_PCI_QUIRK_ID(0x1274, 0x2000), /* GA-7DXR */ + SND_PCI_QUIRK_ID(0x1458, 0xa000), /* GA-8IEXP */ + { } /* end */ +}; + +static int __devinit snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, + int has_spdif, int has_line) { struct snd_card *card = ensoniq->card; struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; - int err, idx; + int err; static struct snd_ac97_bus_ops ops = { .write = snd_es1371_codec_write, .read = snd_es1371_codec_read, @@ -1641,33 +1661,28 @@ static int snd_ensoniq_1371_mixer(struct ac97.scaps = AC97_SCAP_AUDIO; if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0) return err; - for (idx = 0; es1371_spdif_present[idx].vid != (unsigned short)PCI_ANY_ID; idx++) - if ((ensoniq->pci->vendor == es1371_spdif_present[idx].vid && - ensoniq->pci->device == es1371_spdif_present[idx].did && - ensoniq->rev == es1371_spdif_present[idx].rev) || has_spdif > 0) { - struct snd_kcontrol *kctl; - int i, index = 0; - - if (has_spdif < 0) - break; - - ensoniq->spdif_default = ensoniq->spdif_stream = - SNDRV_PCM_DEFAULT_CON_SPDIF; - outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); - - if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) - index++; - - for (i = 0; i < (int)ARRAY_SIZE(snd_es1371_mixer_spdif); i++) { - kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq); - if (! kctl) - return -ENOMEM; - kctl->id.index = index; - if ((err = snd_ctl_add(card, kctl)) < 0) - return err; - } - break; + if (has_spdif > 0 || + (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) { + struct snd_kcontrol *kctl; + int i, index = 0; + + ensoniq->spdif_default = ensoniq->spdif_stream = + SNDRV_PCM_DEFAULT_CON_SPDIF; + outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); + + if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) + index++; + + for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) { + kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq); + if (!kctl) + return -ENOMEM; + kctl->id.index = index; + err = snd_ctl_add(card, kctl); + if (err < 0) + return err; } + } if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SDAC) { /* mirror rear to front speakers */ ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); @@ -1676,12 +1691,10 @@ static int snd_ensoniq_1371_mixer(struct if (err < 0) return err; } - if (((ensoniq->subsystem_vendor_id == 0x1274) && - (ensoniq->subsystem_device_id == 0x2000)) || /* GA-7DXR */ - ((ensoniq->subsystem_vendor_id == 0x1458) && - (ensoniq->subsystem_device_id == 0xa000)) || /* GA-8IEXP */ - has_line > 0) { - err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line, ensoniq)); + if (has_line > 0 || + snd_pci_quirk_lookup(ensoniq->pci, ens1373_line_quirk)) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line, + ensoniq)); if (err < 0) return err; } @@ -1956,21 +1969,15 @@ static int snd_ensoniq_dev_free(struct s } #ifdef CHIP1371 -static struct { - unsigned short svid; /* subsystem vendor ID */ - unsigned short sdid; /* subsystem device ID */ -} es1371_amplifier_hack[] = { - { .svid = 0x107b, .sdid = 0x2150 }, /* Gateway Solo 2150 */ - { .svid = 0x13bd, .sdid = 0x100c }, /* EV1938 on Mebius PC-MJ100V */ - { .svid = 0x1102, .sdid = 0x5938 }, /* Targa Xtender300 */ - { .svid = 0x1102, .sdid = 0x8938 }, /* IPC Topnote G notebook */ - { .svid = PCI_ANY_ID, .sdid = PCI_ANY_ID } +static struct snd_pci_quirk es1371_amplifier_hack[] __devinitdata = { + SND_PCI_QUIRK_ID(0x107b, 0x2150), /* Gateway Solo 2150 */ + SND_PCI_QUIRK_ID(0x13bd, 0x100c), /* EV1938 on Mebius PC-MJ100V */ + SND_PCI_QUIRK_ID(0x1102, 0x5938), /* Targa Xtender300 */ + SND_PCI_QUIRK_ID(0x1102, 0x8938), /* IPC Topnote G notebook */ + { } /* end */ }; -static struct { - unsigned short vid; /* vendor ID */ - unsigned short did; /* device ID */ - unsigned char rev; /* revision */ -} es1371_ac97_reset_hack[] = { + +static struct es1371_quirk es1371_ac97_reset_hack[] = { { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, @@ -1984,7 +1991,6 @@ static void snd_ensoniq_chip_init(struct { #ifdef CHIP1371 int idx; - struct pci_dev *pci = ensoniq->pci; #endif /* this code was part of snd_ensoniq_create before intruduction * of suspend/resume @@ -1999,16 +2005,12 @@ #else outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); outl(0, ES_REG(ensoniq, 1371_LEGACY)); - for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++) - if (pci->vendor == es1371_ac97_reset_hack[idx].vid && - pci->device == es1371_ac97_reset_hack[idx].did && - ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { - outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); - /* need to delay around 20ms(bleech) to give - some CODECs enough time to wakeup */ - msleep(20); - break; - } + if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack)) { + outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); + /* need to delay around 20ms(bleech) to give + some CODECs enough time to wakeup */ + msleep(20); + } /* AC'97 warm reset to start the bitclk */ outl(ensoniq->ctrl | ES_1371_SYNC_RES, ES_REG(ensoniq, CONTROL)); inl(ES_REG(ensoniq, CONTROL)); @@ -2112,11 +2114,7 @@ static int __devinit snd_ensoniq_create( struct ensoniq ** rensoniq) { struct ensoniq *ensoniq; - unsigned short cmdw; unsigned char cmdb; -#ifdef CHIP1371 - int idx; -#endif int err; static struct snd_device_ops ops = { .dev_free = snd_ensoniq_dev_free, @@ -2159,10 +2157,6 @@ #endif pci_set_master(pci); pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb); ensoniq->rev = cmdb; - pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &cmdw); - ensoniq->subsystem_vendor_id = cmdw; - pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw); - ensoniq->subsystem_device_id = cmdw; #ifdef CHIP1370 #if 0 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | @@ -2175,19 +2169,11 @@ #else ensoniq->ctrl = 0; ensoniq->sctrl = 0; ensoniq->cssr = 0; - for (idx = 0; es1371_amplifier_hack[idx].svid != (unsigned short)PCI_ANY_ID; idx++) - if (ensoniq->subsystem_vendor_id == es1371_amplifier_hack[idx].svid && - ensoniq->subsystem_device_id == es1371_amplifier_hack[idx].sdid) { - ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ - break; - } - for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++) - if (pci->vendor == es1371_ac97_reset_hack[idx].vid && - pci->device == es1371_ac97_reset_hack[idx].did && - ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { - ensoniq->cssr |= ES_1371_ST_AC97_RST; - break; - } + if (snd_pci_quirk_lookup(pci, es1371_amplifier_hack)) + ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ + + if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack)) + ensoniq->cssr |= ES_1371_ST_AC97_RST; #endif snd_ensoniq_chip_init(ensoniq); diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index dbacba6..60d7b05 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile @@ -1,5 +1,14 @@ snd-hda-intel-objs := hda_intel.o -snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o patch_sigmatel.o patch_si3054.o patch_atihdmi.o +snd-hda-codec-objs := hda_codec.o \ + hda_generic.o \ + patch_realtek.o \ + patch_cmedia.o \ + patch_analog.o \ + patch_sigmatel.o \ + patch_si3054.o \ + patch_atihdmi.o \ + patch_conexant.o \ + patch_via.o ifdef CONFIG_PROC_FS snd-hda-codec-objs += hda_proc.o endif diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 18bbc87..8f34fb4 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -52,6 +52,7 @@ struct hda_vendor_id { static struct hda_vendor_id hda_vendor_ids[] = { { 0x10ec, "Realtek" }, { 0x1057, "Motorola" }, + { 0x1106, "VIA" }, { 0x11d4, "Analog Devices" }, { 0x13f6, "C-Media" }, { 0x14f1, "Conexant" }, @@ -262,7 +263,7 @@ int snd_hda_queue_unsol_event(struct hda unsol->queue[wp] = res; unsol->queue[wp + 1] = res_ex; - queue_work(unsol->workq, &unsol->work); + schedule_work(&unsol->work); return 0; } @@ -309,12 +310,6 @@ static int init_unsol_queue(struct hda_b snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); return -ENOMEM; } - unsol->workq = create_singlethread_workqueue("hda_codec"); - if (! unsol->workq) { - snd_printk(KERN_ERR "hda_codec: can't create workqueue\n"); - kfree(unsol); - return -ENOMEM; - } INIT_WORK(&unsol->work, process_unsol_events); unsol->bus = bus; bus->unsol = unsol; @@ -333,7 +328,7 @@ static int snd_hda_bus_free(struct hda_b if (! bus) return 0; if (bus->unsol) { - destroy_workqueue(bus->unsol->workq); + flush_scheduled_work(); kfree(bus->unsol); } list_for_each_safe(p, n, &bus->codec_list) { @@ -1714,6 +1709,8 @@ EXPORT_SYMBOL(snd_hda_build_pcms); /** * snd_hda_check_board_config - compare the current codec with the config table * @codec: the HDA codec + * @num_configs: number of config enums + * @models: array of model name strings * @tbl: configuration table, terminated by null entries * * Compares the modelname or PCI subsystem id of the current codec with the @@ -1722,33 +1719,44 @@ EXPORT_SYMBOL(snd_hda_build_pcms); * * If no entries are matching, the function returns a negative value. */ -int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl) -{ - const struct hda_board_config *c; - - if (codec->bus->modelname) { - for (c = tbl; c->modelname || c->pci_subvendor; c++) { - if (c->modelname && - ! strcmp(codec->bus->modelname, c->modelname)) { - snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname); - return c->config; +int snd_hda_check_board_config(struct hda_codec *codec, + int num_configs, const char **models, + const struct snd_pci_quirk *tbl) +{ + if (codec->bus->modelname && models) { + int i; + for (i = 0; i < num_configs; i++) { + if (models[i] && + !strcmp(codec->bus->modelname, models[i])) { + snd_printd(KERN_INFO "hda_codec: model '%s' is " + "selected\n", models[i]); + return i; } } } - if (codec->bus->pci) { - u16 subsystem_vendor, subsystem_device; - pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); - pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); - for (c = tbl; c->modelname || c->pci_subvendor; c++) { - if (c->pci_subvendor == subsystem_vendor && - (! c->pci_subdevice /* all match */|| - (c->pci_subdevice == subsystem_device))) { - snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n", - subsystem_vendor, subsystem_device, c->config); - return c->config; - } + if (!codec->bus->pci || !tbl) + return -1; + + tbl = snd_pci_quirk_lookup(codec->bus->pci, tbl); + if (!tbl) + return -1; + if (tbl->value >= 0 && tbl->value < num_configs) { +#ifdef CONFIG_SND_DEBUG_DETECT + char tmp[10]; + const char *model = NULL; + if (models) + model = models[tbl->value]; + if (!model) { + sprintf(tmp, "#%d", tbl->value); + model = tmp; } + snd_printdd(KERN_INFO "hda_codec: model '%s' is selected " + "for config %x:%x (%s)\n", + model, tbl->subvendor, tbl->subdevice, + (tbl->name ? tbl->name : "Unknown device")); +#endif + return tbl->value; } return -1; } diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 97e9af1..1589d2f 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -485,8 +485,9 @@ #endif return "Front Aux"; return "Aux"; case AC_JACK_MIC_IN: - if (node->pin_caps & - (AC_PINCAP_VREF_80 << AC_PINCAP_VREF_SHIFT)) + if (pinctl && + (node->pin_caps & + (AC_PINCAP_VREF_80 << AC_PINCAP_VREF_SHIFT))) *pinctl |= AC_PINCTL_VREF_80; if ((location & 0x0f) == AC_JACK_LOC_FRONT) return "Front Mic"; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 9fd34f8..e6a1e37 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -83,6 +83,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}, "{Intel, ICH7}," "{Intel, ESB2}," "{Intel, ICH8}," + "{Intel, ICH9}," "{ATI, SB450}," "{ATI, SB600}," "{ATI, RS600}," @@ -1284,7 +1285,7 @@ static int __devinit create_codec_pcm(st snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), - 1024 * 64, 1024 * 128); + 1024 * 64, 1024 * 1024); chip->pcm[pcm_dev] = pcm; if (chip->pcm_devs < pcm_dev + 1) chip->pcm_devs = pcm_dev + 1; @@ -1390,6 +1391,7 @@ static int azx_acquire_irq(struct azx *c return -1; } chip->irq = chip->pci->irq; + pci_intx(chip->pci, !chip->msi); return 0; } @@ -1711,6 +1713,8 @@ static struct pci_device_id azx_ids[] = { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ + { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ + { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ @@ -1718,9 +1722,14 @@ static struct pci_device_id azx_ids[] = { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ - { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 026c */ - { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 0371 */ - { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 03f0 */ + { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP51 */ + { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP55 */ + { 0x10de, 0x03e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ + { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ + { 0x10de, 0x044a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ + { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ + { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ + { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ { 0, } }; MODULE_DEVICE_TABLE(pci, azx_ids); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 9ca1baf..39718d6 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -173,14 +173,9 @@ #endif /* * Misc */ -struct hda_board_config { - const char *modelname; - int config; - unsigned short pci_subvendor; - unsigned short pci_subdevice; -}; - -int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl); +int snd_hda_check_board_config(struct hda_codec *codec, int num_configs, + const char **modelnames, + const struct snd_pci_quirk *pci_list); int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); /* @@ -204,7 +199,6 @@ struct hda_bus_unsolicited { unsigned int rp, wp; /* workqueue */ - struct workqueue_struct *workq; struct work_struct work; struct hda_bus *bus; }; diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h index 0b66879..9f9e9ae 100644 --- a/sound/pci/hda/hda_patch.h +++ b/sound/pci/hda/hda_patch.h @@ -14,6 +14,10 @@ extern struct hda_codec_preset snd_hda_p extern struct hda_codec_preset snd_hda_preset_si3054[]; /* ATI HDMI codecs */ extern struct hda_codec_preset snd_hda_preset_atihdmi[]; +/* Conexant audio codec */ +extern struct hda_codec_preset snd_hda_preset_conexant[]; +/* VIA codecs */ +extern struct hda_codec_preset snd_hda_preset_via[]; static const struct hda_codec_preset *hda_preset_tables[] = { snd_hda_preset_realtek, @@ -22,5 +26,7 @@ static const struct hda_codec_preset *hd snd_hda_preset_sigmatel, snd_hda_preset_si3054, snd_hda_preset_atihdmi, + snd_hda_preset_conexant, + snd_hda_preset_via, NULL }; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 076365b..2e18a71 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -787,49 +787,43 @@ static struct hda_verb ad1986a_eapd_init }; /* models */ -enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD }; - -static struct hda_board_config ad1986a_cfg_tbl[] = { - { .modelname = "6stack", .config = AD1986A_6STACK }, - { .modelname = "3stack", .config = AD1986A_3STACK }, - { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84, - .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x817f, - .config = AD1986A_3STACK }, /* ASUS P5P-L2 */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b3, - .config = AD1986A_3STACK }, /* ASUS P5RD2-VM / P5GPL-X SE */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x81cb, - .config = AD1986A_3STACK }, /* ASUS M2NPV-VM */ - { .modelname = "laptop", .config = AD1986A_LAPTOP }, - { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e, - .config = AD1986A_LAPTOP }, /* FSC V2060 */ - { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017, - .config = AD1986A_LAPTOP }, /* Samsung M50 */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f, - .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */ - { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD }, - { .pci_subvendor = 0x144d, .pci_subdevice = 0xc023, - .config = AD1986A_LAPTOP_EAPD }, /* Samsung X60 Chane */ - { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024, - .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */ - { .pci_subvendor = 0x144d, .pci_subdevice = 0xc026, - .config = AD1986A_LAPTOP_EAPD }, /* Samsung X11-T2300 Culesa */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1153, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS M9 */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1263, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5F */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x12b3, - .config = AD1986A_LAPTOP_EAPD }, /* ASUS V1j */ - { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af, - .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */ - { .pci_subvendor = 0x17aa, .pci_subdevice = 0x2066, - .config = AD1986A_LAPTOP_EAPD }, /* Lenovo 3000 N100-07684JU */ +enum { + AD1986A_6STACK, + AD1986A_3STACK, + AD1986A_LAPTOP, + AD1986A_LAPTOP_EAPD, + AD1986A_MODELS +}; + +static const char *ad1986a_models[AD1986A_MODELS] = { + [AD1986A_6STACK] = "6stack", + [AD1986A_3STACK] = "3stack", + [AD1986A_LAPTOP] = "laptop", + [AD1986A_LAPTOP_EAPD] = "laptop-eapd", +}; + +static struct snd_pci_quirk ad1986a_cfg_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), + SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), + SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), + SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), + SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), + SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), + SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), + SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), + SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD), + SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP), {} }; @@ -861,7 +855,9 @@ static int patch_ad1986a(struct hda_code codec->patch_ops = ad198x_patch_ops; /* override some parameters */ - board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl); + board_config = snd_hda_check_board_config(codec, AD1986A_MODELS, + ad1986a_models, + ad1986a_cfg_tbl); switch (board_config) { case AD1986A_3STACK: spec->num_mixers = 2; @@ -1391,20 +1387,27 @@ static struct hda_input_mux ad1981_think }; /* models */ -enum { AD1981_BASIC, AD1981_HP, AD1981_THINKPAD }; +enum { + AD1981_BASIC, + AD1981_HP, + AD1981_THINKPAD, + AD1981_MODELS +}; -static struct hda_board_config ad1981_cfg_tbl[] = { - { .modelname = "hp", .config = AD1981_HP }, +static const char *ad1981_models[AD1981_MODELS] = { + [AD1981_HP] = "hp", + [AD1981_THINKPAD] = "thinkpad", + [AD1981_BASIC] = "basic", +}; + +static struct snd_pci_quirk ad1981_cfg_tbl[] = { /* All HP models */ - { .pci_subvendor = 0x103c, .config = AD1981_HP }, - { .pci_subvendor = 0x30b0, .pci_subdevice = 0x103c, - .config = AD1981_HP }, /* HP nx6320 (reversed SSID, H/W bug) */ - { .modelname = "thinkpad", .config = AD1981_THINKPAD }, + SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), + /* HP nx6320 (reversed SSID, H/W bug) */ + SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), /* Lenovo Thinkpad T60/X60/Z6xx */ - { .pci_subvendor = 0x17aa, .config = AD1981_THINKPAD }, - { .pci_subvendor = 0x1014, .pci_subdevice = 0x0597, - .config = AD1981_THINKPAD }, /* Z60m/t */ - { .modelname = "basic", .config = AD1981_BASIC }, + SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), + SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), {} }; @@ -1437,7 +1440,9 @@ static int patch_ad1981(struct hda_codec codec->patch_ops = ad198x_patch_ops; /* override some parameters */ - board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl); + board_config = snd_hda_check_board_config(codec, AD1981_MODELS, + ad1981_models, + ad1981_cfg_tbl); switch (board_config) { case AD1981_HP: spec->mixers[0] = ad1981_hp_mixers; @@ -2565,15 +2570,14 @@ static int ad1988_auto_init(struct hda_c /* */ -static struct hda_board_config ad1988_cfg_tbl[] = { - { .modelname = "6stack", .config = AD1988_6STACK }, - { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG }, - { .modelname = "3stack", .config = AD1988_3STACK }, - { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, - { .modelname = "laptop", .config = AD1988_LAPTOP }, - { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, - { .modelname = "auto", .config = AD1988_AUTO }, - {} +static const char *ad1988_models[AD1988_MODEL_LAST] = { + [AD1988_6STACK] = "6stack", + [AD1988_6STACK_DIG] = "6stack-dig", + [AD1988_3STACK] = "3stack", + [AD1988_3STACK_DIG] = "3stack-dig", + [AD1988_LAPTOP] = "laptop", + [AD1988_LAPTOP_DIG] = "laptop-dig", + [AD1988_AUTO] = "auto", }; static int patch_ad1988(struct hda_codec *codec) @@ -2591,8 +2595,9 @@ static int patch_ad1988(struct hda_codec if (is_rev2(codec)) snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); - board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); - if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { + board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, + ad1988_models, NULL); + if (board_config < 0) { printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); board_config = AD1988_AUTO; } diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index d38ce22..5b9d3a3 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -40,6 +40,7 @@ enum { CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */ CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */ CMI_AUTO, /* let driver guess it */ + CMI_MODELS }; struct cmi_spec { @@ -603,14 +604,17 @@ static void cmi9880_free(struct hda_code /* */ -static struct hda_board_config cmi9880_cfg_tbl[] = { - { .modelname = "minimal", .config = CMI_MINIMAL }, - { .modelname = "min_fp", .config = CMI_MIN_FP }, - { .modelname = "full", .config = CMI_FULL }, - { .modelname = "full_dig", .config = CMI_FULL_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */ - { .modelname = "allout", .config = CMI_ALLOUT }, - { .modelname = "auto", .config = CMI_AUTO }, +static const char *cmi9880_models[CMI_MODELS] = { + [CMI_MINIMAL] = "minimal", + [CMI_MIN_FP] = "min_fp", + [CMI_FULL] = "full", + [CMI_FULL_DIG] = "full_dig", + [CMI_ALLOUT] = "allout", + [CMI_AUTO] = "auto", +}; + +static struct snd_pci_quirk cmi9880_cfg_tbl[] = { + SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG), {} /* terminator */ }; @@ -633,7 +637,9 @@ static int patch_cmi9880(struct hda_code return -ENOMEM; codec->spec = spec; - spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl); + spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS, + cmi9880_models, + cmi9880_cfg_tbl); if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); spec->board_config = CMI_AUTO; /* try everything */ diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c new file mode 100644 index 0000000..73f4668 --- /dev/null +++ b/sound/pci/hda/patch_conexant.c @@ -0,0 +1,1311 @@ +/* + * HD audio interface patch for Conexant HDA audio codec + * + * Copyright (c) 2006 Pototskiy Akex + * Takashi Iwai + * Tobin Davis + * + * This driver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This driver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include "hda_codec.h" +#include "hda_local.h" + +#define CXT_PIN_DIR_IN 0x00 +#define CXT_PIN_DIR_OUT 0x01 +#define CXT_PIN_DIR_INOUT 0x02 +#define CXT_PIN_DIR_IN_NOMICBIAS 0x03 +#define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 + +#define CONEXANT_HP_EVENT 0x37 +#define CONEXANT_MIC_EVENT 0x38 + + + +struct conexant_spec { + + struct snd_kcontrol_new *mixers[5]; + int num_mixers; + + const struct hda_verb *init_verbs[5]; /* initialization verbs + * don't forget NULL + * termination! + */ + unsigned int num_init_verbs; + + /* playback */ + struct hda_multi_out multiout; /* playback set-up + * max_channels, dacs must be set + * dig_out_nid and hp_nid are optional + */ + unsigned int cur_eapd; + unsigned int need_dac_fix; + + /* capture */ + unsigned int num_adc_nids; + hda_nid_t *adc_nids; + hda_nid_t dig_in_nid; /* digital-in NID; optional */ + + /* capture source */ + const struct hda_input_mux *input_mux; + hda_nid_t *capsrc_nids; + unsigned int cur_mux[3]; + + /* channel model */ + const struct hda_channel_mode *channel_mode; + int num_channel_mode; + + /* PCM information */ + struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ + + struct mutex amp_mutex; /* PCM volume/mute control mutex */ + unsigned int spdif_route; + + /* dynamic controls, init_verbs and input_mux */ + struct auto_pin_cfg autocfg; + unsigned int num_kctl_alloc, num_kctl_used; + struct snd_kcontrol_new *kctl_alloc; + struct hda_input_mux private_imux; + hda_nid_t private_dac_nids[4]; + +}; + +static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); +} + +static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, + stream_tag, + format, substream); +} + +static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); +} + +/* + * Digital out + */ +static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + return snd_hda_multi_out_dig_open(codec, &spec->multiout); +} + +static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + return snd_hda_multi_out_dig_close(codec, &spec->multiout); +} + +/* + * Analog capture + */ +static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], + stream_tag, 0, format); + return 0; +} + +static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct conexant_spec *spec = codec->spec; + snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], + 0, 0, 0); + return 0; +} + + + +static struct hda_pcm_stream conexant_pcm_analog_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = 0, /* fill later */ + .ops = { + .open = conexant_playback_pcm_open, + .prepare = conexant_playback_pcm_prepare, + .cleanup = conexant_playback_pcm_cleanup + }, +}; + +static struct hda_pcm_stream conexant_pcm_analog_capture = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = 0, /* fill later */ + .ops = { + .prepare = conexant_capture_pcm_prepare, + .cleanup = conexant_capture_pcm_cleanup + }, +}; + + +static struct hda_pcm_stream conexant_pcm_digital_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = 0, /* fill later */ + .ops = { + .open = conexant_dig_playback_pcm_open, + .close = conexant_dig_playback_pcm_close + }, +}; + +static struct hda_pcm_stream conexant_pcm_digital_capture = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + /* NID is set in alc_build_pcms */ +}; + +static int conexant_build_pcms(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct hda_pcm *info = spec->pcm_rec; + + codec->num_pcms = 1; + codec->pcm_info = info; + + info->name = "CONEXANT Analog"; + info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = + spec->multiout.max_channels; + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = + spec->multiout.dac_nids[0]; + info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture; + info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; + info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; + + if (spec->multiout.dig_out_nid) { + info++; + codec->num_pcms++; + info->name = "Conexant Digital"; + info->stream[SNDRV_PCM_STREAM_PLAYBACK] = + conexant_pcm_digital_playback; + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = + spec->multiout.dig_out_nid; + if (spec->dig_in_nid) { + info->stream[SNDRV_PCM_STREAM_CAPTURE] = + conexant_pcm_digital_capture; + info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = + spec->dig_in_nid; + } + } + + return 0; +} + +static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + + return snd_hda_input_mux_info(spec->input_mux, uinfo); +} + +static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + + ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; + return 0; +} + +static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + + return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, + spec->capsrc_nids[adc_idx], + &spec->cur_mux[adc_idx]); +} + +static int conexant_init(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + int i; + + for (i = 0; i < spec->num_init_verbs; i++) + snd_hda_sequence_write(codec, spec->init_verbs[i]); + return 0; +} + +static void conexant_free(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + unsigned int i; + + if (spec->kctl_alloc) { + for (i = 0; i < spec->num_kctl_used; i++) + kfree(spec->kctl_alloc[i].name); + kfree(spec->kctl_alloc); + } + + kfree(codec->spec); +} + +#ifdef CONFIG_PM +static int conexant_resume(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + int i; + + codec->patch_ops.init(codec); + for (i = 0; i < spec->num_mixers; i++) + snd_hda_resume_ctls(codec, spec->mixers[i]); + if (spec->multiout.dig_out_nid) + snd_hda_resume_spdif_out(codec); + if (spec->dig_in_nid) + snd_hda_resume_spdif_in(codec); + return 0; +} +#endif + +static int conexant_build_controls(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + unsigned int i; + int err; + + for (i = 0; i < spec->num_mixers; i++) { + err = snd_hda_add_new_ctls(codec, spec->mixers[i]); + if (err < 0) + return err; + } + if (spec->multiout.dig_out_nid) { + err = snd_hda_create_spdif_out_ctls(codec, + spec->multiout.dig_out_nid); + if (err < 0) + return err; + } + if (spec->dig_in_nid) { + err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); + if (err < 0) + return err; + } + return 0; +} + +static struct hda_codec_ops conexant_patch_ops = { + .build_controls = conexant_build_controls, + .build_pcms = conexant_build_pcms, + .init = conexant_init, + .free = conexant_free, +#ifdef CONFIG_PM + .resume = conexant_resume, +#endif +}; + +/* + * EAPD control + * the private value = nid | (invert << 8) + */ + +static int conexant_eapd_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int conexant_eapd_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + int invert = (kcontrol->private_value >> 8) & 1; + if (invert) + ucontrol->value.integer.value[0] = !spec->cur_eapd; + else + ucontrol->value.integer.value[0] = spec->cur_eapd; + return 0; +} + +static int conexant_eapd_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + int invert = (kcontrol->private_value >> 8) & 1; + hda_nid_t nid = kcontrol->private_value & 0xff; + unsigned int eapd; + eapd = ucontrol->value.integer.value[0]; + if (invert) + eapd = !eapd; + if (eapd == spec->cur_eapd && !codec->in_resume) + return 0; + spec->cur_eapd = eapd; + snd_hda_codec_write(codec, nid, + 0, AC_VERB_SET_EAPD_BTLENABLE, + eapd ? 0x02 : 0x00); + return 1; +} + +/* controls for test mode */ +#ifdef CONFIG_SND_DEBUG + +static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, + spec->num_channel_mode); +} + +static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, + spec->multiout.max_channels); +} + +static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, + &spec->multiout.max_channels); + if (err >= 0 && spec->need_dac_fix) + spec->multiout.num_dacs = spec->multiout.max_channels / 2; + return err; +} + +#define CXT_PIN_MODE(xname, nid, dir) \ + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ + .info = conexant_ch_mode_info, \ + .get = conexant_ch_mode_get, \ + .put = conexant_ch_mode_put, \ + .private_value = nid | (dir<<16) } + +static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + hda_nid_t nid = kcontrol->private_value & 0xffff; + unsigned char mask = (kcontrol->private_value >> 16) & 0xff; + long *valp = ucontrol->value.integer.value; + unsigned int val = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_GPIO_DATA, 0x00); + + *valp = (val & mask) != 0; + return 0; +} + +static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + hda_nid_t nid = kcontrol->private_value & 0xffff; + unsigned char mask = (kcontrol->private_value >> 16) & 0xff; + long val = *ucontrol->value.integer.value; + unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_GPIO_DATA, + 0x00); + unsigned int old_data = gpio_data; + + /* Set/unset the masked GPIO bit(s) as needed */ + if (val == 0) + gpio_data &= ~mask; + else + gpio_data |= mask; + if (gpio_data == old_data && !codec->in_resume) + return 0; + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data); + return 1; +} + +#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \ + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ + .info = cxt_gpio_data_info, \ + .get = cxt_gpio_data_get, \ + .put = cxt_gpio_data_put, \ + .private_value = nid | (mask<<16) } + +static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + hda_nid_t nid = kcontrol->private_value & 0xffff; + unsigned char mask = (kcontrol->private_value >> 16) & 0xff; + long *valp = ucontrol->value.integer.value; + unsigned int val = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_DIGI_CONVERT, 0x00); + + *valp = (val & mask) != 0; + return 0; +} + +static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + hda_nid_t nid = kcontrol->private_value & 0xffff; + unsigned char mask = (kcontrol->private_value >> 16) & 0xff; + long val = *ucontrol->value.integer.value; + unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_DIGI_CONVERT, + 0x00); + unsigned int old_data = ctrl_data; + + /* Set/unset the masked control bit(s) as needed */ + if (val == 0) + ctrl_data &= ~mask; + else + ctrl_data |= mask; + if (ctrl_data == old_data && !codec->in_resume) + return 0; + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, + ctrl_data); + return 1; +} + +#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \ + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ + .info = cxt_spdif_ctrl_info, \ + .get = cxt_spdif_ctrl_get, \ + .put = cxt_spdif_ctrl_put, \ + .private_value = nid | (mask<<16) } + +#endif /* CONFIG_SND_DEBUG */ + +/* Conexant 5045 specific */ + +static hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; +static hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; +static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; +#define CXT5045_SPDIF_OUT 0x13 + +static struct hda_channel_mode cxt5045_modes[1] = { + { 2, NULL }, +}; + +static struct hda_input_mux cxt5045_capture_source = { + .num_items = 2, + .items = { + { "ExtMic", 0x1 }, + { "LineIn", 0x2 }, + } +}; + +/* turn on/off EAPD (+ mute HP) as a master switch */ +static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + + if (!conexant_eapd_put(kcontrol, ucontrol)) + return 0; + + /* toggle HP mute appropriately */ + snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, + 0x80, spec->cur_eapd ? 0 : 0x80); + snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, + 0x80, spec->cur_eapd ? 0 : 0x80); + return 1; +} + +/* bind volumes of both NID 0x10 and 0x11 */ +static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + long *valp = ucontrol->value.integer.value; + int change; + + change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, + 0x7f, valp[0] & 0x7f); + change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, + 0x7f, valp[1] & 0x7f); + snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, + 0x7f, valp[0] & 0x7f); + snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, + 0x7f, valp[1] & 0x7f); + return change; +} + + +/* mute internal speaker if HP is plugged */ +static void cxt5045_hp_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x11, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); +} + +/* unsolicited event for HP jack sensing */ +static void cxt5045_hp_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + res >>= 26; + switch (res) { + case CONEXANT_HP_EVENT: + cxt5045_hp_automute(codec); + break; + } +} + +static struct snd_kcontrol_new cxt5045_mixers[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = conexant_mux_enum_info, + .get = conexant_mux_enum_get, + .put = conexant_mux_enum_put + }, + HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x17, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x17, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x02, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Master Playback Volume", + .info = snd_hda_mixer_amp_volume_info, + .get = snd_hda_mixer_amp_volume_get, + .put = cxt5045_hp_master_vol_put, + .private_value = HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Master Playback Switch", + .info = conexant_eapd_info, + .get = conexant_eapd_get, + .put = cxt5045_hp_master_sw_put, + .private_value = 0x11, + }, + + {} +}; + +static struct hda_verb cxt5045_init_verbs[] = { + /* Line in, Mic */ + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, + /* HP, Amp */ + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + {0x1A, AC_VERB_SET_CONNECT_SEL,0x01}, + {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, + {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, + /* Record selector: Front mic */ + {0x14, AC_VERB_SET_CONNECT_SEL,0x03}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, + /* SPDIF route: PCM */ + { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, + /* pin sensing on HP and Mic jacks */ + {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, + /* EAPD */ + {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */ + { } /* end */ +}; + +#ifdef CONFIG_SND_DEBUG +/* Test configuration for debugging, modelled after the ALC260 test + * configuration. + */ +static struct hda_input_mux cxt5045_test_capture_source = { + .num_items = 5, + .items = { + { "MIXER", 0x0 }, + { "MIC1 pin", 0x1 }, + { "LINE1 pin", 0x2 }, + { "HP-OUT pin", 0x3 }, + { "CD pin", 0x4 }, + }, +}; + +static struct snd_kcontrol_new cxt5045_test_mixer[] = { + + /* Output controls */ + HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x19, 0x00, HDA_OUTPUT), + HDA_CODEC_MUTE("OutAmp-1 Switch", 0x19,0x00, HDA_OUTPUT), + HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), + + /* Modes for retasking pin widgets */ + CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), + CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), + + /* Loopback mixer controls */ + HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT), + HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT), + + /* Controls for GPIO pins, assuming they exist and are configured as outputs */ + CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), +#if 0 /* limit this to one GPIO pin for now */ + CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), + CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), + CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), +#endif + CXT_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x13, 0x01), + + HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Input Source", + .info = conexant_mux_enum_info, + .get = conexant_mux_enum_get, + .put = conexant_mux_enum_put, + }, + + { } /* end */ +}; + +static struct hda_verb cxt5045_test_init_verbs[] = { + /* Enable all GPIOs as outputs with an initial value of 0 */ + {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, + {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, + {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, + + /* Enable retasking pins as output, initially without power amp */ + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + + /* Disable digital (SPDIF) pins initially, but users can enable + * them via a mixer switch. In the case of SPDIF-out, this initverb + * payload also sets the generation to 0, output to be in "consumer" + * PCM format, copyright asserted, no pre-emphasis and no validity + * control. + */ + {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0}, + + /* Start with output sum widgets muted and their output gains at min */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + + /* Unmute retasking pin widget output buffers since the default + * state appears to be output. As the pin mode is changed by the + * user the pin mode control will take care of enabling the pin's + * input/output buffers as needed. + */ + {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + + /* Mute capture amp left and right */ + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + + /* Set ADC connection select to match default mixer setting (mic1 + * pin) + */ + {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, + + /* Mute all inputs to mixer widget (even unconnected ones) */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ + + { } +}; +#endif + + +/* initialize jack-sensing, too */ +static int cxt5045_init(struct hda_codec *codec) +{ + conexant_init(codec); + cxt5045_hp_automute(codec); + return 0; +} + + +enum { + CXT5045_LAPTOP, /* Laptops w/ EAPD support */ +#ifdef CONFIG_SND_DEBUG + CXT5045_TEST, +#endif + CXT5045_MODELS +}; + +static const char *cxt5045_models[CXT5045_MODELS] = { + [CXT5045_LAPTOP] = "laptop", +#ifdef CONFIG_SND_DEBUG + [CXT5045_TEST] = "test", +#endif +}; + +static struct snd_pci_quirk cxt5045_cfg_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), + {} +}; + +static int patch_cxt5045(struct hda_codec *codec) +{ + struct conexant_spec *spec; + int board_config; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (!spec) + return -ENOMEM; + mutex_init(&spec->amp_mutex); + codec->spec = spec; + + spec->multiout.max_channels = 2; + spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); + spec->multiout.dac_nids = cxt5045_dac_nids; + spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; + spec->num_adc_nids = 1; + spec->adc_nids = cxt5045_adc_nids; + spec->capsrc_nids = cxt5045_capsrc_nids; + spec->input_mux = &cxt5045_capture_source; + spec->num_mixers = 1; + spec->mixers[0] = cxt5045_mixers; + spec->num_init_verbs = 1; + spec->init_verbs[0] = cxt5045_init_verbs; + spec->spdif_route = 0; + spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes), + spec->channel_mode = cxt5045_modes, + + + codec->patch_ops = conexant_patch_ops; + codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; + + board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, + cxt5045_models, + cxt5045_cfg_tbl); + switch (board_config) { + case CXT5045_LAPTOP: + spec->input_mux = &cxt5045_capture_source; + spec->num_init_verbs = 2; + spec->init_verbs[1] = cxt5045_init_verbs; + spec->mixers[0] = cxt5045_mixers; + codec->patch_ops.init = cxt5045_init; + break; +#ifdef CONFIG_SND_DEBUG + case CXT5045_TEST: + spec->input_mux = &cxt5045_test_capture_source; + spec->mixers[0] = cxt5045_test_mixer; + spec->init_verbs[0] = cxt5045_test_init_verbs; +#endif + } + return 0; +} + + +/* Conexant 5047 specific */ + +static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; +static hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; +static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; +#define CXT5047_SPDIF_OUT 0x11 + +static struct hda_channel_mode cxt5047_modes[1] = { + { 2, NULL }, +}; + +static struct hda_input_mux cxt5047_capture_source = { + .num_items = 2, + .items = { + { "ExtMic", 0x1 }, + { "IntMic", 0x2 }, + } +}; + +static struct hda_input_mux cxt5047_hp_capture_source = { + .num_items = 1, + .items = { + { "ExtMic", 0x1 }, + } +}; + +/* turn on/off EAPD (+ mute HP) as a master switch */ +static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct conexant_spec *spec = codec->spec; + + if (!conexant_eapd_put(kcontrol, ucontrol)) + return 0; + + /* toggle HP mute appropriately */ + snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, + 0x80, spec->cur_eapd ? 0 : 0x80); + snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, + 0x80, spec->cur_eapd ? 0 : 0x80); + return 1; +} + +#if 0 +/* bind volumes of both NID 0x13 and 0x1d */ +static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + long *valp = ucontrol->value.integer.value; + int change; + + change = snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, + 0x7f, valp[0] & 0x7f); + change |= snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, + 0x7f, valp[1] & 0x7f); + snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, + 0x7f, valp[0] & 0x7f); + snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, + 0x7f, valp[1] & 0x7f); + return change; +} +#endif + +/* mute internal speaker if HP is plugged */ +static void cxt5047_hp_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x13, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); +} + +/* toggle input of built-in and mic jack appropriately */ +static void cxt5047_hp_automic(struct hda_codec *codec) +{ + static struct hda_verb mic_jack_on[] = { + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + {} + }; + static struct hda_verb mic_jack_off[] = { + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + {} + }; + unsigned int present; + + present = snd_hda_codec_read(codec, 0x08, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + if (present) + snd_hda_sequence_write(codec, mic_jack_on); + else + snd_hda_sequence_write(codec, mic_jack_off); +} + +/* unsolicited event for HP jack sensing */ +static void cxt5047_hp_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + res >>= 26; + switch (res) { + case CONEXANT_HP_EVENT: + cxt5047_hp_automute(codec); + break; + case CONEXANT_MIC_EVENT: + cxt5047_hp_automic(codec); + break; + } +} + +static struct snd_kcontrol_new cxt5047_mixers[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = conexant_mux_enum_info, + .get = conexant_mux_enum_get, + .put = conexant_mux_enum_put + }, + HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), + HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), + HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), + HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Master Playback Switch", + .info = conexant_eapd_info, + .get = conexant_eapd_get, + .put = cxt5047_hp_master_sw_put, + .private_value = 0x13, + }, + + {} +}; + +static struct snd_kcontrol_new cxt5047_hp_mixers[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = conexant_mux_enum_info, + .get = conexant_mux_enum_get, + .put = conexant_mux_enum_put + }, + HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), + HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), + HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), + HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Master Playback Switch", + .info = conexant_eapd_info, + .get = conexant_eapd_get, + .put = cxt5047_hp_master_sw_put, + .private_value = 0x13, + }, + { } /* end */ +}; + +static struct hda_verb cxt5047_init_verbs[] = { + /* Line in, Mic, Built-in Mic */ + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, + /* HP, Amp */ + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + {0x1A, AC_VERB_SET_CONNECT_SEL,0x03}, + {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, + {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, + /* Record selector: Front mic */ + {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, + AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, + /* SPDIF route: PCM */ + { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, + { } /* end */ +}; + +/* configuration for Toshiba Laptops */ +static struct hda_verb cxt5047_toshiba_init_verbs[] = { + {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */ + /* pin sensing on HP and Mic jacks */ + {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, + {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, + {} +}; + +/* configuration for HP Laptops */ +static struct hda_verb cxt5047_hp_init_verbs[] = { + /* pin sensing on HP and Mic jacks */ + {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, + {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, + {} +}; + +/* Test configuration for debugging, modelled after the ALC260 test + * configuration. + */ +#ifdef CONFIG_SND_DEBUG +static struct hda_input_mux cxt5047_test_capture_source = { + .num_items = 5, + .items = { + { "MIXER", 0x0 }, + { "LINE1 pin", 0x1 }, + { "MIC1 pin", 0x2 }, + { "MIC2 pin", 0x3 }, + { "CD pin", 0x4 }, + }, +}; + +static struct snd_kcontrol_new cxt5047_test_mixer[] = { + + /* Output only controls */ + HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x00, HDA_OUTPUT), + HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x00, HDA_OUTPUT), + HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x00, HDA_OUTPUT), + HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x00, HDA_OUTPUT), + HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), + + /* Modes for retasking pin widgets */ + CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), + CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), + + /* Loopback mixer controls */ + HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x19, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("MIC1 Playback Switch", 0x19, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x19, 0x03, HDA_INPUT), + HDA_CODEC_MUTE("MIC2 Playback Switch", 0x19, 0x03, HDA_INPUT), + HDA_CODEC_VOLUME("LINE Playback Volume", 0x19, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("LINE Playback Switch", 0x19, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x19, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x19, 0x04, HDA_INPUT), + +#if 0 + /* Controls for GPIO pins, assuming they exist and are configured as outputs */ + CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), + CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), + CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), + CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), +#endif + CXT_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x18, 0x01), + + HDA_CODEC_VOLUME("Capture Volume", 0x19, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Capture Switch", 0x19, 0x0, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Input Source", + .info = conexant_mux_enum_info, + .get = conexant_mux_enum_get, + .put = conexant_mux_enum_put, + }, + + { } /* end */ +}; + +static struct hda_verb cxt5047_test_init_verbs[] = { + /* Enable all GPIOs as outputs with an initial value of 0 */ + {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, + {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, + {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, + + /* Enable retasking pins as output, initially without power amp */ + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + + /* Disable digital (SPDIF) pins initially, but users can enable + * them via a mixer switch. In the case of SPDIF-out, this initverb + * payload also sets the generation to 0, output to be in "consumer" + * PCM format, copyright asserted, no pre-emphasis and no validity + * control. + */ + {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, + + /* Ensure mic1, mic2, line1 pin widgets take input from the + * OUT1 sum bus when acting as an output. + */ + {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, + {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, + + /* Start with output sum widgets muted and their output gains at min */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + + /* Unmute retasking pin widget output buffers since the default + * state appears to be output. As the pin mode is changed by the + * user the pin mode control will take care of enabling the pin's + * input/output buffers as needed. + */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + + /* Mute capture amp left and right */ + {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + + /* Set ADC connection select to match default mixer setting (mic1 + * pin) + */ + {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, + + /* Mute all inputs to mixer widget (even unconnected ones) */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ + + { } +}; +#endif + + +/* initialize jack-sensing, too */ +static int cxt5047_hp_init(struct hda_codec *codec) +{ + conexant_init(codec); + cxt5047_hp_automute(codec); + cxt5047_hp_automic(codec); + return 0; +} + + +enum { + CXT5047_LAPTOP, /* Laptops w/o EAPD support */ + CXT5047_LAPTOP_HP, /* Some HP laptops */ + CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ +#ifdef CONFIG_SND_DEBUG + CXT5047_TEST, +#endif + CXT5047_MODELS +}; + +static const char *cxt5047_models[CXT5047_MODELS] = { + [CXT5047_LAPTOP] = "laptop", + [CXT5047_LAPTOP_HP] = "laptop-hp", + [CXT5047_LAPTOP_EAPD] = "laptop-eapd", +#ifdef CONFIG_SND_DEBUG + [CXT5047_TEST] = "test", +#endif +}; + +static struct snd_pci_quirk cxt5047_cfg_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP), + SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP), + SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), + SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), + {} +}; + +static int patch_cxt5047(struct hda_codec *codec) +{ + struct conexant_spec *spec; + int board_config; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (!spec) + return -ENOMEM; + mutex_init(&spec->amp_mutex); + codec->spec = spec; + + spec->multiout.max_channels = 2; + spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); + spec->multiout.dac_nids = cxt5047_dac_nids; + spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; + spec->num_adc_nids = 1; + spec->adc_nids = cxt5047_adc_nids; + spec->capsrc_nids = cxt5047_capsrc_nids; + spec->input_mux = &cxt5047_capture_source; + spec->num_mixers = 1; + spec->mixers[0] = cxt5047_mixers; + spec->num_init_verbs = 1; + spec->init_verbs[0] = cxt5047_init_verbs; + spec->spdif_route = 0; + spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), + spec->channel_mode = cxt5047_modes, + + codec->patch_ops = conexant_patch_ops; + codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; + + board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, + cxt5047_models, + cxt5047_cfg_tbl); + switch (board_config) { + case CXT5047_LAPTOP: + break; + case CXT5047_LAPTOP_HP: + spec->input_mux = &cxt5047_hp_capture_source; + spec->num_init_verbs = 2; + spec->init_verbs[1] = cxt5047_hp_init_verbs; + spec->mixers[0] = cxt5047_hp_mixers; + codec->patch_ops.init = cxt5047_hp_init; + break; + case CXT5047_LAPTOP_EAPD: + spec->num_init_verbs = 2; + spec->init_verbs[1] = cxt5047_toshiba_init_verbs; + break; +#ifdef CONFIG_SND_DEBUG + case CXT5047_TEST: + spec->input_mux = &cxt5047_test_capture_source; + spec->mixers[0] = cxt5047_test_mixer; + spec->init_verbs[0] = cxt5047_test_init_verbs; +#endif + } + return 0; +} + +struct hda_codec_preset snd_hda_preset_conexant[] = { + { .id = 0x14f15045, .name = "CXT5045", .patch = patch_cxt5045 }, + { .id = 0x14f15047, .name = "CXT5047", .patch = patch_cxt5047 }, + {} /* terminator */ +}; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 29e4c48..2be0ef9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -32,6 +32,10 @@ #include #include "hda_codec.h" #include "hda_local.h" +#define ALC880_FRONT_EVENT 0x01 +#define ALC880_DCVOL_EVENT 0x02 +#define ALC880_HP_EVENT 0x04 +#define ALC880_MIC_EVENT 0x08 /* ALC880 board config type */ enum { @@ -49,6 +53,8 @@ enum { ALC880_ASUS_W1V, ALC880_ASUS_DIG2, ALC880_UNIWILL_DIG, + ALC880_UNIWILL, + ALC880_UNIWILL_P53, ALC880_CLEVO, ALC880_TCL_S700, ALC880_LG, @@ -77,6 +83,8 @@ #endif /* ALC262 models */ enum { ALC262_BASIC, + ALC262_HIPPO, + ALC262_HIPPO_1, ALC262_FUJITSU, ALC262_HP_BPC, ALC262_BENQ_ED8, @@ -91,6 +99,9 @@ enum { ALC861_3ST_DIG, ALC861_6ST_DIG, ALC861_UNIWILL_M31, + ALC861_TOSHIBA, + ALC861_ASUS, + ALC861_ASUS_LAPTOP, ALC861_AUTO, ALC861_MODEL_LAST, }; @@ -101,6 +112,7 @@ enum { ALC882_6ST_DIG, ALC882_ARIMA, ALC882_AUTO, + ALC885_MACPRO, ALC882_MODEL_LAST, }; @@ -110,8 +122,12 @@ enum { ALC883_3ST_6ch_DIG, ALC883_3ST_6ch, ALC883_6ST_DIG, + ALC883_TARGA_DIG, + ALC883_TARGA_2ch_DIG, ALC888_DEMO_BOARD, ALC883_ACER, + ALC883_MEDION, + ALC883_LAPTOP_EAPD, ALC883_AUTO, ALC883_MODEL_LAST, }; @@ -1015,6 +1031,46 @@ static struct snd_kcontrol_new alc880_tc { } /* end */ }; +/* Uniwill */ +static struct snd_kcontrol_new alc880_uniwill_mixer[] = { + HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), + HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), + HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Channel Mode", + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { + HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), + HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + { } /* end */ +}; + /* * build control elements */ @@ -1248,6 +1304,154 @@ static struct hda_verb alc880_pin_6stack { } }; +/* + * Uniwill pin configuration: + * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, + * line = 0x1a + */ +static struct hda_verb alc880_uniwill_init_verbs[] = { + {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ + + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ + /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ + {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + + {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, + + { } +}; + +/* +* Uniwill P53 +* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, + */ +static struct hda_verb alc880_uniwill_p53_init_verbs[] = { + {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ + + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + + {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, + + { } +}; + +/* toggle speaker-output according to the hp-jack state */ +static void alc880_uniwill_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x14, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + + present = snd_hda_codec_read(codec, 0x18, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, + 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); +} + +static void alc880_uniwill_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + /* Looks like the unsol event is incompatible with the standard + * definition. 4bit tag is placed at 28 bit! + */ + if ((res >> 28) == ALC880_HP_EVENT || + (res >> 28) == ALC880_MIC_EVENT) + alc880_uniwill_automute(codec); +} + +static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x14, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + + snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, + 0x80, present ? 0x80 : 0); +} + +static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x21, 0, + AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f; + + snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, + 0x7f, present); + snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, + 0x7f, present); + + snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, + 0x7f, present); + snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, + 0x7f, present); + +} +static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + /* Looks like the unsol event is incompatible with the standard + * definition. 4bit tag is placed at 28 bit! + */ + if ((res >> 28) == ALC880_HP_EVENT) + alc880_uniwill_p53_hp_automute(codec); + if ((res >> 28) == ALC880_DCVOL_EVENT) + alc880_uniwill_p53_dcvol_automute(codec); +} + /* FIXME! */ /* * F1734 pin configuration: @@ -2125,159 +2329,109 @@ #endif /* */ -static struct hda_board_config alc880_cfg_tbl[] = { - /* Back 3 jack, front 2 jack */ - { .modelname = "3stack", .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, - /* TCL S700 */ - { .modelname = "tcl", .config = ALC880_TCL_S700 }, - { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, - - /* Back 3 jack, front 2 jack (Internal add Aux-In) */ - { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, - - /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ - { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, - - /* Clevo laptops */ - { .modelname = "clevo", .config = ALC880_CLEVO }, - { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, - .config = ALC880_CLEVO }, /* Clevo m520G NB */ - { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660, - .config = ALC880_CLEVO }, /* Clevo m665n */ - - /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, - - /* Back 5 jack, front 2 jack */ - { .modelname = "5stack", .config = ALC880_5ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, - { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, - - /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ - { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, - { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, - .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */ - /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ - { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, - /* note subvendor = 0 below */ - /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ - - { .modelname = "w810", .config = ALC880_W810 }, - { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, - - { .modelname = "z71v", .config = ALC880_Z71V }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, - - { .modelname = "6stack", .config = ALC880_6ST }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, - { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ - { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */ - - { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, - { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ - { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */ - { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */ - - { .modelname = "asus", .config = ALC880_ASUS }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */ - { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, - { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, - { .modelname = "asus-dig", .config = ALC880_ASUS_DIG }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */ - { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 }, - { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, - - { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, - { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, - - { .modelname = "F1734", .config = ALC880_F1734 }, - { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, - { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, - - { .modelname = "lg", .config = ALC880_LG }, - { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG }, - { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG }, - - { .modelname = "lg-lw", .config = ALC880_LG_LW }, - { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW }, - { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW }, - +static const char *alc880_models[ALC880_MODEL_LAST] = { + [ALC880_3ST] = "3stack", + [ALC880_TCL_S700] = "tcl", + [ALC880_3ST_DIG] = "3stack-digout", + [ALC880_CLEVO] = "clevo", + [ALC880_5ST] = "5stack", + [ALC880_5ST_DIG] = "5stack-digout", + [ALC880_W810] = "w810", + [ALC880_Z71V] = "z71v", + [ALC880_6ST] = "6stack", + [ALC880_6ST_DIG] = "6stack-digout", + [ALC880_ASUS] = "asus", + [ALC880_ASUS_W1V] = "asus-w1v", + [ALC880_ASUS_DIG] = "asus-dig", + [ALC880_ASUS_DIG2] = "asus-dig2", + [ALC880_UNIWILL_DIG] = "uniwill", + [ALC880_F1734] = "F1734", + [ALC880_LG] = "lg", + [ALC880_LG_LW] = "lg-lw", #ifdef CONFIG_SND_DEBUG - { .modelname = "test", .config = ALC880_TEST }, + [ALC880_TEST] = "test", #endif - { .modelname = "auto", .config = ALC880_AUTO }, + [ALC880_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc880_cfg_tbl[] = { + /* Broken BIOS configuration */ + SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), + SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), + + SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), + SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), + SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), + SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), + SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), + + SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), + SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), + + SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), + SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), + /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ + SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_5ST), + SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), + SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), + SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), + SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), + + SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), + SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), + SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), + SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), + SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), + SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), + SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), + SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), + SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), + SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), + SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), + SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), + + SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), + SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), + SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), + SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), + + SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), + SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), + + SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), + SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), + SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), + SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), + + SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), + SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), + SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), + SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), + SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), {} }; @@ -2438,7 +2592,8 @@ static struct alc_config_preset alc880_p }, [ALC880_UNIWILL_DIG] = { .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, - .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, + .init_verbs = { alc880_volume_init_verbs, + alc880_pin_asus_init_verbs }, .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), .dac_nids = alc880_asus_dac_nids, .dig_out_nid = ALC880_DIGOUT_NID, @@ -2447,6 +2602,32 @@ static struct alc_config_preset alc880_p .need_dac_fix = 1, .input_mux = &alc880_capture_source, }, + [ALC880_UNIWILL] = { + .mixers = { alc880_uniwill_mixer }, + .init_verbs = { alc880_volume_init_verbs, + alc880_uniwill_init_verbs }, + .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), + .dac_nids = alc880_asus_dac_nids, + .dig_out_nid = ALC880_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), + .channel_mode = alc880_threestack_modes, + .need_dac_fix = 1, + .input_mux = &alc880_capture_source, + .unsol_event = alc880_uniwill_unsol_event, + .init_hook = alc880_uniwill_automute, + }, + [ALC880_UNIWILL_P53] = { + .mixers = { alc880_uniwill_p53_mixer }, + .init_verbs = { alc880_volume_init_verbs, + alc880_uniwill_p53_init_verbs }, + .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), + .dac_nids = alc880_asus_dac_nids, + .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), + .channel_mode = alc880_w810_modes, + .input_mux = &alc880_capture_source, + .unsol_event = alc880_uniwill_p53_unsol_event, + .init_hook = alc880_uniwill_p53_hp_automute, + }, [ALC880_CLEVO] = { .mixers = { alc880_three_stack_mixer }, .init_verbs = { alc880_volume_init_verbs, @@ -2841,8 +3022,10 @@ static int patch_alc880(struct hda_codec codec->spec = spec; - board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); - if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { + board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, + alc880_models, + alc880_cfg_tbl); + if (board_config < 0) { printk(KERN_INFO "hda_codec: Unknown model for ALC880, " "trying auto-probe from BIOS...\n"); board_config = ALC880_AUTO; @@ -3090,11 +3273,20 @@ static struct snd_kcontrol_new alc260_fu * and the output jack. If this turns out to be the case for all such * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT * to ALC_PIN_DIR_INOUT_NOMICBIAS. + * + * The C20x Tablet series have a mono internal speaker which is controlled + * via the chip's Mono sum widget and pin complex, so include the necessary + * controls for such models. On models without a "mono speaker" the control + * won't do anything. */ static struct snd_kcontrol_new alc260_acer_mixer[] = { HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), + HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, + HDA_OUTPUT), + HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, + HDA_INPUT), HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), @@ -3409,11 +3601,11 @@ static struct hda_verb alc260_acer_init_ {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, /* Line In jack is connected to Line1 pin */ {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, /* Ensure all other unused pins are disabled and muted. */ {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, - {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, - {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, @@ -3441,6 +3633,8 @@ static struct hda_verb alc260_acer_init_ /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ + {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Unmute Mic1 and Line1 pin widget input buffers since they start as * inputs. If the pin mode is changed by the user the pin mode control * will take care of enabling the pin's input/output buffers as needed. @@ -3928,33 +4122,33 @@ static void alc260_auto_init(struct hda_ /* * ALC260 configurations */ -static struct hda_board_config alc260_cfg_tbl[] = { - { .modelname = "basic", .config = ALC260_BASIC }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, - .config = ALC260_BASIC }, /* Sony VAIO */ - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc, - .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */ - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd, - .config = ALC260_BASIC }, /* Sony VAIO */ - { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729, - .config = ALC260_BASIC }, /* CTL Travel Master U553W */ - { .modelname = "hp", .config = ALC260_HP }, - { .modelname = "hp-3013", .config = ALC260_HP_3013 }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, - { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, - { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, - { .modelname = "acer", .config = ALC260_ACER }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER }, +static const char *alc260_models[ALC260_MODEL_LAST] = { + [ALC260_BASIC] = "basic", + [ALC260_HP] = "hp", + [ALC260_HP_3013] = "hp-3013", + [ALC260_FUJITSU_S702X] = "fujitsu", + [ALC260_ACER] = "acer", #ifdef CONFIG_SND_DEBUG - { .modelname = "test", .config = ALC260_TEST }, + [ALC260_TEST] = "test", #endif - { .modelname = "auto", .config = ALC260_AUTO }, + [ALC260_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc260_cfg_tbl[] = { + SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), + SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), + SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), + SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), + SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), + SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), + SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), + SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), + SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), + SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), + SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), + SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), + SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), + SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), {} }; @@ -4053,8 +4247,10 @@ static int patch_alc260(struct hda_codec codec->spec = spec; - board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); - if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { + board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, + alc260_models, + alc260_cfg_tbl); + if (board_config < 0) { snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " "trying auto-probe from BIOS...\n"); board_config = ALC260_AUTO; @@ -4313,6 +4509,100 @@ static struct hda_verb alc882_eapd_verbs { } }; +/* Mac Pro test */ +static struct snd_kcontrol_new alc882_macpro_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), + { } /* end */ +}; + +static struct hda_verb alc882_macpro_init_verbs[] = { + /* Front mixer: unmute input/output amp left and right (volume = 0) */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + /* Front Pin: output 0 (0x0c) */ + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, + /* Front Mic pin: input vref at 80% */ + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Speaker: output */ + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, + /* Headphone output (output 0 - 0x0c) */ + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, + + /* FIXME: use matrix-type input source selection */ + /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ + /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + /* Input mixer2 */ + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + /* Input mixer3 */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + /* ADC1: mute amp left and right */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, + /* ADC2: mute amp left and right */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + /* ADC3: mute amp left and right */ + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, + + { } +}; +static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) +{ + unsigned int gpiostate, gpiomask, gpiodir; + + gpiostate = snd_hda_codec_read(codec, codec->afg, 0, + AC_VERB_GET_GPIO_DATA, 0); + + if (!muted) + gpiostate |= (1 << pin); + else + gpiostate &= ~(1 << pin); + + gpiomask = snd_hda_codec_read(codec, codec->afg, 0, + AC_VERB_GET_GPIO_MASK, 0); + gpiomask |= (1 << pin); + + gpiodir = snd_hda_codec_read(codec, codec->afg, 0, + AC_VERB_GET_GPIO_DIRECTION, 0); + gpiodir |= (1 << pin); + + + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_MASK, gpiomask); + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_DIRECTION, gpiodir); + + msleep(1); + + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_DATA, gpiostate); +} + /* * generic initialization of ADC, input mixers and output mixers */ @@ -4435,19 +4725,19 @@ #define alc882_pcm_digital_capture alc88 /* * configuration and preset */ -static struct hda_board_config alc882_cfg_tbl[] = { - { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, - { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, - { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, - .config = ALC882_6ST_DIG }, /* MSI */ - { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, - .config = ALC882_6ST_DIG }, /* Foxconn */ - { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, - .config = ALC882_6ST_DIG }, /* ECS to Intel*/ - { .modelname = "arima", .config = ALC882_ARIMA }, - { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054, - .config = ALC882_ARIMA }, /* Arima W820Di1 */ - { .modelname = "auto", .config = ALC882_AUTO }, +static const char *alc882_models[ALC882_MODEL_LAST] = { + [ALC882_3ST_DIG] = "3stack-dig", + [ALC882_6ST_DIG] = "6stack-dig", + [ALC882_ARIMA] = "arima", + [ALC885_MACPRO] = "macpro", + [ALC882_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc882_cfg_tbl[] = { + SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), + SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), + SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), + SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), {} }; @@ -4484,6 +4774,17 @@ static struct alc_config_preset alc882_p .channel_mode = alc882_sixstack_modes, .input_mux = &alc882_capture_source, }, + [ALC885_MACPRO] = { + .mixers = { alc882_macpro_mixer }, + .init_verbs = { alc882_macpro_init_verbs }, + .num_dacs = ARRAY_SIZE(alc882_dac_nids), + .dac_nids = alc882_dac_nids, + .dig_out_nid = ALC882_DIGOUT_NID, + .dig_in_nid = ALC882_DIGIN_NID, + .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), + .channel_mode = alc882_ch_modes, + .input_mux = &alc882_capture_source, + }, }; @@ -4584,7 +4885,9 @@ static int patch_alc882(struct hda_codec codec->spec = spec; - board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); + board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, + alc882_models, + alc882_cfg_tbl); if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { printk(KERN_INFO "hda_codec: Unknown model for ALC882, " @@ -4609,6 +4912,11 @@ static int patch_alc882(struct hda_codec if (board_config != ALC882_AUTO) setup_preset(spec, &alc882_presets[board_config]); + if (board_config == ALC885_MACPRO) { + alc882_gpio_mute(codec, 0, 0); + alc882_gpio_mute(codec, 1, 0); + } + spec->stream_name_analog = "ALC882 Analog"; spec->stream_analog_playback = &alc882_pcm_analog_playback; spec->stream_analog_capture = &alc882_pcm_analog_capture; @@ -4767,6 +5075,13 @@ static struct hda_channel_mode alc883_si { 8, alc883_sixstack_ch8_init }, }; +static struct hda_verb alc883_medion_eapd_verbs[] = { + /* eanable EAPD on medion laptop */ + {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, + {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, + { } +}; + /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b */ @@ -4875,6 +5190,97 @@ static struct snd_kcontrol_new alc883_3S { } /* end */ }; +static struct snd_kcontrol_new alc883_fivestack_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), + HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, + .info = alc883_mux_enum_info, + .get = alc883_mux_enum_get, + .put = alc883_mux_enum_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc883_tagra_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), + HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 2, + .info = alc883_mux_enum_info, + .get = alc883_mux_enum_get, + .put = alc883_mux_enum_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 2, + .info = alc883_mux_enum_info, + .get = alc883_mux_enum_get, + .put = alc883_mux_enum_put, + }, + { } /* end */ +}; + static struct snd_kcontrol_new alc883_chmode_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -4963,6 +5369,45 @@ static struct hda_verb alc883_init_verbs { } }; +static struct hda_verb alc883_tagra_verbs[] = { + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + + {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ + {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ + {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ + + {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, + {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, + {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, + {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, + + { } /* end */ +}; + +/* toggle speaker-output according to the hp-jack state */ +static void alc883_tagra_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x14, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); +} + +static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) +{ + if ((res >> 26) == ALC880_HP_EVENT) + alc883_tagra_automute(codec); +} + /* * generic initialization of ADC, input mixers and output mixers */ @@ -5057,30 +5502,41 @@ #define alc883_pcm_digital_capture alc88 /* * configuration and preset */ -static struct hda_board_config alc883_cfg_tbl[] = { - { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG }, - { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG }, - { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, - .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/ - { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch }, - { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d, - .config = ALC883_3ST_6ch }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601, - .config = ALC883_3ST_6ch }, /* D102GGC */ - { .modelname = "6stack-dig", .config = ALC883_6ST_DIG }, - { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, - .config = ALC883_6ST_DIG }, /* MSI */ - { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, - .config = ALC883_6ST_DIG }, /* Foxconn */ - { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD }, - { .modelname = "acer", .config = ALC883_ACER }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/, - .config = ALC883_ACER }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102, - .config = ALC883_ACER }, - { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f, - .config = ALC883_ACER }, - { .modelname = "auto", .config = ALC883_AUTO }, +static const char *alc883_models[ALC883_MODEL_LAST] = { + [ALC883_3ST_2ch_DIG] = "3stack-dig", + [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", + [ALC883_3ST_6ch] = "3stack-6ch", + [ALC883_6ST_DIG] = "6stack-dig", + [ALC883_TARGA_DIG] = "targa-dig", + [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", + [ALC888_DEMO_BOARD] = "6stack-dig-demo", + [ALC883_ACER] = "acer", + [ALC883_MEDION] = "medion", + [ALC883_LAPTOP_EAPD] = "laptop-eapd", + [ALC883_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc883_cfg_tbl[] = { + SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), + SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), + SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), + SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), + SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), + SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), + SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), + SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), + SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), + SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), + SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), + SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), + SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), + SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), {} }; @@ -5137,6 +5593,35 @@ static struct alc_config_preset alc883_p .channel_mode = alc883_sixstack_modes, .input_mux = &alc883_capture_source, }, + [ALC883_TARGA_DIG] = { + .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, + .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, + .num_dacs = ARRAY_SIZE(alc883_dac_nids), + .dac_nids = alc883_dac_nids, + .dig_out_nid = ALC883_DIGOUT_NID, + .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), + .adc_nids = alc883_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), + .channel_mode = alc883_3ST_6ch_modes, + .need_dac_fix = 1, + .input_mux = &alc883_capture_source, + .unsol_event = alc883_tagra_unsol_event, + .init_hook = alc883_tagra_automute, + }, + [ALC883_TARGA_2ch_DIG] = { + .mixers = { alc883_tagra_2ch_mixer}, + .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, + .num_dacs = ARRAY_SIZE(alc883_dac_nids), + .dac_nids = alc883_dac_nids, + .dig_out_nid = ALC883_DIGOUT_NID, + .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), + .adc_nids = alc883_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), + .channel_mode = alc883_3ST_2ch_modes, + .input_mux = &alc883_capture_source, + .unsol_event = alc883_tagra_unsol_event, + .init_hook = alc883_tagra_automute, + }, [ALC888_DEMO_BOARD] = { .mixers = { alc883_base_mixer, alc883_chmode_mixer }, .init_verbs = { alc883_init_verbs }, @@ -5167,6 +5652,31 @@ static struct alc_config_preset alc883_p .channel_mode = alc883_3ST_2ch_modes, .input_mux = &alc883_capture_source, }, + [ALC883_MEDION] = { + .mixers = { alc883_fivestack_mixer, + alc883_chmode_mixer }, + .init_verbs = { alc883_init_verbs, + alc883_medion_eapd_verbs }, + .num_dacs = ARRAY_SIZE(alc883_dac_nids), + .dac_nids = alc883_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), + .adc_nids = alc883_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), + .channel_mode = alc883_sixstack_modes, + .input_mux = &alc883_capture_source, + }, + [ALC883_LAPTOP_EAPD] = { + .mixers = { alc883_base_mixer, + alc883_chmode_mixer }, + .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, + .num_dacs = ARRAY_SIZE(alc883_dac_nids), + .dac_nids = alc883_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), + .adc_nids = alc883_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), + .channel_mode = alc883_3ST_2ch_modes, + .input_mux = &alc883_capture_source, + }, }; @@ -5275,8 +5785,10 @@ static int patch_alc883(struct hda_codec codec->spec = spec; - board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl); - if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { + board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, + alc883_models, + alc883_cfg_tbl); + if (board_config < 0) { printk(KERN_INFO "hda_codec: Unknown model for ALC883, " "trying auto-probe from BIOS...\n"); board_config = ALC883_AUTO; @@ -5353,6 +5865,24 @@ static struct snd_kcontrol_new alc262_ba { } /* end */ }; +static struct snd_kcontrol_new alc262_hippo1_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), + /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), + HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ + /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ + HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), + { } /* end */ +}; + static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), @@ -5457,6 +5987,103 @@ static struct hda_verb alc262_init_verbs { } }; +static struct hda_verb alc262_hippo_unsol_verbs[] = { + {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {} +}; + +static struct hda_verb alc262_hippo1_unsol_verbs[] = { + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, + {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + + {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {} +}; + +/* mute/unmute internal speaker according to the hp jack and mute state */ +static void alc262_hippo_automute(struct hda_codec *codec, int force) +{ + struct alc_spec *spec = codec->spec; + unsigned int mute; + + if (force || ! spec->sense_updated) { + unsigned int present; + /* need to execute and sync at first */ + snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); + present = snd_hda_codec_read(codec, 0x15, 0, + AC_VERB_GET_PIN_SENSE, 0); + spec->jack_present = (present & 0x80000000) != 0; + spec->sense_updated = 1; + } + if (spec->jack_present) { + /* mute internal speaker */ + snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, + 0x80, 0x80); + snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, + 0x80, 0x80); + } else { + /* unmute internal speaker if necessary */ + mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); + snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, + 0x80, mute & 0x80); + mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0); + snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, + 0x80, mute & 0x80); + } +} + +/* unsolicited event for HP jack sensing */ +static void alc262_hippo_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + if ((res >> 26) != ALC880_HP_EVENT) + return; + alc262_hippo_automute(codec, 1); +} + +static void alc262_hippo1_automute(struct hda_codec *codec, int force) +{ + struct alc_spec *spec = codec->spec; + unsigned int mute; + + if (force || ! spec->sense_updated) { + unsigned int present; + /* need to execute and sync at first */ + snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); + present = snd_hda_codec_read(codec, 0x1b, 0, + AC_VERB_GET_PIN_SENSE, 0); + spec->jack_present = (present & 0x80000000) != 0; + spec->sense_updated = 1; + } + if (spec->jack_present) { + /* mute internal speaker */ + snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, + 0x80, 0x80); + snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, + 0x80, 0x80); + } else { + /* unmute internal speaker if necessary */ + mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); + snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, + 0x80, mute & 0x80); + mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0); + snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, + 0x80, mute & 0x80); + } +} + +/* unsolicited event for HP jack sensing */ +static void alc262_hippo1_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + if ((res >> 26) != ALC880_HP_EVENT) + return; + alc262_hippo1_automute(codec, 1); +} + /* * fujitsu model * 0x14 = headphone/spdif-out, 0x15 = internal speaker @@ -5864,26 +6491,27 @@ static void alc262_auto_init(struct hda_ /* * configuration and preset */ -static struct hda_board_config alc262_cfg_tbl[] = { - { .modelname = "basic", .config = ALC262_BASIC }, - { .modelname = "fujitsu", .config = ALC262_FUJITSU }, - { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, - .config = ALC262_FUJITSU }, - { .modelname = "hp-bpc", .config = ALC262_HP_BPC }, - { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c, - .config = ALC262_HP_BPC }, /* xw4400 */ - { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801, - .config = ALC262_HP_BPC }, /* q965 */ - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, - .config = ALC262_HP_BPC }, /* xw6400 */ - { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, - .config = ALC262_HP_BPC }, /* xw8400 */ - { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe, - .config = ALC262_HP_BPC }, /* xw9400 */ - { .modelname = "benq", .config = ALC262_BENQ_ED8 }, - { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560, - .config = ALC262_BENQ_ED8 }, - { .modelname = "auto", .config = ALC262_AUTO }, +static const char *alc262_models[ALC262_MODEL_LAST] = { + [ALC262_BASIC] = "basic", + [ALC262_HIPPO] = "hippo", + [ALC262_HIPPO_1] = "hippo_1", + [ALC262_FUJITSU] = "fujitsu", + [ALC262_HP_BPC] = "hp-bpc", + [ALC262_BENQ_ED8] = "benq", + [ALC262_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc262_cfg_tbl[] = { + SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), + SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), + SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), + SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC), + SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), + SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), + SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), + SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), + SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), + SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), {} }; @@ -5898,6 +6526,30 @@ static struct alc_config_preset alc262_p .channel_mode = alc262_modes, .input_mux = &alc262_capture_source, }, + [ALC262_HIPPO] = { + .mixers = { alc262_base_mixer }, + .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, + .num_dacs = ARRAY_SIZE(alc262_dac_nids), + .dac_nids = alc262_dac_nids, + .hp_nid = 0x03, + .dig_out_nid = ALC262_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc262_modes), + .channel_mode = alc262_modes, + .input_mux = &alc262_capture_source, + .unsol_event = alc262_hippo_unsol_event, + }, + [ALC262_HIPPO_1] = { + .mixers = { alc262_hippo1_mixer }, + .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, + .num_dacs = ARRAY_SIZE(alc262_dac_nids), + .dac_nids = alc262_dac_nids, + .hp_nid = 0x02, + .dig_out_nid = ALC262_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc262_modes), + .channel_mode = alc262_modes, + .input_mux = &alc262_capture_source, + .unsol_event = alc262_hippo1_unsol_event, + }, [ALC262_FUJITSU] = { .mixers = { alc262_fujitsu_mixer }, .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, @@ -5938,7 +6590,7 @@ static int patch_alc262(struct hda_codec int board_config; int err; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -5954,9 +6606,11 @@ #if 0 } #endif - board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); + board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, + alc262_models, + alc262_cfg_tbl); - if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { + if (board_config < 0) { printk(KERN_INFO "hda_codec: Unknown model for ALC262, " "trying auto-probe from BIOS...\n"); board_config = ALC262_AUTO; @@ -6076,6 +6730,44 @@ static struct hda_channel_mode alc861_un { 4, alc861_uniwill_m31_ch4_init }, }; +/* Set mic1 and line-in as input and unmute the mixer */ +static struct hda_verb alc861_asus_ch2_init[] = { + /* set pin widget 1Ah (line in) for input */ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, +#if 0 + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ +#endif + { } /* end */ +}; +/* Set mic1 nad line-in as output and mute mixer */ +static struct hda_verb alc861_asus_ch6_init[] = { + /* set pin widget 1Ah (line in) for output (Back Surround)*/ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ + /* set pin widget 18h (mic1) for output (CLFE)*/ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ + { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, + { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, + + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, +#if 0 + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ +#endif + { } /* end */ +}; + +static struct hda_channel_mode alc861_asus_modes[2] = { + { 2, alc861_asus_ch2_init }, + { 6, alc861_asus_ch6_init }, +}; + /* patch-ALC861 */ static struct snd_kcontrol_new alc861_base_mixer[] = { @@ -6152,7 +6844,29 @@ static struct snd_kcontrol_new alc861_3S .private_value = ARRAY_SIZE(alc861_threestack_modes), }, { } /* end */ -}; +}; + +static struct snd_kcontrol_new alc861_toshiba_mixer[] = { + /* output mixer control */ + HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), + + /*Capture mixer control */ + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + + { } /* end */ +}; + static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { /* output mixer control */ HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), @@ -6194,7 +6908,58 @@ static struct snd_kcontrol_new alc861_un }, { } /* end */ }; - + +static struct snd_kcontrol_new alc861_asus_mixer[] = { + /* output mixer control */ + HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), + + /* Input mixer control */ + HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */ + + /* Capture mixer control */ + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Channel Mode", + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, + .private_value = ARRAY_SIZE(alc861_asus_modes), + }, + { } +}; + +/* additional mixer */ +static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { + HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), + { } +}; + /* * generic initialization of ADC, input mixers and output mixers */ @@ -6215,7 +6980,7 @@ static struct hda_verb alc861_base_init_ /* port-E for HP out (front panel) */ { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* route front PCM to HP */ - { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, /* port-F for mic-in (front panel) with vref */ { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* port-G for CLFE (rear panel) */ @@ -6279,7 +7044,7 @@ static struct hda_verb alc861_threestack /* port-E for HP out (front panel) */ { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* route front PCM to HP */ - { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, /* port-F for mic-in (front panel) with vref */ { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* port-G for CLFE (rear panel) */ @@ -6339,7 +7104,7 @@ static struct hda_verb alc861_uniwill_m3 /* port-E for HP out (front panel) */ { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 /* route front PCM to HP */ - { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, /* port-F for mic-in (front panel) with vref */ { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* port-G for CLFE (rear panel) */ @@ -6383,6 +7148,74 @@ static struct hda_verb alc861_uniwill_m3 { } }; +static struct hda_verb alc861_asus_init_verbs[] = { + /* + * Unmute ADC0 and set the default input to mic-in + */ + /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ + { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ + /* route front PCM to HP */ + { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, + /* port-B for mic-in (rear panel) with vref */ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-C for line-in (rear panel) */ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* port-D for Front */ + { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-E for HP out (front panel) */ + { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ + /* route front PCM to HP */ + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-F for mic-in (front panel) with vref */ + { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-G for CLFE (rear panel) */ + { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + /* port-H for side (rear panel) */ + { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + /* CD-in */ + { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* route front mic to ADC1*/ + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + /* Unmute DAC0~3 & spdif out*/ + {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* Unmute Mixer 14 (mic) 1c (Line in)*/ + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* Unmute Stereo Mixer 15 */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ + + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */ + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + { } +}; + +/* additional init verbs for ASUS laptops */ +static struct hda_verb alc861_asus_laptop_init_verbs[] = { + { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ + { } +}; + /* * generic initialization of ADC, input mixers and output mixers */ @@ -6435,6 +7268,39 @@ static struct hda_verb alc861_auto_init_ { } }; +static struct hda_verb alc861_toshiba_init_verbs[] = { + {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + + { } +}; + +/* toggle speaker-output according to the hp-jack state */ +static void alc861_toshiba_automute(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_codec_read(codec, 0x0f, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0, + 0x80, present ? 0x80 : 0); + snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3, + 0x80, present ? 0 : 0x80); + snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3, + 0x80, present ? 0 : 0x80); +} + +static void alc861_toshiba_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + /* Looks like the unsol event is incompatible with the standard + * definition. 6bit tag is placed at 26 bit! + */ + if ((res >> 26) == ALC880_HP_EVENT) + alc861_toshiba_automute(codec); +} + /* pcm configuration: identiacal with ALC880 */ #define alc861_pcm_analog_playback alc880_pcm_analog_playback #define alc861_pcm_analog_capture alc880_pcm_analog_capture @@ -6708,19 +7574,26 @@ static void alc861_auto_init(struct hda_ /* * configuration and preset */ -static struct hda_board_config alc861_cfg_tbl[] = { - { .modelname = "3stack", .config = ALC861_3ST }, - { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, - .config = ALC861_3ST }, - { .modelname = "3stack-660", .config = ALC660_3ST }, - { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7, - .config = ALC660_3ST }, - { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, - { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, - { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31}, - { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072, - .config = ALC861_UNIWILL_M31 }, - { .modelname = "auto", .config = ALC861_AUTO }, +static const char *alc861_models[ALC861_MODEL_LAST] = { + [ALC861_3ST] = "3stack", + [ALC660_3ST] = "3stack-660", + [ALC861_3ST_DIG] = "3stack-dig", + [ALC861_6ST_DIG] = "6stack-dig", + [ALC861_UNIWILL_M31] = "uniwill-m31", + [ALC861_TOSHIBA] = "toshiba", + [ALC861_ASUS] = "asus", + [ALC861_ASUS_LAPTOP] = "asus-laptop", + [ALC861_AUTO] = "auto", +}; + +static struct snd_pci_quirk alc861_cfg_tbl[] = { + SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), + SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), + SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), + SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), + SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), + SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), + SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), {} }; @@ -6787,8 +7660,48 @@ static struct alc_config_preset alc861_p .adc_nids = alc861_adc_nids, .input_mux = &alc861_capture_source, }, - -}; + [ALC861_TOSHIBA] = { + .mixers = { alc861_toshiba_mixer }, + .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), + .channel_mode = alc883_3ST_2ch_modes, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + .unsol_event = alc861_toshiba_unsol_event, + .init_hook = alc861_toshiba_automute, + }, + [ALC861_ASUS] = { + .mixers = { alc861_asus_mixer }, + .init_verbs = { alc861_asus_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .dig_out_nid = ALC861_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), + .channel_mode = alc861_asus_modes, + .need_dac_fix = 1, + .hp_nid = 0x06, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + }, + [ALC861_ASUS_LAPTOP] = { + .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, + .init_verbs = { alc861_asus_init_verbs, + alc861_asus_laptop_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .dig_out_nid = ALC861_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), + .channel_mode = alc883_3ST_2ch_modes, + .need_dac_fix = 1, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + }, +}; static int patch_alc861(struct hda_codec *codec) @@ -6797,15 +7710,17 @@ static int patch_alc861(struct hda_codec int board_config; int err; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; codec->spec = spec; - board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); + board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, + alc861_models, + alc861_cfg_tbl); - if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { + if (board_config < 0) { printk(KERN_INFO "hda_codec: Unknown model for ALC861, " "trying auto-probe from BIOS...\n"); board_config = ALC861_AUTO; @@ -6856,7 +7771,8 @@ struct hda_codec_preset snd_hda_preset_r { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861", .patch = patch_alc861 }, - { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", + { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", .patch = patch_alc861 }, + { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 }, {} /* terminator */ }; diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index fe51ef3..4e3fc95 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -37,14 +37,30 @@ #include "hda_local.h" #define NUM_CONTROL_ALLOC 32 #define STAC_HP_EVENT 0x37 -#define STAC_REF 0 -#define STAC_D945GTP3 1 -#define STAC_D945GTP5 2 -#define STAC_MACMINI 3 -#define STAC_922X_MODELS 4 /* number of 922x models */ -#define STAC_D965_3ST 4 -#define STAC_D965_5ST 5 -#define STAC_927X_MODELS 6 /* number of 922x models */ +enum { + STAC_REF, + STAC_9200_MODELS +}; + +enum { + STAC_9205_REF, + STAC_9205_MODELS +}; + +enum { + STAC_D945_REF, + STAC_D945GTP3, + STAC_D945GTP5, + STAC_MACMINI, + STAC_922X_MODELS +}; + +enum { + STAC_D965_REF, + STAC_D965_3ST, + STAC_D965_5ST, + STAC_927X_MODELS +}; struct sigmatel_spec { struct snd_kcontrol_new *mixers[4]; @@ -67,6 +83,9 @@ struct sigmatel_spec { unsigned int num_adcs; hda_nid_t *mux_nids; unsigned int num_muxes; + hda_nid_t *dmic_nids; + unsigned int num_dmics; + hda_nid_t dmux_nid; hda_nid_t dig_in_nid; /* pin widgets */ @@ -80,6 +99,8 @@ struct sigmatel_spec { struct snd_kcontrol_new *mixer; /* capture source */ + struct hda_input_mux *dinput_mux; + unsigned int cur_dmux; struct hda_input_mux *input_mux; unsigned int cur_mux[3]; @@ -92,6 +113,7 @@ struct sigmatel_spec { struct auto_pin_cfg autocfg; unsigned int num_kctl_alloc, num_kctl_used; struct snd_kcontrol_new *kctl_alloc; + struct hda_input_mux private_dimux; struct hda_input_mux private_imux; }; @@ -131,6 +153,10 @@ static hda_nid_t stac9205_mux_nids[2] = 0x19, 0x1a }; +static hda_nid_t stac9205_dmic_nids[3] = { + 0x17, 0x18, 0 +}; + static hda_nid_t stac9200_pin_nids[8] = { 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, @@ -154,6 +180,34 @@ static hda_nid_t stac9205_pin_nids[12] = }; +static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + return snd_hda_input_mux_info(spec->dinput_mux, uinfo); +} + +static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + + ucontrol->value.enumerated.item[0] = spec->cur_dmux; + return 0; +} + +static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + + return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, + spec->dmux_nid, &spec->cur_dmux); +} + static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); @@ -263,7 +317,7 @@ static struct snd_kcontrol_new stac9227_ { } /* end */ }; -static snd_kcontrol_new_t stac927x_mixer[] = { +static struct snd_kcontrol_new stac927x_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Source", @@ -278,7 +332,15 @@ static snd_kcontrol_new_t stac927x_mixer { } /* end */ }; -static snd_kcontrol_new_t stac9205_mixer[] = { +static struct snd_kcontrol_new stac9205_mixer[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Digital Input Source", + .count = 1, + .info = stac92xx_dmux_enum_info, + .get = stac92xx_dmux_enum_get, + .put = stac92xx_dmux_enum_put, + }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Source", @@ -327,22 +389,25 @@ static unsigned int ref9200_pin_configs[ 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, }; -static unsigned int *stac9200_brd_tbl[] = { - ref9200_pin_configs, +static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { + [STAC_REF] = ref9200_pin_configs, +}; + +static const char *stac9200_models[STAC_9200_MODELS] = { + [STAC_REF] = "ref", }; -static struct hda_board_config stac9200_cfg_tbl[] = { - { .modelname = "ref", - .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2668, /* DFI LanParty */ - .config = STAC_REF }, +static struct snd_pci_quirk stac9200_cfg_tbl[] = { + /* SigmaTel reference board */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, + "DFI LanParty", STAC_REF), /* Dell laptops have BIOS problem */ - { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5, - .config = STAC_REF }, /* Dell Inspiron 630m */ - { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2, - .config = STAC_REF }, /* Dell Latitude D620 */ - { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb, - .config = STAC_REF }, /* Dell Latitude 120L */ + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, + "Dell Inspiron 630m", STAC_REF), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, + "Dell Latitude D620", STAC_REF), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, + "Dell Latitude 120L", STAC_REF), {} /* terminator */ }; @@ -365,100 +430,80 @@ static unsigned int d945gtp5_pin_configs }; static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { - [STAC_REF] = ref922x_pin_configs, + [STAC_D945_REF] = ref922x_pin_configs, [STAC_D945GTP3] = d945gtp3_pin_configs, [STAC_D945GTP5] = d945gtp5_pin_configs, [STAC_MACMINI] = d945gtp5_pin_configs, }; -static struct hda_board_config stac922x_cfg_tbl[] = { - { .modelname = "5stack", .config = STAC_D945GTP5 }, - { .modelname = "3stack", .config = STAC_D945GTP3 }, - { .modelname = "ref", - .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2668, /* DFI LanParty */ - .config = STAC_REF }, /* SigmaTel reference board */ - /* Intel 945G based systems */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0101, - .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0202, - .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0606, - .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0601, - .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0111, - .config = STAC_D945GTP3 }, /* Intel D945GZP - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x1115, - .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x1116, - .config = STAC_D945GTP3 }, /* Intel D945GBO - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x1117, - .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x1118, - .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x1119, - .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x8826, - .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x5049, - .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x5055, - .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x5048, - .config = STAC_D945GTP3 }, /* Intel D945GPB - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0110, - .config = STAC_D945GTP3 }, /* Intel D945GLR - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0404, - .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0303, - .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0013, - .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0417, - .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */ - /* Intel 945P based systems */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0b0b, - .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0112, - .config = STAC_D945GTP3 }, /* Intel D945PLN - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0d0d, - .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0909, - .config = STAC_D945GTP3 }, /* Intel D945PAW - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0505, - .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x0707, - .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */ - /* other systems */ - { .pci_subvendor = 0x8384, - .pci_subdevice = 0x7680, - .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */ +static const char *stac922x_models[STAC_922X_MODELS] = { + [STAC_D945_REF] = "ref", + [STAC_D945GTP5] = "5stack", + [STAC_D945GTP3] = "3stack", + [STAC_MACMINI] = "macmini", +}; + +static struct snd_pci_quirk stac922x_cfg_tbl[] = { + /* SigmaTel reference board */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, + "DFI LanParty", STAC_D945_REF), + /* Intel 945G based systems */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, + "Intel D945G", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, + "Intel D945G", STAC_D945GTP3), + /* Intel D945G 5-stack systems */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, + "Intel D945G", STAC_D945GTP5), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, + "Intel D945G", STAC_D945GTP5), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, + "Intel D945G", STAC_D945GTP5), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, + "Intel D945G", STAC_D945GTP5), + /* Intel 945P based systems */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, + "Intel D945P", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, + "Intel D945P", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, + "Intel D945P", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, + "Intel D945P", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, + "Intel D945P", STAC_D945GTP3), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, + "Intel D945P", STAC_D945GTP5), + /* other systems */ + /* Apple Mac Mini (early 2006) */ + SND_PCI_QUIRK(0x8384, 0x7680, + "Mac Mini", STAC_MACMINI), {} /* terminator */ }; @@ -484,120 +529,72 @@ static unsigned int d965_5st_pin_configs }; static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { - [STAC_REF] = ref927x_pin_configs, + [STAC_D965_REF] = ref927x_pin_configs, [STAC_D965_3ST] = d965_3st_pin_configs, [STAC_D965_5ST] = d965_5st_pin_configs, }; -static struct hda_board_config stac927x_cfg_tbl[] = { - { .modelname = "5stack", .config = STAC_D965_5ST }, - { .modelname = "3stack", .config = STAC_D965_3ST }, - { .modelname = "ref", - .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2668, /* DFI LanParty */ - .config = STAC_REF }, /* SigmaTel reference board */ +static const char *stac927x_models[STAC_927X_MODELS] = { + [STAC_D965_REF] = "ref", + [STAC_D965_3ST] = "3stack", + [STAC_D965_5ST] = "5stack", +}; + +static struct snd_pci_quirk stac927x_cfg_tbl[] = { + /* SigmaTel reference board */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, + "DFI LanParty", STAC_D965_REF), /* Intel 946 based systems */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x3d01, - .config = STAC_D965_3ST }, /* D946 configuration */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0xa301, - .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), /* 965 based 3 stack systems */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2116, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2115, - .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2114, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2113, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2112, - .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2111, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2110, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2009, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2008, - .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2007, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2006, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2005, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2004, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2003, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2002, - .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2001, - .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), /* 965 based 5 stack systems */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2301, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2302, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2303, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2304, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2305, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2501, - .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2502, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2503, - .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ - { .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2504, - .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST), {} /* terminator */ }; static unsigned int ref9205_pin_configs[12] = { 0x40000100, 0x40000100, 0x01016011, 0x01014010, - 0x01813122, 0x01a19021, 0x40000100, 0x40000100, - 0x40000100, 0x40000100, 0x01441030, 0x01c41030 + 0x01813122, 0x01a19021, 0x40000100, 0x40000100, + 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 }; -static unsigned int *stac9205_brd_tbl[] = { +static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { ref9205_pin_configs, }; -static struct hda_board_config stac9205_cfg_tbl[] = { - { .modelname = "ref", - .pci_subvendor = PCI_VENDOR_ID_INTEL, - .pci_subdevice = 0x2668, /* DFI LanParty */ - .config = STAC_REF }, /* SigmaTel reference board */ +static const char *stac9205_models[STAC_9205_MODELS] = { + [STAC_9205_REF] = "ref", +}; + +static struct snd_pci_quirk stac9205_cfg_tbl[] = { + /* SigmaTel reference board */ + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, + "DFI LanParty", STAC_9205_REF), {} /* terminator */ }; @@ -1154,6 +1151,58 @@ static int stac92xx_auto_create_hp_ctls( return 0; } +/* labels for dmic mux inputs */ +static const char *stac92xx_dmic_labels[5] = { + "Analog Inputs", "Digital Mic 1", "Digital Mic 2", + "Digital Mic 3", "Digital Mic 4" +}; + +/* create playback/capture controls for input pins on dmic capable codecs */ +static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, + const struct auto_pin_cfg *cfg) +{ + struct sigmatel_spec *spec = codec->spec; + struct hda_input_mux *dimux = &spec->private_dimux; + hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; + int i, j; + + dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; + dimux->items[dimux->num_items].index = 0; + dimux->num_items++; + + for (i = 0; i < spec->num_dmics; i++) { + int index; + int num_cons; + unsigned int def_conf; + + def_conf = snd_hda_codec_read(codec, + spec->dmic_nids[i], + 0, + AC_VERB_GET_CONFIG_DEFAULT, + 0); + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) + continue; + + num_cons = snd_hda_get_connections(codec, + spec->dmux_nid, + con_lst, + HDA_MAX_NUM_INPUTS); + for (j = 0; j < num_cons; j++) + if (con_lst[j] == spec->dmic_nids[i]) { + index = j; + goto found; + } + continue; +found: + dimux->items[dimux->num_items].label = + stac92xx_dmic_labels[dimux->num_items]; + dimux->items[dimux->num_items].index = index; + dimux->num_items++; + } + + return 0; +} + /* create playback/capture controls for input pins */ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { @@ -1238,7 +1287,9 @@ static int stac92xx_parse_auto_config(st struct sigmatel_spec *spec = codec->spec; int err; - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) + if ((err = snd_hda_parse_pin_def_config(codec, + &spec->autocfg, + spec->dmic_nids)) < 0) return err; if (! spec->autocfg.line_outs) return 0; /* can't find valid pin config */ @@ -1254,6 +1305,11 @@ static int stac92xx_parse_auto_config(st (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) return err; + if (spec->num_dmics > 0) + if ((err = stac92xx_auto_create_dmic_input_ctls(codec, + &spec->autocfg)) < 0) + return err; + spec->multiout.max_channels = spec->multiout.num_dacs * 2; if (spec->multiout.max_channels > 2) spec->surr_switch = 1; @@ -1267,6 +1323,7 @@ static int stac92xx_parse_auto_config(st spec->mixers[spec->num_mixers++] = spec->kctl_alloc; spec->input_mux = &spec->private_imux; + spec->dinput_mux = &spec->private_dimux; return 1; } @@ -1366,6 +1423,7 @@ static int stac9200_parse_auto_config(st spec->mixers[spec->num_mixers++] = spec->kctl_alloc; spec->input_mux = &spec->private_imux; + spec->dinput_mux = &spec->private_dimux; return 1; } @@ -1448,6 +1506,11 @@ static int stac92xx_init(struct hda_code stac92xx_auto_set_pinctl(codec, nid, pinctl); } } + if (spec->num_dmics > 0) + for (i = 0; i < spec->num_dmics; i++) + stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], + AC_PINCTL_IN_EN); + if (cfg->dig_out_pin) stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, AC_PINCTL_OUT_EN); @@ -1598,7 +1661,9 @@ static int patch_stac9200(struct hda_cod codec->spec = spec; spec->num_pins = 8; spec->pin_nids = stac9200_pin_nids; - spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl); + spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, + stac9200_models, + stac9200_cfg_tbl); if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); err = stac92xx_save_bios_config_regs(codec); @@ -1618,6 +1683,7 @@ static int patch_stac9200(struct hda_cod spec->adc_nids = stac9200_adc_nids; spec->mux_nids = stac9200_mux_nids; spec->num_muxes = 1; + spec->num_dmics = 0; spec->init = stac9200_core_init; spec->mixer = stac9200_mixer; @@ -1645,7 +1711,9 @@ static int patch_stac922x(struct hda_cod codec->spec = spec; spec->num_pins = 10; spec->pin_nids = stac922x_pin_nids; - spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); + spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, + stac922x_models, + stac922x_cfg_tbl); if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " "using BIOS defaults\n"); @@ -1663,6 +1731,7 @@ static int patch_stac922x(struct hda_cod spec->adc_nids = stac922x_adc_nids; spec->mux_nids = stac922x_mux_nids; spec->num_muxes = 2; + spec->num_dmics = 0; spec->init = stac922x_core_init; spec->mixer = stac922x_mixer; @@ -1695,7 +1764,9 @@ static int patch_stac927x(struct hda_cod codec->spec = spec; spec->num_pins = 14; spec->pin_nids = stac927x_pin_nids; - spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl); + spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, + stac927x_models, + stac927x_cfg_tbl); if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); err = stac92xx_save_bios_config_regs(codec); @@ -1714,6 +1785,7 @@ static int patch_stac927x(struct hda_cod spec->adc_nids = stac927x_adc_nids; spec->mux_nids = stac927x_mux_nids; spec->num_muxes = 3; + spec->num_dmics = 0; spec->init = d965_core_init; spec->mixer = stac9227_mixer; break; @@ -1721,6 +1793,7 @@ static int patch_stac927x(struct hda_cod spec->adc_nids = stac927x_adc_nids; spec->mux_nids = stac927x_mux_nids; spec->num_muxes = 3; + spec->num_dmics = 0; spec->init = d965_core_init; spec->mixer = stac9227_mixer; break; @@ -1728,6 +1801,7 @@ static int patch_stac927x(struct hda_cod spec->adc_nids = stac927x_adc_nids; spec->mux_nids = stac927x_mux_nids; spec->num_muxes = 3; + spec->num_dmics = 0; spec->init = stac927x_core_init; spec->mixer = stac927x_mixer; } @@ -1757,7 +1831,9 @@ static int patch_stac9205(struct hda_cod codec->spec = spec; spec->num_pins = 14; spec->pin_nids = stac9205_pin_nids; - spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl); + spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, + stac9205_models, + stac9205_cfg_tbl); if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); err = stac92xx_save_bios_config_regs(codec); @@ -1773,13 +1849,28 @@ static int patch_stac9205(struct hda_cod spec->adc_nids = stac9205_adc_nids; spec->mux_nids = stac9205_mux_nids; - spec->num_muxes = 3; + spec->num_muxes = 2; + spec->dmic_nids = stac9205_dmic_nids; + spec->num_dmics = 2; + spec->dmux_nid = 0x1d; spec->init = stac9205_core_init; spec->mixer = stac9205_mixer; spec->multiout.dac_nids = spec->dac_nids; + /* Configure GPIO0 as EAPD output */ + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_DIRECTION, 0x00000001); + /* Configure GPIO0 as CMOS */ + snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000); + /* Assert GPIO0 high */ + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_DATA, 0x00000001); + /* Enable GPIO0 */ + snd_hda_codec_write(codec, codec->afg, 0, + AC_VERB_SET_GPIO_MASK, 0x00000001); + err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); if (err < 0) { stac92xx_free(codec); @@ -1963,18 +2054,19 @@ enum { /* FE and SZ series. id=0x8384766 /* Unknown. id=0x83847661 and subsys=0x104D1200. */ STAC9872K_VAIO, /* AR Series. id=0x83847664 and subsys=104D1300 */ - CXD9872AKD_VAIO - }; - -static struct hda_board_config stac9872_cfg_tbl[] = { - { .modelname = "vaio", .config = CXD9872RD_VAIO }, - { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6, - .config = CXD9872RD_VAIO }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef, - .config = CXD9872RD_VAIO }, - { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd, - .config = CXD9872AKD_VAIO }, + CXD9872AKD_VAIO, + STAC_9872_MODELS, +}; + +static const char *stac9872_models[STAC_9872_MODELS] = { + [CXD9872RD_VAIO] = "vaio", + [CXD9872AKD_VAIO] = "vaio-ar", +}; + +static struct snd_pci_quirk stac9872_cfg_tbl[] = { + SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), + SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), + SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), {} }; @@ -1983,7 +2075,9 @@ static int patch_stac9872(struct hda_cod struct sigmatel_spec *spec; int board_config; - board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl); + board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, + stac9872_models, + stac9872_cfg_tbl); if (board_config < 0) /* unknown config, let generic-parser do its job... */ return snd_hda_parse_generic_codec(codec); diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c new file mode 100644 index 0000000..4c839b0 --- /dev/null +++ b/sound/pci/hda/patch_via.c @@ -0,0 +1,1396 @@ +/* + * Universal Interface for Intel High Definition Audio Codec + * + * HD audio interface patch for VIA VT1708 codec + * + * Copyright (c) 2006 Lydia Wang + * Takashi Iwai + * + * This driver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This driver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */ +/* */ +/* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */ +/* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */ +/* 2006-08-02 Lydia Wang Add support to VT1709 codec */ +/* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +#include +#include +#include +#include +#include +#include +#include "hda_codec.h" +#include "hda_local.h" + + +/* amp values */ +#define AMP_VAL_IDX_SHIFT 19 +#define AMP_VAL_IDX_MASK (0x0f<<19) + +#define NUM_CONTROL_ALLOC 32 +#define NUM_VERB_ALLOC 32 + +/* Pin Widget NID */ +#define VT1708_HP_NID 0x13 +#define VT1708_DIGOUT_NID 0x14 +#define VT1708_DIGIN_NID 0x16 + +#define VT1709_HP_DAC_NID 0x28 +#define VT1709_DIGOUT_NID 0x13 +#define VT1709_DIGIN_NID 0x17 + +#define IS_VT1708_VENDORID(x) ((x) >= 0x11061708 && (x) <= 0x1106170b) +#define IS_VT1709_10CH_VENDORID(x) ((x) >= 0x1106e710 && (x) <= 0x1106e713) +#define IS_VT1709_6CH_VENDORID(x) ((x) >= 0x1106e714 && (x) <= 0x1106e717) + + +enum { + VIA_CTL_WIDGET_VOL, + VIA_CTL_WIDGET_MUTE, +}; + +enum { + AUTO_SEQ_FRONT, + AUTO_SEQ_SURROUND, + AUTO_SEQ_CENLFE, + AUTO_SEQ_SIDE +}; + +static struct snd_kcontrol_new vt1708_control_templates[] = { + HDA_CODEC_VOLUME(NULL, 0, 0, 0), + HDA_CODEC_MUTE(NULL, 0, 0, 0), +}; + + +struct via_spec { + /* codec parameterization */ + struct snd_kcontrol_new *mixers[3]; + unsigned int num_mixers; + + struct hda_verb *init_verbs; + + char *stream_name_analog; + struct hda_pcm_stream *stream_analog_playback; + struct hda_pcm_stream *stream_analog_capture; + + char *stream_name_digital; + struct hda_pcm_stream *stream_digital_playback; + struct hda_pcm_stream *stream_digital_capture; + + /* playback */ + struct hda_multi_out multiout; + + /* capture */ + unsigned int num_adc_nids; + hda_nid_t *adc_nids; + hda_nid_t dig_in_nid; + + /* capture source */ + const struct hda_input_mux *input_mux; + unsigned int cur_mux[3]; + + /* PCM information */ + struct hda_pcm pcm_rec[2]; + + /* dynamic controls, init_verbs and input_mux */ + struct auto_pin_cfg autocfg; + unsigned int num_kctl_alloc, num_kctl_used; + struct snd_kcontrol_new *kctl_alloc; + struct hda_input_mux private_imux; + hda_nid_t private_dac_nids[4]; +}; + +static hda_nid_t vt1708_adc_nids[2] = { + /* ADC1-2 */ + 0x15, 0x27 +}; + +static hda_nid_t vt1709_adc_nids[3] = { + /* ADC1-2 */ + 0x14, 0x15, 0x16 +}; + +/* add dynamic controls */ +static int via_add_control(struct via_spec *spec, int type, const char *name, + unsigned long val) +{ + struct snd_kcontrol_new *knew; + + if (spec->num_kctl_used >= spec->num_kctl_alloc) { + int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; + + /* array + terminator */ + knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); + if (!knew) + return -ENOMEM; + if (spec->kctl_alloc) { + memcpy(knew, spec->kctl_alloc, + sizeof(*knew) * spec->num_kctl_alloc); + kfree(spec->kctl_alloc); + } + spec->kctl_alloc = knew; + spec->num_kctl_alloc = num; + } + + knew = &spec->kctl_alloc[spec->num_kctl_used]; + *knew = vt1708_control_templates[type]; + knew->name = kstrdup(name, GFP_KERNEL); + + if (!knew->name) + return -ENOMEM; + knew->private_value = val; + spec->num_kctl_used++; + return 0; +} + +/* create input playback/capture controls for the given pin */ +static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin, + const char *ctlname, int idx, int mix_nid) +{ + char name[32]; + int err; + + sprintf(name, "%s Playback Volume", ctlname); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", ctlname); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); + if (err < 0) + return err; + return 0; +} + +static void via_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type, + int dac_idx) +{ + /* set as output */ + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + pin_type); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE); +} + + +static void via_auto_init_multi_out(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int i; + + for (i = 0; i <= AUTO_SEQ_SIDE; i++) { + hda_nid_t nid = spec->autocfg.line_out_pins[i]; + if (nid) + via_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); + } +} + +static void via_auto_init_hp_out(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + hda_nid_t pin; + + pin = spec->autocfg.hp_pins[0]; + if (pin) /* connect to front */ + via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); +} + +static void via_auto_init_analog_input(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int i; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + hda_nid_t nid = spec->autocfg.input_pins[i]; + + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + (i <= AUTO_PIN_FRONT_MIC ? + PIN_VREF50 : PIN_IN)); + + } +} +/* + * input MUX handling + */ +static int via_mux_enum_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct via_spec *spec = codec->spec; + return snd_hda_input_mux_info(spec->input_mux, uinfo); +} + +static int via_mux_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct via_spec *spec = codec->spec; + unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + + ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; + return 0; +} + +static int via_mux_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct via_spec *spec = codec->spec; + unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + unsigned int vendor_id = codec->vendor_id; + + /* AIW0 lydia 060801 add for correct sw0 input select */ + if (IS_VT1708_VENDORID(vendor_id) && (adc_idx == 0)) + return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, + 0x18, &spec->cur_mux[adc_idx]); + else if ((IS_VT1709_10CH_VENDORID(vendor_id) || + IS_VT1709_6CH_VENDORID(vendor_id)) && (adc_idx == 0) ) + return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, + 0x19, &spec->cur_mux[adc_idx]); + else + return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, + spec->adc_nids[adc_idx], + &spec->cur_mux[adc_idx]); +} + +/* capture mixer elements */ +static struct snd_kcontrol_new vt1708_capture_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x27, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x27, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, + .info = via_mux_enum_info, + .get = via_mux_enum_get, + .put = via_mux_enum_put, + }, + { } /* end */ +}; +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb vt1708_volume_init_verbs[] = { + /* + * Unmute ADC0-1 and set the default input to mic-in + */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + */ + /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output mixers (0x19 - 0x1b) + */ + /* set vol=0 to output mixers */ + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* Setup default input to PW4 */ + {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* Set mic as default input of sw0 */ + {0x18, AC_VERB_SET_CONNECT_SEL, 0x2}, + /* PW9 Output enable */ + {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, +}; + +static int via_playback_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); +} + +static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, + stream_tag, format, substream); +} + +static int via_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); +} + +/* + * Digital out + */ +static int via_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + return snd_hda_multi_out_dig_open(codec, &spec->multiout); +} + +static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + return snd_hda_multi_out_dig_close(codec, &spec->multiout); +} + +/* + * Analog capture + */ +static int via_capture_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + + snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], + stream_tag, 0, format); + return 0; +} + +static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct via_spec *spec = codec->spec; + snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], + 0, 0, 0); + return 0; +} + +static struct hda_pcm_stream vt1708_pcm_analog_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 8, + .nid = 0x10, /* NID to query formats and rates */ + .ops = { + .open = via_playback_pcm_open, + .prepare = via_playback_pcm_prepare, + .cleanup = via_playback_pcm_cleanup + }, +}; + +static struct hda_pcm_stream vt1708_pcm_analog_capture = { + .substreams = 2, + .channels_min = 2, + .channels_max = 2, + .nid = 0x15, /* NID to query formats and rates */ + .ops = { + .prepare = via_capture_pcm_prepare, + .cleanup = via_capture_pcm_cleanup + }, +}; + +static struct hda_pcm_stream vt1708_pcm_digital_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + /* NID is set in via_build_pcms */ + .ops = { + .open = via_dig_playback_pcm_open, + .close = via_dig_playback_pcm_close + }, +}; + +static struct hda_pcm_stream vt1708_pcm_digital_capture = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, +}; + +static int via_build_controls(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int err; + int i; + + for (i = 0; i < spec->num_mixers; i++) { + err = snd_hda_add_new_ctls(codec, spec->mixers[i]); + if (err < 0) + return err; + } + + if (spec->multiout.dig_out_nid) { + err = snd_hda_create_spdif_out_ctls(codec, + spec->multiout.dig_out_nid); + if (err < 0) + return err; + } + if (spec->dig_in_nid) { + err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); + if (err < 0) + return err; + } + return 0; +} + +static int via_build_pcms(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + struct hda_pcm *info = spec->pcm_rec; + + codec->num_pcms = 1; + codec->pcm_info = info; + + info->name = spec->stream_name_analog; + info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; + info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); + info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; + + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = + spec->multiout.max_channels; + + if (spec->multiout.dig_out_nid || spec->dig_in_nid) { + codec->num_pcms++; + info++; + info->name = spec->stream_name_digital; + if (spec->multiout.dig_out_nid) { + info->stream[SNDRV_PCM_STREAM_PLAYBACK] = + *(spec->stream_digital_playback); + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = + spec->multiout.dig_out_nid; + } + if (spec->dig_in_nid) { + info->stream[SNDRV_PCM_STREAM_CAPTURE] = + *(spec->stream_digital_capture); + info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = + spec->dig_in_nid; + } + } + + return 0; +} + +static void via_free(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + unsigned int i; + + if (!spec) + return; + + if (spec->kctl_alloc) { + for (i = 0; i < spec->num_kctl_used; i++) + kfree(spec->kctl_alloc[i].name); + kfree(spec->kctl_alloc); + } + + kfree(codec->spec); +} + +static int via_init(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + snd_hda_sequence_write(codec, spec->init_verbs); + return 0; +} + +#ifdef CONFIG_PM +/* + * resume + */ +static int via_resume(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int i; + + via_init(codec); + for (i = 0; i < spec->num_mixers; i++) + snd_hda_resume_ctls(codec, spec->mixers[i]); + if (spec->multiout.dig_out_nid) + snd_hda_resume_spdif_out(codec); + if (spec->dig_in_nid) + snd_hda_resume_spdif_in(codec); + + return 0; +} +#endif + +/* + */ +static struct hda_codec_ops via_patch_ops = { + .build_controls = via_build_controls, + .build_pcms = via_build_pcms, + .init = via_init, + .free = via_free, +#ifdef CONFIG_PM + .resume = via_resume, +#endif +}; + +/* fill in the dac_nids table from the parsed pin configuration */ +static int vt1708_auto_fill_dac_nids(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + int i; + hda_nid_t nid; + + spec->multiout.num_dacs = cfg->line_outs; + + spec->multiout.dac_nids = spec->private_dac_nids; + + for(i = 0; i < 4; i++) { + nid = cfg->line_out_pins[i]; + if (nid) { + /* config dac list */ + switch (i) { + case AUTO_SEQ_FRONT: + spec->multiout.dac_nids[i] = 0x10; + break; + case AUTO_SEQ_CENLFE: + spec->multiout.dac_nids[i] = 0x12; + break; + case AUTO_SEQ_SURROUND: + spec->multiout.dac_nids[i] = 0x13; + break; + case AUTO_SEQ_SIDE: + spec->multiout.dac_nids[i] = 0x11; + break; + } + } + } + + return 0; +} + +/* add playback controls from the parsed DAC table */ +static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + char name[32]; + static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; + hda_nid_t nid, nid_vol = 0; + int i, err; + + for (i = 0; i <= AUTO_SEQ_SIDE; i++) { + nid = cfg->line_out_pins[i]; + + if (!nid) + continue; + + if (i != AUTO_SEQ_FRONT) + nid_vol = 0x1b - i + 1; + + if (i == AUTO_SEQ_CENLFE) { + /* Center/LFE */ + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Center Playback Volume", + HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "LFE Playback Volume", + HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Center Playback Switch", + HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "LFE Playback Switch", + HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } else if (i == AUTO_SEQ_FRONT){ + /* add control to mixer index 0 */ + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Master Front Playback Volume", + HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Master Front Playback Switch", + HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT)); + if (err < 0) + return err; + + /* add control to PW3 */ + sprintf(name, "%s Playback Volume", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } else { + sprintf(name, "%s Playback Volume", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } + } + + return 0; +} + +static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) +{ + int err; + + if (!pin) + return 0; + + spec->multiout.hp_nid = VT1708_HP_NID; /* AOW3 */ + + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Headphone Playback Volume", + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Headphone Playback Switch", + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + + return 0; +} + +/* create playback/capture controls for input pins */ +static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + static char *labels[] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL + }; + struct hda_input_mux *imux = &spec->private_imux; + int i, err, idx = 0; + + /* for internal loopback recording select */ + imux->items[imux->num_items].label = "Stereo Mixer"; + imux->items[imux->num_items].index = idx; + imux->num_items++; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + if (!cfg->input_pins[i]) + continue; + + switch (cfg->input_pins[i]) { + case 0x1d: /* Mic */ + idx = 2; + break; + + case 0x1e: /* Line In */ + idx = 3; + break; + + case 0x21: /* Front Mic */ + idx = 4; + break; + + case 0x24: /* CD */ + idx = 1; + break; + } + err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], + idx, 0x17); + if (err < 0) + return err; + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = idx; + imux->num_items++; + } + return 0; +} + +static int vt1708_parse_auto_config(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int err; + + err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); + if (err < 0) + return err; + err = vt1708_auto_fill_dac_nids(spec, &spec->autocfg); + if (err < 0) + return err; + if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) + return 0; /* can't find valid BIOS pin config */ + + err = vt1708_auto_create_multi_out_ctls(spec, &spec->autocfg); + if (err < 0) + return err; + err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); + if (err < 0) + return err; + err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); + if (err < 0) + return err; + + spec->multiout.max_channels = spec->multiout.num_dacs * 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; + if (spec->autocfg.dig_in_pin) + spec->dig_in_nid = VT1708_DIGIN_NID; + + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->init_verbs = vt1708_volume_init_verbs; + + spec->input_mux = &spec->private_imux; + + return 1; +} + +/* init callback for auto-configuration model -- overriding the default init */ +static int via_auto_init(struct hda_codec *codec) +{ + via_init(codec); + via_auto_init_multi_out(codec); + via_auto_init_hp_out(codec); + via_auto_init_analog_input(codec); + return 0; +} + +static int patch_vt1708(struct hda_codec *codec) +{ + struct via_spec *spec; + int err; + + /* create a codec specific record */ + spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + /* automatic parse from the BIOS config */ + err = vt1708_parse_auto_config(codec); + if (err < 0) { + via_free(codec); + return err; + } else if (!err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration " + "from BIOS. Using genenic mode...\n"); + } + + + spec->stream_name_analog = "VT1708 Analog"; + spec->stream_analog_playback = &vt1708_pcm_analog_playback; + spec->stream_analog_capture = &vt1708_pcm_analog_capture; + + spec->stream_name_digital = "VT1708 Digital"; + spec->stream_digital_playback = &vt1708_pcm_digital_playback; + spec->stream_digital_capture = &vt1708_pcm_digital_capture; + + + if (!spec->adc_nids && spec->input_mux) { + spec->adc_nids = vt1708_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); + spec->mixers[spec->num_mixers] = vt1708_capture_mixer; + spec->num_mixers++; + } + + codec->patch_ops = via_patch_ops; + + codec->patch_ops.init = via_auto_init; + + return 0; +} + +/* capture mixer elements */ +static struct snd_kcontrol_new vt1709_capture_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x14, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x16, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x16, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, + .info = via_mux_enum_info, + .get = via_mux_enum_get, + .put = via_mux_enum_put, + }, + { } /* end */ +}; + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb vt1709_10ch_volume_init_verbs[] = { + /* + * Unmute ADC0-2 and set the default input to mic-in + */ + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + */ + /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output selector (0x1a, 0x1b, 0x29) + */ + /* set vol=0 to output mixers */ + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* + * Unmute PW3 and PW4 + */ + {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* Set input of PW4 as AOW4 */ + {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* Set mic as default input of sw0 */ + {0x19, AC_VERB_SET_CONNECT_SEL, 0x2}, + /* PW9 Output enable */ + {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + { } +}; + +static struct hda_pcm_stream vt1709_10ch_pcm_analog_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 10, + .nid = 0x10, /* NID to query formats and rates */ + .ops = { + .open = via_playback_pcm_open, + .prepare = via_playback_pcm_prepare, + .cleanup = via_playback_pcm_cleanup + }, +}; + +static struct hda_pcm_stream vt1709_6ch_pcm_analog_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 6, + .nid = 0x10, /* NID to query formats and rates */ + .ops = { + .open = via_playback_pcm_open, + .prepare = via_playback_pcm_prepare, + .cleanup = via_playback_pcm_cleanup + }, +}; + +static struct hda_pcm_stream vt1709_pcm_analog_capture = { + .substreams = 2, + .channels_min = 2, + .channels_max = 2, + .nid = 0x14, /* NID to query formats and rates */ + .ops = { + .prepare = via_capture_pcm_prepare, + .cleanup = via_capture_pcm_cleanup + }, +}; + +static struct hda_pcm_stream vt1709_pcm_digital_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + /* NID is set in via_build_pcms */ + .ops = { + .open = via_dig_playback_pcm_open, + .close = via_dig_playback_pcm_close + }, +}; + +static struct hda_pcm_stream vt1709_pcm_digital_capture = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, +}; + +static int vt1709_auto_fill_dac_nids(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + int i; + hda_nid_t nid; + + if (cfg->line_outs == 4) /* 10 channels */ + spec->multiout.num_dacs = cfg->line_outs+1; /* AOW0~AOW4 */ + else if (cfg->line_outs == 3) /* 6 channels */ + spec->multiout.num_dacs = cfg->line_outs; /* AOW0~AOW2 */ + + spec->multiout.dac_nids = spec->private_dac_nids; + + if (cfg->line_outs == 4) { /* 10 channels */ + for (i = 0; i < cfg->line_outs; i++) { + nid = cfg->line_out_pins[i]; + if (nid) { + /* config dac list */ + switch (i) { + case AUTO_SEQ_FRONT: + /* AOW0 */ + spec->multiout.dac_nids[i] = 0x10; + break; + case AUTO_SEQ_CENLFE: + /* AOW2 */ + spec->multiout.dac_nids[i] = 0x12; + break; + case AUTO_SEQ_SURROUND: + /* AOW3 */ + spec->multiout.dac_nids[i] = 0x27; + break; + case AUTO_SEQ_SIDE: + /* AOW1 */ + spec->multiout.dac_nids[i] = 0x11; + break; + default: + break; + } + } + } + spec->multiout.dac_nids[cfg->line_outs] = 0x28; /* AOW4 */ + + } else if (cfg->line_outs == 3) { /* 6 channels */ + for(i = 0; i < cfg->line_outs; i++) { + nid = cfg->line_out_pins[i]; + if (nid) { + /* config dac list */ + switch(i) { + case AUTO_SEQ_FRONT: + /* AOW0 */ + spec->multiout.dac_nids[i] = 0x10; + break; + case AUTO_SEQ_CENLFE: + /* AOW2 */ + spec->multiout.dac_nids[i] = 0x12; + break; + case AUTO_SEQ_SURROUND: + /* AOW1 */ + spec->multiout.dac_nids[i] = 0x11; + break; + default: + break; + } + } + } + } + + return 0; +} + +/* add playback controls from the parsed DAC table */ +static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + char name[32]; + static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; + hda_nid_t nid = 0; + int i, err; + + for (i = 0; i <= AUTO_SEQ_SIDE; i++) { + nid = cfg->line_out_pins[i]; + + if (!nid) + continue; + + if (i == AUTO_SEQ_CENLFE) { + /* Center/LFE */ + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Center Playback Volume", + HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "LFE Playback Volume", + HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Center Playback Switch", + HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "LFE Playback Switch", + HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } else if (i == AUTO_SEQ_FRONT){ + /* add control to mixer index 0 */ + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Master Front Playback Volume", + HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Master Front Playback Switch", + HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT)); + if (err < 0) + return err; + + /* add control to PW3 */ + sprintf(name, "%s Playback Volume", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } else if (i == AUTO_SEQ_SURROUND) { + sprintf(name, "%s Playback Volume", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(0x29, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } else if (i == AUTO_SEQ_SIDE) { + sprintf(name, "%s Playback Volume", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + } + } + + return 0; +} + +static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) +{ + int err; + + if (!pin) + return 0; + + if (spec->multiout.num_dacs == 5) /* 10 channels */ + spec->multiout.hp_nid = VT1709_HP_DAC_NID; + else if (spec->multiout.num_dacs == 3) /* 6 channels */ + spec->multiout.hp_nid = 0; + + err = via_add_control(spec, VIA_CTL_WIDGET_VOL, + "Headphone Playback Volume", + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, + "Headphone Playback Switch", + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + + return 0; +} + +/* create playback/capture controls for input pins */ +static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + static char *labels[] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL + }; + struct hda_input_mux *imux = &spec->private_imux; + int i, err, idx = 0; + + /* for internal loopback recording select */ + imux->items[imux->num_items].label = "Stereo Mixer"; + imux->items[imux->num_items].index = idx; + imux->num_items++; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + if (!cfg->input_pins[i]) + continue; + + switch (cfg->input_pins[i]) { + case 0x1d: /* Mic */ + idx = 2; + break; + + case 0x1e: /* Line In */ + idx = 3; + break; + + case 0x21: /* Front Mic */ + idx = 4; + break; + + case 0x23: /* CD */ + idx = 1; + break; + } + err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], + idx, 0x18); + if (err < 0) + return err; + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = idx; + imux->num_items++; + } + return 0; +} + +static int vt1709_parse_auto_config(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int err; + + err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); + if (err < 0) + return err; + err = vt1709_auto_fill_dac_nids(spec, &spec->autocfg); + if (err < 0) + return err; + if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) + return 0; /* can't find valid BIOS pin config */ + + err = vt1709_auto_create_multi_out_ctls(spec, &spec->autocfg); + if (err < 0) + return err; + err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); + if (err < 0) + return err; + err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg); + if (err < 0) + return err; + + spec->multiout.max_channels = spec->multiout.num_dacs * 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; + if (spec->autocfg.dig_in_pin) + spec->dig_in_nid = VT1709_DIGIN_NID; + + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->input_mux = &spec->private_imux; + + return 1; +} + +static int patch_vt1709_10ch(struct hda_codec *codec) +{ + struct via_spec *spec; + int err; + + /* create a codec specific record */ + spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + err = vt1709_parse_auto_config(codec); + if (err < 0) { + via_free(codec); + return err; + } else if (!err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration. " + "Using genenic mode...\n"); + } + + spec->init_verbs = vt1709_10ch_volume_init_verbs; + + spec->stream_name_analog = "VT1709 Analog"; + spec->stream_analog_playback = &vt1709_10ch_pcm_analog_playback; + spec->stream_analog_capture = &vt1709_pcm_analog_capture; + + spec->stream_name_digital = "VT1709 Digital"; + spec->stream_digital_playback = &vt1709_pcm_digital_playback; + spec->stream_digital_capture = &vt1709_pcm_digital_capture; + + + if (!spec->adc_nids && spec->input_mux) { + spec->adc_nids = vt1709_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); + spec->mixers[spec->num_mixers] = vt1709_capture_mixer; + spec->num_mixers++; + } + + codec->patch_ops = via_patch_ops; + + codec->patch_ops.init = via_auto_init; + + return 0; +} +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb vt1709_6ch_volume_init_verbs[] = { + /* + * Unmute ADC0-2 and set the default input to mic-in + */ + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + */ + /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output selector (0x1a, 0x1b, 0x29) + */ + /* set vol=0 to output mixers */ + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* + * Unmute PW3 and PW4 + */ + {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* Set input of PW4 as MW0 */ + {0x20, AC_VERB_SET_CONNECT_SEL, 0}, + /* Set mic as default input of sw0 */ + {0x19, AC_VERB_SET_CONNECT_SEL, 0x2}, + /* PW9 Output enable */ + {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + { } +}; + +static int patch_vt1709_6ch(struct hda_codec *codec) +{ + struct via_spec *spec; + int err; + + /* create a codec specific record */ + spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + err = vt1709_parse_auto_config(codec); + if (err < 0) { + via_free(codec); + return err; + } else if (!err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration. " + "Using genenic mode...\n"); + } + + spec->init_verbs = vt1709_6ch_volume_init_verbs; + + spec->stream_name_analog = "VT1709 Analog"; + spec->stream_analog_playback = &vt1709_6ch_pcm_analog_playback; + spec->stream_analog_capture = &vt1709_pcm_analog_capture; + + spec->stream_name_digital = "VT1709 Digital"; + spec->stream_digital_playback = &vt1709_pcm_digital_playback; + spec->stream_digital_capture = &vt1709_pcm_digital_capture; + + + if (!spec->adc_nids && spec->input_mux) { + spec->adc_nids = vt1709_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); + spec->mixers[spec->num_mixers] = vt1709_capture_mixer; + spec->num_mixers++; + } + + codec->patch_ops = via_patch_ops; + + codec->patch_ops.init = via_auto_init; + + return 0; +} + +/* + * patch entries + */ +struct hda_codec_preset snd_hda_preset_via[] = { + { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708}, + { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708}, + { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708}, + { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708}, + { .id = 0x1106E710, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, + { .id = 0x1106E711, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, + { .id = 0x1106E712, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, + { .id = 0x1106E713, .name = "VIA VT1709 10-Ch", .patch = patch_vt1709_10ch}, + { .id = 0x1106E714, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, + { .id = 0x1106E715, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, + { .id = 0x1106E716, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, + { .id = 0x1106E717, .name = "VIA VT1709 6-Ch", .patch = patch_vt1709_6ch}, + {} /* terminator */ +}; diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 9e76ceb..a085618 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -474,7 +474,8 @@ static void aureon_spi_write(struct snd_ tmp = snd_ice1712_gpio_read(ice); - if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT) { + if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT || + ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) { snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_SPI_MOSI|PRODIGY_SPI_CLK|PRODIGY_WM_CS)); mosi = PRODIGY_SPI_MOSI; clk = PRODIGY_SPI_CLK; @@ -601,7 +602,9 @@ static unsigned short wm_get(struct snd_ static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val) { aureon_spi_write(ice, - (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ? PRODIGY_WM_CS : AUREON_WM_CS), + ((ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT || + ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) ? + PRODIGY_WM_CS : AUREON_WM_CS), (reg << 9) | (val & 0x1ff), 16); } @@ -1288,12 +1291,14 @@ static int aureon_set_headphone_amp(stru tmp2 = tmp = snd_ice1712_gpio_read(ice); if (enable) - if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) + if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && + ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) tmp |= AUREON_HP_SEL; else tmp |= PRODIGY_HP_SEL; else - if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) + if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && + ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) tmp &= ~ AUREON_HP_SEL; else tmp &= ~ PRODIGY_HP_SEL; @@ -1898,7 +1903,8 @@ static int __devinit aureon_add_controls return err; } } - else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) { + else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && + ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) { for (i = 0; i < ARRAY_SIZE(ac97_controls); i++) { err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice)); if (err < 0) @@ -1906,7 +1912,8 @@ static int __devinit aureon_add_controls } } - if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) { + if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && + ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) { unsigned char id; snd_ice1712_save_gpio_status(ice); id = aureon_cs8415_get(ice, CS8415_ID); @@ -2062,7 +2069,8 @@ static int __devinit aureon_init(struct /* initialize WM8770 codec */ if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71 || - ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT) + ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT || + ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) p = wm_inits_prodigy; else p = wm_inits_aureon; @@ -2070,7 +2078,8 @@ static int __devinit aureon_init(struct wm_put(ice, p[0], p[1]); /* initialize CS8415A codec */ - if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT) { + if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && + ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) { for (p = cs_inits; *p != (unsigned short)-1; p++) aureon_spi_write(ice, AUREON_CS8415_CS, *p | 0x200000, 24); ice->spec.aureon.cs8415_mux = 1; @@ -2163,7 +2172,22 @@ static unsigned char prodigy71lt_eeprom[ 0x00, /* GPIO_STATE1 */ 0x00, /* GPIO_STATE2 */ }; - + +static unsigned char prodigy71xt_eeprom[] __devinitdata = { + 0x4b, /* SYSCINF: clock 512, spdif-in/ADC, 4DACs */ + 0x80, /* ACLINK: I2S */ + 0xfc, /* I2S: vol, 96k, 24bit, 192k */ + 0xc3, /* SPDIF: out-en, out-int, spdif-in */ + 0xff, /* GPIO_DIR */ + 0xff, /* GPIO_DIR1 */ + 0x5f, /* GPIO_DIR2 */ + 0x00, /* GPIO_MASK */ + 0x00, /* GPIO_MASK1 */ + 0x00, /* GPIO_MASK2 */ + 0x00, /* GPIO_STATE */ + 0x00, /* GPIO_STATE1 */ + 0x00, /* GPIO_STATE2 */ +}; /* entry point */ struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = { @@ -2217,5 +2241,15 @@ struct snd_ice1712_card_info snd_vt1724_ .eeprom_data = prodigy71lt_eeprom, .driver = "Prodigy71LT", }, + { + .subvendor = VT1724_SUBDEVICE_PRODIGY71XT, + .name = "Audiotrak Prodigy 7.1 XT", + .model = "prodigy71xt", + .chip_init = aureon_init, + .build_controls = aureon_add_controls, + .eeprom_size = sizeof(prodigy71xt_eeprom), + .eeprom_data = prodigy71xt_eeprom, + .driver = "Prodigy71LT", + }, { } /* terminator */ }; diff --git a/sound/pci/ice1712/aureon.h b/sound/pci/ice1712/aureon.h index 3b7bea6..c253b8e 100644 --- a/sound/pci/ice1712/aureon.h +++ b/sound/pci/ice1712/aureon.h @@ -28,13 +28,15 @@ #define AUREON_DEVICE_DESC "{Te "{Terratec,Aureon 7.1 Space},"\ "{Terratec,Aureon 7.1 Universe}," \ "{AudioTrak,Prodigy 7.1}," \ - "{AudioTrak,Prodigy 7.1 LT}," + "{AudioTrak,Prodigy 7.1 LT},"\ + "{AudioTrak,Prodigy 7.1 XT}," #define VT1724_SUBDEVICE_AUREON51_SKY 0x3b154711 /* Aureon 5.1 Sky */ #define VT1724_SUBDEVICE_AUREON71_SPACE 0x3b154511 /* Aureon 7.1 Space */ #define VT1724_SUBDEVICE_AUREON71_UNIVERSE 0x3b155311 /* Aureon 7.1 Universe */ #define VT1724_SUBDEVICE_PRODIGY71 0x33495345 /* PRODIGY 7.1 */ #define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */ +#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/ extern struct snd_ice1712_card_info snd_vt1724_aureon_cards[]; diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index ce27eac..064542b 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h @@ -28,6 +28,7 @@ #include #include #include #include +#include #include #include @@ -381,6 +382,11 @@ struct snd_ice1712 { unsigned short master[2]; unsigned short vol[8]; } phase28; + /* a non-standard I2C device for revo51 */ + struct revo51_spec { + struct snd_i2c_device *dev; + struct snd_pt2258 *pt2258; + } revo51; /* Hoontech-specific setting */ struct hoontech_spec { unsigned char boxbits[4]; @@ -462,6 +468,14 @@ static inline void snd_ice1712_gpio_writ snd_ice1712_gpio_write(ice, mask & bits); } +static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice, + unsigned int mask) +{ + ice->gpio.direction &= ~mask; + snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); + return (snd_ice1712_gpio_read(ice) & mask); +} + int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice); int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *template, diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c index bf98ea3..0e578aa 100644 --- a/sound/pci/ice1712/revo.c +++ b/sound/pci/ice1712/revo.c @@ -84,6 +84,102 @@ static void revo_set_rate_val(struct snd } /* + * I2C access to the PT2258 volume controller on GPIO 6/7 (Revolution 5.1) + */ + +static void revo_i2c_start(struct snd_i2c_bus *bus) +{ + struct snd_ice1712 *ice = bus->private_data; + snd_ice1712_save_gpio_status(ice); +} + +static void revo_i2c_stop(struct snd_i2c_bus *bus) +{ + struct snd_ice1712 *ice = bus->private_data; + snd_ice1712_restore_gpio_status(ice); +} + +static void revo_i2c_direction(struct snd_i2c_bus *bus, int clock, int data) +{ + struct snd_ice1712 *ice = bus->private_data; + unsigned int mask, val; + + val = 0; + if (clock) + val |= VT1724_REVO_I2C_CLOCK; /* write SCL */ + if (data) + val |= VT1724_REVO_I2C_DATA; /* write SDA */ + mask = VT1724_REVO_I2C_CLOCK | VT1724_REVO_I2C_DATA; + ice->gpio.direction &= ~mask; + ice->gpio.direction |= val; + snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); + snd_ice1712_gpio_set_mask(ice, ~mask); +} + +static void revo_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data) +{ + struct snd_ice1712 *ice = bus->private_data; + unsigned int val = 0; + + if (clk) + val |= VT1724_REVO_I2C_CLOCK; + if (data) + val |= VT1724_REVO_I2C_DATA; + snd_ice1712_gpio_write_bits(ice, + VT1724_REVO_I2C_DATA | + VT1724_REVO_I2C_CLOCK, val); + udelay(5); +} + +static int revo_i2c_getdata(struct snd_i2c_bus *bus, int ack) +{ + struct snd_ice1712 *ice = bus->private_data; + int bit; + + if (ack) + udelay(5); + bit = snd_ice1712_gpio_read_bits(ice, VT1724_REVO_I2C_DATA) ? 1 : 0; + return bit; +} + +static struct snd_i2c_bit_ops revo51_bit_ops = { + .start = revo_i2c_start, + .stop = revo_i2c_stop, + .direction = revo_i2c_direction, + .setlines = revo_i2c_setlines, + .getdata = revo_i2c_getdata, +}; + +static int revo51_i2c_init(struct snd_ice1712 *ice, + struct snd_pt2258 *pt) +{ + int err; + + /* create the I2C bus */ + err = snd_i2c_bus_create(ice->card, "ICE1724 GPIO6", NULL, &ice->i2c); + if (err < 0) + return err; + + ice->i2c->private_data = ice; + ice->i2c->hw_ops.bit = &revo51_bit_ops; + + /* create the I2C device */ + err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40, + &ice->spec.revo51.dev); + if (err < 0) + return err; + + pt->card = ice->card; + pt->i2c_bus = ice->i2c; + pt->i2c_dev = ice->spec.revo51.dev; + ice->spec.revo51.pt2258 = pt; + + snd_pt2258_reset(pt); + + return 0; +} + +/* * initialize the chips on M-Audio Revolution cards */ @@ -107,11 +203,19 @@ static struct snd_akm4xxx_dac_channel re AK_DAC("PCM Rear Playback Volume", 2), }; +static const char *revo51_adc_input_names[] = { + "Mic", + "Line", + "CD", + NULL +}; + static struct snd_akm4xxx_adc_channel revo51_adc[] = { { .name = "PCM Capture Volume", .switch_name = "PCM Capture Switch", - .num_channels = 2 + .num_channels = 2, + .input_names = revo51_adc_input_names }, }; @@ -172,9 +276,9 @@ static struct snd_ak4xxx_private akm_rev .cif = 0, .data_mask = VT1724_REVO_CDOUT, .clk_mask = VT1724_REVO_CCLK, - .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, - .cs_addr = VT1724_REVO_CS1 | VT1724_REVO_CS2, - .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, + .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1, + .cs_addr = VT1724_REVO_CS1, + .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1, .add_flags = VT1724_REVO_CCLK, /* high at init */ .mask_flags = 0, }; @@ -190,13 +294,190 @@ static struct snd_ak4xxx_private akm_rev .cif = 0, .data_mask = VT1724_REVO_CDOUT, .clk_mask = VT1724_REVO_CCLK, - .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, - .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS2, - .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, + .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1, + .cs_addr = VT1724_REVO_CS0, + .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1, + .add_flags = VT1724_REVO_CCLK, /* high at init */ + .mask_flags = 0, +}; + +static struct snd_pt2258 ptc_revo51_volume; + +/* AK4358 for AP192 DAC, AK5385A for ADC */ +static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) +{ + struct snd_ice1712 *ice = ak->private_data[0]; + + revo_set_rate_val(ak, rate); + +#if 1 /* FIXME: do we need this procedure? */ + /* reset DFS pin of AK5385A for ADC, too */ + /* DFS0 (pin 18) -- GPIO10 pin 77 */ + snd_ice1712_save_gpio_status(ice); + snd_ice1712_gpio_write_bits(ice, 1 << 10, + rate > 48000 ? (1 << 10) : 0); + snd_ice1712_restore_gpio_status(ice); +#endif +} + +static struct snd_akm4xxx_dac_channel ap192_dac[] = { + AK_DAC("PCM Playback Volume", 2) +}; + +static struct snd_akm4xxx akm_ap192 __devinitdata = { + .type = SND_AK4358, + .num_dacs = 2, + .ops = { + .set_rate_val = ap192_set_rate_val + }, + .dac_info = ap192_dac, +}; + +static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = { + .caddr = 2, + .cif = 0, + .data_mask = VT1724_REVO_CDOUT, + .clk_mask = VT1724_REVO_CCLK, + .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3, + .cs_addr = VT1724_REVO_CS3, + .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3, .add_flags = VT1724_REVO_CCLK, /* high at init */ .mask_flags = 0, }; +#if 0 +/* FIXME: ak4114 makes the sound much lower due to some confliction, + * so let's disable it right now... + */ +#define BUILD_AK4114_AP192 +#endif + +#ifdef BUILD_AK4114_AP192 +/* AK4114 support on Audiophile 192 */ +/* CDTO (pin 32) -- GPIO2 pin 52 + * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358) + * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358) + * CSN (pin 35) -- GPIO7 pin 59 + */ +#define AK4114_ADDR 0x00 + +static void write_data(struct snd_ice1712 *ice, unsigned int gpio, + unsigned int data, int idx) +{ + for (; idx >= 0; idx--) { + /* drop clock */ + gpio &= ~VT1724_REVO_CCLK; + snd_ice1712_gpio_write(ice, gpio); + udelay(1); + /* set data */ + if (data & (1 << idx)) + gpio |= VT1724_REVO_CDOUT; + else + gpio &= ~VT1724_REVO_CDOUT; + snd_ice1712_gpio_write(ice, gpio); + udelay(1); + /* raise clock */ + gpio |= VT1724_REVO_CCLK; + snd_ice1712_gpio_write(ice, gpio); + udelay(1); + } +} + +static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio, + int idx) +{ + unsigned char data = 0; + + for (; idx >= 0; idx--) { + /* drop clock */ + gpio &= ~VT1724_REVO_CCLK; + snd_ice1712_gpio_write(ice, gpio); + udelay(1); + /* read data */ + if (snd_ice1712_gpio_read(ice) & VT1724_REVO_CDIN) + data |= (1 << idx); + udelay(1); + /* raise clock */ + gpio |= VT1724_REVO_CCLK; + snd_ice1712_gpio_write(ice, gpio); + udelay(1); + } + return data; +} + +static unsigned char ap192_4wire_start(struct snd_ice1712 *ice) +{ + unsigned int tmp; + + snd_ice1712_save_gpio_status(ice); + tmp = snd_ice1712_gpio_read(ice); + tmp |= VT1724_REVO_CCLK; /* high at init */ + tmp |= VT1724_REVO_CS0; + tmp &= ~VT1724_REVO_CS3; + snd_ice1712_gpio_write(ice, tmp); + udelay(1); + return tmp; +} + +static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp) +{ + tmp |= VT1724_REVO_CS3; + tmp |= VT1724_REVO_CS0; + snd_ice1712_gpio_write(ice, tmp); + udelay(1); + snd_ice1712_restore_gpio_status(ice); +} + +static void ap192_ak4114_write(void *private_data, unsigned char addr, + unsigned char data) +{ + struct snd_ice1712 *ice = private_data; + unsigned int tmp, addrdata; + + tmp = ap192_4wire_start(ice); + addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f); + addrdata = (addrdata << 8) | data; + write_data(ice, tmp, addrdata, 15); + ap192_4wire_finish(ice, tmp); +} + +static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr) +{ + struct snd_ice1712 *ice = private_data; + unsigned int tmp; + unsigned char data; + + tmp = ap192_4wire_start(ice); + write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7); + data = read_data(ice, tmp, 7); + ap192_4wire_finish(ice, tmp); + return data; +} + +static int ap192_ak4114_init(struct snd_ice1712 *ice) +{ + static unsigned char ak4114_init_vals[] = { + AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, + AK4114_DIF_I24I2S, + AK4114_TX1E, + AK4114_EFH_1024 | AK4114_DIT | AK4114_IPS(1), + 0, + 0 + }; + static unsigned char ak4114_init_txcsb[] = { + 0x41, 0x02, 0x2c, 0x00, 0x00 + }; + struct ak4114 *ak; + int err; + + return snd_ak4114_create(ice->card, + ap192_ak4114_read, + ap192_ak4114_write, + ak4114_init_vals, ak4114_init_txcsb, + ice, &ak); +} +#endif /* BUILD_AK4114_AP192 */ + static int __devinit revo_init(struct snd_ice1712 *ice) { struct snd_akm4xxx *ak; @@ -213,6 +494,10 @@ static int __devinit revo_init(struct sn ice->num_total_dacs = 6; ice->num_total_adcs = 2; break; + case VT1724_SUBDEVICE_AUDIOPHILE192: + ice->num_total_dacs = 2; + ice->num_total_adcs = 2; + break; default: snd_BUG(); return -EINVAL; @@ -235,14 +520,28 @@ static int __devinit revo_init(struct sn break; case VT1724_SUBDEVICE_REVOLUTION51: ice->akm_codecs = 2; - if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo51, &akm_revo51_priv, ice)) < 0) + err = snd_ice1712_akm4xxx_init(ak, &akm_revo51, + &akm_revo51_priv, ice); + if (err < 0) return err; - err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo51_adc, + err = snd_ice1712_akm4xxx_init(ak+1, &akm_revo51_adc, &akm_revo51_adc_priv, ice); if (err < 0) return err; - /* unmute all codecs - needed! */ - snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE); + err = revo51_i2c_init(ice, &ptc_revo51_volume); + if (err < 0) + return err; + /* unmute all codecs */ + snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, + VT1724_REVO_MUTE); + break; + case VT1724_SUBDEVICE_AUDIOPHILE192: + ice->akm_codecs = 1; + err = snd_ice1712_akm4xxx_init(ak, &akm_ap192, &akm_ap192_priv, + ice); + if (err < 0) + return err; + break; } @@ -256,10 +555,28 @@ static int __devinit revo_add_controls(s switch (ice->eeprom.subvendor) { case VT1724_SUBDEVICE_REVOLUTION71: + err = snd_ice1712_akm4xxx_build_controls(ice); + if (err < 0) + return err; + break; case VT1724_SUBDEVICE_REVOLUTION51: err = snd_ice1712_akm4xxx_build_controls(ice); if (err < 0) return err; + err = snd_pt2258_build_controls(ice->spec.revo51.pt2258); + if (err < 0) + return err; + break; + case VT1724_SUBDEVICE_AUDIOPHILE192: + err = snd_ice1712_akm4xxx_build_controls(ice); + if (err < 0) + return err; +#ifdef BUILD_AK4114_AP192 + err = ap192_ak4114_init(ice); + if (err < 0) + return err; +#endif + break; } return 0; } @@ -280,5 +597,12 @@ struct snd_ice1712_card_info snd_vt1724_ .chip_init = revo_init, .build_controls = revo_add_controls, }, + { + .subvendor = VT1724_SUBDEVICE_AUDIOPHILE192, + .name = "M Audio Audiophile192", + .model = "ap192", + .chip_init = revo_init, + .build_controls = revo_add_controls, + }, { } /* terminator */ }; diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h index efbb86e..a3ba425 100644 --- a/sound/pci/ice1712/revo.h +++ b/sound/pci/ice1712/revo.h @@ -26,10 +26,12 @@ #define __SOUND_REVO_H #define REVO_DEVICE_DESC \ "{MidiMan M Audio,Revolution 7.1},"\ - "{MidiMan M Audio,Revolution 5.1}," + "{MidiMan M Audio,Revolution 5.1},"\ + "{MidiMan M Audio,Audiophile 192}," #define VT1724_SUBDEVICE_REVOLUTION71 0x12143036 #define VT1724_SUBDEVICE_REVOLUTION51 0x12143136 +#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236 /* entry point */ extern struct snd_ice1712_card_info snd_vt1724_revo_cards[]; @@ -42,9 +44,12 @@ extern struct snd_ice1712_card_info snd_ #define VT1724_REVO_CCLK 0x02 #define VT1724_REVO_CDIN 0x04 /* not used */ #define VT1724_REVO_CDOUT 0x08 -#define VT1724_REVO_CS0 0x10 /* AK5365 chipselect for Rev. 5.1 */ +#define VT1724_REVO_CS0 0x10 /* AK5365 chipselect for (revo51) */ #define VT1724_REVO_CS1 0x20 /* front AKM4381 chipselect */ -#define VT1724_REVO_CS2 0x40 /* surround AKM4355 chipselect */ +#define VT1724_REVO_CS2 0x40 /* surround AKM4355 CS (revo71) */ +#define VT1724_REVO_I2C_DATA 0x40 /* I2C: PT 2258 SDA (on revo51) */ +#define VT1724_REVO_I2C_CLOCK 0x80 /* I2C: PT 2258 SCL (on revo51) */ +#define VT1724_REVO_CS3 0x80 /* AK4114 for AP192 */ #define VT1724_REVO_MUTE (1<<22) /* 0 = all mute, 1 = normal operation */ #endif /* __SOUND_REVO_H */ diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 30aaa60..a289abf 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -71,6 +71,7 @@ static char *ac97_quirk; static int buggy_semaphore; static int buggy_irq = -1; /* auto-check */ static int xbox; +static int spdif_aclink = -1; module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard."); @@ -86,6 +87,8 @@ module_param(buggy_irq, bool, 0444); MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards."); module_param(xbox, bool, 0444); MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection."); +module_param(spdif_aclink, int, 0444); +MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); /* just for backward compatibility */ static int enable; @@ -368,12 +371,8 @@ struct intel8x0 { int irq; - unsigned int mmio; - unsigned long addr; - void __iomem *remap_addr; - unsigned int bm_mmio; - unsigned long bmaddr; - void __iomem *remap_bmaddr; + void __iomem *addr; + void __iomem *bmaddr; struct pci_dev *pci; struct snd_card *card; @@ -446,72 +445,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0_id * Lowlevel I/O - busmaster */ -static u8 igetbyte(struct intel8x0 *chip, u32 offset) +static inline u8 igetbyte(struct intel8x0 *chip, u32 offset) { - if (chip->bm_mmio) - return readb(chip->remap_bmaddr + offset); - else - return inb(chip->bmaddr + offset); + return ioread8(chip->bmaddr + offset); } -static u16 igetword(struct intel8x0 *chip, u32 offset) +static inline u16 igetword(struct intel8x0 *chip, u32 offset) { - if (chip->bm_mmio) - return readw(chip->remap_bmaddr + offset); - else - return inw(chip->bmaddr + offset); + return ioread16(chip->bmaddr + offset); } -static u32 igetdword(struct intel8x0 *chip, u32 offset) +static inline u32 igetdword(struct intel8x0 *chip, u32 offset) { - if (chip->bm_mmio) - return readl(chip->remap_bmaddr + offset); - else - return inl(chip->bmaddr + offset); + return ioread32(chip->bmaddr + offset); } -static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) +static inline void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) { - if (chip->bm_mmio) - writeb(val, chip->remap_bmaddr + offset); - else - outb(val, chip->bmaddr + offset); + iowrite8(val, chip->bmaddr + offset); } -static void iputword(struct intel8x0 *chip, u32 offset, u16 val) +static inline void iputword(struct intel8x0 *chip, u32 offset, u16 val) { - if (chip->bm_mmio) - writew(val, chip->remap_bmaddr + offset); - else - outw(val, chip->bmaddr + offset); + iowrite16(val, chip->bmaddr + offset); } -static void iputdword(struct intel8x0 *chip, u32 offset, u32 val) +static inline void iputdword(struct intel8x0 *chip, u32 offset, u32 val) { - if (chip->bm_mmio) - writel(val, chip->remap_bmaddr + offset); - else - outl(val, chip->bmaddr + offset); + iowrite32(val, chip->bmaddr + offset); } /* * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(struct intel8x0 *chip, u32 offset) +static inline u16 iagetword(struct intel8x0 *chip, u32 offset) { - if (chip->mmio) - return readw(chip->remap_addr + offset); - else - return inw(chip->addr + offset); + return ioread16(chip->addr + offset); } -static void iaputword(struct intel8x0 *chip, u32 offset, u16 val) +static inline void iaputword(struct intel8x0 *chip, u32 offset, u16 val) { - if (chip->mmio) - writew(val, chip->remap_addr + offset); - else - outw(val, chip->addr + offset); + iowrite16(val, chip->addr + offset); } /* @@ -1606,10 +1581,14 @@ static int __devinit snd_intel8x0_pcm(st case DEVICE_INTEL_ICH4: tbl = intel_pcms; tblsize = ARRAY_SIZE(intel_pcms); + if (spdif_aclink) + tblsize--; break; case DEVICE_NFORCE: tbl = nforce_pcms; tblsize = ARRAY_SIZE(nforce_pcms); + if (spdif_aclink) + tblsize--; break; case DEVICE_ALI: tbl = ali_pcms; @@ -2068,24 +2047,26 @@ static int __devinit snd_intel8x0_mixer( }; chip->spdif_idx = -1; /* use PCMOUT (or disabled) */ - switch (chip->device_type) { - case DEVICE_NFORCE: - chip->spdif_idx = NVD_SPBAR; - break; - case DEVICE_ALI: - chip->spdif_idx = ALID_AC97SPDIFOUT; - break; - case DEVICE_INTEL_ICH4: - chip->spdif_idx = ICHD_SPBAR; - break; - }; + if (!spdif_aclink) { + switch (chip->device_type) { + case DEVICE_NFORCE: + chip->spdif_idx = NVD_SPBAR; + break; + case DEVICE_ALI: + chip->spdif_idx = ALID_AC97SPDIFOUT; + break; + case DEVICE_INTEL_ICH4: + chip->spdif_idx = ICHD_SPBAR; + break; + }; + } chip->in_ac97_init = 1; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_intel8x0_mixer_free_ac97; - ac97.scaps = AC97_SCAP_SKIP_MODEM; + ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; if (chip->xbox) ac97.scaps |= AC97_SCAP_DETECT_BY_VENDOR; if (chip->device_type != DEVICE_ALI) { @@ -2201,11 +2182,11 @@ static int __devinit snd_intel8x0_mixer( if ((igetdword(chip, ICHREG(GLOB_STA)) & ICH_SAMPLE_CAP) == ICH_SAMPLE_16_20) chip->smp20bit = 1; } - if (chip->device_type == DEVICE_NFORCE) { + if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { /* 48kHz only */ chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000; } - if (chip->device_type == DEVICE_INTEL_ICH4) { + if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { /* use slot 10/11 for SPDIF */ u32 val; val = igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK; @@ -2333,7 +2314,7 @@ #endif /* unmute the output on SIS7012 */ iputword(chip, 0x4c, igetword(chip, 0x4c) | 1); } - if (chip->device_type == DEVICE_NFORCE) { + if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { /* enable SPDIF interrupt */ unsigned int val; pci_read_config_dword(chip->pci, 0x4c, &val); @@ -2426,7 +2407,7 @@ static int snd_intel8x0_free(struct inte /* reset channels */ for (i = 0; i < chip->bdbars_count; i++) iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); - if (chip->device_type == DEVICE_NFORCE) { + if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { /* stop the spdif interrupt */ unsigned int val; pci_read_config_dword(chip->pci, 0x4c, &val); @@ -2443,10 +2424,10 @@ static int snd_intel8x0_free(struct inte fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0); snd_dma_free_pages(&chip->bdbars); } - if (chip->remap_addr) - iounmap(chip->remap_addr); - if (chip->remap_bmaddr) - iounmap(chip->remap_bmaddr); + if (chip->addr) + pci_iounmap(chip->pci, chip->addr); + if (chip->bmaddr) + pci_iounmap(chip->pci, chip->bmaddr); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); @@ -2520,7 +2501,7 @@ static int intel8x0_resume(struct pci_de snd_intel8x0_chip_init(chip, 0); /* re-initialize mixer stuff */ - if (chip->device_type == DEVICE_INTEL_ICH4) { + if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { /* enable separate SDINs for ICH4 */ iputbyte(chip, ICHREG(SDM), chip->sdm_saved); /* use slot 10/11 for SPDIF */ @@ -2793,35 +2774,27 @@ static int __devinit snd_intel8x0_create if (device_type == DEVICE_ALI) { /* ALI5455 has no ac97 region */ - chip->bmaddr = pci_resource_start(pci, 0); + chip->bmaddr = pci_iomap(pci, 0, 0); goto port_inited; } - if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ - chip->mmio = 1; - chip->addr = pci_resource_start(pci, 2); - chip->remap_addr = ioremap_nocache(chip->addr, - pci_resource_len(pci, 2)); - if (chip->remap_addr == NULL) { - snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->addr = pci_resource_start(pci, 0); - } - if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ - chip->bm_mmio = 1; - chip->bmaddr = pci_resource_start(pci, 3); - chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, - pci_resource_len(pci, 3)); - if (chip->remap_bmaddr == NULL) { - snd_printk(KERN_ERR "Controller space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->bmaddr = pci_resource_start(pci, 1); + if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ + chip->addr = pci_iomap(pci, 2, 0); + else + chip->addr = pci_iomap(pci, 0, 0); + if (!chip->addr) { + snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; + } + if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ + chip->bmaddr = pci_iomap(pci, 3, 0); + else + chip->bmaddr = pci_iomap(pci, 1, 0); + if (!chip->bmaddr) { + snd_printk(KERN_ERR "Controller space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; } port_inited: @@ -2964,6 +2937,29 @@ static struct shortname_table { { 0, NULL }, }; +static struct snd_pci_quirk spdif_aclink_defaults[] __devinitdata = { + SND_PCI_QUIRK(0x147b, 0x1c1a, "ASUS KN8", 1), + { } /* end */ +}; + +/* look up white/black list for SPDIF over ac-link */ +static int __devinit check_default_spdif_aclink(struct pci_dev *pci) +{ + const struct snd_pci_quirk *w; + + w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults); + if (w) { + if (w->value) + snd_printdd(KERN_INFO "intel8x0: Using SPDIF over " + "AC-Link for %s\n", w->name); + else + snd_printdd(KERN_INFO "intel8x0: Using integrated " + "SPDIF DMA for %s\n", w->name); + return w->value; + } + return 0; +} + static int __devinit snd_intel8x0_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -2976,16 +2972,18 @@ static int __devinit snd_intel8x0_probe( if (card == NULL) return -ENOMEM; - switch (pci_id->driver_data) { - case DEVICE_NFORCE: - strcpy(card->driver, "NFORCE"); - break; - case DEVICE_INTEL_ICH4: - strcpy(card->driver, "ICH4"); - break; - default: - strcpy(card->driver, "ICH"); - break; + if (spdif_aclink < 0) + spdif_aclink = check_default_spdif_aclink(pci); + + strcpy(card->driver, "ICH"); + if (!spdif_aclink) { + switch (pci_id->driver_data) { + case DEVICE_NFORCE: + strcpy(card->driver, "NFORCE"); + break; + case DEVICE_INTEL_ICH4: + strcpy(card->driver, "ICH4"); + } } strcpy(card->shortname, "Intel ICH"); @@ -3025,8 +3023,8 @@ static int __devinit snd_intel8x0_probe( snd_intel8x0_proc_init(chip); snprintf(card->longname, sizeof(card->longname), - "%s with %s at %#lx, irq %i", card->shortname, - snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq); + "%s with %s at irq %i", card->shortname, + snd_ac97_get_short_name(chip->ac97[0]), chip->irq); if (! ac97_clock) intel8x0_measure_ac97_clock(chip); diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 09dcf92..c155e1f 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -196,12 +196,8 @@ struct intel8x0m { int irq; - unsigned int mmio; - unsigned long addr; - void __iomem *remap_addr; - unsigned int bm_mmio; - unsigned long bmaddr; - void __iomem *remap_bmaddr; + void __iomem *addr; + void __iomem *bmaddr; struct pci_dev *pci; struct snd_card *card; @@ -253,72 +249,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_i * Lowlevel I/O - busmaster */ -static u8 igetbyte(struct intel8x0m *chip, u32 offset) +static inline u8 igetbyte(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readb(chip->remap_bmaddr + offset); - else - return inb(chip->bmaddr + offset); + return ioread8(chip->bmaddr + offset); } -static u16 igetword(struct intel8x0m *chip, u32 offset) +static inline u16 igetword(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readw(chip->remap_bmaddr + offset); - else - return inw(chip->bmaddr + offset); + return ioread16(chip->bmaddr + offset); } -static u32 igetdword(struct intel8x0m *chip, u32 offset) +static inline u32 igetdword(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readl(chip->remap_bmaddr + offset); - else - return inl(chip->bmaddr + offset); + return ioread32(chip->bmaddr + offset); } -static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) +static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) { - if (chip->bm_mmio) - writeb(val, chip->remap_bmaddr + offset); - else - outb(val, chip->bmaddr + offset); + iowrite8(val, chip->bmaddr + offset); } -static void iputword(struct intel8x0m *chip, u32 offset, u16 val) +static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val) { - if (chip->bm_mmio) - writew(val, chip->remap_bmaddr + offset); - else - outw(val, chip->bmaddr + offset); + iowrite16(val, chip->bmaddr + offset); } -static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) +static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val) { - if (chip->bm_mmio) - writel(val, chip->remap_bmaddr + offset); - else - outl(val, chip->bmaddr + offset); + iowrite32(val, chip->bmaddr + offset); } /* * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(struct intel8x0m *chip, u32 offset) +static inline u16 iagetword(struct intel8x0m *chip, u32 offset) { - if (chip->mmio) - return readw(chip->remap_addr + offset); - else - return inw(chip->addr + offset); + return ioread16(chip->addr + offset); } -static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) +static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val) { - if (chip->mmio) - writew(val, chip->remap_addr + offset); - else - outw(val, chip->addr + offset); + iowrite16(val, chip->addr + offset); } /* @@ -858,7 +830,7 @@ static int __devinit snd_intel8x0_mixer( memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_intel8x0_mixer_free_ac97; - ac97.scaps = AC97_SCAP_SKIP_AUDIO; + ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; glob_sta = igetdword(chip, ICHREG(GLOB_STA)); @@ -1019,10 +991,10 @@ static int snd_intel8x0_free(struct inte __hw_end: if (chip->bdbars.area) snd_dma_free_pages(&chip->bdbars); - if (chip->remap_addr) - iounmap(chip->remap_addr); - if (chip->remap_bmaddr) - iounmap(chip->remap_bmaddr); + if (chip->addr) + pci_iounmap(chip->pci, chip->addr); + if (chip->bmaddr) + pci_iounmap(chip->pci, chip->bmaddr); if (chip->irq >= 0) free_irq(chip->irq, chip); pci_release_regions(chip->pci); @@ -1173,35 +1145,27 @@ static int __devinit snd_intel8x0m_creat if (device_type == DEVICE_ALI) { /* ALI5455 has no ac97 region */ - chip->bmaddr = pci_resource_start(pci, 0); + chip->bmaddr = pci_iomap(pci, 0, 0); goto port_inited; } - if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ - chip->mmio = 1; - chip->addr = pci_resource_start(pci, 2); - chip->remap_addr = ioremap_nocache(chip->addr, - pci_resource_len(pci, 2)); - if (chip->remap_addr == NULL) { - snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->addr = pci_resource_start(pci, 0); + if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ + chip->addr = pci_iomap(pci, 2, 0); + else + chip->addr = pci_iomap(pci, 0, 0); + if (!chip->addr) { + snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; } - if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ - chip->bm_mmio = 1; - chip->bmaddr = pci_resource_start(pci, 3); - chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, - pci_resource_len(pci, 3)); - if (chip->remap_bmaddr == NULL) { - snd_printk(KERN_ERR "Controller space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->bmaddr = pci_resource_start(pci, 1); + if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ + chip->bmaddr = pci_iomap(pci, 3, 0); + else + chip->bmaddr = pci_iomap(pci, 1, 0); + if (!chip->bmaddr) { + snd_printk(KERN_ERR "Controller space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; } port_inited: @@ -1339,8 +1303,8 @@ static int __devinit snd_intel8x0m_probe snd_intel8x0m_proc_init(chip); - sprintf(card->longname, "%s at 0x%lx, irq %i", - card->shortname, chip->addr, chip->irq); + sprintf(card->longname, "%s at irq %i", + card->shortname, chip->irq); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 345eefe..21d0899 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -28,6 +28,7 @@ #include #include #include #include +#include #include #include @@ -263,7 +264,15 @@ #define STOPCARD_DELAY 300 / #define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement // from the card after sending a command. +#define FIRMWARE_IN_THE_KERNEL + +#ifdef FIRMWARE_IN_THE_KERNEL #include "korg1212-firmware.h" +static const struct firmware static_dsp_code = { + .data = (u8 *)dspCode, + .size = sizeof dspCode +}; +#endif enum ClockSourceIndex { K1212_CLKIDX_AdatAt44_1K = 0, // selects source as ADAT at 44.1 kHz @@ -345,8 +354,6 @@ struct snd_korg1212 { struct snd_dma_buffer dma_rec; struct snd_dma_buffer dma_shared; - u32 dspCodeSize; - u32 DataBufsSize; struct KorgAudioBuffer * playDataBufsPtr; @@ -1223,8 +1230,6 @@ static int snd_korg1212_downloadDSPCode( snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS); - memcpy(korg1212->dma_dsp.area, dspCode, korg1212->dspCodeSize); - rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, UpperWordSwap(korg1212->dma_dsp.addr), 0, 0, 0); @@ -2156,6 +2161,7 @@ static int __devinit snd_korg1212_create unsigned int i; unsigned ioport_size, iomem_size, iomem2_size; struct snd_korg1212 * korg1212; + const struct firmware *dsp_code; static struct snd_device_ops ops = { .dev_free = snd_korg1212_dev_free, @@ -2329,8 +2335,6 @@ #else // K1212_LARGEALLOC #endif // K1212_LARGEALLOC - korg1212->dspCodeSize = sizeof (dspCode); - korg1212->VolumeTablePhy = korg1212->sharedBufferPhy + offsetof(struct KorgSharedBuffer, volumeData); korg1212->RoutingTablePhy = korg1212->sharedBufferPhy + @@ -2338,17 +2342,40 @@ #endif // K1212_LARGEALLOC korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + offsetof(struct KorgSharedBuffer, AdatTimeCode); + err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); + if (err < 0) { + release_firmware(dsp_code); +#ifdef FIRMWARE_IN_THE_KERNEL + dsp_code = &static_dsp_code; +#else + snd_printk(KERN_ERR "firmware not available\n"); + snd_korg1212_free(korg1212); + return err; +#endif + } + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), - korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) { - snd_printk(KERN_ERR "korg1212: can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize); + dsp_code->size, &korg1212->dma_dsp) < 0) { + snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); snd_korg1212_free(korg1212); +#ifdef FIRMWARE_IN_THE_KERNEL + if (dsp_code != &static_dsp_code) +#endif + release_firmware(dsp_code); return -ENOMEM; } K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", - korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize, + korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size, stateName[korg1212->cardState]); + memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size); + +#ifdef FIRMWARE_IN_THE_KERNEL + if (dsp_code != &static_dsp_code) +#endif + release_firmware(dsp_code); + rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); if (rc) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 6efe6d5..4526904 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -41,6 +41,7 @@ #include #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include #include #include +#include MODULE_AUTHOR("Zach Brown , Takashi Iwai "); MODULE_DESCRIPTION("ESS Maestro3 PCI"); @@ -768,21 +770,6 @@ #define ARB_VOLUME ( 0x6800 ) /* */ -/* quirk lists */ -struct m3_quirk { - const char *name; /* device name */ - u16 vendor, device; /* subsystem ids */ - int amp_gpio; /* gpio pin # for external amp, -1 = default */ - int irda_workaround; /* non-zero if avoid to touch 0x10 on GPIO_DIRECTION - (e.g. for IrDA on Dell Inspirons) */ -}; - -struct m3_hv_quirk { - u16 vendor, device, subsystem_vendor, subsystem_device; - u32 config; /* ALLEGRO_CONFIG hardware volume bits */ - int is_omnibook; /* Do HP OmniBook GPIO magic? */ -}; - struct m3_list { int curlen; int mem_addr; @@ -830,8 +817,6 @@ struct snd_m3 { struct snd_pcm *pcm; struct pci_dev *pci; - const struct m3_quirk *quirk; - const struct m3_hv_quirk *hv_quirk; int dacs_active; int timer_users; @@ -845,7 +830,11 @@ struct snd_m3 { u8 reset_state; int external_amp; - int amp_gpio; + int amp_gpio; /* gpio pin # for external amp, -1 = default */ + unsigned int hv_config; /* hardware-volume config bits */ + unsigned irda_workaround :1; /* avoid to touch 0x10 on GPIO_DIRECTION + (e.g. for IrDA on Dell Inspirons) */ + unsigned is_omnibook :1; /* Do HP OmniBook GPIO magic? */ /* midi */ struct snd_rawmidi *rmidi; @@ -864,6 +853,9 @@ struct snd_m3 { #ifdef CONFIG_PM u16 *suspend_mem; #endif + + const struct firmware *assp_kernel_image; + const struct firmware *assp_minisrc_image; }; /* @@ -891,127 +883,104 @@ static struct pci_device_id snd_m3_ids[] MODULE_DEVICE_TABLE(pci, snd_m3_ids); -static const struct m3_quirk m3_quirk_list[] = { - /* panasonic CF-28 "toughbook" */ - { - .name = "Panasonic CF-28", - .vendor = 0x10f7, - .device = 0x833e, - .amp_gpio = 0x0d, - }, - /* panasonic CF-72 "toughbook" */ - { - .name = "Panasonic CF-72", - .vendor = 0x10f7, - .device = 0x833d, - .amp_gpio = 0x0d, - }, - /* Dell Inspiron 4000 */ - { - .name = "Dell Inspiron 4000", - .vendor = 0x1028, - .device = 0x00b0, - .amp_gpio = -1, - .irda_workaround = 1, - }, - /* Dell Inspiron 8000 */ - { - .name = "Dell Inspiron 8000", - .vendor = 0x1028, - .device = 0x00a4, - .amp_gpio = -1, - .irda_workaround = 1, - }, - /* Dell Inspiron 8100 */ - { - .name = "Dell Inspiron 8100", - .vendor = 0x1028, - .device = 0x00e6, - .amp_gpio = -1, - .irda_workaround = 1, - }, - /* NEC LM800J/7 */ - { - .name = "NEC LM800J/7", - .vendor = 0x1033, - .device = 0x80f1, - .amp_gpio = 0x03, - }, - /* LEGEND ZhaoYang 3100CF */ - { - .name = "LEGEND ZhaoYang 3100CF", - .vendor = 0x1509, - .device = 0x1740, - .amp_gpio = 0x03, - }, - /* END */ - { NULL } +static struct snd_pci_quirk m3_amp_quirk_list[] __devinitdata = { + SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d), + SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d), + SND_PCI_QUIRK(0x1033, 0x80f1, "NEC LM800J/7", 0x03), + SND_PCI_QUIRK(0x1509, 0x1740, "LEGEND ZhaoYang 3100CF", 0x03), + { } /* END */ }; -/* These values came from the Windows driver. */ -static const struct m3_hv_quirk m3_hv_quirk_list[] = { +static struct snd_pci_quirk m3_irda_quirk_list[] __devinitdata = { + SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1), + SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1), + SND_PCI_QUIRK(0x1028, 0x00e6, "Dell Inspiron 8100", 1), + { } /* END */ +}; + +/* hardware volume quirks */ +static struct snd_pci_quirk m3_hv_quirk_list[] __devinitdata = { /* Allegro chips */ - { 0x125D, 0x1988, 0x0E11, 0x002E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x0E11, 0x0094, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x0E11, 0xB112, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x0E11, 0xB114, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x103C, 0x0012, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x103C, 0x0018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x103C, 0x001C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x103C, 0x001D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x103C, 0x001E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x107B, 0x3350, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x10F7, 0x8338, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x10F7, 0x833C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x10F7, 0x833D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x10F7, 0x833E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x10F7, 0x833F, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x13BD, 0x1018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x13BD, 0x1019, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x13BD, 0x101A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x14FF, 0x0F03, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x14FF, 0x0F04, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x14FF, 0x0F05, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x156D, 0xB400, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x156D, 0xB795, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x156D, 0xB797, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x156D, 0xC700, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, - { 0x125D, 0x1988, 0x1033, 0x80F1, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x103C, 0x001A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, /* HP OmniBook 6100 */ - { 0x125D, 0x1988, 0x107B, 0x340A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x107B, 0x3450, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x109F, 0x3134, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x109F, 0x3161, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x144D, 0x3280, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x144D, 0x3281, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x144D, 0xC002, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x144D, 0xC003, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x1509, 0x1740, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x1610, 0x0010, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x1988, 0x1042, 0x1042, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1988, 0x107B, 0x9500, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1988, 0x14FF, 0x0F06, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1988, 0x1558, 0x8586, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1988, 0x161F, 0x2011, HV_CTRL_ENABLE, 0 }, + SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x0E11, 0x0094, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x0E11, 0xB112, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x0E11, 0xB114, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x103C, 0x0012, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x103C, 0x0018, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x103C, 0x001C, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x103C, 0x001D, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x103C, 0x001E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x107B, 0x3350, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x10F7, 0x8338, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x10F7, 0x833C, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x10F7, 0x833D, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x10F7, 0x833E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x10F7, 0x833F, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x13BD, 0x1018, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x13BD, 0x1019, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x13BD, 0x101A, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x14FF, 0x0F03, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x14FF, 0x0F04, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x14FF, 0x0F05, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x156D, 0xB400, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x156D, 0xB795, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x156D, 0xB797, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x156D, 0xC700, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), + SND_PCI_QUIRK(0x1033, 0x80F1, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x103C, 0x001A, NULL, /* HP OmniBook 6100 */ + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x107B, 0x340A, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x107B, 0x3450, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x109F, 0x3134, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x109F, 0x3161, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0x3280, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0x3281, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0xC002, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0xC003, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x1509, 0x1740, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x1610, 0x0010, NULL, + HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x1042, 0x1042, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x107B, 0x9500, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x14FF, 0x0F06, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x1558, 0x8586, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x161F, 0x2011, NULL, HV_CTRL_ENABLE), /* Maestro3 chips */ - { 0x125D, 0x1998, 0x103C, 0x000E, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x103C, 0x0010, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 6000 */ - { 0x125D, 0x1998, 0x103C, 0x0011, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 500 */ - { 0x125D, 0x1998, 0x103C, 0x001B, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x104D, 0x80A6, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x104D, 0x80AA, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x107B, 0x5300, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x110A, 0x1998, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x13BD, 0x1015, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x13BD, 0x101C, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x13BD, 0x1802, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x1599, 0x0715, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x1998, 0x5643, 0x5643, HV_CTRL_ENABLE, 0 }, - { 0x125D, 0x199A, 0x144D, 0x3260, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x199A, 0x144D, 0x3261, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x199A, 0x144D, 0xC000, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, - { 0x125D, 0x199A, 0x144D, 0xC001, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, - { 0 } + SND_PCI_QUIRK(0x103C, 0x000E, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x103C, 0x0010, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x103C, 0x0011, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x103C, 0x001B, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x104D, 0x80A6, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x104D, 0x80AA, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x107B, 0x5300, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x110A, 0x1998, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x13BD, 0x1015, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x13BD, 0x101C, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x13BD, 0x1802, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x1599, 0x0715, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x5643, 0x5643, NULL, HV_CTRL_ENABLE), + SND_PCI_QUIRK(0x144D, 0x3260, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0x3261, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0xC000, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE), + SND_PCI_QUIRK(0x144D, 0xC001, NULL, HV_CTRL_ENABLE | REDUCED_DEBOUNCE), + { } /* END */ +}; + +/* HP Omnibook quirks */ +static struct snd_pci_quirk m3_omnibook_quirk_list[] __devinitdata = { + SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */ + SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */ + { } /* END */ }; /* @@ -2050,7 +2019,7 @@ static void snd_m3_ac97_reset(struct snd for (i = 0; i < 5; i++) { dir = inw(io + GPIO_DIRECTION); - if (! chip->quirk || ! chip->quirk->irda_workaround) + if (!chip->irda_workaround) dir |= 0x10; /* assuming pci bus master? */ snd_m3_remote_codec_config(io, 0); @@ -2132,6 +2101,10 @@ static int __devinit snd_m3_mixer(struct } +#define FIRMWARE_IN_THE_KERNEL + +#ifdef FIRMWARE_IN_THE_KERNEL + /* * DSP Code images */ @@ -2260,6 +2233,30 @@ static const u16 assp_minisrc_image[] = 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; +static const struct firmware assp_kernel = { + .data = (u8 *)assp_kernel_image, + .size = sizeof assp_kernel_image +}; +static const struct firmware assp_minisrc = { + .data = (u8 *)assp_minisrc_image, + .size = sizeof assp_minisrc_image +}; + +#endif /* FIRMWARE_IN_THE_KERNEL */ + +#ifdef __LITTLE_ENDIAN +static inline void snd_m3_convert_from_le(const struct firmware *fw) { } +#else +static void snd_m3_convert_from_le(const struct firmware *fw) +{ + int i; + u16 *data = (u16 *)fw->data; + + for (i = 0; i < fw->size / 2; ++i) + le16_to_cpus(&data[i]); +} +#endif + /* * initialize ASSP @@ -2274,6 +2271,7 @@ static const u16 minisrc_lpf[MINISRC_LPF static void snd_m3_assp_init(struct snd_m3 *chip) { unsigned int i; + u16 *data; /* zero kernel data */ for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++) @@ -2291,10 +2289,10 @@ static void snd_m3_assp_init(struct snd_ KDATA_DMA_XFER0); /* write kernel into code memory.. */ - for (i = 0 ; i < ARRAY_SIZE(assp_kernel_image); i++) { + data = (u16 *)chip->assp_kernel_image->data; + for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, - REV_B_CODE_MEMORY_BEGIN + i, - assp_kernel_image[i]); + REV_B_CODE_MEMORY_BEGIN + i, data[i]); } /* @@ -2303,10 +2301,10 @@ static void snd_m3_assp_init(struct snd_ * drop it there. It seems that the minisrc doesn't * need vectors, so we won't bother with them.. */ - for (i = 0; i < ARRAY_SIZE(assp_minisrc_image); i++) { + data = (u16 *)chip->assp_minisrc_image->data; + for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, - 0x400 + i, - assp_minisrc_image[i]); + 0x400 + i, data[i]); } /* @@ -2444,7 +2442,7 @@ snd_m3_chip_init(struct snd_m3 *chip) DISABLE_LEGACY); pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w); - if (chip->hv_quirk && chip->hv_quirk->is_omnibook) { + if (chip->is_omnibook) { /* * Volume buttons on some HP OmniBook laptops don't work * correctly. This makes them work for the most part. @@ -2461,8 +2459,7 @@ snd_m3_chip_init(struct snd_m3 *chip) } pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n); n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD); - if (chip->hv_quirk) - n |= chip->hv_quirk->config; + n |= chip->hv_config; /* For some reason we must always use reduced debounce. */ n |= REDUCED_DEBOUNCE; n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING; @@ -2510,7 +2507,7 @@ snd_m3_enable_ints(struct snd_m3 *chip) /* TODO: MPU401 not supported yet */ val = ASSP_INT_ENABLE /*| MPU401_INT_ENABLE*/; - if (chip->hv_quirk && (chip->hv_quirk->config & HV_CTRL_ENABLE)) + if (chip->hv_config & HV_CTRL_ENABLE) val |= HV_INT_ENABLE; outw(val, io + HOST_INT_CTRL); outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, @@ -2553,6 +2550,15 @@ #endif if (chip->iobase) pci_release_regions(chip->pci); +#ifdef FIRMWARE_IN_THE_KERNEL + if (chip->assp_kernel_image != &assp_kernel) +#endif + release_firmware(chip->assp_kernel_image); +#ifdef FIRMWARE_IN_THE_KERNEL + if (chip->assp_minisrc_image != &assp_minisrc) +#endif + release_firmware(chip->assp_minisrc_image); + pci_disable_device(chip->pci); kfree(chip); return 0; @@ -2665,8 +2671,7 @@ snd_m3_create(struct snd_card *card, str { struct snd_m3 *chip; int i, err; - const struct m3_quirk *quirk; - const struct m3_hv_quirk *hv_quirk; + const struct snd_pci_quirk *quirk; static struct snd_device_ops ops = { .dev_free = snd_m3_dev_free, }; @@ -2706,34 +2711,32 @@ snd_m3_create(struct snd_card *card, str chip->pci = pci; chip->irq = -1; - for (quirk = m3_quirk_list; quirk->vendor; quirk++) { - if (pci->subsystem_vendor == quirk->vendor && - pci->subsystem_device == quirk->device) { - printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name); - chip->quirk = quirk; - break; - } - } - - for (hv_quirk = m3_hv_quirk_list; hv_quirk->vendor; hv_quirk++) { - if (pci->vendor == hv_quirk->vendor && - pci->device == hv_quirk->device && - pci->subsystem_vendor == hv_quirk->subsystem_vendor && - pci->subsystem_device == hv_quirk->subsystem_device) { - chip->hv_quirk = hv_quirk; - break; - } - } - chip->external_amp = enable_amp; if (amp_gpio >= 0 && amp_gpio <= 0x0f) chip->amp_gpio = amp_gpio; - else if (chip->quirk && chip->quirk->amp_gpio >= 0) - chip->amp_gpio = chip->quirk->amp_gpio; - else if (chip->allegro_flag) - chip->amp_gpio = GPO_EXT_AMP_ALLEGRO; - else /* presumably this is for all 'maestro3's.. */ - chip->amp_gpio = GPO_EXT_AMP_M3; + else { + quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list); + if (quirk) { + snd_printdd(KERN_INFO "maestro3: set amp-gpio " + "for '%s'\n", quirk->name); + chip->amp_gpio = quirk->value; + } else if (chip->allegro_flag) + chip->amp_gpio = GPO_EXT_AMP_ALLEGRO; + else /* presumably this is for all 'maestro3's.. */ + chip->amp_gpio = GPO_EXT_AMP_M3; + } + + quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list); + if (quirk) { + snd_printdd(KERN_INFO "maestro3: enabled irda workaround " + "for '%s'\n", quirk->name); + chip->irda_workaround = 1; + } + quirk = snd_pci_quirk_lookup(pci, m3_hv_quirk_list); + if (quirk) + chip->hv_config = quirk->value; + if (snd_pci_quirk_lookup(pci, m3_omnibook_quirk_list)) + chip->is_omnibook = 1; chip->num_substreams = NR_DSPS; chip->substreams = kcalloc(chip->num_substreams, sizeof(struct m3_dma), @@ -2744,6 +2747,30 @@ snd_m3_create(struct snd_card *card, str return -ENOMEM; } + err = request_firmware(&chip->assp_kernel_image, + "ess/maestro3_assp_kernel.fw", &pci->dev); + if (err < 0) { +#ifdef FIRMWARE_IN_THE_KERNEL + chip->assp_kernel_image = &assp_kernel; +#else + snd_m3_free(chip); + return err; +#endif + } else + snd_m3_convert_from_le(chip->assp_kernel_image); + + err = request_firmware(&chip->assp_minisrc_image, + "ess/maestro3_assp_minisrc.fw", &pci->dev); + if (err < 0) { +#ifdef FIRMWARE_IN_THE_KERNEL + chip->assp_minisrc_image = &assp_minisrc; +#else + snd_m3_free(chip); + return err; +#endif + } else + snd_m3_convert_from_le(chip->assp_minisrc_image); + if ((err = pci_request_regions(pci, card->driver)) < 0) { snd_m3_free(chip); return err; diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 879e31a..03b3a47 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1628,23 +1628,15 @@ __error: } -struct nm256_quirk { - unsigned short vendor; - unsigned short device; - int type; -}; - enum { NM_BLACKLISTED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 }; -static struct nm256_quirk nm256_quirks[] __devinitdata = { +static struct snd_pci_quirk nm256_quirks[] __devinitdata = { /* HP omnibook 4150 has cs4232 codec internally */ - { .vendor = 0x103c, .device = 0x0007, .type = NM_BLACKLISTED }, - /* Sony PCG-F305 */ - { .vendor = 0x104d, .device = 0x8041, .type = NM_RESET_WORKAROUND }, - /* Dell Latitude LS */ - { .vendor = 0x1028, .device = 0x0080, .type = NM_RESET_WORKAROUND }, - /* Dell Latitude CSx */ - { .vendor = 0x1028, .device = 0x0091, .type = NM_RESET_WORKAROUND_2 }, + SND_PCI_QUIRK(0x103c, 0x0007, "HP omnibook 4150", NM_BLACKLISTED), + /* Reset workarounds to avoid lock-ups */ + SND_PCI_QUIRK(0x104d, 0x8041, "Sony PCG-F305", NM_RESET_WORKAROUND), + SND_PCI_QUIRK(0x1028, 0x0080, "Dell Latitude LS", NM_RESET_WORKAROUND), + SND_PCI_QUIRK(0x1028, 0x0091, "Dell Latitude CSx", NM_RESET_WORKAROUND_2), { } /* terminator */ }; @@ -1655,26 +1647,22 @@ static int __devinit snd_nm256_probe(str struct snd_card *card; struct nm256 *chip; int err; - struct nm256_quirk *q; - u16 subsystem_vendor, subsystem_device; - - pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); - pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); - - for (q = nm256_quirks; q->vendor; q++) { - if (q->vendor == subsystem_vendor && q->device == subsystem_device) { - switch (q->type) { - case NM_BLACKLISTED: - printk(KERN_INFO "nm256: The device is blacklisted. " - "Loading stopped\n"); - return -ENODEV; - case NM_RESET_WORKAROUND_2: - reset_workaround_2 = 1; - /* Fall-through */ - case NM_RESET_WORKAROUND: - reset_workaround = 1; - break; - } + const struct snd_pci_quirk *q; + + q = snd_pci_quirk_lookup(pci, nm256_quirks); + if (q) { + snd_printdd(KERN_INFO "nm256: Enabled quirk for %s.\n", q->name); + switch (q->value) { + case NM_BLACKLISTED: + printk(KERN_INFO "nm256: The device is blacklisted. " + "Loading stopped\n"); + return -ENODEV; + case NM_RESET_WORKAROUND_2: + reset_workaround_2 = 1; + /* Fall-through */ + case NM_RESET_WORKAROUND: + reset_workaround = 1; + break; } } diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 6383987..89b3c7f 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -80,6 +80,7 @@ #define H9632_QS_CHANNELS 4 /* Write registers. These are defined as byte-offsets from the iobase value. */ #define HDSP_resetPointer 0 +#define HDSP_freqReg 0 #define HDSP_outputBufferAddress 32 #define HDSP_inputBufferAddress 36 #define HDSP_controlRegister 64 @@ -469,6 +470,7 @@ struct hdsp { struct pci_dev *pci; struct snd_kcontrol *spdif_ctl; unsigned short mixer_matrix[HDSP_MATRIX_MIXER_SIZE]; + unsigned int dds_value; /* last value written to freq register */ }; /* These tables map the ALSA channels 1..N to the channels that we @@ -598,6 +600,7 @@ static int hdsp_playback_to_output_key ( return (64 * out) + (32 + (in)); case 0x96: case 0x97: + case 0x98: return (32 * out) + (16 + (in)); default: return (52 * out) + (26 + (in)); @@ -611,6 +614,7 @@ static int hdsp_input_to_output_key (str return (64 * out) + in; case 0x96: case 0x97: + case 0x98: return (32 * out) + in; default: return (52 * out) + in; @@ -938,6 +942,11 @@ static snd_pcm_uframes_t hdsp_hw_pointer static void hdsp_reset_hw_pointer(struct hdsp *hdsp) { hdsp_write (hdsp, HDSP_resetPointer, 0); + if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) + /* HDSP_resetPointer = HDSP_freqReg, which is strange and + * requires (?) to write again DDS value after a reset pointer + * (at least, it works like this) */ + hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value); } static void hdsp_start_audio(struct hdsp *s) @@ -982,6 +991,30 @@ static int hdsp_set_interrupt_interval(s return 0; } +static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) +{ + u64 n; + u32 r; + + if (rate >= 112000) + rate /= 4; + else if (rate >= 56000) + rate /= 2; + + /* RME says n = 104857600000000, but in the windows MADI driver, I see: +// return 104857600000000 / rate; // 100 MHz + return 110100480000000 / rate; // 105 MHz + */ + n = 104857600000000ULL; /* = 2^20 * 10^8 */ + div64_32(&n, rate, &r); + /* n should be less than 2^32 for being written to FREQ register */ + snd_assert((n >> 32) == 0); + /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS + value to write it after a reset */ + hdsp->dds_value = n; + hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value); +} + static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) { int reject_if_open = 0; @@ -1090,6 +1123,10 @@ static int hdsp_set_rate(struct hdsp *hd hdsp->control_register |= rate_bits; hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); + /* For HDSP9632 rev 152, need to set DDS value in FREQ register */ + if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) + hdsp_set_dds_value(hdsp, rate); + if (rate >= 128000) { hdsp->channel_map = channel_map_H9632_qs; } else if (rate > 48000) { @@ -4943,6 +4980,7 @@ static int __devinit snd_hdsp_create(str hdsp->irq = pci->irq; hdsp->precise_ptr = 0; hdsp->use_midi_tasklet = 1; + hdsp->dds_value = 0; if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) return err; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 0547f6f..e0215ac 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6,6 +6,8 @@ * code based on hdsp.c Paul Davis * Marcus Andersson * Thomas Charbonnel + * Modified 2006-06-01 for AES32 support by Remy Bruno + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,7 +79,8 @@ MODULE_PARM_DESC(enable_monitor, MODULE_AUTHOR ("Winfried Ritsch , Paul Davis , " - "Marcus Andersson, Thomas Charbonnel "); + "Marcus Andersson, Thomas Charbonnel , " + "Remy Bruno "); MODULE_DESCRIPTION("RME HDSPM"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}"); @@ -107,7 +110,12 @@ #define HDSPM_MATRIX_MIXER_SIZE 8192 /* /* --- Read registers. --- These are defined as byte-offsets from the iobase value */ #define HDSPM_statusRegister 0 -#define HDSPM_statusRegister2 96 +/*#define HDSPM_statusRegister2 96 */ +/* after RME Windows driver sources, status2 is 4-byte word # 48 = word at + * offset 192, for AES32 *and* MADI + * => need to check that offset 192 is working on MADI */ +#define HDSPM_statusRegister2 192 +#define HDSPM_timecodeRegister 128 #define HDSPM_midiDataIn0 360 #define HDSPM_midiDataIn1 364 @@ -140,37 +148,50 @@ #define HDSPM_AudioInterruptEnable (1<<5 #define HDSPM_Frequency0 (1<<6) /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */ #define HDSPM_Frequency1 (1<<7) /* 0=32kHz/64kHz */ #define HDSPM_DoubleSpeed (1<<8) /* 0=normal speed, 1=double speed */ -#define HDSPM_QuadSpeed (1<<31) /* quad speed bit, not implemented now */ +#define HDSPM_QuadSpeed (1<<31) /* quad speed bit */ +#define HDSPM_Professional (1<<9) /* Professional */ /* AES32 ONLY */ #define HDSPM_TX_64ch (1<<10) /* Output 64channel MODE=1, - 56channelMODE=0 */ + 56channelMODE=0 */ /* MADI ONLY*/ +#define HDSPM_Emphasis (1<<10) /* Emphasis */ /* AES32 ONLY */ #define HDSPM_AutoInp (1<<11) /* Auto Input (takeover) == Safe Mode, - 0=off, 1=on */ + 0=off, 1=on */ /* MADI ONLY */ +#define HDSPM_Dolby (1<<11) /* Dolby = "NonAudio" ?? */ /* AES32 ONLY */ -#define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */ +#define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */ /* MADI ONLY*/ #define HDSPM_InputSelect1 (1<<15) /* should be 0 */ #define HDSPM_SyncRef0 (1<<16) /* 0=WOrd, 1=MADI */ -#define HDSPM_SyncRef1 (1<<17) /* should be 0 */ +#define HDSPM_SyncRef1 (1<<17) /* for AES32: SyncRefN codes the AES # */ +#define HDSPM_SyncRef2 (1<<13) +#define HDSPM_SyncRef3 (1<<25) +#define HDSPM_SMUX (1<<18) /* Frame ??? */ /* MADI ONY */ #define HDSPM_clr_tms (1<<19) /* clear track marker, do not use AES additional bits in lower 5 Audiodatabits ??? */ +#define HDSPM_taxi_reset (1<<20) /* ??? */ /* MADI ONLY ? */ +#define HDSPM_WCK48 (1<<20) /* Frame ??? = HDSPM_SMUX */ /* AES32 ONLY */ #define HDSPM_Midi0InterruptEnable (1<<22) #define HDSPM_Midi1InterruptEnable (1<<23) #define HDSPM_LineOut (1<<24) /* Analog Out on channel 63/64 on=1, mute=0 */ +#define HDSPM_DS_DoubleWire (1<<26) /* AES32 ONLY */ +#define HDSPM_QS_DoubleWire (1<<27) /* AES32 ONLY */ +#define HDSPM_QS_QuadWire (1<<28) /* AES32 ONLY */ + +#define HDSPM_wclk_sel (1<<30) /* --- bit helper defines */ #define HDSPM_LatencyMask (HDSPM_Latency0|HDSPM_Latency1|HDSPM_Latency2) -#define HDSPM_FrequencyMask (HDSPM_Frequency0|HDSPM_Frequency1) +#define HDSPM_FrequencyMask (HDSPM_Frequency0|HDSPM_Frequency1|HDSPM_DoubleSpeed|HDSPM_QuadSpeed) #define HDSPM_InputMask (HDSPM_InputSelect0|HDSPM_InputSelect1) #define HDSPM_InputOptical 0 #define HDSPM_InputCoaxial (HDSPM_InputSelect0) -#define HDSPM_SyncRefMask (HDSPM_SyncRef0|HDSPM_SyncRef1) +#define HDSPM_SyncRefMask (HDSPM_SyncRef0|HDSPM_SyncRef1|HDSPM_SyncRef2|HDSPM_SyncRef3) #define HDSPM_SyncRef_Word 0 #define HDSPM_SyncRef_MADI (HDSPM_SyncRef0) @@ -183,6 +204,9 @@ #define HDSPM_Frequency48KHz (HDSPM_Fr #define HDSPM_Frequency64KHz (HDSPM_DoubleSpeed|HDSPM_Frequency0) #define HDSPM_Frequency88_2KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1) #define HDSPM_Frequency96KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1|HDSPM_Frequency0) +#define HDSPM_Frequency128KHz (HDSPM_QuadSpeed|HDSPM_Frequency0) +#define HDSPM_Frequency176_4KHz (HDSPM_QuadSpeed|HDSPM_Frequency1) +#define HDSPM_Frequency192KHz (HDSPM_QuadSpeed|HDSPM_Frequency1|HDSPM_Frequency0) /* --- for internal discrimination */ #define HDSPM_CLOCK_SOURCE_AUTOSYNC 0 /* Sample Clock Sources */ @@ -229,7 +253,8 @@ #define HDSPM_CONFIG_MODE_1 (1<<7) #define HDSPM_BIGENDIAN_MODE (1<<9) #define HDSPM_RD_MULTIPLE (1<<10) -/* --- Status Register bits --- */ +/* --- Status Register bits --- */ /* MADI ONLY */ /* Bits defined here and + that do not conflict with specific bits for AES32 seem to be valid also for the AES32 */ #define HDSPM_audioIRQPending (1<<0) /* IRQ is high and pending */ #define HDSPM_RX_64ch (1<<1) /* Input 64chan. MODE=1, 56chn. MODE=0 */ #define HDSPM_AB_int (1<<2) /* InputChannel Opt=0, Coax=1 (like inp0) */ @@ -263,7 +288,7 @@ #define HDSPM_madiFreq128 (HDSPM_madiF #define HDSPM_madiFreq176_4 (HDSPM_madiFreq3) #define HDSPM_madiFreq192 (HDSPM_madiFreq3|HDSPM_madiFreq0) -/* Status2 Register bits */ +/* Status2 Register bits */ /* MADI ONLY */ #define HDSPM_version0 (1<<0) /* not realy defined but I guess */ #define HDSPM_version1 (1<<1) /* in former cards it was ??? */ @@ -297,6 +322,56 @@ #define HDSPM_SelSyncRef_WORD 0 #define HDSPM_SelSyncRef_MADI (HDSPM_SelSyncRef0) #define HDSPM_SelSyncRef_NVALID (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2) +/* + For AES32, bits for status, status2 and timecode are different +*/ +/* status */ +#define HDSPM_AES32_wcLock 0x0200000 +#define HDSPM_AES32_wcFreq_bit 22 +/* (status >> HDSPM_AES32_wcFreq_bit) & 0xF gives WC frequency (cf function + HDSPM_bit2freq */ +#define HDSPM_AES32_syncref_bit 16 +/* (status >> HDSPM_AES32_syncref_bit) & 0xF gives sync source */ + +#define HDSPM_AES32_AUTOSYNC_FROM_WORD 0 +#define HDSPM_AES32_AUTOSYNC_FROM_AES1 1 +#define HDSPM_AES32_AUTOSYNC_FROM_AES2 2 +#define HDSPM_AES32_AUTOSYNC_FROM_AES3 3 +#define HDSPM_AES32_AUTOSYNC_FROM_AES4 4 +#define HDSPM_AES32_AUTOSYNC_FROM_AES5 5 +#define HDSPM_AES32_AUTOSYNC_FROM_AES6 6 +#define HDSPM_AES32_AUTOSYNC_FROM_AES7 7 +#define HDSPM_AES32_AUTOSYNC_FROM_AES8 8 +#define HDSPM_AES32_AUTOSYNC_FROM_NONE -1 + +/* status2 */ +/* HDSPM_LockAES_bit is given by HDSPM_LockAES >> (AES# - 1) */ +#define HDSPM_LockAES 0x80 +#define HDSPM_LockAES1 0x80 +#define HDSPM_LockAES2 0x40 +#define HDSPM_LockAES3 0x20 +#define HDSPM_LockAES4 0x10 +#define HDSPM_LockAES5 0x8 +#define HDSPM_LockAES6 0x4 +#define HDSPM_LockAES7 0x2 +#define HDSPM_LockAES8 0x1 +/* + Timecode + After windows driver sources, bits 4*i to 4*i+3 give the input frequency on + AES i+1 + bits 3210 + 0001 32kHz + 0010 44.1kHz + 0011 48kHz + 0100 64kHz + 0101 88.2kHz + 0110 96kHz + 0111 128kHz + 1000 176.4kHz + 1001 192kHz + NB: Timecode register doesn't seem to work on AES32 card revision 230 +*/ + /* Mixer Values */ #define UNITY_GAIN 32768 /* = 65536/2 */ #define MINUS_INFINITY_GAIN 0 @@ -314,10 +389,14 @@ #define HDSPM_CHANNEL_BUFFER_BYTES (4 size is the same regardless of the number of channels, and also the latency to use. for one direction !!! + => need to mupltiply by 2!! */ -#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) +#define HDSPM_DMA_AREA_BYTES (2 * HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) #define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) +/* revisions >= 230 indicate AES32 card */ +#define HDSPM_AESREVISION 230 + struct hdspm_midi { struct hdspm *hdspm; int id; @@ -336,7 +415,9 @@ struct hdspm { struct snd_pcm_substream *playback_substream; /* and/or capture stream */ char *card_name; /* for procinfo */ - unsigned short firmware_rev; /* dont know if relevant */ + unsigned short firmware_rev; /* dont know if relevant (yes if AES32)*/ + + unsigned char is_aes32; /* indicates if card is AES32 */ int precise_ptr; /* use precise pointers, to be tested */ int monitor_outs; /* set up monitoring outs init flag */ @@ -453,6 +534,15 @@ static int snd_hdspm_set_defaults(struct static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf, unsigned int reg, int channels); +static inline int HDSPM_bit2freq(int n) +{ + static int bit2freq_tab[] = { 0, 32000, 44100, 48000, 64000, 88200, + 96000, 128000, 176400, 192000 }; + if (n < 1 || n > 9) + return 0; + return bit2freq_tab[n]; +} + /* Write/read to/from HDSPM with Adresses in Bytes not words but only 32Bit writes are allowed */ @@ -544,86 +634,105 @@ static inline int snd_hdspm_use_is_exclu /* check for external sample rate */ static inline int hdspm_external_sample_rate(struct hdspm * hdspm) { - unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); - unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); - unsigned int rate_bits; - int rate = 0; + if (hdspm->is_aes32) { + unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); + unsigned int timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); + + int syncref = hdspm_autosync_ref(hdspm); + + if (syncref == HDSPM_AES32_AUTOSYNC_FROM_WORD && + status & HDSPM_AES32_wcLock) + return HDSPM_bit2freq((status >> HDSPM_AES32_wcFreq_bit) & 0xF); + if (syncref >= HDSPM_AES32_AUTOSYNC_FROM_AES1 && + syncref <= HDSPM_AES32_AUTOSYNC_FROM_AES8 && + status2 & (HDSPM_LockAES >> + (syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1))) + return HDSPM_bit2freq((timecode >> + (4*(syncref-HDSPM_AES32_AUTOSYNC_FROM_AES1))) & 0xF); + return 0; + } else { + unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); + unsigned int rate_bits; + int rate = 0; - /* if wordclock has synced freq and wordclock is valid */ - if ((status2 & HDSPM_wcLock) != 0 && - (status & HDSPM_SelSyncRef0) == 0) { + /* if wordclock has synced freq and wordclock is valid */ + if ((status2 & HDSPM_wcLock) != 0 && + (status & HDSPM_SelSyncRef0) == 0) { - rate_bits = status2 & HDSPM_wcFreqMask; + rate_bits = status2 & HDSPM_wcFreqMask; - switch (rate_bits) { - case HDSPM_wcFreq32: - rate = 32000; - break; - case HDSPM_wcFreq44_1: - rate = 44100; - break; - case HDSPM_wcFreq48: - rate = 48000; - break; - case HDSPM_wcFreq64: - rate = 64000; - break; - case HDSPM_wcFreq88_2: - rate = 88200; - break; - case HDSPM_wcFreq96: - rate = 96000; - break; - /* Quadspeed Bit missing ???? */ - default: - rate = 0; - break; + switch (rate_bits) { + case HDSPM_wcFreq32: + rate = 32000; + break; + case HDSPM_wcFreq44_1: + rate = 44100; + break; + case HDSPM_wcFreq48: + rate = 48000; + break; + case HDSPM_wcFreq64: + rate = 64000; + break; + case HDSPM_wcFreq88_2: + rate = 88200; + break; + case HDSPM_wcFreq96: + rate = 96000; + break; + /* Quadspeed Bit missing ???? */ + default: + rate = 0; + break; + } } - } - /* if rate detected and Syncref is Word than have it, word has priority to MADI */ - if (rate != 0 - && (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD) - return rate; + /* if rate detected and Syncref is Word than have it, word has priority to MADI */ + if (rate != 0 && + (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD) + return rate; - /* maby a madi input (which is taken if sel sync is madi) */ - if (status & HDSPM_madiLock) { - rate_bits = status & HDSPM_madiFreqMask; + /* maby a madi input (which is taken if sel sync is madi) */ + if (status & HDSPM_madiLock) { + rate_bits = status & HDSPM_madiFreqMask; - switch (rate_bits) { - case HDSPM_madiFreq32: - rate = 32000; - break; - case HDSPM_madiFreq44_1: - rate = 44100; - break; - case HDSPM_madiFreq48: - rate = 48000; - break; - case HDSPM_madiFreq64: - rate = 64000; - break; - case HDSPM_madiFreq88_2: - rate = 88200; - break; - case HDSPM_madiFreq96: - rate = 96000; - break; - case HDSPM_madiFreq128: - rate = 128000; - break; - case HDSPM_madiFreq176_4: - rate = 176400; - break; - case HDSPM_madiFreq192: - rate = 192000; - break; - default: - rate = 0; - break; + switch (rate_bits) { + case HDSPM_madiFreq32: + rate = 32000; + break; + case HDSPM_madiFreq44_1: + rate = 44100; + break; + case HDSPM_madiFreq48: + rate = 48000; + break; + case HDSPM_madiFreq64: + rate = 64000; + break; + case HDSPM_madiFreq88_2: + rate = 88200; + break; + case HDSPM_madiFreq96: + rate = 96000; + break; + case HDSPM_madiFreq128: + rate = 128000; + break; + case HDSPM_madiFreq176_4: + rate = 176400; + break; + case HDSPM_madiFreq192: + rate = 192000; + break; + default: + rate = 0; + break; + } } + return rate; } - return rate; } /* Latency function */ @@ -676,7 +785,8 @@ static inline void hdspm_silence_playbac int n = hdspm->period_bytes; void *buf = hdspm->playback_buffer; - snd_assert(buf != NULL, return); + if (buf == NULL) + return; for (i = 0; i < HDSPM_MAX_CHANNELS; i++) { memset(buf, 0, n); @@ -716,6 +826,7 @@ static int hdspm_set_rate(struct hdspm * int current_rate; int rate_bits; int not_set = 0; + int is_single, is_double, is_quad; /* ASSUMPTION: hdspm->lock is either set, or there is no need for it (e.g. during module initialization). @@ -766,43 +877,56 @@ static int hdspm_set_rate(struct hdspm * changes in the read/write routines. */ + is_single = (current_rate <= 48000); + is_double = (current_rate > 48000 && current_rate <= 96000); + is_quad = (current_rate > 96000); + switch (rate) { case 32000: - if (current_rate > 48000) { + if (!is_single) reject_if_open = 1; - } rate_bits = HDSPM_Frequency32KHz; break; case 44100: - if (current_rate > 48000) { + if (!is_single) reject_if_open = 1; - } rate_bits = HDSPM_Frequency44_1KHz; break; case 48000: - if (current_rate > 48000) { + if (!is_single) reject_if_open = 1; - } rate_bits = HDSPM_Frequency48KHz; break; case 64000: - if (current_rate <= 48000) { + if (!is_double) reject_if_open = 1; - } rate_bits = HDSPM_Frequency64KHz; break; case 88200: - if (current_rate <= 48000) { + if (!is_double) reject_if_open = 1; - } rate_bits = HDSPM_Frequency88_2KHz; break; case 96000: - if (current_rate <= 48000) { + if (!is_double) reject_if_open = 1; - } rate_bits = HDSPM_Frequency96KHz; break; + case 128000: + if (!is_quad) + reject_if_open = 1; + rate_bits = HDSPM_Frequency128KHz; + break; + case 176400: + if (!is_quad) + reject_if_open = 1; + rate_bits = HDSPM_Frequency176_4KHz; + break; + case 192000: + if (!is_quad) + reject_if_open = 1; + rate_bits = HDSPM_Frequency192KHz; + break; default: return -EINVAL; } @@ -819,7 +943,7 @@ static int hdspm_set_rate(struct hdspm * hdspm->control_register |= rate_bits; hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); - if (rate > 64000) + if (rate > 96000 /* 64000*/) hdspm->channel_map = channel_map_madi_qs; else if (rate > 48000) hdspm->channel_map = channel_map_madi_ds; @@ -1455,11 +1579,27 @@ static int hdspm_pref_sync_ref(struct hd /* Notice that this looks at the requested sync source, not the one actually in use. */ - switch (hdspm->control_register & HDSPM_SyncRefMask) { - case HDSPM_SyncRef_Word: - return HDSPM_SYNC_FROM_WORD; - case HDSPM_SyncRef_MADI: - return HDSPM_SYNC_FROM_MADI; + if (hdspm->is_aes32) { + switch (hdspm->control_register & HDSPM_SyncRefMask) { + /* number gives AES index, except for 0 which + corresponds to WordClock */ + case 0: return 0; + case HDSPM_SyncRef0: return 1; + case HDSPM_SyncRef1: return 2; + case HDSPM_SyncRef1+HDSPM_SyncRef0: return 3; + case HDSPM_SyncRef2: return 4; + case HDSPM_SyncRef2+HDSPM_SyncRef0: return 5; + case HDSPM_SyncRef2+HDSPM_SyncRef1: return 6; + case HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0: return 7; + case HDSPM_SyncRef3: return 8; + } + } else { + switch (hdspm->control_register & HDSPM_SyncRefMask) { + case HDSPM_SyncRef_Word: + return HDSPM_SYNC_FROM_WORD; + case HDSPM_SyncRef_MADI: + return HDSPM_SYNC_FROM_MADI; + } } return HDSPM_SYNC_FROM_WORD; @@ -1469,15 +1609,49 @@ static int hdspm_set_pref_sync_ref(struc { hdspm->control_register &= ~HDSPM_SyncRefMask; - switch (pref) { - case HDSPM_SYNC_FROM_MADI: - hdspm->control_register |= HDSPM_SyncRef_MADI; - break; - case HDSPM_SYNC_FROM_WORD: - hdspm->control_register |= HDSPM_SyncRef_Word; - break; - default: - return -1; + if (hdspm->is_aes32) { + switch (pref) { + case 0: + hdspm->control_register |= 0; + break; + case 1: + hdspm->control_register |= HDSPM_SyncRef0; + break; + case 2: + hdspm->control_register |= HDSPM_SyncRef1; + break; + case 3: + hdspm->control_register |= HDSPM_SyncRef1+HDSPM_SyncRef0; + break; + case 4: + hdspm->control_register |= HDSPM_SyncRef2; + break; + case 5: + hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef0; + break; + case 6: + hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef1; + break; + case 7: + hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0; + break; + case 8: + hdspm->control_register |= HDSPM_SyncRef3; + break; + default: + return -1; + } + } else { + switch (pref) { + case HDSPM_SYNC_FROM_MADI: + hdspm->control_register |= HDSPM_SyncRef_MADI; + break; + case HDSPM_SYNC_FROM_WORD: + hdspm->control_register |= HDSPM_SyncRef_Word; + break; + default: + return -1; + } } hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); return 0; @@ -1486,18 +1660,36 @@ static int hdspm_set_pref_sync_ref(struc static int snd_hdspm_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - static char *texts[] = { "Word", "MADI" }; + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; + if (hdspm->is_aes32) { + static char *texts[] = { "Word", "AES1", "AES2", "AES3", + "AES4", "AES5", "AES6", "AES7", "AES8" }; - uinfo->value.enumerated.items = 2; + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) - uinfo->value.enumerated.item = - uinfo->value.enumerated.items - 1; - strcpy(uinfo->value.enumerated.name, - texts[uinfo->value.enumerated.item]); + uinfo->value.enumerated.items = 9; + + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + } else { + static char *texts[] = { "Word", "MADI" }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + + uinfo->value.enumerated.items = 2; + + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + } return 0; } @@ -1517,7 +1709,7 @@ static int snd_hdspm_put_pref_sync_ref(s int change, max; unsigned int val; - max = 2; + max = hdspm->is_aes32 ? 9 : 2; if (!snd_hdspm_use_is_exclusive(hdspm)) return -EBUSY; @@ -1542,40 +1734,64 @@ #define HDSPM_AUTOSYNC_REF(xname, xindex static int hdspm_autosync_ref(struct hdspm * hdspm) { - /* This looks at the autosync selected sync reference */ - unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); - - switch (status2 & HDSPM_SelSyncRefMask) { - - case HDSPM_SelSyncRef_WORD: - return HDSPM_AUTOSYNC_FROM_WORD; - - case HDSPM_SelSyncRef_MADI: - return HDSPM_AUTOSYNC_FROM_MADI; - - case HDSPM_SelSyncRef_NVALID: - return HDSPM_AUTOSYNC_FROM_NONE; + if (hdspm->is_aes32) { + unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); + unsigned int syncref = (status >> HDSPM_AES32_syncref_bit) & 0xF; + if (syncref == 0) + return HDSPM_AES32_AUTOSYNC_FROM_WORD; + if (syncref <= 8) + return syncref; + return HDSPM_AES32_AUTOSYNC_FROM_NONE; + } else { + /* This looks at the autosync selected sync reference */ + unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + + switch (status2 & HDSPM_SelSyncRefMask) { + case HDSPM_SelSyncRef_WORD: + return HDSPM_AUTOSYNC_FROM_WORD; + case HDSPM_SelSyncRef_MADI: + return HDSPM_AUTOSYNC_FROM_MADI; + case HDSPM_SelSyncRef_NVALID: + return HDSPM_AUTOSYNC_FROM_NONE; + default: + return 0; + } - default: return 0; } - - return 0; } static int snd_hdspm_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - static char *texts[] = { "WordClock", "MADI", "None" }; + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = 3; - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) - uinfo->value.enumerated.item = - uinfo->value.enumerated.items - 1; - strcpy(uinfo->value.enumerated.name, - texts[uinfo->value.enumerated.item]); + if (hdspm->is_aes32) { + static char *texts[] = { "WordClock", "AES1", "AES2", "AES3", + "AES4", "AES5", "AES6", "AES7", "AES8", "None"}; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 10; + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + } + else + { + static char *texts[] = { "WordClock", "MADI", "None" }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 3; + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + } return 0; } @@ -1841,6 +2057,195 @@ static int snd_hdspm_put_safe_mode(struc return change; } +#define HDSPM_EMPHASIS(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .info = snd_hdspm_info_emphasis, \ + .get = snd_hdspm_get_emphasis, \ + .put = snd_hdspm_put_emphasis \ +} + +static int hdspm_emphasis(struct hdspm * hdspm) +{ + return (hdspm->control_register & HDSPM_Emphasis) ? 1 : 0; +} + +static int hdspm_set_emphasis(struct hdspm * hdspm, int emp) +{ + if (emp) + hdspm->control_register |= HDSPM_Emphasis; + else + hdspm->control_register &= ~HDSPM_Emphasis; + hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); + + return 0; +} + +static int snd_hdspm_info_emphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_hdspm_get_emphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + spin_lock_irq(&hdspm->lock); + ucontrol->value.enumerated.item[0] = hdspm_emphasis(hdspm); + spin_unlock_irq(&hdspm->lock); + return 0; +} + +static int snd_hdspm_put_emphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int change; + unsigned int val; + + if (!snd_hdspm_use_is_exclusive(hdspm)) + return -EBUSY; + val = ucontrol->value.integer.value[0] & 1; + spin_lock_irq(&hdspm->lock); + change = (int) val != hdspm_emphasis(hdspm); + hdspm_set_emphasis(hdspm, val); + spin_unlock_irq(&hdspm->lock); + return change; +} + +#define HDSPM_DOLBY(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .info = snd_hdspm_info_dolby, \ + .get = snd_hdspm_get_dolby, \ + .put = snd_hdspm_put_dolby \ +} + +static int hdspm_dolby(struct hdspm * hdspm) +{ + return (hdspm->control_register & HDSPM_Dolby) ? 1 : 0; +} + +static int hdspm_set_dolby(struct hdspm * hdspm, int dol) +{ + if (dol) + hdspm->control_register |= HDSPM_Dolby; + else + hdspm->control_register &= ~HDSPM_Dolby; + hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); + + return 0; +} + +static int snd_hdspm_info_dolby(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_hdspm_get_dolby(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + spin_lock_irq(&hdspm->lock); + ucontrol->value.enumerated.item[0] = hdspm_dolby(hdspm); + spin_unlock_irq(&hdspm->lock); + return 0; +} + +static int snd_hdspm_put_dolby(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int change; + unsigned int val; + + if (!snd_hdspm_use_is_exclusive(hdspm)) + return -EBUSY; + val = ucontrol->value.integer.value[0] & 1; + spin_lock_irq(&hdspm->lock); + change = (int) val != hdspm_dolby(hdspm); + hdspm_set_dolby(hdspm, val); + spin_unlock_irq(&hdspm->lock); + return change; +} + +#define HDSPM_PROFESSIONAL(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .info = snd_hdspm_info_professional, \ + .get = snd_hdspm_get_professional, \ + .put = snd_hdspm_put_professional \ +} + +static int hdspm_professional(struct hdspm * hdspm) +{ + return (hdspm->control_register & HDSPM_Professional) ? 1 : 0; +} + +static int hdspm_set_professional(struct hdspm * hdspm, int dol) +{ + if (dol) + hdspm->control_register |= HDSPM_Professional; + else + hdspm->control_register &= ~HDSPM_Professional; + hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); + + return 0; +} + +static int snd_hdspm_info_professional(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_hdspm_get_professional(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + spin_lock_irq(&hdspm->lock); + ucontrol->value.enumerated.item[0] = hdspm_professional(hdspm); + spin_unlock_irq(&hdspm->lock); + return 0; +} + +static int snd_hdspm_put_professional(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int change; + unsigned int val; + + if (!snd_hdspm_use_is_exclusive(hdspm)) + return -EBUSY; + val = ucontrol->value.integer.value[0] & 1; + spin_lock_irq(&hdspm->lock); + change = (int) val != hdspm_professional(hdspm); + hdspm_set_professional(hdspm, val); + spin_unlock_irq(&hdspm->lock); + return change; +} + #define HDSPM_INPUT_SELECT(xname, xindex) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ .name = xname, \ @@ -1912,6 +2317,163 @@ static int snd_hdspm_put_input_select(st return change; } +#define HDSPM_DS_WIRE(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .info = snd_hdspm_info_ds_wire, \ + .get = snd_hdspm_get_ds_wire, \ + .put = snd_hdspm_put_ds_wire \ +} + +static int hdspm_ds_wire(struct hdspm * hdspm) +{ + return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0; +} + +static int hdspm_set_ds_wire(struct hdspm * hdspm, int ds) +{ + if (ds) + hdspm->control_register |= HDSPM_DS_DoubleWire; + else + hdspm->control_register &= ~HDSPM_DS_DoubleWire; + hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); + + return 0; +} + +static int snd_hdspm_info_ds_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[] = { "Single", "Double" }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 2; + + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + + return 0; +} + +static int snd_hdspm_get_ds_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + spin_lock_irq(&hdspm->lock); + ucontrol->value.enumerated.item[0] = hdspm_ds_wire(hdspm); + spin_unlock_irq(&hdspm->lock); + return 0; +} + +static int snd_hdspm_put_ds_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int change; + unsigned int val; + + if (!snd_hdspm_use_is_exclusive(hdspm)) + return -EBUSY; + val = ucontrol->value.integer.value[0] & 1; + spin_lock_irq(&hdspm->lock); + change = (int) val != hdspm_ds_wire(hdspm); + hdspm_set_ds_wire(hdspm, val); + spin_unlock_irq(&hdspm->lock); + return change; +} + +#define HDSPM_QS_WIRE(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .info = snd_hdspm_info_qs_wire, \ + .get = snd_hdspm_get_qs_wire, \ + .put = snd_hdspm_put_qs_wire \ +} + +static int hdspm_qs_wire(struct hdspm * hdspm) +{ + if (hdspm->control_register & HDSPM_QS_DoubleWire) + return 1; + if (hdspm->control_register & HDSPM_QS_QuadWire) + return 2; + return 0; +} + +static int hdspm_set_qs_wire(struct hdspm * hdspm, int mode) +{ + hdspm->control_register &= ~(HDSPM_QS_DoubleWire | HDSPM_QS_QuadWire); + switch (mode) { + case 0: + break; + case 1: + hdspm->control_register |= HDSPM_QS_DoubleWire; + break; + case 2: + hdspm->control_register |= HDSPM_QS_QuadWire; + break; + } + hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); + + return 0; +} + +static int snd_hdspm_info_qs_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[] = { "Single", "Double", "Quad" }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 3; + + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = + uinfo->value.enumerated.items - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + + return 0; +} + +static int snd_hdspm_get_qs_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + spin_lock_irq(&hdspm->lock); + ucontrol->value.enumerated.item[0] = hdspm_qs_wire(hdspm); + spin_unlock_irq(&hdspm->lock); + return 0; +} + +static int snd_hdspm_put_qs_wire(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int change; + int val; + + if (!snd_hdspm_use_is_exclusive(hdspm)) + return -EBUSY; + val = ucontrol->value.integer.value[0]; + if (val < 0) + val = 0; + if (val > 2) + val = 2; + spin_lock_irq(&hdspm->lock); + change = (int) val != hdspm_qs_wire(hdspm); + hdspm_set_qs_wire(hdspm, val); + spin_unlock_irq(&hdspm->lock); + return change; +} + /* Simple Mixer deprecated since to much faders ??? MIXER interface says output (source, destination, value) @@ -2135,14 +2697,24 @@ static int snd_hdspm_info_sync_check(str static int hdspm_wc_sync_check(struct hdspm * hdspm) { - int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); - if (status2 & HDSPM_wcLock) { - if (status2 & HDSPM_wcSync) + if (hdspm->is_aes32) { + int status = hdspm_read(hdspm, HDSPM_statusRegister); + if (status & HDSPM_AES32_wcLock) { + /* I don't know how to differenciate sync from lock. + Doing as if sync for now */ return 2; - else - return 1; + } + return 0; + } else { + int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + if (status2 & HDSPM_wcLock) { + if (status2 & HDSPM_wcSync) + return 2; + else + return 1; + } + return 0; } - return 0; } static int snd_hdspm_get_wc_sync_check(struct snd_kcontrol *kcontrol, @@ -2188,9 +2760,43 @@ static int snd_hdspm_get_madisync_sync_c } +#define HDSPM_AES_SYNC_CHECK(xname, xindex) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = xindex, \ + .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ + .info = snd_hdspm_info_sync_check, \ + .get = snd_hdspm_get_aes_sync_check \ +} + +static int hdspm_aes_sync_check(struct hdspm * hdspm, int idx) +{ + int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + if (status2 & (HDSPM_LockAES >> idx)) { + /* I don't know how to differenciate sync from lock. + Doing as if sync for now */ + return 2; + } + return 0; +} + +static int snd_hdspm_get_aes_sync_check(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int offset; + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + + offset = ucontrol->id.index - 1; + if (offset < 0 || offset >= 8) + return -EINVAL; + + ucontrol->value.enumerated.item[0] = + hdspm_aes_sync_check(hdspm, offset); + return 0; +} -static struct snd_kcontrol_new snd_hdspm_controls[] = { +static struct snd_kcontrol_new snd_hdspm_controls_madi[] = { HDSPM_MIXER("Mixer", 0), /* 'Sample Clock Source' complies with the alsa control naming scheme */ @@ -2211,6 +2817,29 @@ static struct snd_kcontrol_new snd_hdspm HDSPM_INPUT_SELECT("Input Select", 0), }; +static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = { + + HDSPM_MIXER("Mixer", 0), +/* 'Sample Clock Source' complies with the alsa control naming scheme */ + HDSPM_CLOCK_SOURCE("Sample Clock Source", 0), + + HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), + HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0), + HDSPM_AUTOSYNC_REF("AutoSync Reference", 0), + HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0), +/* 'External Rate' complies with the alsa control naming scheme */ + HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0), + HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0), +/* HDSPM_AES_SYNC_CHECK("AES Lock Status", 0),*/ /* created in snd_hdspm_create_controls() */ + HDSPM_LINE_OUT("Line Out", 0), + HDSPM_EMPHASIS("Emphasis", 0), + HDSPM_DOLBY("Non Audio", 0), + HDSPM_PROFESSIONAL("Professional", 0), + HDSPM_C_TMS("Clear Track Marker", 0), + HDSPM_DS_WIRE("Double Speed Wire Mode", 0), + HDSPM_QS_WIRE("Quad Speed Wire Mode", 0), +}; + static struct snd_kcontrol_new snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER; @@ -2245,20 +2874,40 @@ static int snd_hdspm_create_controls(str struct snd_kcontrol *kctl; /* add control list first */ - - for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls); idx++) { - if ((err = - snd_ctl_add(card, kctl = - snd_ctl_new1(&snd_hdspm_controls[idx], - hdspm))) < 0) { - return err; + if (hdspm->is_aes32) { + struct snd_kcontrol_new aes_sync_ctl = + HDSPM_AES_SYNC_CHECK("AES Lock Status", 0); + + for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls_aes32); + idx++) { + err = snd_ctl_add(card, + snd_ctl_new1(&snd_hdspm_controls_aes32[idx], + hdspm)); + if (err < 0) + return err; + } + for (idx = 1; idx <= 8; idx++) { + aes_sync_ctl.index = idx; + err = snd_ctl_add(card, + snd_ctl_new1(&aes_sync_ctl, hdspm)); + if (err < 0) + return err; + } + } else { + for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls_madi); + idx++) { + err = snd_ctl_add(card, + snd_ctl_new1(&snd_hdspm_controls_madi[idx], + hdspm)); + if (err < 0) + return err; } } /* Channel playback mixer as default control - Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats too big for any alsamixer - they are accesible via special IOCTL on hwdep - and the mixer 2dimensional mixer control */ +Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats too big for any alsamixer +they are accesible via special IOCTL on hwdep +and the mixer 2dimensional mixer control */ snd_hdspm_playback_mixer.name = "Chn"; limit = HDSPM_MAX_CHANNELS; @@ -2289,7 +2938,8 @@ static int snd_hdspm_create_controls(str ------------------------------------------------------------*/ static void -snd_hdspm_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) +snd_hdspm_proc_read_madi(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) { struct hdspm *hdspm = (struct hdspm *) entry->private_data; unsigned int status; @@ -2420,11 +3070,10 @@ snd_hdspm_proc_read(struct snd_info_entr clock_source = "Error"; } snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source); - if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { + if (!(hdspm->control_register & HDSPM_ClockModeMaster)) system_clock_mode = "Slave"; - } else { + else system_clock_mode = "Master"; - } snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode); switch (hdspm_pref_sync_ref(hdspm)) { @@ -2484,13 +3133,213 @@ snd_hdspm_proc_read(struct snd_info_entr snd_iprintf(buffer, "\n"); } +static void +snd_hdspm_proc_read_aes32(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) +{ + struct hdspm *hdspm = (struct hdspm *) entry->private_data; + unsigned int status; + unsigned int status2; + unsigned int timecode; + int pref_syncref; + char *autosync_ref; + char *system_clock_mode; + char *clock_source; + int x; + + status = hdspm_read(hdspm, HDSPM_statusRegister); + status2 = hdspm_read(hdspm, HDSPM_statusRegister2); + timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); + + snd_iprintf(buffer, "%s (Card #%d) Rev.%x\n", + hdspm->card_name, hdspm->card->number + 1, + hdspm->firmware_rev); + + snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", + hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); + + snd_iprintf(buffer, "--- System ---\n"); + + snd_iprintf(buffer, + "IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n", + status & HDSPM_audioIRQPending, + (status & HDSPM_midi0IRQPending) ? 1 : 0, + (status & HDSPM_midi1IRQPending) ? 1 : 0, + hdspm->irq_count); + snd_iprintf(buffer, + "HW pointer: id = %d, rawptr = %d (%d->%d) estimated= %ld (bytes)\n", + ((status & HDSPM_BufferID) ? 1 : 0), + (status & HDSPM_BufferPositionMask), + (status & HDSPM_BufferPositionMask) % (2 * + (int)hdspm-> + period_bytes), + ((status & HDSPM_BufferPositionMask) - + 64) % (2 * (int)hdspm->period_bytes), + (long) hdspm_hw_pointer(hdspm) * 4); + + snd_iprintf(buffer, + "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", + hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, + hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, + hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, + hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); + snd_iprintf(buffer, + "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n", + hdspm->control_register, hdspm->control2_register, + status, status2, timecode); + + snd_iprintf(buffer, "--- Settings ---\n"); + + x = 1 << (6 + + hdspm_decode_latency(hdspm-> + control_register & + HDSPM_LatencyMask)); + + snd_iprintf(buffer, + "Size (Latency): %d samples (2 periods of %lu bytes)\n", + x, (unsigned long) hdspm->period_bytes); + + snd_iprintf(buffer, "Line out: %s, Precise Pointer: %s\n", + (hdspm-> + control_register & HDSPM_LineOut) ? "on " : "off", + (hdspm->precise_ptr) ? "on" : "off"); + + snd_iprintf(buffer, + "ClearTrackMarker %s, Emphasis %s, Dolby %s\n", + (hdspm-> + control_register & HDSPM_clr_tms) ? "on" : "off", + (hdspm-> + control_register & HDSPM_Emphasis) ? "on" : "off", + (hdspm-> + control_register & HDSPM_Dolby) ? "on" : "off"); + + switch (hdspm_clock_source(hdspm)) { + case HDSPM_CLOCK_SOURCE_AUTOSYNC: + clock_source = "AutoSync"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ: + clock_source = "Internal 32 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ: + clock_source = "Internal 44.1 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ: + clock_source = "Internal 48 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ: + clock_source = "Internal 64 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ: + clock_source = "Internal 88.2 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ: + clock_source = "Internal 96 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ: + clock_source = "Internal 128 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ: + clock_source = "Internal 176.4 kHz"; + break; + case HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ: + clock_source = "Internal 192 kHz"; + break; + default: + clock_source = "Error"; + } + snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source); + if (!(hdspm->control_register & HDSPM_ClockModeMaster)) + system_clock_mode = "Slave"; + else + system_clock_mode = "Master"; + snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode); + + pref_syncref = hdspm_pref_sync_ref(hdspm); + if (pref_syncref == 0) + snd_iprintf(buffer, "Preferred Sync Reference: Word Clock\n"); + else + snd_iprintf(buffer, "Preferred Sync Reference: AES%d\n", + pref_syncref); + + snd_iprintf(buffer, "System Clock Frequency: %d\n", + hdspm->system_sample_rate); + + snd_iprintf(buffer, "Double speed: %s\n", + hdspm->control_register & HDSPM_DS_DoubleWire? + "Double wire" : "Single wire"); + snd_iprintf(buffer, "Quad speed: %s\n", + hdspm->control_register & HDSPM_QS_DoubleWire? + "Double wire" : + hdspm->control_register & HDSPM_QS_QuadWire? + "Quad wire" : "Single wire"); + + snd_iprintf(buffer, "--- Status:\n"); + + snd_iprintf(buffer, "Word: %s Frequency: %d\n", + (status & HDSPM_AES32_wcLock)? "Sync " : "No Lock", + HDSPM_bit2freq((status >> HDSPM_AES32_wcFreq_bit) & 0xF)); + + for (x = 0; x < 8; x++) { + snd_iprintf(buffer, "AES%d: %s Frequency: %d\n", + x+1, + (status2 & (HDSPM_LockAES >> x))? "Sync ": "No Lock", + HDSPM_bit2freq((timecode >> (4*x)) & 0xF)); + } + + switch (hdspm_autosync_ref(hdspm)) { + case HDSPM_AES32_AUTOSYNC_FROM_NONE: autosync_ref="None"; break; + case HDSPM_AES32_AUTOSYNC_FROM_WORD: autosync_ref="Word Clock"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES1: autosync_ref="AES1"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES2: autosync_ref="AES2"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES3: autosync_ref="AES3"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES4: autosync_ref="AES4"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES5: autosync_ref="AES5"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES6: autosync_ref="AES6"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES7: autosync_ref="AES7"; break; + case HDSPM_AES32_AUTOSYNC_FROM_AES8: autosync_ref="AES8"; break; + default: autosync_ref = "---"; break; + } + snd_iprintf(buffer, "AutoSync ref = %s\n", autosync_ref); + + snd_iprintf(buffer, "\n"); +} + +#ifdef CONFIG_SND_DEBUG +static void +snd_hdspm_proc_read_debug(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) +{ + struct hdspm *hdspm = (struct hdspm *)entry->private_data; + + int j,i; + + for (i = 0; i < 256 /* 1024*64 */; i += j) + { + snd_iprintf(buffer, "0x%08X: ", i); + for (j = 0; j < 16; j += 4) + snd_iprintf(buffer, "%08X ", hdspm_read(hdspm, i + j)); + snd_iprintf(buffer, "\n"); + } +} +#endif + + + static void __devinit snd_hdspm_proc_init(struct hdspm * hdspm) { struct snd_info_entry *entry; if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) snd_info_set_text_ops(entry, hdspm, - snd_hdspm_proc_read); + hdspm->is_aes32 ? + snd_hdspm_proc_read_aes32 : + snd_hdspm_proc_read_madi); +#ifdef CONFIG_SND_DEBUG + /* debug file to read all hdspm registers */ + if (!snd_card_proc_new(hdspm->card, "debug", &entry)) + snd_info_set_text_ops(entry, hdspm, + snd_hdspm_proc_read_debug); +#endif } /*------------------------------------------------------------ @@ -2507,13 +3356,20 @@ static int snd_hdspm_set_defaults(struct /* set defaults: */ - hdspm->control_register = HDSPM_ClockModeMaster | /* Master Cloack Mode on */ - hdspm_encode_latency(7) | /* latency maximum = 8192 samples */ - HDSPM_InputCoaxial | /* Input Coax not Optical */ - HDSPM_SyncRef_MADI | /* Madi is syncclock */ - HDSPM_LineOut | /* Analog output in */ - HDSPM_TX_64ch | /* transmit in 64ch mode */ - HDSPM_AutoInp; /* AutoInput chossing (takeover) */ + if (hdspm->is_aes32) + hdspm->control_register = HDSPM_ClockModeMaster | /* Master Cloack Mode on */ + hdspm_encode_latency(7) | /* latency maximum = 8192 samples */ + HDSPM_SyncRef0 | /* AES1 is syncclock */ + HDSPM_LineOut | /* Analog output in */ + HDSPM_Professional; /* Professional mode */ + else + hdspm->control_register = HDSPM_ClockModeMaster | /* Master Cloack Mode on */ + hdspm_encode_latency(7) | /* latency maximum = 8192 samples */ + HDSPM_InputCoaxial | /* Input Coax not Optical */ + HDSPM_SyncRef_MADI | /* Madi is syncclock */ + HDSPM_LineOut | /* Analog output in */ + HDSPM_TX_64ch | /* transmit in 64ch mode */ + HDSPM_AutoInp; /* AutoInput chossing (takeover) */ /* ! HDSPM_Frequency0|HDSPM_Frequency1 = 44.1khz */ /* ! HDSPM_DoubleSpeed HDSPM_QuadSpeed = normal speed */ @@ -2822,6 +3678,8 @@ static int snd_hdspm_hw_params(struct sn hdspm->playback_buffer = (unsigned char *) substream->runtime->dma_area; + snd_printdd("Allocated sample buffer for playback at %p\n", + hdspm->playback_buffer); } else { hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferIn, params_channels(params)); @@ -2831,7 +3689,15 @@ static int snd_hdspm_hw_params(struct sn hdspm->capture_buffer = (unsigned char *) substream->runtime->dma_area; + snd_printdd("Allocated sample buffer for capture at %p\n", + hdspm->capture_buffer); } + /* + snd_printdd("Allocated sample buffer for %s at 0x%08X\n", + substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? + "playback" : "capture", + snd_pcm_sgbuf_get_addr(sgbuf, 0)); + */ return 0; } @@ -2982,9 +3848,10 @@ static struct snd_pcm_hardware snd_hdspm SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000), + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 ), .rate_min = 32000, - .rate_max = 96000, + .rate_max = 192000, .channels_min = 1, .channels_max = HDSPM_MAX_CHANNELS, .buffer_bytes_max = @@ -3006,9 +3873,10 @@ static struct snd_pcm_hardware snd_hdspm SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000), + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000), .rate_min = 32000, - .rate_max = 96000, + .rate_max = 192000, .channels_min = 1, .channels_max = HDSPM_MAX_CHANNELS, .buffer_bytes_max = @@ -3315,7 +4183,8 @@ static int __devinit snd_hdspm_prealloca pcm = hdspm->pcm; - wanted = HDSPM_DMA_AREA_BYTES + 4096; /* dont know why, but it works */ +/* wanted = HDSPM_DMA_AREA_BYTES + 4096;*/ /* dont know why, but it works */ + wanted = HDSPM_DMA_AREA_BYTES; if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, @@ -3467,9 +4336,16 @@ static int __devinit snd_hdspm_create(st pci_read_config_word(hdspm->pci, PCI_CLASS_REVISION, &hdspm->firmware_rev); - strcpy(card->driver, "HDSPM"); + hdspm->is_aes32 = (hdspm->firmware_rev >= HDSPM_AESREVISION); + strcpy(card->mixername, "Xilinx FPGA"); - hdspm->card_name = "RME HDSPM MADI"; + if (hdspm->is_aes32) { + strcpy(card->driver, "HDSPAES32"); + hdspm->card_name = "RME HDSPM AES32"; + } else { + strcpy(card->driver, "HDSPM"); + hdspm->card_name = "RME HDSPM MADI"; + } if ((err = pci_enable_device(pci)) < 0) return err; diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index a572b01..22caf5d 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1823,7 +1823,7 @@ static int __devinit snd_via82xx_mixer_n ac97.private_data = chip; ac97.private_free = snd_via82xx_mixer_free_ac97; ac97.pci = chip->pci; - ac97.scaps = AC97_SCAP_SKIP_MODEM; + ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) return err; @@ -2357,93 +2357,59 @@ static struct via823x_info via823x_cards /* * auto detection of DXS channel supports. */ -struct dxs_whitelist { - unsigned short subvendor; - unsigned short subdevice; - unsigned short mask; - short action; /* new dxs_support value */ + +static struct snd_pci_quirk dxs_whitelist[] __devinitdata = { + SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), + SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x1019, 0, "ESC K8", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1043, 0, "ASUS A7/A8", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x1071, 0, "Diverse Notebook", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1106, 0, "ASRock", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1297, 0xc160, "Shuttle Sk41G", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte GA-7VAXP", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1462, 0x3800, "MSI KT266", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1462, 0, "MSI Mobo", VIA_DXS_SRC), + SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x147b, 0x1413, "ABIT KV8 Pro", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x147b, 0x1415, "ABIT AV8", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x14ff, 0x0403, "Twinhead mobo", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x14ff, 0x0408, "Twinhead laptop", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1558, 0x4701, "Clevo D470", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1584, 0x8120, "Diverse Laptop", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1584, 0x8123, "Targa/Uniwill", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x161f, 0x202b, "Amira Notebook", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x161f, 0x2032, "m680x machines", VIA_DXS_48K), + SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE), + SND_PCI_QUIRK(0x1695, 0, "EPoX mobo", VIA_DXS_SRC), + SND_PCI_QUIRK(0x16f3, 0, "Jetway K8", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1734, 0, "FSC Laptop", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x1849, 0, "ASRock mobo", VIA_DXS_SRC), + SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8", VIA_DXS_NO_VRA), + SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC), + { } /* terminator */ }; static int __devinit check_dxs_list(struct pci_dev *pci, int revision) { - static struct dxs_whitelist whitelist[] __devinitdata = { - { .subvendor = 0x1005, .subdevice = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */ - { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K }, - { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */ - { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */ - { .subvendor = 0x1019, .subdevice = 0xa101, .action = VIA_DXS_SRC }, - { .subvendor = 0x1019, .subdevice = 0xaa01, .action = VIA_DXS_SRC }, /* ECS K8T890-A */ - { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */ - { .subvendor = 0x1025, .subdevice = 0x0046, .action = VIA_DXS_SRC }, /* Acer Aspire 1524 WLMi */ - { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ - { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ - { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ - { .subvendor = 0x1043, .subdevice = 0x810d, .action = VIA_DXS_SRC }, /* ASUS */ - { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */ - { .subvendor = 0x1043, .subdevice = 0x8174, .action = VIA_DXS_SRC }, /* ASUS */ - { .subvendor = 0x1043, .subdevice = 0x81b9, .action = VIA_DXS_SRC }, /* ASUS A8V-MX */ - { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ - { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */ - { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ - { .subvendor = 0x1106, .subdevice = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */ - { .subvendor = 0x1106, .subdevice = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */ - { .subvendor = 0x1106, .subdevice = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */ - { .subvendor = 0x1106, .subdevice = 0xc001, .action = VIA_DXS_SRC }, /* Insight P4-ITX */ - { .subvendor = 0x1297, .subdevice = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */ - { .subvendor = 0x1297, .subdevice = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */ - { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */ - { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */ - { .subvendor = 0x1462, .subdevice = 0x0430, .action = VIA_DXS_SRC }, /* MSI 7142 (K8MM-V) */ - { .subvendor = 0x1462, .subdevice = 0x0470, .action = VIA_DXS_SRC }, /* MSI KT880 Delta-FSR */ - { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */ - { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */ - { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_SRC }, /* MSI K8T Neo2-FI */ - { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ - { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */ - { .subvendor = 0x1462, .subdevice = 0xb012, .action = VIA_DXS_SRC }, /* P4M800/VIA8237R */ - { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ - { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ - { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ - { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */ - { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */ - { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_SRC }, /* Twinhead laptop */ - { .subvendor = 0x1558, .subdevice = 0x4701, .action = VIA_DXS_SRC }, /* Clevo D470 */ - { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */ - { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */ - { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */ - { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ - { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ - { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ - { .subvendor = 0x1695, .subdevice = 0x300c, .action = VIA_DXS_SRC }, /* EPoX EP-8KRAI */ - { .subvendor = 0x1695, .subdevice = 0x300e, .action = VIA_DXS_SRC }, /* EPoX 9HEAI */ - { .subvendor = 0x16f3, .subdevice = 0x6405, .action = VIA_DXS_SRC }, /* Jetway K8M8MS */ - { .subvendor = 0x1734, .subdevice = 0x1078, .action = VIA_DXS_SRC }, /* FSC Amilo L7300 */ - { .subvendor = 0x1734, .subdevice = 0x1093, .action = VIA_DXS_SRC }, /* FSC */ - { .subvendor = 0x1734, .subdevice = 0x10ab, .action = VIA_DXS_SRC }, /* FSC */ - { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ - { .subvendor = 0x1849, .subdevice = 0x9739, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ - { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ - { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ - { .subvendor = 0x4005, .subdevice = 0x4710, .action = VIA_DXS_SRC }, /* MSI K7T266 Pro2 (MS-6380 V2.0) BIOS 3.7 */ - { } /* terminator */ - }; - const struct dxs_whitelist *w; - unsigned short subsystem_vendor; - unsigned short subsystem_device; - - pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); - pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); + const struct snd_pci_quirk *w; - for (w = whitelist; w->subvendor; w++) { - if (w->subvendor != subsystem_vendor) - continue; - if (w->mask) { - if ((w->mask & subsystem_device) == w->subdevice) - return w->action; - } else { - if (subsystem_device == w->subdevice) - return w->action; - } + w = snd_pci_quirk_lookup(pci, dxs_whitelist); + if (w) { + snd_printdd(KERN_INFO "via82xx: DXS white list for %s found\n", + w->name); + return w->value; } /* for newer revision, default to DXS_SRC */ diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 17d6b84..b338e15 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -900,7 +900,7 @@ static int __devinit snd_via82xx_mixer_n ac97.private_data = chip; ac97.private_free = snd_via82xx_mixer_free_ac97; ac97.pci = chip->pci; - ac97.scaps = AC97_SCAP_SKIP_AUDIO; + ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; ac97.num = chip->ac97_secondary; if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) diff --git a/sound/pci/ymfpci/ymfpci_image.h b/sound/pci/ymfpci/ymfpci_image.h index 1b07469..112f2ff 100644 --- a/sound/pci/ymfpci/ymfpci_image.h +++ b/sound/pci/ymfpci/ymfpci_image.h @@ -1,7 +1,7 @@ #ifndef _HWMCODE_ #define _HWMCODE_ -static unsigned long DspInst[YDSXG_DSPLENGTH / 4] = { +static u32 DspInst[YDSXG_DSPLENGTH / 4] = { 0x00000081, 0x000001a4, 0x0000000a, 0x0000002f, 0x00080253, 0x01800317, 0x0000407b, 0x0000843f, 0x0001483c, 0x0001943c, 0x0005d83c, 0x00001c3c, @@ -12,7 +12,7 @@ static unsigned long DspInst[YDSXG_DSPLE 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; -static unsigned long CntrlInst[YDSXG_CTRLLENGTH / 4] = { +static u32 CntrlInst[YDSXG_CTRLLENGTH / 4] = { 0x000007, 0x240007, 0x0C0007, 0x1C0007, 0x060007, 0x700002, 0x000020, 0x030040, 0x007104, 0x004286, 0x030040, 0x000F0D, @@ -791,7 +791,7 @@ static unsigned long CntrlInst[YDSXG_CTR // 04/09 creat // 04/12 stop nise fix // 06/21 WorkingOff timming -static unsigned long CntrlInst1E[YDSXG_CTRLLENGTH / 4] = { +static u32 CntrlInst1E[YDSXG_CTRLLENGTH / 4] = { 0x000007, 0x240007, 0x0C0007, 0x1C0007, 0x060007, 0x700002, 0x000020, 0x030040, 0x007104, 0x004286, 0x030040, 0x000F0D, diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 7881944..8b07693 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2,12 +2,6 @@ * Copyright (c) by Jaroslav Kysela * Routines for control of YMF724/740/744/754 chips * - * BUGS: - * -- - * - * TODO: - * -- - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -26,6 +20,7 @@ #include #include +#include #include #include #include @@ -42,10 +37,7 @@ #include #include #include - -/* - * constants - */ +#include /* * common I/O routines @@ -179,6 +171,17 @@ static u32 snd_ymfpci_calc_lpfQ(u32 rate return val[0]; } +static void snd_ymfpci_pcm_441_volume_set(struct snd_ymfpci_pcm *ypcm) +{ + unsigned int value; + struct snd_ymfpci_pcm_mixer *mixer; + + mixer = &ypcm->chip->pcm_mixer[ypcm->substream->number]; + value = min_t(unsigned int, mixer->left, 0x7fff) >> 1; + value |= (min_t(unsigned int, mixer->right, 0x7fff) >> 1) << 16; + snd_ymfpci_writel(ypcm->chip, YDSXGR_BUF441OUTVOL, value); +} + /* * Hardware start management */ @@ -290,6 +293,10 @@ static int snd_ymfpci_voice_free(struct snd_assert(pvoice != NULL, return -EINVAL); snd_ymfpci_hw_stop(chip); spin_lock_irqsave(&chip->voice_lock, flags); + if (pvoice->number == chip->src441_used) { + chip->src441_used = -1; + pvoice->ypcm->use_441_slot = 0; + } pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = 0; pvoice->ypcm = NULL; pvoice->interrupt = NULL; @@ -394,7 +401,7 @@ static int snd_ymfpci_playback_trigger(s case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: chip->ctrl_playback[ypcm->voices[0]->number + 1] = cpu_to_le32(ypcm->voices[0]->bank_addr); - if (ypcm->voices[1] != NULL) + if (ypcm->voices[1] != NULL && !ypcm->use_441_slot) chip->ctrl_playback[ypcm->voices[1]->number + 1] = cpu_to_le32(ypcm->voices[1]->bank_addr); ypcm->running = 1; break; @@ -402,7 +409,7 @@ static int snd_ymfpci_playback_trigger(s case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; - if (ypcm->voices[1] != NULL) + if (ypcm->voices[1] != NULL && !ypcm->use_441_slot) chip->ctrl_playback[ypcm->voices[1]->number + 1] = 0; ypcm->running = 0; break; @@ -489,6 +496,7 @@ static void snd_ymfpci_pcm_init_voice(st unsigned int nbank; u32 vol_left, vol_right; u8 use_left, use_right; + unsigned long flags; snd_assert(voice != NULL, return); if (runtime->channels == 1) { @@ -507,11 +515,27 @@ static void snd_ymfpci_pcm_init_voice(st vol_left = cpu_to_le32(0x40000000); vol_right = cpu_to_le32(0x40000000); } + spin_lock_irqsave(&ypcm->chip->voice_lock, flags); format = runtime->channels == 2 ? 0x00010000 : 0; if (snd_pcm_format_width(runtime->format) == 8) format |= 0x80000000; + else if (ypcm->chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && + runtime->rate == 44100 && runtime->channels == 2 && + voiceidx == 0 && (ypcm->chip->src441_used == -1 || + ypcm->chip->src441_used == voice->number)) { + ypcm->chip->src441_used = voice->number; + ypcm->use_441_slot = 1; + format |= 0x10000000; + snd_ymfpci_pcm_441_volume_set(ypcm); + } + if (ypcm->chip->src441_used == voice->number && + (format & 0x10000000) == 0) { + ypcm->chip->src441_used = -1; + ypcm->use_441_slot = 0; + } if (runtime->channels == 2 && (voiceidx & 1) != 0) format |= 1; + spin_unlock_irqrestore(&ypcm->chip->voice_lock, flags); for (nbank = 0; nbank < 2; nbank++) { bank = &voice->bank[nbank]; memset(bank, 0, sizeof(*bank)); @@ -1722,7 +1746,10 @@ static int snd_ymfpci_pcm_vol_put(struct spin_lock_irqsave(&chip->voice_lock, flags); if (substream->runtime && substream->runtime->private_data) { struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data; - ypcm->update_pcm_vol = 2; + if (!ypcm->use_441_slot) + ypcm->update_pcm_vol = 2; + else + snd_ymfpci_pcm_441_volume_set(ypcm); } spin_unlock_irqrestore(&chip->voice_lock, flags); return 1; @@ -1971,13 +1998,94 @@ static void snd_ymfpci_disable_dsp(struc } } +#define FIRMWARE_IN_THE_KERNEL + +#ifdef FIRMWARE_IN_THE_KERNEL + #include "ymfpci_image.h" +static struct firmware snd_ymfpci_dsp_microcode = { + .size = YDSXG_DSPLENGTH, + .data = (u8 *)DspInst, +}; +static struct firmware snd_ymfpci_controller_microcode = { + .size = YDSXG_CTRLLENGTH, + .data = (u8 *)CntrlInst, +}; +static struct firmware snd_ymfpci_controller_1e_microcode = { + .size = YDSXG_CTRLLENGTH, + .data = (u8 *)CntrlInst1E, +}; +#endif + +#ifdef __LITTLE_ENDIAN +static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { } +#else +static void snd_ymfpci_convert_from_le(const struct firmware *fw) +{ + int i; + u32 *data = (u32 *)fw->data; + + for (i = 0; i < fw->size / 4; ++i) + le32_to_cpus(&data[i]); +} +#endif + +static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) +{ + int err, is_1e; + const char *name; + + err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw", + &chip->pci->dev); + if (err >= 0) { + if (chip->dsp_microcode->size == YDSXG_DSPLENGTH) + snd_ymfpci_convert_from_le(chip->dsp_microcode); + else { + snd_printk(KERN_ERR "DSP microcode has wrong size\n"); + err = -EINVAL; + } + } + if (err < 0) { +#ifdef FIRMWARE_IN_THE_KERNEL + chip->dsp_microcode = &snd_ymfpci_dsp_microcode; +#else + return err; +#endif + } + is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || + chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || + chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || + chip->device_id == PCI_DEVICE_ID_YAMAHA_754; + name = is_1e ? "yamaha/ds1e_ctrl.fw" : "yamaha/ds1_ctrl.fw"; + err = request_firmware(&chip->controller_microcode, name, + &chip->pci->dev); + if (err >= 0) { + if (chip->controller_microcode->size == YDSXG_CTRLLENGTH) + snd_ymfpci_convert_from_le(chip->controller_microcode); + else { + snd_printk(KERN_ERR "controller microcode" + " has wrong size\n"); + err = -EINVAL; + } + } + if (err < 0) { +#ifdef FIRMWARE_IN_THE_KERNEL + chip->controller_microcode = + is_1e ? &snd_ymfpci_controller_1e_microcode + : &snd_ymfpci_controller_microcode; +#else + return err; +#endif + } + return 0; +} + static void snd_ymfpci_download_image(struct snd_ymfpci *chip) { int i; u16 ctrl; - unsigned long *inst; + u32 *inst; snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000); snd_ymfpci_disable_dsp(chip); @@ -1992,21 +2100,12 @@ static void snd_ymfpci_download_image(st snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); /* setup DSP instruction code */ + inst = (u32 *)chip->dsp_microcode->data; for (i = 0; i < YDSXG_DSPLENGTH / 4; i++) - snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), DspInst[i]); + snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), inst[i]); /* setup control instruction code */ - switch (chip->device_id) { - case PCI_DEVICE_ID_YAMAHA_724F: - case PCI_DEVICE_ID_YAMAHA_740C: - case PCI_DEVICE_ID_YAMAHA_744: - case PCI_DEVICE_ID_YAMAHA_754: - inst = CntrlInst1E; - break; - default: - inst = CntrlInst; - break; - } + inst = (u32 *)chip->controller_microcode->data; for (i = 0; i < YDSXG_CTRLLENGTH / 4; i++) snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), inst[i]); @@ -2160,6 +2259,15 @@ #endif pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); pci_disable_device(chip->pci); +#ifdef FIRMWARE_IN_THE_KERNEL + if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode) +#endif + release_firmware(chip->dsp_microcode); +#ifdef FIRMWARE_IN_THE_KERNEL + if (chip->controller_microcode != &snd_ymfpci_controller_microcode && + chip->controller_microcode != &snd_ymfpci_controller_1e_microcode) +#endif + release_firmware(chip->controller_microcode); kfree(chip); return 0; } @@ -2180,7 +2288,7 @@ static int saved_regs_index[] = { YDSXGR_PRIADCLOOPVOL, YDSXGR_NATIVEDACINVOL, YDSXGR_NATIVEDACOUTVOL, - // YDSXGR_BUF441OUTVOL, + YDSXGR_BUF441OUTVOL, YDSXGR_NATIVEADCINVOL, YDSXGR_SPDIFLOOPVOL, YDSXGR_SPDIFOUTVOL, @@ -2295,6 +2403,7 @@ int __devinit snd_ymfpci_create(struct s chip->reg_area_phys = pci_resource_start(pci, 0); chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000); pci_set_master(pci); + chip->src441_used = -1; if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); @@ -2315,6 +2424,12 @@ int __devinit snd_ymfpci_create(struct s return -EIO; } + err = snd_ymfpci_request_firmware(chip); + if (err < 0) { + snd_printk(KERN_ERR "firmware request failed: %d\n", err); + snd_ymfpci_free(chip); + return err; + } snd_ymfpci_download_image(chip); udelay(100); /* seems we need a delay after downloading image.. */ diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig new file mode 100644 index 0000000..ec821a5 --- /dev/null +++ b/sound/soc/Kconfig @@ -0,0 +1,32 @@ +# +# SoC audio configuration +# + +menu "SoC audio support" + depends on SND!=n + +config SND_SOC_AC97_BUS + bool + +config SND_SOC + tristate "SoC audio support" + ---help--- + + If you want SoC support, you should say Y here and also to the + specific driver for your SoC below. You will also need to select the + specific codec(s) attached to the SoC + + This SoC audio support can also be built as a module. If so, the module + will be called snd-soc-core. + +# All the supported Soc's +menu "SoC Platforms" +depends on SND_SOC +source "sound/soc/at91/Kconfig" +source "sound/soc/pxa/Kconfig" +endmenu + +# Supported codecs +source "sound/soc/codecs/Kconfig" + +endmenu diff --git a/sound/soc/Makefile b/sound/soc/Makefile new file mode 100644 index 0000000..98e6f49 --- /dev/null +++ b/sound/soc/Makefile @@ -0,0 +1,4 @@ +snd-soc-core-objs := soc-core.o soc-dapm.o + +obj-$(CONFIG_SND_SOC) += snd-soc-core.o +obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ diff --git a/sound/soc/at91/Kconfig b/sound/soc/at91/Kconfig new file mode 100644 index 0000000..d38ba92 --- /dev/null +++ b/sound/soc/at91/Kconfig @@ -0,0 +1,24 @@ +menu "SoC Audio for the Atmel AT91" + +config SND_AT91_SOC + tristate "SoC Audio for the Atmel AT91 System-on-Chip" + depends on ARCH_AT91 && SND + select SND_PCM + help + Say Y or M if you want to add support for codecs attached to + the AT91 SSC interface. You will also need + to select the audio interfaces to support below. + +config SND_AT91_SOC_I2S + tristate + +config SND_AT91_SOC_ETI_B1_WM8731 + tristate "SoC I2S Audio support for Endrelia ETI-B1 board" + depends on SND_AT91_SOC && MACH_ETI_B1 + select SND_AT91_SOC_I2S + select SND_SOC_WM8731 + help + Say Y if you want to add support for SoC audio on Endrelia + ETI-B1 board. + +endmenu diff --git a/sound/soc/at91/Makefile b/sound/soc/at91/Makefile new file mode 100644 index 0000000..b77b01a --- /dev/null +++ b/sound/soc/at91/Makefile @@ -0,0 +1,11 @@ +# AT91 Platform Support +snd-soc-at91-objs := at91-pcm.o +snd-soc-at91-i2s-objs := at91-i2s.o + +obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o +obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o + +# AT91 Machine Support +snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o + +obj-$(CONFIG_SND_AT91_SOC_ETI_B1_WM8731) += snd-soc-eti-b1-wm8731.o diff --git a/sound/soc/at91/at91-i2s.c b/sound/soc/at91/at91-i2s.c new file mode 100644 index 0000000..b452e8e --- /dev/null +++ b/sound/soc/at91/at91-i2s.c @@ -0,0 +1,673 @@ +/* + * at91-i2s.c -- ALSA SoC I2S Audio Layer Platform driver + * + * Author: Frank Mandarino + * Endrelia Technologies Inc. + * + * Based on pxa2xx Platform drivers by + * Liam Girdwood + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 3rd Mar 2006 Initial version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "at91-pcm.h" + +#if 0 +#define DBG(x...) printk(KERN_DEBUG "at91-i2s:" x) +#else +#define DBG(x...) +#endif + +#if defined(CONFIG_ARCH_AT91SAM9260) +#define NUM_SSC_DEVICES 1 +#else +#define NUM_SSC_DEVICES 3 +#endif + + +#define AT91_I2S_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_NB_NF) + +#define AT91_I2S_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +/* priv is (SSC_CMR.DIV << 16 | SSC_TCMR.PERIOD ) */ +static struct snd_soc_dai_mode at91_i2s[] = { + + /* 8k: BCLK = (MCLK/10) = (60MHz/50) = 1.2MHz */ + { + .fmt = AT91_I2S_DAIFMT, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = AT91_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1500, + .bfs = SND_SOC_FSBD(10), + .priv = (25 << 16 | 74), + }, + + /* 16k: BCLK = (MCLK/3) ~= (60MHz/14) = 4.285714MHz */ + { + .fmt = AT91_I2S_DAIFMT, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = AT91_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 750, + .bfs = SND_SOC_FSBD(3), + .priv = (7 << 16 | 133), + }, + + /* 32k: BCLK = (MCLK/3) ~= (60MHz/14) = 4.285714MHz */ + { + .fmt = AT91_I2S_DAIFMT, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = AT91_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 375, + .bfs = SND_SOC_FSBD(3), + .priv = (7 << 16 | 66), + }, + + /* 48k: BCLK = (MCLK/5) ~= (60MHz/26) = 2.3076923MHz */ + { + .fmt = AT91_I2S_DAIFMT, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = AT91_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 250, + .bfs SND_SOC_FSBD(5), + .priv = (13 << 16 | 23), + }, +}; + + +/* + * SSC PDC registers required by the PCM DMA engine. + */ +static struct at91_pdc_regs pdc_tx_reg = { + .xpr = AT91_PDC_TPR, + .xcr = AT91_PDC_TCR, + .xnpr = AT91_PDC_TNPR, + .xncr = AT91_PDC_TNCR, +}; + +static struct at91_pdc_regs pdc_rx_reg = { + .xpr = AT91_PDC_RPR, + .xcr = AT91_PDC_RCR, + .xnpr = AT91_PDC_RNPR, + .xncr = AT91_PDC_RNCR, +}; + +/* + * SSC & PDC status bits for transmit and receive. + */ +static struct at91_ssc_mask ssc_tx_mask = { + .ssc_enable = AT91_SSC_TXEN, + .ssc_disable = AT91_SSC_TXDIS, + .ssc_endx = AT91_SSC_ENDTX, + .ssc_endbuf = AT91_SSC_TXBUFE, + .pdc_enable = AT91_PDC_TXTEN, + .pdc_disable = AT91_PDC_TXTDIS, +}; + +static struct at91_ssc_mask ssc_rx_mask = { + .ssc_enable = AT91_SSC_RXEN, + .ssc_disable = AT91_SSC_RXDIS, + .ssc_endx = AT91_SSC_ENDRX, + .ssc_endbuf = AT91_SSC_RXBUFF, + .pdc_enable = AT91_PDC_RXTEN, + .pdc_disable = AT91_PDC_RXTDIS, +}; + + +/* + * DMA parameters. + */ +static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = { + {{ + .name = "SSC0/I2S PCM Stereo out", + .pdc = &pdc_tx_reg, + .mask = &ssc_tx_mask, + }, + { + .name = "SSC0/I2S PCM Stereo in", + .pdc = &pdc_rx_reg, + .mask = &ssc_rx_mask, + }}, +#if NUM_SSC_DEVICES == 3 + {{ + .name = "SSC1/I2S PCM Stereo out", + .pdc = &pdc_tx_reg, + .mask = &ssc_tx_mask, + }, + { + .name = "SSC1/I2S PCM Stereo in", + .pdc = &pdc_rx_reg, + .mask = &ssc_rx_mask, + }}, + {{ + .name = "SSC2/I2S PCM Stereo out", + .pdc = &pdc_tx_reg, + .mask = &ssc_tx_mask, + }, + { + .name = "SSC1/I2S PCM Stereo in", + .pdc = &pdc_rx_reg, + .mask = &ssc_rx_mask, + }}, +#endif +}; + + +/* + * A MUTEX is used to protect an SSC initialzed flag which allows + * the substream hw_params() call to initialize the SSC only if + * there are no other substreams open. If there are other + * substreams open, the hw_param() call can only check that + * it is using the same format and rate. + */ +static DECLARE_MUTEX(ssc0_mutex); +#if NUM_SSC_DEVICES == 3 +static DECLARE_MUTEX(ssc1_mutex); +static DECLARE_MUTEX(ssc2_mutex); +#endif + + +struct at91_ssc_state { + u32 ssc_cmr; + u32 ssc_rcmr; + u32 ssc_rfmr; + u32 ssc_tcmr; + u32 ssc_tfmr; + u32 ssc_sr; + u32 ssc_imr; +}; + + +static struct at91_ssc_info { + char *name; + struct at91_ssc_periph ssc; + spinlock_t lock; /* lock for dir_mask */ + int dir_mask; /* 0=unused, 1=playback, 2=capture */ + struct semaphore *mutex; + int initialized; + int pcmfmt; + int rate; + struct at91_pcm_dma_params *dma_params[2]; + struct at91_ssc_state ssc_state; + +} ssc_info[NUM_SSC_DEVICES] = { + { + .name = "ssc0", + .lock = SPIN_LOCK_UNLOCKED, + .dir_mask = 0, + .mutex = &ssc0_mutex, + .initialized = 0, + }, +#if NUM_SSC_DEVICES == 3 + { + .name = "ssc1", + .lock = SPIN_LOCK_UNLOCKED, + .dir_mask = 0, + .mutex = &ssc1_mutex, + .initialized = 0, + }, + { + .name = "ssc2", + .lock = SPIN_LOCK_UNLOCKED, + .dir_mask = 0, + .mutex = &ssc2_mutex, + .initialized = 0, + }, +#endif +}; + + +static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id) +{ + struct at91_ssc_info *ssc_p = dev_id; + struct at91_pcm_dma_params *dma_params; + u32 ssc_sr; + int i; + + ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR) + & at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR); + + /* + * Loop through the substreams attached to this SSC. If + * a DMA-related interrupt occurred on that substream, call + * the DMA interrupt handler function, if one has been + * registered in the dma_params structure by the PCM driver. + */ + for (i = 0; i < ARRAY_SIZE(ssc_p->dma_params); i++) { + dma_params = ssc_p->dma_params[i]; + + if (dma_params != NULL && dma_params->dma_intr_handler != NULL && + (ssc_sr & + (dma_params->mask->ssc_endx | dma_params->mask->ssc_endbuf))) + + dma_params->dma_intr_handler(ssc_sr, dma_params->substream); + } + + return IRQ_HANDLED; +} + +static int at91_i2s_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct at91_ssc_info *ssc_p = &ssc_info[rtd->cpu_dai->id]; + int dir_mask; + + DBG("i2s_startup: SSC_SR=0x%08lx\n", + at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)); + dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2; + + spin_lock_irq(&ssc_p->lock); + if (ssc_p->dir_mask & dir_mask) { + spin_unlock_irq(&ssc_p->lock); + return -EBUSY; + } + ssc_p->dir_mask |= dir_mask; + spin_unlock_irq(&ssc_p->lock); + + return 0; +} + +static void at91_i2s_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct at91_ssc_info *ssc_p = &ssc_info[rtd->cpu_dai->id]; + struct at91_pcm_dma_params *dma_params = rtd->cpu_dai->dma_data; + int dir, dir_mask; + + dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1; + + if (dma_params != NULL) { + at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR, + dma_params->mask->ssc_disable); + DBG("%s disabled SSC_SR=0x%08lx\n", (dir ? "receive" : "transmit"), + at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)); + + dma_params->ssc_base = NULL; + dma_params->substream = NULL; + ssc_p->dma_params[dir] = NULL; + } + + dir_mask = 1 << dir; + + spin_lock_irq(&ssc_p->lock); + ssc_p->dir_mask &= ~dir_mask; + if (!ssc_p->dir_mask) { + /* Shutdown the SSC clock. */ + DBG("Stopping pid %d clock\n", ssc_p->ssc.pid); + at91_sys_write(AT91_PMC_PCDR, 1<ssc.pid); + + if (ssc_p->initialized) + free_irq(ssc_p->ssc.pid, ssc_p); + + /* Reset the SSC */ + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST); + + /* Force a re-init on the next hw_params() call. */ + ssc_p->initialized = 0; + } + spin_unlock_irq(&ssc_p->lock); +} + +#ifdef CONFIG_PM +static int at91_i2s_suspend(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + struct at91_ssc_info *ssc_p; + + if(!dai->active) + return 0; + + ssc_p = &ssc_info[dai->id]; + + /* Save the status register before disabling transmit and receive. */ + ssc_p->state->ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR); + at91_ssc_write(ssc_p->ssc.base + + AT91_SSC_CR, AT91_SSC_TXDIS | AT91_SSC_RXDIS); + + /* Save the current interrupt mask, then disable unmasked interrupts. */ + ssc_p->state->ssc_imr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IDR, ssc_p->state->ssc_imr); + + ssc_p->state->ssc_cmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_CMR); + ssc_p->state->ssc_rcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR); + ssc_p->state->ssc_rfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR); + ssc_p->state->ssc_tcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR); + ssc_p->state->ssc_tfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR); + + return 0; +} + +static int at91_i2s_resume(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + struct at91_ssc_info *ssc_p; + u32 cr_mask; + + if(!dai->active) + return 0; + + ssc_p = &ssc_info[dai->id]; + + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->state->ssc_tfmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->state->ssc_tcmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->state->ssc_rfmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->state->ssc_rcmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR, ssc_p->state->ssc_cmr); + + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IER, ssc_p->state->ssc_imr); + + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, + ((ssc_p->state->ssc_sr & AT91_SSC_RXENA) ? AT91_SSC_RXEN : 0) | + ((ssc_p->state->ssc_sr & AT91_SSC_TXENA) ? AT91_SSC_TXEN : 0)); + + return 0; +} + +#else +#define at91_i2s_suspend NULL +#define at91_i2s_resume NULL +#endif + +static unsigned int at91_i2s_config_sysclk( + struct snd_soc_cpu_dai *iface, struct snd_soc_clock_info *info, + unsigned int clk) +{ + /* Currently, there is only support for USB (12Mhz) mode */ + if (clk != 12000000) + return 0; + return 12000000; +} + +static int at91_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + int id = rtd->cpu_dai->id; + struct at91_ssc_info *ssc_p = &ssc_info[id]; + struct at91_pcm_dma_params *dma_params; + unsigned int pcmfmt, rate; + int dir, channels, bits; + struct clk *mck_clk; + u32 div, period, tfmr, rfmr, tcmr, rcmr; + int ret; + + /* + * Currently, there is only one set of dma params for + * each direction. If more are added, this code will + * have to be changed to select the proper set. + */ + dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1; + + dma_params = &ssc_dma_params[id][dir]; + dma_params->ssc_base = ssc_p->ssc.base; + dma_params->substream = substream; + + ssc_p->dma_params[dir] = dma_params; + rtd->cpu_dai->dma_data = dma_params; + + rate = params_rate(params); + channels = params_channels(params); + + pcmfmt = rtd->cpu_dai->dai_runtime.pcmfmt; + switch (pcmfmt) { + case SNDRV_PCM_FMTBIT_S16_LE: + /* likely this is all we'll ever support, but ... */ + bits = 16; + dma_params->pdc_xfer_size = 2; + break; + default: + printk(KERN_WARNING "at91-i2s: unsupported format %x\n", + pcmfmt); + return -EINVAL; + } + + /* Don't allow both SSC substreams to initialize at the same time. */ + down(ssc_p->mutex); + + /* + * If this SSC is alreadly initialized, then this substream must use + * the same format and rate. + */ + if (ssc_p->initialized) { + if (pcmfmt != ssc_p->pcmfmt || rate != ssc_p->rate) { + printk(KERN_WARNING "at91-i2s: " + "incompatible substream in other direction\n"); + up(ssc_p->mutex); + return -EINVAL; + } + } else { + /* Enable PMC peripheral clock for this SSC */ + DBG("Starting pid %d clock\n", ssc_p->ssc.pid); + at91_sys_write(AT91_PMC_PCER, 1<ssc.pid); + + /* Reset the SSC */ + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST); + + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RPR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RCR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RNPR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_RNCR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TPR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TCR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TNPR, 0); + at91_ssc_write(ssc_p->ssc.base + AT91_PDC_TNCR, 0); + + div = rtd->cpu_dai->dai_runtime.priv >> 16; + period = rtd->cpu_dai->dai_runtime.priv & 0xffff; + + mck_clk = clk_get(NULL, "mck"); + + DBG("mck %lu fsbd %u bfs %llu bfs_real %u bclk %lu div %u period %u\n", + clk_get_rate(mck_clk), + SND_SOC_FSBD(6), + rtd->cpu_dai->dai_runtime.bfs, + SND_SOC_FSBD_REAL(rtd->cpu_dai->dai_runtime.bfs), + clk_get_rate(mck_clk) / (2 * div), + div, + period); + + clk_put(mck_clk); + + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR, div); + + /* + * Setup the TFMR and RFMR for the proper data format. + */ + tfmr = + (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE) + | (( 0 << 23) & AT91_SSC_FSDEN) + | (( AT91_SSC_FSOS_NEGATIVE ) & AT91_SSC_FSOS) + | (((bits - 1) << 16) & AT91_SSC_FSLEN) + | (((channels - 1) << 8) & AT91_SSC_DATNB) + | (( 1 << 7) & AT91_SSC_MSBF) + | (( 0 << 5) & AT91_SSC_DATDEF) + | (((bits - 1) << 0) & AT91_SSC_DATALEN); + DBG("SSC_TFMR=0x%08x\n", tfmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TFMR, tfmr); + + rfmr = + (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE) + | (( AT91_SSC_FSOS_NONE ) & AT91_SSC_FSOS) + | (( 0 << 16) & AT91_SSC_FSLEN) + | (((channels - 1) << 8) & AT91_SSC_DATNB) + | (( 1 << 7) & AT91_SSC_MSBF) + | (( 0 << 5) & AT91_SSC_LOOP) + | (((bits - 1) << 0) & AT91_SSC_DATALEN); + + DBG("SSC_RFMR=0x%08x\n", rfmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RFMR, rfmr); + + /* + * Setup the TCMR and RCMR to generate the proper BCLK + * and LRC signals. + */ + tcmr = + (( period << 24) & AT91_SSC_PERIOD) + | (( 1 << 16) & AT91_SSC_STTDLY) + | (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START) + | (( AT91_SSC_CKI_FALLING ) & AT91_SSC_CKI) + | (( AT91_SSC_CKO_CONTINUOUS ) & AT91_SSC_CKO) + | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS); + + DBG("SSC_TCMR=0x%08x\n", tcmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TCMR, tcmr); + + rcmr = + (( 0 << 24) & AT91_SSC_PERIOD) + | (( 1 << 16) & AT91_SSC_STTDLY) + | (( AT91_SSC_START_TX_RX ) & AT91_SSC_START) + | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI) + | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO) + | (( AT91_SSC_CKS_CLOCK ) & AT91_SSC_CKS); + + DBG("SSC_RCMR=0x%08x\n", rcmr); + at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, rcmr); + + if ((ret = request_irq(ssc_p->ssc.pid, at91_i2s_interrupt, + 0, ssc_p->name, ssc_p)) < 0) { + printk(KERN_WARNING "at91-i2s: request_irq failure\n"); + return ret; + } + + /* + * Save the current substream parameters in order to check + * that the substream in the opposite direction uses the + * same parameters. + */ + ssc_p->pcmfmt = pcmfmt; + ssc_p->rate = rate; + ssc_p->initialized = 1; + + DBG("hw_params: SSC initialized\n"); + } + + up(ssc_p->mutex); + + return 0; +} + + +static int at91_i2s_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct at91_pcm_dma_params *dma_params = rtd->cpu_dai->dma_data; + + at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR, + dma_params->mask->ssc_enable); + + DBG("%s enabled SSC_SR=0x%08lx\n", + substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? "transmit" : "receive", + at91_ssc_read(ssc_info[rtd->cpu_dai->id].ssc.base + AT91_SSC_SR)); + return 0; +} + + +struct snd_soc_cpu_dai at91_i2s_dai[NUM_SSC_DEVICES] = { + { .name = "at91_ssc0/i2s", + .id = 0, + .type = SND_SOC_DAI_I2S, + .suspend = at91_i2s_suspend, + .resume = at91_i2s_resume, + .config_sysclk = at91_i2s_config_sysclk, + .playback = { + .channels_min = 1, + .channels_max = 2,}, + .capture = { + .channels_min = 1, + .channels_max = 2,}, + .ops = { + .startup = at91_i2s_startup, + .shutdown = at91_i2s_shutdown, + .prepare = at91_i2s_prepare, + .hw_params = at91_i2s_hw_params,}, + .caps = { + .mode = &at91_i2s[0], + .num_modes = ARRAY_SIZE(at91_i2s),}, + .private_data = &ssc_info[0].ssc, + }, +#if NUM_SSC_DEVICES == 3 + { .name = "at91_ssc1/i2s", + .id = 1, + .type = SND_SOC_DAI_I2S, + .suspend = at91_i2s_suspend, + .resume = at91_i2s_resume, + .config_sysclk = at91_i2s_config_sysclk, + .playback = { + .channels_min = 1, + .channels_max = 2,}, + .capture = { + .channels_min = 1, + .channels_max = 2,}, + .ops = { + .startup = at91_i2s_startup, + .shutdown = at91_i2s_shutdown, + .prepare = at91_i2s_prepare, + .hw_params = at91_i2s_hw_params,}, + .caps = { + .mode = &at91_i2s[0], + .num_modes = ARRAY_SIZE(at91_i2s),}, + .private_data = &ssc_info[1].ssc, + }, + { .name = "at91_ssc2/i2s", + .id = 2, + .type = SND_SOC_DAI_I2S, + .suspend = at91_i2s_suspend, + .resume = at91_i2s_resume, + .config_sysclk = at91_i2s_config_sysclk, + .playback = { + .channels_min = 1, + .channels_max = 2,}, + .capture = { + .channels_min = 1, + .channels_max = 2,}, + .ops = { + .startup = at91_i2s_startup, + .shutdown = at91_i2s_shutdown, + .prepare = at91_i2s_prepare, + .hw_params = at91_i2s_hw_params,}, + .caps = { + .mode = &at91_i2s[0], + .num_modes = ARRAY_SIZE(at91_i2s),}, + .private_data = &ssc_info[2].ssc, + }, +#endif +}; + +EXPORT_SYMBOL_GPL(at91_i2s_dai); + +/* Module information */ +MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com"); +MODULE_DESCRIPTION("AT91 I2S ASoC Interface"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/at91/at91-pcm.c b/sound/soc/at91/at91-pcm.c new file mode 100644 index 0000000..fd9d732 --- /dev/null +++ b/sound/soc/at91/at91-pcm.c @@ -0,0 +1,427 @@ +/* + * at91-pcm.c -- ALSA PCM interface for the Atmel AT91 SoC + * + * Author: Frank Mandarino + * Endrelia Technologies Inc. + * Created: Mar 3, 2006 + * + * Based on pxa2xx-pcm.c by: + * + * Author: Nicolas Pitre + * Created: Nov 30, 2004 + * Copyright: (C) 2004 MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "at91-pcm.h" + +#if 0 +#define DBG(x...) printk(KERN_INFO "at91-pcm: " x) +#else +#define DBG(x...) +#endif + +static const struct snd_pcm_hardware at91_pcm_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_PAUSE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .period_bytes_min = 32, + .period_bytes_max = 8192, + .periods_min = 2, + .periods_max = 1024, + .buffer_bytes_max = 32 * 1024, +}; + +struct at91_runtime_data { + struct at91_pcm_dma_params *params; + dma_addr_t dma_buffer; /* physical address of dma buffer */ + dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */ + size_t period_size; + dma_addr_t period_ptr; /* physical address of next period */ + u32 pdc_xpr_save; /* PDC register save */ + u32 pdc_xcr_save; + u32 pdc_xnpr_save; + u32 pdc_xncr_save; +}; + +static void at91_pcm_dma_irq(u32 ssc_sr, + struct snd_pcm_substream *substream) +{ + struct at91_runtime_data *prtd = substream->runtime->private_data; + struct at91_pcm_dma_params *params = prtd->params; + static int count = 0; + + count++; + + if (ssc_sr & params->mask->ssc_endbuf) { + + printk(KERN_WARNING + "at91-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n", + substream->stream == SNDRV_PCM_STREAM_PLAYBACK + ? "underrun" : "overrun", + params->name, ssc_sr, count); + + /* re-start the PDC */ + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable); + + prtd->period_ptr += prtd->period_size; + if (prtd->period_ptr >= prtd->dma_buffer_end) { + prtd->period_ptr = prtd->dma_buffer; + } + + at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr); + at91_ssc_write(params->ssc_base + params->pdc->xcr, + prtd->period_size / params->pdc_xfer_size); + + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable); + } + + if (ssc_sr & params->mask->ssc_endx) { + + /* Load the PDC next pointer and counter registers */ + prtd->period_ptr += prtd->period_size; + if (prtd->period_ptr >= prtd->dma_buffer_end) { + prtd->period_ptr = prtd->dma_buffer; + } + at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr); + at91_ssc_write(params->ssc_base + params->pdc->xncr, + prtd->period_size / params->pdc_xfer_size); + } + + snd_pcm_period_elapsed(substream); +} + +static int at91_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct at91_runtime_data *prtd = runtime->private_data; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + /* this may get called several times by oss emulation + * with different params */ + + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + runtime->dma_bytes = params_buffer_bytes(params); + + prtd->params = rtd->cpu_dai->dma_data; + prtd->params->dma_intr_handler = at91_pcm_dma_irq; + + prtd->dma_buffer = runtime->dma_addr; + prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes; + prtd->period_size = params_period_bytes(params); + + DBG("hw_params: DMA for %s initialized (dma_bytes=%d, period_size=%d)\n", + prtd->params->name, runtime->dma_bytes, prtd->period_size); + return 0; +} + +static int at91_pcm_hw_free(struct snd_pcm_substream *substream) +{ + struct at91_runtime_data *prtd = substream->runtime->private_data; + struct at91_pcm_dma_params *params = prtd->params; + + if (params != NULL) { + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable); + prtd->params->dma_intr_handler = NULL; + } + + return 0; +} + +static int at91_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct at91_runtime_data *prtd = substream->runtime->private_data; + struct at91_pcm_dma_params *params = prtd->params; + + at91_ssc_write(params->ssc_base + AT91_SSC_IDR, + params->mask->ssc_endx | params->mask->ssc_endbuf); + + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable); + return 0; +} + +static int at91_pcm_trigger(struct snd_pcm_substream *substream, + int cmd) +{ + struct at91_runtime_data *prtd = substream->runtime->private_data; + struct at91_pcm_dma_params *params = prtd->params; + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + prtd->period_ptr = prtd->dma_buffer; + + at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->period_ptr); + at91_ssc_write(params->ssc_base + params->pdc->xcr, + prtd->period_size / params->pdc_xfer_size); + + prtd->period_ptr += prtd->period_size; + at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr); + at91_ssc_write(params->ssc_base + params->pdc->xncr, + prtd->period_size / params->pdc_xfer_size); + + DBG("trigger: period_ptr=%lx, xpr=%lx, xcr=%ld, xnpr=%lx, xncr=%ld\n", + (unsigned long) prtd->period_ptr, + at91_ssc_read(params->ssc_base + params->pdc->xpr), + at91_ssc_read(params->ssc_base + params->pdc->xcr), + at91_ssc_read(params->ssc_base + params->pdc->xnpr), + at91_ssc_read(params->ssc_base + params->pdc->xncr)); + + at91_ssc_write(params->ssc_base + AT91_SSC_IER, + params->mask->ssc_endx | params->mask->ssc_endbuf); + + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable); + + DBG("sr=%lx imr=%lx\n", at91_ssc_read(params->ssc_base + AT91_SSC_SR), + at91_ssc_read(params->ssc_base + AT91_SSC_IER)); + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable); + break; + + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable); + break; + + default: + ret = -EINVAL; + } + + return ret; +} + +static snd_pcm_uframes_t at91_pcm_pointer( + struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct at91_runtime_data *prtd = runtime->private_data; + struct at91_pcm_dma_params *params = prtd->params; + dma_addr_t ptr; + snd_pcm_uframes_t x; + + ptr = (dma_addr_t) at91_ssc_read(params->ssc_base + params->pdc->xpr); + x = bytes_to_frames(runtime, ptr - prtd->dma_buffer); + + if (x == runtime->buffer_size) + x = 0; + return x; +} + +static int at91_pcm_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct at91_runtime_data *prtd; + int ret = 0; + + snd_soc_set_runtime_hwparams(substream, &at91_pcm_hardware); + + /* ensure that buffer size is a multiple of period size */ + ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); + if (ret < 0) + goto out; + + prtd = kzalloc(sizeof(struct at91_runtime_data), GFP_KERNEL); + if (prtd == NULL) { + ret = -ENOMEM; + goto out; + } + runtime->private_data = prtd; + + out: + return ret; +} + +static int at91_pcm_close(struct snd_pcm_substream *substream) +{ + struct at91_runtime_data *prtd = substream->runtime->private_data; + + kfree(prtd); + return 0; +} + +static int at91_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + return dma_mmap_writecombine(substream->pcm->card->dev, vma, + runtime->dma_area, + runtime->dma_addr, + runtime->dma_bytes); +} + +struct snd_pcm_ops at91_pcm_ops = { + .open = at91_pcm_open, + .close = at91_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = at91_pcm_hw_params, + .hw_free = at91_pcm_hw_free, + .prepare = at91_pcm_prepare, + .trigger = at91_pcm_trigger, + .pointer = at91_pcm_pointer, + .mmap = at91_pcm_mmap, +}; + +static int at91_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, + int stream) +{ + struct snd_pcm_substream *substream = pcm->streams[stream].substream; + struct snd_dma_buffer *buf = &substream->dma_buffer; + size_t size = at91_pcm_hardware.buffer_bytes_max; + + buf->dev.type = SNDRV_DMA_TYPE_DEV; + buf->dev.dev = pcm->card->dev; + buf->private_data = NULL; + buf->area = dma_alloc_writecombine(pcm->card->dev, size, + &buf->addr, GFP_KERNEL); + + DBG("preallocate_dma_buffer: area=%p, addr=%p, size=%d\n", + (void *) buf->area, + (void *) buf->addr, + size); + + if (!buf->area) + return -ENOMEM; + + buf->bytes = size; + return 0; +} + +static u64 at91_pcm_dmamask = 0xffffffff; + +static int at91_pcm_new(struct snd_card *card, + struct snd_soc_codec_dai *dai, struct snd_pcm *pcm) +{ + int ret = 0; + + if (!card->dev->dma_mask) + card->dev->dma_mask = &at91_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = 0xffffffff; + + if (dai->playback.channels_min) { + ret = at91_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + goto out; + } + + if (dai->capture.channels_min) { + ret = at91_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_CAPTURE); + if (ret) + goto out; + } + out: + return ret; +} + +static void at91_pcm_free_dma_buffers(struct snd_pcm *pcm) +{ + struct snd_pcm_substream *substream; + struct snd_dma_buffer *buf; + int stream; + + for (stream = 0; stream < 2; stream++) { + substream = pcm->streams[stream].substream; + if (!substream) + continue; + + buf = &substream->dma_buffer; + if (!buf->area) + continue; + + dma_free_writecombine(pcm->card->dev, buf->bytes, + buf->area, buf->addr); + buf->area = NULL; + } +} + +static int at91_pcm_suspend(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + struct snd_pcm_runtime *runtime = dai->runtime; + struct at91_runtime_data *prtd; + struct at91_pcm_dma_params *params; + + if (!runtime) + return 0; + + prtd = runtime->private_data; + params = prtd->params; + + /* disable the PDC and save the PDC registers */ + + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_disable); + + prtd->pdc_xpr_save = at91_ssc_read(params->ssc_base + params->pdc->xpr); + prtd->pdc_xcr_save = at91_ssc_read(params->ssc_base + params->pdc->xcr); + prtd->pdc_xnpr_save = at91_ssc_read(params->ssc_base + params->pdc->xnpr); + prtd->pdc_xncr_save = at91_ssc_read(params->ssc_base + params->pdc->xncr); + + return 0; +} + +static int at91_pcm_resume(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + struct snd_pcm_runtime *runtime = dai->runtime; + struct at91_runtime_data *prtd; + struct at91_pcm_dma_params *params; + + if (!runtime) + return 0; + + prtd = runtime->private_data; + params = prtd->params; + + /* restore the PDC registers and enable the PDC */ + at91_ssc_write(params->ssc_base + params->pdc->xpr, prtd->pdc_xpr_save); + at91_ssc_write(params->ssc_base + params->pdc->xcr, prtd->pdc_xcr_save); + at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->pdc_xnpr_save); + at91_ssc_write(params->ssc_base + params->pdc->xncr, prtd->pdc_xncr_save); + + at91_ssc_write(params->ssc_base + AT91_PDC_PTCR, params->mask->pdc_enable); + return 0; +} + +struct snd_soc_platform at91_soc_platform = { + .name = "at91-audio", + .pcm_ops = &at91_pcm_ops, + .pcm_new = at91_pcm_new, + .pcm_free = at91_pcm_free_dma_buffers, + .suspend = at91_pcm_suspend, + .resume = at91_pcm_resume, +}; + +EXPORT_SYMBOL_GPL(at91_soc_platform); + +MODULE_AUTHOR("Frank Mandarino "); +MODULE_DESCRIPTION("Atmel AT91 PCM module"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/at91/at91-pcm.h b/sound/soc/at91/at91-pcm.h new file mode 100644 index 0000000..6c3b095 --- /dev/null +++ b/sound/soc/at91/at91-pcm.h @@ -0,0 +1,71 @@ +/* + * at91-pcm.h - ALSA PCM interface for the Atmel AT91 SoC + * + * Author: Frank Mandarino + * Endrelia Technologies Inc. + * Created: Mar 3, 2006 + * + * Based on pxa2xx-pcm.h by: + * + * Author: Nicolas Pitre + * Created: Nov 30, 2004 + * Copyright: MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include + +struct at91_ssc_periph { + void __iomem *base; + u32 pid; +}; + + +/* + * Registers and status bits that are required by the PCM driver. + */ +struct at91_pdc_regs { + unsigned int xpr; /* PDC recv/trans pointer */ + unsigned int xcr; /* PDC recv/trans counter */ + unsigned int xnpr; /* PDC next recv/trans pointer */ + unsigned int xncr; /* PDC next recv/trans counter */ + unsigned int ptcr; /* PDC transfer control */ +}; + +struct at91_ssc_mask { + u32 ssc_enable; /* SSC recv/trans enable */ + u32 ssc_disable; /* SSC recv/trans disable */ + u32 ssc_endx; /* SSC ENDTX or ENDRX */ + u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */ + u32 pdc_enable; /* PDC recv/trans enable */ + u32 pdc_disable; /* PDC recv/trans disable */ +}; + + +/* + * This structure, shared between the PCM driver and the interface, + * contains all information required by the PCM driver to perform the + * PDC DMA operation. All fields except dma_intr_handler() are initialized + * by the interface. The dms_intr_handler() pointer is set by the PCM + * driver and called by the interface SSC interrupt handler if it is + * non-NULL. + */ +struct at91_pcm_dma_params { + char *name; /* stream identifier */ + int pdc_xfer_size; /* PDC counter increment in bytes */ + void __iomem *ssc_base; /* SSC base address */ + struct at91_pdc_regs *pdc; /* PDC receive or transmit registers */ + struct at91_ssc_mask *mask;/* SSC & PDC status bits */ + struct snd_pcm_substream *substream; + void (*dma_intr_handler)(u32, struct snd_pcm_substream *); +}; + +extern struct snd_soc_cpu_dai at91_i2s_dai[3]; +extern struct snd_soc_platform at91_soc_platform; + + +#define at91_ssc_read(a) ((unsigned long) __raw_readl(a)) +#define at91_ssc_write(a,v) __raw_writel((v),(a)) diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c new file mode 100644 index 0000000..089cdc9 --- /dev/null +++ b/sound/soc/at91/eti_b1_wm8731.c @@ -0,0 +1,268 @@ +/* + * eti_b1_wm8731 -- SoC audio for AT91RM9200-based Endrelia ETI_B1 board. + * + * Author: Frank Mandarino + * Endrelia Technologies Inc. + * Created: Mar 29, 2006 + * + * Based on corgi.c by: + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Authors: Liam Girdwood + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 30th Nov 2005 Initial version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../codecs/wm8731.h" +#include "at91-pcm.h" + +#if 0 +#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731:" x) +#else +#define DBG(x...) +#endif + +#define AT91_PIO_TF1 (1 << (AT91_PIN_PB6 - PIN_BASE) % 32) +#define AT91_PIO_TK1 (1 << (AT91_PIN_PB7 - PIN_BASE) % 32) +#define AT91_PIO_TD1 (1 << (AT91_PIN_PB8 - PIN_BASE) % 32) +#define AT91_PIO_RD1 (1 << (AT91_PIN_PB9 - PIN_BASE) % 32) +#define AT91_PIO_RK1 (1 << (AT91_PIN_PB10 - PIN_BASE) % 32) +#define AT91_PIO_RF1 (1 << (AT91_PIN_PB11 - PIN_BASE) % 32) + + +static struct clk *pck1_clk; +static struct clk *pllb_clk; + +static int eti_b1_startup(struct snd_pcm_substream *substream) +{ + /* Start PCK1 clock. */ + clk_enable(pck1_clk); + DBG("pck1 started\n"); + + return 0; +} + +static void eti_b1_shutdown(struct snd_pcm_substream *substream) +{ + /* Stop PCK1 clock. */ + clk_disable(pck1_clk); + DBG("pck1 stopped\n"); +} + +static struct snd_soc_ops eti_b1_ops = { + .startup = eti_b1_startup, + .shutdown = eti_b1_shutdown, +}; + + +static const struct snd_soc_dapm_widget eti_b1_dapm_widgets[] = { + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), +}; + +static const char *intercon[][3] = { + + /* speaker connected to LHPOUT */ + {"Ext Spk", NULL, "LHPOUT"}, + + /* mic is connected to Mic Jack, with WM8731 Mic Bias */ + {"MICIN", NULL, "Mic Bias"}, + {"Mic Bias", NULL, "Int Mic"}, + + /* terminator */ + {NULL, NULL, NULL}, +}; + +/* + * Logic for a wm8731 as connected on a Endrelia ETI-B1 board. + */ +static int eti_b1_wm8731_init(struct snd_soc_codec *codec) +{ + int i; + + DBG("eti_b1_wm8731_init() called\n"); + + /* Add specific widgets */ + for(i = 0; i < ARRAY_SIZE(eti_b1_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &eti_b1_dapm_widgets[i]); + } + + /* Set up specific audio path interconnects */ + for(i = 0; intercon[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, intercon[i][0], + intercon[i][1], intercon[i][2]); + } + + /* not connected */ + snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0); + snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0); + + /* always connected */ + snd_soc_dapm_set_endpoint(codec, "Int Mic", 1); + snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1); + + snd_soc_dapm_sync_endpoints(codec); + + return 0; +} + +unsigned int eti_b1_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) +{ + if(info->bclk_master & SND_SOC_DAIFMT_CBS_CFS) { + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, 12000000); + } + return 0; +} + +static struct snd_soc_dai_link eti_b1_dai = { + .name = "WM8731", + .stream_name = "WM8731", + .cpu_dai = &at91_i2s_dai[1], + .codec_dai = &wm8731_dai, + .init = eti_b1_wm8731_init, + .config_sysclk = eti_b1_config_sysclk, +}; + +static struct snd_soc_machine snd_soc_machine_eti_b1 = { + .name = "ETI_B1", + .dai_link = &eti_b1_dai, + .num_links = 1, + .ops = &eti_b1_ops, +}; + +static struct wm8731_setup_data eti_b1_wm8731_setup = { + .i2c_address = 0x1a, +}; + +static struct snd_soc_device eti_b1_snd_devdata = { + .machine = &snd_soc_machine_eti_b1, + .platform = &at91_soc_platform, + .codec_dev = &soc_codec_dev_wm8731, + .codec_data = &eti_b1_wm8731_setup, +}; + +static struct platform_device *eti_b1_snd_device; + +static int __init eti_b1_init(void) +{ + int ret; + u32 ssc_pio_lines; + struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data; + + if (!request_mem_region(AT91RM9200_BASE_SSC1, SZ_16K, "soc-audio")) { + DBG("SSC1 memory region is busy\n"); + return -EBUSY; + } + + ssc->base = ioremap(AT91RM9200_BASE_SSC1, SZ_16K); + if (!ssc->base) { + DBG("SSC1 memory ioremap failed\n"); + ret = -ENOMEM; + goto fail_release_mem; + } + + ssc->pid = AT91RM9200_ID_SSC1; + + eti_b1_snd_device = platform_device_alloc("soc-audio", -1); + if (!eti_b1_snd_device) { + DBG("platform device allocation failed\n"); + ret = -ENOMEM; + goto fail_io_unmap; + } + + platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata); + eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev; + + ret = platform_device_add(eti_b1_snd_device); + if (ret) { + DBG("platform device add failed\n"); + platform_device_put(eti_b1_snd_device); + goto fail_io_unmap; + } + + ssc_pio_lines = AT91_PIO_TF1 | AT91_PIO_TK1 | AT91_PIO_TD1 + | AT91_PIO_RD1 /* | AT91_PIO_RK1 | AT91_PIO_RF1 */; + + /* Reset all PIO registers and assign lines to peripheral A */ + at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_ODR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_IFDR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_CODR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_IDR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_MDDR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_PUDR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_ASR, ssc_pio_lines); + at91_sys_write(AT91_PIOB + PIO_OWDR, ssc_pio_lines); + + /* + * Set PCK1 parent to PLLB and its rate to 12 Mhz. + */ + pllb_clk = clk_get(NULL, "pllb"); + pck1_clk = clk_get(NULL, "pck1"); + + clk_set_parent(pck1_clk, pllb_clk); + clk_set_rate(pck1_clk, 12000000); + + DBG("MCLK rate %luHz\n", clk_get_rate(pck1_clk)); + + /* assign the GPIO pin to PCK1 */ + at91_set_B_periph(AT91_PIN_PA24, 0); + + return ret; + +fail_io_unmap: + iounmap(ssc->base); +fail_release_mem: + release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K); + return ret; +} + +static void __exit eti_b1_exit(void) +{ + struct at91_ssc_periph *ssc = eti_b1_dai.cpu_dai->private_data; + + clk_put(pck1_clk); + clk_put(pllb_clk); + + platform_device_unregister(eti_b1_snd_device); + + iounmap(ssc->base); + release_mem_region(AT91RM9200_BASE_SSC1, SZ_16K); +} + +module_init(eti_b1_init); +module_exit(eti_b1_exit); + +/* Module information */ +MODULE_AUTHOR("Frank Mandarino "); +MODULE_DESCRIPTION("ALSA SoC ETI-B1-WM8731"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig new file mode 100644 index 0000000..78ac268 --- /dev/null +++ b/sound/soc/codecs/Kconfig @@ -0,0 +1,15 @@ +config SND_SOC_AC97_CODEC + tristate + depends SND_SOC + +config SND_SOC_WM8731 + tristate + depends SND_SOC + +config SND_SOC_WM8750 + tristate + depends SND_SOC + +config SND_SOC_WM9712 + tristate + depends SND_SOC diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile new file mode 100644 index 0000000..3249a6e --- /dev/null +++ b/sound/soc/codecs/Makefile @@ -0,0 +1,9 @@ +snd-soc-ac97-objs := ac97.o +snd-soc-wm8731-objs := wm8731.o +snd-soc-wm8750-objs := wm8750.o +snd-soc-wm9712-objs := wm9712.o + +obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o +obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o +obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o +obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c new file mode 100644 index 0000000..dd1a9f5 --- /dev/null +++ b/sound/soc/codecs/ac97.c @@ -0,0 +1,167 @@ +/* + * ac97.c -- ALSA Soc AC97 codec support + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Author: Liam Girdwood + * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 17th Oct 2005 Initial version. + * + * Generic AC97 support. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AC97_VERSION "0.5" + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode soc_ac97[] = { + {0, 0, SNDRV_PCM_FMTBIT_S16_LE, AC97_RATES}, + {0, 0, SNDRV_PCM_FMTBIT_S18_3LE, AC97_RATES}, + {0, 0, SNDRV_PCM_FMTBIT_S20_3LE, AC97_RATES}, +}; + +static int ac97_prepare(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + + int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? + AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; + return snd_ac97_set_rate(codec->ac97, reg, runtime->rate); +} + +static struct snd_soc_codec_dai ac97_dai = { + .name = "AC97 HiFi", + .playback = { + .stream_name = "AC97 Playback", + .channels_min = 1, + .channels_max = 2,}, + .capture = { + .stream_name = "AC97 Capture", + .channels_min = 1, + .channels_max = 2,}, + .ops = { + .prepare = ac97_prepare,}, + .caps = { + .num_modes = ARRAY_SIZE(soc_ac97), + .mode = soc_ac97,}, +}; + +static unsigned int ac97_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + return soc_ac97_ops.read(codec->ac97, reg); +} + +static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int val) +{ + soc_ac97_ops.write(codec->ac97, reg, val); + return 0; +} + +static int ac97_soc_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97_template ac97_template; + int ret = 0; + + printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); + + socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (socdev->codec == NULL) + return -ENOMEM; + codec = socdev->codec; + mutex_init(&codec->mutex); + + codec->name = "AC97"; + codec->owner = THIS_MODULE; + codec->dai = &ac97_dai; + codec->num_dai = 1; + codec->write = ac97_write; + codec->read = ac97_read; + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if(ret < 0) + goto err; + + /* add codec as bus device for standard ac97 */ + ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus); + if(ret < 0) + goto bus_err; + + memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); + ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97); + if(ret < 0) + goto bus_err; + + ret = snd_soc_register_card(socdev); + if (ret < 0) + goto bus_err; + return 0; + +bus_err: + snd_soc_free_pcms(socdev); + +err: + kfree(socdev->codec->reg_cache); + kfree(socdev->codec); + socdev->codec = NULL; + return ret; +} + +static int ac97_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + if(codec == NULL) + return 0; + + snd_soc_free_pcms(socdev); + kfree(socdev->codec->reg_cache); + kfree(socdev->codec); + + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_ac97= { + .probe = ac97_soc_probe, + .remove = ac97_soc_remove, +}; + +EXPORT_SYMBOL_GPL(soc_codec_dev_ac97); + +MODULE_DESCRIPTION("Soc Generic AC97 driver"); +MODULE_AUTHOR("Liam Girdwood"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/ac97.h b/sound/soc/codecs/ac97.h new file mode 100644 index 0000000..930ddfc --- /dev/null +++ b/sound/soc/codecs/ac97.h @@ -0,0 +1,18 @@ +/* + * linux/sound/codecs/ac97.h -- ALSA SoC Layer + * + * Author: Liam Girdwood + * Created: Dec 1st 2005 + * Copyright: Wolfson Microelectronics. PLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __LINUX_SND_SOC_AC97_H +#define __LINUX_SND_SOC_AC97_H + +extern struct snd_soc_codec_device soc_codec_dev_ac97; + +#endif diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c new file mode 100644 index 0000000..8151b45 --- /dev/null +++ b/sound/soc/codecs/wm8731.c @@ -0,0 +1,886 @@ +/* + * wm8731.c -- WM8731 ALSA SoC Audio driver + * + * Copyright 2005 Openedhand Ltd. + * + * Author: Richard Purdie + * + * Based on wm8753.c by Liam Girdwood + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wm8731.h" + +#define AUDIO_NAME "wm8731" +#define WM8731_VERSION "0.12" + +/* + * Debug + */ + +#define WM8731_DEBUG 0 + +#ifdef WM8731_DEBUG +#define dbg(format, arg...) \ + printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg) +#else +#define dbg(format, arg...) do {} while (0) +#endif +#define err(format, arg...) \ + printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg) +#define info(format, arg...) \ + printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg) +#define warn(format, arg...) \ + printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg) + +struct snd_soc_codec_device soc_codec_dev_wm8731; + +/* + * wm8731 register cache + * We can't read the WM8731 register space when we are + * using 2 wire for device control, so we cache them instead. + * There is no point in caching the reset register + */ +static const u16 wm8731_reg[WM8731_CACHEREGNUM] = { + 0x0097, 0x0097, 0x0079, 0x0079, + 0x000a, 0x0008, 0x009f, 0x000a, + 0x0000, 0x0000 +}; + +#define WM8731_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_RIGHT_J | \ + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_IB_NF | \ + SND_SOC_DAIFMT_IB_IF) + +#define WM8731_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define WM8731_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + +#define WM8731_HIFI_BITS \ + (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) + +static struct snd_soc_dai_mode wm8731_modes[] = { + /* codec frame and clock master modes */ + /* 8k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 1536, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 2304, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 1408, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 2112, + .bfs = 64, + }, + + /* 32k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 384, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 576, + .bfs = 64, + }, + + /* 44.1k & 48k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 256, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 384, + .bfs = 64, + }, + + /* 88.2 & 96k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 128, + .bfs = 64, + }, + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_RATE, + .fs = 192, + .bfs = 64, + }, + + /* USB codec frame and clock master modes */ + /* 8k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1500, + .bfs = SND_SOC_FSBD(1), + }, + + /* 44.1k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 272, + .bfs = SND_SOC_FSBD(1), + }, + + /* 48k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 250, + .bfs = SND_SOC_FSBD(1), + }, + + /* 88.2k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 136, + .bfs = SND_SOC_FSBD(1), + }, + + /* 96k */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_96000, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 125, + .bfs = SND_SOC_FSBD(1), + }, + + /* codec frame and clock slave modes */ + { + .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = WM8731_HIFI_BITS, + .pcmrate = WM8731_RATES, + .pcmdir = WM8731_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = SND_SOC_FS_ALL, + .bfs = SND_SOC_FSB_ALL, + }, +}; + +/* + * read wm8731 register cache + */ +static inline unsigned int wm8731_read_reg_cache(struct snd_soc_codec *codec, + unsigned int reg) +{ + u16 *cache = codec->reg_cache; + if (reg == WM8731_RESET) + return 0; + if (reg >= WM8731_CACHEREGNUM) + return -1; + return cache[reg]; +} + +/* + * write wm8731 register cache + */ +static inline void wm8731_write_reg_cache(struct snd_soc_codec *codec, + u16 reg, unsigned int value) +{ + u16 *cache = codec->reg_cache; + if (reg >= WM8731_CACHEREGNUM) + return; + cache[reg] = value; +} + +/* + * write to the WM8731 register space + */ +static int wm8731_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + u8 data[2]; + + /* data is + * D15..D9 WM8731 register offset + * D8...D0 register data + */ + data[0] = (reg << 1) | ((value >> 8) & 0x0001); + data[1] = value & 0x00ff; + + wm8731_write_reg_cache (codec, reg, value); + if (codec->hw_write(codec->control_data, data, 2) == 2) + return 0; + else + return -EIO; +} + +#define wm8731_reset(c) wm8731_write(c, WM8731_RESET, 0) + +static const char *wm8731_input_select[] = {"Line In", "Mic"}; +static const char *wm8731_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"}; + +static const struct soc_enum wm8731_enum[] = { + SOC_ENUM_SINGLE(WM8731_APANA, 2, 2, wm8731_input_select), + SOC_ENUM_SINGLE(WM8731_APDIGI, 1, 4, wm8731_deemph), +}; + +static const struct snd_kcontrol_new wm8731_snd_controls[] = { + +SOC_DOUBLE_R("Master Playback Volume", WM8731_LOUT1V, WM8731_ROUT1V, + 0, 127, 0), +SOC_DOUBLE_R("Master Playback ZC Switch", WM8731_LOUT1V, WM8731_ROUT1V, + 7, 1, 0), + +SOC_DOUBLE_R("Capture Volume", WM8731_LINVOL, WM8731_RINVOL, 0, 31, 0), +SOC_DOUBLE_R("Line Capture Switch", WM8731_LINVOL, WM8731_RINVOL, 7, 1, 1), + +SOC_SINGLE("Mic Boost (+20dB)", WM8731_APANA, 0, 1, 0), +SOC_SINGLE("Capture Mic Switch", WM8731_APANA, 1, 1, 1), + +SOC_SINGLE("Sidetone Playback Volume", WM8731_APANA, 6, 3, 1), + +SOC_SINGLE("ADC High Pass Filter Switch", WM8731_APDIGI, 0, 1, 1), +SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI, 4, 1, 0), + +SOC_ENUM("Playback De-emphasis", wm8731_enum[1]), +}; + +/* add non dapm controls */ +static int wm8731_add_controls(struct snd_soc_codec *codec) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) { + if ((err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8731_snd_controls[i],codec, NULL))) < 0) + return err; + } + + return 0; +} + +/* Output Mixer */ +static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = { +SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0), +SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA, 5, 1, 0), +SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0), +}; + +/* Input mux */ +static const struct snd_kcontrol_new wm8731_input_mux_controls = +SOC_DAPM_ENUM("Input Select", wm8731_enum[0]); + +static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { +SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, + &wm8731_output_mixer_controls[0], + ARRAY_SIZE(wm8731_output_mixer_controls)), +SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8731_PWR, 3, 1), +SND_SOC_DAPM_OUTPUT("LOUT"), +SND_SOC_DAPM_OUTPUT("LHPOUT"), +SND_SOC_DAPM_OUTPUT("ROUT"), +SND_SOC_DAPM_OUTPUT("RHPOUT"), +SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8731_PWR, 2, 1), +SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &wm8731_input_mux_controls), +SND_SOC_DAPM_PGA("Line Input", WM8731_PWR, 0, 1, NULL, 0), +SND_SOC_DAPM_MICBIAS("Mic Bias", WM8731_PWR, 1, 1), +SND_SOC_DAPM_INPUT("MICIN"), +SND_SOC_DAPM_INPUT("RLINEIN"), +SND_SOC_DAPM_INPUT("LLINEIN"), +}; + +static const char *intercon[][3] = { + /* output mixer */ + {"Output Mixer", "Line Bypass Switch", "Line Input"}, + {"Output Mixer", "HiFi Playback Switch", "DAC"}, + {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"}, + + /* outputs */ + {"RHPOUT", NULL, "Output Mixer"}, + {"ROUT", NULL, "Output Mixer"}, + {"LHPOUT", NULL, "Output Mixer"}, + {"LOUT", NULL, "Output Mixer"}, + + /* input mux */ + {"Input Mux", "Line In", "Line Input"}, + {"Input Mux", "Mic", "Mic Bias"}, + {"ADC", NULL, "Input Mux"}, + + /* inputs */ + {"Line Input", NULL, "LLINEIN"}, + {"Line Input", NULL, "RLINEIN"}, + {"Mic Bias", NULL, "MICIN"}, + + /* terminator */ + {NULL, NULL, NULL}, +}; + +static int wm8731_add_widgets(struct snd_soc_codec *codec) +{ + int i; + + for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); + } + + /* set up audio path interconnects */ + for(i = 0; intercon[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, intercon[i][0], + intercon[i][1], intercon[i][2]); + } + + snd_soc_dapm_new_widgets(codec); + return 0; +} + +struct _coeff_div { + u32 mclk; + u32 rate; + u16 fs; + u8 sr:4; + u8 bosr:1; + u8 usb:1; +}; + +/* codec mclk clock divider coefficients */ +static const struct _coeff_div coeff_div[] = { + /* 48k */ + {12288000, 48000, 256, 0x0, 0x0, 0x0}, + {18432000, 48000, 384, 0x0, 0x1, 0x0}, + {12000000, 48000, 250, 0x0, 0x0, 0x1}, + + /* 32k */ + {12288000, 32000, 384, 0x6, 0x0, 0x0}, + {18432000, 32000, 576, 0x6, 0x1, 0x0}, + + /* 8k */ + {12288000, 8000, 1536, 0x3, 0x0, 0x0}, + {18432000, 8000, 2304, 0x3, 0x1, 0x0}, + {11289600, 8000, 1408, 0xb, 0x0, 0x0}, + {16934400, 8000, 2112, 0xb, 0x1, 0x0}, + {12000000, 8000, 1500, 0x3, 0x0, 0x1}, + + /* 96k */ + {12288000, 96000, 128, 0x7, 0x0, 0x0}, + {18432000, 96000, 192, 0x7, 0x1, 0x0}, + {12000000, 96000, 125, 0x7, 0x0, 0x1}, + + /* 44.1k */ + {11289600, 44100, 256, 0x8, 0x0, 0x0}, + {16934400, 44100, 384, 0x8, 0x1, 0x0}, + {12000000, 44100, 272, 0x8, 0x1, 0x1}, + + /* 88.2k */ + {11289600, 88200, 128, 0xf, 0x0, 0x0}, + {16934400, 88200, 192, 0xf, 0x1, 0x0}, + {12000000, 88200, 136, 0xf, 0x1, 0x1}, +}; + +static inline int get_coeff(int mclk, int rate) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { + if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) + return i; + } + return 0; +} + +/* WM8731 supports numerous clocks per sample rate */ +static unsigned int wm8731_config_sysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) +{ + dai->mclk = 0; + + /* check that the calculated FS and rate actually match a clock from + * the machine driver */ + if (info->fs * info->rate == clk) + dai->mclk = clk; + + return dai->mclk; +} + +static int wm8731_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + u16 iface = 0, srate; + int i = get_coeff(rtd->codec_dai->mclk, + snd_soc_get_rate(rtd->codec_dai->dai_runtime.pcmrate)); + + /* set master/slave audio interface */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + iface |= 0x0040; + break; + case SND_SOC_DAIFMT_CBS_CFS: + break; + } + srate = (coeff_div[i].sr << 2) | + (coeff_div[i].bosr << 1) | coeff_div[i].usb; + wm8731_write(codec, WM8731_SRATE, srate); + + /* interface format */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface |= 0x0002; + break; + case SND_SOC_DAIFMT_RIGHT_J: + break; + case SND_SOC_DAIFMT_LEFT_J: + iface |= 0x0001; + break; + case SND_SOC_DAIFMT_DSP_A: + iface |= 0x0003; + break; + case SND_SOC_DAIFMT_DSP_B: + iface |= 0x0013; + break; + } + + /* bit size */ + switch (rtd->codec_dai->dai_runtime.pcmfmt) { + case SNDRV_PCM_FMTBIT_S16_LE: + break; + case SNDRV_PCM_FMTBIT_S20_3LE: + iface |= 0x0004; + break; + case SNDRV_PCM_FMTBIT_S24_LE: + iface |= 0x0008; + break; + case SNDRV_PCM_FMTBIT_S32_LE: + iface |= 0x000c; + break; + } + + /* clock inversion */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + break; + case SND_SOC_DAIFMT_IB_IF: + iface |= 0x0090; + break; + case SND_SOC_DAIFMT_IB_NF: + iface |= 0x0080; + break; + case SND_SOC_DAIFMT_NB_IF: + iface |= 0x0010; + break; + } + + /* set iface */ + wm8731_write(codec, WM8731_IFACE, iface); + + /* set active */ + wm8731_write(codec, WM8731_ACTIVE, 0x0001); + return 0; +} + +static void wm8731_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + + /* deactivate */ + if (!codec->active) { + udelay(50); + wm8731_write(codec, WM8731_ACTIVE, 0x0); + } +} + +static int wm8731_mute(struct snd_soc_codec *codec, + struct snd_soc_codec_dai *dai, int mute) +{ + u16 mute_reg = wm8731_read_reg_cache(codec, WM8731_APDIGI) & 0xfff7; + if (mute) + wm8731_write(codec, WM8731_APDIGI, mute_reg | 0x8); + else + wm8731_write(codec, WM8731_APDIGI, mute_reg); + return 0; +} + +static int wm8731_dapm_event(struct snd_soc_codec *codec, int event) +{ + u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f; + + switch (event) { + case SNDRV_CTL_POWER_D0: /* full On */ + /* vref/mid, osc on, dac unmute */ + wm8731_write(codec, WM8731_PWR, reg); + break; + case SNDRV_CTL_POWER_D1: /* partial On */ + case SNDRV_CTL_POWER_D2: /* partial On */ + break; + case SNDRV_CTL_POWER_D3hot: /* Off, with power */ + /* everything off except vref/vmid, */ + wm8731_write(codec, WM8731_PWR, reg | 0x0040); + break; + case SNDRV_CTL_POWER_D3cold: /* Off, without power */ + /* everything off, dac mute, inactive */ + wm8731_write(codec, WM8731_ACTIVE, 0x0); + wm8731_write(codec, WM8731_PWR, 0xffff); + break; + } + codec->dapm_state = event; + return 0; +} + +struct snd_soc_codec_dai wm8731_dai = { + .name = "WM8731", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + }, + .config_sysclk = wm8731_config_sysclk, + .digital_mute = wm8731_mute, + .ops = { + .prepare = wm8731_pcm_prepare, + .shutdown = wm8731_shutdown, + }, + .caps = { + .num_modes = ARRAY_SIZE(wm8731_modes), + .mode = wm8731_modes, + }, +}; +EXPORT_SYMBOL_GPL(wm8731_dai); + +static int wm8731_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + wm8731_write(codec, WM8731_ACTIVE, 0x0); + wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold); + return 0; +} + +static int wm8731_resume(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + int i; + u8 data[2]; + u16 *cache = codec->reg_cache; + + /* Sync reg_cache with the hardware */ + for (i = 0; i < ARRAY_SIZE(wm8731_reg); i++) { + data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001); + data[1] = cache[i] & 0x00ff; + codec->hw_write(codec->control_data, data, 2); + } + wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot); + wm8731_dapm_event(codec, codec->suspend_dapm_state); + return 0; +} + +/* + * initialise the WM8731 driver + * register the mixer and dsp interfaces with the kernel + */ +static int wm8731_init(struct snd_soc_device *socdev) +{ + struct snd_soc_codec *codec = socdev->codec; + int reg, ret = 0; + + codec->name = "WM8731"; + codec->owner = THIS_MODULE; + codec->read = wm8731_read_reg_cache; + codec->write = wm8731_write; + codec->dapm_event = wm8731_dapm_event; + codec->dai = &wm8731_dai; + codec->num_dai = 1; + codec->reg_cache_size = ARRAY_SIZE(wm8731_reg); + + codec->reg_cache = + kzalloc(sizeof(u16) * ARRAY_SIZE(wm8731_reg), GFP_KERNEL); + if (codec->reg_cache == NULL) + return -ENOMEM; + memcpy(codec->reg_cache, + wm8731_reg, sizeof(u16) * ARRAY_SIZE(wm8731_reg)); + codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm8731_reg); + + wm8731_reset(codec); + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + kfree(codec->reg_cache); + return ret; + } + + /* power on device */ + wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3hot); + + /* set the update bits */ + reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); + wm8731_write(codec, WM8731_LOUT1V, reg | 0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V); + wm8731_write(codec, WM8731_ROUT1V, reg | 0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_LINVOL); + wm8731_write(codec, WM8731_LINVOL, reg | 0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); + wm8731_write(codec, WM8731_RINVOL, reg | 0x0100); + + wm8731_add_controls(codec); + wm8731_add_widgets(codec); + ret = snd_soc_register_card(socdev); + if (ret < 0) { + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); + } + + return ret; +} + +static struct snd_soc_device *wm8731_socdev; + +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + +/* + * WM8731 2 wire address is determined by GPIO5 + * state during powerup. + * low = 0x1a + * high = 0x1b + */ +static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END }; + +/* Magic definition of all other variables and things */ +I2C_CLIENT_INSMOD; + +static struct i2c_driver wm8731_i2c_driver; +static struct i2c_client client_template; + +/* If the i2c layer weren't so broken, we could pass this kind of data + around */ + +static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind) +{ + struct snd_soc_device *socdev = wm8731_socdev; + struct wm8731_setup_data *setup = socdev->codec_data; + struct snd_soc_codec *codec = socdev->codec; + struct i2c_client *i2c; + int ret; + + if (addr != setup->i2c_address) + return -ENODEV; + + client_template.adapter = adap; + client_template.addr = addr; + + i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + if (i2c == NULL) { + kfree(codec); + return -ENOMEM; + } + memcpy(i2c, &client_template, sizeof(struct i2c_client)); + i2c_set_clientdata(i2c, codec); + codec->control_data = i2c; + + ret = i2c_attach_client(i2c); + if (ret < 0) { + err("failed to attach codec at addr %x\n", addr); + goto err; + } + + ret = wm8731_init(socdev); + if (ret < 0) { + err("failed to initialise WM8731\n"); + goto err; + } + return ret; + +err: + kfree(codec); + kfree(i2c); + return ret; +} + +static int wm8731_i2c_detach(struct i2c_client *client) +{ + struct snd_soc_codec* codec = i2c_get_clientdata(client); + i2c_detach_client(client); + kfree(codec->reg_cache); + kfree(client); + return 0; +} + +static int wm8731_i2c_attach(struct i2c_adapter *adap) +{ + return i2c_probe(adap, &addr_data, wm8731_codec_probe); +} + +/* corgi i2c codec control layer */ +static struct i2c_driver wm8731_i2c_driver = { + .driver = { + .name = "WM8731 I2C Codec", + .owner = THIS_MODULE, + }, + .id = I2C_DRIVERID_WM8731, + .attach_adapter = wm8731_i2c_attach, + .detach_client = wm8731_i2c_detach, + .command = NULL, +}; + +static struct i2c_client client_template = { + .name = "WM8731", + .driver = &wm8731_i2c_driver, +}; +#endif + +static int wm8731_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct wm8731_setup_data *setup; + struct snd_soc_codec *codec; + int ret = 0; + + info("WM8731 Audio Codec %s", WM8731_VERSION); + + setup = socdev->codec_data; + codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (codec == NULL) + return -ENOMEM; + + socdev->codec = codec; + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + wm8731_socdev = socdev; +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + if (setup->i2c_address) { + normal_i2c[0] = setup->i2c_address; + codec->hw_write = (hw_write_t)i2c_master_send; + ret = i2c_add_driver(&wm8731_i2c_driver); + if (ret != 0) + printk(KERN_ERR "can't add i2c driver"); + } +#else + /* Add other interfaces here */ +#endif + return ret; +} + +/* power down chip */ +static int wm8731_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + if (codec->control_data) + wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold); + + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + i2c_del_driver(&wm8731_i2c_driver); +#endif + kfree(codec); + + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm8731 = { + .probe = wm8731_probe, + .remove = wm8731_remove, + .suspend = wm8731_suspend, + .resume = wm8731_resume, +}; + +EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); + +MODULE_DESCRIPTION("ASoC WM8731 driver"); +MODULE_AUTHOR("Richard Purdie"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h new file mode 100644 index 0000000..8fa0f53 --- /dev/null +++ b/sound/soc/codecs/wm8731.h @@ -0,0 +1,41 @@ +/* + * wm8731.h -- WM8731 Soc Audio driver + * + * Copyright 2005 Openedhand Ltd. + * + * Author: Richard Purdie + * + * Based on wm8753.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _WM8731_H +#define _WM8731_H + +/* WM8731 register space */ + +#define WM8731_LINVOL 0x00 +#define WM8731_RINVOL 0x01 +#define WM8731_LOUT1V 0x02 +#define WM8731_ROUT1V 0x03 +#define WM8731_APANA 0x04 +#define WM8731_APDIGI 0x05 +#define WM8731_PWR 0x06 +#define WM8731_IFACE 0x07 +#define WM8731_SRATE 0x08 +#define WM8731_ACTIVE 0x09 +#define WM8731_RESET 0x0f + +#define WM8731_CACHEREGNUM 10 + +struct wm8731_setup_data { + unsigned short i2c_address; +}; + +extern struct snd_soc_codec_dai wm8731_dai; +extern struct snd_soc_codec_device soc_codec_dev_wm8731; + +#endif diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c new file mode 100644 index 0000000..e7f04b8 --- /dev/null +++ b/sound/soc/codecs/wm8750.c @@ -0,0 +1,1273 @@ +/* + * wm8750.c -- WM8750 ALSA SoC audio driver + * + * Copyright 2005 Openedhand Ltd. + * + * Author: Richard Purdie + * + * Based on WM8753.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wm8750.h" + +#define AUDIO_NAME "WM8750" +#define WM8750_VERSION "0.11" + +/* + * Debug + */ + +#define WM8750_DEBUG 0 + +#ifdef WM8750_DEBUG +#define dbg(format, arg...) \ + printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg) +#else +#define dbg(format, arg...) do {} while (0) +#endif +#define err(format, arg...) \ + printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg) +#define info(format, arg...) \ + printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg) +#define warn(format, arg...) \ + printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg) + +/* + * wm8750 register cache + * We can't read the WM8750 register space when we + * are using 2 wire for device control, so we cache them instead. + */ +static const u16 wm8750_reg[] = { + 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ + 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ + 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ + 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ + 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ + 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ + 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ + 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ + 0x0079, 0x0079, 0x0079, /* 40 */ +}; + +#define WM8750_HIFI_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_RIGHT_J | \ + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_IB_NF | \ + SND_SOC_DAIFMT_IB_IF) + +#define WM8750_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define WM8750_HIFI_FSB \ + (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \ + SND_SOC_FSBD(8) | SND_SOC_FSBD(16)) + +#define WM8750_HIFI_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + +#define WM8750_HIFI_BITS \ + (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) + +static struct snd_soc_dai_mode wm8750_modes[] = { + /* common codec frame and clock master modes */ + /* 8k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1536, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1408, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 2304, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 2112, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1500, + .bfs = WM8750_HIFI_FSB, + }, + + /* 11.025k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_11025, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1024, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_11025, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1536, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_11025, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1088, + .bfs = WM8750_HIFI_FSB, + }, + + /* 16k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 768, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 1152, + .bfs = WM8750_HIFI_FSB + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 750, + .bfs = WM8750_HIFI_FSB, + }, + + /* 22.05k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_22050, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 512, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_22050, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 768, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_22050, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 544, + .bfs = WM8750_HIFI_FSB, + }, + + /* 32k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 384, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 576, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_32000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 375, + .bfs = WM8750_HIFI_FSB, + }, + + /* 44.1k & 48k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 384, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_44100, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 272, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 250, + .bfs = WM8750_HIFI_FSB, + }, + + /* 88.2k & 96k */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 128, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 192, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_88200, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 136, + .bfs = WM8750_HIFI_FSB, + }, + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = SNDRV_PCM_RATE_96000, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 125, + .bfs = WM8750_HIFI_FSB, + }, + + /* codec frame and clock slave modes */ + { + .fmt = WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = WM8750_HIFI_BITS, + .pcmrate = WM8750_HIFI_RATES, + .pcmdir = WM8750_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = SND_SOC_FS_ALL, + .bfs = SND_SOC_FSB_ALL, + }, +}; + +/* + * read wm8750 register cache + */ +static inline unsigned int wm8750_read_reg_cache(struct snd_soc_codec *codec, + unsigned int reg) +{ + u16 *cache = codec->reg_cache; + if (reg > WM8750_CACHE_REGNUM) + return -1; + return cache[reg]; +} + +/* + * write wm8750 register cache + */ +static inline void wm8750_write_reg_cache(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) +{ + u16 *cache = codec->reg_cache; + if (reg > WM8750_CACHE_REGNUM) + return; + cache[reg] = value; +} + +static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + u8 data[2]; + + /* data is + * D15..D9 WM8753 register offset + * D8...D0 register data + */ + data[0] = (reg << 1) | ((value >> 8) & 0x0001); + data[1] = value & 0x00ff; + + wm8750_write_reg_cache (codec, reg, value); + if (codec->hw_write(codec->control_data, data, 2) == 2) + return 0; + else + return -EIO; +} + +#define wm8750_reset(c) wm8750_write(c, WM8750_RESET, 0) + +/* + * WM8750 Controls + */ +static const char *wm8750_bass[] = {"Linear Control", "Adaptive Boost"}; +static const char *wm8750_bass_filter[] = { "130Hz @ 48kHz", "200Hz @ 48kHz" }; +static const char *wm8750_treble[] = {"8kHz", "4kHz"}; +static const char *wm8750_3d_lc[] = {"200Hz", "500Hz"}; +static const char *wm8750_3d_uc[] = {"2.2kHz", "1.5kHz"}; +static const char *wm8750_3d_func[] = {"Capture", "Playback"}; +static const char *wm8750_alc_func[] = {"Off", "Right", "Left", "Stereo"}; +static const char *wm8750_ng_type[] = {"Constant PGA Gain", + "Mute ADC Output"}; +static const char *wm8750_line_mux[] = {"Line 1", "Line 2", "Line 3", "PGA", + "Differential"}; +static const char *wm8750_pga_sel[] = {"Line 1", "Line 2", "Line 3", + "Differential"}; +static const char *wm8750_out3[] = {"VREF", "ROUT1 + Vol", "MonoOut", + "ROUT1"}; +static const char *wm8750_diff_sel[] = {"Line 1", "Line 2"}; +static const char *wm8750_adcpol[] = {"Normal", "L Invert", "R Invert", + "L + R Invert"}; +static const char *wm8750_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"}; +static const char *wm8750_mono_mux[] = {"Stereo", "Mono (Left)", + "Mono (Right)", "Digital Mono"}; + +static const struct soc_enum wm8750_enum[] = { +SOC_ENUM_SINGLE(WM8750_BASS, 7, 2, wm8750_bass), +SOC_ENUM_SINGLE(WM8750_BASS, 6, 2, wm8750_bass_filter), +SOC_ENUM_SINGLE(WM8750_TREBLE, 6, 2, wm8750_treble), +SOC_ENUM_SINGLE(WM8750_3D, 5, 2, wm8750_3d_lc), +SOC_ENUM_SINGLE(WM8750_3D, 6, 2, wm8750_3d_uc), +SOC_ENUM_SINGLE(WM8750_3D, 7, 2, wm8750_3d_func), +SOC_ENUM_SINGLE(WM8750_ALC1, 7, 4, wm8750_alc_func), +SOC_ENUM_SINGLE(WM8750_NGATE, 1, 2, wm8750_ng_type), +SOC_ENUM_SINGLE(WM8750_LOUTM1, 0, 5, wm8750_line_mux), +SOC_ENUM_SINGLE(WM8750_ROUTM1, 0, 5, wm8750_line_mux), +SOC_ENUM_SINGLE(WM8750_LADCIN, 6, 4, wm8750_pga_sel), /* 10 */ +SOC_ENUM_SINGLE(WM8750_RADCIN, 6, 4, wm8750_pga_sel), +SOC_ENUM_SINGLE(WM8750_ADCTL2, 7, 4, wm8750_out3), +SOC_ENUM_SINGLE(WM8750_ADCIN, 8, 2, wm8750_diff_sel), +SOC_ENUM_SINGLE(WM8750_ADCDAC, 5, 4, wm8750_adcpol), +SOC_ENUM_SINGLE(WM8750_ADCDAC, 1, 4, wm8750_deemph), +SOC_ENUM_SINGLE(WM8750_ADCIN, 6, 4, wm8750_mono_mux), /* 16 */ + +}; + +static const struct snd_kcontrol_new wm8750_snd_controls[] = { + +SOC_DOUBLE_R("Capture Volume", WM8750_LINVOL, WM8750_RINVOL, 0, 63, 0), +SOC_DOUBLE_R("Capture ZC Switch", WM8750_LINVOL, WM8750_RINVOL, 6, 1, 0), +SOC_DOUBLE_R("Capture Switch", WM8750_LINVOL, WM8750_RINVOL, 7, 1, 1), + +SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8750_LOUT1V, + WM8750_ROUT1V, 7, 1, 0), +SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8750_LOUT2V, + WM8750_ROUT2V, 7, 1, 0), + +SOC_ENUM("Playback De-emphasis", wm8750_enum[15]), + +SOC_ENUM("Capture Polarity", wm8750_enum[14]), +SOC_SINGLE("Playback 6dB Attenuate", WM8750_ADCDAC, 7, 1, 0), +SOC_SINGLE("Capture 6dB Attenuate", WM8750_ADCDAC, 8, 1, 0), + +SOC_DOUBLE_R("PCM Volume", WM8750_LDAC, WM8750_RDAC, 0, 255, 0), + +SOC_ENUM("Bass Boost", wm8750_enum[0]), +SOC_ENUM("Bass Filter", wm8750_enum[1]), +SOC_SINGLE("Bass Volume", WM8750_BASS, 0, 15, 1), + +SOC_SINGLE("Treble Volume", WM8750_TREBLE, 0, 15, 0), +SOC_ENUM("Treble Cut-off", wm8750_enum[2]), + +SOC_SINGLE("3D Switch", WM8750_3D, 0, 1, 0), +SOC_SINGLE("3D Volume", WM8750_3D, 1, 15, 0), +SOC_ENUM("3D Lower Cut-off", wm8750_enum[3]), +SOC_ENUM("3D Upper Cut-off", wm8750_enum[4]), +SOC_ENUM("3D Mode", wm8750_enum[5]), + +SOC_SINGLE("ALC Capture Target Volume", WM8750_ALC1, 0, 7, 0), +SOC_SINGLE("ALC Capture Max Volume", WM8750_ALC1, 4, 7, 0), +SOC_ENUM("ALC Capture Function", wm8750_enum[6]), +SOC_SINGLE("ALC Capture ZC Switch", WM8750_ALC2, 7, 1, 0), +SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0), +SOC_SINGLE("ALC Capture Decay Time", WM8750_ALC3, 4, 15, 0), +SOC_SINGLE("ALC Capture Attack Time", WM8750_ALC3, 0, 15, 0), +SOC_SINGLE("ALC Capture NG Threshold", WM8750_NGATE, 3, 31, 0), +SOC_ENUM("ALC Capture NG Type", wm8750_enum[4]), +SOC_SINGLE("ALC Capture NG Switch", WM8750_NGATE, 0, 1, 0), + +SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0), +SOC_SINGLE("Right ADC Capture Volume", WM8750_RADC, 0, 255, 0), + +SOC_SINGLE("ZC Timeout Switch", WM8750_ADCTL1, 0, 1, 0), +SOC_SINGLE("Playback Invert Switch", WM8750_ADCTL1, 1, 1, 0), + +SOC_SINGLE("Right Speaker Playback Invert Switch", WM8750_ADCTL2, 4, 1, 0), + +/* Unimplemented */ +/* ADCDAC Bit 0 - ADCHPD */ +/* ADCDAC Bit 4 - HPOR */ +/* ADCTL1 Bit 2,3 - DATSEL */ +/* ADCTL1 Bit 4,5 - DMONOMIX */ +/* ADCTL1 Bit 6,7 - VSEL */ +/* ADCTL2 Bit 2 - LRCM */ +/* ADCTL2 Bit 3 - TRI */ +/* ADCTL3 Bit 5 - HPFLREN */ +/* ADCTL3 Bit 6 - VROI */ +/* ADCTL3 Bit 7,8 - ADCLRM */ +/* ADCIN Bit 4 - LDCM */ +/* ADCIN Bit 5 - RDCM */ + +SOC_DOUBLE_R("Mic Boost", WM8750_LADCIN, WM8750_RADCIN, 4, 3, 0), + +SOC_DOUBLE_R("Bypass Left Playback Volume", WM8750_LOUTM1, + WM8750_LOUTM2, 4, 7, 1), +SOC_DOUBLE_R("Bypass Right Playback Volume", WM8750_ROUTM1, + WM8750_ROUTM2, 4, 7, 1), +SOC_DOUBLE_R("Bypass Mono Playback Volume", WM8750_MOUTM1, + WM8750_MOUTM2, 4, 7, 1), + +SOC_SINGLE("Mono Playback ZC Switch", WM8750_MOUTV, 7, 1, 0), + +SOC_DOUBLE_R("Headphone Playback Volume", WM8750_LOUT1V, WM8750_ROUT1V, + 0, 127, 0), +SOC_DOUBLE_R("Speaker Playback Volume", WM8750_LOUT2V, WM8750_ROUT2V, + 0, 127, 0), + +SOC_SINGLE("Mono Playback Volume", WM8750_MOUTV, 0, 127, 0), + +}; + +/* add non dapm controls */ +static int wm8750_add_controls(struct snd_soc_codec *codec) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8750_snd_controls[i],codec, NULL)); + if (err < 0) + return err; + } + return 0; +} + +/* + * DAPM Controls + */ + +/* Left Mixer */ +static const struct snd_kcontrol_new wm8750_left_mixer_controls[] = { +SOC_DAPM_SINGLE("Playback Switch", WM8750_LOUTM1, 8, 1, 0), +SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_LOUTM1, 7, 1, 0), +SOC_DAPM_SINGLE("Right Playback Switch", WM8750_LOUTM2, 8, 1, 0), +SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_LOUTM2, 7, 1, 0), +}; + +/* Right Mixer */ +static const struct snd_kcontrol_new wm8750_right_mixer_controls[] = { +SOC_DAPM_SINGLE("Left Playback Switch", WM8750_ROUTM1, 8, 1, 0), +SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_ROUTM1, 7, 1, 0), +SOC_DAPM_SINGLE("Playback Switch", WM8750_ROUTM2, 8, 1, 0), +SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_ROUTM2, 7, 1, 0), +}; + +/* Mono Mixer */ +static const struct snd_kcontrol_new wm8750_mono_mixer_controls[] = { +SOC_DAPM_SINGLE("Left Playback Switch", WM8750_MOUTM1, 8, 1, 0), +SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_MOUTM1, 7, 1, 0), +SOC_DAPM_SINGLE("Right Playback Switch", WM8750_MOUTM2, 8, 1, 0), +SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_MOUTM2, 7, 1, 0), +}; + +/* Left Line Mux */ +static const struct snd_kcontrol_new wm8750_left_line_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[8]); + +/* Right Line Mux */ +static const struct snd_kcontrol_new wm8750_right_line_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[9]); + +/* Left PGA Mux */ +static const struct snd_kcontrol_new wm8750_left_pga_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[10]); + +/* Right PGA Mux */ +static const struct snd_kcontrol_new wm8750_right_pga_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[11]); + +/* Out 3 Mux */ +static const struct snd_kcontrol_new wm8750_out3_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[12]); + +/* Differential Mux */ +static const struct snd_kcontrol_new wm8750_diffmux_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[13]); + +/* Mono ADC Mux */ +static const struct snd_kcontrol_new wm8750_monomux_controls = +SOC_DAPM_ENUM("Route", wm8750_enum[16]); + +static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { + SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0, + &wm8750_left_mixer_controls[0], + ARRAY_SIZE(wm8750_left_mixer_controls)), + SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0, + &wm8750_right_mixer_controls[0], + ARRAY_SIZE(wm8750_right_mixer_controls)), + SND_SOC_DAPM_MIXER("Mono Mixer", WM8750_PWR2, 2, 0, + &wm8750_mono_mixer_controls[0], + ARRAY_SIZE(wm8750_mono_mixer_controls)), + + SND_SOC_DAPM_PGA("Right Out 2", WM8750_PWR2, 3, 0, NULL, 0), + SND_SOC_DAPM_PGA("Left Out 2", WM8750_PWR2, 4, 0, NULL, 0), + SND_SOC_DAPM_PGA("Right Out 1", WM8750_PWR2, 5, 0, NULL, 0), + SND_SOC_DAPM_PGA("Left Out 1", WM8750_PWR2, 6, 0, NULL, 0), + SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8750_PWR2, 7, 0), + SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8750_PWR2, 8, 0), + + SND_SOC_DAPM_MICBIAS("Mic Bias", WM8750_PWR1, 1, 0), + SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8750_PWR1, 2, 0), + SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8750_PWR1, 3, 0), + + SND_SOC_DAPM_MUX("Left PGA Mux", WM8750_PWR1, 5, 0, + &wm8750_left_pga_controls), + SND_SOC_DAPM_MUX("Right PGA Mux", WM8750_PWR1, 4, 0, + &wm8750_right_pga_controls), + SND_SOC_DAPM_MUX("Left Line Mux", SND_SOC_NOPM, 0, 0, + &wm8750_left_line_controls), + SND_SOC_DAPM_MUX("Right Line Mux", SND_SOC_NOPM, 0, 0, + &wm8750_right_line_controls), + + SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8750_out3_controls), + SND_SOC_DAPM_PGA("Out 3", WM8750_PWR2, 1, 0, NULL, 0), + SND_SOC_DAPM_PGA("Mono Out 1", WM8750_PWR2, 2, 0, NULL, 0), + + SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0, + &wm8750_diffmux_controls), + SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0, + &wm8750_monomux_controls), + SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0, + &wm8750_monomux_controls), + + SND_SOC_DAPM_OUTPUT("LOUT1"), + SND_SOC_DAPM_OUTPUT("ROUT1"), + SND_SOC_DAPM_OUTPUT("LOUT2"), + SND_SOC_DAPM_OUTPUT("ROUT2"), + SND_SOC_DAPM_OUTPUT("MONO"), + SND_SOC_DAPM_OUTPUT("OUT3"), + + SND_SOC_DAPM_INPUT("LINPUT1"), + SND_SOC_DAPM_INPUT("LINPUT2"), + SND_SOC_DAPM_INPUT("LINPUT3"), + SND_SOC_DAPM_INPUT("RINPUT1"), + SND_SOC_DAPM_INPUT("RINPUT2"), + SND_SOC_DAPM_INPUT("RINPUT3"), +}; + +static const char *audio_map[][3] = { + /* left mixer */ + {"Left Mixer", "Playback Switch", "Left DAC"}, + {"Left Mixer", "Left Bypass Switch", "Left Line Mux"}, + {"Left Mixer", "Right Playback Switch", "Right DAC"}, + {"Left Mixer", "Right Bypass Switch", "Right Line Mux"}, + + /* right mixer */ + {"Right Mixer", "Left Playback Switch", "Left DAC"}, + {"Right Mixer", "Left Bypass Switch", "Left Line Mux"}, + {"Right Mixer", "Playback Switch", "Right DAC"}, + {"Right Mixer", "Right Bypass Switch", "Right Line Mux"}, + + /* left out 1 */ + {"Left Out 1", NULL, "Left Mixer"}, + {"LOUT1", NULL, "Left Out 1"}, + + /* left out 2 */ + {"Left Out 2", NULL, "Left Mixer"}, + {"LOUT2", NULL, "Left Out 2"}, + + /* right out 1 */ + {"Right Out 1", NULL, "Right Mixer"}, + {"ROUT1", NULL, "Right Out 1"}, + + /* right out 2 */ + {"Right Out 2", NULL, "Right Mixer"}, + {"ROUT2", NULL, "Right Out 2"}, + + /* mono mixer */ + {"Mono Mixer", "Left Playback Switch", "Left DAC"}, + {"Mono Mixer", "Left Bypass Switch", "Left Line Mux"}, + {"Mono Mixer", "Right Playback Switch", "Right DAC"}, + {"Mono Mixer", "Right Bypass Switch", "Right Line Mux"}, + + /* mono out */ + {"Mono Out 1", NULL, "Mono Mixer"}, + {"MONO1", NULL, "Mono Out 1"}, + + /* out 3 */ + {"Out3 Mux", "VREF", "VREF"}, + {"Out3 Mux", "ROUT1 + Vol", "ROUT1"}, + {"Out3 Mux", "ROUT1", "Right Mixer"}, + {"Out3 Mux", "MonoOut", "MONO1"}, + {"Out 3", NULL, "Out3 Mux"}, + {"OUT3", NULL, "Out 3"}, + + /* Left Line Mux */ + {"Left Line Mux", "Line 1", "LINPUT1"}, + {"Left Line Mux", "Line 2", "LINPUT2"}, + {"Left Line Mux", "Line 3", "LINPUT3"}, + {"Left Line Mux", "PGA", "Left PGA Mux"}, + {"Left Line Mux", "Differential", "Differential Mux"}, + + /* Right Line Mux */ + {"Right Line Mux", "Line 1", "RINPUT1"}, + {"Right Line Mux", "Line 2", "RINPUT2"}, + {"Right Line Mux", "Line 3", "RINPUT3"}, + {"Right Line Mux", "PGA", "Right PGA Mux"}, + {"Right Line Mux", "Differential", "Differential Mux"}, + + /* Left PGA Mux */ + {"Left PGA Mux", "Line 1", "LINPUT1"}, + {"Left PGA Mux", "Line 2", "LINPUT2"}, + {"Left PGA Mux", "Line 3", "LINPUT3"}, + {"Left PGA Mux", "Differential", "Differential Mux"}, + + /* Right PGA Mux */ + {"Right PGA Mux", "Line 1", "RINPUT1"}, + {"Right PGA Mux", "Line 2", "RINPUT2"}, + {"Right PGA Mux", "Line 3", "RINPUT3"}, + {"Right PGA Mux", "Differential", "Differential Mux"}, + + /* Differential Mux */ + {"Differential Mux", "Line 1", "LINPUT1"}, + {"Differential Mux", "Line 1", "RINPUT1"}, + {"Differential Mux", "Line 2", "LINPUT2"}, + {"Differential Mux", "Line 2", "RINPUT2"}, + + /* Left ADC Mux */ + {"Left ADC Mux", "Stereo", "Left PGA Mux"}, + {"Left ADC Mux", "Mono (Left)", "Left PGA Mux"}, + {"Left ADC Mux", "Digital Mono", "Left PGA Mux"}, + + /* Right ADC Mux */ + {"Right ADC Mux", "Stereo", "Right PGA Mux"}, + {"Right ADC Mux", "Mono (Right)", "Right PGA Mux"}, + {"Right ADC Mux", "Digital Mono", "Right PGA Mux"}, + + /* ADC */ + {"Left ADC", NULL, "Left ADC Mux"}, + {"Right ADC", NULL, "Right ADC Mux"}, + + /* terminator */ + {NULL, NULL, NULL}, +}; + +static int wm8750_add_widgets(struct snd_soc_codec *codec) +{ + int i; + + for(i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); + } + + /* set up audio path audio_mapnects */ + for(i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_new_widgets(codec); + return 0; +} + +struct _coeff_div { + u32 mclk; + u32 rate; + u16 fs; + u8 sr:5; + u8 usb:1; +}; + +/* codec hifi mclk clock divider coefficients */ +static const struct _coeff_div coeff_div[] = { + /* 8k */ + {12288000, 8000, 1536, 0x6, 0x0}, + {11289600, 8000, 1408, 0x16, 0x0}, + {18432000, 8000, 2304, 0x7, 0x0}, + {16934400, 8000, 2112, 0x17, 0x0}, + {12000000, 8000, 1500, 0x6, 0x1}, + + /* 11.025k */ + {11289600, 11025, 1024, 0x18, 0x0}, + {16934400, 11025, 1536, 0x19, 0x0}, + {12000000, 11025, 1088, 0x19, 0x1}, + + /* 16k */ + {12288000, 16000, 768, 0xa, 0x0}, + {18432000, 16000, 1152, 0xb, 0x0}, + {12000000, 16000, 750, 0xa, 0x1}, + + /* 22.05k */ + {11289600, 22050, 512, 0x1a, 0x0}, + {16934400, 22050, 768, 0x1b, 0x0}, + {12000000, 22050, 544, 0x1b, 0x1}, + + /* 32k */ + {12288000, 32000, 384, 0xc, 0x0}, + {18432000, 32000, 576, 0xd, 0x0}, + {12000000, 32000, 375, 0xa, 0x1}, + + /* 44.1k */ + {11289600, 44100, 256, 0x10, 0x0}, + {16934400, 44100, 384, 0x11, 0x0}, + {12000000, 44100, 272, 0x11, 0x1}, + + /* 48k */ + {12288000, 48000, 256, 0x0, 0x0}, + {18432000, 48000, 384, 0x1, 0x0}, + {12000000, 48000, 250, 0x0, 0x1}, + + /* 88.2k */ + {11289600, 88200, 128, 0x1e, 0x0}, + {16934400, 88200, 192, 0x1f, 0x0}, + {12000000, 88200, 136, 0x1f, 0x1}, + + /* 96k */ + {12288000, 96000, 128, 0xe, 0x0}, + {18432000, 96000, 192, 0xf, 0x0}, + {12000000, 96000, 125, 0xe, 0x1}, +}; + +static inline int get_coeff(int mclk, int rate) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { + if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) + return i; + } + + printk(KERN_ERR "wm8750: could not get coeff for mclk %d @ rate %d\n", + mclk, rate); + return -EINVAL; +} + +/* WM8750 supports numerous input clocks per sample rate */ +static unsigned int wm8750_config_sysclk(struct snd_soc_codec_dai *dai, + struct snd_soc_clock_info *info, unsigned int clk) +{ + dai->mclk = clk; + return dai->mclk; +} + +static int wm8750_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + u16 iface = 0, bfs, srate = 0; + int i = get_coeff(rtd->codec_dai->mclk, + snd_soc_get_rate(rtd->codec_dai->dai_runtime.pcmrate)); + + /* is coefficient valid ? */ + if (i < 0) + return i; + + bfs = SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs); + + /* set master/slave audio interface */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + iface = 0x0040; + break; + case SND_SOC_DAIFMT_CBS_CFS: + break; + } + + /* interface format */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface |= 0x0002; + break; + case SND_SOC_DAIFMT_RIGHT_J: + break; + case SND_SOC_DAIFMT_LEFT_J: + iface |= 0x0001; + break; + case SND_SOC_DAIFMT_DSP_A: + iface |= 0x0003; + break; + case SND_SOC_DAIFMT_DSP_B: + iface |= 0x0013; + break; + } + + /* bit size */ + switch (rtd->codec_dai->dai_runtime.pcmfmt) { + case SNDRV_PCM_FMTBIT_S16_LE: + break; + case SNDRV_PCM_FMTBIT_S20_3LE: + iface |= 0x0004; + break; + case SNDRV_PCM_FMTBIT_S24_LE: + iface |= 0x0008; + break; + case SNDRV_PCM_FMTBIT_S32_LE: + iface |= 0x000c; + break; + } + + /* clock inversion */ + switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + break; + case SND_SOC_DAIFMT_IB_IF: + iface |= 0x0090; + break; + case SND_SOC_DAIFMT_IB_NF: + iface |= 0x0080; + break; + case SND_SOC_DAIFMT_NB_IF: + iface |= 0x0010; + break; + } + + /* set bclk divisor rate */ + switch (bfs) { + case 1: + break; + case 4: + srate |= (0x1 << 7); + break; + case 8: + srate |= (0x2 << 7); + break; + case 16: + srate |= (0x3 << 7); + break; + } + + /* set iface & srate */ + wm8750_write(codec, WM8750_IFACE, iface); + wm8750_write(codec, WM8750_SRATE, srate | + (coeff_div[i].sr << 1) | coeff_div[i].usb); + + return 0; +} + +static int wm8750_mute(struct snd_soc_codec *codec, + struct snd_soc_codec_dai *dai, int mute) +{ + u16 mute_reg = wm8750_read_reg_cache(codec, WM8750_ADCDAC) & 0xfff7; + if (mute) + wm8750_write(codec, WM8750_ADCDAC, mute_reg | 0x8); + else + wm8750_write(codec, WM8750_ADCDAC, mute_reg); + return 0; +} + +static int wm8750_dapm_event(struct snd_soc_codec *codec, int event) +{ + u16 pwr_reg = wm8750_read_reg_cache(codec, WM8750_PWR1) & 0xfe3e; + + switch (event) { + case SNDRV_CTL_POWER_D0: /* full On */ + /* set vmid to 50k and unmute dac */ + wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x00c0); + break; + case SNDRV_CTL_POWER_D1: /* partial On */ + case SNDRV_CTL_POWER_D2: /* partial On */ + /* set vmid to 5k for quick power up */ + wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x01c1); + break; + case SNDRV_CTL_POWER_D3hot: /* Off, with power */ + /* mute dac and set vmid to 500k, enable VREF */ + wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x0141); + break; + case SNDRV_CTL_POWER_D3cold: /* Off, without power */ + wm8750_write(codec, WM8750_PWR1, 0x0001); + break; + } + codec->dapm_state = event; + return 0; +} + +struct snd_soc_codec_dai wm8750_dai = { + .name = "WM8750", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + }, + .config_sysclk = wm8750_config_sysclk, + .digital_mute = wm8750_mute, + .ops = { + .prepare = wm8750_pcm_prepare, + }, + .caps = { + .num_modes = ARRAY_SIZE(wm8750_modes), + .mode = wm8750_modes, + }, +}; +EXPORT_SYMBOL_GPL(wm8750_dai); + +static void wm8750_work(struct work_struct *work) +{ + struct snd_soc_codec *codec = + container_of(work, struct snd_soc_codec, delayed_work.work); + wm8750_dapm_event(codec, codec->dapm_state); +} + +static int wm8750_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold); + return 0; +} + +static int wm8750_resume(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + int i; + u8 data[2]; + u16 *cache = codec->reg_cache; + + /* Sync reg_cache with the hardware */ + for (i = 0; i < ARRAY_SIZE(wm8750_reg); i++) { + if (i == WM8750_RESET) + continue; + data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001); + data[1] = cache[i] & 0x00ff; + codec->hw_write(codec->control_data, data, 2); + } + + wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot); + + /* charge wm8750 caps */ + if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) { + wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); + codec->dapm_state = SNDRV_CTL_POWER_D0; + schedule_delayed_work(&codec->delayed_work, + msecs_to_jiffies(1000)); + } + + return 0; +} + +/* + * initialise the WM8750 driver + * register the mixer and dsp interfaces with the kernel + */ +static int wm8750_init(struct snd_soc_device *socdev) +{ + struct snd_soc_codec *codec = socdev->codec; + int reg, ret = 0; + + codec->name = "WM8750"; + codec->owner = THIS_MODULE; + codec->read = wm8750_read_reg_cache; + codec->write = wm8750_write; + codec->dapm_event = wm8750_dapm_event; + codec->dai = &wm8750_dai; + codec->num_dai = 1; + codec->reg_cache_size = ARRAY_SIZE(wm8750_reg); + + codec->reg_cache = + kzalloc(sizeof(u16) * ARRAY_SIZE(wm8750_reg), GFP_KERNEL); + if (codec->reg_cache == NULL) + return -ENOMEM; + memcpy(codec->reg_cache, wm8750_reg, + sizeof(u16) * ARRAY_SIZE(wm8750_reg)); + codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm8750_reg); + + wm8750_reset(codec); + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + kfree(codec->reg_cache); + return ret; + } + + /* charge output caps */ + wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); + codec->dapm_state = SNDRV_CTL_POWER_D3hot; + schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000)); + + /* set the update bits */ + reg = wm8750_read_reg_cache(codec, WM8750_LDAC); + wm8750_write(codec, WM8750_LDAC, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_RDAC); + wm8750_write(codec, WM8750_RDAC, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_LOUT1V); + wm8750_write(codec, WM8750_LOUT1V, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_ROUT1V); + wm8750_write(codec, WM8750_ROUT1V, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_LOUT2V); + wm8750_write(codec, WM8750_LOUT2V, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_ROUT2V); + wm8750_write(codec, WM8750_ROUT2V, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_LINVOL); + wm8750_write(codec, WM8750_LINVOL, reg | 0x0100); + reg = wm8750_read_reg_cache(codec, WM8750_RINVOL); + wm8750_write(codec, WM8750_RINVOL, reg | 0x0100); + + wm8750_add_controls(codec); + wm8750_add_widgets(codec); + ret = snd_soc_register_card(socdev); + if (ret < 0) { + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); + } + + return ret; +} + +/* If the i2c layer weren't so broken, we could pass this kind of data + around */ +static struct snd_soc_device *wm8750_socdev; + +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + +/* + * WM8731 2 wire address is determined by GPIO5 + * state during powerup. + * low = 0x1a + * high = 0x1b + */ +static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END }; + +/* Magic definition of all other variables and things */ +I2C_CLIENT_INSMOD; + +static struct i2c_driver wm8750_i2c_driver; +static struct i2c_client client_template; + +static int wm8750_codec_probe(struct i2c_adapter *adap, int addr, int kind) +{ + struct snd_soc_device *socdev = wm8750_socdev; + struct wm8750_setup_data *setup = socdev->codec_data; + struct snd_soc_codec *codec = socdev->codec; + struct i2c_client *i2c; + int ret; + + if (addr != setup->i2c_address) + return -ENODEV; + + client_template.adapter = adap; + client_template.addr = addr; + + i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); + if (i2c == NULL) { + kfree(codec); + return -ENOMEM; + } + memcpy(i2c, &client_template, sizeof(struct i2c_client)); + i2c_set_clientdata(i2c, codec); + codec->control_data = i2c; + + ret = i2c_attach_client(i2c); + if (ret < 0) { + err("failed to attach codec at addr %x\n", addr); + goto err; + } + + ret = wm8750_init(socdev); + if (ret < 0) { + err("failed to initialise WM8750\n"); + goto err; + } + return ret; + +err: + kfree(codec); + kfree(i2c); + return ret; +} + +static int wm8750_i2c_detach(struct i2c_client *client) +{ + struct snd_soc_codec *codec = i2c_get_clientdata(client); + i2c_detach_client(client); + kfree(codec->reg_cache); + kfree(client); + return 0; +} + +static int wm8750_i2c_attach(struct i2c_adapter *adap) +{ + return i2c_probe(adap, &addr_data, wm8750_codec_probe); +} + +/* corgi i2c codec control layer */ +static struct i2c_driver wm8750_i2c_driver = { + .driver = { + .name = "WM8750 I2C Codec", + .owner = THIS_MODULE, + }, + .id = I2C_DRIVERID_WM8750, + .attach_adapter = wm8750_i2c_attach, + .detach_client = wm8750_i2c_detach, + .command = NULL, +}; + +static struct i2c_client client_template = { + .name = "WM8750", + .driver = &wm8750_i2c_driver, +}; +#endif + +static int wm8750_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct wm8750_setup_data *setup = socdev->codec_data; + struct snd_soc_codec *codec; + int ret = 0; + + info("WM8750 Audio Codec %s", WM8750_VERSION); + codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (codec == NULL) + return -ENOMEM; + + socdev->codec = codec; + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + wm8750_socdev = socdev; + INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work); +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + if (setup->i2c_address) { + normal_i2c[0] = setup->i2c_address; + codec->hw_write = (hw_write_t)i2c_master_send; + ret = i2c_add_driver(&wm8750_i2c_driver); + if (ret != 0) + printk(KERN_ERR "can't add i2c driver"); + } +#else + /* Add other interfaces here */ +#endif + + return ret; +} + +/* power down chip */ +static int wm8750_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + if (codec->control_data) + wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold); + flush_scheduled_work(); + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); +#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) + i2c_del_driver(&wm8750_i2c_driver); +#endif + kfree(codec); + + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm8750 = { + .probe = wm8750_probe, + .remove = wm8750_remove, + .suspend = wm8750_suspend, + .resume = wm8750_resume, +}; + +EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750); + +MODULE_DESCRIPTION("ASoC WM8750 driver"); +MODULE_AUTHOR("Liam Girdwood"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/wm8750.h b/sound/soc/codecs/wm8750.h new file mode 100644 index 0000000..ee5eea4 --- /dev/null +++ b/sound/soc/codecs/wm8750.h @@ -0,0 +1,66 @@ +/* + * Copyright 2005 Openedhand Ltd. + * + * Author: Richard Purdie + * + * Based on WM8753.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef _WM8750_H +#define _WM8750_H + +/* WM8750 register space */ + +#define WM8750_LINVOL 0x00 +#define WM8750_RINVOL 0x01 +#define WM8750_LOUT1V 0x02 +#define WM8750_ROUT1V 0x03 +#define WM8750_ADCDAC 0x05 +#define WM8750_IFACE 0x07 +#define WM8750_SRATE 0x08 +#define WM8750_LDAC 0x0a +#define WM8750_RDAC 0x0b +#define WM8750_BASS 0x0c +#define WM8750_TREBLE 0x0d +#define WM8750_RESET 0x0f +#define WM8750_3D 0x10 +#define WM8750_ALC1 0x11 +#define WM8750_ALC2 0x12 +#define WM8750_ALC3 0x13 +#define WM8750_NGATE 0x14 +#define WM8750_LADC 0x15 +#define WM8750_RADC 0x16 +#define WM8750_ADCTL1 0x17 +#define WM8750_ADCTL2 0x18 +#define WM8750_PWR1 0x19 +#define WM8750_PWR2 0x1a +#define WM8750_ADCTL3 0x1b +#define WM8750_ADCIN 0x1f +#define WM8750_LADCIN 0x20 +#define WM8750_RADCIN 0x21 +#define WM8750_LOUTM1 0x22 +#define WM8750_LOUTM2 0x23 +#define WM8750_ROUTM1 0x24 +#define WM8750_ROUTM2 0x25 +#define WM8750_MOUTM1 0x26 +#define WM8750_MOUTM2 0x27 +#define WM8750_LOUT2V 0x28 +#define WM8750_ROUT2V 0x29 +#define WM8750_MOUTV 0x2a + +#define WM8750_CACHE_REGNUM 0x2a + +struct wm8750_setup_data { + unsigned short i2c_address; + unsigned int mclk; +}; + +extern struct snd_soc_codec_dai wm8750_dai; +extern struct snd_soc_codec_device soc_codec_dev_wm8750; + +#endif diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c new file mode 100644 index 0000000..36c6a38 --- /dev/null +++ b/sound/soc/codecs/wm9712.c @@ -0,0 +1,781 @@ +/* + * wm9712.c -- ALSA Soc WM9712 codec support + * + * Copyright 2006 Wolfson Microelectronics PLC. + * Author: Liam Girdwood + * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 4th Feb 2006 Initial version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WM9712_VERSION "0.4" + +static unsigned int ac97_read(struct snd_soc_codec *codec, + unsigned int reg); +static int ac97_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int val); + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode ac97_modes[] = { + { + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE, + .pcmrate = AC97_RATES, + .pcmdir = AC97_DIR, + }, +}; + +/* + * WM9712 register cache + */ +static const u16 wm9712_reg[] = { + 0x6174, 0x8000, 0x8000, 0x8000, // 6 + 0xf0f0, 0xaaa0, 0xc008, 0x6808, // e + 0xe808, 0xaaa0, 0xad00, 0x8000, // 16 + 0xe808, 0x3000, 0x8000, 0x0000, // 1e + 0x0000, 0x0000, 0x0000, 0x000f, // 26 + 0x0405, 0x0410, 0xbb80, 0xbb80, // 2e + 0x0000, 0xbb80, 0x0000, 0x0000, // 36 + 0x0000, 0x2000, 0x0000, 0x0000, // 3e + 0x0000, 0x0000, 0x0000, 0x0000, // 46 + 0x0000, 0x0000, 0xf83e, 0xffff, // 4e + 0x0000, 0x0000, 0x0000, 0xf83e, // 56 + 0x0008, 0x0000, 0x0000, 0x0000, // 5e + 0xb032, 0x3e00, 0x0000, 0x0000, // 66 + 0x0000, 0x0000, 0x0000, 0x0000, // 6e + 0x0000, 0x0000, 0x0000, 0x0006, // 76 + 0x0001, 0x0000, 0x574d, 0x4c12, // 7e + 0x0000, 0x0000 // virtual hp mixers +}; + +/* virtual HP mixers regs */ +#define HPL_MIXER 0x80 +#define HPR_MIXER 0x82 + +static const char *wm9712_alc_select[] = {"None", "Left", "Right", "Stereo"}; +static const char *wm9712_alc_mux[] = {"Stereo", "Left", "Right", "None"}; +static const char *wm9712_out3_src[] = {"Left", "VREF", "Left + Right", + "Mono"}; +static const char *wm9712_spk_src[] = {"Speaker Mix", "Headphone Mix"}; +static const char *wm9712_rec_adc[] = {"Stereo", "Left", "Right", "Mute"}; +static const char *wm9712_base[] = {"Linear Control", "Adaptive Boost"}; +static const char *wm9712_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; +static const char *wm9712_mic[] = {"Mic 1", "Differential", "Mic 2", + "Stereo"}; +static const char *wm9712_rec_sel[] = {"Mic", "NC", "NC", "Speaker Mixer", + "Line", "Headphone Mixer", "Phone Mixer", "Phone"}; +static const char *wm9712_ng_type[] = {"Constant Gain", "Mute"}; +static const char *wm9712_diff_sel[] = {"Mic", "Line"}; + +static const struct soc_enum wm9712_enum[] = { +SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9712_alc_select), +SOC_ENUM_SINGLE(AC97_VIDEO, 12, 4, wm9712_alc_mux), +SOC_ENUM_SINGLE(AC97_AUX, 9, 4, wm9712_out3_src), +SOC_ENUM_SINGLE(AC97_AUX, 8, 2, wm9712_spk_src), +SOC_ENUM_SINGLE(AC97_REC_SEL, 12, 4, wm9712_rec_adc), +SOC_ENUM_SINGLE(AC97_MASTER_TONE, 15, 2, wm9712_base), +SOC_ENUM_DOUBLE(AC97_REC_GAIN, 14, 6, 2, wm9712_rec_gain), +SOC_ENUM_SINGLE(AC97_MIC, 5, 4, wm9712_mic), +SOC_ENUM_SINGLE(AC97_REC_SEL, 8, 8, wm9712_rec_sel), +SOC_ENUM_SINGLE(AC97_REC_SEL, 0, 8, wm9712_rec_sel), +SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9712_ng_type), +SOC_ENUM_SINGLE(0x5c, 8, 2, wm9712_diff_sel), +}; + +static const struct snd_kcontrol_new wm9712_snd_ac97_controls[] = { +SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1), +SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1), +SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), +SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE,15, 1, 1), + +SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0), +SOC_SINGLE("Speaker Playback Invert Switch", AC97_MASTER, 6, 1, 0), +SOC_SINGLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 7, 1, 0), +SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_MONO, 7, 1, 0), +SOC_SINGLE("Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 0), + +SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0), +SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0), +SOC_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_REV, 4, 15, 0), +SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS_REV, 0, 15, 0), +SOC_ENUM("ALC Function", wm9712_enum[0]), +SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11, 7, 0), +SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 3, 1), +SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0), +SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0), +SOC_ENUM("ALC NG Type", wm9712_enum[10]), +SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 0, 31, 1), + +SOC_SINGLE("Mic Headphone Volume", AC97_VIDEO, 12, 7, 1), +SOC_SINGLE("ALC Headphone Volume", AC97_VIDEO, 7, 7, 1), + +SOC_SINGLE("Out3 Switch", AC97_AUX, 15, 1, 1), +SOC_SINGLE("Out3 ZC Switch", AC97_AUX, 7, 1, 1), +SOC_SINGLE("Out3 Volume", AC97_AUX, 0, 31, 1), + +SOC_SINGLE("PCBeep Bypass Headphone Volume", AC97_PC_BEEP, 12, 7, 1), +SOC_SINGLE("PCBeep Bypass Speaker Volume", AC97_PC_BEEP, 8, 7, 1), +SOC_SINGLE("PCBeep Bypass Phone Volume", AC97_PC_BEEP, 4, 7, 1), + +SOC_SINGLE("Aux Playback Headphone Volume", AC97_CD, 12, 7, 1), +SOC_SINGLE("Aux Playback Speaker Volume", AC97_CD, 8, 7, 1), +SOC_SINGLE("Aux Playback Phone Volume", AC97_CD, 4, 7, 1), + +SOC_SINGLE("Phone Volume", AC97_PHONE, 0, 15, 0), +SOC_DOUBLE("Line Capture Volume", AC97_LINE, 8, 0, 31, 1), + +SOC_SINGLE("Capture 20dB Boost Switch", AC97_REC_SEL, 14, 1, 0), +SOC_SINGLE("Capture to Phone 20dB Boost Switch", AC97_REC_SEL, 11, 1, 1), + +SOC_SINGLE("3D Upper Cut-off Switch", AC97_3D_CONTROL, 5, 1, 1), +SOC_SINGLE("3D Lower Cut-off Switch", AC97_3D_CONTROL, 4, 1, 1), +SOC_SINGLE("3D Playback Volume", AC97_3D_CONTROL, 0, 15, 0), + +SOC_ENUM("Bass Control", wm9712_enum[5]), +SOC_SINGLE("Bass Cut-off Switch", AC97_MASTER_TONE, 12, 1, 1), +SOC_SINGLE("Tone Cut-off Switch", AC97_MASTER_TONE, 4, 1, 1), +SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_MASTER_TONE, 6, 1, 0), +SOC_SINGLE("Bass Volume", AC97_MASTER_TONE, 8, 15, 0), +SOC_SINGLE("Treble Volume", AC97_MASTER_TONE, 0, 15, 0), + +SOC_SINGLE("Capture ADC Switch", AC97_REC_GAIN, 15, 1, 1), +SOC_ENUM("Capture Volume Steps", wm9712_enum[6]), +SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 63, 1), +SOC_SINGLE("Capture ZC Switch", AC97_REC_GAIN, 7, 1, 0), + +SOC_SINGLE("Mic 1 Volume", AC97_MIC, 8, 31, 1), +SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1), +SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0), +}; + +/* add non dapm controls */ +static int wm9712_add_controls(struct snd_soc_codec *codec) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm9712_snd_ac97_controls[i],codec, NULL)); + if (err < 0) + return err; + } + return 0; +} + +/* We have to create a fake left and right HP mixers because + * the codec only has a single control that is shared by both channels. + * This makes it impossible to determine the audio path. + */ +static int mixer_event (struct snd_soc_dapm_widget *w, int event) +{ + u16 l, r, beep, line, phone, mic, pcm, aux; + + l = ac97_read(w->codec, HPL_MIXER); + r = ac97_read(w->codec, HPR_MIXER); + beep = ac97_read(w->codec, AC97_PC_BEEP); + mic = ac97_read(w->codec, AC97_VIDEO); + phone = ac97_read(w->codec, AC97_PHONE); + line = ac97_read(w->codec, AC97_LINE); + pcm = ac97_read(w->codec, AC97_PCM); + aux = ac97_read(w->codec, AC97_CD); + + if (l & 0x1 || r & 0x1) + ac97_write(w->codec, AC97_VIDEO, mic & 0x7fff); + else + ac97_write(w->codec, AC97_VIDEO, mic | 0x8000); + + if (l & 0x2 || r & 0x2) + ac97_write(w->codec, AC97_PCM, pcm & 0x7fff); + else + ac97_write(w->codec, AC97_PCM, pcm | 0x8000); + + if (l & 0x4 || r & 0x4) + ac97_write(w->codec, AC97_LINE, line & 0x7fff); + else + ac97_write(w->codec, AC97_LINE, line | 0x8000); + + if (l & 0x8 || r & 0x8) + ac97_write(w->codec, AC97_PHONE, phone & 0x7fff); + else + ac97_write(w->codec, AC97_PHONE, phone | 0x8000); + + if (l & 0x10 || r & 0x10) + ac97_write(w->codec, AC97_CD, aux & 0x7fff); + else + ac97_write(w->codec, AC97_CD, aux | 0x8000); + + if (l & 0x20 || r & 0x20) + ac97_write(w->codec, AC97_PC_BEEP, beep & 0x7fff); + else + ac97_write(w->codec, AC97_PC_BEEP, beep | 0x8000); + + return 0; +} + +/* Left Headphone Mixers */ +static const struct snd_kcontrol_new wm9712_hpl_mixer_controls[] = { + SOC_DAPM_SINGLE("PCBeep Bypass Switch", HPL_MIXER, 5, 1, 0), + SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 4, 1, 0), + SOC_DAPM_SINGLE("Phone Bypass Switch", HPL_MIXER, 3, 1, 0), + SOC_DAPM_SINGLE("Line Bypass Switch", HPL_MIXER, 2, 1, 0), + SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 1, 1, 0), + SOC_DAPM_SINGLE("Mic Sidetone Switch", HPL_MIXER, 0, 1, 0), +}; + +/* Right Headphone Mixers */ +static const struct snd_kcontrol_new wm9712_hpr_mixer_controls[] = { + SOC_DAPM_SINGLE("PCBeep Bypass Switch", HPR_MIXER, 5, 1, 0), + SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 4, 1, 0), + SOC_DAPM_SINGLE("Phone Bypass Switch", HPR_MIXER, 3, 1, 0), + SOC_DAPM_SINGLE("Line Bypass Switch", HPR_MIXER, 2, 1, 0), + SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 1, 1, 0), + SOC_DAPM_SINGLE("Mic Sidetone Switch", HPR_MIXER, 0, 1, 0), +}; + +/* Speaker Mixer */ +static const struct snd_kcontrol_new wm9712_speaker_mixer_controls[] = { + SOC_DAPM_SINGLE("PCBeep Bypass Switch", AC97_PC_BEEP, 11, 1, 1), + SOC_DAPM_SINGLE("Aux Playback Switch", AC97_CD, 11, 1, 1), + SOC_DAPM_SINGLE("Phone Bypass Switch", AC97_PHONE, 14, 1, 1), + SOC_DAPM_SINGLE("Line Bypass Switch", AC97_LINE, 14, 1, 1), + SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PCM, 14, 1, 1), +}; + +/* Phone Mixer */ +static const struct snd_kcontrol_new wm9712_phone_mixer_controls[] = { + SOC_DAPM_SINGLE("PCBeep Bypass Switch", AC97_PC_BEEP, 7, 1, 1), + SOC_DAPM_SINGLE("Aux Playback Switch", AC97_CD, 7, 1, 1), + SOC_DAPM_SINGLE("Line Bypass Switch", AC97_LINE, 13, 1, 1), + SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PCM, 13, 1, 1), + SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_MIC, 14, 1, 1), + SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_MIC, 13, 1, 1), +}; + +/* ALC headphone mux */ +static const struct snd_kcontrol_new wm9712_alc_mux_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[1]); + +/* out 3 mux */ +static const struct snd_kcontrol_new wm9712_out3_mux_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[2]); + +/* spk mux */ +static const struct snd_kcontrol_new wm9712_spk_mux_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[3]); + +/* Capture to Phone mux */ +static const struct snd_kcontrol_new wm9712_capture_phone_mux_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[4]); + +/* Capture left select */ +static const struct snd_kcontrol_new wm9712_capture_selectl_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[8]); + +/* Capture right select */ +static const struct snd_kcontrol_new wm9712_capture_selectr_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[9]); + +/* Mic select */ +static const struct snd_kcontrol_new wm9712_mic_src_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[7]); + +/* diff select */ +static const struct snd_kcontrol_new wm9712_diff_sel_controls = +SOC_DAPM_ENUM("Route", wm9712_enum[11]); + +static const struct snd_soc_dapm_widget wm9712_dapm_widgets[] = { +SND_SOC_DAPM_MUX("ALC Sidetone Mux", SND_SOC_NOPM, 0, 0, + &wm9712_alc_mux_controls), +SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, + &wm9712_out3_mux_controls), +SND_SOC_DAPM_MUX("Speaker Mux", SND_SOC_NOPM, 0, 0, + &wm9712_spk_mux_controls), +SND_SOC_DAPM_MUX("Capture Phone Mux", SND_SOC_NOPM, 0, 0, + &wm9712_capture_phone_mux_controls), +SND_SOC_DAPM_MUX("Left Capture Select", SND_SOC_NOPM, 0, 0, + &wm9712_capture_selectl_controls), +SND_SOC_DAPM_MUX("Right Capture Select", SND_SOC_NOPM, 0, 0, + &wm9712_capture_selectr_controls), +SND_SOC_DAPM_MUX("Mic Select Source", SND_SOC_NOPM, 0, 0, + &wm9712_mic_src_controls), +SND_SOC_DAPM_MUX("Differential Source", SND_SOC_NOPM, 0, 0, + &wm9712_diff_sel_controls), +SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), +SND_SOC_DAPM_MIXER_E("Left HP Mixer", AC97_INT_PAGING, 9, 1, + &wm9712_hpl_mixer_controls[0], ARRAY_SIZE(wm9712_hpl_mixer_controls), + mixer_event, SND_SOC_DAPM_POST_REG), +SND_SOC_DAPM_MIXER_E("Right HP Mixer", AC97_INT_PAGING, 8, 1, + &wm9712_hpr_mixer_controls[0], ARRAY_SIZE(wm9712_hpr_mixer_controls), + mixer_event, SND_SOC_DAPM_POST_REG), +SND_SOC_DAPM_MIXER("Phone Mixer", AC97_INT_PAGING, 6, 1, + &wm9712_phone_mixer_controls[0], ARRAY_SIZE(wm9712_phone_mixer_controls)), +SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_INT_PAGING, 7, 1, + &wm9712_speaker_mixer_controls[0], + ARRAY_SIZE(wm9712_speaker_mixer_controls)), +SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), +SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", AC97_INT_PAGING, 14, 1), +SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", AC97_INT_PAGING, 13, 1), +SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", SND_SOC_NOPM, 0, 0), +SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", AC97_INT_PAGING, 12, 1), +SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", AC97_INT_PAGING, 11, 1), +SND_SOC_DAPM_PGA("Headphone PGA", AC97_INT_PAGING, 4, 1, NULL, 0), +SND_SOC_DAPM_PGA("Speaker PGA", AC97_INT_PAGING, 3, 1, NULL, 0), +SND_SOC_DAPM_PGA("Out 3 PGA", AC97_INT_PAGING, 5, 1, NULL, 0), +SND_SOC_DAPM_PGA("Line PGA", AC97_INT_PAGING, 2, 1, NULL, 0), +SND_SOC_DAPM_PGA("Phone PGA", AC97_INT_PAGING, 1, 1, NULL, 0), +SND_SOC_DAPM_PGA("Mic PGA", AC97_INT_PAGING, 0, 1, NULL, 0), +SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_INT_PAGING, 10, 1), +SND_SOC_DAPM_OUTPUT("MONOOUT"), +SND_SOC_DAPM_OUTPUT("HPOUTL"), +SND_SOC_DAPM_OUTPUT("HPOUTR"), +SND_SOC_DAPM_OUTPUT("LOUT2"), +SND_SOC_DAPM_OUTPUT("ROUT2"), +SND_SOC_DAPM_OUTPUT("OUT3"), +SND_SOC_DAPM_INPUT("LINEINL"), +SND_SOC_DAPM_INPUT("LINEINR"), +SND_SOC_DAPM_INPUT("PHONE"), +SND_SOC_DAPM_INPUT("PCBEEP"), +SND_SOC_DAPM_INPUT("MIC1"), +SND_SOC_DAPM_INPUT("MIC2"), +}; + +static const char *audio_map[][3] = { + /* virtual mixer - mixes left & right channels for spk and mono */ + {"AC97 Mixer", NULL, "Left DAC"}, + {"AC97 Mixer", NULL, "Right DAC"}, + + /* Left HP mixer */ + {"Left HP Mixer", "PCBeep Bypass Switch", "PCBEEP"}, + {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"}, + {"Left HP Mixer", "Phone Bypass Switch", "Phone PGA"}, + {"Left HP Mixer", "Line Bypass Switch", "Line PGA"}, + {"Left HP Mixer", "PCM Playback Switch", "Left DAC"}, + {"Left HP Mixer", "Mic Sidetone Switch", "Mic PGA"}, + {"Left HP Mixer", NULL, "ALC Sidetone Mux"}, + //{"Right HP Mixer", NULL, "HP Mixer"}, + + /* Right HP mixer */ + {"Right HP Mixer", "PCBeep Bypass Switch", "PCBEEP"}, + {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"}, + {"Right HP Mixer", "Phone Bypass Switch", "Phone PGA"}, + {"Right HP Mixer", "Line Bypass Switch", "Line PGA"}, + {"Right HP Mixer", "PCM Playback Switch", "Right DAC"}, + {"Right HP Mixer", "Mic Sidetone Switch", "Mic PGA"}, + {"Right HP Mixer", NULL, "ALC Sidetone Mux"}, + + /* speaker mixer */ + {"Speaker Mixer", "PCBeep Bypass Switch", "PCBEEP"}, + {"Speaker Mixer", "Line Bypass Switch", "Line PGA"}, + {"Speaker Mixer", "PCM Playback Switch", "AC97 Mixer"}, + {"Speaker Mixer", "Phone Bypass Switch", "Phone PGA"}, + {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"}, + + /* Phone mixer */ + {"Phone Mixer", "PCBeep Bypass Switch", "PCBEEP"}, + {"Phone Mixer", "Line Bypass Switch", "Line PGA"}, + {"Phone Mixer", "Aux Playback Switch", "Aux DAC"}, + {"Phone Mixer", "PCM Playback Switch", "AC97 Mixer"}, + {"Phone Mixer", "Mic 1 Sidetone Switch", "Mic PGA"}, + {"Phone Mixer", "Mic 2 Sidetone Switch", "Mic PGA"}, + + /* inputs */ + {"Line PGA", NULL, "LINEINL"}, + {"Line PGA", NULL, "LINEINR"}, + {"Phone PGA", NULL, "PHONE"}, + {"Mic PGA", NULL, "MIC1"}, + {"Mic PGA", NULL, "MIC2"}, + + /* left capture selector */ + {"Left Capture Select", "Mic", "MIC1"}, + {"Left Capture Select", "Speaker Mixer", "Speaker Mixer"}, + {"Left Capture Select", "Line", "LINEINL"}, + {"Left Capture Select", "Headphone Mixer", "Left HP Mixer"}, + {"Left Capture Select", "Phone Mixer", "Phone Mixer"}, + {"Left Capture Select", "Phone", "PHONE"}, + + /* right capture selector */ + {"Right Capture Select", "Mic", "MIC2"}, + {"Right Capture Select", "Speaker Mixer", "Speaker Mixer"}, + {"Right Capture Select", "Line", "LINEINR"}, + {"Right Capture Select", "Headphone Mixer", "Right HP Mixer"}, + {"Right Capture Select", "Phone Mixer", "Phone Mixer"}, + {"Right Capture Select", "Phone", "PHONE"}, + + /* ALC Sidetone */ + {"ALC Sidetone Mux", "Stereo", "Left Capture Select"}, + {"ALC Sidetone Mux", "Stereo", "Right Capture Select"}, + {"ALC Sidetone Mux", "Left", "Left Capture Select"}, + {"ALC Sidetone Mux", "Right", "Right Capture Select"}, + + /* ADC's */ + {"Left ADC", NULL, "Left Capture Select"}, + {"Right ADC", NULL, "Right Capture Select"}, + + /* outputs */ + {"MONOOUT", NULL, "Phone Mixer"}, + {"HPOUTL", NULL, "Headphone PGA"}, + {"Headphone PGA", NULL, "Left HP Mixer"}, + {"HPOUTR", NULL, "Headphone PGA"}, + {"Headphone PGA", NULL, "Right HP Mixer"}, + + /* mono hp mixer */ + {"Mono HP Mixer", NULL, "Left HP Mixer"}, + {"Mono HP Mixer", NULL, "Right HP Mixer"}, + + /* Out3 Mux */ + {"Out3 Mux", "Left", "Left HP Mixer"}, + {"Out3 Mux", "Mono", "Phone Mixer"}, + {"Out3 Mux", "Left + Right", "Mono HP Mixer"}, + {"Out 3 PGA", NULL, "Out3 Mux"}, + {"OUT3", NULL, "Out 3 PGA"}, + + /* speaker Mux */ + {"Speaker Mux", "Speaker Mix", "Speaker Mixer"}, + {"Speaker Mux", "Headphone Mix", "Mono HP Mixer"}, + {"Speaker PGA", NULL, "Speaker Mux"}, + {"LOUT2", NULL, "Speaker PGA"}, + {"ROUT2", NULL, "Speaker PGA"}, + + {NULL, NULL, NULL}, +}; + +static int wm9712_add_widgets(struct snd_soc_codec *codec) +{ + int i; + + for(i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]); + } + + /* set up audio path audio_mapnects */ + for(i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_new_widgets(codec); + return 0; +} + +static unsigned int ac97_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + u16 *cache = codec->reg_cache; + + if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || + reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 || + reg == AC97_REC_GAIN) + return soc_ac97_ops.read(codec->ac97, reg); + else { + reg = reg >> 1; + + if (reg > (ARRAY_SIZE(wm9712_reg))) + return -EIO; + + return cache[reg]; + } +} + +static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int val) +{ + u16 *cache = codec->reg_cache; + + soc_ac97_ops.write(codec->ac97, reg, val); + reg = reg >> 1; + if (reg <= (ARRAY_SIZE(wm9712_reg))) + cache[reg] = val; + + return 0; +} + +static int ac97_prepare(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + int reg; + u16 vra; + + vra = ac97_read(codec, AC97_EXTENDED_STATUS); + ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + reg = AC97_PCM_FRONT_DAC_RATE; + else + reg = AC97_PCM_LR_ADC_RATE; + + return ac97_write(codec, reg, runtime->rate); +} + +static int ac97_aux_prepare(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + u16 vra, xsle; + + vra = ac97_read(codec, AC97_EXTENDED_STATUS); + ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1); + xsle = ac97_read(codec, AC97_PCI_SID); + ac97_write(codec, AC97_PCI_SID, xsle | 0x8000); + + if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) + return -ENODEV; + + return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); +} + +struct snd_soc_codec_dai wm9712_dai[] = { +{ + .name = "AC97 HiFi", + .playback = { + .stream_name = "HiFi Playback", + .channels_min = 1, + .channels_max = 2,}, + .capture = { + .stream_name = "HiFi Capture", + .channels_min = 1, + .channels_max = 2,}, + .ops = { + .prepare = ac97_prepare,}, + .caps = { + .num_modes = ARRAY_SIZE(ac97_modes), + .mode = ac97_modes,}, + }, + { + .name = "AC97 Aux", + .playback = { + .stream_name = "Aux Playback", + .channels_min = 1, + .channels_max = 1,}, + .ops = { + .prepare = ac97_aux_prepare,}, + .caps = { + .num_modes = ARRAY_SIZE(ac97_modes), + .mode = ac97_modes,}, + }, +}; +EXPORT_SYMBOL_GPL(wm9712_dai); + +static int wm9712_dapm_event(struct snd_soc_codec *codec, int event) +{ + u16 reg; + + switch (event) { + case SNDRV_CTL_POWER_D0: /* full On */ + /* liam - maybe enable thermal shutdown */ + reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xdfff; + ac97_write(codec, AC97_EXTENDED_MID, reg); + break; + case SNDRV_CTL_POWER_D1: /* partial On */ + case SNDRV_CTL_POWER_D2: /* partial On */ + break; + case SNDRV_CTL_POWER_D3hot: /* Off, with power */ + /* enable master bias and vmid */ + reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xbbff; + ac97_write(codec, AC97_EXTENDED_MID, reg); + ac97_write(codec, AC97_POWERDOWN, 0x0000); + break; + case SNDRV_CTL_POWER_D3cold: /* Off, without power */ + /* disable everything including AC link */ + ac97_write(codec, AC97_EXTENDED_MID, 0xffff); + ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); + ac97_write(codec, AC97_POWERDOWN, 0xffff); + break; + } + codec->dapm_state = event; + return 0; +} + +static int wm9712_reset(struct snd_soc_codec *codec, int try_warm) +{ + if (try_warm && soc_ac97_ops.warm_reset) { + soc_ac97_ops.warm_reset(codec->ac97); + if (!(ac97_read(codec, 0) & 0x8000)) + return 1; + } + + soc_ac97_ops.reset(codec->ac97); + if (ac97_read(codec, 0) & 0x8000) + goto err; + return 0; + +err: + printk(KERN_ERR "WM9712 AC97 reset failed\n"); + return -EIO; +} + +static int wm9712_soc_suspend(struct platform_device *pdev, + pm_message_t state) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3cold); + return 0; +} + +static int wm9712_soc_resume(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + int i, ret; + u16 *cache = codec->reg_cache; + + ret = wm9712_reset(codec, 1); + if (ret < 0){ + printk(KERN_ERR "could not reset AC97 codec\n"); + return ret; + } + + wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot); + + if (ret == 0) { + /* Sync reg_cache with the hardware after cold reset */ + for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i+=2) { + if (i == AC97_INT_PAGING || i == AC97_POWERDOWN || + (i > 0x58 && i != 0x5c)) + continue; + soc_ac97_ops.write(codec->ac97, i, cache[i>>1]); + } + } + + if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) + wm9712_dapm_event(codec, SNDRV_CTL_POWER_D0); + + return ret; +} + +static int wm9712_soc_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret = 0; + + printk(KERN_INFO "WM9711/WM9712 SoC Audio Codec %s\n", WM9712_VERSION); + + socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (socdev->codec == NULL) + return -ENOMEM; + codec = socdev->codec; + mutex_init(&codec->mutex); + + codec->reg_cache = + kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL); + if (codec->reg_cache == NULL) { + kfree(codec->ac97); + kfree(socdev->codec); + socdev->codec = NULL; + return -ENOMEM; + } + memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg)); + codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg); + codec->reg_cache_step = 2; + + codec->name = "WM9712"; + codec->owner = THIS_MODULE; + codec->dai = wm9712_dai; + codec->num_dai = ARRAY_SIZE(wm9712_dai); + codec->write = ac97_write; + codec->read = ac97_read; + codec->dapm_event = wm9712_dapm_event; + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); + if (ret < 0) + goto err; + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) + goto pcm_err; + + ret = wm9712_reset(codec, 0); + if (ret < 0) { + printk(KERN_ERR "AC97 link error\n"); + goto reset_err; + } + + /* set alc mux to none */ + ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); + + wm9712_dapm_event(codec, SNDRV_CTL_POWER_D3hot); + wm9712_add_controls(codec); + wm9712_add_widgets(codec); + ret = snd_soc_register_card(socdev); + if (ret < 0) + goto reset_err; + + return 0; + +reset_err: + snd_soc_free_pcms(socdev); + +pcm_err: + snd_soc_free_ac97_codec(codec); + +err: + kfree(socdev->codec->reg_cache); + kfree(socdev->codec); + socdev->codec = NULL; + return ret; +} + +static int wm9712_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + if (codec == NULL) + return 0; + + snd_soc_dapm_free(socdev); + snd_soc_free_pcms(socdev); + snd_soc_free_ac97_codec(codec); + kfree(codec->reg_cache); + kfree(codec); + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm9712 = { + .probe = wm9712_soc_probe, + .remove = wm9712_soc_remove, + .suspend = wm9712_soc_suspend, + .resume = wm9712_soc_resume, +}; + +EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712); + +MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); +MODULE_AUTHOR("Liam Girdwood"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/wm9712.h b/sound/soc/codecs/wm9712.h new file mode 100644 index 0000000..719105d --- /dev/null +++ b/sound/soc/codecs/wm9712.h @@ -0,0 +1,14 @@ +/* + * wm9712.h -- WM9712 Soc Audio driver + */ + +#ifndef _WM9712_H +#define _WM9712_H + +#define WM9712_DAI_AC97_HIFI 0 +#define WM9712_DAI_AC97_AUX 1 + +extern struct snd_soc_codec_dai wm9712_dai[2]; +extern struct snd_soc_codec_device soc_codec_dev_wm9712; + +#endif diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig new file mode 100644 index 0000000..579e1c8 --- /dev/null +++ b/sound/soc/pxa/Kconfig @@ -0,0 +1,60 @@ +menu "SoC Audio for the Intel PXA2xx" + +config SND_PXA2XX_SOC + tristate "SoC Audio for the Intel PXA2xx chip" + depends on ARCH_PXA && SND + select SND_PCM + help + Say Y or M if you want to add support for codecs attached to + the PXA2xx AC97, I2S or SSP interface. You will also need + to select the audio interfaces to support below. + +config SND_PXA2XX_AC97 + tristate + select SND_AC97_CODEC + +config SND_PXA2XX_SOC_AC97 + tristate + select AC97_BUS + select SND_SOC_AC97_BUS + +config SND_PXA2XX_SOC_I2S + tristate + +config SND_PXA2XX_SOC_CORGI + tristate "SoC Audio support for Sharp Zaurus SL-C7x0" + depends on SND_PXA2XX_SOC && PXA_SHARP_C7xx + select SND_PXA2XX_SOC_I2S + select SND_SOC_WM8731 + help + Say Y if you want to add support for SoC audio on Sharp + Zaurus SL-C7x0 models (Corgi, Shepherd, Husky). + +config SND_PXA2XX_SOC_SPITZ + tristate "SoC Audio support for Sharp Zaurus SL-Cxx00" + depends on SND_PXA2XX_SOC && PXA_SHARP_Cxx00 + select SND_PXA2XX_SOC_I2S + select SND_SOC_WM8750 + help + Say Y if you want to add support for SoC audio on Sharp + Zaurus SL-Cxx00 models (Spitz, Borzoi and Akita). + +config SND_PXA2XX_SOC_POODLE + tristate "SoC Audio support for Poodle" + depends on SND_PXA2XX_SOC && MACH_POODLE + select SND_PXA2XX_SOC_I2S + select SND_SOC_WM8731 + help + Say Y if you want to add support for SoC audio on Sharp + Zaurus SL-5600 model (Poodle). + +config SND_PXA2XX_SOC_TOSA + tristate "SoC AC97 Audio support for Tosa" + depends on SND_PXA2XX_SOC && MACH_TOSA + select SND_PXA2XX_SOC_AC97 + select SND_SOC_WM9712 + help + Say Y if you want to add support for SoC audio on Sharp + Zaurus SL-C6000x models (Tosa). + +endmenu diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile new file mode 100644 index 0000000..78e0d6b --- /dev/null +++ b/sound/soc/pxa/Makefile @@ -0,0 +1,20 @@ +# PXA Platform Support +snd-soc-pxa2xx-objs := pxa2xx-pcm.o +snd-soc-pxa2xx-ac97-objs := pxa2xx-ac97.o +snd-soc-pxa2xx-i2s-objs := pxa2xx-i2s.o + +obj-$(CONFIG_SND_PXA2XX_SOC) += snd-soc-pxa2xx.o +obj-$(CONFIG_SND_PXA2XX_SOC_AC97) += snd-soc-pxa2xx-ac97.o +obj-$(CONFIG_SND_PXA2XX_SOC_I2S) += snd-soc-pxa2xx-i2s.o + +# PXA Machine Support +snd-soc-corgi-objs := corgi.o +snd-soc-poodle-objs := poodle.o +snd-soc-tosa-objs := tosa.o +snd-soc-spitz-objs := spitz.o + +obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o +obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o +obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o +obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o + diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c new file mode 100644 index 0000000..2b1c6e9 --- /dev/null +++ b/sound/soc/pxa/corgi.c @@ -0,0 +1,361 @@ +/* + * corgi.c -- SoC audio for Corgi + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Authors: Liam Girdwood + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 30th Nov 2005 Initial version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../codecs/wm8731.h" +#include "pxa2xx-pcm.h" + +#define CORGI_HP 0 +#define CORGI_MIC 1 +#define CORGI_LINE 2 +#define CORGI_HEADSET 3 +#define CORGI_HP_OFF 4 +#define CORGI_SPK_ON 0 +#define CORGI_SPK_OFF 1 + + /* audio clock in Hz - rounded from 12.235MHz */ +#define CORGI_AUDIO_CLOCK 12288000 + +static int corgi_jack_func; +static int corgi_spk_func; + +static void corgi_ext_control(struct snd_soc_codec *codec) +{ + int spk = 0, mic = 0, line = 0, hp = 0, hs = 0; + + /* set up jack connection */ + switch (corgi_jack_func) { + case CORGI_HP: + hp = 1; + /* set = unmute headphone */ + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); + break; + case CORGI_MIC: + mic = 1; + /* reset = mute headphone */ + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); + break; + case CORGI_LINE: + line = 1; + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); + break; + case CORGI_HEADSET: + hs = 1; + mic = 1; + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); + break; + } + + if (corgi_spk_func == CORGI_SPK_ON) + spk = 1; + + /* set the enpoints to their new connetion states */ + snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", mic); + snd_soc_dapm_set_endpoint(codec, "Line Jack", line); + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs); + + /* signal a DAPM event */ + snd_soc_dapm_sync_endpoints(codec); +} + +static int corgi_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* check the jack status at stream startup */ + corgi_ext_control(codec); + return 0; +} + +/* we need to unmute the HP at shutdown as the mute burns power on corgi */ +static int corgi_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* set = unmute headphone */ + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); + return 0; +} + +static struct snd_soc_ops corgi_ops = { + .startup = corgi_startup, + .shutdown = corgi_shutdown, +}; + +static int corgi_get_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = corgi_jack_func; + return 0; +} + +static int corgi_set_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (corgi_jack_func == ucontrol->value.integer.value[0]) + return 0; + + corgi_jack_func = ucontrol->value.integer.value[0]; + corgi_ext_control(codec); + return 1; +} + +static int corgi_get_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = corgi_spk_func; + return 0; +} + +static int corgi_set_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (corgi_spk_func == ucontrol->value.integer.value[0]) + return 0; + + corgi_spk_func = ucontrol->value.integer.value[0]; + corgi_ext_control(codec); + return 1; +} + +static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event) +{ + if (SND_SOC_DAPM_EVENT_ON(event)) + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); + else + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); + + return 0; +} + +static int corgi_mic_event(struct snd_soc_dapm_widget *w, int event) +{ + if (SND_SOC_DAPM_EVENT_ON(event)) + set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS); + else + reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS); + + return 0; +} + +/* corgi machine dapm widgets */ +static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { +SND_SOC_DAPM_HP("Headphone Jack", NULL), +SND_SOC_DAPM_MIC("Mic Jack", corgi_mic_event), +SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event), +SND_SOC_DAPM_LINE("Line Jack", NULL), +SND_SOC_DAPM_HP("Headset Jack", NULL), +}; + +/* Corgi machine audio map (connections to the codec pins) */ +static const char *audio_map[][3] = { + + /* headset Jack - in = micin, out = LHPOUT*/ + {"Headset Jack", NULL, "LHPOUT"}, + + /* headphone connected to LHPOUT1, RHPOUT1 */ + {"Headphone Jack", NULL, "LHPOUT"}, + {"Headphone Jack", NULL, "RHPOUT"}, + + /* speaker connected to LOUT, ROUT */ + {"Ext Spk", NULL, "ROUT"}, + {"Ext Spk", NULL, "LOUT"}, + + /* mic is connected to MICIN (via right channel of headphone jack) */ + {"MICIN", NULL, "Mic Jack"}, + + /* Same as the above but no mic bias for line signals */ + {"MICIN", NULL, "Line Jack"}, + + {NULL, NULL, NULL}, +}; + +static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", + "Off"}; +static const char *spk_function[] = {"On", "Off"}; +static const struct soc_enum corgi_enum[] = { + SOC_ENUM_SINGLE_EXT(5, jack_function), + SOC_ENUM_SINGLE_EXT(2, spk_function), +}; + +static const struct snd_kcontrol_new wm8731_corgi_controls[] = { + SOC_ENUM_EXT("Jack Function", corgi_enum[0], corgi_get_jack, + corgi_set_jack), + SOC_ENUM_EXT("Speaker Function", corgi_enum[1], corgi_get_spk, + corgi_set_spk), +}; + +/* + * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device + */ +static int corgi_wm8731_init(struct snd_soc_codec *codec) +{ + int i, err; + + snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0); + snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0); + + /* Add corgi specific controls */ + for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8731_corgi_controls[i],codec, NULL)); + if (err < 0) + return err; + } + + /* Add corgi specific widgets */ + for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); + } + + /* Set up corgi specific audio path audio_map */ + for(i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_sync_endpoints(codec); + return 0; +} + +static unsigned int corgi_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) +{ + if (info->bclk_master & SND_SOC_DAIFMT_CBS_CFS) { + /* pxa2xx is i2s master */ + switch (info->rate) { + case 44100: + case 88200: + /* configure codec digital filters for 44.1, 88.2 */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + 11289600); + break; + default: + /* configure codec digital filters for all other rates */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + CORGI_AUDIO_CLOCK); + break; + } + /* config pxa i2s as master */ + return rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, + CORGI_AUDIO_CLOCK); + } else { + /* codec is i2s master - + * only configure codec DAI clock and filters */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + CORGI_AUDIO_CLOCK); + } +} + +/* corgi digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link corgi_dai = { + .name = "WM8731", + .stream_name = "WM8731", + .cpu_dai = &pxa_i2s_dai, + .codec_dai = &wm8731_dai, + .init = corgi_wm8731_init, + .config_sysclk = corgi_config_sysclk, +}; + +/* corgi audio machine driver */ +static struct snd_soc_machine snd_soc_machine_corgi = { + .name = "Corgi", + .dai_link = &corgi_dai, + .num_links = 1, + .ops = &corgi_ops, +}; + +/* corgi audio private data */ +static struct wm8731_setup_data corgi_wm8731_setup = { + .i2c_address = 0x1b, +}; + +/* corgi audio subsystem */ +static struct snd_soc_device corgi_snd_devdata = { + .machine = &snd_soc_machine_corgi, + .platform = &pxa2xx_soc_platform, + .codec_dev = &soc_codec_dev_wm8731, + .codec_data = &corgi_wm8731_setup, +}; + +static struct platform_device *corgi_snd_device; + +static int __init corgi_init(void) +{ + int ret; + + if (!(machine_is_corgi() || machine_is_shepherd() || machine_is_husky())) + return -ENODEV; + + corgi_snd_device = platform_device_alloc("soc-audio", -1); + if (!corgi_snd_device) + return -ENOMEM; + + platform_set_drvdata(corgi_snd_device, &corgi_snd_devdata); + corgi_snd_devdata.dev = &corgi_snd_device->dev; + ret = platform_device_add(corgi_snd_device); + + if (ret) + platform_device_put(corgi_snd_device); + + return ret; +} + +static void __exit corgi_exit(void) +{ + platform_device_unregister(corgi_snd_device); +} + +module_init(corgi_init); +module_exit(corgi_exit); + +/* Module information */ +MODULE_AUTHOR("Richard Purdie"); +MODULE_DESCRIPTION("ALSA SoC Corgi"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c new file mode 100644 index 0000000..ee93360 --- /dev/null +++ b/sound/soc/pxa/poodle.c @@ -0,0 +1,329 @@ +/* + * poodle.c -- SoC audio for Poodle + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Authors: Liam Girdwood + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../codecs/wm8731.h" +#include "pxa2xx-pcm.h" + +#define POODLE_HP 1 +#define POODLE_HP_OFF 0 +#define POODLE_SPK_ON 1 +#define POODLE_SPK_OFF 0 + + /* audio clock in Hz - rounded from 12.235MHz */ +#define POODLE_AUDIO_CLOCK 12288000 + +static int poodle_jack_func; +static int poodle_spk_func; + +static void poodle_ext_control(struct snd_soc_codec *codec) +{ + int spk = 0; + + /* set up jack connection */ + if (poodle_jack_func == POODLE_HP) { + /* set = unmute headphone */ + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_L, 1); + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_R, 1); + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1); + } else { + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_L, 0); + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_R, 0); + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0); + } + + if (poodle_spk_func == POODLE_SPK_ON) + spk = 1; + + /* set the enpoints to their new connetion states */ + snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk); + + /* signal a DAPM event */ + snd_soc_dapm_sync_endpoints(codec); +} + +static int poodle_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* check the jack status at stream startup */ + poodle_ext_control(codec); + return 0; +} + +/* we need to unmute the HP at shutdown as the mute burns power on poodle */ +static int poodle_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* set = unmute headphone */ + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_L, 1); + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_R, 1); + return 0; +} + +static struct snd_soc_ops poodle_ops = { + .startup = poodle_startup, + .shutdown = poodle_shutdown, +}; + +static int poodle_get_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = poodle_jack_func; + return 0; +} + +static int poodle_set_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (poodle_jack_func == ucontrol->value.integer.value[0]) + return 0; + + poodle_jack_func = ucontrol->value.integer.value[0]; + poodle_ext_control(codec); + return 1; +} + +static int poodle_get_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = poodle_spk_func; + return 0; +} + +static int poodle_set_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (poodle_spk_func == ucontrol->value.integer.value[0]) + return 0; + + poodle_spk_func = ucontrol->value.integer.value[0]; + poodle_ext_control(codec); + return 1; +} + +static int poodle_amp_event(struct snd_soc_dapm_widget *w, int event) +{ + if (SND_SOC_DAPM_EVENT_ON(event)) + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_AMP_ON, 0); + else + locomo_gpio_write(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_AMP_ON, 1); + + return 0; +} + +/* poodle machine dapm widgets */ +static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { +SND_SOC_DAPM_HP("Headphone Jack", NULL), +SND_SOC_DAPM_SPK("Ext Spk", poodle_amp_event), +}; + +/* Corgi machine audio_mapnections to the codec pins */ +static const char *audio_map[][3] = { + + /* headphone connected to LHPOUT1, RHPOUT1 */ + {"Headphone Jack", NULL, "LHPOUT"}, + {"Headphone Jack", NULL, "RHPOUT"}, + + /* speaker connected to LOUT, ROUT */ + {"Ext Spk", NULL, "ROUT"}, + {"Ext Spk", NULL, "LOUT"}, + + {NULL, NULL, NULL}, +}; + +static const char *jack_function[] = {"Off", "Headphone"}; +static const char *spk_function[] = {"Off", "On"}; +static const struct soc_enum poodle_enum[] = { + SOC_ENUM_SINGLE_EXT(2, jack_function), + SOC_ENUM_SINGLE_EXT(2, spk_function), +}; + +static const snd_kcontrol_new_t wm8731_poodle_controls[] = { + SOC_ENUM_EXT("Jack Function", poodle_enum[0], poodle_get_jack, + poodle_set_jack), + SOC_ENUM_EXT("Speaker Function", poodle_enum[1], poodle_get_spk, + poodle_set_spk), +}; + +/* + * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device + */ +static int poodle_wm8731_init(struct snd_soc_codec *codec) +{ + int i, err; + + snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0); + snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0); + snd_soc_dapm_set_endpoint(codec, "MICIN", 1); + + /* Add poodle specific controls */ + for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8731_poodle_controls[i],codec, NULL)); + if (err < 0) + return err; + } + + /* Add poodle specific widgets */ + for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); + } + + /* Set up poodle specific audio path audio_map */ + for (i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_sync_endpoints(codec); + return 0; +} + +static unsigned int poodle_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) +{ + if (info->bclk_master & SND_SOC_DAIFMT_CBS_CFS) { + /* pxa2xx is i2s master */ + switch (info->rate) { + case 44100: + case 88200: + /* configure codec digital filters for 44.1, 88.2 */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + 11289600); + break; + default: + /* configure codec digital filters for all other rates */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + POODLE_AUDIO_CLOCK); + break; + } + return rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, + POODLE_AUDIO_CLOCK); + } else { + /* codec is i2s master - + * only configure codec DAI clock and filters */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + POODLE_AUDIO_CLOCK); + } +} + +/* poodle digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link poodle_dai = { + .name = "WM8731", + .stream_name = "WM8731", + .cpu_dai = &pxa_i2s_dai, + .codec_dai = &wm8731_dai, + .init = poodle_wm8731_init, + .config_sysclk = poodle_config_sysclk, +}; + +/* poodle audio machine driver */ +static struct snd_soc_machine snd_soc_machine_poodle = { + .name = "Poodle", + .dai_link = &poodle_dai, + .num_links = 1, + .ops = &poodle_ops, +}; + +/* poodle audio private data */ +static struct wm8731_setup_data poodle_wm8731_setup = { + .i2c_address = 0x1b, +}; + +/* poodle audio subsystem */ +static struct snd_soc_device poodle_snd_devdata = { + .machine = &snd_soc_machine_poodle, + .platform = &pxa2xx_soc_platform, + .codec_dev = &soc_codec_dev_wm8731, + .codec_data = &poodle_wm8731_setup, +}; + +static struct platform_device *poodle_snd_device; + +static int __init poodle_init(void) +{ + int ret; + + if (!machine_is_poodle()) + return -ENODEV; + + locomo_gpio_set_dir(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_AMP_ON, 0); + /* should we mute HP at startup - burning power ?*/ + locomo_gpio_set_dir(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_L, 0); + locomo_gpio_set_dir(&poodle_locomo_device.dev, + POODLE_LOCOMO_GPIO_MUTE_R, 0); + + poodle_snd_device = platform_device_alloc("soc-audio", -1); + if (!poodle_snd_device) + return -ENOMEM; + + platform_set_drvdata(poodle_snd_device, &poodle_snd_devdata); + poodle_snd_devdata.dev = &poodle_snd_device->dev; + ret = platform_device_add(poodle_snd_device); + + if (ret) + platform_device_put(poodle_snd_device); + + return ret; +} + +static void __exit poodle_exit(void) +{ + platform_device_unregister(poodle_snd_device); +} + +module_init(poodle_init); +module_exit(poodle_exit); + +/* Module information */ +MODULE_AUTHOR("Richard Purdie"); +MODULE_DESCRIPTION("ALSA SoC Poodle"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c new file mode 100644 index 0000000..28b1985 --- /dev/null +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -0,0 +1,437 @@ +/* + * linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip. + * + * Author: Nicolas Pitre + * Created: Dec 02, 2004 + * Copyright: MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "pxa2xx-pcm.h" + +static DEFINE_MUTEX(car_mutex); +static DECLARE_WAIT_QUEUE_HEAD(gsr_wq); +static volatile long gsr_bits; + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + { + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = AC97_RATES, + .pcmdir = AC97_DIR, + }, +}; + +/* + * Beware PXA27x bugs: + * + * o Slot 12 read from modem space will hang controller. + * o CDONE, SDONE interrupt fails after any slot 12 IO. + * + * We therefore have an hybrid approach for waiting on SDONE (interrupt or + * 1 jiffy timeout if interrupt never comes). + */ + +static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, + unsigned short reg) +{ + unsigned short val = -1; + volatile u32 *reg_addr; + + mutex_lock(&car_mutex); + + /* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; +#else + if (reg == AC97_GPIO_STATUS) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE; + else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; +#endif + reg_addr += (reg >> 1); + +#ifndef CONFIG_PXA27x + if (reg == AC97_GPIO_STATUS) { + /* read from controller cache */ + val = *reg_addr; + goto out; + } +#endif + + /* start read access across the ac97 link */ + GSR = GSR_CDONE | GSR_SDONE; + gsr_bits = 0; + val = *reg_addr; + + wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1); + if (!((GSR | gsr_bits) & GSR_SDONE)) { + printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n", + __FUNCTION__, reg, GSR | gsr_bits); + val = -1; + goto out; + } + + /* valid data now */ + GSR = GSR_CDONE | GSR_SDONE; + gsr_bits = 0; + val = *reg_addr; + /* but we've just started another cycle... */ + wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1); + +out: mutex_unlock(&car_mutex); + return val; +} + +static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short val) +{ + volatile u32 *reg_addr; + + mutex_lock(&car_mutex); + + /* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; +#else + if (reg == AC97_GPIO_STATUS) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE; + else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE; +#endif + reg_addr += (reg >> 1); + + GSR = GSR_CDONE | GSR_SDONE; + gsr_bits = 0; + *reg_addr = val; + wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1); + if (!((GSR | gsr_bits) & GSR_CDONE)) + printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n", + __FUNCTION__, reg, GSR | gsr_bits); + + mutex_unlock(&car_mutex); +} + +static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97) +{ + gsr_bits = 0; + +#ifdef CONFIG_PXA27x + /* warm reset broken on Bulverde, + so manually keep AC97 reset high */ + pxa_gpio_mode(113 | GPIO_OUT | GPIO_DFLT_HIGH); + udelay(10); + GCR |= GCR_WARM_RST; + pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); + udelay(500); +#else + GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN; + wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); +#endif + + if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) + printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", + __FUNCTION__, gsr_bits); + + GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); + GCR |= GCR_SDONE_IE|GCR_CDONE_IE; +} + +static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97) +{ + GCR &= GCR_COLD_RST; /* clear everything but nCRST */ + GCR &= ~GCR_COLD_RST; /* then assert nCRST */ + + gsr_bits = 0; +#ifdef CONFIG_PXA27x + /* PXA27x Developers Manual section 13.5.2.2.1 */ + pxa_set_cken(1 << 31, 1); + udelay(5); + pxa_set_cken(1 << 31, 0); + GCR = GCR_COLD_RST; + udelay(50); +#else + GCR = GCR_COLD_RST; + GCR |= GCR_CDONE_IE|GCR_SDONE_IE; + wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); +#endif + + if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) + printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", + __FUNCTION__, gsr_bits); + + GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); + GCR |= GCR_SDONE_IE|GCR_CDONE_IE; +} + +static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id) +{ + long status; + + status = GSR; + if (status) { + GSR = status; + gsr_bits |= status; + wake_up(&gsr_wq); + +#ifdef CONFIG_PXA27x + /* Although we don't use those we still need to clear them + since they tend to spuriously trigger when MMC is used + (hardware bug? go figure)... */ + MISR = MISR_EOC; + PISR = PISR_EOC; + MCSR = MCSR_EOC; +#endif + + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +struct snd_ac97_bus_ops soc_ac97_ops = { + .read = pxa2xx_ac97_read, + .write = pxa2xx_ac97_write, + .warm_reset = pxa2xx_ac97_warm_reset, + .reset = pxa2xx_ac97_cold_reset, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_out = { + .name = "AC97 PCM Stereo out", + .dev_addr = __PREG(PCDR), + .drcmr = &DRCMRTXPCDR, + .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | + DCMD_BURST32 | DCMD_WIDTH4, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_in = { + .name = "AC97 PCM Stereo in", + .dev_addr = __PREG(PCDR), + .drcmr = &DRCMRRXPCDR, + .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | + DCMD_BURST32 | DCMD_WIDTH4, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_out = { + .name = "AC97 Aux PCM (Slot 5) Mono out", + .dev_addr = __PREG(MODR), + .drcmr = &DRCMRTXMODR, + .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | + DCMD_BURST16 | DCMD_WIDTH2, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_in = { + .name = "AC97 Aux PCM (Slot 5) Mono in", + .dev_addr = __PREG(MODR), + .drcmr = &DRCMRRXMODR, + .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | + DCMD_BURST16 | DCMD_WIDTH2, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = { + .name = "AC97 Mic PCM (Slot 6) Mono in", + .dev_addr = __PREG(MCDR), + .drcmr = &DRCMRRXMCDR, + .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | + DCMD_BURST16 | DCMD_WIDTH2, +}; + +#ifdef CONFIG_PM +static int pxa2xx_ac97_suspend(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + GCR |= GCR_ACLINK_OFF; + pxa_set_cken(CKEN2_AC97, 0); + return 0; +} + +static int pxa2xx_ac97_resume(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + pxa_gpio_mode(GPIO31_SYNC_AC97_MD); + pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); + pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); + pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD); +#ifdef CONFIG_PXA27x + /* Use GPIO 113 as AC97 Reset on Bulverde */ + pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); +#endif + pxa_set_cken(CKEN2_AC97, 1); + return 0; +} + +#else +#define pxa2xx_ac97_suspend NULL +#define pxa2xx_ac97_resume NULL +#endif + +static int pxa2xx_ac97_probe(struct platform_device *pdev) +{ + int ret; + + ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, IRQF_DISABLED, "AC97", NULL); + if (ret < 0) + goto err; + + pxa_gpio_mode(GPIO31_SYNC_AC97_MD); + pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); + pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); + pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD); +#ifdef CONFIG_PXA27x + /* Use GPIO 113 as AC97 Reset on Bulverde */ + pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT); +#endif + pxa_set_cken(CKEN2_AC97, 1); + return 0; + + err: + if (CKEN & CKEN2_AC97) { + GCR |= GCR_ACLINK_OFF; + free_irq(IRQ_AC97, NULL); + pxa_set_cken(CKEN2_AC97, 0); + } + return ret; +} + +static void pxa2xx_ac97_remove(struct platform_device *pdev) +{ + GCR |= GCR_ACLINK_OFF; + free_irq(IRQ_AC97, NULL); + pxa_set_cken(CKEN2_AC97, 0); +} + +static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out; + else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in; + + return 0; +} + +static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out; + else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in; + + return 0; +} + +static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + return -ENODEV; + else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in; + + return 0; +} + +/* + * There is only 1 physical AC97 interface for pxa2xx, but it + * has extra fifo's that can be used for aux DACs and ADCs. + */ +struct snd_soc_cpu_dai pxa_ac97_dai[] = { +{ + .name = "pxa2xx-ac97", + .id = 0, + .type = SND_SOC_DAI_AC97, + .probe = pxa2xx_ac97_probe, + .remove = pxa2xx_ac97_remove, + .suspend = pxa2xx_ac97_suspend, + .resume = pxa2xx_ac97_resume, + .playback = { + .stream_name = "AC97 Playback", + .channels_min = 2, + .channels_max = 2,}, + .capture = { + .stream_name = "AC97 Capture", + .channels_min = 2, + .channels_max = 2,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_params,}, + .caps = { + .num_modes = ARRAY_SIZE(pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name = "pxa2xx-ac97-aux", + .id = 1, + .type = SND_SOC_DAI_AC97, + .playback = { + .stream_name = "AC97 Aux Playback", + .channels_min = 1, + .channels_max = 1,}, + .capture = { + .stream_name = "AC97 Aux Capture", + .channels_min = 1, + .channels_max = 1,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_aux_params,}, + .caps = { + .num_modes = ARRAY_SIZE(pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name = "pxa2xx-ac97-mic", + .id = 2, + .type = SND_SOC_DAI_AC97, + .capture = { + .stream_name = "AC97 Mic Capture", + .channels_min = 1, + .channels_max = 1,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_mic_params,}, + .caps = { + .num_modes = ARRAY_SIZE(pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,},}, +}; + +EXPORT_SYMBOL_GPL(pxa_ac97_dai); +EXPORT_SYMBOL_GPL(soc_ac97_ops); + +MODULE_AUTHOR("Nicolas Pitre"); +MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c new file mode 100644 index 0000000..98b167f --- /dev/null +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -0,0 +1,354 @@ +/* + * pxa2xx-i2s.c -- ALSA Soc Audio Layer + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Author: Liam Girdwood + * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 12th Aug 2005 Initial version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "pxa2xx-pcm.h" + +/* used to disable sysclk if external crystal is used */ +static int extclk; +module_param(extclk, int, 0); +MODULE_PARM_DESC(extclk, "set to 1 to disable pxa2xx i2s sysclk"); + +struct pxa_i2s_port { + u32 sadiv; + u32 sacr0; + u32 sacr1; + u32 saimr; + int master; +}; +static struct pxa_i2s_port pxa_i2s; + +#define PXA_I2S_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF) + +#define PXA_I2S_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define PXA_I2S_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + +/* priv is divider */ +static struct snd_soc_dai_mode pxa2xx_i2s_modes[] = { + /* pxa2xx I2S frame and clock master modes */ + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_8000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x48, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_11025, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x34, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_16000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x24, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_22050, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0x1a, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_44100, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0xd, + }, + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = SNDRV_PCM_RATE_48000, + .pcmdir = PXA_I2S_DIR, + .flags = SND_SOC_DAI_BFS_DIV, + .fs = 256, + .bfs = SND_SOC_FSBD(4), + .priv = 0xc, + }, + + /* pxa2xx I2S frame master and clock slave mode */ + { + .fmt = PXA_I2S_DAIFMT | SND_SOC_DAIFMT_CBM_CFS, + .pcmfmt = SNDRV_PCM_FMTBIT_S16_LE, + .pcmrate = PXA_I2S_RATES, + .pcmdir = PXA_I2S_DIR, + .fs = SND_SOC_FS_ALL, + .flags = SND_SOC_DAI_BFS_RATE, + .bfs = 64, + .priv = 0x48, + }, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_i2s_pcm_stereo_out = { + .name = "I2S PCM Stereo out", + .dev_addr = __PREG(SADR), + .drcmr = &DRCMRTXSADR, + .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | + DCMD_BURST32 | DCMD_WIDTH4, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_i2s_pcm_stereo_in = { + .name = "I2S PCM Stereo in", + .dev_addr = __PREG(SADR), + .drcmr = &DRCMRRXSADR, + .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | + DCMD_BURST32 | DCMD_WIDTH4, +}; + +static struct pxa2xx_gpio gpio_bus[] = { + { /* I2S SoC Slave */ + .rx = GPIO29_SDATA_IN_I2S_MD, + .tx = GPIO30_SDATA_OUT_I2S_MD, + .clk = GPIO28_BITCLK_IN_I2S_MD, + .frm = GPIO31_SYNC_I2S_MD, + }, + { /* I2S SoC Master */ +#ifdef CONFIG_PXA27x + .sys = GPIO113_I2S_SYSCLK_MD, +#else + .sys = GPIO32_SYSCLK_I2S_MD, +#endif + .rx = GPIO29_SDATA_IN_I2S_MD, + .tx = GPIO30_SDATA_OUT_I2S_MD, + .clk = GPIO28_BITCLK_OUT_I2S_MD, + .frm = GPIO31_SYNC_I2S_MD, + }, +}; + +static int pxa2xx_i2s_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + if (!rtd->cpu_dai->active) { + SACR0 |= SACR0_RST; + SACR0 = 0; + } + + return 0; +} + +/* wait for I2S controller to be ready */ +static int pxa_i2s_wait(void) +{ + int i; + + /* flush the Rx FIFO */ + for(i = 0; i < 16; i++) + SADR; + return 0; +} + +static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + pxa_i2s.master = 0; + if (rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CBS_CFS) + pxa_i2s.master = 1; + + if (pxa_i2s.master && !extclk) + pxa_gpio_mode(gpio_bus[pxa_i2s.master].sys); + + pxa_gpio_mode(gpio_bus[pxa_i2s.master].rx); + pxa_gpio_mode(gpio_bus[pxa_i2s.master].tx); + pxa_gpio_mode(gpio_bus[pxa_i2s.master].frm); + pxa_gpio_mode(gpio_bus[pxa_i2s.master].clk); + pxa_set_cken(CKEN8_I2S, 1); + pxa_i2s_wait(); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_out; + else + rtd->cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_in; + + /* is port used by another stream */ + if (!(SACR0 & SACR0_ENB)) { + + SACR0 = 0; + SACR1 = 0; + if (pxa_i2s.master) + SACR0 |= SACR0_BCKD; + + SACR0 |= SACR0_RFTH(14) | SACR0_TFTH(1); + + if (rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_LEFT_J) + SACR1 |= SACR1_AMSL; + } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + SAIMR |= SAIMR_TFS; + else + SAIMR |= SAIMR_RFS; + + SADIV = rtd->cpu_dai->dai_runtime.priv; + return 0; +} + +static int pxa2xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd) +{ + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + SACR0 |= SACR0_ENB; + break; + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream) +{ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + SACR1 |= SACR1_DRPL; + SAIMR &= ~SAIMR_TFS; + } else { + SACR1 |= SACR1_DREC; + SAIMR &= ~SAIMR_RFS; + } + + if (SACR1 & (SACR1_DREC | SACR1_DRPL)) { + SACR0 &= ~SACR0_ENB; + pxa_i2s_wait(); + pxa_set_cken(CKEN8_I2S, 0); + } +} + +#ifdef CONFIG_PM +static int pxa2xx_i2s_suspend(struct platform_device *dev, + struct snd_soc_cpu_dai *dai) +{ + if (!dai->active) + return 0; + + /* store registers */ + pxa_i2s.sacr0 = SACR0; + pxa_i2s.sacr1 = SACR1; + pxa_i2s.saimr = SAIMR; + pxa_i2s.sadiv = SADIV; + + /* deactivate link */ + SACR0 &= ~SACR0_ENB; + pxa_i2s_wait(); + return 0; +} + +static int pxa2xx_i2s_resume(struct platform_device *pdev, + struct snd_soc_cpu_dai *dai) +{ + if (!dai->active) + return 0; + + pxa_i2s_wait(); + + SACR0 = pxa_i2s.sacr0 &= ~SACR0_ENB; + SACR1 = pxa_i2s.sacr1; + SAIMR = pxa_i2s.saimr; + SADIV = pxa_i2s.sadiv; + SACR0 |= SACR0_ENB; + + return 0; +} + +#else +#define pxa2xx_i2s_suspend NULL +#define pxa2xx_i2s_resume NULL +#endif + +/* pxa2xx I2S sysclock is always 256 FS */ +static unsigned int pxa_i2s_config_sysclk(struct snd_soc_cpu_dai *iface, + struct snd_soc_clock_info *info, unsigned int clk) +{ + return info->rate << 8; +} + +struct snd_soc_cpu_dai pxa_i2s_dai = { + .name = "pxa2xx-i2s", + .id = 0, + .type = SND_SOC_DAI_I2S, + .suspend = pxa2xx_i2s_suspend, + .resume = pxa2xx_i2s_resume, + .config_sysclk = pxa_i2s_config_sysclk, + .playback = { + .channels_min = 2, + .channels_max = 2,}, + .capture = { + .channels_min = 2, + .channels_max = 2,}, + .ops = { + .startup = pxa2xx_i2s_startup, + .shutdown = pxa2xx_i2s_shutdown, + .trigger = pxa2xx_i2s_trigger, + .hw_params = pxa2xx_i2s_hw_params,}, + .caps = { + .num_modes = ARRAY_SIZE(pxa2xx_i2s_modes), + .mode = pxa2xx_i2s_modes,}, +}; + +EXPORT_SYMBOL_GPL(pxa_i2s_dai); + +/* Module information */ +MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com"); +MODULE_DESCRIPTION("pxa2xx I2S SoC Interface"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c new file mode 100644 index 0000000..ff32f89 --- /dev/null +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -0,0 +1,363 @@ +/* + * linux/sound/arm/pxa2xx-pcm.c -- ALSA PCM interface for the Intel PXA2xx chip + * + * Author: Nicolas Pitre + * Created: Nov 30, 2004 + * Copyright: (C) 2004 MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "pxa2xx-pcm.h" + +static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_RESUME, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .period_bytes_min = 32, + .period_bytes_max = 8192 - 32, + .periods_min = 1, + .periods_max = PAGE_SIZE/sizeof(pxa_dma_desc), + .buffer_bytes_max = 128 * 1024, + .fifo_size = 32, +}; + +struct pxa2xx_runtime_data { + int dma_ch; + struct pxa2xx_pcm_dma_params *params; + pxa_dma_desc *dma_desc_array; + dma_addr_t dma_desc_array_phys; +}; + +static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id) +{ + struct snd_pcm_substream *substream = dev_id; + struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; + int dcsr; + + dcsr = DCSR(dma_ch); + DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN; + + if (dcsr & DCSR_ENDINTR) { + snd_pcm_period_elapsed(substream); + } else { + printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n", + prtd->params->name, dma_ch, dcsr ); + } +} + +static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct pxa2xx_runtime_data *prtd = runtime->private_data; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct pxa2xx_pcm_dma_params *dma = rtd->cpu_dai->dma_data; + size_t totsize = params_buffer_bytes(params); + size_t period = params_period_bytes(params); + pxa_dma_desc *dma_desc; + dma_addr_t dma_buff_phys, next_desc_phys; + int ret; + + /* this may get called several times by oss emulation + * with different params */ + if (prtd->params == NULL) { + prtd->params = dma; + ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW, + pxa2xx_pcm_dma_irq, substream); + if (ret < 0) + return ret; + prtd->dma_ch = ret; + } else if (prtd->params != dma) { + pxa_free_dma(prtd->dma_ch); + prtd->params = dma; + ret = pxa_request_dma(prtd->params->name, DMA_PRIO_LOW, + pxa2xx_pcm_dma_irq, substream); + if (ret < 0) + return ret; + prtd->dma_ch = ret; + } + + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + runtime->dma_bytes = totsize; + + dma_desc = prtd->dma_desc_array; + next_desc_phys = prtd->dma_desc_array_phys; + dma_buff_phys = runtime->dma_addr; + do { + next_desc_phys += sizeof(pxa_dma_desc); + dma_desc->ddadr = next_desc_phys; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + dma_desc->dsadr = dma_buff_phys; + dma_desc->dtadr = prtd->params->dev_addr; + } else { + dma_desc->dsadr = prtd->params->dev_addr; + dma_desc->dtadr = dma_buff_phys; + } + if (period > totsize) + period = totsize; + dma_desc->dcmd = prtd->params->dcmd | period | DCMD_ENDIRQEN; + dma_desc++; + dma_buff_phys += period; + } while (totsize -= period); + dma_desc[-1].ddadr = prtd->dma_desc_array_phys; + + return 0; +} + +static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) +{ + struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; + + if (prtd && prtd->params) + *prtd->params->drcmr = 0; + + if (prtd->dma_ch) { + snd_pcm_set_runtime_buffer(substream, NULL); + pxa_free_dma(prtd->dma_ch); + prtd->dma_ch = 0; + } + + return 0; +} + +static int pxa2xx_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; + + DCSR(prtd->dma_ch) &= ~DCSR_RUN; + DCSR(prtd->dma_ch) = 0; + DCMD(prtd->dma_ch) = 0; + *prtd->params->drcmr = prtd->dma_ch | DRCMR_MAPVLD; + + return 0; +} + +static int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; + DCSR(prtd->dma_ch) = DCSR_RUN; + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + DCSR(prtd->dma_ch) &= ~DCSR_RUN; + break; + + case SNDRV_PCM_TRIGGER_RESUME: + DCSR(prtd->dma_ch) |= DCSR_RUN; + break; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; + DCSR(prtd->dma_ch) |= DCSR_RUN; + break; + + default: + ret = -EINVAL; + } + + return ret; +} + +static snd_pcm_uframes_t +pxa2xx_pcm_pointer(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct pxa2xx_runtime_data *prtd = runtime->private_data; + + dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? + DSADR(prtd->dma_ch) : DTADR(prtd->dma_ch); + snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr); + + if (x == runtime->buffer_size) + x = 0; + return x; +} + +static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct pxa2xx_runtime_data *prtd; + int ret; + + snd_soc_set_runtime_hwparams(substream, &pxa2xx_pcm_hardware); + + /* + * For mysterious reasons (and despite what the manual says) + * playback samples are lost if the DMA count is not a multiple + * of the DMA burst size. Let's add a rule to enforce that. + */ + ret = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); + if (ret) + goto out; + + ret = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); + if (ret) + goto out; + + prtd = kzalloc(sizeof(struct pxa2xx_runtime_data), GFP_KERNEL); + if (prtd == NULL) { + ret = -ENOMEM; + goto out; + } + + prtd->dma_desc_array = + dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE, + &prtd->dma_desc_array_phys, GFP_KERNEL); + if (!prtd->dma_desc_array) { + ret = -ENOMEM; + goto err1; + } + + runtime->private_data = prtd; + return 0; + + err1: + kfree(prtd); + out: + return ret; +} + +static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct pxa2xx_runtime_data *prtd = runtime->private_data; + + dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE, + prtd->dma_desc_array, prtd->dma_desc_array_phys); + kfree(prtd); + return 0; +} + +static int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + return dma_mmap_writecombine(substream->pcm->card->dev, vma, + runtime->dma_area, + runtime->dma_addr, + runtime->dma_bytes); +} + +struct snd_pcm_ops pxa2xx_pcm_ops = { + .open = pxa2xx_pcm_open, + .close = pxa2xx_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = pxa2xx_pcm_hw_params, + .hw_free = pxa2xx_pcm_hw_free, + .prepare = pxa2xx_pcm_prepare, + .trigger = pxa2xx_pcm_trigger, + .pointer = pxa2xx_pcm_pointer, + .mmap = pxa2xx_pcm_mmap, +}; + +static int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) +{ + struct snd_pcm_substream *substream = pcm->streams[stream].substream; + struct snd_dma_buffer *buf = &substream->dma_buffer; + size_t size = pxa2xx_pcm_hardware.buffer_bytes_max; + buf->dev.type = SNDRV_DMA_TYPE_DEV; + buf->dev.dev = pcm->card->dev; + buf->private_data = NULL; + buf->area = dma_alloc_writecombine(pcm->card->dev, size, + &buf->addr, GFP_KERNEL); + if (!buf->area) + return -ENOMEM; + buf->bytes = size; + return 0; +} + +static void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm) +{ + struct snd_pcm_substream *substream; + struct snd_dma_buffer *buf; + int stream; + + for (stream = 0; stream < 2; stream++) { + substream = pcm->streams[stream].substream; + if (!substream) + continue; + + buf = &substream->dma_buffer; + if (!buf->area) + continue; + + dma_free_writecombine(pcm->card->dev, buf->bytes, + buf->area, buf->addr); + buf->area = NULL; + } +} + +static u64 pxa2xx_pcm_dmamask = DMA_32BIT_MASK; + +int pxa2xx_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai, + struct snd_pcm *pcm) +{ + int ret = 0; + + if (!card->dev->dma_mask) + card->dev->dma_mask = &pxa2xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_32BIT_MASK; + + if (dai->playback.channels_min) { + ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + goto out; + } + + if (dai->capture.channels_min) { + ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_CAPTURE); + if (ret) + goto out; + } + out: + return ret; +} + +struct snd_soc_platform pxa2xx_soc_platform = { + .name = "pxa2xx-audio", + .pcm_ops = &pxa2xx_pcm_ops, + .pcm_new = pxa2xx_pcm_new, + .pcm_free = pxa2xx_pcm_free_dma_buffers, +}; + +EXPORT_SYMBOL_GPL(pxa2xx_soc_platform); + +MODULE_AUTHOR("Nicolas Pitre"); +MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/pxa2xx-pcm.h b/sound/soc/pxa/pxa2xx-pcm.h new file mode 100644 index 0000000..0b55f07 --- /dev/null +++ b/sound/soc/pxa/pxa2xx-pcm.h @@ -0,0 +1,48 @@ +/* + * linux/sound/arm/pxa2xx-pcm.h -- ALSA PCM interface for the Intel PXA2xx chip + * + * Author: Nicolas Pitre + * Created: Nov 30, 2004 + * Copyright: MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _PXA2XX_PCM_H +#define _PXA2XX_PCM_H + +struct pxa2xx_pcm_dma_params { + char *name; /* stream identifier */ + u32 dcmd; /* DMA descriptor dcmd field */ + volatile u32 *drcmr; /* the DMA request channel to use */ + u32 dev_addr; /* device physical address for DMA */ +}; + +struct pxa2xx_gpio { + u32 sys; + u32 rx; + u32 tx; + u32 clk; + u32 frm; +}; + +/* pxa2xx DAI ID's */ +#define PXA2XX_DAI_AC97_HIFI 0 +#define PXA2XX_DAI_AC97_AUX 1 +#define PXA2XX_DAI_AC97_MIC 2 +#define PXA2XX_DAI_I2S 0 +#define PXA2XX_DAI_SSP1 0 +#define PXA2XX_DAI_SSP2 1 +#define PXA2XX_DAI_SSP3 2 + +extern struct snd_soc_cpu_dai pxa_ac97_dai[3]; +extern struct snd_soc_cpu_dai pxa_i2s_dai; +extern struct snd_soc_cpu_dai pxa_ssp_dai[3]; + +/* platform data */ +extern struct snd_soc_platform pxa2xx_soc_platform; +extern struct snd_ac97_bus_ops pxa2xx_ac97_ops; + +#endif diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c new file mode 100644 index 0000000..17c8e61 --- /dev/null +++ b/sound/soc/pxa/spitz.c @@ -0,0 +1,374 @@ +/* + * spitz.c -- SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Authors: Liam Girdwood + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 30th Nov 2005 Initial version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "../codecs/wm8750.h" +#include "pxa2xx-pcm.h" + +#define SPITZ_HP 0 +#define SPITZ_MIC 1 +#define SPITZ_LINE 2 +#define SPITZ_HEADSET 3 +#define SPITZ_HP_OFF 4 +#define SPITZ_SPK_ON 0 +#define SPITZ_SPK_OFF 1 + + /* audio clock in Hz - rounded from 12.235MHz */ +#define SPITZ_AUDIO_CLOCK 12288000 + +static int spitz_jack_func; +static int spitz_spk_func; + +static void spitz_ext_control(struct snd_soc_codec *codec) +{ + if (spitz_spk_func == SPITZ_SPK_ON) + snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1); + else + snd_soc_dapm_set_endpoint(codec, "Ext Spk", 0); + + /* set up jack connection */ + switch (spitz_jack_func) { + case SPITZ_HP: + /* enable and unmute hp jack, disable mic bias */ + snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Line Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1); + set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); + set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); + break; + case SPITZ_MIC: + /* enable mic jack and bias, mute hp */ + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Line Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); + break; + case SPITZ_LINE: + /* enable line jack, disable mic bias and mute hp */ + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Line Jack", 1); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); + break; + case SPITZ_HEADSET: + /* enable and unmute headset jack enable mic bias, mute L hp */ + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1); + snd_soc_dapm_set_endpoint(codec, "Line Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", 1); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); + set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); + break; + case SPITZ_HP_OFF: + + /* jack removed, everything off */ + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0); + snd_soc_dapm_set_endpoint(codec, "Line Jack", 0); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); + reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); + break; + } + snd_soc_dapm_sync_endpoints(codec); +} + +static int spitz_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* check the jack status at stream startup */ + spitz_ext_control(codec); + return 0; +} + +static struct snd_soc_ops spitz_ops = { + .startup = spitz_startup, +}; + +static int spitz_get_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = spitz_jack_func; + return 0; +} + +static int spitz_set_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (spitz_jack_func == ucontrol->value.integer.value[0]) + return 0; + + spitz_jack_func = ucontrol->value.integer.value[0]; + spitz_ext_control(codec); + return 1; +} + +static int spitz_get_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = spitz_spk_func; + return 0; +} + +static int spitz_set_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (spitz_spk_func == ucontrol->value.integer.value[0]) + return 0; + + spitz_spk_func = ucontrol->value.integer.value[0]; + spitz_ext_control(codec); + return 1; +} + +static int spitz_mic_bias(struct snd_soc_dapm_widget *w, int event) +{ + if (machine_is_borzoi() || machine_is_spitz()) { + if (SND_SOC_DAPM_EVENT_ON(event)) + set_scoop_gpio(&spitzscoop2_device.dev, + SPITZ_SCP2_MIC_BIAS); + else + reset_scoop_gpio(&spitzscoop2_device.dev, + SPITZ_SCP2_MIC_BIAS); + } + + if (machine_is_akita()) { + if (SND_SOC_DAPM_EVENT_ON(event)) + akita_set_ioexp(&akitaioexp_device.dev, + AKITA_IOEXP_MIC_BIAS); + else + akita_reset_ioexp(&akitaioexp_device.dev, + AKITA_IOEXP_MIC_BIAS); + } + return 0; +} + +/* spitz machine dapm widgets */ +static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), + SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_LINE("Line Jack", NULL), + + /* headset is a mic and mono headphone */ + SND_SOC_DAPM_HP("Headset Jack", NULL), +}; + +/* Spitz machine audio_map */ +static const char *audio_map[][3] = { + + /* headphone connected to LOUT1, ROUT1 */ + {"Headphone Jack", NULL, "LOUT1"}, + {"Headphone Jack", NULL, "ROUT1"}, + + /* headset connected to ROUT1 and LINPUT1 with bias (def below) */ + {"Headset Jack", NULL, "ROUT1"}, + + /* ext speaker connected to LOUT2, ROUT2 */ + {"Ext Spk", NULL , "ROUT2"}, + {"Ext Spk", NULL , "LOUT2"}, + + /* mic is connected to input 1 - with bias */ + {"LINPUT1", NULL, "Mic Bias"}, + {"Mic Bias", NULL, "Mic Jack"}, + + /* line is connected to input 1 - no bias */ + {"LINPUT1", NULL, "Line Jack"}, + + {NULL, NULL, NULL}, +}; + +static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", + "Off"}; +static const char *spk_function[] = {"On", "Off"}; +static const struct soc_enum spitz_enum[] = { + SOC_ENUM_SINGLE_EXT(5, jack_function), + SOC_ENUM_SINGLE_EXT(2, spk_function), +}; + +static const struct snd_kcontrol_new wm8750_spitz_controls[] = { + SOC_ENUM_EXT("Jack Function", spitz_enum[0], spitz_get_jack, + spitz_set_jack), + SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk, + spitz_set_spk), +}; + +/* + * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device + */ +static int spitz_wm8750_init(struct snd_soc_codec *codec) +{ + int i, err; + + /* NC codec pins */ + snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0); + snd_soc_dapm_set_endpoint(codec, "LINPUT2", 0); + snd_soc_dapm_set_endpoint(codec, "RINPUT2", 0); + snd_soc_dapm_set_endpoint(codec, "LINPUT3", 0); + snd_soc_dapm_set_endpoint(codec, "RINPUT3", 0); + snd_soc_dapm_set_endpoint(codec, "OUT3", 0); + snd_soc_dapm_set_endpoint(codec, "MONO", 0); + + /* Add spitz specific controls */ + for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); + if (err < 0) + return err; + } + + /* Add spitz specific widgets */ + for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); + } + + /* Set up spitz specific audio path audio_map */ + for (i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_sync_endpoints(codec); + return 0; +} + +static unsigned int spitz_config_sysclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) +{ + if (info->bclk_master & SND_SOC_DAIFMT_CBS_CFS) { + /* pxa2xx is i2s master */ + switch (info->rate) { + case 11025: + case 22050: + case 44100: + case 88200: + /* configure codec digital filters + * for 11.025, 22.05, 44.1, 88.2 */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + 11289600); + break; + default: + /* configure codec digital filters for all other rates */ + rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + SPITZ_AUDIO_CLOCK); + break; + } + /* configure pxa2xx i2s interface clocks as master */ + return rtd->cpu_dai->config_sysclk(rtd->cpu_dai, info, + SPITZ_AUDIO_CLOCK); + } else { + /* codec is i2s master - only configure codec DAI clock */ + return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, + SPITZ_AUDIO_CLOCK); + } +} + +/* spitz digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link spitz_dai = { + .name = "wm8750", + .stream_name = "WM8750", + .cpu_dai = &pxa_i2s_dai, + .codec_dai = &wm8750_dai, + .init = spitz_wm8750_init, + .config_sysclk = spitz_config_sysclk, +}; + +/* spitz audio machine driver */ +static struct snd_soc_machine snd_soc_machine_spitz = { + .name = "Spitz", + .dai_link = &spitz_dai, + .num_links = 1, + .ops = &spitz_ops, +}; + +/* spitz audio private data */ +static struct wm8750_setup_data spitz_wm8750_setup = { + .i2c_address = 0x1b, +}; + +/* spitz audio subsystem */ +static struct snd_soc_device spitz_snd_devdata = { + .machine = &snd_soc_machine_spitz, + .platform = &pxa2xx_soc_platform, + .codec_dev = &soc_codec_dev_wm8750, + .codec_data = &spitz_wm8750_setup, +}; + +static struct platform_device *spitz_snd_device; + +static int __init spitz_init(void) +{ + int ret; + + if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) + return -ENODEV; + + spitz_snd_device = platform_device_alloc("soc-audio", -1); + if (!spitz_snd_device) + return -ENOMEM; + + platform_set_drvdata(spitz_snd_device, &spitz_snd_devdata); + spitz_snd_devdata.dev = &spitz_snd_device->dev; + ret = platform_device_add(spitz_snd_device); + + if (ret) + platform_device_put(spitz_snd_device); + + return ret; +} + +static void __exit spitz_exit(void) +{ + platform_device_unregister(spitz_snd_device); +} + +module_init(spitz_init); +module_exit(spitz_exit); + +MODULE_AUTHOR("Richard Purdie"); +MODULE_DESCRIPTION("ALSA SoC Spitz"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c new file mode 100644 index 0000000..8c3c6b0 --- /dev/null +++ b/sound/soc/pxa/tosa.c @@ -0,0 +1,287 @@ +/* + * tosa.c -- SoC audio for Tosa + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Authors: Liam Girdwood + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 30th Nov 2005 Initial version. + * + * GPIO's + * 1 - Jack Insertion + * 5 - Hookswitch (headset answer/hang up switch) + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../codecs/wm9712.h" +#include "pxa2xx-pcm.h" + +static struct snd_soc_machine tosa; + +#define TOSA_HP 0 +#define TOSA_MIC_INT 1 +#define TOSA_HEADSET 2 +#define TOSA_HP_OFF 3 +#define TOSA_SPK_ON 0 +#define TOSA_SPK_OFF 1 + +static int tosa_jack_func; +static int tosa_spk_func; + +static void tosa_ext_control(struct snd_soc_codec *codec) +{ + int spk = 0, mic_int = 0, hp = 0, hs = 0; + + /* set up jack connection */ + switch (tosa_jack_func) { + case TOSA_HP: + hp = 1; + break; + case TOSA_MIC_INT: + mic_int = 1; + break; + case TOSA_HEADSET: + hs = 1; + break; + } + + if (tosa_spk_func == TOSA_SPK_ON) + spk = 1; + + snd_soc_dapm_set_endpoint(codec, "Speaker", spk); + snd_soc_dapm_set_endpoint(codec, "Mic (Internal)", mic_int); + snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp); + snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs); + snd_soc_dapm_sync_endpoints(codec); +} + +static int tosa_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + /* check the jack status at stream startup */ + tosa_ext_control(codec); + return 0; +} + +static struct snd_soc_ops tosa_ops = { + .startup = tosa_startup, +}; + +static int tosa_get_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = tosa_jack_func; + return 0; +} + +static int tosa_set_jack(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (tosa_jack_func == ucontrol->value.integer.value[0]) + return 0; + + tosa_jack_func = ucontrol->value.integer.value[0]; + tosa_ext_control(codec); + return 1; +} + +static int tosa_get_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = tosa_spk_func; + return 0; +} + +static int tosa_set_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + + if (tosa_spk_func == ucontrol->value.integer.value[0]) + return 0; + + tosa_spk_func = ucontrol->value.integer.value[0]; + tosa_ext_control(codec); + return 1; +} + +/* tosa dapm event handlers */ +static int tosa_hp_event(struct snd_soc_dapm_widget *w, int event) +{ + if (SND_SOC_DAPM_EVENT_ON(event)) + set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE); + else + reset_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE); + return 0; +} + +/* tosa machine dapm widgets */ +static const struct snd_soc_dapm_widget tosa_dapm_widgets[] = { +SND_SOC_DAPM_HP("Headphone Jack", tosa_hp_event), +SND_SOC_DAPM_HP("Headset Jack", NULL), +SND_SOC_DAPM_MIC("Mic (Internal)", NULL), +SND_SOC_DAPM_SPK("Speaker", NULL), +}; + +/* tosa audio map */ +static const char *audio_map[][3] = { + + /* headphone connected to HPOUTL, HPOUTR */ + {"Headphone Jack", NULL, "HPOUTL"}, + {"Headphone Jack", NULL, "HPOUTR"}, + + /* ext speaker connected to LOUT2, ROUT2 */ + {"Speaker", NULL, "LOUT2"}, + {"Speaker", NULL, "ROUT2"}, + + /* internal mic is connected to mic1, mic2 differential - with bias */ + {"MIC1", NULL, "Mic Bias"}, + {"MIC2", NULL, "Mic Bias"}, + {"Mic Bias", NULL, "Mic (Internal)"}, + + /* headset is connected to HPOUTR, and LINEINR with bias */ + {"Headset Jack", NULL, "HPOUTR"}, + {"LINEINR", NULL, "Mic Bias"}, + {"Mic Bias", NULL, "Headset Jack"}, + + {NULL, NULL, NULL}, +}; + +static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", + "Off"}; +static const char *spk_function[] = {"On", "Off"}; +static const struct soc_enum tosa_enum[] = { + SOC_ENUM_SINGLE_EXT(5, jack_function), + SOC_ENUM_SINGLE_EXT(2, spk_function), +}; + +static const struct snd_kcontrol_new tosa_controls[] = { + SOC_ENUM_EXT("Jack Function", tosa_enum[0], tosa_get_jack, + tosa_set_jack), + SOC_ENUM_EXT("Speaker Function", tosa_enum[1], tosa_get_spk, + tosa_set_spk), +}; + +static int tosa_ac97_init(struct snd_soc_codec *codec) +{ + int i, err; + + snd_soc_dapm_set_endpoint(codec, "OUT3", 0); + snd_soc_dapm_set_endpoint(codec, "MONOOUT", 0); + + /* add tosa specific controls */ + for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&tosa_controls[i],codec, NULL)); + if (err < 0) + return err; + } + + /* add tosa specific widgets */ + for (i = 0; i < ARRAY_SIZE(tosa_dapm_widgets); i++) { + snd_soc_dapm_new_control(codec, &tosa_dapm_widgets[i]); + } + + /* set up tosa specific audio path audio_map */ + for (i = 0; audio_map[i][0] != NULL; i++) { + snd_soc_dapm_connect_input(codec, audio_map[i][0], + audio_map[i][1], audio_map[i][2]); + } + + snd_soc_dapm_sync_endpoints(codec); + return 0; +} + +static struct snd_soc_dai_link tosa_dai[] = { +{ + .name = "AC97", + .stream_name = "AC97 HiFi", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI], + .init = tosa_ac97_init, +}, +{ + .name = "AC97 Aux", + .stream_name = "AC97 Aux", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX], +}, +}; + +static struct snd_soc_machine tosa = { + .name = "Tosa", + .dai_link = tosa_dai, + .num_links = ARRAY_SIZE(tosa_dai), + .ops = &tosa_ops, +}; + +static struct snd_soc_device tosa_snd_devdata = { + .machine = &tosa, + .platform = &pxa2xx_soc_platform, + .codec_dev = &soc_codec_dev_wm9712, +}; + +static struct platform_device *tosa_snd_device; + +static int __init tosa_init(void) +{ + int ret; + + if (!machine_is_tosa()) + return -ENODEV; + + tosa_snd_device = platform_device_alloc("soc-audio", -1); + if (!tosa_snd_device) + return -ENOMEM; + + platform_set_drvdata(tosa_snd_device, &tosa_snd_devdata); + tosa_snd_devdata.dev = &tosa_snd_device->dev; + ret = platform_device_add(tosa_snd_device); + + if (ret) + platform_device_put(tosa_snd_device); + + return ret; +} + +static void __exit tosa_exit(void) +{ + platform_device_unregister(tosa_snd_device); +} + +module_init(tosa_init); +module_exit(tosa_exit); + +/* Module information */ +MODULE_AUTHOR("Richard Purdie"); +MODULE_DESCRIPTION("ALSA SoC Tosa"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c new file mode 100644 index 0000000..cf84d82 --- /dev/null +++ b/sound/soc/soc-core.c @@ -0,0 +1,2051 @@ +/* + * soc-core.c -- ALSA SoC Audio Layer + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * Author: Liam Girdwood + * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com + * with code, comments and ideas from :- + * Richard Purdie + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 12th Aug 2005 Initial version. + * 25th Oct 2005 Working Codec, Interface and Platform registration. + * + * TODO: + * o Add hw rules to enforce rates, etc. + * o More testing with other codecs/machines. + * o Add more codecs and platforms to ensure good API coverage. + * o Support TDM on PCM and I2S + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* debug */ +#define SOC_DEBUG 0 +#if SOC_DEBUG +#define dbg(format, arg...) printk(format, ## arg) +#else +#define dbg(format, arg...) +#endif +/* debug DAI capabilities matching */ +#define SOC_DEBUG_DAI 0 +#if SOC_DEBUG_DAI +#define dbgc(format, arg...) printk(format, ## arg) +#else +#define dbgc(format, arg...) +#endif + +#define CODEC_CPU(codec, cpu) ((codec << 4) | cpu) + +static DEFINE_MUTEX(pcm_mutex); +static DEFINE_MUTEX(io_mutex); +static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq); + +/* supported sample rates */ +/* ATTENTION: these values depend on the definition in pcm.h! */ +static const unsigned int rates[] = { + 5512, 8000, 11025, 16000, 22050, 32000, 44100, + 48000, 64000, 88200, 96000, 176400, 192000 +}; + +/* + * This is a timeout to do a DAPM powerdown after a stream is closed(). + * It can be used to eliminate pops between different playback streams, e.g. + * between two audio tracks. + */ +static int pmdown_time = 5000; +module_param(pmdown_time, int, 0); +MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); + +#ifdef CONFIG_SND_SOC_AC97_BUS +/* unregister ac97 codec */ +static int soc_ac97_dev_unregister(struct snd_soc_codec *codec) +{ + if (codec->ac97->dev.bus) + device_unregister(&codec->ac97->dev); + return 0; +} + +/* stop no dev release warning */ +static void soc_ac97_device_release(struct device *dev){} + +/* register ac97 codec to bus */ +static int soc_ac97_dev_register(struct snd_soc_codec *codec) +{ + int err; + + codec->ac97->dev.bus = &ac97_bus_type; + codec->ac97->dev.parent = NULL; + codec->ac97->dev.release = soc_ac97_device_release; + + snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s", + codec->card->number, 0, codec->name); + err = device_register(&codec->ac97->dev); + if (err < 0) { + snd_printk(KERN_ERR "Can't register ac97 bus\n"); + codec->ac97->dev.bus = NULL; + return err; + } + return 0; +} +#endif + +static inline const char* get_dai_name(int type) +{ + switch(type) { + case SND_SOC_DAI_AC97: + return "AC97"; + case SND_SOC_DAI_I2S: + return "I2S"; + case SND_SOC_DAI_PCM: + return "PCM"; + } + return NULL; +} + +/* get rate format from rate */ +static inline int soc_get_rate_format(int rate) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(rates); i++) { + if (rates[i] == rate) + return 1 << i; + } + return 0; +} + +/* gets the audio system mclk/sysclk for the given parameters */ +static unsigned inline int soc_get_mclk(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_clock_info *info) +{ + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_machine *machine = socdev->machine; + int i; + + /* find the matching machine config and get it's mclk for the given + * sample rate and hardware format */ + for(i = 0; i < machine->num_links; i++) { + if (machine->dai_link[i].cpu_dai == rtd->cpu_dai && + machine->dai_link[i].config_sysclk) + return machine->dai_link[i].config_sysclk(rtd, info); + } + return 0; +} + +/* changes a bitclk multiplier mask to a divider mask */ +static u64 soc_bfs_rcw_to_div(u64 bfs, int rate, unsigned int mclk, + unsigned int pcmfmt, unsigned int chn) +{ + int i, j; + u64 bfs_ = 0; + int size = snd_pcm_format_physical_width(pcmfmt), min = 0; + + if (size <= 0) + return 0; + + /* the minimum bit clock that has enough bandwidth */ + min = size * rate * chn; + dbgc("rcw --> div min bclk %d with mclk %d\n", min, mclk); + + for (i = 0; i < 64; i++) { + if ((bfs >> i) & 0x1) { + j = min * (i + 1); + bfs_ |= SND_SOC_FSBD(mclk/j); + dbgc("rcw --> div support mult %d\n", + SND_SOC_FSBD_REAL(1<> i) & 0x1) { + j = mclk / (i + 1); + if (j >= min) { + bfs_ |= SND_SOC_FSBW(j/min); + dbgc("div --> rcw support div %d\n", + SND_SOC_FSBW_REAL(1< rcw min bclk %d with mclk %d\n", min, mclk); + + if (bfs_ < min) + return 0; + else { + bfs_ = SND_SOC_FSBW(bfs_/min); + dbgc("rate --> rcw support div %d\n", SND_SOC_FSBW_REAL(bfs_)); + return bfs_; + } +} + +/* changes a bitclk multiplier mask to a divider mask */ +static u64 soc_bfs_rate_to_div(u64 bfs, int rate, unsigned int mclk, + unsigned int pcmfmt, unsigned int chn) +{ + unsigned int bfs_ = rate * bfs; + int size = snd_pcm_format_physical_width(pcmfmt), min = 0; + + if (size <= 0) + return 0; + + /* the minimum bit clock that has enough bandwidth */ + min = size * rate * chn; + dbgc("rate --> div min bclk %d with mclk %d\n", min, mclk); + + if (bfs_ < min) + return 0; + else { + bfs_ = SND_SOC_FSBW(mclk/bfs_); + dbgc("rate --> div support div %d\n", SND_SOC_FSBD_REAL(bfs_)); + return bfs_; + } +} + +/* Matches codec DAI and SoC CPU DAI hardware parameters */ +static int soc_hw_match_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai_mode *codec_dai_mode = NULL; + struct snd_soc_dai_mode *cpu_dai_mode = NULL; + struct snd_soc_clock_info clk_info; + unsigned int fs, mclk, rate = params_rate(params), + chn, j, k, cpu_bclk, codec_bclk, pcmrate; + u16 fmt = 0; + u64 codec_bfs, cpu_bfs; + + dbg("asoc: match version %s\n", SND_SOC_VERSION); + clk_info.rate = rate; + pcmrate = soc_get_rate_format(rate); + + /* try and find a match from the codec and cpu DAI capabilities */ + for (j = 0; j < rtd->codec_dai->caps.num_modes; j++) { + for (k = 0; k < rtd->cpu_dai->caps.num_modes; k++) { + codec_dai_mode = &rtd->codec_dai->caps.mode[j]; + cpu_dai_mode = &rtd->cpu_dai->caps.mode[k]; + + if (!(codec_dai_mode->pcmrate & cpu_dai_mode->pcmrate & + pcmrate)) { + dbgc("asoc: DAI[%d:%d] failed to match rate\n", j, k); + continue; + } + + fmt = codec_dai_mode->fmt & cpu_dai_mode->fmt; + if (!(fmt & SND_SOC_DAIFMT_FORMAT_MASK)) { + dbgc("asoc: DAI[%d:%d] failed to match format\n", j, k); + continue; + } + + if (!(fmt & SND_SOC_DAIFMT_CLOCK_MASK)) { + dbgc("asoc: DAI[%d:%d] failed to match clock masters\n", + j, k); + continue; + } + + if (!(fmt & SND_SOC_DAIFMT_INV_MASK)) { + dbgc("asoc: DAI[%d:%d] failed to match invert\n", j, k); + continue; + } + + if (!(codec_dai_mode->pcmfmt & cpu_dai_mode->pcmfmt)) { + dbgc("asoc: DAI[%d:%d] failed to match pcm format\n", j, k); + continue; + } + + if (!(codec_dai_mode->pcmdir & cpu_dai_mode->pcmdir)) { + dbgc("asoc: DAI[%d:%d] failed to match direction\n", j, k); + continue; + } + + /* todo - still need to add tdm selection */ + rtd->cpu_dai->dai_runtime.fmt = + rtd->codec_dai->dai_runtime.fmt = + 1 << (ffs(fmt & SND_SOC_DAIFMT_FORMAT_MASK) -1) | + 1 << (ffs(fmt & SND_SOC_DAIFMT_CLOCK_MASK) - 1) | + 1 << (ffs(fmt & SND_SOC_DAIFMT_INV_MASK) - 1); + clk_info.bclk_master = + rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK; + + /* make sure the ratio between rate and master + * clock is acceptable*/ + fs = (cpu_dai_mode->fs & codec_dai_mode->fs); + if (fs == 0) { + dbgc("asoc: DAI[%d:%d] failed to match FS\n", j, k); + continue; + } + clk_info.fs = rtd->cpu_dai->dai_runtime.fs = + rtd->codec_dai->dai_runtime.fs = fs; + + /* calculate audio system clocking using slowest clocks possible*/ + mclk = soc_get_mclk(rtd, &clk_info); + if (mclk == 0) { + dbgc("asoc: DAI[%d:%d] configuration not clockable\n", j, k); + dbgc("asoc: rate %d fs %d master %x\n", rate, fs, + clk_info.bclk_master); + continue; + } + + /* calculate word size (per channel) and frame size */ + rtd->codec_dai->dai_runtime.pcmfmt = + rtd->cpu_dai->dai_runtime.pcmfmt = + 1 << params_format(params); + + chn = params_channels(params); + /* i2s always has left and right */ + if (params_channels(params) == 1 && + rtd->cpu_dai->dai_runtime.fmt & (SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_LEFT_J)) + chn <<= 1; + + /* Calculate bfs - the ratio between bitclock and the sample rate + * We must take into consideration the dividers and multipliers + * used in the codec and cpu DAI modes. We always choose the + * lowest possible clocks to reduce power. + */ + switch (CODEC_CPU(codec_dai_mode->flags, cpu_dai_mode->flags)) { + case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_DIV): + /* cpu & codec bfs dividers */ + rtd->cpu_dai->dai_runtime.bfs = + rtd->codec_dai->dai_runtime.bfs = + 1 << (fls(codec_dai_mode->bfs & cpu_dai_mode->bfs) - 1); + break; + case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_RCW): + /* normalise bfs codec divider & cpu rcw mult */ + codec_bfs = soc_bfs_div_to_rcw(codec_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + rtd->cpu_dai->dai_runtime.bfs = + 1 << (ffs(codec_bfs & cpu_dai_mode->bfs) - 1); + cpu_bfs = soc_bfs_rcw_to_div(cpu_dai_mode->bfs, rate, mclk, + rtd->codec_dai->dai_runtime.pcmfmt, chn); + rtd->codec_dai->dai_runtime.bfs = + 1 << (fls(codec_dai_mode->bfs & cpu_bfs) - 1); + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_DIV): + /* normalise bfs codec rcw mult & cpu divider */ + codec_bfs = soc_bfs_rcw_to_div(codec_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + rtd->cpu_dai->dai_runtime.bfs = + 1 << (fls(codec_bfs & cpu_dai_mode->bfs) -1); + cpu_bfs = soc_bfs_div_to_rcw(cpu_dai_mode->bfs, rate, mclk, + rtd->codec_dai->dai_runtime.pcmfmt, chn); + rtd->codec_dai->dai_runtime.bfs = + 1 << (ffs(codec_dai_mode->bfs & cpu_bfs) -1); + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_RCW): + /* codec & cpu bfs rate rcw multipliers */ + rtd->cpu_dai->dai_runtime.bfs = + rtd->codec_dai->dai_runtime.bfs = + 1 << (ffs(codec_dai_mode->bfs & cpu_dai_mode->bfs) -1); + break; + case CODEC_CPU(SND_SOC_DAI_BFS_DIV, SND_SOC_DAI_BFS_RATE): + /* normalise cpu bfs rate const multiplier & codec div */ + cpu_bfs = soc_bfs_rate_to_div(cpu_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + if(codec_dai_mode->bfs & cpu_bfs) { + rtd->codec_dai->dai_runtime.bfs = cpu_bfs; + rtd->cpu_dai->dai_runtime.bfs = cpu_dai_mode->bfs; + } else + rtd->cpu_dai->dai_runtime.bfs = 0; + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RCW, SND_SOC_DAI_BFS_RATE): + /* normalise cpu bfs rate const multiplier & codec rcw mult */ + cpu_bfs = soc_bfs_rate_to_rcw(cpu_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + if(codec_dai_mode->bfs & cpu_bfs) { + rtd->codec_dai->dai_runtime.bfs = cpu_bfs; + rtd->cpu_dai->dai_runtime.bfs = cpu_dai_mode->bfs; + } else + rtd->cpu_dai->dai_runtime.bfs = 0; + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_RCW): + /* normalise cpu bfs rate rcw multiplier & codec const mult */ + codec_bfs = soc_bfs_rate_to_rcw(codec_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + if(cpu_dai_mode->bfs & codec_bfs) { + rtd->cpu_dai->dai_runtime.bfs = codec_bfs; + rtd->codec_dai->dai_runtime.bfs = codec_dai_mode->bfs; + } else + rtd->cpu_dai->dai_runtime.bfs = 0; + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_DIV): + /* normalise cpu bfs div & codec const mult */ + codec_bfs = soc_bfs_rate_to_div(codec_dai_mode->bfs, rate, + mclk, rtd->codec_dai->dai_runtime.pcmfmt, chn); + if(cpu_dai_mode->bfs & codec_bfs) { + rtd->cpu_dai->dai_runtime.bfs = codec_bfs; + rtd->codec_dai->dai_runtime.bfs = codec_dai_mode->bfs; + } else + rtd->cpu_dai->dai_runtime.bfs = 0; + break; + case CODEC_CPU(SND_SOC_DAI_BFS_RATE, SND_SOC_DAI_BFS_RATE): + /* cpu & codec constant mult */ + if(codec_dai_mode->bfs == cpu_dai_mode->bfs) + rtd->cpu_dai->dai_runtime.bfs = + rtd->codec_dai->dai_runtime.bfs = + codec_dai_mode->bfs; + else + rtd->cpu_dai->dai_runtime.bfs = + rtd->codec_dai->dai_runtime.bfs = 0; + break; + } + + /* make sure the bit clock speed is acceptable */ + if (!rtd->cpu_dai->dai_runtime.bfs || + !rtd->codec_dai->dai_runtime.bfs) { + dbgc("asoc: DAI[%d:%d] failed to match BFS\n", j, k); + dbgc("asoc: cpu_dai %llu codec %llu\n", + rtd->cpu_dai->dai_runtime.bfs, + rtd->codec_dai->dai_runtime.bfs); + dbgc("asoc: mclk %d hwfmt %x\n", mclk, fmt); + continue; + } + + goto found; + } + } + printk(KERN_ERR "asoc: no matching DAI found between codec and CPU\n"); + return -EINVAL; + +found: + /* we have matching DAI's, so complete the runtime info */ + rtd->codec_dai->dai_runtime.pcmrate = + rtd->cpu_dai->dai_runtime.pcmrate = + soc_get_rate_format(rate); + + rtd->codec_dai->dai_runtime.priv = codec_dai_mode->priv; + rtd->cpu_dai->dai_runtime.priv = cpu_dai_mode->priv; + rtd->codec_dai->dai_runtime.flags = codec_dai_mode->flags; + rtd->cpu_dai->dai_runtime.flags = cpu_dai_mode->flags; + + /* for debug atm */ + dbg("asoc: DAI[%d:%d] Match OK\n", j, k); + if (rtd->codec_dai->dai_runtime.flags == SND_SOC_DAI_BFS_DIV) { + codec_bclk = (rtd->codec_dai->dai_runtime.fs * params_rate(params)) / + SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs); + dbg("asoc: codec fs %d mclk %d bfs div %d bclk %d\n", + rtd->codec_dai->dai_runtime.fs, mclk, + SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs), codec_bclk); + } else if(rtd->codec_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RATE) { + codec_bclk = params_rate(params) * rtd->codec_dai->dai_runtime.bfs; + dbg("asoc: codec fs %d mclk %d bfs rate mult %llu bclk %d\n", + rtd->codec_dai->dai_runtime.fs, mclk, + rtd->codec_dai->dai_runtime.bfs, codec_bclk); + } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RCW) { + codec_bclk = params_rate(params) * params_channels(params) * + snd_pcm_format_physical_width(rtd->codec_dai->dai_runtime.pcmfmt) * + SND_SOC_FSBW_REAL(rtd->codec_dai->dai_runtime.bfs); + dbg("asoc: codec fs %d mclk %d bfs rcw mult %d bclk %d\n", + rtd->codec_dai->dai_runtime.fs, mclk, + SND_SOC_FSBW_REAL(rtd->codec_dai->dai_runtime.bfs), codec_bclk); + } else + codec_bclk = 0; + + if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_DIV) { + cpu_bclk = (rtd->cpu_dai->dai_runtime.fs * params_rate(params)) / + SND_SOC_FSBD_REAL(rtd->cpu_dai->dai_runtime.bfs); + dbg("asoc: cpu fs %d mclk %d bfs div %d bclk %d\n", + rtd->cpu_dai->dai_runtime.fs, mclk, + SND_SOC_FSBD_REAL(rtd->cpu_dai->dai_runtime.bfs), cpu_bclk); + } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RATE) { + cpu_bclk = params_rate(params) * rtd->cpu_dai->dai_runtime.bfs; + dbg("asoc: cpu fs %d mclk %d bfs rate mult %llu bclk %d\n", + rtd->cpu_dai->dai_runtime.fs, mclk, + rtd->cpu_dai->dai_runtime.bfs, cpu_bclk); + } else if (rtd->cpu_dai->dai_runtime.flags == SND_SOC_DAI_BFS_RCW) { + cpu_bclk = params_rate(params) * params_channels(params) * + snd_pcm_format_physical_width(rtd->cpu_dai->dai_runtime.pcmfmt) * + SND_SOC_FSBW_REAL(rtd->cpu_dai->dai_runtime.bfs); + dbg("asoc: cpu fs %d mclk %d bfs mult rcw %d bclk %d\n", + rtd->cpu_dai->dai_runtime.fs, mclk, + SND_SOC_FSBW_REAL(rtd->cpu_dai->dai_runtime.bfs), cpu_bclk); + } else + cpu_bclk = 0; + + /* + * Check we have matching bitclocks. If we don't then it means the + * sysclock returned by either the codec or cpu DAI (selected by the + * machine sysclock function) is wrong compared with the supported DAI + * modes for the codec or cpu DAI. Check your codec or CPU DAI + * config_sysclock() functions. + */ + if (cpu_bclk != codec_bclk && cpu_bclk){ + printk(KERN_ERR + "asoc: codec and cpu bitclocks differ, audio may be wrong speed\n" + ); + printk(KERN_ERR "asoc: codec %d != cpu %d\n", codec_bclk, cpu_bclk); + } + + switch(rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + dbg("asoc: DAI codec BCLK master, LRC master\n"); + break; + case SND_SOC_DAIFMT_CBS_CFM: + dbg("asoc: DAI codec BCLK slave, LRC master\n"); + break; + case SND_SOC_DAIFMT_CBM_CFS: + dbg("asoc: DAI codec BCLK master, LRC slave\n"); + break; + case SND_SOC_DAIFMT_CBS_CFS: + dbg("asoc: DAI codec BCLK slave, LRC slave\n"); + break; + } + dbg("asoc: mode %x, invert %x\n", + rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_FORMAT_MASK, + rtd->cpu_dai->dai_runtime.fmt & SND_SOC_DAIFMT_INV_MASK); + dbg("asoc: audio rate %d chn %d fmt %x\n", params_rate(params), + params_channels(params), params_format(params)); + + return 0; +} + +static inline u32 get_rates(struct snd_soc_dai_mode *modes, int nmodes) +{ + int i; + u32 rates = 0; + + for(i = 0; i < nmodes; i++) + rates |= modes[i].pcmrate; + + return rates; +} + +static inline u64 get_formats(struct snd_soc_dai_mode *modes, int nmodes) +{ + int i; + u64 formats = 0; + + for(i = 0; i < nmodes; i++) + formats |= modes[i].pcmfmt; + + return formats; +} + +/* + * Called by ALSA when a PCM substream is opened, the runtime->hw record is + * then initialized and any private data can be allocated. This also calls + * startup for the cpu DAI, platform, machine and codec DAI. + */ +static int soc_pcm_open(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec_dai *codec_dai = rtd->codec_dai; + struct snd_soc_cpu_dai *cpu_dai = rtd->cpu_dai; + int ret = 0; + + mutex_lock(&pcm_mutex); + + /* startup the audio subsystem */ + if (rtd->cpu_dai->ops.startup) { + ret = rtd->cpu_dai->ops.startup(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: can't open interface %s\n", + rtd->cpu_dai->name); + goto out; + } + } + + if (platform->pcm_ops->open) { + ret = platform->pcm_ops->open(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: can't open platform %s\n", platform->name); + goto platform_err; + } + } + + if (machine->ops && machine->ops->startup) { + ret = machine->ops->startup(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: %s startup failed\n", machine->name); + goto machine_err; + } + } + + if (rtd->codec_dai->ops.startup) { + ret = rtd->codec_dai->ops.startup(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: can't open codec %s\n", + rtd->codec_dai->name); + goto codec_dai_err; + } + } + + /* create runtime params from DMA, codec and cpu DAI */ + if (runtime->hw.rates) + runtime->hw.rates &= + get_rates(codec_dai->caps.mode, codec_dai->caps.num_modes) & + get_rates(cpu_dai->caps.mode, cpu_dai->caps.num_modes); + else + runtime->hw.rates = + get_rates(codec_dai->caps.mode, codec_dai->caps.num_modes) & + get_rates(cpu_dai->caps.mode, cpu_dai->caps.num_modes); + if (runtime->hw.formats) + runtime->hw.formats &= + get_formats(codec_dai->caps.mode, codec_dai->caps.num_modes) & + get_formats(cpu_dai->caps.mode, cpu_dai->caps.num_modes); + else + runtime->hw.formats = + get_formats(codec_dai->caps.mode, codec_dai->caps.num_modes) & + get_formats(cpu_dai->caps.mode, cpu_dai->caps.num_modes); + + /* Check that the codec and cpu DAI's are compatible */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + runtime->hw.rate_min = + max(rtd->codec_dai->playback.rate_min, + rtd->cpu_dai->playback.rate_min); + runtime->hw.rate_max = + min(rtd->codec_dai->playback.rate_max, + rtd->cpu_dai->playback.rate_max); + runtime->hw.channels_min = + max(rtd->codec_dai->playback.channels_min, + rtd->cpu_dai->playback.channels_min); + runtime->hw.channels_max = + min(rtd->codec_dai->playback.channels_max, + rtd->cpu_dai->playback.channels_max); + } else { + runtime->hw.rate_min = + max(rtd->codec_dai->capture.rate_min, + rtd->cpu_dai->capture.rate_min); + runtime->hw.rate_max = + min(rtd->codec_dai->capture.rate_max, + rtd->cpu_dai->capture.rate_max); + runtime->hw.channels_min = + max(rtd->codec_dai->capture.channels_min, + rtd->cpu_dai->capture.channels_min); + runtime->hw.channels_max = + min(rtd->codec_dai->capture.channels_max, + rtd->cpu_dai->capture.channels_max); + } + + snd_pcm_limit_hw_rates(runtime); + if (!runtime->hw.rates) { + printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", + rtd->codec_dai->name, rtd->cpu_dai->name); + goto codec_dai_err; + } + if (!runtime->hw.formats) { + printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", + rtd->codec_dai->name, rtd->cpu_dai->name); + goto codec_dai_err; + } + if (!runtime->hw.channels_min || !runtime->hw.channels_max) { + printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", + rtd->codec_dai->name, rtd->cpu_dai->name); + goto codec_dai_err; + } + + dbg("asoc: %s <-> %s info:\n", rtd->codec_dai->name, rtd->cpu_dai->name); + dbg("asoc: rate mask 0x%x\n", runtime->hw.rates); + dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, + runtime->hw.channels_max); + dbg("asoc: min rate %d max rate %d\n", runtime->hw.rate_min, + runtime->hw.rate_max); + + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->cpu_dai->playback.active = rtd->codec_dai->playback.active = 1; + else + rtd->cpu_dai->capture.active = rtd->codec_dai->capture.active = 1; + rtd->cpu_dai->active = rtd->codec_dai->active = 1; + rtd->cpu_dai->runtime = runtime; + socdev->codec->active++; + mutex_unlock(&pcm_mutex); + return 0; + +codec_dai_err: + if (machine->ops && machine->ops->shutdown) + machine->ops->shutdown(substream); + +machine_err: + if (platform->pcm_ops->close) + platform->pcm_ops->close(substream); + +platform_err: + if (rtd->cpu_dai->ops.shutdown) + rtd->cpu_dai->ops.shutdown(substream); +out: + mutex_unlock(&pcm_mutex); + return ret; +} + +/* + * Power down the audio subsytem pmdown_time msecs after close is called. + * This is to ensure there are no pops or clicks in between any music tracks + * due to DAPM power cycling. + */ +static void close_delayed_work(struct work_struct *work) +{ + struct snd_soc_device *socdev = + container_of(work, struct snd_soc_device, delayed_work.work); + struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec_dai *codec_dai; + int i; + + mutex_lock(&pcm_mutex); + for(i = 0; i < codec->num_dai; i++) { + codec_dai = &codec->dai[i]; + + dbg("pop wq checking: %s status: %s waiting: %s\n", + codec_dai->playback.stream_name, + codec_dai->playback.active ? "active" : "inactive", + codec_dai->pop_wait ? "yes" : "no"); + + /* are we waiting on this codec DAI stream */ + if (codec_dai->pop_wait == 1) { + + codec_dai->pop_wait = 0; + snd_soc_dapm_stream_event(codec, codec_dai->playback.stream_name, + SND_SOC_DAPM_STREAM_STOP); + + /* power down the codec power domain if no longer active */ + if (codec->active == 0) { + dbg("pop wq D3 %s %s\n", codec->name, + codec_dai->playback.stream_name); + if (codec->dapm_event) + codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot); + } + } + } + mutex_unlock(&pcm_mutex); +} + +/* + * Called by ALSA when a PCM substream is closed. Private data can be + * freed here. The cpu DAI, codec DAI, machine and platform are also + * shutdown. + */ +static int soc_codec_close(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec *codec = socdev->codec; + + mutex_lock(&pcm_mutex); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->cpu_dai->playback.active = rtd->codec_dai->playback.active = 0; + else + rtd->cpu_dai->capture.active = rtd->codec_dai->capture.active = 0; + + if (rtd->codec_dai->playback.active == 0 && + rtd->codec_dai->capture.active == 0) { + rtd->cpu_dai->active = rtd->codec_dai->active = 0; + } + codec->active--; + + if (rtd->cpu_dai->ops.shutdown) + rtd->cpu_dai->ops.shutdown(substream); + + if (rtd->codec_dai->ops.shutdown) + rtd->codec_dai->ops.shutdown(substream); + + if (machine->ops && machine->ops->shutdown) + machine->ops->shutdown(substream); + + if (platform->pcm_ops->close) + platform->pcm_ops->close(substream); + rtd->cpu_dai->runtime = NULL; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + /* start delayed pop wq here for playback streams */ + rtd->codec_dai->pop_wait = 1; + schedule_delayed_work(&socdev->delayed_work, + msecs_to_jiffies(pmdown_time)); + } else { + /* capture streams can be powered down now */ + snd_soc_dapm_stream_event(codec, rtd->codec_dai->capture.stream_name, + SND_SOC_DAPM_STREAM_STOP); + + if (codec->active == 0 && rtd->codec_dai->pop_wait == 0){ + if (codec->dapm_event) + codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot); + } + } + + mutex_unlock(&pcm_mutex); + return 0; +} + +/* + * Called by ALSA when the PCM substream is prepared, can set format, sample + * rate, etc. This function is non atomic and can be called multiple times, + * it can refer to the runtime info. + */ +static int soc_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec *codec = socdev->codec; + int ret = 0; + + mutex_lock(&pcm_mutex); + if (platform->pcm_ops->prepare) { + ret = platform->pcm_ops->prepare(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: platform prepare error\n"); + goto out; + } + } + + if (rtd->codec_dai->ops.prepare) { + ret = rtd->codec_dai->ops.prepare(substream); + if (ret < 0) { + printk(KERN_ERR "asoc: codec DAI prepare error\n"); + goto out; + } + } + + if (rtd->cpu_dai->ops.prepare) + ret = rtd->cpu_dai->ops.prepare(substream); + + /* we only want to start a DAPM playback stream if we are not waiting + * on an existing one stopping */ + if (rtd->codec_dai->pop_wait) { + /* we are waiting for the delayed work to start */ + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + snd_soc_dapm_stream_event(codec, + rtd->codec_dai->capture.stream_name, + SND_SOC_DAPM_STREAM_START); + else { + rtd->codec_dai->pop_wait = 0; + cancel_delayed_work(&socdev->delayed_work); + if (rtd->codec_dai->digital_mute) + rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0); + } + } else { + /* no delayed work - do we need to power up codec */ + if (codec->dapm_state != SNDRV_CTL_POWER_D0) { + + if (codec->dapm_event) + codec->dapm_event(codec, SNDRV_CTL_POWER_D1); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_dapm_stream_event(codec, + rtd->codec_dai->playback.stream_name, + SND_SOC_DAPM_STREAM_START); + else + snd_soc_dapm_stream_event(codec, + rtd->codec_dai->capture.stream_name, + SND_SOC_DAPM_STREAM_START); + + if (codec->dapm_event) + codec->dapm_event(codec, SNDRV_CTL_POWER_D0); + if (rtd->codec_dai->digital_mute) + rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0); + + } else { + /* codec already powered - power on widgets */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_dapm_stream_event(codec, + rtd->codec_dai->playback.stream_name, + SND_SOC_DAPM_STREAM_START); + else + snd_soc_dapm_stream_event(codec, + rtd->codec_dai->capture.stream_name, + SND_SOC_DAPM_STREAM_START); + if (rtd->codec_dai->digital_mute) + rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 0); + } + } + +out: + mutex_unlock(&pcm_mutex); + return ret; +} + +/* + * Called by ALSA when the hardware params are set by application. This + * function can also be called multiple times and can allocate buffers + * (using snd_pcm_lib_* ). It's non-atomic. + */ +static int soc_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_machine *machine = socdev->machine; + int ret = 0; + + mutex_lock(&pcm_mutex); + + /* we don't need to match any AC97 params */ + if (rtd->cpu_dai->type != SND_SOC_DAI_AC97) { + ret = soc_hw_match_params(substream, params); + if (ret < 0) + goto out; + } else { + struct snd_soc_clock_info clk_info; + clk_info.rate = params_rate(params); + ret = soc_get_mclk(rtd, &clk_info); + if (ret < 0) + goto out; + } + + if (rtd->codec_dai->ops.hw_params) { + ret = rtd->codec_dai->ops.hw_params(substream, params); + if (ret < 0) { + printk(KERN_ERR "asoc: can't set codec %s hw params\n", + rtd->codec_dai->name); + goto out; + } + } + + if (rtd->cpu_dai->ops.hw_params) { + ret = rtd->cpu_dai->ops.hw_params(substream, params); + if (ret < 0) { + printk(KERN_ERR "asoc: can't set interface %s hw params\n", + rtd->cpu_dai->name); + goto interface_err; + } + } + + if (platform->pcm_ops->hw_params) { + ret = platform->pcm_ops->hw_params(substream, params); + if (ret < 0) { + printk(KERN_ERR "asoc: can't set platform %s hw params\n", + platform->name); + goto platform_err; + } + } + + if (machine->ops && machine->ops->hw_params) { + ret = machine->ops->hw_params(substream, params); + if (ret < 0) { + printk(KERN_ERR "asoc: machine hw_params failed\n"); + goto machine_err; + } + } + +out: + mutex_unlock(&pcm_mutex); + return ret; + +machine_err: + if (platform->pcm_ops->hw_free) + platform->pcm_ops->hw_free(substream); + +platform_err: + if (rtd->cpu_dai->ops.hw_free) + rtd->cpu_dai->ops.hw_free(substream); + +interface_err: + if (rtd->codec_dai->ops.hw_free) + rtd->codec_dai->ops.hw_free(substream); + + mutex_unlock(&pcm_mutex); + return ret; +} + +/* + * Free's resources allocated by hw_params, can be called multiple times + */ +static int soc_pcm_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_machine *machine = socdev->machine; + + mutex_lock(&pcm_mutex); + + /* apply codec digital mute */ + if (!codec->active && rtd->codec_dai->digital_mute) + rtd->codec_dai->digital_mute(codec, rtd->codec_dai, 1); + + /* free any machine hw params */ + if (machine->ops && machine->ops->hw_free) + machine->ops->hw_free(substream); + + /* free any DMA resources */ + if (platform->pcm_ops->hw_free) + platform->pcm_ops->hw_free(substream); + + /* now free hw params for the DAI's */ + if (rtd->codec_dai->ops.hw_free) + rtd->codec_dai->ops.hw_free(substream); + + if (rtd->cpu_dai->ops.hw_free) + rtd->cpu_dai->ops.hw_free(substream); + + mutex_unlock(&pcm_mutex); + return 0; +} + +static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_platform *platform = socdev->platform; + int ret; + + if (rtd->codec_dai->ops.trigger) { + ret = rtd->codec_dai->ops.trigger(substream, cmd); + if (ret < 0) + return ret; + } + + if (platform->pcm_ops->trigger) { + ret = platform->pcm_ops->trigger(substream, cmd); + if (ret < 0) + return ret; + } + + if (rtd->cpu_dai->ops.trigger) { + ret = rtd->cpu_dai->ops.trigger(substream, cmd); + if (ret < 0) + return ret; + } + return 0; +} + +/* ASoC PCM operations */ +static struct snd_pcm_ops soc_pcm_ops = { + .open = soc_pcm_open, + .close = soc_codec_close, + .hw_params = soc_pcm_hw_params, + .hw_free = soc_pcm_hw_free, + .prepare = soc_pcm_prepare, + .trigger = soc_pcm_trigger, +}; + +#ifdef CONFIG_PM +/* powers down audio subsystem for suspend */ +static int soc_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec_device *codec_dev = socdev->codec_dev; + struct snd_soc_codec *codec = socdev->codec; + int i; + + /* mute any active DAC's */ + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; + if (dai->digital_mute && dai->playback.active) + dai->digital_mute(codec, dai, 1); + } + + if (machine->suspend_pre) + machine->suspend_pre(pdev, state); + + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97) + cpu_dai->suspend(pdev, cpu_dai); + if (platform->suspend) + platform->suspend(pdev, cpu_dai); + } + + /* close any waiting streams and save state */ + flush_scheduled_work(); + codec->suspend_dapm_state = codec->dapm_state; + + for(i = 0; i < codec->num_dai; i++) { + char *stream = codec->dai[i].playback.stream_name; + if (stream != NULL) + snd_soc_dapm_stream_event(codec, stream, + SND_SOC_DAPM_STREAM_SUSPEND); + stream = codec->dai[i].capture.stream_name; + if (stream != NULL) + snd_soc_dapm_stream_event(codec, stream, + SND_SOC_DAPM_STREAM_SUSPEND); + } + + if (codec_dev->suspend) + codec_dev->suspend(pdev, state); + + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97) + cpu_dai->suspend(pdev, cpu_dai); + } + + if (machine->suspend_post) + machine->suspend_post(pdev, state); + + return 0; +} + +/* powers up audio subsystem after a suspend */ +static int soc_resume(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec_device *codec_dev = socdev->codec_dev; + struct snd_soc_codec *codec = socdev->codec; + int i; + + if (machine->resume_pre) + machine->resume_pre(pdev); + + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97) + cpu_dai->resume(pdev, cpu_dai); + } + + if (codec_dev->resume) + codec_dev->resume(pdev); + + for(i = 0; i < codec->num_dai; i++) { + char* stream = codec->dai[i].playback.stream_name; + if (stream != NULL) + snd_soc_dapm_stream_event(codec, stream, + SND_SOC_DAPM_STREAM_RESUME); + stream = codec->dai[i].capture.stream_name; + if (stream != NULL) + snd_soc_dapm_stream_event(codec, stream, + SND_SOC_DAPM_STREAM_RESUME); + } + + /* unmute any active DAC's */ + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; + if (dai->digital_mute && dai->playback.active) + dai->digital_mute(codec, dai, 0); + } + + for(i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97) + cpu_dai->resume(pdev, cpu_dai); + if (platform->resume) + platform->resume(pdev, cpu_dai); + } + + if (machine->resume_post) + machine->resume_post(pdev); + + return 0; +} + +#else +#define soc_suspend NULL +#define soc_resume NULL +#endif + +/* probes a new socdev */ +static int soc_probe(struct platform_device *pdev) +{ + int ret = 0, i; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec_device *codec_dev = socdev->codec_dev; + + if (machine->probe) { + ret = machine->probe(pdev); + if(ret < 0) + return ret; + } + + for (i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->probe) { + ret = cpu_dai->probe(pdev); + if(ret < 0) + goto cpu_dai_err; + } + } + + if (codec_dev->probe) { + ret = codec_dev->probe(pdev); + if(ret < 0) + goto cpu_dai_err; + } + + if (platform->probe) { + ret = platform->probe(pdev); + if(ret < 0) + goto platform_err; + } + + /* DAPM stream work */ + INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work); + return 0; + +platform_err: + if (codec_dev->remove) + codec_dev->remove(pdev); + +cpu_dai_err: + for (i--; i > 0; i--) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->remove) + cpu_dai->remove(pdev); + } + + if (machine->remove) + machine->remove(pdev); + + return ret; +} + +/* removes a socdev */ +static int soc_remove(struct platform_device *pdev) +{ + int i; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_machine *machine = socdev->machine; + struct snd_soc_platform *platform = socdev->platform; + struct snd_soc_codec_device *codec_dev = socdev->codec_dev; + + if (platform->remove) + platform->remove(pdev); + + if (codec_dev->remove) + codec_dev->remove(pdev); + + for (i = 0; i < machine->num_links; i++) { + struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; + if (cpu_dai->remove) + cpu_dai->remove(pdev); + } + + if (machine->remove) + machine->remove(pdev); + + return 0; +} + +/* ASoC platform driver */ +static struct platform_driver soc_driver = { + .driver = { + .name = "soc-audio", + }, + .probe = soc_probe, + .remove = soc_remove, + .suspend = soc_suspend, + .resume = soc_resume, +}; + +/* create a new pcm */ +static int soc_new_pcm(struct snd_soc_device *socdev, + struct snd_soc_dai_link *dai_link, int num) +{ + struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec_dai *codec_dai = dai_link->codec_dai; + struct snd_soc_cpu_dai *cpu_dai = dai_link->cpu_dai; + struct snd_soc_pcm_runtime *rtd; + struct snd_pcm *pcm; + char new_name[64]; + int ret = 0, playback = 0, capture = 0; + + rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL); + if (rtd == NULL) + return -ENOMEM; + rtd->cpu_dai = cpu_dai; + rtd->codec_dai = codec_dai; + rtd->socdev = socdev; + + /* check client and interface hw capabilities */ + sprintf(new_name, "%s %s-%s-%d",dai_link->stream_name, codec_dai->name, + get_dai_name(cpu_dai->type), num); + + if (codec_dai->playback.channels_min) + playback = 1; + if (codec_dai->capture.channels_min) + capture = 1; + + ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback, + capture, &pcm); + if (ret < 0) { + printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name); + kfree(rtd); + return ret; + } + + pcm->private_data = rtd; + soc_pcm_ops.mmap = socdev->platform->pcm_ops->mmap; + soc_pcm_ops.pointer = socdev->platform->pcm_ops->pointer; + soc_pcm_ops.ioctl = socdev->platform->pcm_ops->ioctl; + soc_pcm_ops.copy = socdev->platform->pcm_ops->copy; + soc_pcm_ops.silence = socdev->platform->pcm_ops->silence; + soc_pcm_ops.ack = socdev->platform->pcm_ops->ack; + soc_pcm_ops.page = socdev->platform->pcm_ops->page; + + if (playback) + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops); + + if (capture) + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops); + + ret = socdev->platform->pcm_new(codec->card, codec_dai, pcm); + if (ret < 0) { + printk(KERN_ERR "asoc: platform pcm constructor failed\n"); + kfree(rtd); + return ret; + } + + pcm->private_free = socdev->platform->pcm_free; + printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name, + cpu_dai->name); + return ret; +} + +/* codec register dump */ +static ssize_t codec_reg_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_soc_device *devdata = dev_get_drvdata(dev); + struct snd_soc_codec *codec = devdata->codec; + int i, step = 1, count = 0; + + if (!codec->reg_cache_size) + return 0; + + if (codec->reg_cache_step) + step = codec->reg_cache_step; + + count += sprintf(buf, "%s registers\n", codec->name); + for(i = 0; i < codec->reg_cache_size; i += step) + count += sprintf(buf + count, "%2x: %4x\n", i, codec->read(codec, i)); + + return count; +} +static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); + +/** + * snd_soc_new_ac97_codec - initailise AC97 device + * @codec: audio codec + * @ops: AC97 bus operations + * @num: AC97 codec number + * + * Initialises AC97 codec resources for use by ad-hoc devices only. + */ +int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, + struct snd_ac97_bus_ops *ops, int num) +{ + mutex_lock(&codec->mutex); + + codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); + if (codec->ac97 == NULL) { + mutex_unlock(&codec->mutex); + return -ENOMEM; + } + + codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL); + if (codec->ac97->bus == NULL) { + kfree(codec->ac97); + codec->ac97 = NULL; + mutex_unlock(&codec->mutex); + return -ENOMEM; + } + + codec->ac97->bus->ops = ops; + codec->ac97->num = num; + mutex_unlock(&codec->mutex); + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); + +/** + * snd_soc_free_ac97_codec - free AC97 codec device + * @codec: audio codec + * + * Frees AC97 codec device resources. + */ +void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) +{ + mutex_lock(&codec->mutex); + kfree(codec->ac97->bus); + kfree(codec->ac97); + codec->ac97 = NULL; + mutex_unlock(&codec->mutex); +} +EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); + +/** + * snd_soc_update_bits - update codec register bits + * @codec: audio codec + * @reg: codec register + * @mask: register mask + * @value: new value + * + * Writes new register value. + * + * Returns 1 for change else 0. + */ +int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned short mask, unsigned short value) +{ + int change; + unsigned short old, new; + + mutex_lock(&io_mutex); + old = snd_soc_read(codec, reg); + new = (old & ~mask) | value; + change = old != new; + if (change) + snd_soc_write(codec, reg, new); + + mutex_unlock(&io_mutex); + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_update_bits); + +/** + * snd_soc_test_bits - test register for change + * @codec: audio codec + * @reg: codec register + * @mask: register mask + * @value: new value + * + * Tests a register with a new value and checks if the new value is + * different from the old value. + * + * Returns 1 for change else 0. + */ +int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned short mask, unsigned short value) +{ + int change; + unsigned short old, new; + + mutex_lock(&io_mutex); + old = snd_soc_read(codec, reg); + new = (old & ~mask) | value; + change = old != new; + mutex_unlock(&io_mutex); + + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_test_bits); + +/** + * snd_soc_get_rate - get int sample rate + * @hwpcmrate: the hardware pcm rate + * + * Returns the audio rate integaer value, else 0. + */ +int snd_soc_get_rate(int hwpcmrate) +{ + int rate = ffs(hwpcmrate) - 1; + + if (rate > ARRAY_SIZE(rates)) + return 0; + return rates[rate]; +} +EXPORT_SYMBOL_GPL(snd_soc_get_rate); + +/** + * snd_soc_new_pcms - create new sound card and pcms + * @socdev: the SoC audio device + * + * Create a new sound card based upon the codec and interface pcms. + * + * Returns 0 for success, else error. + */ +int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char * xid) +{ + struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_machine *machine = socdev->machine; + int ret = 0, i; + + mutex_lock(&codec->mutex); + + /* register a sound card */ + codec->card = snd_card_new(idx, xid, codec->owner, 0); + if (!codec->card) { + printk(KERN_ERR "asoc: can't create sound card for codec %s\n", + codec->name); + mutex_unlock(&codec->mutex); + return -ENODEV; + } + + codec->card->dev = socdev->dev; + codec->card->private_data = codec; + strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); + + /* create the pcms */ + for(i = 0; i < machine->num_links; i++) { + ret = soc_new_pcm(socdev, &machine->dai_link[i], i); + if (ret < 0) { + printk(KERN_ERR "asoc: can't create pcm %s\n", + machine->dai_link[i].stream_name); + mutex_unlock(&codec->mutex); + return ret; + } + } + + mutex_unlock(&codec->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_new_pcms); + +/** + * snd_soc_register_card - register sound card + * @socdev: the SoC audio device + * + * Register a SoC sound card. Also registers an AC97 device if the + * codec is AC97 for ad hoc devices. + * + * Returns 0 for success, else error. + */ +int snd_soc_register_card(struct snd_soc_device *socdev) +{ + struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_machine *machine = socdev->machine; + int ret = 0, i, ac97 = 0, err = 0; + + mutex_lock(&codec->mutex); + for(i = 0; i < machine->num_links; i++) { + if (socdev->machine->dai_link[i].init) { + err = socdev->machine->dai_link[i].init(codec); + if (err < 0) { + printk(KERN_ERR "asoc: failed to init %s\n", + socdev->machine->dai_link[i].stream_name); + continue; + } + } + if (socdev->machine->dai_link[i].cpu_dai->type == SND_SOC_DAI_AC97) + ac97 = 1; + } + snprintf(codec->card->shortname, sizeof(codec->card->shortname), + "%s", machine->name); + snprintf(codec->card->longname, sizeof(codec->card->longname), + "%s (%s)", machine->name, codec->name); + + ret = snd_card_register(codec->card); + if (ret < 0) { + printk(KERN_ERR "asoc: failed to register soundcard for codec %s\n", + codec->name); + goto out; + } + +#ifdef CONFIG_SND_SOC_AC97_BUS + if (ac97) { + ret = soc_ac97_dev_register(codec); + if (ret < 0) { + printk(KERN_ERR "asoc: AC97 device register failed\n"); + snd_card_free(codec->card); + goto out; + } + } +#endif + + err = snd_soc_dapm_sys_add(socdev->dev); + if (err < 0) + printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n"); + + err = device_create_file(socdev->dev, &dev_attr_codec_reg); + if (err < 0) + printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n"); +out: + mutex_unlock(&codec->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_register_card); + +/** + * snd_soc_free_pcms - free sound card and pcms + * @socdev: the SoC audio device + * + * Frees sound card and pcms associated with the socdev. + * Also unregister the codec if it is an AC97 device. + */ +void snd_soc_free_pcms(struct snd_soc_device *socdev) +{ + struct snd_soc_codec *codec = socdev->codec; + + mutex_lock(&codec->mutex); +#ifdef CONFIG_SND_SOC_AC97_BUS + if (codec->ac97) + soc_ac97_dev_unregister(codec); +#endif + + if (codec->card) + snd_card_free(codec->card); + device_remove_file(socdev->dev, &dev_attr_codec_reg); + mutex_unlock(&codec->mutex); +} +EXPORT_SYMBOL_GPL(snd_soc_free_pcms); + +/** + * snd_soc_set_runtime_hwparams - set the runtime hardware parameters + * @substream: the pcm substream + * @hw: the hardware parameters + * + * Sets the substream runtime hardware parameters. + */ +int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, + const struct snd_pcm_hardware *hw) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + runtime->hw.info = hw->info; + runtime->hw.formats = hw->formats; + runtime->hw.period_bytes_min = hw->period_bytes_min; + runtime->hw.period_bytes_max = hw->period_bytes_max; + runtime->hw.periods_min = hw->periods_min; + runtime->hw.periods_max = hw->periods_max; + runtime->hw.buffer_bytes_max = hw->buffer_bytes_max; + runtime->hw.fifo_size = hw->fifo_size; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); + +/** + * snd_soc_cnew - create new control + * @_template: control template + * @data: control private data + * @lnng_name: control long name + * + * Create a new mixer control from a template control. + * + * Returns 0 for success, else error. + */ +struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, + void *data, char *long_name) +{ + struct snd_kcontrol_new template; + + memcpy(&template, _template, sizeof(template)); + if (long_name) + template.name = long_name; + template.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; + template.index = 0; + + return snd_ctl_new1(&template, data); +} +EXPORT_SYMBOL_GPL(snd_soc_cnew); + +/** + * snd_soc_info_enum_double - enumerated double mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a double enumerated + * mixer control. + * + * Returns 0 for success. + */ +int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = e->shift_l == e->shift_r ? 1 : 2; + uinfo->value.enumerated.items = e->mask; + + if (uinfo->value.enumerated.item > e->mask - 1) + uinfo->value.enumerated.item = e->mask - 1; + strcpy(uinfo->value.enumerated.name, + e->texts[uinfo->value.enumerated.item]); + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); + +/** + * snd_soc_get_enum_double - enumerated double mixer get callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to get the value of a double enumerated mixer. + * + * Returns 0 for success. + */ +int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val, bitmask; + + for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) + ; + val = snd_soc_read(codec, e->reg); + ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); + if (e->shift_l != e->shift_r) + ucontrol->value.enumerated.item[1] = + (val >> e->shift_r) & (bitmask - 1); + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_get_enum_double); + +/** + * snd_soc_put_enum_double - enumerated double mixer put callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to set the value of a double enumerated mixer. + * + * Returns 0 for success. + */ +int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val; + unsigned short mask, bitmask; + + for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) + ; + if (ucontrol->value.enumerated.item[0] > e->mask - 1) + return -EINVAL; + val = ucontrol->value.enumerated.item[0] << e->shift_l; + mask = (bitmask - 1) << e->shift_l; + if (e->shift_l != e->shift_r) { + if (ucontrol->value.enumerated.item[1] > e->mask - 1) + return -EINVAL; + val |= ucontrol->value.enumerated.item[1] << e->shift_r; + mask |= (bitmask - 1) << e->shift_r; + } + + return snd_soc_update_bits(codec, e->reg, mask, val); +} +EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); + +/** + * snd_soc_info_enum_ext - external enumerated single mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about an external enumerated + * single mixer. + * + * Returns 0 for success. + */ +int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = e->mask; + + if (uinfo->value.enumerated.item > e->mask - 1) + uinfo->value.enumerated.item = e->mask - 1; + strcpy(uinfo->value.enumerated.name, + e->texts[uinfo->value.enumerated.item]); + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext); + +/** + * snd_soc_info_volsw_ext - external single mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a single external mixer control. + * + * Returns 0 for success. + */ +int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + int mask = kcontrol->private_value; + + uinfo->type = + mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = mask; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext); + +/** + * snd_soc_info_bool_ext - external single boolean mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a single boolean external mixer control. + * + * Returns 0 for success. + */ +int snd_soc_info_bool_ext(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_bool_ext); + +/** + * snd_soc_info_volsw - single mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a single mixer control. + * + * Returns 0 for success. + */ +int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + int mask = (kcontrol->private_value >> 16) & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + + uinfo->type = + mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = shift == rshift ? 1 : 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = mask; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_volsw); + +/** + * snd_soc_get_volsw - single mixer get callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to get the value of a single mixer control. + * + * Returns 0 for success. + */ +int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + int mask = (kcontrol->private_value >> 16) & 0xff; + int invert = (kcontrol->private_value >> 24) & 0x01; + + ucontrol->value.integer.value[0] = + (snd_soc_read(codec, reg) >> shift) & mask; + if (shift != rshift) + ucontrol->value.integer.value[1] = + (snd_soc_read(codec, reg) >> rshift) & mask; + if (invert) { + ucontrol->value.integer.value[0] = + mask - ucontrol->value.integer.value[0]; + if (shift != rshift) + ucontrol->value.integer.value[1] = + mask - ucontrol->value.integer.value[1]; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_get_volsw); + +/** + * snd_soc_put_volsw - single mixer put callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to set the value of a single mixer control. + * + * Returns 0 for success. + */ +int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + int mask = (kcontrol->private_value >> 16) & 0xff; + int invert = (kcontrol->private_value >> 24) & 0x01; + int err; + unsigned short val, val2, val_mask; + + val = (ucontrol->value.integer.value[0] & mask); + if (invert) + val = mask - val; + val_mask = mask << shift; + val = val << shift; + if (shift != rshift) { + val2 = (ucontrol->value.integer.value[1] & mask); + if (invert) + val2 = mask - val2; + val_mask |= mask << rshift; + val |= val2 << rshift; + } + err = snd_soc_update_bits(codec, reg, val_mask, val); + return err; +} +EXPORT_SYMBOL_GPL(snd_soc_put_volsw); + +/** + * snd_soc_info_volsw_2r - double mixer info callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a double mixer control that + * spans 2 codec registers. + * + * Returns 0 for success. + */ +int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + int mask = (kcontrol->private_value >> 12) & 0xff; + + uinfo->type = + mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = mask; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r); + +/** + * snd_soc_get_volsw_2r - double mixer get callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to get the value of a double mixer control that spans 2 registers. + * + * Returns 0 for success. + */ +int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int reg2 = (kcontrol->private_value >> 24) & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int mask = (kcontrol->private_value >> 12) & 0xff; + int invert = (kcontrol->private_value >> 20) & 0x01; + + ucontrol->value.integer.value[0] = + (snd_soc_read(codec, reg) >> shift) & mask; + ucontrol->value.integer.value[1] = + (snd_soc_read(codec, reg2) >> shift) & mask; + if (invert) { + ucontrol->value.integer.value[0] = + mask - ucontrol->value.integer.value[0]; + ucontrol->value.integer.value[1] = + mask - ucontrol->value.integer.value[1]; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r); + +/** + * snd_soc_put_volsw_2r - double mixer set callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to set the value of a double mixer control that spans 2 registers. + * + * Returns 0 for success. + */ +int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int reg2 = (kcontrol->private_value >> 24) & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int mask = (kcontrol->private_value >> 12) & 0xff; + int invert = (kcontrol->private_value >> 20) & 0x01; + int err; + unsigned short val, val2, val_mask; + + val_mask = mask << shift; + val = (ucontrol->value.integer.value[0] & mask); + val2 = (ucontrol->value.integer.value[1] & mask); + + if (invert) { + val = mask - val; + val2 = mask - val2; + } + + val = val << shift; + val2 = val2 << shift; + + if ((err = snd_soc_update_bits(codec, reg, val_mask, val)) < 0) + return err; + + err = snd_soc_update_bits(codec, reg2, val_mask, val2); + return err; +} +EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r); + +static int __devinit snd_soc_init(void) +{ + printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION); + return platform_driver_register(&soc_driver); +} + +static void snd_soc_exit(void) +{ + platform_driver_unregister(&soc_driver); +} + +module_init(snd_soc_init); +module_exit(snd_soc_exit); + +/* Module information */ +MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com"); +MODULE_DESCRIPTION("ALSA SoC Core"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c new file mode 100644 index 0000000..411651d --- /dev/null +++ b/sound/soc/soc-dapm.c @@ -0,0 +1,1327 @@ +/* + * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Author: Liam Girdwood + * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 12th Aug 2005 Initial version. + * 25th Oct 2005 Implemented path power domain. + * 18th Dec 2005 Implemented machine and stream level power domain. + * + * Features: + * o Changes power status of internal codec blocks depending on the + * dynamic configuration of codec internal audio paths and active + * DAC's/ADC's. + * o Platform power domain - can support external components i.e. amps and + * mic/meadphone insertion events. + * o Automatic Mic Bias support + * o Jack insertion power event initiation - e.g. hp insertion will enable + * sinks, dacs, etc + * o Delayed powerdown of audio susbsytem to reduce pops between a quick + * device reopen. + * + * Todo: + * o DAPM power change sequencing - allow for configurable per + * codec sequences. + * o Support for analogue bias optimisation. + * o Support for reduced codec oversampling rates. + * o Support for reduced codec bias currents. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* debug */ +#define DAPM_DEBUG 0 +#if DAPM_DEBUG +#define dump_dapm(codec, action) dbg_dump_dapm(codec, action) +#define dbg(format, arg...) printk(format, ## arg) +#else +#define dump_dapm(codec, action) +#define dbg(format, arg...) +#endif + +#define POP_DEBUG 0 +#if POP_DEBUG +#define POP_TIME 500 /* 500 msecs - change if pop debug is too fast */ +#define pop_wait(time) schedule_timeout_interruptible(msecs_to_jiffies(time)) +#define pop_dbg(format, arg...) printk(format, ## arg); pop_wait(POP_TIME) +#else +#define pop_dbg(format, arg...) +#define pop_wait(time) +#endif + +/* dapm power sequences - make this per codec in the future */ +static int dapm_up_seq[] = { + snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, + snd_soc_dapm_mux, snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_pga, + snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post +}; +static int dapm_down_seq[] = { + snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, + snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, + snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post +}; + +static int dapm_status = 1; +module_param(dapm_status, int, 0); +MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries"); + +/* create a new dapm widget */ +static struct snd_soc_dapm_widget *dapm_cnew_widget( + const struct snd_soc_dapm_widget *_widget) +{ + struct snd_soc_dapm_widget* widget; + widget = kmalloc(sizeof(struct snd_soc_dapm_widget), GFP_KERNEL); + if (!widget) + return NULL; + + memcpy(widget, _widget, sizeof(struct snd_soc_dapm_widget)); + return widget; +} + +/* set up initial codec paths */ +static void dapm_set_path_status(struct snd_soc_dapm_widget *w, + struct snd_soc_dapm_path *p, int i) +{ + switch (w->id) { + case snd_soc_dapm_switch: + case snd_soc_dapm_mixer: { + int val; + int reg = w->kcontrols[i].private_value & 0xff; + int shift = (w->kcontrols[i].private_value >> 8) & 0x0f; + int mask = (w->kcontrols[i].private_value >> 16) & 0xff; + int invert = (w->kcontrols[i].private_value >> 24) & 0x01; + + val = snd_soc_read(w->codec, reg); + val = (val >> shift) & mask; + + if ((invert && !val) || (!invert && val)) + p->connect = 1; + else + p->connect = 0; + } + break; + case snd_soc_dapm_mux: { + struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value; + int val, item, bitmask; + + for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) + ; + val = snd_soc_read(w->codec, e->reg); + item = (val >> e->shift_l) & (bitmask - 1); + + p->connect = 0; + for (i = 0; i < e->mask; i++) { + if (!(strcmp(p->name, e->texts[i])) && item == i) + p->connect = 1; + } + } + break; + /* does not effect routing - always connected */ + case snd_soc_dapm_pga: + case snd_soc_dapm_output: + case snd_soc_dapm_adc: + case snd_soc_dapm_input: + case snd_soc_dapm_dac: + case snd_soc_dapm_micbias: + case snd_soc_dapm_vmid: + p->connect = 1; + break; + /* does effect routing - dynamically connected */ + case snd_soc_dapm_hp: + case snd_soc_dapm_mic: + case snd_soc_dapm_spk: + case snd_soc_dapm_line: + case snd_soc_dapm_pre: + case snd_soc_dapm_post: + p->connect = 0; + break; + } +} + +/* connect mux widget to it's interconnecting audio paths */ +static int dapm_connect_mux(struct snd_soc_codec *codec, + struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, + struct snd_soc_dapm_path *path, const char *control_name, + const struct snd_kcontrol_new *kcontrol) +{ + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + int i; + + for (i = 0; i < e->mask; i++) { + if (!(strcmp(control_name, e->texts[i]))) { + list_add(&path->list, &codec->dapm_paths); + list_add(&path->list_sink, &dest->sources); + list_add(&path->list_source, &src->sinks); + path->name = (char*)e->texts[i]; + dapm_set_path_status(dest, path, 0); + return 0; + } + } + + return -ENODEV; +} + +/* connect mixer widget to it's interconnecting audio paths */ +static int dapm_connect_mixer(struct snd_soc_codec *codec, + struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, + struct snd_soc_dapm_path *path, const char *control_name) +{ + int i; + + /* search for mixer kcontrol */ + for (i = 0; i < dest->num_kcontrols; i++) { + if (!strcmp(control_name, dest->kcontrols[i].name)) { + list_add(&path->list, &codec->dapm_paths); + list_add(&path->list_sink, &dest->sources); + list_add(&path->list_source, &src->sinks); + path->name = dest->kcontrols[i].name; + dapm_set_path_status(dest, path, i); + return 0; + } + } + return -ENODEV; +} + +/* update dapm codec register bits */ +static int dapm_update_bits(struct snd_soc_dapm_widget *widget) +{ + int change, power; + unsigned short old, new; + struct snd_soc_codec *codec = widget->codec; + + /* check for valid widgets */ + if (widget->reg < 0 || widget->id == snd_soc_dapm_input || + widget->id == snd_soc_dapm_output || + widget->id == snd_soc_dapm_hp || + widget->id == snd_soc_dapm_mic || + widget->id == snd_soc_dapm_line || + widget->id == snd_soc_dapm_spk) + return 0; + + power = widget->power; + if (widget->invert) + power = (power ? 0:1); + + old = snd_soc_read(codec, widget->reg); + new = (old & ~(0x1 << widget->shift)) | (power << widget->shift); + + change = old != new; + if (change) { + pop_dbg("pop test %s : %s in %d ms\n", widget->name, + widget->power ? "on" : "off", POP_TIME); + snd_soc_write(codec, widget->reg, new); + pop_wait(POP_TIME); + } + dbg("reg old %x new %x change %d\n", old, new, change); + return change; +} + +/* ramps the volume up or down to minimise pops before or after a + * DAPM power event */ +static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power) +{ + const struct snd_kcontrol_new *k = widget->kcontrols; + + if (widget->muted && !power) + return 0; + if (!widget->muted && power) + return 0; + + if (widget->num_kcontrols && k) { + int reg = k->private_value & 0xff; + int shift = (k->private_value >> 8) & 0x0f; + int mask = (k->private_value >> 16) & 0xff; + int invert = (k->private_value >> 24) & 0x01; + + if (power) { + int i; + /* power up has happended, increase volume to last level */ + if (invert) { + for (i = mask; i > widget->saved_value; i--) + snd_soc_update_bits(widget->codec, reg, mask, i); + } else { + for (i = 0; i < widget->saved_value; i++) + snd_soc_update_bits(widget->codec, reg, mask, i); + } + widget->muted = 0; + } else { + /* power down is about to occur, decrease volume to mute */ + int val = snd_soc_read(widget->codec, reg); + int i = widget->saved_value = (val >> shift) & mask; + if (invert) { + for (; i < mask; i++) + snd_soc_update_bits(widget->codec, reg, mask, i); + } else { + for (; i > 0; i--) + snd_soc_update_bits(widget->codec, reg, mask, i); + } + widget->muted = 1; + } + } + return 0; +} + +/* create new dapm mixer control */ +static int dapm_new_mixer(struct snd_soc_codec *codec, + struct snd_soc_dapm_widget *w) +{ + int i, ret = 0; + char name[32]; + struct snd_soc_dapm_path *path; + + /* add kcontrol */ + for (i = 0; i < w->num_kcontrols; i++) { + + /* match name */ + list_for_each_entry(path, &w->sources, list_sink) { + + /* mixer/mux paths name must match control name */ + if (path->name != (char*)w->kcontrols[i].name) + continue; + + /* add dapm control with long name */ + snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name); + path->long_name = kstrdup (name, GFP_KERNEL); + if (path->long_name == NULL) + return -ENOMEM; + + path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, + path->long_name); + ret = snd_ctl_add(codec->card, path->kcontrol); + if (ret < 0) { + printk(KERN_ERR "asoc: failed to add dapm kcontrol %s\n", + path->long_name); + kfree(path->long_name); + path->long_name = NULL; + return ret; + } + } + } + return ret; +} + +/* create new dapm mux control */ +static int dapm_new_mux(struct snd_soc_codec *codec, + struct snd_soc_dapm_widget *w) +{ + struct snd_soc_dapm_path *path = NULL; + struct snd_kcontrol *kcontrol; + int ret = 0; + + if (!w->num_kcontrols) { + printk(KERN_ERR "asoc: mux %s has no controls\n", w->name); + return -EINVAL; + } + + kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name); + ret = snd_ctl_add(codec->card, kcontrol); + if (ret < 0) + goto err; + + list_for_each_entry(path, &w->sources, list_sink) + path->kcontrol = kcontrol; + + return ret; + +err: + printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name); + return ret; +} + +/* create new dapm volume control */ +static int dapm_new_pga(struct snd_soc_codec *codec, + struct snd_soc_dapm_widget *w) +{ + struct snd_kcontrol *kcontrol; + int ret = 0; + + if (!w->num_kcontrols) + return -EINVAL; + + kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name); + ret = snd_ctl_add(codec->card, kcontrol); + if (ret < 0) { + printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name); + return ret; + } + + return ret; +} + +/* reset 'walked' bit for each dapm path */ +static inline void dapm_clear_walk(struct snd_soc_codec *codec) +{ + struct snd_soc_dapm_path *p; + + list_for_each_entry(p, &codec->dapm_paths, list) + p->walked = 0; +} + +/* + * Recursively check for a completed path to an active or physically connected + * output widget. Returns number of complete paths. + */ +static int is_connected_output_ep(struct snd_soc_dapm_widget *widget) +{ + struct snd_soc_dapm_path *path; + int con = 0; + + if (widget->id == snd_soc_dapm_adc && widget->active) + return 1; + + if (widget->connected) { + /* connected pin ? */ + if (widget->id == snd_soc_dapm_output && !widget->ext) + return 1; + + /* connected jack or spk ? */ + if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk || + widget->id == snd_soc_dapm_line) + return 1; + } + + list_for_each_entry(path, &widget->sinks, list_source) { + if (path->walked) + continue; + + if (path->sink && path->connect) { + path->walked = 1; + con += is_connected_output_ep(path->sink); + } + } + + return con; +} + +/* + * Recursively check for a completed path to an active or physically connected + * input widget. Returns number of complete paths. + */ +static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) +{ + struct snd_soc_dapm_path *path; + int con = 0; + + /* active stream ? */ + if (widget->id == snd_soc_dapm_dac && widget->active) + return 1; + + if (widget->connected) { + /* connected pin ? */ + if (widget->id == snd_soc_dapm_input && !widget->ext) + return 1; + + /* connected VMID/Bias for lower pops */ + if (widget->id == snd_soc_dapm_vmid) + return 1; + + /* connected jack ? */ + if (widget->id == snd_soc_dapm_mic || widget->id == snd_soc_dapm_line) + return 1; + } + + list_for_each_entry(path, &widget->sources, list_sink) { + if (path->walked) + continue; + + if (path->source && path->connect) { + path->walked = 1; + con += is_connected_input_ep(path->source); + } + } + + return con; +} + +/* + * Scan each dapm widget for complete audio path. + * A complete path is a route that has valid endpoints i.e.:- + * + * o DAC to output pin. + * o Input Pin to ADC. + * o Input pin to Output pin (bypass, sidetone) + * o DAC to ADC (loopback). + */ +static int dapm_power_widgets(struct snd_soc_codec *codec, int event) +{ + struct snd_soc_dapm_widget *w; + int in, out, i, c = 1, *seq = NULL, ret = 0, power_change, power; + + /* do we have a sequenced stream event */ + if (event == SND_SOC_DAPM_STREAM_START) { + c = ARRAY_SIZE(dapm_up_seq); + seq = dapm_up_seq; + } else if (event == SND_SOC_DAPM_STREAM_STOP) { + c = ARRAY_SIZE(dapm_down_seq); + seq = dapm_down_seq; + } + + for(i = 0; i < c; i++) { + list_for_each_entry(w, &codec->dapm_widgets, list) { + + /* is widget in stream order */ + if (seq && seq[i] && w->id != seq[i]) + continue; + + /* vmid - no action */ + if (w->id == snd_soc_dapm_vmid) + continue; + + /* active ADC */ + if (w->id == snd_soc_dapm_adc && w->active) { + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + w->power = (in != 0) ? 1 : 0; + dapm_update_bits(w); + continue; + } + + /* active DAC */ + if (w->id == snd_soc_dapm_dac && w->active) { + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + w->power = (out != 0) ? 1 : 0; + dapm_update_bits(w); + continue; + } + + /* programmable gain/attenuation */ + if (w->id == snd_soc_dapm_pga) { + int on; + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + w->power = on = (out != 0 && in != 0) ? 1 : 0; + + if (!on) + dapm_set_pga(w, on); /* lower volume to reduce pops */ + dapm_update_bits(w); + if (on) + dapm_set_pga(w, on); /* restore volume from zero */ + + continue; + } + + /* pre and post event widgets */ + if (w->id == snd_soc_dapm_pre) { + if (!w->event) + continue; + + if (event == SND_SOC_DAPM_STREAM_START) { + ret = w->event(w, SND_SOC_DAPM_PRE_PMU); + if (ret < 0) + return ret; + } else if (event == SND_SOC_DAPM_STREAM_STOP) { + ret = w->event(w, SND_SOC_DAPM_PRE_PMD); + if (ret < 0) + return ret; + } + continue; + } + if (w->id == snd_soc_dapm_post) { + if (!w->event) + continue; + + if (event == SND_SOC_DAPM_STREAM_START) { + ret = w->event(w, SND_SOC_DAPM_POST_PMU); + if (ret < 0) + return ret; + } else if (event == SND_SOC_DAPM_STREAM_STOP) { + ret = w->event(w, SND_SOC_DAPM_POST_PMD); + if (ret < 0) + return ret; + } + continue; + } + + /* all other widgets */ + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + power = (out != 0 && in != 0) ? 1 : 0; + power_change = (w->power == power) ? 0: 1; + w->power = power; + + /* call any power change event handlers */ + if (power_change) { + if (w->event) { + dbg("power %s event for %s flags %x\n", + w->power ? "on" : "off", w->name, w->event_flags); + if (power) { + /* power up event */ + if (w->event_flags & SND_SOC_DAPM_PRE_PMU) { + ret = w->event(w, SND_SOC_DAPM_PRE_PMU); + if (ret < 0) + return ret; + } + dapm_update_bits(w); + if (w->event_flags & SND_SOC_DAPM_POST_PMU){ + ret = w->event(w, SND_SOC_DAPM_POST_PMU); + if (ret < 0) + return ret; + } + } else { + /* power down event */ + if (w->event_flags & SND_SOC_DAPM_PRE_PMD) { + ret = w->event(w, SND_SOC_DAPM_PRE_PMD); + if (ret < 0) + return ret; + } + dapm_update_bits(w); + if (w->event_flags & SND_SOC_DAPM_POST_PMD) { + ret = w->event(w, SND_SOC_DAPM_POST_PMD); + if (ret < 0) + return ret; + } + } + } else + /* no event handler */ + dapm_update_bits(w); + } + } + } + + return ret; +} + +#if DAPM_DEBUG +static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action) +{ + struct snd_soc_dapm_widget *w; + struct snd_soc_dapm_path *p = NULL; + int in, out; + + printk("DAPM %s %s\n", codec->name, action); + + list_for_each_entry(w, &codec->dapm_widgets, list) { + + /* only display widgets that effect routing */ + switch (w->id) { + case snd_soc_dapm_pre: + case snd_soc_dapm_post: + case snd_soc_dapm_vmid: + continue; + case snd_soc_dapm_mux: + case snd_soc_dapm_output: + case snd_soc_dapm_input: + case snd_soc_dapm_switch: + case snd_soc_dapm_hp: + case snd_soc_dapm_mic: + case snd_soc_dapm_spk: + case snd_soc_dapm_line: + case snd_soc_dapm_micbias: + case snd_soc_dapm_dac: + case snd_soc_dapm_adc: + case snd_soc_dapm_pga: + case snd_soc_dapm_mixer: + if (w->name) { + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + printk("%s: %s in %d out %d\n", w->name, + w->power ? "On":"Off",in, out); + + list_for_each_entry(p, &w->sources, list_sink) { + if (p->connect) + printk(" in %s %s\n", p->name ? p->name : "static", + p->source->name); + } + list_for_each_entry(p, &w->sinks, list_source) { + p = list_entry(lp, struct snd_soc_dapm_path, list_source); + if (p->connect) + printk(" out %s %s\n", p->name ? p->name : "static", + p->sink->name); + } + } + break; + } + } +} +#endif + +/* test and update the power status of a mux widget */ +static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, + struct snd_kcontrol *kcontrol, int mask, + int val, struct soc_enum* e) +{ + struct snd_soc_dapm_path *path; + int found = 0; + + if (widget->id != snd_soc_dapm_mux) + return -ENODEV; + + if (!snd_soc_test_bits(widget->codec, e->reg, mask, val)) + return 0; + + /* find dapm widget path assoc with kcontrol */ + list_for_each_entry(path, &widget->codec->dapm_paths, list) { + if (path->kcontrol != kcontrol) + continue; + + if (!path->name || ! e->texts[val]) + continue; + + found = 1; + /* we now need to match the string in the enum to the path */ + if (!(strcmp(path->name, e->texts[val]))) + path->connect = 1; /* new connection */ + else + path->connect = 0; /* old connection must be powered down */ + } + + if (found) + dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP); + + return 0; +} + +/* test and update the power status of a mixer widget */ +static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, + struct snd_kcontrol *kcontrol, int reg, + int val_mask, int val, int invert) +{ + struct snd_soc_dapm_path *path; + int found = 0; + + if (widget->id != snd_soc_dapm_mixer) + return -ENODEV; + + if (!snd_soc_test_bits(widget->codec, reg, val_mask, val)) + return 0; + + /* find dapm widget path assoc with kcontrol */ + list_for_each_entry(path, &widget->codec->dapm_paths, list) { + if (path->kcontrol != kcontrol) + continue; + + /* found, now check type */ + found = 1; + if (val) + /* new connection */ + path->connect = invert ? 0:1; + else + /* old connection must be powered down */ + path->connect = invert ? 1:0; + break; + } + + if (found) + dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP); + + return 0; +} + +/* show dapm widget status in sys fs */ +static ssize_t dapm_widget_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_soc_device *devdata = dev_get_drvdata(dev); + struct snd_soc_codec *codec = devdata->codec; + struct snd_soc_dapm_widget *w; + int count = 0; + char *state = "not set"; + + list_for_each_entry(w, &codec->dapm_widgets, list) { + + /* only display widgets that burnm power */ + switch (w->id) { + case snd_soc_dapm_hp: + case snd_soc_dapm_mic: + case snd_soc_dapm_spk: + case snd_soc_dapm_line: + case snd_soc_dapm_micbias: + case snd_soc_dapm_dac: + case snd_soc_dapm_adc: + case snd_soc_dapm_pga: + case snd_soc_dapm_mixer: + if (w->name) + count += sprintf(buf + count, "%s: %s\n", + w->name, w->power ? "On":"Off"); + break; + default: + break; + } + } + + switch(codec->dapm_state){ + case SNDRV_CTL_POWER_D0: + state = "D0"; + break; + case SNDRV_CTL_POWER_D1: + state = "D1"; + break; + case SNDRV_CTL_POWER_D2: + state = "D2"; + break; + case SNDRV_CTL_POWER_D3hot: + state = "D3hot"; + break; + case SNDRV_CTL_POWER_D3cold: + state = "D3cold"; + break; + } + count += sprintf(buf + count, "PM State: %s\n", state); + + return count; +} + +static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); + +int snd_soc_dapm_sys_add(struct device *dev) +{ + int ret = 0; + + if (dapm_status) + ret = device_create_file(dev, &dev_attr_dapm_widget); + + return ret; +} + +static void snd_soc_dapm_sys_remove(struct device *dev) +{ + if (dapm_status) + device_remove_file(dev, &dev_attr_dapm_widget); +} + +/* free all dapm widgets and resources */ +static void dapm_free_widgets(struct snd_soc_codec *codec) +{ + struct snd_soc_dapm_widget *w, *next_w; + struct snd_soc_dapm_path *p, *next_p; + + list_for_each_entry_safe(w, next_w, &codec->dapm_widgets, list) { + list_del(&w->list); + kfree(w); + } + + list_for_each_entry_safe(p, next_p, &codec->dapm_paths, list) { + list_del(&p->list); + kfree(p->long_name); + kfree(p); + } +} + +/** + * snd_soc_dapm_sync_endpoints - scan and power dapm paths + * @codec: audio codec + * + * Walks all dapm audio paths and powers widgets according to their + * stream or path usage. + * + * Returns 0 for success. + */ +int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec) +{ + return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP); +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints); + +/** + * snd_soc_dapm_connect_input - connect dapm widgets + * @codec: audio codec + * @sink: name of target widget + * @control: mixer control name + * @source: name of source name + * + * Connects 2 dapm widgets together via a named audio path. The sink is + * the widget receiving the audio signal, whilst the source is the sender + * of the audio signal. + * + * Returns 0 for success else error. + */ +int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink, + const char * control, const char *source) +{ + struct snd_soc_dapm_path *path; + struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; + int ret = 0; + + /* find src and dest widgets */ + list_for_each_entry(w, &codec->dapm_widgets, list) { + + if (!wsink && !(strcmp(w->name, sink))) { + wsink = w; + continue; + } + if (!wsource && !(strcmp(w->name, source))) { + wsource = w; + } + } + + if (wsource == NULL || wsink == NULL) + return -ENODEV; + + path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL); + if (!path) + return -ENOMEM; + + path->source = wsource; + path->sink = wsink; + INIT_LIST_HEAD(&path->list); + INIT_LIST_HEAD(&path->list_source); + INIT_LIST_HEAD(&path->list_sink); + + /* check for external widgets */ + if (wsink->id == snd_soc_dapm_input) { + if (wsource->id == snd_soc_dapm_micbias || + wsource->id == snd_soc_dapm_mic || + wsink->id == snd_soc_dapm_line) + wsink->ext = 1; + } + if (wsource->id == snd_soc_dapm_output) { + if (wsink->id == snd_soc_dapm_spk || + wsink->id == snd_soc_dapm_hp || + wsink->id == snd_soc_dapm_line) + wsource->ext = 1; + } + + /* connect static paths */ + if (control == NULL) { + list_add(&path->list, &codec->dapm_paths); + list_add(&path->list_sink, &wsink->sources); + list_add(&path->list_source, &wsource->sinks); + path->connect = 1; + return 0; + } + + /* connect dynamic paths */ + switch(wsink->id) { + case snd_soc_dapm_adc: + case snd_soc_dapm_dac: + case snd_soc_dapm_pga: + case snd_soc_dapm_input: + case snd_soc_dapm_output: + case snd_soc_dapm_micbias: + case snd_soc_dapm_vmid: + case snd_soc_dapm_pre: + case snd_soc_dapm_post: + list_add(&path->list, &codec->dapm_paths); + list_add(&path->list_sink, &wsink->sources); + list_add(&path->list_source, &wsource->sinks); + path->connect = 1; + return 0; + case snd_soc_dapm_mux: + ret = dapm_connect_mux(codec, wsource, wsink, path, control, + &wsink->kcontrols[0]); + if (ret != 0) + goto err; + break; + case snd_soc_dapm_switch: + case snd_soc_dapm_mixer: + ret = dapm_connect_mixer(codec, wsource, wsink, path, control); + if (ret != 0) + goto err; + break; + case snd_soc_dapm_hp: + case snd_soc_dapm_mic: + case snd_soc_dapm_line: + case snd_soc_dapm_spk: + list_add(&path->list, &codec->dapm_paths); + list_add(&path->list_sink, &wsink->sources); + list_add(&path->list_source, &wsource->sinks); + path->connect = 0; + return 0; + } + return 0; + +err: + printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source, + control, sink); + kfree(path); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input); + +/** + * snd_soc_dapm_new_widgets - add new dapm widgets + * @codec: audio codec + * + * Checks the codec for any new dapm widgets and creates them if found. + * + * Returns 0 for success. + */ +int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) +{ + struct snd_soc_dapm_widget *w; + + mutex_lock(&codec->mutex); + list_for_each_entry(w, &codec->dapm_widgets, list) + { + if (w->new) + continue; + + switch(w->id) { + case snd_soc_dapm_switch: + case snd_soc_dapm_mixer: + dapm_new_mixer(codec, w); + break; + case snd_soc_dapm_mux: + dapm_new_mux(codec, w); + break; + case snd_soc_dapm_adc: + case snd_soc_dapm_dac: + case snd_soc_dapm_pga: + dapm_new_pga(codec, w); + break; + case snd_soc_dapm_input: + case snd_soc_dapm_output: + case snd_soc_dapm_micbias: + case snd_soc_dapm_spk: + case snd_soc_dapm_hp: + case snd_soc_dapm_mic: + case snd_soc_dapm_line: + case snd_soc_dapm_vmid: + case snd_soc_dapm_pre: + case snd_soc_dapm_post: + break; + } + w->new = 1; + } + + dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP); + mutex_unlock(&codec->mutex); + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); + +/** + * snd_soc_dapm_get_volsw - dapm mixer get callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to get the value of a dapm mixer control. + * + * Returns 0 for success. + */ +int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + int mask = (kcontrol->private_value >> 16) & 0xff; + int invert = (kcontrol->private_value >> 24) & 0x01; + + /* return the saved value if we are powered down */ + if (widget->id == snd_soc_dapm_pga && !widget->power) { + ucontrol->value.integer.value[0] = widget->saved_value; + return 0; + } + + ucontrol->value.integer.value[0] = + (snd_soc_read(widget->codec, reg) >> shift) & mask; + if (shift != rshift) + ucontrol->value.integer.value[1] = + (snd_soc_read(widget->codec, reg) >> rshift) & mask; + if (invert) { + ucontrol->value.integer.value[0] = + mask - ucontrol->value.integer.value[0]; + if (shift != rshift) + ucontrol->value.integer.value[1] = + mask - ucontrol->value.integer.value[1]; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); + +/** + * snd_soc_dapm_put_volsw - dapm mixer set callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to set the value of a dapm mixer control. + * + * Returns 0 for success. + */ +int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + int reg = kcontrol->private_value & 0xff; + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + int mask = (kcontrol->private_value >> 16) & 0xff; + int invert = (kcontrol->private_value >> 24) & 0x01; + unsigned short val, val2, val_mask; + int ret; + + val = (ucontrol->value.integer.value[0] & mask); + + if (invert) + val = mask - val; + val_mask = mask << shift; + val = val << shift; + if (shift != rshift) { + val2 = (ucontrol->value.integer.value[1] & mask); + if (invert) + val2 = mask - val2; + val_mask |= mask << rshift; + val |= val2 << rshift; + } + + mutex_lock(&widget->codec->mutex); + widget->value = val; + + /* save volume value if the widget is powered down */ + if (widget->id == snd_soc_dapm_pga && !widget->power) { + widget->saved_value = val; + mutex_unlock(&widget->codec->mutex); + return 1; + } + + dapm_mixer_update_power(widget, kcontrol, reg, val_mask, val, invert); + if (widget->event) { + if (widget->event_flags & SND_SOC_DAPM_PRE_REG) { + ret = widget->event(widget, SND_SOC_DAPM_PRE_REG); + if (ret < 0) + goto out; + } + ret = snd_soc_update_bits(widget->codec, reg, val_mask, val); + if (widget->event_flags & SND_SOC_DAPM_POST_REG) + ret = widget->event(widget, SND_SOC_DAPM_POST_REG); + } else + ret = snd_soc_update_bits(widget->codec, reg, val_mask, val); + +out: + mutex_unlock(&widget->codec->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); + +/** + * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to get the value of a dapm enumerated double mixer control. + * + * Returns 0 for success. + */ +int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val, bitmask; + + for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) + ; + val = snd_soc_read(widget->codec, e->reg); + ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); + if (e->shift_l != e->shift_r) + ucontrol->value.enumerated.item[1] = + (val >> e->shift_r) & (bitmask - 1); + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); + +/** + * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to set the value of a dapm enumerated double mixer control. + * + * Returns 0 for success. + */ +int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val, mux; + unsigned short mask, bitmask; + int ret = 0; + + for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) + ; + if (ucontrol->value.enumerated.item[0] > e->mask - 1) + return -EINVAL; + mux = ucontrol->value.enumerated.item[0]; + val = mux << e->shift_l; + mask = (bitmask - 1) << e->shift_l; + if (e->shift_l != e->shift_r) { + if (ucontrol->value.enumerated.item[1] > e->mask - 1) + return -EINVAL; + val |= ucontrol->value.enumerated.item[1] << e->shift_r; + mask |= (bitmask - 1) << e->shift_r; + } + + mutex_lock(&widget->codec->mutex); + widget->value = val; + dapm_mux_update_power(widget, kcontrol, mask, mux, e); + if (widget->event) { + if (widget->event_flags & SND_SOC_DAPM_PRE_REG) { + ret = widget->event(widget, SND_SOC_DAPM_PRE_REG); + if (ret < 0) + goto out; + } + ret = snd_soc_update_bits(widget->codec, e->reg, mask, val); + if (widget->event_flags & SND_SOC_DAPM_POST_REG) + ret = widget->event(widget, SND_SOC_DAPM_POST_REG); + } else + ret = snd_soc_update_bits(widget->codec, e->reg, mask, val); + +out: + mutex_unlock(&widget->codec->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); + +/** + * snd_soc_dapm_new_control - create new dapm control + * @codec: audio codec + * @widget: widget template + * + * Creates a new dapm control based upon the template. + * + * Returns 0 for success else error. + */ +int snd_soc_dapm_new_control(struct snd_soc_codec *codec, + const struct snd_soc_dapm_widget *widget) +{ + struct snd_soc_dapm_widget *w; + + if ((w = dapm_cnew_widget(widget)) == NULL) + return -ENOMEM; + + w->codec = codec; + INIT_LIST_HEAD(&w->sources); + INIT_LIST_HEAD(&w->sinks); + INIT_LIST_HEAD(&w->list); + list_add(&w->list, &codec->dapm_widgets); + + /* machine layer set ups unconnected pins and insertions */ + w->connected = 1; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control); + +/** + * snd_soc_dapm_stream_event - send a stream event to the dapm core + * @codec: audio codec + * @stream: stream name + * @event: stream event + * + * Sends a stream event to the dapm core. The core then makes any + * necessary widget power changes. + * + * Returns 0 for success else error. + */ +int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, + char *stream, int event) +{ + struct snd_soc_dapm_widget *w; + + mutex_lock(&codec->mutex); + list_for_each_entry(w, &codec->dapm_widgets, list) + { + if (!w->sname) + continue; + dbg("widget %s\n %s stream %s event %d\n", w->name, w->sname, + stream, event); + if (strstr(w->sname, stream)) { + switch(event) { + case SND_SOC_DAPM_STREAM_START: + w->active = 1; + break; + case SND_SOC_DAPM_STREAM_STOP: + w->active = 0; + break; + case SND_SOC_DAPM_STREAM_SUSPEND: + if (w->active) + w->suspend = 1; + w->active = 0; + break; + case SND_SOC_DAPM_STREAM_RESUME: + if (w->suspend) { + w->active = 1; + w->suspend = 0; + } + break; + case SND_SOC_DAPM_STREAM_PAUSE_PUSH: + break; + case SND_SOC_DAPM_STREAM_PAUSE_RELEASE: + break; + } + } + } + mutex_unlock(&codec->mutex); + + dapm_power_widgets(codec, event); + dump_dapm(codec, __FUNCTION__); + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); + +/** + * snd_soc_dapm_set_endpoint - set audio endpoint status + * @codec: audio codec + * @endpoint: audio signal endpoint (or start point) + * @status: point status + * + * Set audio endpoint status - connected or disconnected. + * + * Returns 0 for success else error. + */ +int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec, + char *endpoint, int status) +{ + struct snd_soc_dapm_widget *w; + + list_for_each_entry(w, &codec->dapm_widgets, list) { + if (!strcmp(w->name, endpoint)) { + w->connected = status; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint); + +/** + * snd_soc_dapm_free - free dapm resources + * @socdev: SoC device + * + * Free all dapm widgets and resources. + */ +void snd_soc_dapm_free(struct snd_soc_device *socdev) +{ + struct snd_soc_codec *codec = socdev->codec; + + snd_soc_dapm_sys_remove(socdev->dev); + dapm_free_widgets(codec); +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_free); + +/* Module information */ +MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com"); +MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC"); +MODULE_LICENSE("GPL"); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 4ceb09d..25a2a73 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -678,7 +678,7 @@ static s32 *dbri_cmdlock(struct snd_dbri * The JUMP cmd points to the new cmd string. * It also releases the cmdlock spinlock. * - * Lock must not be held before calling this. + * Lock must be held before calling this. */ static void dbri_cmdsend(struct snd_dbri * dbri, s32 * cmd,int len) { diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 3d7f36f..3c3da46 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -391,6 +391,16 @@ static int retire_capture_urb(struct snd return 0; } +/* + * Process after capture complete when paused. Nothing to do. + */ +static int retire_paused_capture_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, + struct urb *urb) +{ + return 0; +} + /* * prepare urb for full speed playback sync pipe @@ -493,13 +503,13 @@ static int snd_usb_audio_next_packet_siz } /* - * Prepare urb for streaming before playback starts. + * Prepare urb for streaming before playback starts or when paused. * - * We don't yet have data, so we send a frame of silence. + * We don't have any data, so we send a frame of silence. */ -static int prepare_startup_playback_urb(struct snd_usb_substream *subs, - struct snd_pcm_runtime *runtime, - struct urb *urb) +static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, + struct urb *urb) { unsigned int i, offs, counts; struct snd_urb_ctx *ctx = urb->context; @@ -622,7 +632,7 @@ static int retire_playback_urb(struct sn */ static struct snd_urb_ops audio_urb_ops[2] = { { - .prepare = prepare_startup_playback_urb, + .prepare = prepare_nodata_playback_urb, .retire = retire_playback_urb, .prepare_sync = prepare_playback_sync_urb, .retire_sync = retire_playback_sync_urb, @@ -637,7 +647,7 @@ static struct snd_urb_ops audio_urb_ops[ static struct snd_urb_ops audio_urb_ops_high_speed[2] = { { - .prepare = prepare_startup_playback_urb, + .prepare = prepare_nodata_playback_urb, .retire = retire_playback_urb, .prepare_sync = prepare_playback_sync_urb_hs, .retire_sync = retire_playback_sync_urb_hs, @@ -925,10 +935,14 @@ static int snd_usb_pcm_playback_trigger( switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: subs->ops.prepare = prepare_playback_urb; return 0; case SNDRV_PCM_TRIGGER_STOP: return deactivate_urbs(subs, 0, 0); + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + subs->ops.prepare = prepare_nodata_playback_urb; + return 0; default: return -EINVAL; } @@ -944,9 +958,16 @@ static int snd_usb_pcm_capture_trigger(s switch (cmd) { case SNDRV_PCM_TRIGGER_START: + subs->ops.retire = retire_capture_urb; return start_urbs(subs, substream->runtime); case SNDRV_PCM_TRIGGER_STOP: return deactivate_urbs(subs, 0, 0); + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + subs->ops.retire = retire_paused_capture_urb; + return 0; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + subs->ops.retire = retire_capture_urb; + return 0; default: return -EINVAL; } @@ -1505,33 +1526,20 @@ static int snd_usb_pcm_prepare(struct sn /* for playback, submit the URBs now; otherwise, the first hwptr_done * updates for all URBs would happen at the same time when starting */ if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { - subs->ops.prepare = prepare_startup_playback_urb; + subs->ops.prepare = prepare_nodata_playback_urb; return start_urbs(subs, runtime); } else return 0; } -static struct snd_pcm_hardware snd_usb_playback = -{ - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_BATCH | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER, - .buffer_bytes_max = 1024 * 1024, - .period_bytes_min = 64, - .period_bytes_max = 512 * 1024, - .periods_min = 2, - .periods_max = 1024, -}; - -static struct snd_pcm_hardware snd_usb_capture = +static struct snd_pcm_hardware snd_usb_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER, + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_PAUSE, .buffer_bytes_max = 1024 * 1024, .period_bytes_min = 64, .period_bytes_max = 512 * 1024, @@ -1904,8 +1912,7 @@ static int setup_hw_info(struct snd_pcm_ return 0; } -static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction, - struct snd_pcm_hardware *hw) +static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) { struct snd_usb_stream *as = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; @@ -1913,7 +1920,7 @@ static int snd_usb_pcm_open(struct snd_p subs->interface = -1; subs->format = 0; - runtime->hw = *hw; + runtime->hw = snd_usb_hardware; runtime->private_data = subs; subs->pcm_substream = substream; return setup_hw_info(runtime, subs); @@ -1934,7 +1941,7 @@ static int snd_usb_pcm_close(struct snd_ static int snd_usb_playback_open(struct snd_pcm_substream *substream) { - return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK, &snd_usb_playback); + return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK); } static int snd_usb_playback_close(struct snd_pcm_substream *substream) @@ -1944,7 +1951,7 @@ static int snd_usb_playback_close(struct static int snd_usb_capture_open(struct snd_pcm_substream *substream) { - return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE, &snd_usb_capture); + return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE); } static int snd_usb_capture_close(struct snd_pcm_substream *substream) @@ -2471,7 +2478,13 @@ static int parse_audio_format_rates(stru fp->nr_rates = nr_rates; fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { - unsigned int rate = fp->rate_table[r] = combine_triple(&fmt[idx]); + unsigned int rate = combine_triple(&fmt[idx]); + /* C-Media CM6501 mislabels its 96 kHz altsetting */ + if (rate == 48000 && nr_rates == 1 && + chip->usb_id == USB_ID(0x0d8c, 0x0201) && + fp->altsetting == 5 && fp->maxpacksize == 392) + rate = 96000; + fp->rate_table[r] = rate; if (rate < fp->rate_min) fp->rate_min = rate; else if (rate > fp->rate_max)